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,6 +22,7 @@
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 @@ -113,7 +114,12 @@ 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 @@ -134,7 +140,12 @@ 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. 2025.
* (C) Copyright IBM Corp. 2026.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -12,7 +12,7 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 3.105.0-3c13b041-20250605-193116
* IBM OpenAPI SDK Code Generator Version: 3.111.0-1bfb72c2-20260206-185521
*/

package com.ibm.cloud.platform_services.global_tagging.v1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2025.
* (C) Copyright IBM Corp. 2026.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -25,6 +25,7 @@ public class TagResultsItem extends GenericModel {
protected String resourceId;
@SerializedName("is_error")
protected Boolean isError;
protected String message;

protected TagResultsItem() { }

Expand All @@ -49,5 +50,16 @@ public String getResourceId() {
public Boolean isIsError() {
return isError;
}

/**
* Gets the message.
*
* Error message returned when the operation fails.
*
* @return the message
*/
public String getMessage() {
return message;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@ public void testDeleteTagUser() throws Exception {

assertNotNull(deleteTagResults.getResults());
for (DeleteTagResultsItem result : deleteTagResults.getResults()) {
assertFalse(result.isIsError());
// tags are already deleted at detach time if not attached to any resource
assertTrue(result.isIsError());
}
} catch (ServiceResponseException e) {
fail(String.format("Service returned status code %d: %s\nError details: %s", e.getStatusCode(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2025.
* (C) Copyright IBM Corp. 2026.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -305,7 +305,7 @@ public void testDeleteTagNoOptions() throws Throwable {
@Test
public void testAttachTagWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"results\": [{\"resource_id\": \"resourceId\", \"is_error\": false}]}";
String mockResponseBody = "{\"results\": [{\"resource_id\": \"resourceId\", \"is_error\": false, \"message\": \"message\"}]}";
String attachTagPath = "/v3/tags/attach";
server.enqueue(new MockResponse()
.setHeader("Content-type", "application/json")
Expand Down Expand Up @@ -373,7 +373,7 @@ public void testAttachTagWRetries() throws Throwable {
@Test
public void testDetachTagWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"results\": [{\"resource_id\": \"resourceId\", \"is_error\": false}]}";
String mockResponseBody = "{\"results\": [{\"resource_id\": \"resourceId\", \"is_error\": false, \"message\": \"message\"}]}";
String detachTagPath = "/v3/tags/detach";
server.enqueue(new MockResponse()
.setHeader("Content-type", "application/json")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2025.
* (C) Copyright IBM Corp. 2026.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -34,5 +34,6 @@ public void testTagResultsItem() throws Throwable {
TagResultsItem tagResultsItemModel = new TagResultsItem();
assertNull(tagResultsItemModel.getResourceId());
assertNull(tagResultsItemModel.isIsError());
assertNull(tagResultsItemModel.getMessage());
}
}