diff --git a/.codegen.json b/.codegen.json index 0d0685676..0c67f4d3f 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "205c0e9", "specHash": "5bf3652", "version": "0.1.0" } +{ "engineHash": "47ff60c", "specHash": "d068f97", "version": "0.1.0" } diff --git a/docs/README.md b/docs/README.md index 6dce8ccfc..f33f1ff46 100644 --- a/docs/README.md +++ b/docs/README.md @@ -23,6 +23,7 @@ the SDK are available by topic: * [Downloads](downloads.md) * [Emailaliases](emailaliases.md) * [Events](events.md) +* [Externalusers](externalusers.md) * [Fileclassifications](fileclassifications.md) * [Filemetadata](filemetadata.md) * [Filerequests](filerequests.md) diff --git a/docs/externalusers.md b/docs/externalusers.md new file mode 100644 index 000000000..a8d154148 --- /dev/null +++ b/docs/externalusers.md @@ -0,0 +1,32 @@ +# ExternalUsersManager + + +- [Submit job to delete external users](#submit-job-to-delete-external-users) + +## Submit job to delete external users + +Delete external users from current user enterprise. This will remove each +external user from all invited collaborations within the current enterprise. + +This operation is performed by calling function `createExternalUserSubmitDeleteJobV2025R0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/post-external-users-submit-delete-job/). + +*Currently we don't have an example for calling `createExternalUserSubmitDeleteJobV2025R0` in integration tests* + +### Arguments + +- requestBody `ExternalUsersSubmitDeleteJobRequestV2025R0` + - Request body of createExternalUserSubmitDeleteJobV2025R0 method +- headers `CreateExternalUserSubmitDeleteJobV2025R0Headers` + - Headers of createExternalUserSubmitDeleteJobV2025R0 method + + +### Returns + +This function returns a value of type `ExternalUsersSubmitDeleteJobResponseV2025R0`. + + + + diff --git a/src/main/java/com/box/sdkgen/client/BoxClient.java b/src/main/java/com/box/sdkgen/client/BoxClient.java index 61e525fa4..491f7e319 100644 --- a/src/main/java/com/box/sdkgen/client/BoxClient.java +++ b/src/main/java/com/box/sdkgen/client/BoxClient.java @@ -21,6 +21,7 @@ import com.box.sdkgen.managers.downloads.DownloadsManager; import com.box.sdkgen.managers.emailaliases.EmailAliasesManager; import com.box.sdkgen.managers.events.EventsManager; +import com.box.sdkgen.managers.externalusers.ExternalUsersManager; import com.box.sdkgen.managers.fileclassifications.FileClassificationsManager; import com.box.sdkgen.managers.filemetadata.FileMetadataManager; import com.box.sdkgen.managers.filerequests.FileRequestsManager; @@ -256,6 +257,8 @@ public class BoxClient { public final ArchivesManager archives; + public final ExternalUsersManager externalUsers; + public BoxClient(Authentication auth) { this.auth = auth; this.networkSession = new NetworkSession.Builder().baseUrls(new BaseUrls()).build(); @@ -584,6 +587,11 @@ public BoxClient(Authentication auth) { .build(); this.archives = new ArchivesManager.Builder().auth(this.auth).networkSession(this.networkSession).build(); + this.externalUsers = + new ExternalUsersManager.Builder() + .auth(this.auth) + .networkSession(this.networkSession) + .build(); } protected BoxClient(Builder builder) { @@ -914,6 +922,11 @@ protected BoxClient(Builder builder) { .build(); this.archives = new ArchivesManager.Builder().auth(this.auth).networkSession(this.networkSession).build(); + this.externalUsers = + new ExternalUsersManager.Builder() + .auth(this.auth) + .networkSession(this.networkSession) + .build(); } public FetchResponse makeRequest(FetchOptions fetchOptions) { @@ -1299,6 +1312,10 @@ public ArchivesManager getArchives() { return archives; } + public ExternalUsersManager getExternalUsers() { + return externalUsers; + } + public static class Builder { protected final Authentication auth; diff --git a/src/main/java/com/box/sdkgen/managers/externalusers/CreateExternalUserSubmitDeleteJobV2025R0Headers.java b/src/main/java/com/box/sdkgen/managers/externalusers/CreateExternalUserSubmitDeleteJobV2025R0Headers.java new file mode 100644 index 000000000..ebf269cf4 --- /dev/null +++ b/src/main/java/com/box/sdkgen/managers/externalusers/CreateExternalUserSubmitDeleteJobV2025R0Headers.java @@ -0,0 +1,63 @@ +package com.box.sdkgen.managers.externalusers; + +import static com.box.sdkgen.internal.utils.UtilsManager.mapOf; + +import com.box.sdkgen.parameters.v2025r0.boxversionheaderv2025r0.BoxVersionHeaderV2025R0; +import com.box.sdkgen.serialization.json.EnumWrapper; +import java.util.Map; + +public class CreateExternalUserSubmitDeleteJobV2025R0Headers { + + public EnumWrapper boxVersion; + + public Map extraHeaders; + + public CreateExternalUserSubmitDeleteJobV2025R0Headers() { + this.boxVersion = new EnumWrapper(BoxVersionHeaderV2025R0._2025_0); + this.extraHeaders = mapOf(); + } + + protected CreateExternalUserSubmitDeleteJobV2025R0Headers(Builder builder) { + this.boxVersion = builder.boxVersion; + this.extraHeaders = builder.extraHeaders; + } + + public EnumWrapper getBoxVersion() { + return boxVersion; + } + + public Map getExtraHeaders() { + return extraHeaders; + } + + public static class Builder { + + protected EnumWrapper boxVersion; + + protected Map extraHeaders; + + public Builder() { + this.boxVersion = new EnumWrapper(BoxVersionHeaderV2025R0._2025_0); + this.extraHeaders = mapOf(); + } + + public Builder boxVersion(BoxVersionHeaderV2025R0 boxVersion) { + this.boxVersion = new EnumWrapper(boxVersion); + return this; + } + + public Builder boxVersion(EnumWrapper boxVersion) { + this.boxVersion = boxVersion; + return this; + } + + public Builder extraHeaders(Map extraHeaders) { + this.extraHeaders = extraHeaders; + return this; + } + + public CreateExternalUserSubmitDeleteJobV2025R0Headers build() { + return new CreateExternalUserSubmitDeleteJobV2025R0Headers(this); + } + } +} diff --git a/src/main/java/com/box/sdkgen/managers/externalusers/ExternalUsersManager.java b/src/main/java/com/box/sdkgen/managers/externalusers/ExternalUsersManager.java new file mode 100644 index 000000000..9889880c5 --- /dev/null +++ b/src/main/java/com/box/sdkgen/managers/externalusers/ExternalUsersManager.java @@ -0,0 +1,101 @@ +package com.box.sdkgen.managers.externalusers; + +import static com.box.sdkgen.internal.utils.UtilsManager.convertToString; +import static com.box.sdkgen.internal.utils.UtilsManager.entryOf; +import static com.box.sdkgen.internal.utils.UtilsManager.mapOf; +import static com.box.sdkgen.internal.utils.UtilsManager.mergeMaps; +import static com.box.sdkgen.internal.utils.UtilsManager.prepareParams; + +import com.box.sdkgen.networking.auth.Authentication; +import com.box.sdkgen.networking.fetchoptions.FetchOptions; +import com.box.sdkgen.networking.fetchoptions.ResponseFormat; +import com.box.sdkgen.networking.fetchresponse.FetchResponse; +import com.box.sdkgen.networking.network.NetworkSession; +import com.box.sdkgen.schemas.v2025r0.externaluserssubmitdeletejobrequestv2025r0.ExternalUsersSubmitDeleteJobRequestV2025R0; +import com.box.sdkgen.schemas.v2025r0.externaluserssubmitdeletejobresponsev2025r0.ExternalUsersSubmitDeleteJobResponseV2025R0; +import com.box.sdkgen.serialization.json.JsonManager; +import java.util.Map; + +public class ExternalUsersManager { + + public Authentication auth; + + public NetworkSession networkSession; + + public ExternalUsersManager() { + this.networkSession = new NetworkSession(); + } + + protected ExternalUsersManager(Builder builder) { + this.auth = builder.auth; + this.networkSession = builder.networkSession; + } + + public ExternalUsersSubmitDeleteJobResponseV2025R0 createExternalUserSubmitDeleteJobV2025R0( + ExternalUsersSubmitDeleteJobRequestV2025R0 requestBody) { + return createExternalUserSubmitDeleteJobV2025R0( + requestBody, new CreateExternalUserSubmitDeleteJobV2025R0Headers()); + } + + public ExternalUsersSubmitDeleteJobResponseV2025R0 createExternalUserSubmitDeleteJobV2025R0( + ExternalUsersSubmitDeleteJobRequestV2025R0 requestBody, + CreateExternalUserSubmitDeleteJobV2025R0Headers headers) { + Map headersMap = + prepareParams( + mergeMaps( + mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))), + headers.getExtraHeaders())); + FetchResponse response = + this.networkSession + .getNetworkClient() + .fetch( + new FetchOptions.Builder( + String.join( + "", + this.networkSession.getBaseUrls().getBaseUrl(), + "/2.0/external_users/submit_delete_job"), + "POST") + .headers(headersMap) + .data(JsonManager.serialize(requestBody)) + .contentType("application/json") + .responseFormat(ResponseFormat.JSON) + .auth(this.auth) + .networkSession(this.networkSession) + .build()); + return JsonManager.deserialize( + response.getData(), ExternalUsersSubmitDeleteJobResponseV2025R0.class); + } + + public Authentication getAuth() { + return auth; + } + + public NetworkSession getNetworkSession() { + return networkSession; + } + + public static class Builder { + + protected Authentication auth; + + protected NetworkSession networkSession; + + public Builder() { + this.networkSession = new NetworkSession(); + } + + public Builder auth(Authentication auth) { + this.auth = auth; + return this; + } + + public Builder networkSession(NetworkSession networkSession) { + this.networkSession = networkSession; + return this; + } + + public ExternalUsersManager build() { + return new ExternalUsersManager(this); + } + } +} diff --git a/src/main/java/com/box/sdkgen/schemas/v2025r0/externaluserdeletionresultv2025r0/ExternalUserDeletionResultV2025R0.java b/src/main/java/com/box/sdkgen/schemas/v2025r0/externaluserdeletionresultv2025r0/ExternalUserDeletionResultV2025R0.java new file mode 100644 index 000000000..4d3d37651 --- /dev/null +++ b/src/main/java/com/box/sdkgen/schemas/v2025r0/externaluserdeletionresultv2025r0/ExternalUserDeletionResultV2025R0.java @@ -0,0 +1,105 @@ +package com.box.sdkgen.schemas.v2025r0.externaluserdeletionresultv2025r0; + +import com.box.sdkgen.internal.NullableFieldTracker; +import com.box.sdkgen.internal.SerializableObject; +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; + +@JsonFilter("nullablePropertyFilter") +public class ExternalUserDeletionResultV2025R0 extends SerializableObject { + + @JsonProperty("user_id") + protected final String userId; + + protected final long status; + + protected String detail; + + public ExternalUserDeletionResultV2025R0( + @JsonProperty("user_id") String userId, @JsonProperty("status") long status) { + super(); + this.userId = userId; + this.status = status; + } + + protected ExternalUserDeletionResultV2025R0(Builder builder) { + super(); + this.userId = builder.userId; + this.status = builder.status; + this.detail = builder.detail; + markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); + } + + public String getUserId() { + return userId; + } + + public long getStatus() { + return status; + } + + public String getDetail() { + return detail; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExternalUserDeletionResultV2025R0 casted = (ExternalUserDeletionResultV2025R0) o; + return Objects.equals(userId, casted.userId) + && Objects.equals(status, casted.status) + && Objects.equals(detail, casted.detail); + } + + @Override + public int hashCode() { + return Objects.hash(userId, status, detail); + } + + @Override + public String toString() { + return "ExternalUserDeletionResultV2025R0{" + + "userId='" + + userId + + '\'' + + ", " + + "status='" + + status + + '\'' + + ", " + + "detail='" + + detail + + '\'' + + "}"; + } + + public static class Builder extends NullableFieldTracker { + + protected final String userId; + + protected final long status; + + protected String detail; + + public Builder(String userId, long status) { + super(); + this.userId = userId; + this.status = status; + } + + public Builder detail(String detail) { + this.detail = detail; + return this; + } + + public ExternalUserDeletionResultV2025R0 build() { + return new ExternalUserDeletionResultV2025R0(this); + } + } +} diff --git a/src/main/java/com/box/sdkgen/schemas/v2025r0/externaluserssubmitdeletejobrequestv2025r0/ExternalUsersSubmitDeleteJobRequestV2025R0.java b/src/main/java/com/box/sdkgen/schemas/v2025r0/externaluserssubmitdeletejobrequestv2025r0/ExternalUsersSubmitDeleteJobRequestV2025R0.java new file mode 100644 index 000000000..e491e4a81 --- /dev/null +++ b/src/main/java/com/box/sdkgen/schemas/v2025r0/externaluserssubmitdeletejobrequestv2025r0/ExternalUsersSubmitDeleteJobRequestV2025R0.java @@ -0,0 +1,52 @@ +package com.box.sdkgen.schemas.v2025r0.externaluserssubmitdeletejobrequestv2025r0; + +import com.box.sdkgen.internal.SerializableObject; +import com.box.sdkgen.schemas.v2025r0.userreferencev2025r0.UserReferenceV2025R0; +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import java.util.Objects; + +@JsonFilter("nullablePropertyFilter") +public class ExternalUsersSubmitDeleteJobRequestV2025R0 extends SerializableObject { + + @JsonProperty("external_users") + protected final List externalUsers; + + public ExternalUsersSubmitDeleteJobRequestV2025R0( + @JsonProperty("external_users") List externalUsers) { + super(); + this.externalUsers = externalUsers; + } + + public List getExternalUsers() { + return externalUsers; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExternalUsersSubmitDeleteJobRequestV2025R0 casted = + (ExternalUsersSubmitDeleteJobRequestV2025R0) o; + return Objects.equals(externalUsers, casted.externalUsers); + } + + @Override + public int hashCode() { + return Objects.hash(externalUsers); + } + + @Override + public String toString() { + return "ExternalUsersSubmitDeleteJobRequestV2025R0{" + + "externalUsers='" + + externalUsers + + '\'' + + "}"; + } +} diff --git a/src/main/java/com/box/sdkgen/schemas/v2025r0/externaluserssubmitdeletejobresponsev2025r0/ExternalUsersSubmitDeleteJobResponseV2025R0.java b/src/main/java/com/box/sdkgen/schemas/v2025r0/externaluserssubmitdeletejobresponsev2025r0/ExternalUsersSubmitDeleteJobResponseV2025R0.java new file mode 100644 index 000000000..2f60dc80a --- /dev/null +++ b/src/main/java/com/box/sdkgen/schemas/v2025r0/externaluserssubmitdeletejobresponsev2025r0/ExternalUsersSubmitDeleteJobResponseV2025R0.java @@ -0,0 +1,47 @@ +package com.box.sdkgen.schemas.v2025r0.externaluserssubmitdeletejobresponsev2025r0; + +import com.box.sdkgen.internal.SerializableObject; +import com.box.sdkgen.schemas.v2025r0.externaluserdeletionresultv2025r0.ExternalUserDeletionResultV2025R0; +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import java.util.Objects; + +@JsonFilter("nullablePropertyFilter") +public class ExternalUsersSubmitDeleteJobResponseV2025R0 extends SerializableObject { + + protected final List entries; + + public ExternalUsersSubmitDeleteJobResponseV2025R0( + @JsonProperty("entries") List entries) { + super(); + this.entries = entries; + } + + public List getEntries() { + return entries; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExternalUsersSubmitDeleteJobResponseV2025R0 casted = + (ExternalUsersSubmitDeleteJobResponseV2025R0) o; + return Objects.equals(entries, casted.entries); + } + + @Override + public int hashCode() { + return Objects.hash(entries); + } + + @Override + public String toString() { + return "ExternalUsersSubmitDeleteJobResponseV2025R0{" + "entries='" + entries + '\'' + "}"; + } +} diff --git a/src/main/java/com/box/sdkgen/schemas/v2025r0/userreferencev2025r0/UserReferenceV2025R0.java b/src/main/java/com/box/sdkgen/schemas/v2025r0/userreferencev2025r0/UserReferenceV2025R0.java new file mode 100644 index 000000000..f47964532 --- /dev/null +++ b/src/main/java/com/box/sdkgen/schemas/v2025r0/userreferencev2025r0/UserReferenceV2025R0.java @@ -0,0 +1,93 @@ +package com.box.sdkgen.schemas.v2025r0.userreferencev2025r0; + +import com.box.sdkgen.internal.NullableFieldTracker; +import com.box.sdkgen.internal.SerializableObject; +import com.box.sdkgen.serialization.json.EnumWrapper; +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import java.util.Objects; + +@JsonFilter("nullablePropertyFilter") +public class UserReferenceV2025R0 extends SerializableObject { + + @JsonDeserialize( + using = UserReferenceV2025R0TypeField.UserReferenceV2025R0TypeFieldDeserializer.class) + @JsonSerialize( + using = UserReferenceV2025R0TypeField.UserReferenceV2025R0TypeFieldSerializer.class) + protected EnumWrapper type; + + protected final String id; + + public UserReferenceV2025R0(@JsonProperty("id") String id) { + super(); + this.id = id; + this.type = new EnumWrapper(UserReferenceV2025R0TypeField.USER); + } + + protected UserReferenceV2025R0(Builder builder) { + super(); + this.type = builder.type; + this.id = builder.id; + markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); + } + + public EnumWrapper getType() { + return type; + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserReferenceV2025R0 casted = (UserReferenceV2025R0) o; + return Objects.equals(type, casted.type) && Objects.equals(id, casted.id); + } + + @Override + public int hashCode() { + return Objects.hash(type, id); + } + + @Override + public String toString() { + return "UserReferenceV2025R0{" + "type='" + type + '\'' + ", " + "id='" + id + '\'' + "}"; + } + + public static class Builder extends NullableFieldTracker { + + protected EnumWrapper type; + + protected final String id; + + public Builder(String id) { + super(); + this.id = id; + this.type = + new EnumWrapper(UserReferenceV2025R0TypeField.USER); + } + + public Builder type(UserReferenceV2025R0TypeField type) { + this.type = new EnumWrapper(type); + return this; + } + + public Builder type(EnumWrapper type) { + this.type = type; + return this; + } + + public UserReferenceV2025R0 build() { + return new UserReferenceV2025R0(this); + } + } +} diff --git a/src/main/java/com/box/sdkgen/schemas/v2025r0/userreferencev2025r0/UserReferenceV2025R0TypeField.java b/src/main/java/com/box/sdkgen/schemas/v2025r0/userreferencev2025r0/UserReferenceV2025R0TypeField.java new file mode 100644 index 000000000..e930f325a --- /dev/null +++ b/src/main/java/com/box/sdkgen/schemas/v2025r0/userreferencev2025r0/UserReferenceV2025R0TypeField.java @@ -0,0 +1,62 @@ +package com.box.sdkgen.schemas.v2025r0.userreferencev2025r0; + +import com.box.sdkgen.serialization.json.EnumWrapper; +import com.box.sdkgen.serialization.json.Valuable; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import java.io.IOException; +import java.util.Arrays; + +public enum UserReferenceV2025R0TypeField implements Valuable { + USER("user"); + + private final String value; + + UserReferenceV2025R0TypeField(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static class UserReferenceV2025R0TypeFieldDeserializer + extends JsonDeserializer> { + + public UserReferenceV2025R0TypeFieldDeserializer() { + super(); + } + + @Override + public EnumWrapper deserialize( + JsonParser p, DeserializationContext ctxt) throws IOException { + String value = p.getValueAsString(); + return Arrays.stream(UserReferenceV2025R0TypeField.values()) + .filter((v) -> v.getValue().equalsIgnoreCase(value)) + .findFirst() + .map(EnumWrapper::new) + .orElse(new EnumWrapper(value)); + } + } + + public static class UserReferenceV2025R0TypeFieldSerializer + extends JsonSerializer> { + + public UserReferenceV2025R0TypeFieldSerializer() { + super(); + } + + @Override + public void serialize( + EnumWrapper value, + JsonGenerator gen, + SerializerProvider serializers) + throws IOException { + gen.writeString(value.getStringValue()); + } + } +}