-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds the ability to create bulk user exports. With this update, a new request type of `StatusCodeRequest` was added in order to handle queries against the `job_error` endpoint which report the error result of a given job. Please note: With this change, consumers of the API will be responsible for fetching and decompressing the `gzip` file produced from the job request via the URL provided in the response.
- Loading branch information
Manny Batule
committed
Sep 19, 2018
1 parent
772daf1
commit 096c30e
Showing
14 changed files
with
722 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.auth0.json.mgmt.jobs; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* Class that represents an Auth0 Job Error object. Related to the {@link com.auth0.client.mgmt.JobsEntity} entity. | ||
*/ | ||
@SuppressWarnings({"unused", "WeakerAccess"}) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class JobError { | ||
|
||
@JsonProperty("statusCode") | ||
private Integer statusCode; | ||
@JsonProperty("message") | ||
private String message; | ||
|
||
@JsonCreator | ||
public JobError(@JsonProperty("statusCode") Integer statusCode, @JsonProperty("message") String message) { | ||
this.statusCode = statusCode; | ||
this.message = message; | ||
} | ||
|
||
@JsonProperty("statusCode") | ||
public Integer getStatusCode() { | ||
return statusCode; | ||
} | ||
|
||
@JsonProperty("message") | ||
public String getMessage() { | ||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.auth0.json.mgmt.jobs; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Class that represents an Auth0 Users Export object. Related to the {@link com.auth0.client.mgmt.JobsEntity} entity. | ||
*/ | ||
@SuppressWarnings({"unused", "WeakerAccess"}) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class UsersExport { | ||
|
||
@JsonProperty("connection_id") | ||
private String connectionId; | ||
@JsonProperty("format") | ||
private String format; | ||
@JsonProperty("limit") | ||
private int limit; | ||
@JsonProperty("fields") | ||
private List<List<Map<String, String>>> fields = null; | ||
|
||
@JsonCreator | ||
public UsersExport() {} | ||
|
||
@JsonCreator | ||
public UsersExport( | ||
@JsonProperty("connection_id") String connectionId, | ||
@JsonProperty("format") String format, | ||
@JsonProperty("limit") int limit, | ||
@JsonProperty("fields") List<List<Map<String, String>>> fields) { | ||
this.connectionId = connectionId; | ||
this.format = format; | ||
this.limit = limit; | ||
this.fields = fields; | ||
} | ||
|
||
@JsonProperty("connection_id") | ||
public String getConnectionId() { return connectionId; } | ||
|
||
@JsonProperty("connection_id") | ||
public void setConnectionId(final String connectionId) { | ||
this.connectionId = connectionId; | ||
} | ||
|
||
@JsonProperty("format") | ||
public String getFormat() { return format; } | ||
|
||
@JsonProperty("format") | ||
public void setFormat(final String format) { | ||
this.format = format; | ||
} | ||
|
||
@JsonProperty("limit") | ||
public int getLimit() { return limit; } | ||
|
||
@JsonProperty("limit") | ||
public void setFields(final List<List<Map<String, String>>> fields) { | ||
this.fields = fields; | ||
} | ||
|
||
@JsonProperty("fields") | ||
public List<List<Map<String, String>>> getFields() { return fields; } | ||
|
||
@JsonProperty("fields") | ||
public void setLimit(final int limit) { | ||
this.limit = limit; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.auth0.net; | ||
|
||
import com.auth0.exception.APIException; | ||
import com.auth0.exception.Auth0Exception; | ||
import com.auth0.json.mgmt.jobs.JobError; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import okhttp3.OkHttpClient; | ||
import okhttp3.RequestBody; | ||
import okhttp3.Response; | ||
import okhttp3.ResponseBody; | ||
|
||
import java.io.IOException; | ||
|
||
public class StatusCodeRequest extends EmptyBodyRequest<JobError> { | ||
|
||
public StatusCodeRequest(final OkHttpClient client, final String url) { | ||
super(client, url, "GET", new TypeReference<JobError>() {}); | ||
} | ||
|
||
@Override | ||
protected RequestBody createBody() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected JobError parseResponse(final Response response) throws Auth0Exception { | ||
if (!response.isSuccessful()) { | ||
throw createResponseException(response); | ||
} | ||
|
||
try (final ResponseBody body = response.body()) { | ||
final String payload = body.string(); | ||
return new JobError(response.code(), payload); | ||
} catch (final IOException e) { | ||
throw new APIException("Failed to parse response", response.code(), e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.