Skip to content

Commit 01f02ac

Browse files
fix(Global Search/Tagging): re-gen services with latest API definition (#246)
Signed-off-by: Fabrizio Leoni <[email protected]>
1 parent 7ea35cb commit 01f02ac

File tree

4 files changed

+80
-64
lines changed

4 files changed

+80
-64
lines changed

ibm_platform_services/global_search_v2.py

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

3-
# (C) Copyright IBM Corp. 2023.
3+
# (C) Copyright IBM Corp. 2024.
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.82.1-2082d402-20231115-195014
17+
# IBM OpenAPI SDK Code Generator Version: 3.86.0-bc6f14b3-20240221-193958
1818

1919
"""
2020
Search for resources with the global and shared resource properties repository that is
@@ -118,15 +118,19 @@ def search(
118118
You must use `/v3/resources/search` when you need to fetch more than `10000`
119119
resource items. On the first call, the operation returns a live cursor on the data
120120
that you must use on all the subsequent calls to get the next batch of results
121-
until you get the empty result set. By default, the fields that are returned for
122-
every resource are "crn", "name", "family", "type", and "account_id". You can
123-
specify the subset of the fields you want in your request.
121+
until you get the empty result set.
122+
By default, the fields that are returned for every resource are `crn`, `name`,
123+
`family`, `type`, and `account_id`. You can specify the subset of the fields you
124+
want in your request using the `fields` request body attribute. Set `"fields":
125+
["*"]` to discover the set of fields which are available to request.
124126
125127
:param str query: (optional) The Lucene-formatted query string. Default to
126128
'*' if not set.
127129
:param List[str] fields: (optional) The list of the fields returned by the
128130
search. By default, the returned fields are the `account_id`, `name`,
129-
`type`, `family`, and `crn`. For all queries, `crn` is always returned.
131+
`type`, `family`, and `crn`. For all queries, `crn` is always returned. You
132+
may set `"fields": ["*"]` to discover the set of fields available to
133+
request.
130134
:param str search_cursor: (optional) An opaque cursor that is returned on
131135
each call and that must be set on the subsequent call to get the next batch
132136
of items. If the search returns no items, then the search_cursor is not
@@ -327,8 +331,8 @@ def __init__(
327331
def from_dict(cls, _dict: Dict) -> 'ResultItem':
328332
"""Initialize a ResultItem object from a json dictionary."""
329333
args = {}
330-
if 'crn' in _dict:
331-
args['crn'] = _dict.get('crn')
334+
if (crn := _dict.get('crn')) is not None:
335+
args['crn'] = crn
332336
else:
333337
raise ValueError('Required property \'crn\' not present in ResultItem JSON')
334338
args.update({k: v for (k, v) in _dict.items() if k not in cls._properties})
@@ -392,8 +396,10 @@ class ScanResult:
392396
the first one.
393397
:param int limit: Value of the limit parameter specified by the user.
394398
:param List[ResultItem] items: The array of results. Each item represents a
395-
resource. An empty array signals the end of the result set, which means there
396-
are no more results to fetch.
399+
resource. For each resource, the requested `fields` are returned. If you did not
400+
set the `fields` request body parameter, then the `account_id`, `name`, `type`,
401+
`family`, and `crn` are returned. An empty array signals the end of the result
402+
set, which means there are no more results to fetch.
397403
"""
398404

399405
def __init__(
@@ -408,8 +414,10 @@ def __init__(
408414
409415
:param int limit: Value of the limit parameter specified by the user.
410416
:param List[ResultItem] items: The array of results. Each item represents a
411-
resource. An empty array signals the end of the result set, which means
412-
there are no more results to fetch.
417+
resource. For each resource, the requested `fields` are returned. If you
418+
did not set the `fields` request body parameter, then the `account_id`,
419+
`name`, `type`, `family`, and `crn` are returned. An empty array signals
420+
the end of the result set, which means there are no more results to fetch.
413421
:param str search_cursor: (optional) The search cursor to use on all calls
414422
after the first one.
415423
"""
@@ -421,14 +429,14 @@ def __init__(
421429
def from_dict(cls, _dict: Dict) -> 'ScanResult':
422430
"""Initialize a ScanResult object from a json dictionary."""
423431
args = {}
424-
if 'search_cursor' in _dict:
425-
args['search_cursor'] = _dict.get('search_cursor')
426-
if 'limit' in _dict:
427-
args['limit'] = _dict.get('limit')
432+
if (search_cursor := _dict.get('search_cursor')) is not None:
433+
args['search_cursor'] = search_cursor
434+
if (limit := _dict.get('limit')) is not None:
435+
args['limit'] = limit
428436
else:
429437
raise ValueError('Required property \'limit\' not present in ScanResult JSON')
430-
if 'items' in _dict:
431-
args['items'] = [ResultItem.from_dict(v) for v in _dict.get('items')]
438+
if (items := _dict.get('items')) is not None:
439+
args['items'] = [ResultItem.from_dict(v) for v in items]
432440
else:
433441
raise ValueError('Required property \'items\' not present in ScanResult JSON')
434442
return cls(**args)

ibm_platform_services/global_tagging_v1.py

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

3-
# (C) Copyright IBM Corp. 2023.
3+
# (C) Copyright IBM Corp. 2024.
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.82.1-2082d402-20231115-195014
17+
# IBM OpenAPI SDK Code Generator Version: 3.86.0-bc6f14b3-20240221-193958
1818

1919
"""
2020
Manage your tags with the Tagging API in IBM Cloud. You can attach, detach, delete, or
@@ -480,6 +480,7 @@ def attach_tag(
480480
transaction_id: Optional[str] = None,
481481
account_id: Optional[str] = None,
482482
tag_type: Optional[str] = None,
483+
replace: Optional[bool] = None,
483484
**kwargs,
484485
) -> DetailedResponse:
485486
"""
@@ -519,6 +520,9 @@ def attach_tag(
519520
:param str tag_type: (optional) The type of the tag. Supported values are
520521
`user`, `service` and `access`. `service` and `access` are not supported
521522
for IMS resources.
523+
:param bool replace: (optional) Flag to request replacement of all attached
524+
tags. Set 'true' if you want to replace all the list of tags attached to
525+
the resource. Default value is false.
522526
:param dict headers: A `dict` containing the request headers
523527
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
524528
:rtype: DetailedResponse with `dict` result representing a `TagResults` object
@@ -542,6 +546,7 @@ def attach_tag(
542546
params = {
543547
'account_id': account_id,
544548
'tag_type': tag_type,
549+
'replace': replace,
545550
}
546551

547552
data = {
@@ -831,8 +836,8 @@ def __init__(
831836
def from_dict(cls, _dict: Dict) -> 'CreateTagResults':
832837
"""Initialize a CreateTagResults object from a json dictionary."""
833838
args = {}
834-
if 'results' in _dict:
835-
args['results'] = [CreateTagResultsResultsItem.from_dict(v) for v in _dict.get('results')]
839+
if (results := _dict.get('results')) is not None:
840+
args['results'] = [CreateTagResultsResultsItem.from_dict(v) for v in results]
836841
return cls(**args)
837842

838843
@classmethod
@@ -901,10 +906,10 @@ def __init__(
901906
def from_dict(cls, _dict: Dict) -> 'CreateTagResultsResultsItem':
902907
"""Initialize a CreateTagResultsResultsItem object from a json dictionary."""
903908
args = {}
904-
if 'tag_name' in _dict:
905-
args['tag_name'] = _dict.get('tag_name')
906-
if 'is_error' in _dict:
907-
args['is_error'] = _dict.get('is_error')
909+
if (tag_name := _dict.get('tag_name')) is not None:
910+
args['tag_name'] = tag_name
911+
if (is_error := _dict.get('is_error')) is not None:
912+
args['is_error'] = is_error
908913
return cls(**args)
909914

910915
@classmethod
@@ -965,8 +970,8 @@ def __init__(
965970
def from_dict(cls, _dict: Dict) -> 'DeleteTagResults':
966971
"""Initialize a DeleteTagResults object from a json dictionary."""
967972
args = {}
968-
if 'results' in _dict:
969-
args['results'] = [DeleteTagResultsItem.from_dict(v) for v in _dict.get('results')]
973+
if (results := _dict.get('results')) is not None:
974+
args['results'] = [DeleteTagResultsItem.from_dict(v) for v in results]
970975
return cls(**args)
971976

972977
@classmethod
@@ -1042,10 +1047,10 @@ def __init__(
10421047
def from_dict(cls, _dict: Dict) -> 'DeleteTagResultsItem':
10431048
"""Initialize a DeleteTagResultsItem object from a json dictionary."""
10441049
args = {}
1045-
if 'provider' in _dict:
1046-
args['provider'] = _dict.get('provider')
1047-
if 'is_error' in _dict:
1048-
args['is_error'] = _dict.get('is_error')
1050+
if (provider := _dict.get('provider')) is not None:
1051+
args['provider'] = provider
1052+
if (is_error := _dict.get('is_error')) is not None:
1053+
args['is_error'] = is_error
10491054
args.update({k: v for (k, v) in _dict.items() if k not in cls._properties})
10501055
return cls(**args)
10511056

@@ -1145,12 +1150,12 @@ def __init__(
11451150
def from_dict(cls, _dict: Dict) -> 'DeleteTagsResult':
11461151
"""Initialize a DeleteTagsResult object from a json dictionary."""
11471152
args = {}
1148-
if 'total_count' in _dict:
1149-
args['total_count'] = _dict.get('total_count')
1150-
if 'errors' in _dict:
1151-
args['errors'] = _dict.get('errors')
1152-
if 'items' in _dict:
1153-
args['items'] = [DeleteTagsResultItem.from_dict(v) for v in _dict.get('items')]
1153+
if (total_count := _dict.get('total_count')) is not None:
1154+
args['total_count'] = total_count
1155+
if (errors := _dict.get('errors')) is not None:
1156+
args['errors'] = errors
1157+
if (items := _dict.get('items')) is not None:
1158+
args['items'] = [DeleteTagsResultItem.from_dict(v) for v in items]
11541159
return cls(**args)
11551160

11561161
@classmethod
@@ -1221,10 +1226,10 @@ def __init__(
12211226
def from_dict(cls, _dict: Dict) -> 'DeleteTagsResultItem':
12221227
"""Initialize a DeleteTagsResultItem object from a json dictionary."""
12231228
args = {}
1224-
if 'tag_name' in _dict:
1225-
args['tag_name'] = _dict.get('tag_name')
1226-
if 'is_error' in _dict:
1227-
args['is_error'] = _dict.get('is_error')
1229+
if (tag_name := _dict.get('tag_name')) is not None:
1230+
args['tag_name'] = tag_name
1231+
if (is_error := _dict.get('is_error')) is not None:
1232+
args['is_error'] = is_error
12281233
return cls(**args)
12291234

12301235
@classmethod
@@ -1287,12 +1292,12 @@ def __init__(
12871292
def from_dict(cls, _dict: Dict) -> 'Resource':
12881293
"""Initialize a Resource object from a json dictionary."""
12891294
args = {}
1290-
if 'resource_id' in _dict:
1291-
args['resource_id'] = _dict.get('resource_id')
1295+
if (resource_id := _dict.get('resource_id')) is not None:
1296+
args['resource_id'] = resource_id
12921297
else:
12931298
raise ValueError('Required property \'resource_id\' not present in Resource JSON')
1294-
if 'resource_type' in _dict:
1295-
args['resource_type'] = _dict.get('resource_type')
1299+
if (resource_type := _dict.get('resource_type')) is not None:
1300+
args['resource_type'] = resource_type
12961301
return cls(**args)
12971302

12981303
@classmethod
@@ -1350,8 +1355,8 @@ def __init__(
13501355
def from_dict(cls, _dict: Dict) -> 'Tag':
13511356
"""Initialize a Tag object from a json dictionary."""
13521357
args = {}
1353-
if 'name' in _dict:
1354-
args['name'] = _dict.get('name')
1358+
if (name := _dict.get('name')) is not None:
1359+
args['name'] = name
13551360
else:
13561361
raise ValueError('Required property \'name\' not present in Tag JSON')
13571362
return cls(**args)
@@ -1424,14 +1429,14 @@ def __init__(
14241429
def from_dict(cls, _dict: Dict) -> 'TagList':
14251430
"""Initialize a TagList object from a json dictionary."""
14261431
args = {}
1427-
if 'total_count' in _dict:
1428-
args['total_count'] = _dict.get('total_count')
1429-
if 'offset' in _dict:
1430-
args['offset'] = _dict.get('offset')
1431-
if 'limit' in _dict:
1432-
args['limit'] = _dict.get('limit')
1433-
if 'items' in _dict:
1434-
args['items'] = [Tag.from_dict(v) for v in _dict.get('items')]
1432+
if (total_count := _dict.get('total_count')) is not None:
1433+
args['total_count'] = total_count
1434+
if (offset := _dict.get('offset')) is not None:
1435+
args['offset'] = offset
1436+
if (limit := _dict.get('limit')) is not None:
1437+
args['limit'] = limit
1438+
if (items := _dict.get('items')) is not None:
1439+
args['items'] = [Tag.from_dict(v) for v in items]
14351440
return cls(**args)
14361441

14371442
@classmethod
@@ -1502,8 +1507,8 @@ def __init__(
15021507
def from_dict(cls, _dict: Dict) -> 'TagResults':
15031508
"""Initialize a TagResults object from a json dictionary."""
15041509
args = {}
1505-
if 'results' in _dict:
1506-
args['results'] = [TagResultsItem.from_dict(v) for v in _dict.get('results')]
1510+
if (results := _dict.get('results')) is not None:
1511+
args['results'] = [TagResultsItem.from_dict(v) for v in results]
15071512
return cls(**args)
15081513

15091514
@classmethod
@@ -1572,12 +1577,12 @@ def __init__(
15721577
def from_dict(cls, _dict: Dict) -> 'TagResultsItem':
15731578
"""Initialize a TagResultsItem object from a json dictionary."""
15741579
args = {}
1575-
if 'resource_id' in _dict:
1576-
args['resource_id'] = _dict.get('resource_id')
1580+
if (resource_id := _dict.get('resource_id')) is not None:
1581+
args['resource_id'] = resource_id
15771582
else:
15781583
raise ValueError('Required property \'resource_id\' not present in TagResultsItem JSON')
1579-
if 'is_error' in _dict:
1580-
args['is_error'] = _dict.get('is_error')
1584+
if (is_error := _dict.get('is_error')) is not None:
1585+
args['is_error'] = is_error
15811586
return cls(**args)
15821587

15831588
@classmethod

test/unit/test_global_search_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# (C) Copyright IBM Corp. 2023.
2+
# (C) Copyright IBM Corp. 2024.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

test/unit/test_global_tagging_v1.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# (C) Copyright IBM Corp. 2023.
2+
# (C) Copyright IBM Corp. 2024.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -611,6 +611,7 @@ def test_attach_tag_all_params(self):
611611
transaction_id = 'testString'
612612
account_id = 'testString'
613613
tag_type = 'user'
614+
replace = False
614615

615616
# Invoke method
616617
response = _service.attach_tag(
@@ -622,6 +623,7 @@ def test_attach_tag_all_params(self):
622623
transaction_id=transaction_id,
623624
account_id=account_id,
624625
tag_type=tag_type,
626+
replace=replace,
625627
headers={},
626628
)
627629

@@ -633,6 +635,7 @@ def test_attach_tag_all_params(self):
633635
query_string = urllib.parse.unquote_plus(query_string)
634636
assert 'account_id={}'.format(account_id) in query_string
635637
assert 'tag_type={}'.format(tag_type) in query_string
638+
assert 'replace={}'.format('true' if replace else 'false') in query_string
636639
# Validate body params
637640
req_body = json.loads(str(responses.calls[0].request.body, 'utf-8'))
638641
assert req_body['resources'] == [resource_model]

0 commit comments

Comments
 (0)