Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -338,19 +338,36 @@ public ServiceCall<TagResults> 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<TagResults> responseConverter =
ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<TagResults>() { }.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<TagResults> attachTag() {
return attachTag(null);
}

/**
* Detach tags.
*
Expand Down Expand Up @@ -381,17 +398,33 @@ public ServiceCall<TagResults> 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<TagResults> responseConverter =
ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<TagResults>() { }.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<TagResults> detachTag() {
return detachTag(null);
}

}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -35,9 +36,10 @@ public interface TagType {
String ACCESS = "access";
}

protected List<Resource> resources;
protected String tagName;
protected List<String> tagNames;
protected List<Resource> resources;
protected QueryString query;
protected String xRequestId;
protected String xCorrelationId;
protected String accountId;
Expand All @@ -49,9 +51,10 @@ public interface TagType {
* Builder.
*/
public static class Builder {
private List<Resource> resources;
private String tagName;
private List<String> tagNames;
private List<Resource> resources;
private QueryString query;
private String xRequestId;
private String xCorrelationId;
private String accountId;
Expand All @@ -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;
Expand All @@ -82,15 +86,6 @@ private Builder(AttachTagOptions attachTagOptions) {
public Builder() {
}

/**
* Instantiates a new builder with required properties.
*
* @param resources the resources
*/
public Builder(List<Resource> resources) {
this.resources = resources;
}

/**
* Builds a AttachTagOptions.
*
Expand All @@ -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<Resource>();
}
this.resources.add(resources);
return this;
}

/**
* Adds a new element to tagNames.
*
Expand All @@ -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<Resource> 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<Resource>();
}
this.resources.add(resources);
return this;
}

Expand All @@ -167,6 +150,29 @@ public Builder tagNames(List<String> tagNames) {
return this;
}

/**
* Set the resources.
* Existing resources will be replaced.
*
* @param resources the resources
* @return the AttachTagOptions builder
*/
public Builder resources(List<Resource> 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.
*
Expand Down Expand Up @@ -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;
Expand All @@ -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<Resource> resources() {
return resources;
}

/**
* Gets the tagName.
*
Expand All @@ -292,6 +286,28 @@ public List<String> tagNames() {
return tagNames;
}

/**
* Gets the resources.
*
* List of resources on which the tagging operation operates on.
*
* @return the resources
*/
public List<Resource> resources() {
return resources;
}

/**
* Gets the query.
*
* A valid Global Search string.
*
* @return the query
*/
public QueryString query() {
return query;
}

/**
* Gets the xRequestId.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down
Loading