Skip to content

Commit ca8273c

Browse files
committed
feat(Tagging): added error message in case of failures
1 parent e79b283 commit ca8273c

40 files changed

Lines changed: 4608 additions & 0 deletions

global-tagging/src/main/java/com/ibm/cloud/platform_services/global_tagging/v1/GlobalTagging.java

Lines changed: 430 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 393 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,393 @@
1+
/*
2+
* (C) Copyright IBM Corp. 2026.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package com.ibm.cloud.platform_services.global_tagging.v1.model;
15+
16+
import java.util.ArrayList;
17+
import java.util.List;
18+
19+
import com.ibm.cloud.sdk.core.service.model.GenericModel;
20+
21+
/**
22+
* The attachTag options.
23+
*/
24+
public class AttachTagOptions extends GenericModel {
25+
26+
/**
27+
* The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported
28+
* for IMS resources.
29+
*/
30+
public interface TagType {
31+
/** user. */
32+
String USER = "user";
33+
/** service. */
34+
String SERVICE = "service";
35+
/** access. */
36+
String ACCESS = "access";
37+
}
38+
39+
protected String tagName;
40+
protected List<String> tagNames;
41+
protected List<Resource> resources;
42+
protected QueryString query;
43+
protected String xRequestId;
44+
protected String xCorrelationId;
45+
protected String accountId;
46+
protected String tagType;
47+
protected Boolean replace;
48+
protected Boolean update;
49+
50+
/**
51+
* Builder.
52+
*/
53+
public static class Builder {
54+
private String tagName;
55+
private List<String> tagNames;
56+
private List<Resource> resources;
57+
private QueryString query;
58+
private String xRequestId;
59+
private String xCorrelationId;
60+
private String accountId;
61+
private String tagType;
62+
private Boolean replace;
63+
private Boolean update;
64+
65+
/**
66+
* Instantiates a new Builder from an existing AttachTagOptions instance.
67+
*
68+
* @param attachTagOptions the instance to initialize the Builder with
69+
*/
70+
private Builder(AttachTagOptions attachTagOptions) {
71+
this.tagName = attachTagOptions.tagName;
72+
this.tagNames = attachTagOptions.tagNames;
73+
this.resources = attachTagOptions.resources;
74+
this.query = attachTagOptions.query;
75+
this.xRequestId = attachTagOptions.xRequestId;
76+
this.xCorrelationId = attachTagOptions.xCorrelationId;
77+
this.accountId = attachTagOptions.accountId;
78+
this.tagType = attachTagOptions.tagType;
79+
this.replace = attachTagOptions.replace;
80+
this.update = attachTagOptions.update;
81+
}
82+
83+
/**
84+
* Instantiates a new builder.
85+
*/
86+
public Builder() {
87+
}
88+
89+
/**
90+
* Builds a AttachTagOptions.
91+
*
92+
* @return the new AttachTagOptions instance
93+
*/
94+
public AttachTagOptions build() {
95+
return new AttachTagOptions(this);
96+
}
97+
98+
/**
99+
* Adds a new element to tagNames.
100+
*
101+
* @param tagNames the new element to be added
102+
* @return the AttachTagOptions builder
103+
*/
104+
public Builder addTagNames(String tagNames) {
105+
com.ibm.cloud.sdk.core.util.Validator.notNull(tagNames,
106+
"tagNames cannot be null");
107+
if (this.tagNames == null) {
108+
this.tagNames = new ArrayList<String>();
109+
}
110+
this.tagNames.add(tagNames);
111+
return this;
112+
}
113+
114+
/**
115+
* Adds a new element to resources.
116+
*
117+
* @param resources the new element to be added
118+
* @return the AttachTagOptions builder
119+
*/
120+
public Builder addResources(Resource resources) {
121+
com.ibm.cloud.sdk.core.util.Validator.notNull(resources,
122+
"resources cannot be null");
123+
if (this.resources == null) {
124+
this.resources = new ArrayList<Resource>();
125+
}
126+
this.resources.add(resources);
127+
return this;
128+
}
129+
130+
/**
131+
* Set the tagName.
132+
*
133+
* @param tagName the tagName
134+
* @return the AttachTagOptions builder
135+
*/
136+
public Builder tagName(String tagName) {
137+
this.tagName = tagName;
138+
return this;
139+
}
140+
141+
/**
142+
* Set the tagNames.
143+
* Existing tagNames will be replaced.
144+
*
145+
* @param tagNames the tagNames
146+
* @return the AttachTagOptions builder
147+
*/
148+
public Builder tagNames(List<String> tagNames) {
149+
this.tagNames = tagNames;
150+
return this;
151+
}
152+
153+
/**
154+
* Set the resources.
155+
* Existing resources will be replaced.
156+
*
157+
* @param resources the resources
158+
* @return the AttachTagOptions builder
159+
*/
160+
public Builder resources(List<Resource> resources) {
161+
this.resources = resources;
162+
return this;
163+
}
164+
165+
/**
166+
* Set the query.
167+
*
168+
* @param query the query
169+
* @return the AttachTagOptions builder
170+
*/
171+
public Builder query(QueryString query) {
172+
this.query = query;
173+
return this;
174+
}
175+
176+
/**
177+
* Set the xRequestId.
178+
*
179+
* @param xRequestId the xRequestId
180+
* @return the AttachTagOptions builder
181+
*/
182+
public Builder xRequestId(String xRequestId) {
183+
this.xRequestId = xRequestId;
184+
return this;
185+
}
186+
187+
/**
188+
* Set the xCorrelationId.
189+
*
190+
* @param xCorrelationId the xCorrelationId
191+
* @return the AttachTagOptions builder
192+
*/
193+
public Builder xCorrelationId(String xCorrelationId) {
194+
this.xCorrelationId = xCorrelationId;
195+
return this;
196+
}
197+
198+
/**
199+
* Set the accountId.
200+
*
201+
* @param accountId the accountId
202+
* @return the AttachTagOptions builder
203+
*/
204+
public Builder accountId(String accountId) {
205+
this.accountId = accountId;
206+
return this;
207+
}
208+
209+
/**
210+
* Set the tagType.
211+
*
212+
* @param tagType the tagType
213+
* @return the AttachTagOptions builder
214+
*/
215+
public Builder tagType(String tagType) {
216+
this.tagType = tagType;
217+
return this;
218+
}
219+
220+
/**
221+
* Set the replace.
222+
*
223+
* @param replace the replace
224+
* @return the AttachTagOptions builder
225+
*/
226+
public Builder replace(Boolean replace) {
227+
this.replace = replace;
228+
return this;
229+
}
230+
231+
/**
232+
* Set the update.
233+
*
234+
* @param update the update
235+
* @return the AttachTagOptions builder
236+
*/
237+
public Builder update(Boolean update) {
238+
this.update = update;
239+
return this;
240+
}
241+
}
242+
243+
protected AttachTagOptions() { }
244+
245+
protected AttachTagOptions(Builder builder) {
246+
tagName = builder.tagName;
247+
tagNames = builder.tagNames;
248+
resources = builder.resources;
249+
query = builder.query;
250+
xRequestId = builder.xRequestId;
251+
xCorrelationId = builder.xCorrelationId;
252+
accountId = builder.accountId;
253+
tagType = builder.tagType;
254+
replace = builder.replace;
255+
update = builder.update;
256+
}
257+
258+
/**
259+
* New builder.
260+
*
261+
* @return a AttachTagOptions builder
262+
*/
263+
public Builder newBuilder() {
264+
return new Builder(this);
265+
}
266+
267+
/**
268+
* Gets the tagName.
269+
*
270+
* The name of the tag to attach.
271+
*
272+
* @return the tagName
273+
*/
274+
public String tagName() {
275+
return tagName;
276+
}
277+
278+
/**
279+
* Gets the tagNames.
280+
*
281+
* An array of tag names to attach.
282+
*
283+
* @return the tagNames
284+
*/
285+
public List<String> tagNames() {
286+
return tagNames;
287+
}
288+
289+
/**
290+
* Gets the resources.
291+
*
292+
* List of resources on which the tagging operation operates on.
293+
*
294+
* @return the resources
295+
*/
296+
public List<Resource> resources() {
297+
return resources;
298+
}
299+
300+
/**
301+
* Gets the query.
302+
*
303+
* A valid Global Search string.
304+
*
305+
* @return the query
306+
*/
307+
public QueryString query() {
308+
return query;
309+
}
310+
311+
/**
312+
* Gets the xRequestId.
313+
*
314+
* An alphanumeric string that is used to trace the request. The value may include ASCII alphanumerics and any of
315+
* following segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to
316+
* 1024 bytes. The value is considered invalid and must be ignored if that value includes any other character or is
317+
* longer than 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by
318+
* a random (version 4) UUID.
319+
*
320+
* @return the xRequestId
321+
*/
322+
public String xRequestId() {
323+
return xRequestId;
324+
}
325+
326+
/**
327+
* Gets the xCorrelationId.
328+
*
329+
* An alphanumeric string that is used to trace the request as a part of a larger context: the same value is used for
330+
* downstream requests and retries of those requests. The value may include ASCII alphanumerics and any of following
331+
* segment separators: space ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to 1024 bytes.
332+
* The value is considered invalid and must be ignored if that value includes any other character or is longer than
333+
* 1024 bytes or is fewer than 8 characters. If not specified or invalid, it is automatically replaced by a random
334+
* (version 4) UUID.
335+
*
336+
* @return the xCorrelationId
337+
*/
338+
public String xCorrelationId() {
339+
return xCorrelationId;
340+
}
341+
342+
/**
343+
* Gets the accountId.
344+
*
345+
* The ID of the billing account of the tagged resource. It is a required parameter if `tag_type` is set to `service`.
346+
* Otherwise, it is inferred from the authorization IAM token.
347+
*
348+
* @return the accountId
349+
*/
350+
public String accountId() {
351+
return accountId;
352+
}
353+
354+
/**
355+
* Gets the tagType.
356+
*
357+
* The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported
358+
* for IMS resources.
359+
*
360+
* @return the tagType
361+
*/
362+
public String tagType() {
363+
return tagType;
364+
}
365+
366+
/**
367+
* Gets the replace.
368+
*
369+
* Flag to request replacement of all attached tags. Set `true` if you want to replace all tags attached to the
370+
* resource with the current ones. Default value is false.
371+
*
372+
* @return the replace
373+
*/
374+
public Boolean replace() {
375+
return replace;
376+
}
377+
378+
/**
379+
* Gets the update.
380+
*
381+
* Flag to request update of attached tags in the format `key:value`. Here's how it works for each tag in the request
382+
* body: If the tag to attach is in the format `key:value`, the System will atomically detach all existing tags
383+
* starting with `key:` and attach the new `key:value` tag. If no such tags exist, a new `key:value` tag will be
384+
* attached. If the tag is not in the `key:value` format (e.g., a simple label), the System will attach the label as
385+
* usual. The update query parameter is available for user and access management tags, but not for service tags.
386+
*
387+
* @return the update
388+
*/
389+
public Boolean update() {
390+
return update;
391+
}
392+
}
393+

0 commit comments

Comments
 (0)