Skip to content

Commit 2bbb8e9

Browse files
authored
fix(Resource Manager): re-gen service after API definition updates (#23)
1 parent 1aa1108 commit 2bbb8e9

File tree

2 files changed

+190
-181
lines changed

2 files changed

+190
-181
lines changed

ibm_platform_services/resource_manager_v2.py

Lines changed: 85 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
class ResourceManagerV2(BaseService):
3737
"""The Resource Manager V2 service."""
3838

39-
DEFAULT_SERVICE_URL = 'https://resource-controller.cloud.ibm.com'
39+
DEFAULT_SERVICE_URL = 'https://resource-controller.cloud.ibm.com/v2'
4040
DEFAULT_SERVICE_NAME = 'resource_manager'
4141

4242
@classmethod
@@ -70,84 +70,14 @@ def __init__(self,
7070

7171

7272
#########################
73-
# quotaDefinition
74-
#########################
75-
76-
77-
def list_quota_definitions(self,
78-
**kwargs
79-
) -> DetailedResponse:
80-
"""
81-
Get a list of all quota definitions.
82-
83-
Get a list of all quota definitions.
84-
85-
:param dict headers: A `dict` containing the request headers
86-
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
87-
:rtype: DetailedResponse with `dict` result representing a `QuotaDefinitionList` object
88-
"""
89-
90-
headers = {}
91-
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME,
92-
service_version='V2',
93-
operation_id='list_quota_definitions')
94-
headers.update(sdk_headers)
95-
96-
if 'headers' in kwargs:
97-
headers.update(kwargs.get('headers'))
98-
99-
url = '/quota_definitions'
100-
request = self.prepare_request(method='GET',
101-
url=url,
102-
headers=headers)
103-
104-
response = self.send(request)
105-
return response
106-
107-
108-
def get_quota_definition(self,
109-
id: str,
110-
**kwargs
111-
) -> DetailedResponse:
112-
"""
113-
Get a quota definition.
114-
115-
Get a quota definition.
116-
117-
:param str id: The id of the quota.
118-
:param dict headers: A `dict` containing the request headers
119-
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
120-
:rtype: DetailedResponse with `dict` result representing a `QuotaDefinition` object
121-
"""
122-
123-
if id is None:
124-
raise ValueError('id must be provided')
125-
headers = {}
126-
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME,
127-
service_version='V2',
128-
operation_id='get_quota_definition')
129-
headers.update(sdk_headers)
130-
131-
if 'headers' in kwargs:
132-
headers.update(kwargs.get('headers'))
133-
134-
url = '/quota_definitions/{0}'.format(
135-
*self.encode_path_vars(id))
136-
request = self.prepare_request(method='GET',
137-
url=url,
138-
headers=headers)
139-
140-
response = self.send(request)
141-
return response
142-
143-
#########################
144-
# resourceGroup
73+
# Resource Group
14574
#########################
14675

14776

14877
def list_resource_groups(self,
14978
*,
15079
account_id: str = None,
80+
date: str = None,
15181
**kwargs
15282
) -> DetailedResponse:
15383
"""
@@ -157,6 +87,8 @@ def list_resource_groups(self,
15787
15888
:param str account_id: (optional) The ID of the account that contains the
15989
resource groups that you want to get.
90+
:param str date: (optional) The date would be in a format of YYYY-MM which
91+
returns resource groups exclude the deleted ones before this month.
16092
:param dict headers: A `dict` containing the request headers
16193
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
16294
:rtype: DetailedResponse with `dict` result representing a `ResourceGroupList` object
@@ -169,7 +101,8 @@ def list_resource_groups(self,
169101
headers.update(sdk_headers)
170102

171103
params = {
172-
'account_id': account_id
104+
'account_id': account_id,
105+
'date': date
173106
}
174107

175108
if 'headers' in kwargs:
@@ -351,6 +284,77 @@ def delete_resource_group(self,
351284
response = self.send(request)
352285
return response
353286

287+
#########################
288+
# Quota Definition
289+
#########################
290+
291+
292+
def list_quota_definitions(self,
293+
**kwargs
294+
) -> DetailedResponse:
295+
"""
296+
List quota definitions.
297+
298+
Get a list of all quota definitions.
299+
300+
:param dict headers: A `dict` containing the request headers
301+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
302+
:rtype: DetailedResponse with `dict` result representing a `QuotaDefinitionList` object
303+
"""
304+
305+
headers = {}
306+
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME,
307+
service_version='V2',
308+
operation_id='list_quota_definitions')
309+
headers.update(sdk_headers)
310+
311+
if 'headers' in kwargs:
312+
headers.update(kwargs.get('headers'))
313+
314+
url = '/quota_definitions'
315+
request = self.prepare_request(method='GET',
316+
url=url,
317+
headers=headers)
318+
319+
response = self.send(request)
320+
return response
321+
322+
323+
def get_quota_definition(self,
324+
id: str,
325+
**kwargs
326+
) -> DetailedResponse:
327+
"""
328+
Get a quota definition.
329+
330+
Get a a quota definition.
331+
332+
:param str id: The id of the quota.
333+
:param dict headers: A `dict` containing the request headers
334+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
335+
:rtype: DetailedResponse with `dict` result representing a `QuotaDefinition` object
336+
"""
337+
338+
if id is None:
339+
raise ValueError('id must be provided')
340+
headers = {}
341+
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME,
342+
service_version='V2',
343+
operation_id='get_quota_definition')
344+
headers.update(sdk_headers)
345+
346+
if 'headers' in kwargs:
347+
headers.update(kwargs.get('headers'))
348+
349+
url = '/quota_definitions/{0}'.format(
350+
*self.encode_path_vars(id))
351+
request = self.prepare_request(method='GET',
352+
url=url,
353+
headers=headers)
354+
355+
response = self.send(request)
356+
return response
357+
354358

355359
##############################################################################
356360
# Models
@@ -373,7 +377,8 @@ class QuotaDefinition():
373377
:attr str instance_memory: (optional) The total memory of app instance.
374378
:attr str total_app_memory: (optional) The total app memory capacity.
375379
:attr float vsi_limit: (optional) The VSI limit.
376-
:attr ResourceQuota resource_quotas: (optional) A resource quota.
380+
:attr List[ResourceQuota] resource_quotas: (optional) The resource quotas
381+
associated with a quota definition.
377382
:attr datetime created_at: (optional) The date when the quota was initially
378383
created.
379384
:attr datetime updated_at: (optional) The date when the quota was last updated.
@@ -391,7 +396,7 @@ def __init__(self,
391396
instance_memory: str = None,
392397
total_app_memory: str = None,
393398
vsi_limit: float = None,
394-
resource_quotas: 'ResourceQuota' = None,
399+
resource_quotas: List['ResourceQuota'] = None,
395400
created_at: datetime = None,
396401
updated_at: datetime = None) -> None:
397402
"""
@@ -410,7 +415,8 @@ def __init__(self,
410415
:param str instance_memory: (optional) The total memory of app instance.
411416
:param str total_app_memory: (optional) The total app memory capacity.
412417
:param float vsi_limit: (optional) The VSI limit.
413-
:param ResourceQuota resource_quotas: (optional) A resource quota.
418+
:param List[ResourceQuota] resource_quotas: (optional) The resource quotas
419+
associated with a quota definition.
414420
:param datetime created_at: (optional) The date when the quota was
415421
initially created.
416422
:param datetime updated_at: (optional) The date when the quota was last
@@ -455,7 +461,7 @@ def from_dict(cls, _dict: Dict) -> 'QuotaDefinition':
455461
if 'vsi_limit' in _dict:
456462
args['vsi_limit'] = _dict.get('vsi_limit')
457463
if 'resource_quotas' in _dict:
458-
args['resource_quotas'] = ResourceQuota.from_dict(_dict.get('resource_quotas'))
464+
args['resource_quotas'] = [ResourceQuota.from_dict(x) for x in _dict.get('resource_quotas')]
459465
if 'created_at' in _dict:
460466
args['created_at'] = string_to_datetime(_dict.get('created_at'))
461467
if 'updated_at' in _dict:
@@ -491,7 +497,7 @@ def to_dict(self) -> Dict:
491497
if hasattr(self, 'vsi_limit') and self.vsi_limit is not None:
492498
_dict['vsi_limit'] = self.vsi_limit
493499
if hasattr(self, 'resource_quotas') and self.resource_quotas is not None:
494-
_dict['resource_quotas'] = self.resource_quotas.to_dict()
500+
_dict['resource_quotas'] = [x.to_dict() for x in self.resource_quotas]
495501
if hasattr(self, 'created_at') and self.created_at is not None:
496502
_dict['created_at'] = datetime_to_string(self.created_at)
497503
if hasattr(self, 'updated_at') and self.updated_at is not None:

0 commit comments

Comments
 (0)