From eb24b687753ce6ee312bd140c411d238a00aa5d6 Mon Sep 17 00:00:00 2001 From: francescadecicco Date: Tue, 1 Jul 2025 11:18:12 +0200 Subject: [PATCH 1/5] fix(Global Search/Tagging): regenerated services with latest API definition Signed-off-by: francescadecicco --- .../global_tagging/v1/GlobalTagging.java | 47 ++++++-- .../v1/model/AttachTagOptions.java | 112 ++++++++++-------- .../v1/model/CreateTagOptions.java | 3 +- .../v1/model/CreateTagResults.java | 3 +- .../v1/model/CreateTagResultsResultsItem.java | 3 +- .../v1/model/DeleteTagAllOptions.java | 3 +- .../v1/model/DeleteTagOptions.java | 3 +- .../v1/model/DeleteTagResults.java | 3 +- .../v1/model/DeleteTagResultsItem.java | 5 +- .../v1/model/DeleteTagsResult.java | 3 +- .../v1/model/DeleteTagsResultItem.java | 3 +- .../v1/model/DetachTagOptions.java | 112 ++++++++++-------- .../v1/model/ListTagsOptions.java | 3 +- .../global_tagging/v1/model/Resource.java | 8 +- .../global_tagging/v1/model/Tag.java | 3 +- .../global_tagging/v1/model/TagList.java | 3 +- .../global_tagging/v1/model/TagResults.java | 3 +- .../v1/model/TagResultsItem.java | 3 +- .../global_tagging/v1/package-info.java | 3 +- .../global_tagging/v1/GlobalTaggingTest.java | 34 +++--- .../v1/model/AttachTagOptionsTest.java | 20 ++-- .../v1/model/CreateTagOptionsTest.java | 2 +- .../CreateTagResultsResultsItemTest.java | 2 +- .../v1/model/CreateTagResultsTest.java | 2 +- .../v1/model/DeleteTagAllOptionsTest.java | 2 +- .../v1/model/DeleteTagOptionsTest.java | 2 +- .../v1/model/DeleteTagResultsItemTest.java | 2 +- .../v1/model/DeleteTagResultsTest.java | 2 +- .../v1/model/DeleteTagsResultItemTest.java | 2 +- .../v1/model/DeleteTagsResultTest.java | 2 +- .../v1/model/DetachTagOptionsTest.java | 20 ++-- .../v1/model/ListTagsOptionsTest.java | 2 +- .../global_tagging/v1/model/ResourceTest.java | 2 +- .../global_tagging/v1/model/TagListTest.java | 2 +- .../v1/model/TagResultsItemTest.java | 2 +- .../v1/model/TagResultsTest.java | 2 +- .../global_tagging/v1/model/TagTest.java | 2 +- .../v1/utils/TestUtilities.java | 8 +- 38 files changed, 265 insertions(+), 173 deletions(-) diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTagging.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTagging.java index 53691cfda9..f294e3e602 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTagging.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTagging.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -12,7 +12,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.87.0-91c7c775-20240320-213027 + * IBM OpenAPI SDK Code Generator Version: 3.105.0-3c13b041-20250605-193116 */ package com.ibm.cloud.platform_services.global_tagging.v1; @@ -48,9 +48,9 @@ * 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 and Cloud Foundry 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. + * 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 */ @@ -338,19 +338,36 @@ public ServiceCall attachTag(AttachTagOptions attachTagOptions) { builder.query("update", String.valueOf(attachTagOptions.update())); } final JsonObject contentJson = new JsonObject(); - contentJson.add("resources", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(attachTagOptions.resources())); 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. * @@ -381,17 +398,33 @@ public ServiceCall detachTag(DetachTagOptions detachTagOptions) { builder.query("tag_type", String.valueOf(detachTagOptions.tagType())); } final JsonObject contentJson = new JsonObject(); - contentJson.add("resources", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(detachTagOptions.resources())); 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/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptions.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptions.java index 63c642d804..cd80f130a6 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptions.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; @@ -35,9 +36,10 @@ public interface TagType { String ACCESS = "access"; } - protected List resources; protected String tagName; protected List tagNames; + protected List resources; + protected QueryString query; protected String xRequestId; protected String xCorrelationId; protected String accountId; @@ -49,9 +51,10 @@ public interface TagType { * Builder. */ public static class Builder { - private List resources; private String tagName; private List tagNames; + private List resources; + private QueryString query; private String xRequestId; private String xCorrelationId; private String accountId; @@ -65,9 +68,10 @@ public static class Builder { * @param attachTagOptions the instance to initialize the Builder with */ private Builder(AttachTagOptions attachTagOptions) { - this.resources = attachTagOptions.resources; 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; @@ -82,15 +86,6 @@ private Builder(AttachTagOptions attachTagOptions) { public Builder() { } - /** - * Instantiates a new builder with required properties. - * - * @param resources the resources - */ - public Builder(List resources) { - this.resources = resources; - } - /** * Builds a AttachTagOptions. * @@ -100,22 +95,6 @@ public AttachTagOptions build() { return new AttachTagOptions(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; - } - /** * Adds a new element to tagNames. * @@ -133,14 +112,18 @@ public Builder addTagNames(String tagNames) { } /** - * Set the resources. - * Existing resources will be replaced. + * Adds a new element to resources. * - * @param resources the resources + * @param resources the new element to be added * @return the AttachTagOptions builder */ - public Builder resources(List resources) { - this.resources = resources; + 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; } @@ -167,6 +150,29 @@ public Builder tagNames(List 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. * @@ -237,11 +243,10 @@ public Builder update(Boolean update) { protected AttachTagOptions() { } protected AttachTagOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.resources, - "resources cannot be null"); - resources = builder.resources; tagName = builder.tagName; tagNames = builder.tagNames; + resources = builder.resources; + query = builder.query; xRequestId = builder.xRequestId; xCorrelationId = builder.xCorrelationId; accountId = builder.accountId; @@ -259,17 +264,6 @@ public Builder newBuilder() { return new Builder(this); } - /** - * Gets the resources. - * - * List of resources on which the tag or tags are attached. - * - * @return the resources - */ - public List resources() { - return resources; - } - /** * Gets the tagName. * @@ -292,6 +286,28 @@ 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. * diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptions.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptions.java index 6f8bb514fb..0afc9ac8de 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptions.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResults.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResults.java index 916b626bef..442c840aee 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResults.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItem.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItem.java index bab9f19663..c709fccb0d 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItem.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItem.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptions.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptions.java index 4d8b183636..c68a96ab83 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptions.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptions.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptions.java index 9d61a8438c..2b534cab07 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptions.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResults.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResults.java index eef71cbc26..9906a810ca 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResults.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItem.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItem.java index 2862b69ded..1821f2566d 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItem.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItem.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; @@ -18,6 +19,8 @@ /** * Result of a delete_tag request. + * + * This type supports additional properties of type Object. */ public class DeleteTagResultsItem extends DynamicModel { diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResult.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResult.java index b120a4a446..47fdc717d5 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResult.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItem.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItem.java index 906c8e4cdd..8d4eaa504d 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItem.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItem.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptions.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptions.java index 2bc7f99a9e..a0b7b80c15 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptions.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; @@ -35,9 +36,10 @@ public interface TagType { String ACCESS = "access"; } - protected List resources; protected String tagName; protected List tagNames; + protected List resources; + protected QueryString query; protected String xRequestId; protected String xCorrelationId; protected String accountId; @@ -47,9 +49,10 @@ public interface TagType { * Builder. */ public static class Builder { - private List resources; private String tagName; private List tagNames; + private List resources; + private QueryString query; private String xRequestId; private String xCorrelationId; private String accountId; @@ -61,9 +64,10 @@ public static class Builder { * @param detachTagOptions the instance to initialize the Builder with */ private Builder(DetachTagOptions detachTagOptions) { - this.resources = detachTagOptions.resources; 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; @@ -76,15 +80,6 @@ private Builder(DetachTagOptions detachTagOptions) { public Builder() { } - /** - * Instantiates a new builder with required properties. - * - * @param resources the resources - */ - public Builder(List resources) { - this.resources = resources; - } - /** * Builds a DetachTagOptions. * @@ -94,22 +89,6 @@ public DetachTagOptions build() { return new DetachTagOptions(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; - } - /** * Adds a new element to tagNames. * @@ -127,14 +106,18 @@ public Builder addTagNames(String tagNames) { } /** - * Set the resources. - * Existing resources will be replaced. + * Adds a new element to resources. * - * @param resources the resources + * @param resources the new element to be added * @return the DetachTagOptions builder */ - public Builder resources(List resources) { - this.resources = resources; + 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; } @@ -161,6 +144,29 @@ public Builder tagNames(List 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. * @@ -209,11 +215,10 @@ public Builder tagType(String tagType) { protected DetachTagOptions() { } protected DetachTagOptions(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.resources, - "resources cannot be null"); - resources = builder.resources; tagName = builder.tagName; tagNames = builder.tagNames; + resources = builder.resources; + query = builder.query; xRequestId = builder.xRequestId; xCorrelationId = builder.xCorrelationId; accountId = builder.accountId; @@ -229,17 +234,6 @@ public Builder newBuilder() { return new Builder(this); } - /** - * Gets the resources. - * - * List of resources on which the tag or tags are detached. - * - * @return the resources - */ - public List resources() { - return resources; - } - /** * Gets the tagName. * @@ -262,6 +256,28 @@ 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. * diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptions.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptions.java index 5199e15ec1..d2fd91d9ab 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptions.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Resource.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Resource.java index e565e0dff8..cd57c8157e 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Resource.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Resource.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; @@ -121,7 +122,10 @@ public String resourceId() { /** * Gets the resourceType. * - * The IMS resource type of the resource. + * 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 */ diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Tag.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Tag.java index cbfbce32ec..331ac64f5e 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Tag.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Tag.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagList.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagList.java index 75d3ff598a..85df33ebea 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagList.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagList.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResults.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResults.java index 30d4406385..0e5ab7c536 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResults.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; 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 ee520fc138..a7d54aae08 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 @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/package-info.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/package-info.java index 1d00403a52..057350d5b9 100644 --- a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/package-info.java +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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. */ diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingTest.java index 31bd59dc83..8ecaf1be21 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,6 +10,7 @@ * 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; @@ -25,6 +26,7 @@ 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; @@ -316,11 +318,17 @@ public void testAttachTagWOptions() throws Throwable { .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() - .resources(java.util.Arrays.asList(resourceModel)) .tagName("testString") .tagNames(java.util.Arrays.asList("testString")) + .resources(java.util.Arrays.asList(resourceModel)) + .query(queryStringModel) .xRequestId("testString") .xCorrelationId("testString") .accountId("testString") @@ -361,13 +369,6 @@ public void testAttachTagWRetries() throws Throwable { testAttachTagWOptions(); } - // Test the attachTag operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testAttachTagNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - globalTaggingService.attachTag(null).execute(); - } - // Test the detachTag operation with a valid options model parameter @Test public void testDetachTagWOptions() throws Throwable { @@ -385,11 +386,17 @@ public void testDetachTagWOptions() throws Throwable { .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() - .resources(java.util.Arrays.asList(resourceModel)) .tagName("testString") .tagNames(java.util.Arrays.asList("testString")) + .resources(java.util.Arrays.asList(resourceModel)) + .query(queryStringModel) .xRequestId("testString") .xCorrelationId("testString") .accountId("testString") @@ -426,13 +433,6 @@ public void testDetachTagWRetries() throws Throwable { testDetachTagWOptions(); } - // Test the detachTag operation with a null options model (negative test) - @Test(expectedExceptions = IllegalArgumentException.class) - public void testDetachTagNoOptions() throws Throwable { - server.enqueue(new MockResponse()); - globalTaggingService.detachTag(null).execute(); - } - // Perform setup needed before each test method @BeforeMethod public void beforeEachTest() { diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptionsTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptionsTest.java index ceae456003..08e25e8817 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptionsTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -14,6 +14,7 @@ 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; @@ -39,10 +40,16 @@ public void testAttachTagOptions() throws Throwable { 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() - .resources(java.util.Arrays.asList(resourceModel)) .tagName("testString") .tagNames(java.util.Arrays.asList("testString")) + .resources(java.util.Arrays.asList(resourceModel)) + .query(queryStringModel) .xRequestId("testString") .xCorrelationId("testString") .accountId("testString") @@ -50,9 +57,10 @@ public void testAttachTagOptions() throws Throwable { .replace(false) .update(false) .build(); - assertEquals(attachTagOptionsModel.resources(), java.util.Arrays.asList(resourceModel)); 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"); @@ -60,10 +68,4 @@ public void testAttachTagOptions() throws Throwable { assertEquals(attachTagOptionsModel.replace(), Boolean.valueOf(false)); assertEquals(attachTagOptionsModel.update(), Boolean.valueOf(false)); } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testAttachTagOptionsError() throws Throwable { - new AttachTagOptions.Builder().build(); - } - } \ No newline at end of file diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptionsTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptionsTest.java index b4177c3457..a2b95852ba 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptionsTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItemTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItemTest.java index a81ef305eb..2cad363f32 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItemTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItemTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsTest.java index 835d2163e5..945f41f58a 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptionsTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptionsTest.java index 515d60c0d2..baffd9cd70 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptionsTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptionsTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptionsTest.java index 9bcc98fdbb..2797cf2e2f 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptionsTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItemTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItemTest.java index b3b487d108..6b94dcb880 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItemTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItemTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsTest.java index d83a78fc6d..210263b799 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItemTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItemTest.java index ab221b7369..fcc28ef8c7 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItemTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItemTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultTest.java index dea40e5f4d..37b01dca08 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptionsTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptionsTest.java index 24396bed47..81c7117718 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptionsTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -14,6 +14,7 @@ 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; @@ -39,27 +40,28 @@ public void testDetachTagOptions() throws Throwable { 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() - .resources(java.util.Arrays.asList(resourceModel)) .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.resources(), java.util.Arrays.asList(resourceModel)); 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"); } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testDetachTagOptionsError() throws Throwable { - new DetachTagOptions.Builder().build(); - } - } \ No newline at end of file diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptionsTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptionsTest.java index fb0ece4e42..c37577cacd 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptionsTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ResourceTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ResourceTest.java index 9929fd0f6f..525b74c60e 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ResourceTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ResourceTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagListTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagListTest.java index dd65dec29b..b538963260 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagListTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagListTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItemTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItemTest.java index 5c8034dd6a..f2b97b5883 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItemTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItemTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsTest.java index 8eb47ebc42..90d45e4436 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagTest.java index 50a95caf70..1ac2651b1a 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagTest.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 diff --git a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/utils/TestUtilities.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/utils/TestUtilities.java index ff7a211d9f..69e5c9cb9b 100644 --- a/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/utils/TestUtilities.java +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/utils/TestUtilities.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2024. + * (C) Copyright IBM Corp. 2025. * * 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 @@ -10,8 +10,10 @@ * 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; @@ -115,8 +117,8 @@ public static List creatMockListFileWithMetadata() { return list; } - public static byte[] createMockByteArray(String bytes) { - return bytes.getBytes(); + public static byte[] createMockByteArray(String encodedString) throws Exception { + return Base64.getDecoder().decode(encodedString); } public static Date createMockDate(String date) throws Exception { From 6847c1a4323d690b68a895501360de1f18068d3e Mon Sep 17 00:00:00 2001 From: francescadecicco Date: Tue, 1 Jul 2025 16:53:51 +0200 Subject: [PATCH 2/5] fix(Global Search/Tagging): regenerated services with latest API definition Signed-off-by: francescadecicco --- .../global_tagging/v1/model/QueryString.java | 106 ++++++++++++++++++ .../v1/model/QueryStringTest.java | 51 +++++++++ 2 files changed, 157 insertions(+) create mode 100644 modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryString.java create mode 100644 modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryStringTest.java diff --git a/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryString.java b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryString.java new file mode 100644 index 0000000000..9ba0251d91 --- /dev/null +++ b/modules/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryString.java @@ -0,0 +1,106 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryStringTest.java b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryStringTest.java new file mode 100644 index 0000000000..6592ab4cd5 --- /dev/null +++ b/modules/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryStringTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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 From 6f7eeb644e4661193e8040620e4bd7fd093c6cc9 Mon Sep 17 00:00:00 2001 From: francescadecicco Date: Thu, 3 Jul 2025 17:55:41 +0200 Subject: [PATCH 3/5] feat(Global Search/Tagging): regenerated services with latest API definition Signed-off-by: francescadecicco --- .../global_tagging/v1/GlobalTagging.java | 430 ++++++++++++++++ .../v1/model/AttachTagOptions.java | 393 +++++++++++++++ .../v1/model/CreateTagOptions.java | 245 +++++++++ .../v1/model/CreateTagResults.java | 40 ++ .../v1/model/CreateTagResultsResultsItem.java | 53 ++ .../v1/model/DeleteTagAllOptions.java | 231 +++++++++ .../v1/model/DeleteTagOptions.java | 286 +++++++++++ .../v1/model/DeleteTagResults.java | 40 ++ .../v1/model/DeleteTagResultsItem.java | 67 +++ .../v1/model/DeleteTagsResult.java | 66 +++ .../v1/model/DeleteTagsResultItem.java | 53 ++ .../v1/model/DetachTagOptions.java | 336 +++++++++++++ .../v1/model/ListTagsOptions.java | 446 +++++++++++++++++ .../global_tagging/v1/model/QueryString.java | 106 ++++ .../global_tagging/v1/model/Resource.java | 136 +++++ .../global_tagging/v1/model/Tag.java | 38 ++ .../global_tagging/v1/model/TagList.java | 78 +++ .../global_tagging/v1/model/TagResults.java | 40 ++ .../v1/model/TagResultsItem.java | 53 ++ .../global_tagging/v1/package-info.java | 17 + .../global_tagging/v1/GlobalTaggingTest.java | 467 ++++++++++++++++++ .../v1/model/AttachTagOptionsTest.java | 71 +++ .../v1/model/CreateTagOptionsTest.java | 53 ++ .../CreateTagResultsResultsItemTest.java | 38 ++ .../v1/model/CreateTagResultsTest.java | 38 ++ .../v1/model/DeleteTagAllOptionsTest.java | 47 ++ .../v1/model/DeleteTagOptionsTest.java | 55 +++ .../v1/model/DeleteTagResultsItemTest.java | 38 ++ .../v1/model/DeleteTagResultsTest.java | 38 ++ .../v1/model/DeleteTagsResultItemTest.java | 38 ++ .../v1/model/DeleteTagsResultTest.java | 40 ++ .../v1/model/DetachTagOptionsTest.java | 67 +++ .../v1/model/ListTagsOptionsTest.java | 61 +++ .../v1/model/QueryStringTest.java | 51 ++ .../global_tagging/v1/model/ResourceTest.java | 54 ++ .../global_tagging/v1/model/TagListTest.java | 41 ++ .../v1/model/TagResultsItemTest.java | 38 ++ .../v1/model/TagResultsTest.java | 38 ++ .../global_tagging/v1/model/TagTest.java | 37 ++ .../v1/utils/TestUtilities.java | 131 +++++ pom.xml | 2 +- 41 files changed, 4596 insertions(+), 1 deletion(-) create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTagging.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptions.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptions.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResults.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItem.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptions.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptions.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResults.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItem.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResult.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItem.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptions.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptions.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryString.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Resource.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Tag.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagList.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResults.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItem.java create mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/package-info.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptionsTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptionsTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItemTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptionsTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptionsTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItemTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItemTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptionsTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptionsTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryStringTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ResourceTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagListTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItemTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagTest.java create mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/utils/TestUtilities.java 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..f294e3e602 --- /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. 2025. + * + * 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.105.0-3c13b041-20250605-193116 + */ + +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..cd80f130a6 --- /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. 2025. + * + * 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..0afc9ac8de --- /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. 2025. + * + * 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..442c840aee --- /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. 2025. + * + * 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..c709fccb0d --- /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. 2025. + * + * 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..c68a96ab83 --- /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. 2025. + * + * 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..2b534cab07 --- /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. 2025. + * + * 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..9906a810ca --- /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. 2025. + * + * 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..1821f2566d --- /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. 2025. + * + * 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..47fdc717d5 --- /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. 2025. + * + * 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..8d4eaa504d --- /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. 2025. + * + * 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..a0b7b80c15 --- /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. 2025. + * + * 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..d2fd91d9ab --- /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. 2025. + * + * 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..9ba0251d91 --- /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. 2025. + * + * 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..cd57c8157e --- /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. 2025. + * + * 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..331ac64f5e --- /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. 2025. + * + * 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..85df33ebea --- /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. 2025. + * + * 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..0e5ab7c536 --- /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. 2025. + * + * 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..a7d54aae08 --- /dev/null +++ b/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItem.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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 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; + } +} + 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..057350d5b9 --- /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. 2025. + * + * 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..8ecaf1be21 --- /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. 2025. + * + * 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}]}"; + 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}]}"; + 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..08e25e8817 --- /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. 2025. + * + * 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..a2b95852ba --- /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. 2025. + * + * 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..2cad363f32 --- /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. 2025. + * + * 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..945f41f58a --- /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. 2025. + * + * 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..baffd9cd70 --- /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. 2025. + * + * 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..2797cf2e2f --- /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. 2025. + * + * 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..6b94dcb880 --- /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. 2025. + * + * 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..210263b799 --- /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. 2025. + * + * 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..fcc28ef8c7 --- /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. 2025. + * + * 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..37b01dca08 --- /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. 2025. + * + * 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..81c7117718 --- /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. 2025. + * + * 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..c37577cacd --- /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. 2025. + * + * 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..6592ab4cd5 --- /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. 2025. + * + * 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..525b74c60e --- /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. 2025. + * + * 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..b538963260 --- /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. 2025. + * + * 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..f2b97b5883 --- /dev/null +++ b/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItemTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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()); + } +} \ 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..90d45e4436 --- /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. 2025. + * + * 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..1ac2651b1a --- /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. 2025. + * + * 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..69e5c9cb9b --- /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. 2025. + * + * 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/pom.xml b/pom.xml index 38b9ab4d8a..53abfe22ea 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 7.11.0 4.12.0 3.1.2 - 0.8.10 + 0.8.11 3.1.1 1.6.13 3.1.0 From 2dffc4fead67b7c4d1361486bea9592ee4d0ec59 Mon Sep 17 00:00:00 2001 From: francescadecicco Date: Tue, 8 Jul 2025 16:02:43 +0200 Subject: [PATCH 4/5] feat(Global Search/Tagging): regenerated services with latest API definition Signed-off-by: francescadecicco --- .../global_tagging/v1/GlobalTagging.java | 430 ---------------- .../v1/model/AttachTagOptions.java | 393 --------------- .../v1/model/CreateTagOptions.java | 245 --------- .../v1/model/CreateTagResults.java | 40 -- .../v1/model/CreateTagResultsResultsItem.java | 53 -- .../v1/model/DeleteTagAllOptions.java | 231 --------- .../v1/model/DeleteTagOptions.java | 286 ----------- .../v1/model/DeleteTagResults.java | 40 -- .../v1/model/DeleteTagResultsItem.java | 67 --- .../v1/model/DeleteTagsResult.java | 66 --- .../v1/model/DeleteTagsResultItem.java | 53 -- .../v1/model/DetachTagOptions.java | 336 ------------- .../v1/model/ListTagsOptions.java | 446 ----------------- .../global_tagging/v1/model/QueryString.java | 106 ---- .../global_tagging/v1/model/Resource.java | 136 ----- .../global_tagging/v1/model/Tag.java | 38 -- .../global_tagging/v1/model/TagList.java | 78 --- .../global_tagging/v1/model/TagResults.java | 40 -- .../v1/model/TagResultsItem.java | 53 -- .../global_tagging/v1/package-info.java | 17 - .../global_tagging/v1/GlobalTaggingTest.java | 467 ------------------ .../v1/model/AttachTagOptionsTest.java | 71 --- .../v1/model/CreateTagOptionsTest.java | 53 -- .../CreateTagResultsResultsItemTest.java | 38 -- .../v1/model/CreateTagResultsTest.java | 38 -- .../v1/model/DeleteTagAllOptionsTest.java | 47 -- .../v1/model/DeleteTagOptionsTest.java | 55 --- .../v1/model/DeleteTagResultsItemTest.java | 38 -- .../v1/model/DeleteTagResultsTest.java | 38 -- .../v1/model/DeleteTagsResultItemTest.java | 38 -- .../v1/model/DeleteTagsResultTest.java | 40 -- .../v1/model/DetachTagOptionsTest.java | 67 --- .../v1/model/ListTagsOptionsTest.java | 61 --- .../v1/model/QueryStringTest.java | 51 -- .../global_tagging/v1/model/ResourceTest.java | 54 -- .../global_tagging/v1/model/TagListTest.java | 41 -- .../v1/model/TagResultsItemTest.java | 38 -- .../v1/model/TagResultsTest.java | 38 -- .../global_tagging/v1/model/TagTest.java | 37 -- .../v1/utils/TestUtilities.java | 131 ----- 40 files changed, 4595 deletions(-) delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTagging.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptions.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptions.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResults.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItem.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptions.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptions.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResults.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItem.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResult.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItem.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptions.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptions.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryString.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Resource.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Tag.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagList.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResults.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItem.java delete mode 100644 global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/package-info.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptionsTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptionsTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItemTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptionsTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptionsTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItemTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItemTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptionsTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptionsTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryStringTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ResourceTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagListTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItemTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagTest.java delete mode 100644 global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/utils/TestUtilities.java 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 deleted file mode 100644 index f294e3e602..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTagging.java +++ /dev/null @@ -1,430 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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.105.0-3c13b041-20250605-193116 - */ - -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 deleted file mode 100644 index cd80f130a6..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptions.java +++ /dev/null @@ -1,393 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 0afc9ac8de..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptions.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 442c840aee..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResults.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index c709fccb0d..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItem.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index c68a96ab83..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptions.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 2b534cab07..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptions.java +++ /dev/null @@ -1,286 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 9906a810ca..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResults.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 1821f2566d..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItem.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 47fdc717d5..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResult.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 8d4eaa504d..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItem.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index a0b7b80c15..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptions.java +++ /dev/null @@ -1,336 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index d2fd91d9ab..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptions.java +++ /dev/null @@ -1,446 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 9ba0251d91..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryString.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index cd57c8157e..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Resource.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 331ac64f5e..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/Tag.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 85df33ebea..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagList.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 0e5ab7c536..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResults.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index a7d54aae08..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItem.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 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; - } -} - 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 deleted file mode 100644 index 057350d5b9..0000000000 --- a/global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 8ecaf1be21..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingTest.java +++ /dev/null @@ -1,467 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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}]}"; - 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}]}"; - 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 deleted file mode 100644 index 08e25e8817..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/AttachTagOptionsTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index a2b95852ba..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagOptionsTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 2cad363f32..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsResultsItemTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 945f41f58a..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/CreateTagResultsTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index baffd9cd70..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagAllOptionsTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 2797cf2e2f..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagOptionsTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 6b94dcb880..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsItemTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 210263b799..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagResultsTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index fcc28ef8c7..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultItemTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 37b01dca08..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DeleteTagsResultTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 81c7117718..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/DetachTagOptionsTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index c37577cacd..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ListTagsOptionsTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 6592ab4cd5..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/QueryStringTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 525b74c60e..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/ResourceTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index b538963260..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagListTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index f2b97b5883..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsItemTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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()); - } -} \ 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 deleted file mode 100644 index 90d45e4436..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagResultsTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 1ac2651b1a..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/model/TagTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 deleted file mode 100644 index 69e5c9cb9b..0000000000 --- a/global-tagging/src/test/java/com/ibm/cloud/platform_services/global_tagging/v1/utils/TestUtilities.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2025. - * - * 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 From f85ceded28e83a678137024beeb95bf263064d15 Mon Sep 17 00:00:00 2001 From: Norbert Biczo Date: Wed, 9 Jul 2025 11:33:14 +0200 Subject: [PATCH 5/5] chore: align the examples with the other SDKs Signed-off-by: Norbert Biczo --- .../global_tagging/v1/GlobalTaggingExamples.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/examples/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingExamples.java b/modules/examples/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingExamples.java index 0b014476e3..568e550a6b 100644 --- a/modules/examples/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingExamples.java +++ b/modules/examples/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTaggingExamples.java @@ -22,7 +22,6 @@ 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.Resource; 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.Response; @@ -114,9 +113,7 @@ public static void main(String[] args) throws Exception { // begin-attach_tag - Resource resourceModel = new Resource.Builder().resourceId(resourceCRN).build(); AttachTagOptions attachTagOptions = new AttachTagOptions.Builder() - .addResources(resourceModel) .addTagNames("tag_test_1") .addTagNames("tag_test_2") .build(); @@ -137,9 +134,7 @@ public static void main(String[] args) throws Exception { // begin-detach_tag - Resource resourceModel = new Resource.Builder().resourceId(resourceCRN).build(); DetachTagOptions detachTagOptions = new DetachTagOptions.Builder() - .addResources(resourceModel) .addTagNames("tag_test_1") .addTagNames("tag_test_2") .tagType("user")