1
1
# coding: utf-8
2
2
3
- # (C) Copyright IBM Corp. 2024 .
3
+ # (C) Copyright IBM Corp. 2025 .
4
4
#
5
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
6
# you may not use this file except in compliance with the License.
14
14
# See the License for the specific language governing permissions and
15
15
# limitations under the License.
16
16
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
18
18
19
19
"""
20
20
Manage your tags with the Tagging API in IBM Cloud. You can attach, detach, delete, or
23
23
`label`. The tagging API supports three types of tag: `user` `service`, and `access` tags.
24
24
`service` tags cannot be attached to IMS resources. `service` tags must be in the form
25
25
`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.
30
30
31
31
API Version: 1.2.0
32
32
"""
@@ -63,7 +63,9 @@ def new_instance(
63
63
parameters and external configuration.
64
64
"""
65
65
authenticator = get_authenticator_from_environment (service_name )
66
- service = cls (authenticator )
66
+ service = cls (
67
+ authenticator
68
+ )
67
69
service .configure_service (service_name )
68
70
return service
69
71
@@ -453,10 +455,11 @@ def delete_tag(
453
455
454
456
def attach_tag (
455
457
self ,
456
- resources : List ['Resource' ],
457
458
* ,
458
459
tag_name : Optional [str ] = None ,
459
460
tag_names : Optional [List [str ]] = None ,
461
+ resources : Optional [List ['Resource' ]] = None ,
462
+ query : Optional ['QueryString' ] = None ,
460
463
x_request_id : Optional [str ] = None ,
461
464
x_correlation_id : Optional [str ] = None ,
462
465
account_id : Optional [str ] = None ,
@@ -472,10 +475,11 @@ def attach_tag(
472
475
than 1000 tags per each 'user' and 'service' type, and no more than 250 'access'
473
476
tags (which is the account limit).
474
477
475
- :param List[Resource] resources: List of resources on which the tag or tags
476
- are attached.
477
478
:param str tag_name: (optional) The name of the tag to attach.
478
479
:param List[str] tag_names: (optional) An array of tag names to attach.
480
+ :param List[Resource] resources: (optional) List of resources on which the
481
+ tagging operation operates on.
482
+ :param QueryString query: (optional) A valid Global Search string.
479
483
:param str x_request_id: (optional) An alphanumeric string that is used to
480
484
trace the request. The value may include ASCII alphanumerics and any of
481
485
following segment separators: space ( ), comma (,), hyphen, (-), and
@@ -516,9 +520,10 @@ def attach_tag(
516
520
:rtype: DetailedResponse with `dict` result representing a `TagResults` object
517
521
"""
518
522
519
- if resources is None :
520
- raise ValueError ('resources must be provided' )
521
- resources = [convert_model (x ) for x in resources ]
523
+ if resources is not None :
524
+ resources = [convert_model (x ) for x in resources ]
525
+ if query is not None :
526
+ query = convert_model (query )
522
527
headers = {
523
528
'x-request-id' : x_request_id ,
524
529
'x-correlation-id' : x_correlation_id ,
@@ -538,9 +543,10 @@ def attach_tag(
538
543
}
539
544
540
545
data = {
541
- 'resources' : resources ,
542
546
'tag_name' : tag_name ,
543
547
'tag_names' : tag_names ,
548
+ 'resources' : resources ,
549
+ 'query' : query ,
544
550
}
545
551
data = {k : v for (k , v ) in data .items () if v is not None }
546
552
data = json .dumps (data )
@@ -565,10 +571,11 @@ def attach_tag(
565
571
566
572
def detach_tag (
567
573
self ,
568
- resources : List ['Resource' ],
569
574
* ,
570
575
tag_name : Optional [str ] = None ,
571
576
tag_names : Optional [List [str ]] = None ,
577
+ resources : Optional [List ['Resource' ]] = None ,
578
+ query : Optional ['QueryString' ] = None ,
572
579
x_request_id : Optional [str ] = None ,
573
580
x_correlation_id : Optional [str ] = None ,
574
581
account_id : Optional [str ] = None ,
@@ -580,10 +587,11 @@ def detach_tag(
580
587
581
588
Detaches one or more tags from one or more resources.
582
589
583
- :param List[Resource] resources: List of resources on which the tag or tags
584
- are detached.
585
590
:param str tag_name: (optional) The name of the tag to detach.
586
591
:param List[str] tag_names: (optional) An array of tag names to detach.
592
+ :param List[Resource] resources: (optional) List of resources on which the
593
+ tagging operation operates on.
594
+ :param QueryString query: (optional) A valid Global Search string.
587
595
:param str x_request_id: (optional) An alphanumeric string that is used to
588
596
trace the request. The value may include ASCII alphanumerics and any of
589
597
following segment separators: space ( ), comma (,), hyphen, (-), and
@@ -612,9 +620,10 @@ def detach_tag(
612
620
:rtype: DetailedResponse with `dict` result representing a `TagResults` object
613
621
"""
614
622
615
- if resources is None :
616
- raise ValueError ('resources must be provided' )
617
- resources = [convert_model (x ) for x in resources ]
623
+ if resources is not None :
624
+ resources = [convert_model (x ) for x in resources ]
625
+ if query is not None :
626
+ query = convert_model (query )
618
627
headers = {
619
628
'x-request-id' : x_request_id ,
620
629
'x-correlation-id' : x_correlation_id ,
@@ -632,9 +641,10 @@ def detach_tag(
632
641
}
633
642
634
643
data = {
635
- 'resources' : resources ,
636
644
'tag_name' : tag_name ,
637
645
'tag_names' : tag_names ,
646
+ 'resources' : resources ,
647
+ 'query' : query ,
638
648
}
639
649
data = {k : v for (k , v ) in data .items () if v is not None }
640
650
data = json .dumps (data )
@@ -672,7 +682,6 @@ class TagType(str, Enum):
672
682
USER = 'user'
673
683
SERVICE = 'service'
674
684
ACCESS = 'access'
675
-
676
685
class Providers (str , Enum ):
677
686
"""
678
687
Select a provider. Supported values are `ghost` and `ims`. To list both Global
@@ -683,7 +692,6 @@ class Providers(str, Enum):
683
692
684
693
GHOST = 'ghost'
685
694
IMS = 'ims'
686
-
687
695
class OrderByName (str , Enum ):
688
696
"""
689
697
Order the output by tag name.
@@ -718,7 +726,6 @@ class Providers(str, Enum):
718
726
719
727
GHOST = 'ghost'
720
728
IMS = 'ims'
721
-
722
729
class TagType (str , Enum ):
723
730
"""
724
731
The type of the tag. Supported values are `user`, `service` and `access`.
@@ -744,7 +751,6 @@ class Providers(str, Enum):
744
751
745
752
GHOST = 'ghost'
746
753
IMS = 'ims'
747
-
748
754
class TagType (str , Enum ):
749
755
"""
750
756
The type of the tag. Supported values are `user`, `service` and `access`.
@@ -1001,6 +1007,8 @@ class DeleteTagResultsItem:
1001
1007
:param str provider: (optional) The provider of the tag.
1002
1008
:param bool is_error: (optional) It is `true` if the operation exits with an
1003
1009
error (for example, the tag does not exist).
1010
+
1011
+ This type supports additional properties of type object.
1004
1012
"""
1005
1013
1006
1014
# The set of defined properties for the class
@@ -1011,20 +1019,25 @@ def __init__(
1011
1019
* ,
1012
1020
provider : Optional [str ] = None ,
1013
1021
is_error : Optional [bool ] = None ,
1014
- ** kwargs ,
1022
+ ** kwargs : Optional [ object ] ,
1015
1023
) -> None :
1016
1024
"""
1017
1025
Initialize a DeleteTagResultsItem object.
1018
1026
1019
1027
:param str provider: (optional) The provider of the tag.
1020
1028
:param bool is_error: (optional) It is `true` if the operation exits with
1021
1029
an error (for example, the tag does not exist).
1022
- :param **kwargs: (optional) Any additional properties.
1030
+ :param object **kwargs: (optional) Additional properties of type object
1023
1031
"""
1024
1032
self .provider = provider
1025
1033
self .is_error = is_error
1026
- for _key , _value in kwargs .items ():
1027
- setattr (self , _key , _value )
1034
+ for k , v in kwargs .items ():
1035
+ if k not in DeleteTagResultsItem ._properties :
1036
+ if not isinstance (v , object ):
1037
+ raise ValueError ('Value for additional property {} must be of type object' .format (k ))
1038
+ setattr (self , k , v )
1039
+ else :
1040
+ raise ValueError ('Property {} cannot be specified as an additional property' .format (k ))
1028
1041
1029
1042
@classmethod
1030
1043
def from_dict (cls , _dict : Dict ) -> 'DeleteTagResultsItem' :
@@ -1034,7 +1047,11 @@ def from_dict(cls, _dict: Dict) -> 'DeleteTagResultsItem':
1034
1047
args ['provider' ] = provider
1035
1048
if (is_error := _dict .get ('is_error' )) is not None :
1036
1049
args ['is_error' ] = is_error
1037
- args .update ({k : v for (k , v ) in _dict .items () if k not in cls ._properties })
1050
+ for k , v in _dict .items ():
1051
+ if k not in cls ._properties :
1052
+ if not isinstance (v , object ):
1053
+ raise ValueError ('Value for additional property {} must be of type object' .format (k ))
1054
+ args [k ] = v
1038
1055
return cls (** args )
1039
1056
1040
1057
@classmethod
@@ -1049,30 +1066,32 @@ def to_dict(self) -> Dict:
1049
1066
_dict ['provider' ] = self .provider
1050
1067
if hasattr (self , 'is_error' ) and self .is_error is not None :
1051
1068
_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 )
1069
+ for k in [_k for _k in vars (self ).keys () if _k not in DeleteTagResultsItem ._properties ]:
1070
+ _dict [k ] = getattr (self , k )
1054
1071
return _dict
1055
1072
1056
1073
def _to_dict (self ):
1057
1074
"""Return a json dictionary representing this model."""
1058
1075
return self .to_dict ()
1059
1076
1060
1077
def get_properties (self ) -> Dict :
1061
- """Return a dictionary of arbitrary properties from this instance of DeleteTagResultsItem"""
1078
+ """Return the additional properties from this instance of DeleteTagResultsItem in the form of a dict. """
1062
1079
_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 )
1080
+ for k in [_k for _k in vars (self ).keys () if _k not in DeleteTagResultsItem ._properties ]:
1081
+ _dict [k ] = getattr (self , k )
1066
1082
return _dict
1067
1083
1068
1084
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 )
1085
+ """Set a dictionary of additional properties in this instance of DeleteTagResultsItem"""
1086
+ for k in [_k for _k in vars (self ).keys () if _k not in DeleteTagResultsItem ._properties ]:
1087
+ delattr (self , k )
1088
+ for k , v in _dict .items ():
1089
+ if k not in DeleteTagResultsItem ._properties :
1090
+ if not isinstance (v , object ):
1091
+ raise ValueError ('Value for additional property {} must be of type object' .format (k ))
1092
+ setattr (self , k , v )
1093
+ else :
1094
+ raise ValueError ('Property {} cannot be specified as an additional property' .format (k ))
1076
1095
1077
1096
def __str__ (self ) -> str :
1078
1097
"""Return a `str` version of this DeleteTagResultsItem object."""
@@ -1097,6 +1116,7 @@ class ProviderEnum(str, Enum):
1097
1116
IMS = 'ims'
1098
1117
1099
1118
1119
+
1100
1120
class DeleteTagsResult :
1101
1121
"""
1102
1122
Results of deleting unattatched tags.
@@ -1248,12 +1268,76 @@ def __ne__(self, other: 'DeleteTagsResultItem') -> bool:
1248
1268
return not self == other
1249
1269
1250
1270
1271
+ class QueryString :
1272
+ """
1273
+ A valid Global Search string.
1274
+
1275
+ :param str query_string: The Lucene-formatted query string.
1276
+ """
1277
+
1278
+ def __init__ (
1279
+ self ,
1280
+ query_string : str ,
1281
+ ) -> None :
1282
+ """
1283
+ Initialize a QueryString object.
1284
+
1285
+ :param str query_string: The Lucene-formatted query string.
1286
+ """
1287
+ self .query_string = query_string
1288
+
1289
+ @classmethod
1290
+ def from_dict (cls , _dict : Dict ) -> 'QueryString' :
1291
+ """Initialize a QueryString object from a json dictionary."""
1292
+ args = {}
1293
+ if (query_string := _dict .get ('query_string' )) is not None :
1294
+ args ['query_string' ] = query_string
1295
+ else :
1296
+ raise ValueError ('Required property \' query_string\' not present in QueryString JSON' )
1297
+ return cls (** args )
1298
+
1299
+ @classmethod
1300
+ def _from_dict (cls , _dict ):
1301
+ """Initialize a QueryString object from a json dictionary."""
1302
+ return cls .from_dict (_dict )
1303
+
1304
+ def to_dict (self ) -> Dict :
1305
+ """Return a json dictionary representing this model."""
1306
+ _dict = {}
1307
+ if hasattr (self , 'query_string' ) and self .query_string is not None :
1308
+ _dict ['query_string' ] = self .query_string
1309
+ return _dict
1310
+
1311
+ def _to_dict (self ):
1312
+ """Return a json dictionary representing this model."""
1313
+ return self .to_dict ()
1314
+
1315
+ def __str__ (self ) -> str :
1316
+ """Return a `str` version of this QueryString object."""
1317
+ return json .dumps (self .to_dict (), indent = 2 )
1318
+
1319
+ def __eq__ (self , other : 'QueryString' ) -> bool :
1320
+ """Return `true` when self and other are equal, false otherwise."""
1321
+ if not isinstance (other , self .__class__ ):
1322
+ return False
1323
+ return self .__dict__ == other .__dict__
1324
+
1325
+ def __ne__ (self , other : 'QueryString' ) -> bool :
1326
+ """Return `true` when self and other are not equal, false otherwise."""
1327
+ return not self == other
1328
+
1329
+
1251
1330
class Resource :
1252
1331
"""
1253
1332
A resource that might have tags that are attached.
1254
1333
1255
1334
: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.
1335
+ :param str resource_type: (optional) The IMS resource type of the resource. It
1336
+ can be one of SoftLayer_Virtual_DedicatedHost, SoftLayer_Hardware,
1337
+ SoftLayer_Hardware_Server, SoftLayer_Network_Application_Delivery_Controller,
1338
+ SoftLayer_Network_Vlan, SoftLayer_Network_Vlan_Firewall,
1339
+ SoftLayer_Network_Component_Firewall, SoftLayer_Network_Firewall_Module_Context,
1340
+ SoftLayer_Virtual_Guest.
1257
1341
"""
1258
1342
1259
1343
def __init__ (
@@ -1267,6 +1351,11 @@ def __init__(
1267
1351
1268
1352
:param str resource_id: The CRN or IMS ID of the resource.
1269
1353
:param str resource_type: (optional) The IMS resource type of the resource.
1354
+ It can be one of SoftLayer_Virtual_DedicatedHost, SoftLayer_Hardware,
1355
+ SoftLayer_Hardware_Server,
1356
+ SoftLayer_Network_Application_Delivery_Controller, SoftLayer_Network_Vlan,
1357
+ SoftLayer_Network_Vlan_Firewall, SoftLayer_Network_Component_Firewall,
1358
+ SoftLayer_Network_Firewall_Module_Context, SoftLayer_Virtual_Guest.
1270
1359
"""
1271
1360
self .resource_id = resource_id
1272
1361
self .resource_type = resource_type
0 commit comments