Skip to content

Commit 37c93f8

Browse files
committed
chore: re-gen global-catalog service with latest API def
1 parent 18c081b commit 37c93f8

File tree

2 files changed

+37
-88
lines changed

2 files changed

+37
-88
lines changed

ibm_platform_services/global_catalog_v1.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,16 @@ def list_catalog_entries(self, *, account: str = None, include: str = None, q: s
151151
return response
152152

153153

154-
def create_catalog_entry(self, name: str, overview_ui: 'OverviewUI', kind: str, images: 'Image', disabled: bool, tags: List[str], provider: 'Provider', *, parent_id: str = None, parent_url: str = None, group: bool = None, metadata: 'ObjectMetaData' = None, active: bool = None, children: List['CatalogEntry'] = None, account: str = None, **kwargs) -> DetailedResponse:
154+
def create_catalog_entry(self, id: str, name: str, overview_ui: 'OverviewUI', kind: str, images: 'Image', disabled: bool, tags: List[str], provider: 'Provider', *, parent_id: str = None, group: bool = None, metadata: 'ObjectMetaData' = None, active: bool = None, account: str = None, **kwargs) -> DetailedResponse:
155155
"""
156156
Create a catalog entry.
157157
158158
The created catalog entry is restricted by default. You must have an administrator
159159
or editor role in the scope of the provided token. This API will return an ETag
160160
that can be used for standard ETag processing, except when depth query is used.
161161
162+
:param str id: Catalog entry's unique ID. It's the same across all catalog
163+
instances.
162164
:param str name: Programmatic name for this catalog entry, which must be
163165
formatted like a CRN segment. See the display name in OverviewUI for a
164166
user-readable name.
@@ -177,17 +179,12 @@ def create_catalog_entry(self, name: str, overview_ui: 'OverviewUI', kind: str,
177179
with a catalog entry.
178180
:param str parent_id: (optional) The ID of the parent catalog entry if it
179181
exists.
180-
:param str parent_url: (optional) The catalog URL of the parent catalog
181-
entry.
182182
:param bool group: (optional) Boolean value that determines whether the
183183
catalog entry is a group.
184184
:param ObjectMetaData metadata: (optional) Metadata is not returned by
185185
default, and includes specific data depending on the object **kind**.
186186
:param bool active: (optional) Boolean value that describes whether the
187187
service is active.
188-
:param List[CatalogEntry] children: (optional) The children of this catalog
189-
entry. This is read-only and ignored on put or post. It is filled in when
190-
`?depth=_value_` is used.
191188
:param str account: (optional) This changes the scope of the request
192189
regardless of the authorization header. Example scopes are `account` and
193190
`global`. `account=global` is reqired if operating with a service ID that
@@ -197,6 +194,8 @@ def create_catalog_entry(self, name: str, overview_ui: 'OverviewUI', kind: str,
197194
:rtype: DetailedResponse
198195
"""
199196

197+
if id is None:
198+
raise ValueError('id must be provided')
200199
if name is None:
201200
raise ValueError('name must be provided')
202201
if overview_ui is None:
@@ -216,8 +215,6 @@ def create_catalog_entry(self, name: str, overview_ui: 'OverviewUI', kind: str,
216215
provider = convert_model(provider)
217216
if metadata is not None:
218217
metadata = convert_model(metadata)
219-
if children is not None:
220-
children = [ convert_model(x) for x in children ]
221218
headers = {}
222219
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_catalog_entry')
223220
headers.update(sdk_headers)
@@ -227,6 +224,7 @@ def create_catalog_entry(self, name: str, overview_ui: 'OverviewUI', kind: str,
227224
}
228225

229226
data = {
227+
'id': id,
230228
'name': name,
231229
'overview_ui': overview_ui,
232230
'kind': kind,
@@ -235,11 +233,9 @@ def create_catalog_entry(self, name: str, overview_ui: 'OverviewUI', kind: str,
235233
'tags': tags,
236234
'provider': provider,
237235
'parent_id': parent_id,
238-
'parent_url': parent_url,
239236
'group': group,
240237
'metadata': metadata,
241-
'active': active,
242-
'children': children
238+
'active': active
243239
}
244240
data = {k: v for (k, v) in data.items() if v is not None}
245241
data = json.dumps(data)
@@ -441,11 +437,11 @@ def update_catalog_entry(self, id: str, name: str, overview_ui: 'OverviewUI', ki
441437
return response
442438

443439

444-
def archive_catalog_entry(self, id: str, *, account: str = None, **kwargs) -> DetailedResponse:
440+
def delete_catalog_entry(self, id: str, *, account: str = None, **kwargs) -> DetailedResponse:
445441
"""
446-
Archive a catalog entry.
442+
Delete a catalog entry.
447443
448-
Archive a catalog entry. This will archive the catalog entry for a minimum of two
444+
Delete a catalog entry. This will archive the catalog entry for a minimum of two
449445
weeks. While archived, it can be restored using the PUT restore API. After two
450446
weeks, it will be deleted and cannot be restored. You must have administrator role
451447
in the scope of the provided token to modify it. This endpoint is ETag enabled.
@@ -463,7 +459,7 @@ def archive_catalog_entry(self, id: str, *, account: str = None, **kwargs) -> De
463459
if id is None:
464460
raise ValueError('id must be provided')
465461
headers = {}
466-
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='archive_catalog_entry')
462+
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_catalog_entry')
467463
headers.update(sdk_headers)
468464

469465
params = {
@@ -1394,8 +1390,8 @@ class CatalogEntry():
13941390
"""
13951391
An entry in the global catalog.
13961392
1397-
:attr str id: (optional) Catalog entry's unique ID. It's the same across all
1398-
catalog instances.
1393+
:attr str id: Catalog entry's unique ID. It's the same across all catalog
1394+
instances.
13991395
:attr str catalog_crn: (optional) The cloud resource name of the catalog entry.
14001396
:attr str url: (optional) The catalog URL for the catalog entry.
14011397
:attr str name: Programmatic name for this catalog entry, which must be
@@ -1433,10 +1429,12 @@ class CatalogEntry():
14331429
`?depth=_value_` is used.
14341430
"""
14351431

1436-
def __init__(self, name: str, overview_ui: 'OverviewUI', kind: str, images: 'Image', disabled: bool, tags: List[str], provider: 'Provider', *, id: str = None, catalog_crn: str = None, url: str = None, parent_id: str = None, children_url: str = None, parent_url: str = None, geo_tags: List[str] = None, pricing_tags: List[str] = None, group: bool = None, created: datetime = None, updated: datetime = None, metadata: 'ObjectMetaData' = None, active: bool = None, children: List['CatalogEntry'] = None) -> None:
1432+
def __init__(self, id: str, name: str, overview_ui: 'OverviewUI', kind: str, images: 'Image', disabled: bool, tags: List[str], provider: 'Provider', *, catalog_crn: str = None, url: str = None, parent_id: str = None, children_url: str = None, parent_url: str = None, geo_tags: List[str] = None, pricing_tags: List[str] = None, group: bool = None, created: datetime = None, updated: datetime = None, metadata: 'ObjectMetaData' = None, active: bool = None, children: List['CatalogEntry'] = None) -> None:
14371433
"""
14381434
Initialize a CatalogEntry object.
14391435
1436+
:param str id: Catalog entry's unique ID. It's the same across all catalog
1437+
instances.
14401438
:param str name: Programmatic name for this catalog entry, which must be
14411439
formatted like a CRN segment. See the display name in OverviewUI for a
14421440
user-readable name.
@@ -1495,6 +1493,8 @@ def from_dict(cls, _dict: Dict) -> 'CatalogEntry':
14951493
args = {}
14961494
if 'id' in _dict:
14971495
args['id'] = _dict.get('id')
1496+
else:
1497+
raise ValueError('Required property \'id\' not present in CatalogEntry JSON')
14981498
if 'catalog_crn' in _dict:
14991499
args['catalog_crn'] = _dict.get('catalog_crn')
15001500
if 'url' in _dict:

test/unit/test_global_catalog_v1.py

Lines changed: 19 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -363,22 +363,8 @@ def test_create_catalog_entry_all_params(self):
363363
object_meta_data_model['original_name'] = 'testString'
364364
object_meta_data_model['other'] = { 'foo': 'bar' }
365365

366-
# Construct a dict representation of a CatalogEntry model
367-
catalog_entry_model = {}
368-
catalog_entry_model['name'] = 'testString'
369-
catalog_entry_model['overview_ui'] = overview_ui_model
370-
catalog_entry_model['kind'] = 'testString'
371-
catalog_entry_model['images'] = image_model
372-
catalog_entry_model['parent_id'] = 'testString'
373-
catalog_entry_model['parent_url'] = 'testString'
374-
catalog_entry_model['disabled'] = True
375-
catalog_entry_model['tags'] = ['testString']
376-
catalog_entry_model['group'] = True
377-
catalog_entry_model['provider'] = provider_model
378-
catalog_entry_model['metadata'] = object_meta_data_model
379-
catalog_entry_model['active'] = True
380-
381366
# Set up parameter values
367+
id = 'testString'
382368
name = 'testString'
383369
overview_ui = overview_ui_model
384370
kind = 'testString'
@@ -387,15 +373,14 @@ def test_create_catalog_entry_all_params(self):
387373
tags = ['testString']
388374
provider = provider_model
389375
parent_id = 'testString'
390-
parent_url = 'testString'
391376
group = True
392377
metadata = object_meta_data_model
393378
active = True
394-
children = [catalog_entry_model]
395379
account = 'testString'
396380

397381
# Invoke method
398382
response = service.create_catalog_entry(
383+
id,
399384
name,
400385
overview_ui,
401386
kind,
@@ -404,11 +389,9 @@ def test_create_catalog_entry_all_params(self):
404389
tags,
405390
provider,
406391
parent_id=parent_id,
407-
parent_url=parent_url,
408392
group=group,
409393
metadata=metadata,
410394
active=active,
411-
children=children,
412395
account=account,
413396
headers={}
414397
)
@@ -422,6 +405,7 @@ def test_create_catalog_entry_all_params(self):
422405
assert 'account={}'.format(account) in query_string
423406
# Validate body params
424407
req_body = json.loads(str(responses.calls[0].request.body, 'utf-8'))
408+
assert req_body['id'] == 'testString'
425409
assert req_body['name'] == 'testString'
426410
assert req_body['overview_ui'] == overview_ui_model
427411
assert req_body['kind'] == 'testString'
@@ -430,11 +414,9 @@ def test_create_catalog_entry_all_params(self):
430414
assert req_body['tags'] == ['testString']
431415
assert req_body['provider'] == provider_model
432416
assert req_body['parent_id'] == 'testString'
433-
assert req_body['parent_url'] == 'testString'
434417
assert req_body['group'] == True
435418
assert req_body['metadata'] == object_meta_data_model
436419
assert req_body['active'] == True
437-
assert req_body['children'] == [catalog_entry_model]
438420

439421

440422
#--------------------------------------------------------
@@ -682,22 +664,8 @@ def test_create_catalog_entry_required_params(self):
682664
object_meta_data_model['original_name'] = 'testString'
683665
object_meta_data_model['other'] = { 'foo': 'bar' }
684666

685-
# Construct a dict representation of a CatalogEntry model
686-
catalog_entry_model = {}
687-
catalog_entry_model['name'] = 'testString'
688-
catalog_entry_model['overview_ui'] = overview_ui_model
689-
catalog_entry_model['kind'] = 'testString'
690-
catalog_entry_model['images'] = image_model
691-
catalog_entry_model['parent_id'] = 'testString'
692-
catalog_entry_model['parent_url'] = 'testString'
693-
catalog_entry_model['disabled'] = True
694-
catalog_entry_model['tags'] = ['testString']
695-
catalog_entry_model['group'] = True
696-
catalog_entry_model['provider'] = provider_model
697-
catalog_entry_model['metadata'] = object_meta_data_model
698-
catalog_entry_model['active'] = True
699-
700667
# Set up parameter values
668+
id = 'testString'
701669
name = 'testString'
702670
overview_ui = overview_ui_model
703671
kind = 'testString'
@@ -706,14 +674,13 @@ def test_create_catalog_entry_required_params(self):
706674
tags = ['testString']
707675
provider = provider_model
708676
parent_id = 'testString'
709-
parent_url = 'testString'
710677
group = True
711678
metadata = object_meta_data_model
712679
active = True
713-
children = [catalog_entry_model]
714680

715681
# Invoke method
716682
response = service.create_catalog_entry(
683+
id,
717684
name,
718685
overview_ui,
719686
kind,
@@ -722,11 +689,9 @@ def test_create_catalog_entry_required_params(self):
722689
tags,
723690
provider,
724691
parent_id=parent_id,
725-
parent_url=parent_url,
726692
group=group,
727693
metadata=metadata,
728694
active=active,
729-
children=children,
730695
headers={}
731696
)
732697

@@ -735,6 +700,7 @@ def test_create_catalog_entry_required_params(self):
735700
assert response.status_code == 201
736701
# Validate body params
737702
req_body = json.loads(str(responses.calls[0].request.body, 'utf-8'))
703+
assert req_body['id'] == 'testString'
738704
assert req_body['name'] == 'testString'
739705
assert req_body['overview_ui'] == overview_ui_model
740706
assert req_body['kind'] == 'testString'
@@ -743,11 +709,9 @@ def test_create_catalog_entry_required_params(self):
743709
assert req_body['tags'] == ['testString']
744710
assert req_body['provider'] == provider_model
745711
assert req_body['parent_id'] == 'testString'
746-
assert req_body['parent_url'] == 'testString'
747712
assert req_body['group'] == True
748713
assert req_body['metadata'] == object_meta_data_model
749714
assert req_body['active'] == True
750-
assert req_body['children'] == [catalog_entry_model]
751715

752716

753717
#--------------------------------------------------------
@@ -995,22 +959,8 @@ def test_create_catalog_entry_value_error(self):
995959
object_meta_data_model['original_name'] = 'testString'
996960
object_meta_data_model['other'] = { 'foo': 'bar' }
997961

998-
# Construct a dict representation of a CatalogEntry model
999-
catalog_entry_model = {}
1000-
catalog_entry_model['name'] = 'testString'
1001-
catalog_entry_model['overview_ui'] = overview_ui_model
1002-
catalog_entry_model['kind'] = 'testString'
1003-
catalog_entry_model['images'] = image_model
1004-
catalog_entry_model['parent_id'] = 'testString'
1005-
catalog_entry_model['parent_url'] = 'testString'
1006-
catalog_entry_model['disabled'] = True
1007-
catalog_entry_model['tags'] = ['testString']
1008-
catalog_entry_model['group'] = True
1009-
catalog_entry_model['provider'] = provider_model
1010-
catalog_entry_model['metadata'] = object_meta_data_model
1011-
catalog_entry_model['active'] = True
1012-
1013962
# Set up parameter values
963+
id = 'testString'
1014964
name = 'testString'
1015965
overview_ui = overview_ui_model
1016966
kind = 'testString'
@@ -1019,14 +969,13 @@ def test_create_catalog_entry_value_error(self):
1019969
tags = ['testString']
1020970
provider = provider_model
1021971
parent_id = 'testString'
1022-
parent_url = 'testString'
1023972
group = True
1024973
metadata = object_meta_data_model
1025974
active = True
1026-
children = [catalog_entry_model]
1027975

1028976
# Pass in all but one required param and check for a ValueError
1029977
req_param_dict = {
978+
"id": id,
1030979
"name": name,
1031980
"overview_ui": overview_ui,
1032981
"kind": kind,
@@ -2088,15 +2037,15 @@ def test_update_catalog_entry_value_error(self):
20882037

20892038

20902039
#-----------------------------------------------------------------------------
2091-
# Test Class for archive_catalog_entry
2040+
# Test Class for delete_catalog_entry
20922041
#-----------------------------------------------------------------------------
2093-
class TestArchiveCatalogEntry():
2042+
class TestDeleteCatalogEntry():
20942043

20952044
#--------------------------------------------------------
2096-
# archive_catalog_entry()
2045+
# delete_catalog_entry()
20972046
#--------------------------------------------------------
20982047
@responses.activate
2099-
def test_archive_catalog_entry_all_params(self):
2048+
def test_delete_catalog_entry_all_params(self):
21002049
# Set up mock
21012050
url = base_url + '/testString'
21022051
responses.add(responses.DELETE,
@@ -2108,7 +2057,7 @@ def test_archive_catalog_entry_all_params(self):
21082057
account = 'testString'
21092058

21102059
# Invoke method
2111-
response = service.archive_catalog_entry(
2060+
response = service.delete_catalog_entry(
21122061
id,
21132062
account=account,
21142063
headers={}
@@ -2124,10 +2073,10 @@ def test_archive_catalog_entry_all_params(self):
21242073

21252074

21262075
#--------------------------------------------------------
2127-
# test_archive_catalog_entry_required_params()
2076+
# test_delete_catalog_entry_required_params()
21282077
#--------------------------------------------------------
21292078
@responses.activate
2130-
def test_archive_catalog_entry_required_params(self):
2079+
def test_delete_catalog_entry_required_params(self):
21312080
# Set up mock
21322081
url = base_url + '/testString'
21332082
responses.add(responses.DELETE,
@@ -2138,7 +2087,7 @@ def test_archive_catalog_entry_required_params(self):
21382087
id = 'testString'
21392088

21402089
# Invoke method
2141-
response = service.archive_catalog_entry(
2090+
response = service.delete_catalog_entry(
21422091
id,
21432092
headers={}
21442093
)
@@ -2149,10 +2098,10 @@ def test_archive_catalog_entry_required_params(self):
21492098

21502099

21512100
#--------------------------------------------------------
2152-
# test_archive_catalog_entry_value_error()
2101+
# test_delete_catalog_entry_value_error()
21532102
#--------------------------------------------------------
21542103
@responses.activate
2155-
def test_archive_catalog_entry_value_error(self):
2104+
def test_delete_catalog_entry_value_error(self):
21562105
# Set up mock
21572106
url = base_url + '/testString'
21582107
responses.add(responses.DELETE,
@@ -2169,7 +2118,7 @@ def test_archive_catalog_entry_value_error(self):
21692118
for param in req_param_dict.keys():
21702119
req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()}
21712120
with pytest.raises(ValueError):
2172-
service.archive_catalog_entry(**req_copy)
2121+
service.delete_catalog_entry(**req_copy)
21732122

21742123

21752124

0 commit comments

Comments
 (0)