diff --git a/README.md b/README.md index 65eaf7b9d3..d6c9f3f284 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ Service Name | Artifact Coordinates [Open Service Broker](https://cloud.ibm.com/apidocs/resource-controller/ibm-cloud-osb-api) | com.ibm.cloud:open-service-broker:0.10.0 [Resource Controller](https://cloud.ibm.com/apidocs/resource-controller/resource-controller) | com.ibm.cloud:resource-controller:0.10.0 [Resource Manager](https://cloud.ibm.com/apidocs/resource-controller/resource-manager) | com.ibm.cloud:resource-manager:0.10.0 +[User Management](https://cloud.ibm.com/apidocs/user-management) | com.ibm.cloud:user-management:0.10.0 ## Prerequisites diff --git a/modules/coverage-reports/pom.xml b/modules/coverage-reports/pom.xml index 4bb1067392..55903dc483 100644 --- a/modules/coverage-reports/pom.xml +++ b/modules/coverage-reports/pom.xml @@ -83,6 +83,11 @@ resource-manager ${project.version} + + ${project.groupId} + user-management + ${project.version} + diff --git a/modules/user-management/pom.xml b/modules/user-management/pom.xml new file mode 100644 index 0000000000..069c537c4c --- /dev/null +++ b/modules/user-management/pom.xml @@ -0,0 +1,78 @@ + + 4.0.0 + + + + platform-services + com.ibm.cloud + 99-SNAPSHOT + ../.. + + + + user-management + + + IBM Cloud User Management API + jar + + + + com.ibm.cloud + sdk-core + + + + platform-services-common + com.ibm.cloud + + + + platform-services-common + ${project.groupId} + test-jar + tests + test + + + org.testng + testng + test + + + com.squareup.okhttp3 + mockwebserver + test + + + org.json + json + 20180130 + + + com.cloudant + cloudant-client + 2.19.0 + + + org.powermock + powermock-api-mockito2 + test + + + org.powermock + powermock-module-testng + test + + + + + + IBM Cloud DevX SDK Development + devxsdk@us.ibm.com + https://www.ibm.com/ + + + + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/UserManagement.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/UserManagement.java new file mode 100644 index 0000000000..f2dc861d83 --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/UserManagement.java @@ -0,0 +1,338 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-79b061f4-20200806-065240 + */ + +package com.ibm.cloud.platform_services.user_management.v1; + +import com.google.gson.JsonObject; +import com.ibm.cloud.platform_services.common.SdkCommon; +import com.ibm.cloud.platform_services.user_management.v1.model.GetUserProfileOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.GetUserSettingsOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.InviteUsersOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.ListUsersOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.RemoveUsersOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.UpdateUserProfilesOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.UpdateUserSettingsOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.UserList; +import com.ibm.cloud.platform_services.user_management.v1.model.UserProfile; +import com.ibm.cloud.platform_services.user_management.v1.model.UserSettings; +import com.ibm.cloud.sdk.core.http.RequestBuilder; +import com.ibm.cloud.sdk.core.http.ResponseConverter; +import com.ibm.cloud.sdk.core.http.ServiceCall; +import com.ibm.cloud.sdk.core.security.Authenticator; +import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; +import com.ibm.cloud.sdk.core.service.BaseService; +import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; +import java.util.Map; +import java.util.Map.Entry; + +/** + * Manage the lifecycle of your users using User Management APIs. + * + * @version v1 + */ +public class UserManagement extends BaseService { + + public static final String DEFAULT_SERVICE_NAME = "user_management"; + + public static final String DEFAULT_SERVICE_URL = "https://user-management.cloud.ibm.com"; + + /** + * Class method which constructs an instance of the `UserManagement` client. + * The default service name is used to configure the client instance. + * + * @return an instance of the `UserManagement` client using external configuration + */ + public static UserManagement newInstance() { + return newInstance(DEFAULT_SERVICE_NAME); + } + + /** + * Class method which constructs an instance of the `UserManagement` client. + * The specified service name is used to configure the client instance. + * + * @param serviceName the service name to be used when configuring the client instance + * @return an instance of the `UserManagement` client using external configuration + */ + public static UserManagement newInstance(String serviceName) { + Authenticator authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName); + UserManagement service = new UserManagement(serviceName, authenticator); + service.configureService(serviceName); + return service; + } + + /** + * Constructs an instance of the `UserManagement` client. + * The specified service name and authenticator are used to configure the client instance. + * + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client + */ + public UserManagement(String serviceName, Authenticator authenticator) { + super(serviceName, authenticator); + setServiceUrl(DEFAULT_SERVICE_URL); + } + + /** + * Get user settings. + * + * Retrieve a user's settings by the user's IAM ID. You can use the IAM service token or a user token for + * authorization. To use this method, the requesting user or service ID must have the viewer, editor, or administrator + * role on the User Management service. <br/><br/>The user settings have several fields. The `language` + * field is the language setting for the user interface display language. The `notification_language` field is the + * language setting for phone and email notifications. The `allowed_ip_addresses` field specifies a list of IP + * addresses that the user can log in and perform operations from as described in [Allowing specific IP addresses for + * a user](/docs/account?topic=account-ips). For information about the `self_manage` field, review information about + * the [user-managed login setting](/docs/account?topic=account-types). + * + * @param getUserSettingsOptions the {@link GetUserSettingsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link UserSettings} + */ + public ServiceCall getUserSettings(GetUserSettingsOptions getUserSettingsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getUserSettingsOptions, + "getUserSettingsOptions cannot be null"); + String[] pathSegments = { "v2/accounts", "users", "settings" }; + String[] pathParameters = { getUserSettingsOptions.accountId(), getUserSettingsOptions.iamId() }; + RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + Map sdkHeaders = SdkCommon.getSdkHeaders("user_management", "v1", "getUserSettings"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Partially update user settings. + * + * Update a user's settings by the user's IAM ID. You can use the IAM service token or a user token for authorization. + * To fully use this method, the user or service ID must have the editor or administrator role on the User Management + * service. Without these roles, a user can update only their own `language` or `notification_language` fields. If + * `self_manage` is `true`, the user can also update the `allowed_ip_addresses` field. + * + * @param updateUserSettingsOptions the {@link UpdateUserSettingsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link UserSettings} + */ + public ServiceCall updateUserSettings(UpdateUserSettingsOptions updateUserSettingsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(updateUserSettingsOptions, + "updateUserSettingsOptions cannot be null"); + String[] pathSegments = { "v2/accounts", "users", "settings" }; + String[] pathParameters = { updateUserSettingsOptions.accountId(), updateUserSettingsOptions.iamId() }; + RequestBuilder builder = RequestBuilder.patch(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + Map sdkHeaders = SdkCommon.getSdkHeaders("user_management", "v1", "updateUserSettings"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + if (updateUserSettingsOptions.language() != null) { + contentJson.addProperty("language", updateUserSettingsOptions.language()); + } + if (updateUserSettingsOptions.notificationLanguage() != null) { + contentJson.addProperty("notification_language", updateUserSettingsOptions.notificationLanguage()); + } + if (updateUserSettingsOptions.allowedIpAddresses() != null) { + contentJson.addProperty("allowed_ip_addresses", updateUserSettingsOptions.allowedIpAddresses()); + } + if (updateUserSettingsOptions.selfManage() != null) { + contentJson.addProperty("self_manage", updateUserSettingsOptions.selfManage()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List users. + * + * Retrieve users in the account. You can use the IAM service token or a user token for authorization. To use this + * method, the requesting user or service ID must have at least the viewer, editor, or administrator role on the User + * Management service. If unrestricted view is enabled, the user can see all users in the same account without an IAM + * role. If restricted view is enabled and user has the viewer, editor, or administrator role on the user management + * service, the API returns all users in the account. If unrestricted view is enabled and the user does not have these + * roles, the API returns only the current user. Users are returned in a paginated list with a default limit of 100 + * users. You can iterate through all users by following the `next_url` field. + * + * @param listUsersOptions the {@link ListUsersOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link UserList} + */ + public ServiceCall listUsers(ListUsersOptions listUsersOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(listUsersOptions, + "listUsersOptions cannot be null"); + String[] pathSegments = { "v2/accounts", "users" }; + String[] pathParameters = { listUsersOptions.accountId() }; + RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + Map sdkHeaders = SdkCommon.getSdkHeaders("user_management", "v1", "listUsers"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (listUsersOptions.state() != null) { + builder.query("state", listUsersOptions.state()); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Invite users. + * + * Invite users to the account. You must use a user token for authorization. Service IDs can't invite users to the + * account. To use this method, the requesting user must have the editor or administrator role on the User Management + * service. For more information, see the [Inviting users](/docs/account?topic=account-iamuserinv) documentation. You + * can specify the user account role and the corresponding IAM policy information in the request body. + * <br/><br/>When you invite a user to an account, the user is initially created in the `PROCESSING` + * state. After the user is successfully created, all specified permissions are configured, and the activation email + * is sent, the invited user is transitioned to the `PENDING` state. When the invited user clicks the activation email + * and creates and confirms their IBM Cloud account, the user is transitioned to `ACTIVE` state. If the user email is + * already verified, no email is generated. + * + * @param inviteUsersOptions the {@link InviteUsersOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link UserList} + */ + public ServiceCall inviteUsers(InviteUsersOptions inviteUsersOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(inviteUsersOptions, + "inviteUsersOptions cannot be null"); + String[] pathSegments = { "v2/accounts", "users" }; + String[] pathParameters = { inviteUsersOptions.accountId() }; + RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + Map sdkHeaders = SdkCommon.getSdkHeaders("user_management", "v1", "inviteUsers"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + if (inviteUsersOptions.users() != null) { + contentJson.add("users", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(inviteUsersOptions.users())); + } + if (inviteUsersOptions.iamPolicy() != null) { + contentJson.add("iam_policy", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(inviteUsersOptions.iamPolicy())); + } + if (inviteUsersOptions.accessGroups() != null) { + contentJson.add("access_groups", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(inviteUsersOptions.accessGroups())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get user profile. + * + * Retrieve a user's profile by the user's IAM ID in your account. You can use the IAM service token or a user token + * for authorization. To use this method, the requesting user or service ID must have at least the viewer, editor, or + * administrator role on the User Management service. + * + * @param getUserProfileOptions the {@link GetUserProfileOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link UserProfile} + */ + public ServiceCall getUserProfile(GetUserProfileOptions getUserProfileOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getUserProfileOptions, + "getUserProfileOptions cannot be null"); + String[] pathSegments = { "v2/accounts", "users" }; + String[] pathParameters = { getUserProfileOptions.accountId(), getUserProfileOptions.iamId() }; + RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + Map sdkHeaders = SdkCommon.getSdkHeaders("user_management", "v1", "getUserProfile"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Partially update user profiles. + * + * Partially update a user's profile by user's IAM ID. You can use the IAM service token or a user token for + * authorization. To use this method, the requesting user or service ID must have at least the editor or administrator + * role on the User Management service. A user or service ID with these roles can change a user's state between + * `ACTIVE`, `VPN_ONLY`, or `DISABLED_CLASSIC_INFRASTRUCTURE`, but they can't change the state to `PROCESSING` or + * `PENDING` because these are system states. For other request body fields, a user can update their own profile + * without having User Management service permissions. + * + * @param updateUserProfilesOptions the {@link UpdateUserProfilesOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall updateUserProfiles(UpdateUserProfilesOptions updateUserProfilesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(updateUserProfilesOptions, + "updateUserProfilesOptions cannot be null"); + String[] pathSegments = { "v2/accounts", "users" }; + String[] pathParameters = { updateUserProfilesOptions.accountId(), updateUserProfilesOptions.iamId() }; + RequestBuilder builder = RequestBuilder.patch(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + Map sdkHeaders = SdkCommon.getSdkHeaders("user_management", "v1", "updateUserProfiles"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + final JsonObject contentJson = new JsonObject(); + if (updateUserProfilesOptions.firstname() != null) { + contentJson.addProperty("firstname", updateUserProfilesOptions.firstname()); + } + if (updateUserProfilesOptions.lastname() != null) { + contentJson.addProperty("lastname", updateUserProfilesOptions.lastname()); + } + if (updateUserProfilesOptions.state() != null) { + contentJson.addProperty("state", updateUserProfilesOptions.state()); + } + if (updateUserProfilesOptions.email() != null) { + contentJson.addProperty("email", updateUserProfilesOptions.email()); + } + if (updateUserProfilesOptions.phonenumber() != null) { + contentJson.addProperty("phonenumber", updateUserProfilesOptions.phonenumber()); + } + if (updateUserProfilesOptions.altphonenumber() != null) { + contentJson.addProperty("altphonenumber", updateUserProfilesOptions.altphonenumber()); + } + if (updateUserProfilesOptions.photo() != null) { + contentJson.addProperty("photo", updateUserProfilesOptions.photo()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Remove users. + * + * Remove users from an account by user's IAM ID. You must use a user token for authorization. Service IDs can't + * remove users from an account. To use this method, the requesting user must have the editor or administrator role on + * the User Management service. For more information, see the [Removing users](/docs/account?topic=account-remove) + * documentation. + * + * @param removeUsersOptions the {@link RemoveUsersOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall removeUsers(RemoveUsersOptions removeUsersOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(removeUsersOptions, + "removeUsersOptions cannot be null"); + String[] pathSegments = { "v2/accounts", "users" }; + String[] pathParameters = { removeUsersOptions.accountId(), removeUsersOptions.iamId() }; + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + Map sdkHeaders = SdkCommon.getSdkHeaders("user_management", "v1", "removeUsers"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + +} diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/Attribute.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/Attribute.java new file mode 100644 index 0000000000..a58e4c22e9 --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/Attribute.java @@ -0,0 +1,111 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Attribute. + */ +public class Attribute extends GenericModel { + + protected String name; + protected String value; + + /** + * Builder. + */ + public static class Builder { + private String name; + private String value; + + private Builder(Attribute attribute) { + this.name = attribute.name; + this.value = attribute.value; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a Attribute. + * + * @return the new Attribute instance + */ + public Attribute build() { + return new Attribute(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the Attribute builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the Attribute builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + } + + protected Attribute(Builder builder) { + name = builder.name; + value = builder.value; + } + + /** + * New builder. + * + * @return a Attribute builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + * The name of the attribute. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the value. + * + * The value of the attribute. + * + * @return the value + */ + public String value() { + return value; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/GetUserProfileOptions.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/GetUserProfileOptions.java new file mode 100644 index 0000000000..c67b401e01 --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/GetUserProfileOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getUserProfile options. + */ +public class GetUserProfileOptions extends GenericModel { + + protected String accountId; + protected String iamId; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String iamId; + + private Builder(GetUserProfileOptions getUserProfileOptions) { + this.accountId = getUserProfileOptions.accountId; + this.iamId = getUserProfileOptions.iamId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + * @param iamId the iamId + */ + public Builder(String accountId, String iamId) { + this.accountId = accountId; + this.iamId = iamId; + } + + /** + * Builds a GetUserProfileOptions. + * + * @return the new GetUserProfileOptions instance + */ + public GetUserProfileOptions build() { + return new GetUserProfileOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the GetUserProfileOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the iamId. + * + * @param iamId the iamId + * @return the GetUserProfileOptions builder + */ + public Builder iamId(String iamId) { + this.iamId = iamId; + return this; + } + } + + protected GetUserProfileOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.accountId, + "accountId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.iamId, + "iamId cannot be empty"); + accountId = builder.accountId; + iamId = builder.iamId; + } + + /** + * New builder. + * + * @return a GetUserProfileOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The account ID. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the iamId. + * + * The user's IAM ID. + * + * @return the iamId + */ + public String iamId() { + return iamId; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/GetUserSettingsOptions.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/GetUserSettingsOptions.java new file mode 100644 index 0000000000..cbd82cd5ba --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/GetUserSettingsOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getUserSettings options. + */ +public class GetUserSettingsOptions extends GenericModel { + + protected String accountId; + protected String iamId; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String iamId; + + private Builder(GetUserSettingsOptions getUserSettingsOptions) { + this.accountId = getUserSettingsOptions.accountId; + this.iamId = getUserSettingsOptions.iamId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + * @param iamId the iamId + */ + public Builder(String accountId, String iamId) { + this.accountId = accountId; + this.iamId = iamId; + } + + /** + * Builds a GetUserSettingsOptions. + * + * @return the new GetUserSettingsOptions instance + */ + public GetUserSettingsOptions build() { + return new GetUserSettingsOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the GetUserSettingsOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the iamId. + * + * @param iamId the iamId + * @return the GetUserSettingsOptions builder + */ + public Builder iamId(String iamId) { + this.iamId = iamId; + return this; + } + } + + protected GetUserSettingsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.accountId, + "accountId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.iamId, + "iamId cannot be empty"); + accountId = builder.accountId; + iamId = builder.iamId; + } + + /** + * New builder. + * + * @return a GetUserSettingsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The account ID. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the iamId. + * + * The user's IAM ID. + * + * @return the iamId + */ + public String iamId() { + return iamId; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUser.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUser.java new file mode 100644 index 0000000000..42da4e81f1 --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUser.java @@ -0,0 +1,113 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Invite a user. + */ +public class InviteUser extends GenericModel { + + protected String email; + @SerializedName("account_role") + protected String accountRole; + + /** + * Builder. + */ + public static class Builder { + private String email; + private String accountRole; + + private Builder(InviteUser inviteUser) { + this.email = inviteUser.email; + this.accountRole = inviteUser.accountRole; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a InviteUser. + * + * @return the new InviteUser instance + */ + public InviteUser build() { + return new InviteUser(this); + } + + /** + * Set the email. + * + * @param email the email + * @return the InviteUser builder + */ + public Builder email(String email) { + this.email = email; + return this; + } + + /** + * Set the accountRole. + * + * @param accountRole the accountRole + * @return the InviteUser builder + */ + public Builder accountRole(String accountRole) { + this.accountRole = accountRole; + return this; + } + } + + protected InviteUser(Builder builder) { + email = builder.email; + accountRole = builder.accountRole; + } + + /** + * New builder. + * + * @return a InviteUser builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the email. + * + * The email of the user to be invited. + * + * @return the email + */ + public String email() { + return email; + } + + /** + * Gets the accountRole. + * + * The account role of the user to be invited. + * + * @return the accountRole + */ + public String accountRole() { + return accountRole; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUserIamPolicy.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUserIamPolicy.java new file mode 100644 index 0000000000..d6b9807655 --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUserIamPolicy.java @@ -0,0 +1,173 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Invite a user to an IAM policy. + */ +public class InviteUserIamPolicy extends GenericModel { + protected String type; + protected List roles; + protected List resources; + + /** + * Builder. + */ + public static class Builder { + private String type; + private List roles; + private List resources; + + private Builder(InviteUserIamPolicy inviteUserIamPolicy) { + this.roles = inviteUserIamPolicy.roles; + this.resources = inviteUserIamPolicy.resources; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a InviteUserIamPolicy. + * + * @return the new InviteUserIamPolicy instance + */ + public InviteUserIamPolicy build() { + return new InviteUserIamPolicy(this); + } + + /** + * Adds an roles to roles. + * + * @param roles the new roles + * @return the InviteUserIamPolicy builder + */ + public Builder addRoles(Role roles) { + com.ibm.cloud.sdk.core.util.Validator.notNull(roles, + "roles cannot be null"); + if (this.roles == null) { + this.roles = new ArrayList(); + } + this.roles.add(roles); + return this; + } + + /** + * Adds an resources to resources. + * + * @param resources the new resources + * @return the InviteUserIamPolicy builder + */ + public Builder addResources(Resource resources) { + com.ibm.cloud.sdk.core.util.Validator.notNull(resources, + "resources cannot be null"); + if (this.resources == null) { + this.resources = new ArrayList(); + } + this.resources.add(resources); + return this; + } + + /** + * Set the type. + * Existing resources will be replaced. + * + * @param type the type + * @return the InviteUserIamPolicy builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the roles. + * Existing roles will be replaced. + * + * @param roles the roles + * @return the InviteUserIamPolicy builder + */ + public Builder roles(List roles) { + this.roles = roles; + return this; + } + + /** + * Set the resources. + * Existing resources will be replaced. + * + * @param resources the resources + * @return the InviteUserIamPolicy builder + */ + public Builder resources(List resources) { + this.resources = resources; + return this; + } + } + + protected InviteUserIamPolicy(Builder builder) { + type = builder.type; + roles = builder.roles; + resources = builder.resources; + } + + /** + * New builder. + * + * @return a InviteUserIamPolicy builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the roles. + * + * A list of IAM roles. + * + * @return the roles + */ + public List roles() { + return roles; + } + + /** + * Gets the resources. + * + * A list of resources. + * + * @return the resources + */ + public List resources() { + return resources; + } + + /** + * Gets the type. + * + * type + * + * @return the type + */ + public String type() { + return type; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUsersOptions.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUsersOptions.java new file mode 100644 index 0000000000..cc943696a9 --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUsersOptions.java @@ -0,0 +1,228 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The inviteUsers options. + */ +public class InviteUsersOptions extends GenericModel { + + protected String accountId; + protected List users; + protected List iamPolicy; + protected List accessGroups; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private List users; + private List iamPolicy; + private List accessGroups; + + private Builder(InviteUsersOptions inviteUsersOptions) { + this.accountId = inviteUsersOptions.accountId; + this.users = inviteUsersOptions.users; + this.iamPolicy = inviteUsersOptions.iamPolicy; + this.accessGroups = inviteUsersOptions.accessGroups; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + */ + public Builder(String accountId) { + this.accountId = accountId; + } + + /** + * Builds a InviteUsersOptions. + * + * @return the new InviteUsersOptions instance + */ + public InviteUsersOptions build() { + return new InviteUsersOptions(this); + } + + /** + * Adds an users to users. + * + * @param users the new users + * @return the InviteUsersOptions builder + */ + public Builder addUsers(InviteUser users) { + com.ibm.cloud.sdk.core.util.Validator.notNull(users, + "users cannot be null"); + if (this.users == null) { + this.users = new ArrayList(); + } + this.users.add(users); + return this; + } + + /** + * Adds an iamPolicy to iamPolicy. + * + * @param iamPolicy the new iamPolicy + * @return the InviteUsersOptions builder + */ + public Builder addIamPolicy(InviteUserIamPolicy iamPolicy) { + com.ibm.cloud.sdk.core.util.Validator.notNull(iamPolicy, + "iamPolicy cannot be null"); + if (this.iamPolicy == null) { + this.iamPolicy = new ArrayList(); + } + this.iamPolicy.add(iamPolicy); + return this; + } + + /** + * Adds an accessGroups to accessGroups. + * + * @param accessGroups the new accessGroups + * @return the InviteUsersOptions builder + */ + public Builder addAccessGroups(String accessGroups) { + com.ibm.cloud.sdk.core.util.Validator.notNull(accessGroups, + "accessGroups cannot be null"); + if (this.accessGroups == null) { + this.accessGroups = new ArrayList(); + } + this.accessGroups.add(accessGroups); + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the InviteUsersOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the users. + * Existing users will be replaced. + * + * @param users the users + * @return the InviteUsersOptions builder + */ + public Builder users(List users) { + this.users = users; + return this; + } + + /** + * Set the iamPolicy. + * Existing iamPolicy will be replaced. + * + * @param iamPolicy the iamPolicy + * @return the InviteUsersOptions builder + */ + public Builder iamPolicy(List iamPolicy) { + this.iamPolicy = iamPolicy; + return this; + } + + /** + * Set the accessGroups. + * Existing accessGroups will be replaced. + * + * @param accessGroups the accessGroups + * @return the InviteUsersOptions builder + */ + public Builder accessGroups(List accessGroups) { + this.accessGroups = accessGroups; + return this; + } + } + + protected InviteUsersOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.accountId, + "accountId cannot be empty"); + accountId = builder.accountId; + users = builder.users; + iamPolicy = builder.iamPolicy; + accessGroups = builder.accessGroups; + } + + /** + * New builder. + * + * @return a InviteUsersOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The account ID. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the users. + * + * A list of users to be invited. + * + * @return the users + */ + public List users() { + return users; + } + + /** + * Gets the iamPolicy. + * + * A list of IAM policies. + * + * @return the iamPolicy + */ + public List iamPolicy() { + return iamPolicy; + } + + /** + * Gets the accessGroups. + * + * A list of access groups. + * + * @return the accessGroups + */ + public List accessGroups() { + return accessGroups; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/ListUsersOptions.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/ListUsersOptions.java new file mode 100644 index 0000000000..4f8bb4e27e --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/ListUsersOptions.java @@ -0,0 +1,122 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The listUsers options. + */ +public class ListUsersOptions extends GenericModel { + + protected String accountId; + protected String state; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String state; + + private Builder(ListUsersOptions listUsersOptions) { + this.accountId = listUsersOptions.accountId; + this.state = listUsersOptions.state; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + */ + public Builder(String accountId) { + this.accountId = accountId; + } + + /** + * Builds a ListUsersOptions. + * + * @return the new ListUsersOptions instance + */ + public ListUsersOptions build() { + return new ListUsersOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the ListUsersOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the state. + * + * @param state the state + * @return the ListUsersOptions builder + */ + public Builder state(String state) { + this.state = state; + return this; + } + } + + protected ListUsersOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.accountId, + "accountId cannot be empty"); + accountId = builder.accountId; + state = builder.state; + } + + /** + * New builder. + * + * @return a ListUsersOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The account ID. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the state. + * + * The state of the user. + * + * @return the state + */ + public String state() { + return state; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/RemoveUsersOptions.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/RemoveUsersOptions.java new file mode 100644 index 0000000000..d8bc4111fa --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/RemoveUsersOptions.java @@ -0,0 +1,126 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The removeUsers options. + */ +public class RemoveUsersOptions extends GenericModel { + + protected String accountId; + protected String iamId; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String iamId; + + private Builder(RemoveUsersOptions removeUsersOptions) { + this.accountId = removeUsersOptions.accountId; + this.iamId = removeUsersOptions.iamId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + * @param iamId the iamId + */ + public Builder(String accountId, String iamId) { + this.accountId = accountId; + this.iamId = iamId; + } + + /** + * Builds a RemoveUsersOptions. + * + * @return the new RemoveUsersOptions instance + */ + public RemoveUsersOptions build() { + return new RemoveUsersOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the RemoveUsersOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the iamId. + * + * @param iamId the iamId + * @return the RemoveUsersOptions builder + */ + public Builder iamId(String iamId) { + this.iamId = iamId; + return this; + } + } + + protected RemoveUsersOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.accountId, + "accountId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.iamId, + "iamId cannot be empty"); + accountId = builder.accountId; + iamId = builder.iamId; + } + + /** + * New builder. + * + * @return a RemoveUsersOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The account ID. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the iamId. + * + * The user's IAM ID. + * + * @return the iamId + */ + public String iamId() { + return iamId; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/Resource.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/Resource.java new file mode 100644 index 0000000000..be563e6742 --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/Resource.java @@ -0,0 +1,105 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * object. + */ +public class Resource extends GenericModel { + + protected List attributes; + + /** + * Builder. + */ + public static class Builder { + private List attributes; + + private Builder(Resource resource) { + this.attributes = resource.attributes; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a Resource. + * + * @return the new Resource instance + */ + public Resource build() { + return new Resource(this); + } + + /** + * Adds an attributes to attributes. + * + * @param attributes the new attributes + * @return the Resource builder + */ + public Builder addAttributes(Attribute attributes) { + com.ibm.cloud.sdk.core.util.Validator.notNull(attributes, + "attributes cannot be null"); + if (this.attributes == null) { + this.attributes = new ArrayList(); + } + this.attributes.add(attributes); + return this; + } + + /** + * Set the attributes. + * Existing attributes will be replaced. + * + * @param attributes the attributes + * @return the Resource builder + */ + public Builder attributes(List attributes) { + this.attributes = attributes; + return this; + } + } + + protected Resource(Builder builder) { + attributes = builder.attributes; + } + + /** + * New builder. + * + * @return a Resource builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the attributes. + * + * A list of IAM attributes. + * + * @return the attributes + */ + public List attributes() { + return attributes; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/Role.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/Role.java new file mode 100644 index 0000000000..ece2bdcb89 --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/Role.java @@ -0,0 +1,87 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The role of an IAM policy. + */ +public class Role extends GenericModel { + + @SerializedName("role_id") + protected String roleId; + + /** + * Builder. + */ + public static class Builder { + private String roleId; + + private Builder(Role role) { + this.roleId = role.roleId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a Role. + * + * @return the new Role instance + */ + public Role build() { + return new Role(this); + } + + /** + * Set the roleId. + * + * @param roleId the roleId + * @return the Role builder + */ + public Builder roleId(String roleId) { + this.roleId = roleId; + return this; + } + } + + protected Role(Builder builder) { + roleId = builder.roleId; + } + + /** + * New builder. + * + * @return a Role builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the roleId. + * + * An alphanumeric value identifying the origin. + * + * @return the roleId + */ + public String roleId() { + return roleId; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UpdateUserProfilesOptions.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UpdateUserProfilesOptions.java new file mode 100644 index 0000000000..e943deaaed --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UpdateUserProfilesOptions.java @@ -0,0 +1,309 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The updateUserProfiles options. + */ +public class UpdateUserProfilesOptions extends GenericModel { + + protected String accountId; + protected String iamId; + protected String firstname; + protected String lastname; + protected String state; + protected String email; + protected String phonenumber; + protected String altphonenumber; + protected String photo; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String iamId; + private String firstname; + private String lastname; + private String state; + private String email; + private String phonenumber; + private String altphonenumber; + private String photo; + + private Builder(UpdateUserProfilesOptions updateUserProfilesOptions) { + this.accountId = updateUserProfilesOptions.accountId; + this.iamId = updateUserProfilesOptions.iamId; + this.firstname = updateUserProfilesOptions.firstname; + this.lastname = updateUserProfilesOptions.lastname; + this.state = updateUserProfilesOptions.state; + this.email = updateUserProfilesOptions.email; + this.phonenumber = updateUserProfilesOptions.phonenumber; + this.altphonenumber = updateUserProfilesOptions.altphonenumber; + this.photo = updateUserProfilesOptions.photo; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + * @param iamId the iamId + */ + public Builder(String accountId, String iamId) { + this.accountId = accountId; + this.iamId = iamId; + } + + /** + * Builds a UpdateUserProfilesOptions. + * + * @return the new UpdateUserProfilesOptions instance + */ + public UpdateUserProfilesOptions build() { + return new UpdateUserProfilesOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the UpdateUserProfilesOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the iamId. + * + * @param iamId the iamId + * @return the UpdateUserProfilesOptions builder + */ + public Builder iamId(String iamId) { + this.iamId = iamId; + return this; + } + + /** + * Set the firstname. + * + * @param firstname the firstname + * @return the UpdateUserProfilesOptions builder + */ + public Builder firstname(String firstname) { + this.firstname = firstname; + return this; + } + + /** + * Set the lastname. + * + * @param lastname the lastname + * @return the UpdateUserProfilesOptions builder + */ + public Builder lastname(String lastname) { + this.lastname = lastname; + return this; + } + + /** + * Set the state. + * + * @param state the state + * @return the UpdateUserProfilesOptions builder + */ + public Builder state(String state) { + this.state = state; + return this; + } + + /** + * Set the email. + * + * @param email the email + * @return the UpdateUserProfilesOptions builder + */ + public Builder email(String email) { + this.email = email; + return this; + } + + /** + * Set the phonenumber. + * + * @param phonenumber the phonenumber + * @return the UpdateUserProfilesOptions builder + */ + public Builder phonenumber(String phonenumber) { + this.phonenumber = phonenumber; + return this; + } + + /** + * Set the altphonenumber. + * + * @param altphonenumber the altphonenumber + * @return the UpdateUserProfilesOptions builder + */ + public Builder altphonenumber(String altphonenumber) { + this.altphonenumber = altphonenumber; + return this; + } + + /** + * Set the photo. + * + * @param photo the photo + * @return the UpdateUserProfilesOptions builder + */ + public Builder photo(String photo) { + this.photo = photo; + return this; + } + } + + protected UpdateUserProfilesOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.accountId, + "accountId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.iamId, + "iamId cannot be empty"); + accountId = builder.accountId; + iamId = builder.iamId; + firstname = builder.firstname; + lastname = builder.lastname; + state = builder.state; + email = builder.email; + phonenumber = builder.phonenumber; + altphonenumber = builder.altphonenumber; + photo = builder.photo; + } + + /** + * New builder. + * + * @return a UpdateUserProfilesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The account ID. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the iamId. + * + * The user's IAM ID. + * + * @return the iamId + */ + public String iamId() { + return iamId; + } + + /** + * Gets the firstname. + * + * The first name of the user. + * + * @return the firstname + */ + public String firstname() { + return firstname; + } + + /** + * Gets the lastname. + * + * The last name of the user. + * + * @return the lastname + */ + public String lastname() { + return lastname; + } + + /** + * Gets the state. + * + * The state of the user. Possible values are `PROCESSING`, `PENDING`, `ACTIVE`, `DISABLED_CLASSIC_INFRASTRUCTURE`, + * and `VPN_ONLY`. + * + * @return the state + */ + public String state() { + return state; + } + + /** + * Gets the email. + * + * The email address of the user. + * + * @return the email + */ + public String email() { + return email; + } + + /** + * Gets the phonenumber. + * + * The phone number of the user. + * + * @return the phonenumber + */ + public String phonenumber() { + return phonenumber; + } + + /** + * Gets the altphonenumber. + * + * The alternative phone number of the user. + * + * @return the altphonenumber + */ + public String altphonenumber() { + return altphonenumber; + } + + /** + * Gets the photo. + * + * A link to a photo of the user. + * + * @return the photo + */ + public String photo() { + return photo; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UpdateUserSettingsOptions.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UpdateUserSettingsOptions.java new file mode 100644 index 0000000000..61c4f451dd --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UpdateUserSettingsOptions.java @@ -0,0 +1,244 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The updateUserSettings options. + */ +public class UpdateUserSettingsOptions extends GenericModel { + + protected String accountId; + protected String iamId; + protected String language; + protected String notificationLanguage; + protected String allowedIpAddresses; + protected Boolean selfManage; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String iamId; + private String language; + private String notificationLanguage; + private String allowedIpAddresses; + private Boolean selfManage; + + private Builder(UpdateUserSettingsOptions updateUserSettingsOptions) { + this.accountId = updateUserSettingsOptions.accountId; + this.iamId = updateUserSettingsOptions.iamId; + this.language = updateUserSettingsOptions.language; + this.notificationLanguage = updateUserSettingsOptions.notificationLanguage; + this.allowedIpAddresses = updateUserSettingsOptions.allowedIpAddresses; + this.selfManage = updateUserSettingsOptions.selfManage; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + * @param iamId the iamId + */ + public Builder(String accountId, String iamId) { + this.accountId = accountId; + this.iamId = iamId; + } + + /** + * Builds a UpdateUserSettingsOptions. + * + * @return the new UpdateUserSettingsOptions instance + */ + public UpdateUserSettingsOptions build() { + return new UpdateUserSettingsOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the UpdateUserSettingsOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the iamId. + * + * @param iamId the iamId + * @return the UpdateUserSettingsOptions builder + */ + public Builder iamId(String iamId) { + this.iamId = iamId; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the UpdateUserSettingsOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the notificationLanguage. + * + * @param notificationLanguage the notificationLanguage + * @return the UpdateUserSettingsOptions builder + */ + public Builder notificationLanguage(String notificationLanguage) { + this.notificationLanguage = notificationLanguage; + return this; + } + + /** + * Set the allowedIpAddresses. + * + * @param allowedIpAddresses the allowedIpAddresses + * @return the UpdateUserSettingsOptions builder + */ + public Builder allowedIpAddresses(String allowedIpAddresses) { + this.allowedIpAddresses = allowedIpAddresses; + return this; + } + + /** + * Set the selfManage. + * + * @param selfManage the selfManage + * @return the UpdateUserSettingsOptions builder + */ + public Builder selfManage(Boolean selfManage) { + this.selfManage = selfManage; + return this; + } + + /** + * Set the userSettings. + * + * @param userSettings the userSettings + * @return the UpdateUserSettingsOptions builder + */ + public Builder userSettings(UserSettings userSettings) { + this.language = userSettings.language(); + this.notificationLanguage = userSettings.notificationLanguage(); + this.allowedIpAddresses = userSettings.allowedIpAddresses(); + this.selfManage = userSettings.selfManage(); + return this; + } + } + + protected UpdateUserSettingsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.accountId, + "accountId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.iamId, + "iamId cannot be empty"); + accountId = builder.accountId; + iamId = builder.iamId; + language = builder.language; + notificationLanguage = builder.notificationLanguage; + allowedIpAddresses = builder.allowedIpAddresses; + selfManage = builder.selfManage; + } + + /** + * New builder. + * + * @return a UpdateUserSettingsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The account ID. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the iamId. + * + * The user's IAM ID. + * + * @return the iamId + */ + public String iamId() { + return iamId; + } + + /** + * Gets the language. + * + * The console UI language. By default, this field is empty. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the notificationLanguage. + * + * The language for email and phone notifications. By default, this field is empty. + * + * @return the notificationLanguage + */ + public String notificationLanguage() { + return notificationLanguage; + } + + /** + * Gets the allowedIpAddresses. + * + * A comma-separated list of IP addresses. + * + * @return the allowedIpAddresses + */ + public String allowedIpAddresses() { + return allowedIpAddresses; + } + + /** + * Gets the selfManage. + * + * Whether user managed login is enabled. The default value is `false`. + * + * @return the selfManage + */ + public Boolean selfManage() { + return selfManage; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UserList.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UserList.java new file mode 100644 index 0000000000..5755bbbdbf --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UserList.java @@ -0,0 +1,89 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The users returned. + */ +public class UserList extends GenericModel { + + @SerializedName("total_results") + protected Double totalResults; + protected Double limit; + @SerializedName("first_url") + protected String firstUrl; + @SerializedName("next_url") + protected String nextUrl; + protected List resources; + + /** + * Gets the totalResults. + * + * The number of users returned. + * + * @return the totalResults + */ + public Double getTotalResults() { + return totalResults; + } + + /** + * Gets the limit. + * + * A limit to the number of users returned in a page. + * + * @return the limit + */ + public Double getLimit() { + return limit; + } + + /** + * Gets the firstUrl. + * + * The first URL of the get users API. + * + * @return the firstUrl + */ + public String getFirstUrl() { + return firstUrl; + } + + /** + * Gets the nextUrl. + * + * The next URL of the get users API. + * + * @return the nextUrl + */ + public String getNextUrl() { + return nextUrl; + } + + /** + * Gets the resources. + * + * A list of users in the account. + * + * @return the resources + */ + public List getResources() { + return resources; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UserProfile.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UserProfile.java new file mode 100644 index 0000000000..1d3a7f58c8 --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UserProfile.java @@ -0,0 +1,172 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Returned the user profile. + */ +public class UserProfile extends GenericModel { + + protected String id; + @SerializedName("iam_id") + protected String iamId; + protected String realm; + @SerializedName("user_id") + protected String userId; + protected String firstname; + protected String lastname; + protected String state; + protected String email; + protected String phonenumber; + protected String altphonenumber; + protected String photo; + @SerializedName("account_id") + protected String accountId; + + /** + * Gets the id. + * + * An alphanumeric value identifying the user profile. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the iamId. + * + * An alphanumeric value identifying the user's IAM ID. + * + * @return the iamId + */ + public String getIamId() { + return iamId; + } + + /** + * Gets the realm. + * + * The realm of the user. The value is either `IBMid` or `SL`. + * + * @return the realm + */ + public String getRealm() { + return realm; + } + + /** + * Gets the userId. + * + * The user ID used for login. + * + * @return the userId + */ + public String getUserId() { + return userId; + } + + /** + * Gets the firstname. + * + * The first name of the user. + * + * @return the firstname + */ + public String getFirstname() { + return firstname; + } + + /** + * Gets the lastname. + * + * The last name of the user. + * + * @return the lastname + */ + public String getLastname() { + return lastname; + } + + /** + * Gets the state. + * + * The state of the user. Possible values are `PROCESSING`, `PENDING`, `ACTIVE`, `DISABLED_CLASSIC_INFRASTRUCTURE`, + * and `VPN_ONLY`. + * + * @return the state + */ + public String getState() { + return state; + } + + /** + * Gets the email. + * + * The email address of the user. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Gets the phonenumber. + * + * The phone number of the user. + * + * @return the phonenumber + */ + public String getPhonenumber() { + return phonenumber; + } + + /** + * Gets the altphonenumber. + * + * The alternative phone number of the user. + * + * @return the altphonenumber + */ + public String getAltphonenumber() { + return altphonenumber; + } + + /** + * Gets the photo. + * + * A link to a photo of the user. + * + * @return the photo + */ + public String getPhoto() { + return photo; + } + + /** + * Gets the accountId. + * + * An alphanumeric value identifying the account ID. + * + * @return the accountId + */ + public String getAccountId() { + return accountId; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UserSettings.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UserSettings.java new file mode 100644 index 0000000000..5110390c22 --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/model/UserSettings.java @@ -0,0 +1,167 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The user settings returned. + */ +public class UserSettings extends GenericModel { + + protected String language; + @SerializedName("notification_language") + protected String notificationLanguage; + @SerializedName("allowed_ip_addresses") + protected String allowedIpAddresses; + @SerializedName("self_manage") + protected Boolean selfManage; + + /** + * Builder. + */ + public static class Builder { + private String language; + private String notificationLanguage; + private String allowedIpAddresses; + private Boolean selfManage; + + private Builder(UserSettings userSettings) { + this.language = userSettings.language; + this.notificationLanguage = userSettings.notificationLanguage; + this.allowedIpAddresses = userSettings.allowedIpAddresses; + this.selfManage = userSettings.selfManage; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a UserSettings. + * + * @return the new UserSettings instance + */ + public UserSettings build() { + return new UserSettings(this); + } + + /** + * Set the language. + * + * @param language the language + * @return the UserSettings builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the notificationLanguage. + * + * @param notificationLanguage the notificationLanguage + * @return the UserSettings builder + */ + public Builder notificationLanguage(String notificationLanguage) { + this.notificationLanguage = notificationLanguage; + return this; + } + + /** + * Set the allowedIpAddresses. + * + * @param allowedIpAddresses the allowedIpAddresses + * @return the UserSettings builder + */ + public Builder allowedIpAddresses(String allowedIpAddresses) { + this.allowedIpAddresses = allowedIpAddresses; + return this; + } + + /** + * Set the selfManage. + * + * @param selfManage the selfManage + * @return the UserSettings builder + */ + public Builder selfManage(Boolean selfManage) { + this.selfManage = selfManage; + return this; + } + } + + protected UserSettings(Builder builder) { + language = builder.language; + notificationLanguage = builder.notificationLanguage; + allowedIpAddresses = builder.allowedIpAddresses; + selfManage = builder.selfManage; + } + + /** + * New builder. + * + * @return a UserSettings builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the language. + * + * The console UI language. By default, this field is empty. + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the notificationLanguage. + * + * The language for email and phone notifications. By default, this field is empty. + * + * @return the notificationLanguage + */ + public String notificationLanguage() { + return notificationLanguage; + } + + /** + * Gets the allowedIpAddresses. + * + * A comma-separated list of IP addresses. + * + * @return the allowedIpAddresses + */ + public String allowedIpAddresses() { + return allowedIpAddresses; + } + + /** + * Gets the selfManage. + * + * Whether user managed login is enabled. The default value is `false`. + * + * @return the selfManage + */ + public Boolean selfManage() { + return selfManage; + } +} + diff --git a/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/package-info.java b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/package-info.java new file mode 100644 index 0000000000..b4d22bd5b1 --- /dev/null +++ b/modules/user-management/src/main/java/com/ibm/cloud/platform_services/user_management/v1/package-info.java @@ -0,0 +1,16 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +/** + * IBM Cloud User Management API v1. + */ +package com.ibm.cloud.platform_services.user_management.v1; diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/UserManagementIT.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/UserManagementIT.java new file mode 100644 index 0000000000..a67dfbfc15 --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/UserManagementIT.java @@ -0,0 +1,300 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.fail; + +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.ibm.cloud.platform_services.test.SdkIntegrationTestBase; +import com.ibm.cloud.platform_services.user_management.v1.model.Attribute; +import com.ibm.cloud.platform_services.user_management.v1.model.GetUserProfileOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.GetUserSettingsOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.InviteUser; +import com.ibm.cloud.platform_services.user_management.v1.model.InviteUserIamPolicy; +import com.ibm.cloud.platform_services.user_management.v1.model.InviteUsersOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.ListUsersOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.RemoveUsersOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.Resource; +import com.ibm.cloud.platform_services.user_management.v1.model.Role; +import com.ibm.cloud.platform_services.user_management.v1.model.UpdateUserProfilesOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.UpdateUserSettingsOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.UserList; +import com.ibm.cloud.platform_services.user_management.v1.model.UserProfile; +import com.ibm.cloud.platform_services.user_management.v1.model.UserSettings; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.CredentialUtils; +import org.json.JSONObject; +import org.json.JSONArray; + + +/** + * Integration test class for the UserManagement service. + */ +public class UserManagementIT extends SdkIntegrationTestBase { + public UserManagement service = null; + public UserManagement alternateService = null; + public static Map config = null; + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + public String userId = null; + /** + * This method provides our config filename to the base class. + */ + + public String getConfigFilename() { + return "../../user_management.env"; + } + + @BeforeClass + public void constructService() { + // Ask super if we should skip the tests. + if (skipTests()) { + return; + } + + service = UserManagement.newInstance("USERMGMT1"); + assertNotNull(service); + assertNotNull(service.getServiceUrl()); + + alternateService = UserManagement.newInstance("USERMGMT2"); + assertNotNull(alternateService); + assertNotNull(alternateService.getServiceUrl()); + + // Load up our test-specific config properties. + config = CredentialUtils.getServiceProperties("USERMGMT1"); + assertNotNull(config); + assertFalse(config.isEmpty()); + assertEquals(service.getServiceUrl(), config.get("URL")); + + System.out.println("Setup complete."); + } + + @Test + public void testGetUserSettings() throws Exception { + try { + GetUserSettingsOptions getUserSettingsOptions = new GetUserSettingsOptions.Builder() + .accountId("1aa434630b594b8a88b961a44c9eb2a9") + .iamId("IBMid-550008BJPR") + .build(); + + // Invoke operation + Response response = service.getUserSettings(getUserSettingsOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + UserSettings userSettingsResult = response.getResult(); + + assertNotNull(userSettingsResult); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %s: %s\nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test + public void testUpdateUserSettings() throws Exception { + try { + UpdateUserSettingsOptions updateUserSettingsOptions = new UpdateUserSettingsOptions.Builder() + .accountId("1aa434630b594b8a88b961a44c9eb2a9") + .iamId("IBMid-550008BJPR") + .language("testString") + .notificationLanguage("testString") + .allowedIpAddresses("32.96.110.50,172.16.254.1") + .selfManage(true) + .build(); + + // Invoke operation + Response response = service.updateUserSettings(updateUserSettingsOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + UserSettings userSettingsResult = response.getResult(); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %s: %s\nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test + public void testListUsers() throws Exception { + try { + ListUsersOptions listUsersOptions = new ListUsersOptions.Builder() + .accountId("1aa434630b594b8a88b961a44c9eb2a9") + .state("ACTIVE") + .build(); + + // Invoke operation + Response response = service.listUsers(listUsersOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + UserList userListResult = response.getResult(); + + assertNotNull(userListResult); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %s: %s\nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test + public void testInviteUsers() throws Exception { + try { + InviteUser inviteUserModel = new InviteUser.Builder() + .email("aminttest+linked_account_owner_11@mail.test.ibm.com") + .accountRole("Member") + .build(); + + Role roleModel = new Role.Builder() + .roleId("crn:v1:bluemix:public:iam::::role:Viewer") + .build(); + + Attribute attributeModel = new Attribute.Builder() + .name("accountId") + .value("1aa434630b594b8a88b961a44c9eb2a9") + .build(); + + Attribute attributeModel2 = new Attribute.Builder() + .name("resourceGroupId") + .value("*") + .build(); + + Attribute[] attributeArray = new Attribute[]{attributeModel, attributeModel2}; + + Resource resourceModel = new Resource.Builder() + .attributes(new java.util.ArrayList(java.util.Arrays.asList(attributeArray))) + .build(); + + InviteUserIamPolicy inviteUserIamPolicyModel = new InviteUserIamPolicy.Builder() + .type("access") + .roles(new java.util.ArrayList(java.util.Arrays.asList(roleModel))) + .resources(new java.util.ArrayList(java.util.Arrays.asList(resourceModel))) + .build(); + + InviteUsersOptions inviteUsersOptions = new InviteUsersOptions.Builder() + .accountId("1aa434630b594b8a88b961a44c9eb2a9") + .users(new java.util.ArrayList(java.util.Arrays.asList(inviteUserModel))) + .iamPolicy(new java.util.ArrayList(java.util.Arrays.asList(inviteUserIamPolicyModel))) + .accessGroups(new java.util.ArrayList(java.util.Arrays.asList("AccessGroupId-51675919-2bd7-4ce3-86e4-5faff8065574"))) + .build(); + + // Invoke operation + Response response = alternateService.inviteUsers(inviteUsersOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 202); + + UserList userListResult = response.getResult(); + + assertNotNull(userListResult); + + List profile = userListResult.getResources(); + userId = profile.get(0).getId(); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %s: %s\nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test + public void testGetUserProfile() throws Exception { + try { + GetUserProfileOptions getUserProfileOptions = new GetUserProfileOptions.Builder() + .accountId("1aa434630b594b8a88b961a44c9eb2a9") + .iamId("IBMid-550008BJPR") + .build(); + + // Invoke operation + Response response = service.getUserProfile(getUserProfileOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + UserProfile userProfileResult = response.getResult(); + + assertNotNull(userProfileResult); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %s: %s\nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test + public void testUpdateUserProfiles() throws Exception { + try { + UpdateUserProfilesOptions updateUserProfilesOptions = new UpdateUserProfilesOptions.Builder() + .accountId("1aa434630b594b8a88b961a44c9eb2a9") + .iamId("IBMid-550008BJPR") + .firstname("testString") + .lastname("testString") + .state("ACTIVE") + .email("do_not_delete_user_without_iam_policy_stage@mail.test.ibm.com") + .phonenumber("testString") + .altphonenumber("testString") + .photo("testString") + .build(); + + // Invoke operation + Response response = service.updateUserProfiles(updateUserProfilesOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %s: %s\nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test + public void testRemoveUsers() throws Exception { + try { + RemoveUsersOptions removeUsersOptions = new RemoveUsersOptions.Builder() + .accountId("1aa434630b594b8a88b961a44c9eb2a9") + .iamId(userId) + .build(); + + // Invoke operation + Response response = service.removeUsers(removeUsersOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %s: %s\nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @AfterClass + public void tearDown() { + // Add any clean up logic here + System.out.println("Clean up complete."); + } + } diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/UserManagementTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/UserManagementTest.java new file mode 100644 index 0000000000..461e3dfa58 --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/UserManagementTest.java @@ -0,0 +1,520 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1; + +import com.ibm.cloud.platform_services.user_management.v1.UserManagement; +import com.ibm.cloud.platform_services.user_management.v1.model.Attribute; +import com.ibm.cloud.platform_services.user_management.v1.model.GetUserProfileOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.GetUserSettingsOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.InviteUser; +import com.ibm.cloud.platform_services.user_management.v1.model.InviteUserIamPolicy; +import com.ibm.cloud.platform_services.user_management.v1.model.InviteUsersOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.ListUsersOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.RemoveUsersOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.Resource; +import com.ibm.cloud.platform_services.user_management.v1.model.Role; +import com.ibm.cloud.platform_services.user_management.v1.model.UpdateUserProfilesOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.UpdateUserSettingsOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.UserList; +import com.ibm.cloud.platform_services.user_management.v1.model.UserProfile; +import com.ibm.cloud.platform_services.user_management.v1.model.UserSettings; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; +import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; + +import com.ibm.cloud.sdk.core.util.EnvironmentUtils; + +import java.io.IOException; +import java.io.InputStream; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; + +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.testng.PowerMockTestCase; + +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the UserManagement service. + */ +@PrepareForTest({ EnvironmentUtils.class }) +@PowerMockIgnore("javax.net.ssl.*") +public class UserManagementTest extends PowerMockTestCase { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected UserManagement userManagementService; + + // Creates a mock set of environment variables that are returned by EnvironmentUtils.getenv(). + private Map getTestProcessEnvironment() { + Map env = new HashMap<>(); + env.put("TESTSERVICE_AUTH_TYPE", "noAuth"); + return env; + } + + public void constructClientService() throws Throwable { + PowerMockito.spy(EnvironmentUtils.class); + PowerMockito.when(EnvironmentUtils.getenv()).thenReturn(getTestProcessEnvironment()); + final String serviceName = "testService"; + + userManagementService = UserManagement.newInstance(serviceName); + String url = server.url("/").toString(); + userManagementService.setServiceUrl(url); + } + + /** + * Negative Test - construct the service with a null authenticator. + */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + + new UserManagement(serviceName, null); + } + + @Test + public void testGetUserSettingsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"language\": \"language\", \"notification_language\": \"notificationLanguage\", \"allowed_ip_addresses\": \"32.96.110.50,172.16.254.1\", \"self_manage\": true}"; + String getUserSettingsPath = "/v2/accounts/testString/users/testString/settings"; + + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetUserSettingsOptions model + GetUserSettingsOptions getUserSettingsOptionsModel = new GetUserSettingsOptions.Builder() + .accountId("testString") + .iamId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = userManagementService.getUserSettings(getUserSettingsOptionsModel).execute(); + assertNotNull(response); + UserSettings responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getUserSettingsPath); + } + + // Test the getUserSettings operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetUserSettingsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + userManagementService.getUserSettings(null).execute(); + } + + @Test + public void testUpdateUserSettingsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"language\": \"language\", \"notification_language\": \"notificationLanguage\", \"allowed_ip_addresses\": \"32.96.110.50,172.16.254.1\", \"self_manage\": true}"; + String updateUserSettingsPath = "/v2/accounts/testString/users/testString/settings"; + + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateUserSettingsOptions model + UpdateUserSettingsOptions updateUserSettingsOptionsModel = new UpdateUserSettingsOptions.Builder() + .accountId("testString") + .iamId("testString") + .language("testString") + .notificationLanguage("testString") + .allowedIpAddresses("32.96.110.50,172.16.254.1") + .selfManage(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = userManagementService.updateUserSettings(updateUserSettingsOptionsModel).execute(); + assertNotNull(response); + UserSettings responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PATCH"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateUserSettingsPath); + } + + // Test the updateUserSettings operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateUserSettingsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + userManagementService.updateUserSettings(null).execute(); + } + + @Test + public void testListUsersWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"total_results\": 12, \"limit\": 5, \"first_url\": \"firstUrl\", \"next_url\": \"nextUrl\", \"resources\": [{\"id\": \"id\", \"iam_id\": \"iamId\", \"realm\": \"realm\", \"user_id\": \"userId\", \"firstname\": \"firstname\", \"lastname\": \"lastname\", \"state\": \"state\", \"email\": \"email\", \"phonenumber\": \"phonenumber\", \"altphonenumber\": \"altphonenumber\", \"photo\": \"photo\", \"account_id\": \"accountId\"}]}"; + String listUsersPath = "/v2/accounts/testString/users"; + + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListUsersOptions model + ListUsersOptions listUsersOptionsModel = new ListUsersOptions.Builder() + .accountId("testString") + .state("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = userManagementService.listUsers(listUsersOptionsModel).execute(); + assertNotNull(response); + UserList responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("state"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listUsersPath); + } + + // Test the listUsers operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListUsersNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + userManagementService.listUsers(null).execute(); + } + + @Test + public void testInviteUsersWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"total_results\": 12, \"limit\": 5, \"first_url\": \"firstUrl\", \"next_url\": \"nextUrl\", \"resources\": [{\"id\": \"id\", \"iam_id\": \"iamId\", \"realm\": \"realm\", \"user_id\": \"userId\", \"firstname\": \"firstname\", \"lastname\": \"lastname\", \"state\": \"state\", \"email\": \"email\", \"phonenumber\": \"phonenumber\", \"altphonenumber\": \"altphonenumber\", \"photo\": \"photo\", \"account_id\": \"accountId\"}]}"; + String inviteUsersPath = "/v2/accounts/testString/users"; + + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the InviteUser model + InviteUser inviteUserModel = new InviteUser.Builder() + .email("testString") + .accountRole("testString") + .build(); + + // Construct an instance of the Role model + Role roleModel = new Role.Builder() + .roleId("testString") + .build(); + + // Construct an instance of the Attribute model + Attribute attributeModel = new Attribute.Builder() + .name("testString") + .value("testString") + .build(); + + // Construct an instance of the Resource model + Resource resourceModel = new Resource.Builder() + .attributes(new java.util.ArrayList(java.util.Arrays.asList(attributeModel))) + .build(); + + // Construct an instance of the InviteUserIamPolicy model + InviteUserIamPolicy inviteUserIamPolicyModel = new InviteUserIamPolicy.Builder() + .roles(new java.util.ArrayList(java.util.Arrays.asList(roleModel))) + .resources(new java.util.ArrayList(java.util.Arrays.asList(resourceModel))) + .build(); + + // Construct an instance of the InviteUsersOptions model + InviteUsersOptions inviteUsersOptionsModel = new InviteUsersOptions.Builder() + .accountId("testString") + .users(new java.util.ArrayList(java.util.Arrays.asList(inviteUserModel))) + .iamPolicy(new java.util.ArrayList(java.util.Arrays.asList(inviteUserIamPolicyModel))) + .accessGroups(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = userManagementService.inviteUsers(inviteUsersOptionsModel).execute(); + assertNotNull(response); + UserList responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, inviteUsersPath); + } + + // Test the inviteUsers operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInviteUsersNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + userManagementService.inviteUsers(null).execute(); + } + + @Test + public void testGetUserProfileWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"id\": \"id\", \"iam_id\": \"iamId\", \"realm\": \"realm\", \"user_id\": \"userId\", \"firstname\": \"firstname\", \"lastname\": \"lastname\", \"state\": \"state\", \"email\": \"email\", \"phonenumber\": \"phonenumber\", \"altphonenumber\": \"altphonenumber\", \"photo\": \"photo\", \"account_id\": \"accountId\"}"; + String getUserProfilePath = "/v2/accounts/testString/users/testString"; + + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetUserProfileOptions model + GetUserProfileOptions getUserProfileOptionsModel = new GetUserProfileOptions.Builder() + .accountId("testString") + .iamId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = userManagementService.getUserProfile(getUserProfileOptionsModel).execute(); + assertNotNull(response); + UserProfile responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getUserProfilePath); + } + + // Test the getUserProfile operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetUserProfileNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + userManagementService.getUserProfile(null).execute(); + } + + @Test + public void testUpdateUserProfilesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String updateUserProfilesPath = "/v2/accounts/testString/users/testString"; + + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateUserProfilesOptions model + UpdateUserProfilesOptions updateUserProfilesOptionsModel = new UpdateUserProfilesOptions.Builder() + .accountId("testString") + .iamId("testString") + .firstname("testString") + .lastname("testString") + .state("testString") + .email("testString") + .phonenumber("testString") + .altphonenumber("testString") + .photo("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = userManagementService.updateUserProfiles(updateUserProfilesOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PATCH"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateUserProfilesPath); + } + + // Test the updateUserProfiles operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateUserProfilesNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + userManagementService.updateUserProfiles(null).execute(); + } + + @Test + public void testRemoveUsersWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String removeUsersPath = "/v2/accounts/testString/users/testString"; + + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the RemoveUsersOptions model + RemoveUsersOptions removeUsersOptionsModel = new RemoveUsersOptions.Builder() + .accountId("testString") + .iamId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = userManagementService.removeUsers(removeUsersOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, removeUsersPath); + } + + // Test the removeUsers operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRemoveUsersNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + userManagementService.removeUsers(null).execute(); + } + + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } + catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + } + + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + userManagementService = null; + } +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/AttributeTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/AttributeTest.java new file mode 100644 index 0000000000..592016dae3 --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/AttributeTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.Attribute; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the Attribute model. + */ +public class AttributeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAttribute() throws Throwable { + Attribute attributeModel = new Attribute.Builder() + .name("testString") + .value("testString") + .build(); + assertEquals(attributeModel.name(), "testString"); + assertEquals(attributeModel.value(), "testString"); + + String json = TestUtilities.serialize(attributeModel); + + Attribute attributeModelNew = TestUtilities.deserialize(json, Attribute.class); + assertTrue(attributeModelNew instanceof Attribute); + assertEquals(attributeModelNew.name(), "testString"); + assertEquals(attributeModelNew.value(), "testString"); + } +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/GetUserProfileOptionsTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/GetUserProfileOptionsTest.java new file mode 100644 index 0000000000..e0447427fb --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/GetUserProfileOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.GetUserProfileOptions; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the GetUserProfileOptions model. + */ +public class GetUserProfileOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetUserProfileOptions() throws Throwable { + GetUserProfileOptions getUserProfileOptionsModel = new GetUserProfileOptions.Builder() + .accountId("testString") + .iamId("testString") + .build(); + assertEquals(getUserProfileOptionsModel.accountId(), "testString"); + assertEquals(getUserProfileOptionsModel.iamId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetUserProfileOptionsError() throws Throwable { + new GetUserProfileOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/GetUserSettingsOptionsTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/GetUserSettingsOptionsTest.java new file mode 100644 index 0000000000..46c2cc502a --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/GetUserSettingsOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.GetUserSettingsOptions; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the GetUserSettingsOptions model. + */ +public class GetUserSettingsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetUserSettingsOptions() throws Throwable { + GetUserSettingsOptions getUserSettingsOptionsModel = new GetUserSettingsOptions.Builder() + .accountId("testString") + .iamId("testString") + .build(); + assertEquals(getUserSettingsOptionsModel.accountId(), "testString"); + assertEquals(getUserSettingsOptionsModel.iamId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetUserSettingsOptionsError() throws Throwable { + new GetUserSettingsOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUserIamPolicyTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUserIamPolicyTest.java new file mode 100644 index 0000000000..25678b8be8 --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUserIamPolicyTest.java @@ -0,0 +1,71 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.Attribute; +import com.ibm.cloud.platform_services.user_management.v1.model.InviteUserIamPolicy; +import com.ibm.cloud.platform_services.user_management.v1.model.Resource; +import com.ibm.cloud.platform_services.user_management.v1.model.Role; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the InviteUserIamPolicy model. + */ +public class InviteUserIamPolicyTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testInviteUserIamPolicy() throws Throwable { + Attribute attributeModel = new Attribute.Builder() + .name("testString") + .value("testString") + .build(); + assertEquals(attributeModel.name(), "testString"); + assertEquals(attributeModel.value(), "testString"); + + Resource resourceModel = new Resource.Builder() + .attributes(new java.util.ArrayList(java.util.Arrays.asList(attributeModel))) + .build(); + assertEquals(resourceModel.attributes(), new java.util.ArrayList(java.util.Arrays.asList(attributeModel))); + + Role roleModel = new Role.Builder() + .roleId("testString") + .build(); + assertEquals(roleModel.roleId(), "testString"); + + InviteUserIamPolicy inviteUserIamPolicyModel = new InviteUserIamPolicy.Builder() + .roles(new java.util.ArrayList(java.util.Arrays.asList(roleModel))) + .resources(new java.util.ArrayList(java.util.Arrays.asList(resourceModel))) + .build(); + assertEquals(inviteUserIamPolicyModel.roles(), new java.util.ArrayList(java.util.Arrays.asList(roleModel))); + assertEquals(inviteUserIamPolicyModel.resources(), new java.util.ArrayList(java.util.Arrays.asList(resourceModel))); + + String json = TestUtilities.serialize(inviteUserIamPolicyModel); + + InviteUserIamPolicy inviteUserIamPolicyModelNew = TestUtilities.deserialize(json, InviteUserIamPolicy.class); + assertTrue(inviteUserIamPolicyModelNew instanceof InviteUserIamPolicy); + } +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUserTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUserTest.java new file mode 100644 index 0000000000..db7c3d7d0e --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUserTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.InviteUser; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the InviteUser model. + */ +public class InviteUserTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testInviteUser() throws Throwable { + InviteUser inviteUserModel = new InviteUser.Builder() + .email("testString") + .accountRole("testString") + .build(); + assertEquals(inviteUserModel.email(), "testString"); + assertEquals(inviteUserModel.accountRole(), "testString"); + + String json = TestUtilities.serialize(inviteUserModel); + + InviteUser inviteUserModelNew = TestUtilities.deserialize(json, InviteUser.class); + assertTrue(inviteUserModelNew instanceof InviteUser); + assertEquals(inviteUserModelNew.email(), "testString"); + assertEquals(inviteUserModelNew.accountRole(), "testString"); + } +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUsersOptionsTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUsersOptionsTest.java new file mode 100644 index 0000000000..e20d6620fb --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/InviteUsersOptionsTest.java @@ -0,0 +1,92 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.Attribute; +import com.ibm.cloud.platform_services.user_management.v1.model.InviteUser; +import com.ibm.cloud.platform_services.user_management.v1.model.InviteUserIamPolicy; +import com.ibm.cloud.platform_services.user_management.v1.model.InviteUsersOptions; +import com.ibm.cloud.platform_services.user_management.v1.model.Resource; +import com.ibm.cloud.platform_services.user_management.v1.model.Role; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the InviteUsersOptions model. + */ +public class InviteUsersOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testInviteUsersOptions() throws Throwable { + Attribute attributeModel = new Attribute.Builder() + .name("testString") + .value("testString") + .build(); + assertEquals(attributeModel.name(), "testString"); + assertEquals(attributeModel.value(), "testString"); + + Resource resourceModel = new Resource.Builder() + .attributes(new java.util.ArrayList(java.util.Arrays.asList(attributeModel))) + .build(); + assertEquals(resourceModel.attributes(), new java.util.ArrayList(java.util.Arrays.asList(attributeModel))); + + Role roleModel = new Role.Builder() + .roleId("testString") + .build(); + assertEquals(roleModel.roleId(), "testString"); + + InviteUser inviteUserModel = new InviteUser.Builder() + .email("testString") + .accountRole("testString") + .build(); + assertEquals(inviteUserModel.email(), "testString"); + assertEquals(inviteUserModel.accountRole(), "testString"); + + InviteUserIamPolicy inviteUserIamPolicyModel = new InviteUserIamPolicy.Builder() + .roles(new java.util.ArrayList(java.util.Arrays.asList(roleModel))) + .resources(new java.util.ArrayList(java.util.Arrays.asList(resourceModel))) + .build(); + assertEquals(inviteUserIamPolicyModel.roles(), new java.util.ArrayList(java.util.Arrays.asList(roleModel))); + assertEquals(inviteUserIamPolicyModel.resources(), new java.util.ArrayList(java.util.Arrays.asList(resourceModel))); + + InviteUsersOptions inviteUsersOptionsModel = new InviteUsersOptions.Builder() + .accountId("testString") + .users(new java.util.ArrayList(java.util.Arrays.asList(inviteUserModel))) + .iamPolicy(new java.util.ArrayList(java.util.Arrays.asList(inviteUserIamPolicyModel))) + .accessGroups(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(inviteUsersOptionsModel.accountId(), "testString"); + assertEquals(inviteUsersOptionsModel.users(), new java.util.ArrayList(java.util.Arrays.asList(inviteUserModel))); + assertEquals(inviteUsersOptionsModel.iamPolicy(), new java.util.ArrayList(java.util.Arrays.asList(inviteUserIamPolicyModel))); + assertEquals(inviteUsersOptionsModel.accessGroups(), new java.util.ArrayList(java.util.Arrays.asList("testString"))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInviteUsersOptionsError() throws Throwable { + new InviteUsersOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/ListUsersOptionsTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/ListUsersOptionsTest.java new file mode 100644 index 0000000000..dcb9cdf984 --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/ListUsersOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.ListUsersOptions; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ListUsersOptions model. + */ +public class ListUsersOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListUsersOptions() throws Throwable { + ListUsersOptions listUsersOptionsModel = new ListUsersOptions.Builder() + .accountId("testString") + .state("testString") + .build(); + assertEquals(listUsersOptionsModel.accountId(), "testString"); + assertEquals(listUsersOptionsModel.state(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListUsersOptionsError() throws Throwable { + new ListUsersOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/RemoveUsersOptionsTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/RemoveUsersOptionsTest.java new file mode 100644 index 0000000000..9dd2261cd7 --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/RemoveUsersOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.RemoveUsersOptions; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the RemoveUsersOptions model. + */ +public class RemoveUsersOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRemoveUsersOptions() throws Throwable { + RemoveUsersOptions removeUsersOptionsModel = new RemoveUsersOptions.Builder() + .accountId("testString") + .iamId("testString") + .build(); + assertEquals(removeUsersOptionsModel.accountId(), "testString"); + assertEquals(removeUsersOptionsModel.iamId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRemoveUsersOptionsError() throws Throwable { + new RemoveUsersOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/ResourceTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/ResourceTest.java new file mode 100644 index 0000000000..64996dd1ce --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/ResourceTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.Attribute; +import com.ibm.cloud.platform_services.user_management.v1.model.Resource; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the Resource model. + */ +public class ResourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testResource() throws Throwable { + Attribute attributeModel = new Attribute.Builder() + .name("testString") + .value("testString") + .build(); + assertEquals(attributeModel.name(), "testString"); + assertEquals(attributeModel.value(), "testString"); + + Resource resourceModel = new Resource.Builder() + .attributes(new java.util.ArrayList(java.util.Arrays.asList(attributeModel))) + .build(); + assertEquals(resourceModel.attributes(), new java.util.ArrayList(java.util.Arrays.asList(attributeModel))); + + String json = TestUtilities.serialize(resourceModel); + + Resource resourceModelNew = TestUtilities.deserialize(json, Resource.class); + assertTrue(resourceModelNew instanceof Resource); + } +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/RoleTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/RoleTest.java new file mode 100644 index 0000000000..4f76a6b301 --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/RoleTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.Role; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the Role model. + */ +public class RoleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRole() throws Throwable { + Role roleModel = new Role.Builder() + .roleId("testString") + .build(); + assertEquals(roleModel.roleId(), "testString"); + + String json = TestUtilities.serialize(roleModel); + + Role roleModelNew = TestUtilities.deserialize(json, Role.class); + assertTrue(roleModelNew instanceof Role); + assertEquals(roleModelNew.roleId(), "testString"); + } +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UpdateUserProfilesOptionsTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UpdateUserProfilesOptionsTest.java new file mode 100644 index 0000000000..7d226b349e --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UpdateUserProfilesOptionsTest.java @@ -0,0 +1,64 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.UpdateUserProfilesOptions; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the UpdateUserProfilesOptions model. + */ +public class UpdateUserProfilesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateUserProfilesOptions() throws Throwable { + UpdateUserProfilesOptions updateUserProfilesOptionsModel = new UpdateUserProfilesOptions.Builder() + .accountId("testString") + .iamId("testString") + .firstname("testString") + .lastname("testString") + .state("testString") + .email("testString") + .phonenumber("testString") + .altphonenumber("testString") + .photo("testString") + .build(); + assertEquals(updateUserProfilesOptionsModel.accountId(), "testString"); + assertEquals(updateUserProfilesOptionsModel.iamId(), "testString"); + assertEquals(updateUserProfilesOptionsModel.firstname(), "testString"); + assertEquals(updateUserProfilesOptionsModel.lastname(), "testString"); + assertEquals(updateUserProfilesOptionsModel.state(), "testString"); + assertEquals(updateUserProfilesOptionsModel.email(), "testString"); + assertEquals(updateUserProfilesOptionsModel.phonenumber(), "testString"); + assertEquals(updateUserProfilesOptionsModel.altphonenumber(), "testString"); + assertEquals(updateUserProfilesOptionsModel.photo(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateUserProfilesOptionsError() throws Throwable { + new UpdateUserProfilesOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UpdateUserSettingsOptionsTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UpdateUserSettingsOptionsTest.java new file mode 100644 index 0000000000..54da68c000 --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UpdateUserSettingsOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.UpdateUserSettingsOptions; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the UpdateUserSettingsOptions model. + */ +public class UpdateUserSettingsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateUserSettingsOptions() throws Throwable { + UpdateUserSettingsOptions updateUserSettingsOptionsModel = new UpdateUserSettingsOptions.Builder() + .accountId("testString") + .iamId("testString") + .language("testString") + .notificationLanguage("testString") + .allowedIpAddresses("32.96.110.50,172.16.254.1") + .selfManage(true) + .build(); + assertEquals(updateUserSettingsOptionsModel.accountId(), "testString"); + assertEquals(updateUserSettingsOptionsModel.iamId(), "testString"); + assertEquals(updateUserSettingsOptionsModel.language(), "testString"); + assertEquals(updateUserSettingsOptionsModel.notificationLanguage(), "testString"); + assertEquals(updateUserSettingsOptionsModel.allowedIpAddresses(), "32.96.110.50,172.16.254.1"); + assertEquals(updateUserSettingsOptionsModel.selfManage(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateUserSettingsOptionsError() throws Throwable { + new UpdateUserSettingsOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UserListTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UserListTest.java new file mode 100644 index 0000000000..9b63a5f2a0 --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UserListTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.UserList; +import com.ibm.cloud.platform_services.user_management.v1.model.UserProfile; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the UserList model. + */ +public class UserListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUserList() throws Throwable { + UserList userListModel = new UserList(); + assertNull(userListModel.getTotalResults()); + assertNull(userListModel.getLimit()); + assertNull(userListModel.getFirstUrl()); + assertNull(userListModel.getNextUrl()); + assertNull(userListModel.getResources()); + } +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UserProfileTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UserProfileTest.java new file mode 100644 index 0000000000..711d1c1b6c --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UserProfileTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.UserProfile; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the UserProfile model. + */ +public class UserProfileTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUserProfile() throws Throwable { + UserProfile userProfileModel = new UserProfile(); + assertNull(userProfileModel.getId()); + assertNull(userProfileModel.getIamId()); + assertNull(userProfileModel.getRealm()); + assertNull(userProfileModel.getUserId()); + assertNull(userProfileModel.getFirstname()); + assertNull(userProfileModel.getLastname()); + assertNull(userProfileModel.getState()); + assertNull(userProfileModel.getEmail()); + assertNull(userProfileModel.getPhonenumber()); + assertNull(userProfileModel.getAltphonenumber()); + assertNull(userProfileModel.getPhoto()); + assertNull(userProfileModel.getAccountId()); + } +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UserSettingsTest.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UserSettingsTest.java new file mode 100644 index 0000000000..4f751eec40 --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/model/UserSettingsTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.user_management.v1.model; + +import com.ibm.cloud.platform_services.user_management.v1.model.UserSettings; +import com.ibm.cloud.platform_services.user_management.v1.utils.TestUtilities; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; + +import java.util.HashMap; +import java.util.List; + +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the UserSettings model. + */ +public class UserSettingsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUserSettings() throws Throwable { + UserSettings userSettingsModel = new UserSettings.Builder() + .language("testString") + .notificationLanguage("testString") + .allowedIpAddresses("32.96.110.50,172.16.254.1") + .selfManage(true) + .build(); + assertEquals(userSettingsModel.language(), "testString"); + assertEquals(userSettingsModel.notificationLanguage(), "testString"); + assertEquals(userSettingsModel.allowedIpAddresses(), "32.96.110.50,172.16.254.1"); + assertEquals(userSettingsModel.selfManage(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(userSettingsModel); + + UserSettings userSettingsModelNew = TestUtilities.deserialize(json, UserSettings.class); + assertTrue(userSettingsModelNew instanceof UserSettings); + assertEquals(userSettingsModelNew.language(), "testString"); + assertEquals(userSettingsModelNew.notificationLanguage(), "testString"); + assertEquals(userSettingsModelNew.allowedIpAddresses(), "32.96.110.50,172.16.254.1"); + assertEquals(userSettingsModelNew.selfManage(), Boolean.valueOf(true)); + } +} \ No newline at end of file diff --git a/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/utils/TestUtilities.java b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/utils/TestUtilities.java new file mode 100644 index 0000000000..9fbdafe277 --- /dev/null +++ b/modules/user-management/src/test/java/com/ibm/cloud/platform_services/user_management/v1/utils/TestUtilities.java @@ -0,0 +1,129 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.cloud.platform_services.user_management.v1.utils; + +import java.util.Map; +import java.util.Set; +import java.util.List; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.text.SimpleDateFormat; + +import okhttp3.mockwebserver.RecordedRequest; +import okhttp3.HttpUrl; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; + +/** + * A class used by the unit tests containing utility functions. + */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { put("key1", createMockStream("This is a mock file.")); } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 18d8e4ab50..28102d43bb 100644 --- a/pom.xml +++ b/pom.xml @@ -54,6 +54,7 @@ modules/open-service-broker modules/resource-controller modules/resource-manager + modules/user-management modules/coverage-reports