diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTagging.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTagging.java new file mode 100644 index 0000000000..a18c293d1d --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTagging.java @@ -0,0 +1,430 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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: 3.111.0-1bfb72c2-20260206-185521 + */ + +package com.ibm.cloud.platform_services.global_tagging.v1; + +import com.google.gson.JsonObject; +import com.ibm.cloud.platform_services.common.SdkCommon; +import com.ibm.cloud.platform_services.global_tagging.v1.model.AttachTagOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.CreateTagOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.CreateTagResults; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagAllOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagResults; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagsResult; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DetachTagOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.ListTagsOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.TagList; +import com.ibm.cloud.platform_services.global_tagging.v1.model.TagResults; +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.RequestUtils; +import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +/** + * Manage your tags with the Tagging API in IBM Cloud. You can attach, detach, delete, or list all of the tags in your + * billing account with the Tagging API. The tag name must be unique within a billing account. You can create tags in + * two formats: `key:value` or `label`. The tagging API supports three types of tag: `user` `service`, and `access` + * tags. `service` tags cannot be attached to IMS resources. `service` tags must be in the form + * `service_prefix:tag_label` where `service_prefix` identifies the Service owning the tag. `access` tags cannot be + * attached to IMS resources. They must be in the form `key:value`. You can replace all resource's tags using the + * `replace` query parameter in the attach operation. You can update the `value` of a resource's tag in the format + * `key:value`, using the `update` query parameter in the attach operation. + * + * API Version: 1.2.0 + */ +public class GlobalTagging extends BaseService { + + /** + * Default service name used when configuring the `GlobalTagging` client. + */ + public static final String DEFAULT_SERVICE_NAME = "global_tagging"; + + /** + * Default service endpoint URL. + */ + public static final String DEFAULT_SERVICE_URL = "https://tags.global-search-tagging.cloud.ibm.com"; + + /** + * Class method which constructs an instance of the `GlobalTagging` client. + * The default service name is used to configure the client instance. + * + * @return an instance of the `GlobalTagging` client using external configuration + */ + public static GlobalTagging newInstance() { + return newInstance(DEFAULT_SERVICE_NAME); + } + + /** + * Class method which constructs an instance of the `GlobalTagging` 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 `GlobalTagging` client using external configuration + */ + public static GlobalTagging newInstance(String serviceName) { + Authenticator authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName); + GlobalTagging service = new GlobalTagging(serviceName, authenticator); + service.configureService(serviceName); + return service; + } + + /** + * Constructs an instance of the `GlobalTagging` 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 GlobalTagging(String serviceName, Authenticator authenticator) { + super(serviceName, authenticator); + setServiceUrl(DEFAULT_SERVICE_URL); + } + + /** + * Get all tags. + * + * Lists all tags that are in a billing account. Use the `attached_to` parameter to return the list of tags that are + * attached to the specified resource. + * + * @param listTagsOptions the {@link ListTagsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link TagList} + */ + public ServiceCall listTags(ListTagsOptions listTagsOptions) { + if (listTagsOptions == null) { + listTagsOptions = new ListTagsOptions.Builder().build(); + } + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/tags")); + Map sdkHeaders = SdkCommon.getSdkHeaders("global_tagging", "v1", "listTags"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (listTagsOptions.xRequestId() != null) { + builder.header("x-request-id", listTagsOptions.xRequestId()); + } + if (listTagsOptions.xCorrelationId() != null) { + builder.header("x-correlation-id", listTagsOptions.xCorrelationId()); + } + if (listTagsOptions.accountId() != null) { + builder.query("account_id", String.valueOf(listTagsOptions.accountId())); + } + if (listTagsOptions.tagType() != null) { + builder.query("tag_type", String.valueOf(listTagsOptions.tagType())); + } + if (listTagsOptions.fullData() != null) { + builder.query("full_data", String.valueOf(listTagsOptions.fullData())); + } + if (listTagsOptions.providers() != null) { + builder.query("providers", RequestUtils.join(listTagsOptions.providers(), ",")); + } + if (listTagsOptions.attachedTo() != null) { + builder.query("attached_to", String.valueOf(listTagsOptions.attachedTo())); + } + if (listTagsOptions.offset() != null) { + builder.query("offset", String.valueOf(listTagsOptions.offset())); + } + if (listTagsOptions.limit() != null) { + builder.query("limit", String.valueOf(listTagsOptions.limit())); + } + if (listTagsOptions.timeout() != null) { + builder.query("timeout", String.valueOf(listTagsOptions.timeout())); + } + if (listTagsOptions.orderByName() != null) { + builder.query("order_by_name", String.valueOf(listTagsOptions.orderByName())); + } + if (listTagsOptions.attachedOnly() != null) { + builder.query("attached_only", String.valueOf(listTagsOptions.attachedOnly())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get all tags. + * + * Lists all tags that are in a billing account. Use the `attached_to` parameter to return the list of tags that are + * attached to the specified resource. + * + * @return a {@link ServiceCall} with a result of type {@link TagList} + */ + public ServiceCall listTags() { + return listTags(null); + } + + /** + * Create an access management tag. + * + * Create an access management tag. To create an `access` tag, you must have the access listed in the [Granting users + * access to tag resources](https://cloud.ibm.com/docs/account?topic=account-access) documentation. `service` and + * `user` tags cannot be created upfront. They are created when they are attached for the first time to a resource. + * + * @param createTagOptions the {@link CreateTagOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link CreateTagResults} + */ + public ServiceCall createTag(CreateTagOptions createTagOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(createTagOptions, + "createTagOptions cannot be null"); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/tags")); + Map sdkHeaders = SdkCommon.getSdkHeaders("global_tagging", "v1", "createTag"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (createTagOptions.xRequestId() != null) { + builder.header("x-request-id", createTagOptions.xRequestId()); + } + if (createTagOptions.xCorrelationId() != null) { + builder.header("x-correlation-id", createTagOptions.xCorrelationId()); + } + if (createTagOptions.accountId() != null) { + builder.query("account_id", String.valueOf(createTagOptions.accountId())); + } + if (createTagOptions.tagType() != null) { + builder.query("tag_type", String.valueOf(createTagOptions.tagType())); + } + final JsonObject contentJson = new JsonObject(); + contentJson.add("tag_names", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createTagOptions.tagNames())); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete all unused tags. + * + * Delete the tags that are not attached to any resource. + * + * @param deleteTagAllOptions the {@link DeleteTagAllOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DeleteTagsResult} + */ + public ServiceCall deleteTagAll(DeleteTagAllOptions deleteTagAllOptions) { + if (deleteTagAllOptions == null) { + deleteTagAllOptions = new DeleteTagAllOptions.Builder().build(); + } + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/tags")); + Map sdkHeaders = SdkCommon.getSdkHeaders("global_tagging", "v1", "deleteTagAll"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (deleteTagAllOptions.xRequestId() != null) { + builder.header("x-request-id", deleteTagAllOptions.xRequestId()); + } + if (deleteTagAllOptions.xCorrelationId() != null) { + builder.header("x-correlation-id", deleteTagAllOptions.xCorrelationId()); + } + if (deleteTagAllOptions.providers() != null) { + builder.query("providers", String.valueOf(deleteTagAllOptions.providers())); + } + if (deleteTagAllOptions.accountId() != null) { + builder.query("account_id", String.valueOf(deleteTagAllOptions.accountId())); + } + if (deleteTagAllOptions.tagType() != null) { + builder.query("tag_type", String.valueOf(deleteTagAllOptions.tagType())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete all unused tags. + * + * Delete the tags that are not attached to any resource. + * + * @return a {@link ServiceCall} with a result of type {@link DeleteTagsResult} + */ + public ServiceCall deleteTagAll() { + return deleteTagAll(null); + } + + /** + * Delete an unused tag. + * + * Delete an existing tag. A tag can be deleted only if it is not attached to any resource. + * + * @param deleteTagOptions the {@link DeleteTagOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link DeleteTagResults} + */ + public ServiceCall deleteTag(DeleteTagOptions deleteTagOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteTagOptions, + "deleteTagOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("tag_name", deleteTagOptions.tagName()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/tags/{tag_name}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("global_tagging", "v1", "deleteTag"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (deleteTagOptions.xRequestId() != null) { + builder.header("x-request-id", deleteTagOptions.xRequestId()); + } + if (deleteTagOptions.xCorrelationId() != null) { + builder.header("x-correlation-id", deleteTagOptions.xCorrelationId()); + } + if (deleteTagOptions.providers() != null) { + builder.query("providers", RequestUtils.join(deleteTagOptions.providers(), ",")); + } + if (deleteTagOptions.accountId() != null) { + builder.query("account_id", String.valueOf(deleteTagOptions.accountId())); + } + if (deleteTagOptions.tagType() != null) { + builder.query("tag_type", String.valueOf(deleteTagOptions.tagType())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Attach tags. + * + * Attaches one or more tags to one or more resources. Each resource can have no more than 1000 tags per each 'user' + * and 'service' type, and no more than 250 'access' tags (which is the account limit). + * + * @param attachTagOptions the {@link AttachTagOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link TagResults} + */ + public ServiceCall attachTag(AttachTagOptions attachTagOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(attachTagOptions, + "attachTagOptions cannot be null"); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/tags/attach")); + Map sdkHeaders = SdkCommon.getSdkHeaders("global_tagging", "v1", "attachTag"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (attachTagOptions.xRequestId() != null) { + builder.header("x-request-id", attachTagOptions.xRequestId()); + } + if (attachTagOptions.xCorrelationId() != null) { + builder.header("x-correlation-id", attachTagOptions.xCorrelationId()); + } + if (attachTagOptions.accountId() != null) { + builder.query("account_id", String.valueOf(attachTagOptions.accountId())); + } + if (attachTagOptions.tagType() != null) { + builder.query("tag_type", String.valueOf(attachTagOptions.tagType())); + } + if (attachTagOptions.replace() != null) { + builder.query("replace", String.valueOf(attachTagOptions.replace())); + } + if (attachTagOptions.update() != null) { + builder.query("update", String.valueOf(attachTagOptions.update())); + } + final JsonObject contentJson = new JsonObject(); + if (attachTagOptions.tagName() != null) { + contentJson.addProperty("tag_name", attachTagOptions.tagName()); + } + if (attachTagOptions.tagNames() != null) { + contentJson.add("tag_names", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(attachTagOptions.tagNames())); + } + if (attachTagOptions.resources() != null) { + contentJson.add("resources", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(attachTagOptions.resources())); + } + if (attachTagOptions.query() != null) { + contentJson.add("query", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(attachTagOptions.query())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Attach tags. + * + * Attaches one or more tags to one or more resources. Each resource can have no more than 1000 tags per each 'user' + * and 'service' type, and no more than 250 'access' tags (which is the account limit). + * + * @return a {@link ServiceCall} with a result of type {@link TagResults} + */ + public ServiceCall attachTag() { + return attachTag(null); + } + + /** + * Detach tags. + * + * Detaches one or more tags from one or more resources. + * + * @param detachTagOptions the {@link DetachTagOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link TagResults} + */ + public ServiceCall detachTag(DetachTagOptions detachTagOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(detachTagOptions, + "detachTagOptions cannot be null"); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/tags/detach")); + Map sdkHeaders = SdkCommon.getSdkHeaders("global_tagging", "v1", "detachTag"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (detachTagOptions.xRequestId() != null) { + builder.header("x-request-id", detachTagOptions.xRequestId()); + } + if (detachTagOptions.xCorrelationId() != null) { + builder.header("x-correlation-id", detachTagOptions.xCorrelationId()); + } + if (detachTagOptions.accountId() != null) { + builder.query("account_id", String.valueOf(detachTagOptions.accountId())); + } + if (detachTagOptions.tagType() != null) { + builder.query("tag_type", String.valueOf(detachTagOptions.tagType())); + } + final JsonObject contentJson = new JsonObject(); + if (detachTagOptions.tagName() != null) { + contentJson.addProperty("tag_name", detachTagOptions.tagName()); + } + if (detachTagOptions.tagNames() != null) { + contentJson.add("tag_names", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(detachTagOptions.tagNames())); + } + if (detachTagOptions.resources() != null) { + contentJson.add("resources", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(detachTagOptions.resources())); + } + if (detachTagOptions.query() != null) { + contentJson.add("query", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(detachTagOptions.query())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Detach tags. + * + * Detaches one or more tags from one or more resources. + * + * @return a {@link ServiceCall} with a result of type {@link TagResults} + */ + public ServiceCall detachTag() { + return detachTag(null); + } + +} diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptions.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptions.java new file mode 100644 index 0000000000..4dde06f1cd --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptions.java @@ -0,0 +1,393 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The attachTag options. + */ +public class AttachTagOptions extends GenericModel { + + /** + * The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported + * for IMS resources. + */ + public interface TagType { + /** user. */ + String USER = "user"; + /** service. */ + String SERVICE = "service"; + /** access. */ + String ACCESS = "access"; + } + + protected String tagName; + protected List tagNames; + protected List resources; + protected QueryString query; + protected String xRequestId; + protected String xCorrelationId; + protected String accountId; + protected String tagType; + protected Boolean replace; + protected Boolean update; + + /** + * Builder. + */ + public static class Builder { + private String tagName; + private List tagNames; + private List resources; + private QueryString query; + private String xRequestId; + private String xCorrelationId; + private String accountId; + private String tagType; + private Boolean replace; + private Boolean update; + + /** + * Instantiates a new Builder from an existing AttachTagOptions instance. + * + * @param attachTagOptions the instance to initialize the Builder with + */ + private Builder(AttachTagOptions attachTagOptions) { + this.tagName = attachTagOptions.tagName; + this.tagNames = attachTagOptions.tagNames; + this.resources = attachTagOptions.resources; + this.query = attachTagOptions.query; + this.xRequestId = attachTagOptions.xRequestId; + this.xCorrelationId = attachTagOptions.xCorrelationId; + this.accountId = attachTagOptions.accountId; + this.tagType = attachTagOptions.tagType; + this.replace = attachTagOptions.replace; + this.update = attachTagOptions.update; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a AttachTagOptions. + * + * @return the new AttachTagOptions instance + */ + public AttachTagOptions build() { + return new AttachTagOptions(this); + } + + /** + * Adds a new element to tagNames. + * + * @param tagNames the new element to be added + * @return the AttachTagOptions builder + */ + public Builder addTagNames(String tagNames) { + com.ibm.cloud.sdk.core.util.Validator.notNull(tagNames, + "tagNames cannot be null"); + if (this.tagNames == null) { + this.tagNames = new ArrayList(); + } + this.tagNames.add(tagNames); + return this; + } + + /** + * Adds a new element to resources. + * + * @param resources the new element to be added + * @return the AttachTagOptions 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 tagName. + * + * @param tagName the tagName + * @return the AttachTagOptions builder + */ + public Builder tagName(String tagName) { + this.tagName = tagName; + return this; + } + + /** + * Set the tagNames. + * Existing tagNames will be replaced. + * + * @param tagNames the tagNames + * @return the AttachTagOptions builder + */ + public Builder tagNames(List tagNames) { + this.tagNames = tagNames; + return this; + } + + /** + * Set the resources. + * Existing resources will be replaced. + * + * @param resources the resources + * @return the AttachTagOptions builder + */ + public Builder resources(List resources) { + this.resources = resources; + return this; + } + + /** + * Set the query. + * + * @param query the query + * @return the AttachTagOptions builder + */ + public Builder query(QueryString query) { + this.query = query; + return this; + } + + /** + * Set the xRequestId. + * + * @param xRequestId the xRequestId + * @return the AttachTagOptions builder + */ + public Builder xRequestId(String xRequestId) { + this.xRequestId = xRequestId; + return this; + } + + /** + * Set the xCorrelationId. + * + * @param xCorrelationId the xCorrelationId + * @return the AttachTagOptions builder + */ + public Builder xCorrelationId(String xCorrelationId) { + this.xCorrelationId = xCorrelationId; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the AttachTagOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the tagType. + * + * @param tagType the tagType + * @return the AttachTagOptions builder + */ + public Builder tagType(String tagType) { + this.tagType = tagType; + return this; + } + + /** + * Set the replace. + * + * @param replace the replace + * @return the AttachTagOptions builder + */ + public Builder replace(Boolean replace) { + this.replace = replace; + return this; + } + + /** + * Set the update. + * + * @param update the update + * @return the AttachTagOptions builder + */ + public Builder update(Boolean update) { + this.update = update; + return this; + } + } + + protected AttachTagOptions() { } + + protected AttachTagOptions(Builder builder) { + tagName = builder.tagName; + tagNames = builder.tagNames; + resources = builder.resources; + query = builder.query; + xRequestId = builder.xRequestId; + xCorrelationId = builder.xCorrelationId; + accountId = builder.accountId; + tagType = builder.tagType; + replace = builder.replace; + update = builder.update; + } + + /** + * New builder. + * + * @return a AttachTagOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the tagName. + * + * The name of the tag to attach. + * + * @return the tagName + */ + public String tagName() { + return tagName; + } + + /** + * Gets the tagNames. + * + * An array of tag names to attach. + * + * @return the tagNames + */ + public List tagNames() { + return tagNames; + } + + /** + * Gets the resources. + * + * List of resources on which the tagging operation operates on. + * + * @return the resources + */ + public List resources() { + return resources; + } + + /** + * Gets the query. + * + * A valid Global Search string. + * + * @return the query + */ + public QueryString query() { + return query; + } + + /** + * Gets the xRequestId. + * + * An alphanumeric string that is used to trace the request. The value may include ASCII alphanumerics and any of + * following segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to + * 1024 bytes. The value is considered invalid and must be ignored if that value includes any other character or is + * longer than 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by + * a random (version 4) UUID. + * + * @return the xRequestId + */ + public String xRequestId() { + return xRequestId; + } + + /** + * Gets the xCorrelationId. + * + * An alphanumeric string that is used to trace the request as a part of a larger context: the same value is used for + * downstream requests and retries of those requests. The value may include ASCII alphanumerics and any of following + * segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to 1024 bytes. + * The value is considered invalid and must be ignored if that value includes any other character or is longer than + * 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by a random + * (version 4) UUID. + * + * @return the xCorrelationId + */ + public String xCorrelationId() { + return xCorrelationId; + } + + /** + * Gets the accountId. + * + * The ID of the billing account of the tagged resource. It is a required parameter if `tag_type` is set to `service`. + * Otherwise, it is inferred from the authorization IAM token. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the tagType. + * + * The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported + * for IMS resources. + * + * @return the tagType + */ + public String tagType() { + return tagType; + } + + /** + * Gets the replace. + * + * Flag to request replacement of all attached tags. Set `true` if you want to replace all tags attached to the + * resource with the current ones. Default value is false. + * + * @return the replace + */ + public Boolean replace() { + return replace; + } + + /** + * Gets the update. + * + * Flag to request update of attached tags in the format `key:value`. Here's how it works for each tag in the request + * body: If the tag to attach is in the format `key:value`, the System will atomically detach all existing tags + * starting with `key:` and attach the new `key:value` tag. If no such tags exist, a new `key:value` tag will be + * attached. If the tag is not in the `key:value` format (e.g., a simple label), the System will attach the label as + * usual. The update query parameter is available for user and access management tags, but not for service tags. + * + * @return the update + */ + public Boolean update() { + return update; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptions.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptions.java new file mode 100644 index 0000000000..140d43ab3c --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptions.java @@ -0,0 +1,245 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The createTag options. + */ +public class CreateTagOptions extends GenericModel { + + /** + * The type of the tags you want to create. The only allowed value is `access`. + */ + public interface TagType { + /** access. */ + String ACCESS = "access"; + } + + protected List tagNames; + protected String xRequestId; + protected String xCorrelationId; + protected String accountId; + protected String tagType; + + /** + * Builder. + */ + public static class Builder { + private List tagNames; + private String xRequestId; + private String xCorrelationId; + private String accountId; + private String tagType; + + /** + * Instantiates a new Builder from an existing CreateTagOptions instance. + * + * @param createTagOptions the instance to initialize the Builder with + */ + private Builder(CreateTagOptions createTagOptions) { + this.tagNames = createTagOptions.tagNames; + this.xRequestId = createTagOptions.xRequestId; + this.xCorrelationId = createTagOptions.xCorrelationId; + this.accountId = createTagOptions.accountId; + this.tagType = createTagOptions.tagType; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param tagNames the tagNames + */ + public Builder(List tagNames) { + this.tagNames = tagNames; + } + + /** + * Builds a CreateTagOptions. + * + * @return the new CreateTagOptions instance + */ + public CreateTagOptions build() { + return new CreateTagOptions(this); + } + + /** + * Adds a new element to tagNames. + * + * @param tagNames the new element to be added + * @return the CreateTagOptions builder + */ + public Builder addTagNames(String tagNames) { + com.ibm.cloud.sdk.core.util.Validator.notNull(tagNames, + "tagNames cannot be null"); + if (this.tagNames == null) { + this.tagNames = new ArrayList(); + } + this.tagNames.add(tagNames); + return this; + } + + /** + * Set the tagNames. + * Existing tagNames will be replaced. + * + * @param tagNames the tagNames + * @return the CreateTagOptions builder + */ + public Builder tagNames(List tagNames) { + this.tagNames = tagNames; + return this; + } + + /** + * Set the xRequestId. + * + * @param xRequestId the xRequestId + * @return the CreateTagOptions builder + */ + public Builder xRequestId(String xRequestId) { + this.xRequestId = xRequestId; + return this; + } + + /** + * Set the xCorrelationId. + * + * @param xCorrelationId the xCorrelationId + * @return the CreateTagOptions builder + */ + public Builder xCorrelationId(String xCorrelationId) { + this.xCorrelationId = xCorrelationId; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the CreateTagOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the tagType. + * + * @param tagType the tagType + * @return the CreateTagOptions builder + */ + public Builder tagType(String tagType) { + this.tagType = tagType; + return this; + } + } + + protected CreateTagOptions() { } + + protected CreateTagOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.tagNames, + "tagNames cannot be null"); + tagNames = builder.tagNames; + xRequestId = builder.xRequestId; + xCorrelationId = builder.xCorrelationId; + accountId = builder.accountId; + tagType = builder.tagType; + } + + /** + * New builder. + * + * @return a CreateTagOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the tagNames. + * + * An array of tag names to create. + * + * @return the tagNames + */ + public List tagNames() { + return tagNames; + } + + /** + * Gets the xRequestId. + * + * An alphanumeric string that is used to trace the request. The value may include ASCII alphanumerics and any of + * following segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to + * 1024 bytes. The value is considered invalid and must be ignored if that value includes any other character or is + * longer than 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by + * a random (version 4) UUID. + * + * @return the xRequestId + */ + public String xRequestId() { + return xRequestId; + } + + /** + * Gets the xCorrelationId. + * + * An alphanumeric string that is used to trace the request as a part of a larger context: the same value is used for + * downstream requests and retries of those requests. The value may include ASCII alphanumerics and any of following + * segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to 1024 bytes. + * The value is considered invalid and must be ignored if that value includes any other character or is longer than + * 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by a random + * (version 4) UUID. + * + * @return the xCorrelationId + */ + public String xCorrelationId() { + return xCorrelationId; + } + + /** + * Gets the accountId. + * + * The ID of the billing account where the tag must be created. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the tagType. + * + * The type of the tags you want to create. The only allowed value is `access`. + * + * @return the tagType + */ + public String tagType() { + return tagType; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResults.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResults.java new file mode 100644 index 0000000000..8ae3220ce0 --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResults.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Results of a create tag(s) request. + */ +public class CreateTagResults extends GenericModel { + + protected List results; + + protected CreateTagResults() { } + + /** + * Gets the results. + * + * Array of results of a create_tag request. + * + * @return the results + */ + public List getResults() { + return results; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItem.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItem.java new file mode 100644 index 0000000000..1a5e49f359 --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItem.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * CreateTagResultsResultsItem. + */ +public class CreateTagResultsResultsItem extends GenericModel { + + @SerializedName("tag_name") + protected String tagName; + @SerializedName("is_error") + protected Boolean isError; + + protected CreateTagResultsResultsItem() { } + + /** + * Gets the tagName. + * + * The name of the tag created. + * + * @return the tagName + */ + public String getTagName() { + return tagName; + } + + /** + * Gets the isError. + * + * true if the tag was not created (for example, the tag already exists). + * + * @return the isError + */ + public Boolean isIsError() { + return isError; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptions.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptions.java new file mode 100644 index 0000000000..c4f88c2082 --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptions.java @@ -0,0 +1,231 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteTagAll options. + */ +public class DeleteTagAllOptions extends GenericModel { + + /** + * Select a provider. Supported values are `ghost` and `ims`. + */ + public interface Providers { + /** ghost. */ + String GHOST = "ghost"; + /** ims. */ + String IMS = "ims"; + } + + /** + * The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported + * for IMS resources (`providers` parameter set to `ims`). + */ + public interface TagType { + /** user. */ + String USER = "user"; + /** service. */ + String SERVICE = "service"; + /** access. */ + String ACCESS = "access"; + } + + protected String xRequestId; + protected String xCorrelationId; + protected String providers; + protected String accountId; + protected String tagType; + + /** + * Builder. + */ + public static class Builder { + private String xRequestId; + private String xCorrelationId; + private String providers; + private String accountId; + private String tagType; + + /** + * Instantiates a new Builder from an existing DeleteTagAllOptions instance. + * + * @param deleteTagAllOptions the instance to initialize the Builder with + */ + private Builder(DeleteTagAllOptions deleteTagAllOptions) { + this.xRequestId = deleteTagAllOptions.xRequestId; + this.xCorrelationId = deleteTagAllOptions.xCorrelationId; + this.providers = deleteTagAllOptions.providers; + this.accountId = deleteTagAllOptions.accountId; + this.tagType = deleteTagAllOptions.tagType; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a DeleteTagAllOptions. + * + * @return the new DeleteTagAllOptions instance + */ + public DeleteTagAllOptions build() { + return new DeleteTagAllOptions(this); + } + + /** + * Set the xRequestId. + * + * @param xRequestId the xRequestId + * @return the DeleteTagAllOptions builder + */ + public Builder xRequestId(String xRequestId) { + this.xRequestId = xRequestId; + return this; + } + + /** + * Set the xCorrelationId. + * + * @param xCorrelationId the xCorrelationId + * @return the DeleteTagAllOptions builder + */ + public Builder xCorrelationId(String xCorrelationId) { + this.xCorrelationId = xCorrelationId; + return this; + } + + /** + * Set the providers. + * + * @param providers the providers + * @return the DeleteTagAllOptions builder + */ + public Builder providers(String providers) { + this.providers = providers; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the DeleteTagAllOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the tagType. + * + * @param tagType the tagType + * @return the DeleteTagAllOptions builder + */ + public Builder tagType(String tagType) { + this.tagType = tagType; + return this; + } + } + + protected DeleteTagAllOptions() { } + + protected DeleteTagAllOptions(Builder builder) { + xRequestId = builder.xRequestId; + xCorrelationId = builder.xCorrelationId; + providers = builder.providers; + accountId = builder.accountId; + tagType = builder.tagType; + } + + /** + * New builder. + * + * @return a DeleteTagAllOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the xRequestId. + * + * An alphanumeric string that is used to trace the request. The value may include ASCII alphanumerics and any of + * following segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to + * 1024 bytes. The value is considered invalid and must be ignored if that value includes any other character or is + * longer than 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by + * a random (version 4) UUID. + * + * @return the xRequestId + */ + public String xRequestId() { + return xRequestId; + } + + /** + * Gets the xCorrelationId. + * + * An alphanumeric string that is used to trace the request as a part of a larger context: the same value is used for + * downstream requests and retries of those requests. The value may include ASCII alphanumerics and any of following + * segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to 1024 bytes. + * The value is considered invalid and must be ignored if that value includes any other character or is longer than + * 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by a random + * (version 4) UUID. + * + * @return the xCorrelationId + */ + public String xCorrelationId() { + return xCorrelationId; + } + + /** + * Gets the providers. + * + * Select a provider. Supported values are `ghost` and `ims`. + * + * @return the providers + */ + public String providers() { + return providers; + } + + /** + * Gets the accountId. + * + * The ID of the billing account to delete the tags for. If it is not set, then it is taken from the authorization + * token. It is a required parameter if `tag_type` is set to `service`. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the tagType. + * + * The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported + * for IMS resources (`providers` parameter set to `ims`). + * + * @return the tagType + */ + public String tagType() { + return tagType; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptions.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptions.java new file mode 100644 index 0000000000..e3323f48ee --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptions.java @@ -0,0 +1,286 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteTag options. + */ +public class DeleteTagOptions extends GenericModel { + + public interface Providers { + /** ghost. */ + String GHOST = "ghost"; + /** ims. */ + String IMS = "ims"; + } + + /** + * The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported + * for IMS resources (`providers` parameter set to `ims`). + */ + public interface TagType { + /** user. */ + String USER = "user"; + /** service. */ + String SERVICE = "service"; + /** access. */ + String ACCESS = "access"; + } + + protected String tagName; + protected String xRequestId; + protected String xCorrelationId; + protected List providers; + protected String accountId; + protected String tagType; + + /** + * Builder. + */ + public static class Builder { + private String tagName; + private String xRequestId; + private String xCorrelationId; + private List providers; + private String accountId; + private String tagType; + + /** + * Instantiates a new Builder from an existing DeleteTagOptions instance. + * + * @param deleteTagOptions the instance to initialize the Builder with + */ + private Builder(DeleteTagOptions deleteTagOptions) { + this.tagName = deleteTagOptions.tagName; + this.xRequestId = deleteTagOptions.xRequestId; + this.xCorrelationId = deleteTagOptions.xCorrelationId; + this.providers = deleteTagOptions.providers; + this.accountId = deleteTagOptions.accountId; + this.tagType = deleteTagOptions.tagType; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param tagName the tagName + */ + public Builder(String tagName) { + this.tagName = tagName; + } + + /** + * Builds a DeleteTagOptions. + * + * @return the new DeleteTagOptions instance + */ + public DeleteTagOptions build() { + return new DeleteTagOptions(this); + } + + /** + * Adds a new element to providers. + * + * @param providers the new element to be added + * @return the DeleteTagOptions builder + */ + public Builder addProviders(String providers) { + com.ibm.cloud.sdk.core.util.Validator.notNull(providers, + "providers cannot be null"); + if (this.providers == null) { + this.providers = new ArrayList(); + } + this.providers.add(providers); + return this; + } + + /** + * Set the tagName. + * + * @param tagName the tagName + * @return the DeleteTagOptions builder + */ + public Builder tagName(String tagName) { + this.tagName = tagName; + return this; + } + + /** + * Set the xRequestId. + * + * @param xRequestId the xRequestId + * @return the DeleteTagOptions builder + */ + public Builder xRequestId(String xRequestId) { + this.xRequestId = xRequestId; + return this; + } + + /** + * Set the xCorrelationId. + * + * @param xCorrelationId the xCorrelationId + * @return the DeleteTagOptions builder + */ + public Builder xCorrelationId(String xCorrelationId) { + this.xCorrelationId = xCorrelationId; + return this; + } + + /** + * Set the providers. + * Existing providers will be replaced. + * + * @param providers the providers + * @return the DeleteTagOptions builder + */ + public Builder providers(List providers) { + this.providers = providers; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the DeleteTagOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the tagType. + * + * @param tagType the tagType + * @return the DeleteTagOptions builder + */ + public Builder tagType(String tagType) { + this.tagType = tagType; + return this; + } + } + + protected DeleteTagOptions() { } + + protected DeleteTagOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.tagName, + "tagName cannot be empty"); + tagName = builder.tagName; + xRequestId = builder.xRequestId; + xCorrelationId = builder.xCorrelationId; + providers = builder.providers; + accountId = builder.accountId; + tagType = builder.tagType; + } + + /** + * New builder. + * + * @return a DeleteTagOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the tagName. + * + * The name of tag to be deleted. + * + * @return the tagName + */ + public String tagName() { + return tagName; + } + + /** + * Gets the xRequestId. + * + * An alphanumeric string that is used to trace the request. The value may include ASCII alphanumerics and any of + * following segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to + * 1024 bytes. The value is considered invalid and must be ignored if that value includes any other character or is + * longer than 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by + * a random (version 4) UUID. + * + * @return the xRequestId + */ + public String xRequestId() { + return xRequestId; + } + + /** + * Gets the xCorrelationId. + * + * An alphanumeric string that is used to trace the request as a part of a larger context: the same value is used for + * downstream requests and retries of those requests. The value may include ASCII alphanumerics and any of following + * segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to 1024 bytes. + * The value is considered invalid and must be ignored if that value includes any other character or is longer than + * 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by a random + * (version 4) UUID. + * + * @return the xCorrelationId + */ + public String xCorrelationId() { + return xCorrelationId; + } + + /** + * Gets the providers. + * + * Select a provider. Supported values are `ghost` and `ims`. To delete tags both in Global Search and Tagging and in + * IMS, use `ghost,ims`. + * + * @return the providers + */ + public List providers() { + return providers; + } + + /** + * Gets the accountId. + * + * The ID of the billing account to delete the tag for. It is a required parameter if `tag_type` is set to `service`, + * otherwise it is inferred from the authorization IAM token. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the tagType. + * + * The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported + * for IMS resources (`providers` parameter set to `ims`). + * + * @return the tagType + */ + public String tagType() { + return tagType; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResults.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResults.java new file mode 100644 index 0000000000..593a21661c --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResults.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Results of a delete_tag request. + */ +public class DeleteTagResults extends GenericModel { + + protected List results; + + protected DeleteTagResults() { } + + /** + * Gets the results. + * + * Array of results of a delete_tag request. + * + * @return the results + */ + public List getResults() { + return results; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItem.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItem.java new file mode 100644 index 0000000000..9b1e3f2acd --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItem.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.ibm.cloud.sdk.core.service.model.DynamicModel; + +/** + * Result of a delete_tag request. + * + * This type supports additional properties of type Object. + */ +public class DeleteTagResultsItem extends DynamicModel { + + /** + * The provider of the tag. + */ + public interface Provider { + /** ghost. */ + String GHOST = "ghost"; + /** ims. */ + String IMS = "ims"; + } + + @SerializedName("provider") + protected String provider; + @SerializedName("is_error") + protected Boolean isError; + + public DeleteTagResultsItem() { + super(new TypeToken() { }); + } + + /** + * Gets the provider. + * + * The provider of the tag. + * + * @return the provider + */ + public String getProvider() { + return this.provider; + } + + /** + * Gets the isError. + * + * It is `true` if the operation exits with an error (for example, the tag does not exist). + * + * @return the isError + */ + public Boolean isIsError() { + return this.isError; + } +} diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResult.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResult.java new file mode 100644 index 0000000000..dca9e4c231 --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResult.java @@ -0,0 +1,66 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Results of deleting unattatched tags. + */ +public class DeleteTagsResult extends GenericModel { + + @SerializedName("total_count") + protected Long totalCount; + protected Boolean errors; + protected List items; + + protected DeleteTagsResult() { } + + /** + * Gets the totalCount. + * + * The number of tags that have been deleted. + * + * @return the totalCount + */ + public Long getTotalCount() { + return totalCount; + } + + /** + * Gets the errors. + * + * It is set to true if there is at least one tag operation in error. + * + * @return the errors + */ + public Boolean isErrors() { + return errors; + } + + /** + * Gets the items. + * + * The list of tag operation results. + * + * @return the items + */ + public List getItems() { + return items; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItem.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItem.java new file mode 100644 index 0000000000..20d145dec9 --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItem.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Result of a delete_tags request. + */ +public class DeleteTagsResultItem extends GenericModel { + + @SerializedName("tag_name") + protected String tagName; + @SerializedName("is_error") + protected Boolean isError; + + protected DeleteTagsResultItem() { } + + /** + * Gets the tagName. + * + * The name of the deleted tag. + * + * @return the tagName + */ + public String getTagName() { + return tagName; + } + + /** + * Gets the isError. + * + * true if the tag was not deleted. + * + * @return the isError + */ + public Boolean isIsError() { + return isError; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptions.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptions.java new file mode 100644 index 0000000000..3605b3a7fc --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptions.java @@ -0,0 +1,336 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The detachTag options. + */ +public class DetachTagOptions extends GenericModel { + + /** + * The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported + * for IMS resources. + */ + public interface TagType { + /** user. */ + String USER = "user"; + /** service. */ + String SERVICE = "service"; + /** access. */ + String ACCESS = "access"; + } + + protected String tagName; + protected List tagNames; + protected List resources; + protected QueryString query; + protected String xRequestId; + protected String xCorrelationId; + protected String accountId; + protected String tagType; + + /** + * Builder. + */ + public static class Builder { + private String tagName; + private List tagNames; + private List resources; + private QueryString query; + private String xRequestId; + private String xCorrelationId; + private String accountId; + private String tagType; + + /** + * Instantiates a new Builder from an existing DetachTagOptions instance. + * + * @param detachTagOptions the instance to initialize the Builder with + */ + private Builder(DetachTagOptions detachTagOptions) { + this.tagName = detachTagOptions.tagName; + this.tagNames = detachTagOptions.tagNames; + this.resources = detachTagOptions.resources; + this.query = detachTagOptions.query; + this.xRequestId = detachTagOptions.xRequestId; + this.xCorrelationId = detachTagOptions.xCorrelationId; + this.accountId = detachTagOptions.accountId; + this.tagType = detachTagOptions.tagType; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a DetachTagOptions. + * + * @return the new DetachTagOptions instance + */ + public DetachTagOptions build() { + return new DetachTagOptions(this); + } + + /** + * Adds a new element to tagNames. + * + * @param tagNames the new element to be added + * @return the DetachTagOptions builder + */ + public Builder addTagNames(String tagNames) { + com.ibm.cloud.sdk.core.util.Validator.notNull(tagNames, + "tagNames cannot be null"); + if (this.tagNames == null) { + this.tagNames = new ArrayList(); + } + this.tagNames.add(tagNames); + return this; + } + + /** + * Adds a new element to resources. + * + * @param resources the new element to be added + * @return the DetachTagOptions 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 tagName. + * + * @param tagName the tagName + * @return the DetachTagOptions builder + */ + public Builder tagName(String tagName) { + this.tagName = tagName; + return this; + } + + /** + * Set the tagNames. + * Existing tagNames will be replaced. + * + * @param tagNames the tagNames + * @return the DetachTagOptions builder + */ + public Builder tagNames(List tagNames) { + this.tagNames = tagNames; + return this; + } + + /** + * Set the resources. + * Existing resources will be replaced. + * + * @param resources the resources + * @return the DetachTagOptions builder + */ + public Builder resources(List resources) { + this.resources = resources; + return this; + } + + /** + * Set the query. + * + * @param query the query + * @return the DetachTagOptions builder + */ + public Builder query(QueryString query) { + this.query = query; + return this; + } + + /** + * Set the xRequestId. + * + * @param xRequestId the xRequestId + * @return the DetachTagOptions builder + */ + public Builder xRequestId(String xRequestId) { + this.xRequestId = xRequestId; + return this; + } + + /** + * Set the xCorrelationId. + * + * @param xCorrelationId the xCorrelationId + * @return the DetachTagOptions builder + */ + public Builder xCorrelationId(String xCorrelationId) { + this.xCorrelationId = xCorrelationId; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the DetachTagOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the tagType. + * + * @param tagType the tagType + * @return the DetachTagOptions builder + */ + public Builder tagType(String tagType) { + this.tagType = tagType; + return this; + } + } + + protected DetachTagOptions() { } + + protected DetachTagOptions(Builder builder) { + tagName = builder.tagName; + tagNames = builder.tagNames; + resources = builder.resources; + query = builder.query; + xRequestId = builder.xRequestId; + xCorrelationId = builder.xCorrelationId; + accountId = builder.accountId; + tagType = builder.tagType; + } + + /** + * New builder. + * + * @return a DetachTagOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the tagName. + * + * The name of the tag to detach. + * + * @return the tagName + */ + public String tagName() { + return tagName; + } + + /** + * Gets the tagNames. + * + * An array of tag names to detach. + * + * @return the tagNames + */ + public List tagNames() { + return tagNames; + } + + /** + * Gets the resources. + * + * List of resources on which the tagging operation operates on. + * + * @return the resources + */ + public List resources() { + return resources; + } + + /** + * Gets the query. + * + * A valid Global Search string. + * + * @return the query + */ + public QueryString query() { + return query; + } + + /** + * Gets the xRequestId. + * + * An alphanumeric string that is used to trace the request. The value may include ASCII alphanumerics and any of + * following segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to + * 1024 bytes. The value is considered invalid and must be ignored if that value includes any other character or is + * longer than 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by + * a random (version 4) UUID. + * + * @return the xRequestId + */ + public String xRequestId() { + return xRequestId; + } + + /** + * Gets the xCorrelationId. + * + * An alphanumeric string that is used to trace the request as a part of a larger context: the same value is used for + * downstream requests and retries of those requests. The value may include ASCII alphanumerics and any of following + * segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to 1024 bytes. + * The value is considered invalid and must be ignored if that value includes any other character or is longer than + * 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by a random + * (version 4) UUID. + * + * @return the xCorrelationId + */ + public String xCorrelationId() { + return xCorrelationId; + } + + /** + * Gets the accountId. + * + * The ID of the billing account of the untagged resource. It is a required parameter if `tag_type` is set to + * `service`, otherwise it is inferred from the authorization IAM token. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the tagType. + * + * The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported + * for IMS resources. + * + * @return the tagType + */ + public String tagType() { + return tagType; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptions.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptions.java new file mode 100644 index 0000000000..85bd5829db --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptions.java @@ -0,0 +1,446 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The listTags options. + */ +public class ListTagsOptions extends GenericModel { + + /** + * The type of the tag you want to list. Supported values are `user`, `service` and `access`. + */ + public interface TagType { + /** user. */ + String USER = "user"; + /** service. */ + String SERVICE = "service"; + /** access. */ + String ACCESS = "access"; + } + + public interface Providers { + /** ghost. */ + String GHOST = "ghost"; + /** ims. */ + String IMS = "ims"; + } + + /** + * Order the output by tag name. + */ + public interface OrderByName { + /** asc. */ + String ASC = "asc"; + /** desc. */ + String DESC = "desc"; + } + + protected String xRequestId; + protected String xCorrelationId; + protected String accountId; + protected String tagType; + protected Boolean fullData; + protected List providers; + protected String attachedTo; + protected Long offset; + protected Long limit; + protected Long timeout; + protected String orderByName; + protected Boolean attachedOnly; + + /** + * Builder. + */ + public static class Builder { + private String xRequestId; + private String xCorrelationId; + private String accountId; + private String tagType; + private Boolean fullData; + private List providers; + private String attachedTo; + private Long offset; + private Long limit; + private Long timeout; + private String orderByName; + private Boolean attachedOnly; + + /** + * Instantiates a new Builder from an existing ListTagsOptions instance. + * + * @param listTagsOptions the instance to initialize the Builder with + */ + private Builder(ListTagsOptions listTagsOptions) { + this.xRequestId = listTagsOptions.xRequestId; + this.xCorrelationId = listTagsOptions.xCorrelationId; + this.accountId = listTagsOptions.accountId; + this.tagType = listTagsOptions.tagType; + this.fullData = listTagsOptions.fullData; + this.providers = listTagsOptions.providers; + this.attachedTo = listTagsOptions.attachedTo; + this.offset = listTagsOptions.offset; + this.limit = listTagsOptions.limit; + this.timeout = listTagsOptions.timeout; + this.orderByName = listTagsOptions.orderByName; + this.attachedOnly = listTagsOptions.attachedOnly; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a ListTagsOptions. + * + * @return the new ListTagsOptions instance + */ + public ListTagsOptions build() { + return new ListTagsOptions(this); + } + + /** + * Adds a new element to providers. + * + * @param providers the new element to be added + * @return the ListTagsOptions builder + */ + public Builder addProviders(String providers) { + com.ibm.cloud.sdk.core.util.Validator.notNull(providers, + "providers cannot be null"); + if (this.providers == null) { + this.providers = new ArrayList(); + } + this.providers.add(providers); + return this; + } + + /** + * Set the xRequestId. + * + * @param xRequestId the xRequestId + * @return the ListTagsOptions builder + */ + public Builder xRequestId(String xRequestId) { + this.xRequestId = xRequestId; + return this; + } + + /** + * Set the xCorrelationId. + * + * @param xCorrelationId the xCorrelationId + * @return the ListTagsOptions builder + */ + public Builder xCorrelationId(String xCorrelationId) { + this.xCorrelationId = xCorrelationId; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the ListTagsOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the tagType. + * + * @param tagType the tagType + * @return the ListTagsOptions builder + */ + public Builder tagType(String tagType) { + this.tagType = tagType; + return this; + } + + /** + * Set the fullData. + * + * @param fullData the fullData + * @return the ListTagsOptions builder + */ + public Builder fullData(Boolean fullData) { + this.fullData = fullData; + return this; + } + + /** + * Set the providers. + * Existing providers will be replaced. + * + * @param providers the providers + * @return the ListTagsOptions builder + */ + public Builder providers(List providers) { + this.providers = providers; + return this; + } + + /** + * Set the attachedTo. + * + * @param attachedTo the attachedTo + * @return the ListTagsOptions builder + */ + public Builder attachedTo(String attachedTo) { + this.attachedTo = attachedTo; + return this; + } + + /** + * Set the offset. + * + * @param offset the offset + * @return the ListTagsOptions builder + */ + public Builder offset(long offset) { + this.offset = offset; + return this; + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the ListTagsOptions builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + + /** + * Set the timeout. + * + * @param timeout the timeout + * @return the ListTagsOptions builder + */ + public Builder timeout(long timeout) { + this.timeout = timeout; + return this; + } + + /** + * Set the orderByName. + * + * @param orderByName the orderByName + * @return the ListTagsOptions builder + */ + public Builder orderByName(String orderByName) { + this.orderByName = orderByName; + return this; + } + + /** + * Set the attachedOnly. + * + * @param attachedOnly the attachedOnly + * @return the ListTagsOptions builder + */ + public Builder attachedOnly(Boolean attachedOnly) { + this.attachedOnly = attachedOnly; + return this; + } + } + + protected ListTagsOptions() { } + + protected ListTagsOptions(Builder builder) { + xRequestId = builder.xRequestId; + xCorrelationId = builder.xCorrelationId; + accountId = builder.accountId; + tagType = builder.tagType; + fullData = builder.fullData; + providers = builder.providers; + attachedTo = builder.attachedTo; + offset = builder.offset; + limit = builder.limit; + timeout = builder.timeout; + orderByName = builder.orderByName; + attachedOnly = builder.attachedOnly; + } + + /** + * New builder. + * + * @return a ListTagsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the xRequestId. + * + * An alphanumeric string that is used to trace the request. The value may include ASCII alphanumerics and any of + * following segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to + * 1024 bytes. The value is considered invalid and must be ignored if that value includes any other character or is + * longer than 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by + * a random (version 4) UUID. + * + * @return the xRequestId + */ + public String xRequestId() { + return xRequestId; + } + + /** + * Gets the xCorrelationId. + * + * An alphanumeric string that is used to trace the request as a part of a larger context: the same value is used for + * downstream requests and retries of those requests. The value may include ASCII alphanumerics and any of following + * segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to 1024 bytes. + * The value is considered invalid and must be ignored if that value includes any other character or is longer than + * 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by a random + * (version 4) UUID. + * + * @return the xCorrelationId + */ + public String xCorrelationId() { + return xCorrelationId; + } + + /** + * Gets the accountId. + * + * The ID of the billing account to list the tags for. If it is not set, then it is taken from the authorization + * token. This parameter is required if `tag_type` is set to `service`. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the tagType. + * + * The type of the tag you want to list. Supported values are `user`, `service` and `access`. + * + * @return the tagType + */ + public String tagType() { + return tagType; + } + + /** + * Gets the fullData. + * + * If set to `true`, this query returns the provider, `ghost`, `ims` or `ghost,ims`, where the tag exists and the + * number of attached resources. + * + * @return the fullData + */ + public Boolean fullData() { + return fullData; + } + + /** + * Gets the providers. + * + * Select a provider. Supported values are `ghost` and `ims`. To list both Global Search and Tagging tags and + * infrastructure tags, use `ghost,ims`. `service` and `access` tags can only be attached to resources that are + * onboarded to Global Search and Tagging, so you should not set this parameter to list them. + * + * @return the providers + */ + public List providers() { + return providers; + } + + /** + * Gets the attachedTo. + * + * If you want to return only the list of tags that are attached to a specified resource, pass the ID of the resource + * on this parameter. For resources that are onboarded to Global Search and Tagging, the resource ID is the CRN; for + * IMS resources, it is the IMS ID. When using this parameter, you must specify the appropriate provider (`ims` or + * `ghost`). + * + * @return the attachedTo + */ + public String attachedTo() { + return attachedTo; + } + + /** + * Gets the offset. + * + * The offset is the index of the item from which you want to start returning data from. + * + * @return the offset + */ + public Long offset() { + return offset; + } + + /** + * Gets the limit. + * + * The number of tags to return. + * + * @return the limit + */ + public Long limit() { + return limit; + } + + /** + * Gets the timeout. + * + * The timeout in milliseconds, bounds the request to run within the specified time value. It returns the accumulated + * results until time runs out. + * + * @return the timeout + */ + public Long timeout() { + return timeout; + } + + /** + * Gets the orderByName. + * + * Order the output by tag name. + * + * @return the orderByName + */ + public String orderByName() { + return orderByName; + } + + /** + * Gets the attachedOnly. + * + * Filter on attached tags. If `true`, it returns only tags that are attached to one or more resources. If `false`, it + * returns all tags. + * + * @return the attachedOnly + */ + public Boolean attachedOnly() { + return attachedOnly; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryString.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryString.java new file mode 100644 index 0000000000..c778db4b9e --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryString.java @@ -0,0 +1,106 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A valid Global Search string. + */ +public class QueryString extends GenericModel { + + @SerializedName("query_string") + protected String queryString; + + /** + * Builder. + */ + public static class Builder { + private String queryString; + + /** + * Instantiates a new Builder from an existing QueryString instance. + * + * @param queryString the instance to initialize the Builder with + */ + private Builder(QueryString queryString) { + this.queryString = queryString.queryString; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param queryString the queryString + */ + public Builder(String queryString) { + this.queryString = queryString; + } + + /** + * Builds a QueryString. + * + * @return the new QueryString instance + */ + public QueryString build() { + return new QueryString(this); + } + + /** + * Set the queryString. + * + * @param queryString the queryString + * @return the QueryString builder + */ + public Builder queryString(String queryString) { + this.queryString = queryString; + return this; + } + } + + protected QueryString() { } + + protected QueryString(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.queryString, + "queryString cannot be null"); + queryString = builder.queryString; + } + + /** + * New builder. + * + * @return a QueryString builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the queryString. + * + * The Lucene-formatted query string. + * + * @return the queryString + */ + public String queryString() { + return queryString; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Resource.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Resource.java new file mode 100644 index 0000000000..54e2c3334f --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Resource.java @@ -0,0 +1,136 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A resource that might have tags that are attached. + */ +public class Resource extends GenericModel { + + @SerializedName("resource_id") + protected String resourceId; + @SerializedName("resource_type") + protected String resourceType; + + /** + * Builder. + */ + public static class Builder { + private String resourceId; + private String resourceType; + + /** + * Instantiates a new Builder from an existing Resource instance. + * + * @param resource the instance to initialize the Builder with + */ + private Builder(Resource resource) { + this.resourceId = resource.resourceId; + this.resourceType = resource.resourceType; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param resourceId the resourceId + */ + public Builder(String resourceId) { + this.resourceId = resourceId; + } + + /** + * Builds a Resource. + * + * @return the new Resource instance + */ + public Resource build() { + return new Resource(this); + } + + /** + * Set the resourceId. + * + * @param resourceId the resourceId + * @return the Resource builder + */ + public Builder resourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * Set the resourceType. + * + * @param resourceType the resourceType + * @return the Resource builder + */ + public Builder resourceType(String resourceType) { + this.resourceType = resourceType; + return this; + } + } + + protected Resource() { } + + protected Resource(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.resourceId, + "resourceId cannot be null"); + resourceId = builder.resourceId; + resourceType = builder.resourceType; + } + + /** + * New builder. + * + * @return a Resource builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the resourceId. + * + * The CRN or IMS ID of the resource. + * + * @return the resourceId + */ + public String resourceId() { + return resourceId; + } + + /** + * Gets the resourceType. + * + * The IMS resource type of the resource. It can be one of SoftLayer_Virtual_DedicatedHost, SoftLayer_Hardware, + * SoftLayer_Hardware_Server, SoftLayer_Network_Application_Delivery_Controller, SoftLayer_Network_Vlan, + * SoftLayer_Network_Vlan_Firewall, SoftLayer_Network_Component_Firewall, SoftLayer_Network_Firewall_Module_Context, + * SoftLayer_Virtual_Guest. + * + * @return the resourceType + */ + public String resourceType() { + return resourceType; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Tag.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Tag.java new file mode 100644 index 0000000000..5c49df1652 --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Tag.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A tag. + */ +public class Tag extends GenericModel { + + protected String name; + + protected Tag() { } + + /** + * Gets the name. + * + * The name of the tag. + * + * @return the name + */ + public String getName() { + return name; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagList.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagList.java new file mode 100644 index 0000000000..3dec441382 --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagList.java @@ -0,0 +1,78 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A list of tags. + */ +public class TagList extends GenericModel { + + @SerializedName("total_count") + protected Long totalCount; + protected Long offset; + protected Long limit; + protected List items; + + protected TagList() { } + + /** + * Gets the totalCount. + * + * Set the occurrences of the total tags that are associated with this account. + * + * @return the totalCount + */ + public Long getTotalCount() { + return totalCount; + } + + /** + * Gets the offset. + * + * The offset at which tags are returned. + * + * @return the offset + */ + public Long getOffset() { + return offset; + } + + /** + * Gets the limit. + * + * The number of tags requested to be returned. + * + * @return the limit + */ + public Long getLimit() { + return limit; + } + + /** + * Gets the items. + * + * Array of output results. + * + * @return the items + */ + public List getItems() { + return items; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResults.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResults.java new file mode 100644 index 0000000000..9035a20ea2 --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResults.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Results of an attach_tag or detach_tag request. + */ +public class TagResults extends GenericModel { + + protected List results; + + protected TagResults() { } + + /** + * Gets the results. + * + * Array of results of an attach_tag or detach_tag request. + * + * @return the results + */ + public List getResults() { + return results; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItem.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItem.java new file mode 100644 index 0000000000..eae0268a59 --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItem.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Result of an attach_tag or detach_tag request for a tagged resource. + */ +public class TagResultsItem extends GenericModel { + + @SerializedName("resource_id") + protected String resourceId; + @SerializedName("is_error") + protected Boolean isError; + protected String message; + + protected TagResultsItem() { } + + /** + * Gets the resourceId. + * + * The CRN or IMS ID of the resource. + * + * @return the resourceId + */ + public String getResourceId() { + return resourceId; + } + + /** + * Gets the isError. + * + * It is `true` if the operation exits with an error. + * + * @return the isError + */ + public Boolean isIsError() { + return isError; + } + + /** + * Gets the message. + * + * Error message returned when the operation fails. + * + * @return the message + */ + public String getMessage() { + return message; + } +} + diff --git a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/package-info.java b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/package-info.java new file mode 100644 index 0000000000..62b3bb4684 --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/package-info.java @@ -0,0 +1,17 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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. + */ + +/** + * Global Tagging v1. + */ +package com.ibm.cloud.platform_services.global_tagging.v1; diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingTest.java new file mode 100644 index 0000000000..b47e15f37d --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingTest.java @@ -0,0 +1,467 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1; + +import com.ibm.cloud.platform_services.global_tagging.v1.GlobalTagging; +import com.ibm.cloud.platform_services.global_tagging.v1.model.AttachTagOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.CreateTagOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.CreateTagResults; +import com.ibm.cloud.platform_services.global_tagging.v1.model.CreateTagResultsResultsItem; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagAllOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagResults; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagResultsItem; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagsResult; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagsResultItem; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DetachTagOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.ListTagsOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.QueryString; +import com.ibm.cloud.platform_services.global_tagging.v1.model.Resource; +import com.ibm.cloud.platform_services.global_tagging.v1.model.Tag; +import com.ibm.cloud.platform_services.global_tagging.v1.model.TagList; +import com.ibm.cloud.platform_services.global_tagging.v1.model.TagResults; +import com.ibm.cloud.platform_services.global_tagging.v1.model.TagResultsItem; +import com.ibm.cloud.platform_services.global_tagging.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.RequestUtils; +import java.io.IOException; +import java.io.InputStream; +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.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the GlobalTagging service. + */ +public class GlobalTaggingTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected GlobalTagging globalTaggingService; + + // Construct the service with a null authenticator (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + new GlobalTagging(serviceName, null); + } + + // Test the listTags operation with a valid options model parameter + @Test + public void testListTagsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"total_count\": 0, \"offset\": 0, \"limit\": 1, \"items\": [{\"name\": \"name\"}]}"; + String listTagsPath = "/v3/tags"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListTagsOptions model + ListTagsOptions listTagsOptionsModel = new ListTagsOptions.Builder() + .xRequestId("testString") + .xCorrelationId("testString") + .accountId("testString") + .tagType("user") + .fullData(false) + .providers(java.util.Arrays.asList("ghost")) + .attachedTo("testString") + .offset(Long.valueOf("0")) + .limit(Long.valueOf("100")) + .timeout(Long.valueOf("0")) + .orderByName("asc") + .attachedOnly(false) + .build(); + + // Invoke listTags() with a valid options model and verify the result + Response response = globalTaggingService.listTags(listTagsOptionsModel).execute(); + assertNotNull(response); + TagList responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listTagsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "testString"); + assertEquals(query.get("tag_type"), "user"); + assertEquals(Boolean.valueOf(query.get("full_data")), Boolean.valueOf(false)); + assertEquals(query.get("providers"), RequestUtils.join(java.util.Arrays.asList("ghost"), ",")); + assertEquals(query.get("attached_to"), "testString"); + assertEquals(Long.valueOf(query.get("offset")), Long.valueOf("0")); + assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("100")); + assertEquals(Long.valueOf(query.get("timeout")), Long.valueOf("0")); + assertEquals(query.get("order_by_name"), "asc"); + assertEquals(Boolean.valueOf(query.get("attached_only")), Boolean.valueOf(false)); + } + + // Test the listTags operation with and without retries enabled + @Test + public void testListTagsWRetries() throws Throwable { + globalTaggingService.enableRetries(4, 30); + testListTagsWOptions(); + + globalTaggingService.disableRetries(); + testListTagsWOptions(); + } + + // Test the createTag operation with a valid options model parameter + @Test + public void testCreateTagWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"results\": [{\"tag_name\": \"tagName\", \"is_error\": false}]}"; + String createTagPath = "/v3/tags"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the CreateTagOptions model + CreateTagOptions createTagOptionsModel = new CreateTagOptions.Builder() + .tagNames(java.util.Arrays.asList("testString")) + .xRequestId("testString") + .xCorrelationId("testString") + .accountId("testString") + .tagType("access") + .build(); + + // Invoke createTag() with a valid options model and verify the result + Response response = globalTaggingService.createTag(createTagOptionsModel).execute(); + assertNotNull(response); + CreateTagResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createTagPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "testString"); + assertEquals(query.get("tag_type"), "access"); + } + + // Test the createTag operation with and without retries enabled + @Test + public void testCreateTagWRetries() throws Throwable { + globalTaggingService.enableRetries(4, 30); + testCreateTagWOptions(); + + globalTaggingService.disableRetries(); + testCreateTagWOptions(); + } + + // Test the createTag operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateTagNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + globalTaggingService.createTag(null).execute(); + } + + // Test the deleteTagAll operation with a valid options model parameter + @Test + public void testDeleteTagAllWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"total_count\": 10, \"errors\": true, \"items\": [{\"tag_name\": \"tagName\", \"is_error\": false}]}"; + String deleteTagAllPath = "/v3/tags"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteTagAllOptions model + DeleteTagAllOptions deleteTagAllOptionsModel = new DeleteTagAllOptions.Builder() + .xRequestId("testString") + .xCorrelationId("testString") + .providers("ghost") + .accountId("testString") + .tagType("user") + .build(); + + // Invoke deleteTagAll() with a valid options model and verify the result + Response response = globalTaggingService.deleteTagAll(deleteTagAllOptionsModel).execute(); + assertNotNull(response); + DeleteTagsResult responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteTagAllPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("providers"), "ghost"); + assertEquals(query.get("account_id"), "testString"); + assertEquals(query.get("tag_type"), "user"); + } + + // Test the deleteTagAll operation with and without retries enabled + @Test + public void testDeleteTagAllWRetries() throws Throwable { + globalTaggingService.enableRetries(4, 30); + testDeleteTagAllWOptions(); + + globalTaggingService.disableRetries(); + testDeleteTagAllWOptions(); + } + + // Test the deleteTag operation with a valid options model parameter + @Test + public void testDeleteTagWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"results\": [{\"provider\": \"ghost\", \"is_error\": false}]}"; + String deleteTagPath = "/v3/tags/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteTagOptions model + DeleteTagOptions deleteTagOptionsModel = new DeleteTagOptions.Builder() + .tagName("testString") + .xRequestId("testString") + .xCorrelationId("testString") + .providers(java.util.Arrays.asList("ghost")) + .accountId("testString") + .tagType("user") + .build(); + + // Invoke deleteTag() with a valid options model and verify the result + Response response = globalTaggingService.deleteTag(deleteTagOptionsModel).execute(); + assertNotNull(response); + DeleteTagResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteTagPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("providers"), RequestUtils.join(java.util.Arrays.asList("ghost"), ",")); + assertEquals(query.get("account_id"), "testString"); + assertEquals(query.get("tag_type"), "user"); + } + + // Test the deleteTag operation with and without retries enabled + @Test + public void testDeleteTagWRetries() throws Throwable { + globalTaggingService.enableRetries(4, 30); + testDeleteTagWOptions(); + + globalTaggingService.disableRetries(); + testDeleteTagWOptions(); + } + + // Test the deleteTag operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTagNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + globalTaggingService.deleteTag(null).execute(); + } + + // Test the attachTag operation with a valid options model parameter + @Test + public void testAttachTagWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"results\": [{\"resource_id\": \"resourceId\", \"is_error\": false, \"message\": \"message\"}]}"; + String attachTagPath = "/v3/tags/attach"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the Resource model + Resource resourceModel = new Resource.Builder() + .resourceId("testString") + .resourceType("testString") + .build(); + + // Construct an instance of the QueryString model + QueryString queryStringModel = new QueryString.Builder() + .queryString("testString") + .build(); + + // Construct an instance of the AttachTagOptions model + AttachTagOptions attachTagOptionsModel = new AttachTagOptions.Builder() + .tagName("testString") + .tagNames(java.util.Arrays.asList("testString")) + .resources(java.util.Arrays.asList(resourceModel)) + .query(queryStringModel) + .xRequestId("testString") + .xCorrelationId("testString") + .accountId("testString") + .tagType("user") + .replace(false) + .update(false) + .build(); + + // Invoke attachTag() with a valid options model and verify the result + Response response = globalTaggingService.attachTag(attachTagOptionsModel).execute(); + assertNotNull(response); + TagResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, attachTagPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "testString"); + assertEquals(query.get("tag_type"), "user"); + assertEquals(Boolean.valueOf(query.get("replace")), Boolean.valueOf(false)); + assertEquals(Boolean.valueOf(query.get("update")), Boolean.valueOf(false)); + } + + // Test the attachTag operation with and without retries enabled + @Test + public void testAttachTagWRetries() throws Throwable { + globalTaggingService.enableRetries(4, 30); + testAttachTagWOptions(); + + globalTaggingService.disableRetries(); + testAttachTagWOptions(); + } + + // Test the detachTag operation with a valid options model parameter + @Test + public void testDetachTagWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"results\": [{\"resource_id\": \"resourceId\", \"is_error\": false, \"message\": \"message\"}]}"; + String detachTagPath = "/v3/tags/detach"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the Resource model + Resource resourceModel = new Resource.Builder() + .resourceId("testString") + .resourceType("testString") + .build(); + + // Construct an instance of the QueryString model + QueryString queryStringModel = new QueryString.Builder() + .queryString("testString") + .build(); + + // Construct an instance of the DetachTagOptions model + DetachTagOptions detachTagOptionsModel = new DetachTagOptions.Builder() + .tagName("testString") + .tagNames(java.util.Arrays.asList("testString")) + .resources(java.util.Arrays.asList(resourceModel)) + .query(queryStringModel) + .xRequestId("testString") + .xCorrelationId("testString") + .accountId("testString") + .tagType("user") + .build(); + + // Invoke detachTag() with a valid options model and verify the result + Response response = globalTaggingService.detachTag(detachTagOptionsModel).execute(); + assertNotNull(response); + TagResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, detachTagPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "testString"); + assertEquals(query.get("tag_type"), "user"); + } + + // Test the detachTag operation with and without retries enabled + @Test + public void testDetachTagWRetries() throws Throwable { + globalTaggingService.enableRetries(4, 30); + testDetachTagWOptions(); + + globalTaggingService.disableRetries(); + testDetachTagWOptions(); + } + + // Perform setup needed before each test method + @BeforeMethod + public void beforeEachTest() { + // Start the mock server. + try { + server = new MockWebServer(); + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + + // Construct an instance of the service + constructClientService(); + } + + // Perform tear down after each test method + @AfterMethod + public void afterEachTest() throws IOException { + server.shutdown(); + globalTaggingService = null; + } + + // Constructs an instance of the service to be used by the tests + public void constructClientService() { + System.setProperty("TESTSERVICE_AUTH_TYPE", "noAuth"); + final String serviceName = "testService"; + + globalTaggingService = GlobalTagging.newInstance(serviceName); + String url = server.url("/").toString(); + globalTaggingService.setServiceUrl(url); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptionsTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptionsTest.java new file mode 100644 index 0000000000..128b3e401d --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptionsTest.java @@ -0,0 +1,71 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.AttachTagOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.QueryString; +import com.ibm.cloud.platform_services.global_tagging.v1.model.Resource; +import com.ibm.cloud.platform_services.global_tagging.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 AttachTagOptions model. + */ +public class AttachTagOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAttachTagOptions() throws Throwable { + Resource resourceModel = new Resource.Builder() + .resourceId("testString") + .resourceType("testString") + .build(); + assertEquals(resourceModel.resourceId(), "testString"); + assertEquals(resourceModel.resourceType(), "testString"); + + QueryString queryStringModel = new QueryString.Builder() + .queryString("testString") + .build(); + assertEquals(queryStringModel.queryString(), "testString"); + + AttachTagOptions attachTagOptionsModel = new AttachTagOptions.Builder() + .tagName("testString") + .tagNames(java.util.Arrays.asList("testString")) + .resources(java.util.Arrays.asList(resourceModel)) + .query(queryStringModel) + .xRequestId("testString") + .xCorrelationId("testString") + .accountId("testString") + .tagType("user") + .replace(false) + .update(false) + .build(); + assertEquals(attachTagOptionsModel.tagName(), "testString"); + assertEquals(attachTagOptionsModel.tagNames(), java.util.Arrays.asList("testString")); + assertEquals(attachTagOptionsModel.resources(), java.util.Arrays.asList(resourceModel)); + assertEquals(attachTagOptionsModel.query(), queryStringModel); + assertEquals(attachTagOptionsModel.xRequestId(), "testString"); + assertEquals(attachTagOptionsModel.xCorrelationId(), "testString"); + assertEquals(attachTagOptionsModel.accountId(), "testString"); + assertEquals(attachTagOptionsModel.tagType(), "user"); + assertEquals(attachTagOptionsModel.replace(), Boolean.valueOf(false)); + assertEquals(attachTagOptionsModel.update(), Boolean.valueOf(false)); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptionsTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptionsTest.java new file mode 100644 index 0000000000..3f6ea6e298 --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptionsTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.CreateTagOptions; +import com.ibm.cloud.platform_services.global_tagging.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 CreateTagOptions model. + */ +public class CreateTagOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateTagOptions() throws Throwable { + CreateTagOptions createTagOptionsModel = new CreateTagOptions.Builder() + .tagNames(java.util.Arrays.asList("testString")) + .xRequestId("testString") + .xCorrelationId("testString") + .accountId("testString") + .tagType("access") + .build(); + assertEquals(createTagOptionsModel.tagNames(), java.util.Arrays.asList("testString")); + assertEquals(createTagOptionsModel.xRequestId(), "testString"); + assertEquals(createTagOptionsModel.xCorrelationId(), "testString"); + assertEquals(createTagOptionsModel.accountId(), "testString"); + assertEquals(createTagOptionsModel.tagType(), "access"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateTagOptionsError() throws Throwable { + new CreateTagOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItemTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItemTest.java new file mode 100644 index 0000000000..ca0906b3ec --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItemTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.CreateTagResultsResultsItem; +import com.ibm.cloud.platform_services.global_tagging.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 CreateTagResultsResultsItem model. + */ +public class CreateTagResultsResultsItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateTagResultsResultsItem() throws Throwable { + CreateTagResultsResultsItem createTagResultsResultsItemModel = new CreateTagResultsResultsItem(); + assertNull(createTagResultsResultsItemModel.getTagName()); + assertNull(createTagResultsResultsItemModel.isIsError()); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsTest.java new file mode 100644 index 0000000000..a4f05dd2d0 --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.CreateTagResults; +import com.ibm.cloud.platform_services.global_tagging.v1.model.CreateTagResultsResultsItem; +import com.ibm.cloud.platform_services.global_tagging.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 CreateTagResults model. + */ +public class CreateTagResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateTagResults() throws Throwable { + CreateTagResults createTagResultsModel = new CreateTagResults(); + assertNull(createTagResultsModel.getResults()); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptionsTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptionsTest.java new file mode 100644 index 0000000000..8dda09b285 --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagAllOptions; +import com.ibm.cloud.platform_services.global_tagging.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 DeleteTagAllOptions model. + */ +public class DeleteTagAllOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteTagAllOptions() throws Throwable { + DeleteTagAllOptions deleteTagAllOptionsModel = new DeleteTagAllOptions.Builder() + .xRequestId("testString") + .xCorrelationId("testString") + .providers("ghost") + .accountId("testString") + .tagType("user") + .build(); + assertEquals(deleteTagAllOptionsModel.xRequestId(), "testString"); + assertEquals(deleteTagAllOptionsModel.xCorrelationId(), "testString"); + assertEquals(deleteTagAllOptionsModel.providers(), "ghost"); + assertEquals(deleteTagAllOptionsModel.accountId(), "testString"); + assertEquals(deleteTagAllOptionsModel.tagType(), "user"); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptionsTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptionsTest.java new file mode 100644 index 0000000000..2df3292ba2 --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptionsTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagOptions; +import com.ibm.cloud.platform_services.global_tagging.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 DeleteTagOptions model. + */ +public class DeleteTagOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteTagOptions() throws Throwable { + DeleteTagOptions deleteTagOptionsModel = new DeleteTagOptions.Builder() + .tagName("testString") + .xRequestId("testString") + .xCorrelationId("testString") + .providers(java.util.Arrays.asList("ghost")) + .accountId("testString") + .tagType("user") + .build(); + assertEquals(deleteTagOptionsModel.tagName(), "testString"); + assertEquals(deleteTagOptionsModel.xRequestId(), "testString"); + assertEquals(deleteTagOptionsModel.xCorrelationId(), "testString"); + assertEquals(deleteTagOptionsModel.providers(), java.util.Arrays.asList("ghost")); + assertEquals(deleteTagOptionsModel.accountId(), "testString"); + assertEquals(deleteTagOptionsModel.tagType(), "user"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTagOptionsError() throws Throwable { + new DeleteTagOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItemTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItemTest.java new file mode 100644 index 0000000000..536ea494af --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItemTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagResultsItem; +import com.ibm.cloud.platform_services.global_tagging.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 DeleteTagResultsItem model. + */ +public class DeleteTagResultsItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteTagResultsItem() throws Throwable { + DeleteTagResultsItem deleteTagResultsItemModel = new DeleteTagResultsItem(); + assertNull(deleteTagResultsItemModel.getProvider()); + assertNull(deleteTagResultsItemModel.isIsError()); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsTest.java new file mode 100644 index 0000000000..2b238f344e --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagResults; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagResultsItem; +import com.ibm.cloud.platform_services.global_tagging.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 DeleteTagResults model. + */ +public class DeleteTagResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteTagResults() throws Throwable { + DeleteTagResults deleteTagResultsModel = new DeleteTagResults(); + assertNull(deleteTagResultsModel.getResults()); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItemTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItemTest.java new file mode 100644 index 0000000000..e00050218f --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItemTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagsResultItem; +import com.ibm.cloud.platform_services.global_tagging.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 DeleteTagsResultItem model. + */ +public class DeleteTagsResultItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteTagsResultItem() throws Throwable { + DeleteTagsResultItem deleteTagsResultItemModel = new DeleteTagsResultItem(); + assertNull(deleteTagsResultItemModel.getTagName()); + assertNull(deleteTagsResultItemModel.isIsError()); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultTest.java new file mode 100644 index 0000000000..2850dcc75a --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagsResult; +import com.ibm.cloud.platform_services.global_tagging.v1.model.DeleteTagsResultItem; +import com.ibm.cloud.platform_services.global_tagging.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 DeleteTagsResult model. + */ +public class DeleteTagsResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteTagsResult() throws Throwable { + DeleteTagsResult deleteTagsResultModel = new DeleteTagsResult(); + assertNull(deleteTagsResultModel.getTotalCount()); + assertNull(deleteTagsResultModel.isErrors()); + assertNull(deleteTagsResultModel.getItems()); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptionsTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptionsTest.java new file mode 100644 index 0000000000..11c1f84eb4 --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptionsTest.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.DetachTagOptions; +import com.ibm.cloud.platform_services.global_tagging.v1.model.QueryString; +import com.ibm.cloud.platform_services.global_tagging.v1.model.Resource; +import com.ibm.cloud.platform_services.global_tagging.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 DetachTagOptions model. + */ +public class DetachTagOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDetachTagOptions() throws Throwable { + Resource resourceModel = new Resource.Builder() + .resourceId("testString") + .resourceType("testString") + .build(); + assertEquals(resourceModel.resourceId(), "testString"); + assertEquals(resourceModel.resourceType(), "testString"); + + QueryString queryStringModel = new QueryString.Builder() + .queryString("testString") + .build(); + assertEquals(queryStringModel.queryString(), "testString"); + + DetachTagOptions detachTagOptionsModel = new DetachTagOptions.Builder() + .tagName("testString") + .tagNames(java.util.Arrays.asList("testString")) + .resources(java.util.Arrays.asList(resourceModel)) + .query(queryStringModel) + .xRequestId("testString") + .xCorrelationId("testString") + .accountId("testString") + .tagType("user") + .build(); + assertEquals(detachTagOptionsModel.tagName(), "testString"); + assertEquals(detachTagOptionsModel.tagNames(), java.util.Arrays.asList("testString")); + assertEquals(detachTagOptionsModel.resources(), java.util.Arrays.asList(resourceModel)); + assertEquals(detachTagOptionsModel.query(), queryStringModel); + assertEquals(detachTagOptionsModel.xRequestId(), "testString"); + assertEquals(detachTagOptionsModel.xCorrelationId(), "testString"); + assertEquals(detachTagOptionsModel.accountId(), "testString"); + assertEquals(detachTagOptionsModel.tagType(), "user"); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptionsTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptionsTest.java new file mode 100644 index 0000000000..aec5a038e7 --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptionsTest.java @@ -0,0 +1,61 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.ListTagsOptions; +import com.ibm.cloud.platform_services.global_tagging.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 ListTagsOptions model. + */ +public class ListTagsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListTagsOptions() throws Throwable { + ListTagsOptions listTagsOptionsModel = new ListTagsOptions.Builder() + .xRequestId("testString") + .xCorrelationId("testString") + .accountId("testString") + .tagType("user") + .fullData(false) + .providers(java.util.Arrays.asList("ghost")) + .attachedTo("testString") + .offset(Long.valueOf("0")) + .limit(Long.valueOf("100")) + .timeout(Long.valueOf("0")) + .orderByName("asc") + .attachedOnly(false) + .build(); + assertEquals(listTagsOptionsModel.xRequestId(), "testString"); + assertEquals(listTagsOptionsModel.xCorrelationId(), "testString"); + assertEquals(listTagsOptionsModel.accountId(), "testString"); + assertEquals(listTagsOptionsModel.tagType(), "user"); + assertEquals(listTagsOptionsModel.fullData(), Boolean.valueOf(false)); + assertEquals(listTagsOptionsModel.providers(), java.util.Arrays.asList("ghost")); + assertEquals(listTagsOptionsModel.attachedTo(), "testString"); + assertEquals(listTagsOptionsModel.offset(), Long.valueOf("0")); + assertEquals(listTagsOptionsModel.limit(), Long.valueOf("100")); + assertEquals(listTagsOptionsModel.timeout(), Long.valueOf("0")); + assertEquals(listTagsOptionsModel.orderByName(), "asc"); + assertEquals(listTagsOptionsModel.attachedOnly(), Boolean.valueOf(false)); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryStringTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryStringTest.java new file mode 100644 index 0000000000..5258bc860c --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryStringTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.QueryString; +import com.ibm.cloud.platform_services.global_tagging.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 QueryString model. + */ +public class QueryStringTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryString() throws Throwable { + QueryString queryStringModel = new QueryString.Builder() + .queryString("testString") + .build(); + assertEquals(queryStringModel.queryString(), "testString"); + + String json = TestUtilities.serialize(queryStringModel); + + QueryString queryStringModelNew = TestUtilities.deserialize(json, QueryString.class); + assertTrue(queryStringModelNew instanceof QueryString); + assertEquals(queryStringModelNew.queryString(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryStringError() throws Throwable { + new QueryString.Builder().build(); + } + +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ResourceTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ResourceTest.java new file mode 100644 index 0000000000..8f68b5fa74 --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ResourceTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.Resource; +import com.ibm.cloud.platform_services.global_tagging.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 Resource model. + */ +public class ResourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testResource() throws Throwable { + Resource resourceModel = new Resource.Builder() + .resourceId("testString") + .resourceType("testString") + .build(); + assertEquals(resourceModel.resourceId(), "testString"); + assertEquals(resourceModel.resourceType(), "testString"); + + String json = TestUtilities.serialize(resourceModel); + + Resource resourceModelNew = TestUtilities.deserialize(json, Resource.class); + assertTrue(resourceModelNew instanceof Resource); + assertEquals(resourceModelNew.resourceId(), "testString"); + assertEquals(resourceModelNew.resourceType(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testResourceError() throws Throwable { + new Resource.Builder().build(); + } + +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagListTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagListTest.java new file mode 100644 index 0000000000..a99fadd873 --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagListTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.Tag; +import com.ibm.cloud.platform_services.global_tagging.v1.model.TagList; +import com.ibm.cloud.platform_services.global_tagging.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 TagList model. + */ +public class TagListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTagList() throws Throwable { + TagList tagListModel = new TagList(); + assertNull(tagListModel.getTotalCount()); + assertNull(tagListModel.getOffset()); + assertNull(tagListModel.getLimit()); + assertNull(tagListModel.getItems()); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItemTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItemTest.java new file mode 100644 index 0000000000..b45cdad14b --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItemTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.TagResultsItem; +import com.ibm.cloud.platform_services.global_tagging.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 TagResultsItem model. + */ +public class TagResultsItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTagResultsItem() throws Throwable { + TagResultsItem tagResultsItemModel = new TagResultsItem(); + assertNull(tagResultsItemModel.getResourceId()); + assertNull(tagResultsItemModel.isIsError()); + assertNull(tagResultsItemModel.getMessage()); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsTest.java new file mode 100644 index 0000000000..7383cf7a6d --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.TagResults; +import com.ibm.cloud.platform_services.global_tagging.v1.model.TagResultsItem; +import com.ibm.cloud.platform_services.global_tagging.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 TagResults model. + */ +public class TagResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTagResults() throws Throwable { + TagResults tagResultsModel = new TagResults(); + assertNull(tagResultsModel.getResults()); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagTest.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagTest.java new file mode 100644 index 0000000000..6553c625dc --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.model; + +import com.ibm.cloud.platform_services.global_tagging.v1.model.Tag; +import com.ibm.cloud.platform_services.global_tagging.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 Tag model. + */ +public class TagTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTag() throws Throwable { + Tag tagModel = new Tag(); + assertNull(tagModel.getName()); + } +} \ No newline at end of file diff --git a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/utils/TestUtilities.java b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/utils/TestUtilities.java new file mode 100644 index 0000000000..ec64032ab3 --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/utils/TestUtilities.java @@ -0,0 +1,131 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * 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.global_tagging.v1.utils; + +import java.util.Base64; +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 okhttp3.mockwebserver.RecordedRequest; +import okhttp3.HttpUrl; +import com.ibm.cloud.sdk.core.util.DateUtils; +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 encodedString) throws Exception { + return Base64.getDecoder().decode(encodedString); + } + + public static Date createMockDate(String date) throws Exception { + return DateUtils.parseAsDate(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return DateUtils.parseAsDateTime(date); + } +} \ No newline at end of file diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItem.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItem.java index a7d54aae08..347393dc31 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItem.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItem.java @@ -25,6 +25,8 @@ public class TagResultsItem extends GenericModel { protected String resourceId; @SerializedName("is_error") protected Boolean isError; + @SerializedName("message") + protected String message; protected TagResultsItem() { } @@ -49,5 +51,16 @@ public String getResourceId() { public Boolean isIsError() { return isError; } + + /** + * Gets the message. + * + * Error message returned when the operation fails. + * + * @return the message + */ + public String getMessage() { + return message; + } }