Skip to content

Commit 649c1a1

Browse files
feat(Global Tagging): regenerate service with latest API definition (#295)
Signed-off-by: francescadecicco <[email protected]>
1 parent dccc02e commit 649c1a1

File tree

3 files changed

+204
-155
lines changed

3 files changed

+204
-155
lines changed

examples/test_global_tagging_v1_examples.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,8 @@ def test_attach_tag_example(self):
128128
print('\nattach_tag() result:')
129129
# begin-attach_tag
130130

131-
resource_model = {'resource_id': resource_crn}
132-
133131
tag_results = global_tagging_service.attach_tag(
134-
resources=[resource_model], tag_names=['tag_test_1', 'tag_test_2'], tag_type='user'
132+
tag_names=['tag_test_1', 'tag_test_2'], tag_type='user'
135133
).get_result()
136134

137135
print(json.dumps(tag_results, indent=2))
@@ -150,10 +148,8 @@ def test_detach_tag_example(self):
150148
print('\ndetach_tag() result:')
151149
# begin-detach_tag
152150

153-
resource_model = {'resource_id': resource_crn}
154-
155151
tag_results = global_tagging_service.detach_tag(
156-
resources=[resource_model], tag_names=['tag_test_1', 'tag_test_2'], tag_type='user'
152+
tag_names=['tag_test_1', 'tag_test_2'], tag_type='user'
157153
).get_result()
158154

159155
print(json.dumps(tag_results, indent=2))

ibm_platform_services/global_tagging_v1.py

Lines changed: 129 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding: utf-8
22

3-
# (C) Copyright IBM Corp. 2024.
3+
# (C) Copyright IBM Corp. 2025.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# IBM OpenAPI SDK Code Generator Version: 3.87.0-91c7c775-20240320-213027
17+
# IBM OpenAPI SDK Code Generator Version: 3.105.0-3c13b041-20250605-193116
1818

1919
"""
2020
Manage your tags with the Tagging API in IBM Cloud. You can attach, detach, delete, or
@@ -23,10 +23,10 @@
2323
`label`. The tagging API supports three types of tag: `user` `service`, and `access` tags.
2424
`service` tags cannot be attached to IMS resources. `service` tags must be in the form
2525
`service_prefix:tag_label` where `service_prefix` identifies the Service owning the tag.
26-
`access` tags cannot be attached to IMS and Cloud Foundry resources. They must be in the
27-
form `key:value`. You can replace all resource's tags using the `replace` query parameter
28-
in the attach operation. You can update the `value` of a resource's tag in the format
29-
`key:value`, using the `update` query parameter in the attach operation.
26+
`access` tags cannot be attached to IMS resources. They must be in the form `key:value`.
27+
You can replace all resource's tags using the `replace` query parameter in the attach
28+
operation. You can update the `value` of a resource's tag in the format `key:value`, using
29+
the `update` query parameter in the attach operation.
3030
3131
API Version: 1.2.0
3232
"""
@@ -453,10 +453,11 @@ def delete_tag(
453453

454454
def attach_tag(
455455
self,
456-
resources: List['Resource'],
457456
*,
458457
tag_name: Optional[str] = None,
459458
tag_names: Optional[List[str]] = None,
459+
resources: Optional[List['Resource']] = None,
460+
query: Optional['QueryString'] = None,
460461
x_request_id: Optional[str] = None,
461462
x_correlation_id: Optional[str] = None,
462463
account_id: Optional[str] = None,
@@ -472,10 +473,11 @@ def attach_tag(
472473
than 1000 tags per each 'user' and 'service' type, and no more than 250 'access'
473474
tags (which is the account limit).
474475
475-
:param List[Resource] resources: List of resources on which the tag or tags
476-
are attached.
477476
:param str tag_name: (optional) The name of the tag to attach.
478477
:param List[str] tag_names: (optional) An array of tag names to attach.
478+
:param List[Resource] resources: (optional) List of resources on which the
479+
tagging operation operates on.
480+
:param QueryString query: (optional) A valid Global Search string.
479481
:param str x_request_id: (optional) An alphanumeric string that is used to
480482
trace the request. The value may include ASCII alphanumerics and any of
481483
following segment separators: space ( ), comma (,), hyphen, (-), and
@@ -516,9 +518,10 @@ def attach_tag(
516518
:rtype: DetailedResponse with `dict` result representing a `TagResults` object
517519
"""
518520

519-
if resources is None:
520-
raise ValueError('resources must be provided')
521-
resources = [convert_model(x) for x in resources]
521+
if resources is not None:
522+
resources = [convert_model(x) for x in resources]
523+
if query is not None:
524+
query = convert_model(query)
522525
headers = {
523526
'x-request-id': x_request_id,
524527
'x-correlation-id': x_correlation_id,
@@ -538,9 +541,10 @@ def attach_tag(
538541
}
539542

540543
data = {
541-
'resources': resources,
542544
'tag_name': tag_name,
543545
'tag_names': tag_names,
546+
'resources': resources,
547+
'query': query,
544548
}
545549
data = {k: v for (k, v) in data.items() if v is not None}
546550
data = json.dumps(data)
@@ -565,10 +569,11 @@ def attach_tag(
565569

566570
def detach_tag(
567571
self,
568-
resources: List['Resource'],
569572
*,
570573
tag_name: Optional[str] = None,
571574
tag_names: Optional[List[str]] = None,
575+
resources: Optional[List['Resource']] = None,
576+
query: Optional['QueryString'] = None,
572577
x_request_id: Optional[str] = None,
573578
x_correlation_id: Optional[str] = None,
574579
account_id: Optional[str] = None,
@@ -580,10 +585,11 @@ def detach_tag(
580585
581586
Detaches one or more tags from one or more resources.
582587
583-
:param List[Resource] resources: List of resources on which the tag or tags
584-
are detached.
585588
:param str tag_name: (optional) The name of the tag to detach.
586589
:param List[str] tag_names: (optional) An array of tag names to detach.
590+
:param List[Resource] resources: (optional) List of resources on which the
591+
tagging operation operates on.
592+
:param QueryString query: (optional) A valid Global Search string.
587593
:param str x_request_id: (optional) An alphanumeric string that is used to
588594
trace the request. The value may include ASCII alphanumerics and any of
589595
following segment separators: space ( ), comma (,), hyphen, (-), and
@@ -612,9 +618,10 @@ def detach_tag(
612618
:rtype: DetailedResponse with `dict` result representing a `TagResults` object
613619
"""
614620

615-
if resources is None:
616-
raise ValueError('resources must be provided')
617-
resources = [convert_model(x) for x in resources]
621+
if resources is not None:
622+
resources = [convert_model(x) for x in resources]
623+
if query is not None:
624+
query = convert_model(query)
618625
headers = {
619626
'x-request-id': x_request_id,
620627
'x-correlation-id': x_correlation_id,
@@ -632,9 +639,10 @@ def detach_tag(
632639
}
633640

634641
data = {
635-
'resources': resources,
636642
'tag_name': tag_name,
637643
'tag_names': tag_names,
644+
'resources': resources,
645+
'query': query,
638646
}
639647
data = {k: v for (k, v) in data.items() if v is not None}
640648
data = json.dumps(data)
@@ -1001,6 +1009,8 @@ class DeleteTagResultsItem:
10011009
:param str provider: (optional) The provider of the tag.
10021010
:param bool is_error: (optional) It is `true` if the operation exits with an
10031011
error (for example, the tag does not exist).
1012+
1013+
This type supports additional properties of type object.
10041014
"""
10051015

10061016
# The set of defined properties for the class
@@ -1011,20 +1021,25 @@ def __init__(
10111021
*,
10121022
provider: Optional[str] = None,
10131023
is_error: Optional[bool] = None,
1014-
**kwargs,
1024+
**kwargs: Optional[object],
10151025
) -> None:
10161026
"""
10171027
Initialize a DeleteTagResultsItem object.
10181028
10191029
:param str provider: (optional) The provider of the tag.
10201030
:param bool is_error: (optional) It is `true` if the operation exits with
10211031
an error (for example, the tag does not exist).
1022-
:param **kwargs: (optional) Any additional properties.
1032+
:param object **kwargs: (optional) Additional properties of type object
10231033
"""
10241034
self.provider = provider
10251035
self.is_error = is_error
1026-
for _key, _value in kwargs.items():
1027-
setattr(self, _key, _value)
1036+
for k, v in kwargs.items():
1037+
if k not in DeleteTagResultsItem._properties:
1038+
if not isinstance(v, object):
1039+
raise ValueError('Value for additional property {} must be of type object'.format(k))
1040+
setattr(self, k, v)
1041+
else:
1042+
raise ValueError('Property {} cannot be specified as an additional property'.format(k))
10281043

10291044
@classmethod
10301045
def from_dict(cls, _dict: Dict) -> 'DeleteTagResultsItem':
@@ -1034,7 +1049,11 @@ def from_dict(cls, _dict: Dict) -> 'DeleteTagResultsItem':
10341049
args['provider'] = provider
10351050
if (is_error := _dict.get('is_error')) is not None:
10361051
args['is_error'] = is_error
1037-
args.update({k: v for (k, v) in _dict.items() if k not in cls._properties})
1052+
for k, v in _dict.items():
1053+
if k not in cls._properties:
1054+
if not isinstance(v, object):
1055+
raise ValueError('Value for additional property {} must be of type object'.format(k))
1056+
args[k] = v
10381057
return cls(**args)
10391058

10401059
@classmethod
@@ -1049,30 +1068,32 @@ def to_dict(self) -> Dict:
10491068
_dict['provider'] = self.provider
10501069
if hasattr(self, 'is_error') and self.is_error is not None:
10511070
_dict['is_error'] = self.is_error
1052-
for _key in [k for k in vars(self).keys() if k not in DeleteTagResultsItem._properties]:
1053-
_dict[_key] = getattr(self, _key)
1071+
for k in [_k for _k in vars(self).keys() if _k not in DeleteTagResultsItem._properties]:
1072+
_dict[k] = getattr(self, k)
10541073
return _dict
10551074

10561075
def _to_dict(self):
10571076
"""Return a json dictionary representing this model."""
10581077
return self.to_dict()
10591078

10601079
def get_properties(self) -> Dict:
1061-
"""Return a dictionary of arbitrary properties from this instance of DeleteTagResultsItem"""
1080+
"""Return the additional properties from this instance of DeleteTagResultsItem in the form of a dict."""
10621081
_dict = {}
1063-
1064-
for _key in [k for k in vars(self).keys() if k not in DeleteTagResultsItem._properties]:
1065-
_dict[_key] = getattr(self, _key)
1082+
for k in [_k for _k in vars(self).keys() if _k not in DeleteTagResultsItem._properties]:
1083+
_dict[k] = getattr(self, k)
10661084
return _dict
10671085

10681086
def set_properties(self, _dict: dict):
1069-
"""Set a dictionary of arbitrary properties to this instance of DeleteTagResultsItem"""
1070-
for _key in [k for k in vars(self).keys() if k not in DeleteTagResultsItem._properties]:
1071-
delattr(self, _key)
1072-
1073-
for _key, _value in _dict.items():
1074-
if _key not in DeleteTagResultsItem._properties:
1075-
setattr(self, _key, _value)
1087+
"""Set a dictionary of additional properties in this instance of DeleteTagResultsItem"""
1088+
for k in [_k for _k in vars(self).keys() if _k not in DeleteTagResultsItem._properties]:
1089+
delattr(self, k)
1090+
for k, v in _dict.items():
1091+
if k not in DeleteTagResultsItem._properties:
1092+
if not isinstance(v, object):
1093+
raise ValueError('Value for additional property {} must be of type object'.format(k))
1094+
setattr(self, k, v)
1095+
else:
1096+
raise ValueError('Property {} cannot be specified as an additional property'.format(k))
10761097

10771098
def __str__(self) -> str:
10781099
"""Return a `str` version of this DeleteTagResultsItem object."""
@@ -1248,12 +1269,76 @@ def __ne__(self, other: 'DeleteTagsResultItem') -> bool:
12481269
return not self == other
12491270

12501271

1272+
class QueryString:
1273+
"""
1274+
A valid Global Search string.
1275+
1276+
:param str query_string: The Lucene-formatted query string.
1277+
"""
1278+
1279+
def __init__(
1280+
self,
1281+
query_string: str,
1282+
) -> None:
1283+
"""
1284+
Initialize a QueryString object.
1285+
1286+
:param str query_string: The Lucene-formatted query string.
1287+
"""
1288+
self.query_string = query_string
1289+
1290+
@classmethod
1291+
def from_dict(cls, _dict: Dict) -> 'QueryString':
1292+
"""Initialize a QueryString object from a json dictionary."""
1293+
args = {}
1294+
if (query_string := _dict.get('query_string')) is not None:
1295+
args['query_string'] = query_string
1296+
else:
1297+
raise ValueError('Required property \'query_string\' not present in QueryString JSON')
1298+
return cls(**args)
1299+
1300+
@classmethod
1301+
def _from_dict(cls, _dict):
1302+
"""Initialize a QueryString object from a json dictionary."""
1303+
return cls.from_dict(_dict)
1304+
1305+
def to_dict(self) -> Dict:
1306+
"""Return a json dictionary representing this model."""
1307+
_dict = {}
1308+
if hasattr(self, 'query_string') and self.query_string is not None:
1309+
_dict['query_string'] = self.query_string
1310+
return _dict
1311+
1312+
def _to_dict(self):
1313+
"""Return a json dictionary representing this model."""
1314+
return self.to_dict()
1315+
1316+
def __str__(self) -> str:
1317+
"""Return a `str` version of this QueryString object."""
1318+
return json.dumps(self.to_dict(), indent=2)
1319+
1320+
def __eq__(self, other: 'QueryString') -> bool:
1321+
"""Return `true` when self and other are equal, false otherwise."""
1322+
if not isinstance(other, self.__class__):
1323+
return False
1324+
return self.__dict__ == other.__dict__
1325+
1326+
def __ne__(self, other: 'QueryString') -> bool:
1327+
"""Return `true` when self and other are not equal, false otherwise."""
1328+
return not self == other
1329+
1330+
12511331
class Resource:
12521332
"""
12531333
A resource that might have tags that are attached.
12541334
12551335
:param str resource_id: The CRN or IMS ID of the resource.
1256-
:param str resource_type: (optional) The IMS resource type of the resource.
1336+
:param str resource_type: (optional) The IMS resource type of the resource. It
1337+
can be one of SoftLayer_Virtual_DedicatedHost, SoftLayer_Hardware,
1338+
SoftLayer_Hardware_Server, SoftLayer_Network_Application_Delivery_Controller,
1339+
SoftLayer_Network_Vlan, SoftLayer_Network_Vlan_Firewall,
1340+
SoftLayer_Network_Component_Firewall, SoftLayer_Network_Firewall_Module_Context,
1341+
SoftLayer_Virtual_Guest.
12571342
"""
12581343

12591344
def __init__(
@@ -1267,6 +1352,11 @@ def __init__(
12671352
12681353
:param str resource_id: The CRN or IMS ID of the resource.
12691354
:param str resource_type: (optional) The IMS resource type of the resource.
1355+
It can be one of SoftLayer_Virtual_DedicatedHost, SoftLayer_Hardware,
1356+
SoftLayer_Hardware_Server,
1357+
SoftLayer_Network_Application_Delivery_Controller, SoftLayer_Network_Vlan,
1358+
SoftLayer_Network_Vlan_Firewall, SoftLayer_Network_Component_Firewall,
1359+
SoftLayer_Network_Firewall_Module_Context, SoftLayer_Virtual_Guest.
12701360
"""
12711361
self.resource_id = resource_id
12721362
self.resource_type = resource_type

0 commit comments

Comments
 (0)