Skip to content

Commit 7a3a43b

Browse files
authored
feat(Usage Reports): add billing snapshot config service to usage reports (#214)
Signed-off-by: manu.k.m <[email protected]>
1 parent 7be93ed commit 7a3a43b

File tree

4 files changed

+2726
-1
lines changed

4 files changed

+2726
-1
lines changed

examples/test_usage_reports_v4_examples.py

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,26 @@ def setup_class(cls):
9191
global billing_month
9292
billing_month = config.get("BILLING_MONTH")
9393

94+
global cos_bucket
95+
cos_bucket = config.get("COS_BUCKET")
96+
97+
global cos_location
98+
cos_location = config.get("COS_LOCATION")
99+
100+
global snapshot_date_from
101+
snapshot_date_from = config.get("DATE_FROM")
102+
103+
global snapshot_date_to
104+
snapshot_date_to = config.get("DATE_TO")
105+
94106
assert account_id is not None
95107
assert resource_group_id is not None
96108
assert org_id is not None
97109
assert billing_month is not None
110+
assert cos_bucket is not None
111+
assert cos_location is not None
112+
assert snapshot_date_from is not None
113+
assert snapshot_date_to is not None
98114

99115
print('Setup complete.')
100116

@@ -256,6 +272,124 @@ def test_get_resource_usage_org_example(self):
256272
except ApiException as e:
257273
pytest.fail(str(e))
258274

275+
@needscredentials
276+
def test_create_reports_snapshot_config_example(self):
277+
"""
278+
create_reports_snapshot_config request example
279+
"""
280+
try:
281+
global account_id, cos_bucket, cos_location
282+
283+
print('\ncreate_reports_snapshot_config() result:')
284+
# begin-create_reports_snapshot_config
285+
286+
response = usage_reports_service.create_reports_snapshot_config(
287+
account_id=account_id,
288+
interval='daily',
289+
cos_bucket=cos_bucket,
290+
cos_location=cos_location,
291+
)
292+
snapshot_config = response.get_result()
293+
294+
print(json.dumps(snapshot_config, indent=2))
295+
296+
# end-create_reports_snapshot_config
297+
298+
except ApiException as e:
299+
pytest.fail(str(e))
300+
301+
@needscredentials
302+
def test_get_reports_snapshot_config_example(self):
303+
"""
304+
get_reports_snapshot_config request example
305+
"""
306+
try:
307+
global account_id
308+
309+
print('\nget_reports_snapshot_config() result:')
310+
# begin-get_reports_snapshot_config
311+
312+
response = usage_reports_service.get_reports_snapshot_config(
313+
account_id=account_id,
314+
)
315+
snapshot_config = response.get_result()
316+
317+
print(json.dumps(snapshot_config, indent=2))
318+
319+
# end-get_reports_snapshot_config
320+
321+
except ApiException as e:
322+
pytest.fail(str(e))
323+
324+
@needscredentials
325+
def test_update_reports_snapshot_config_example(self):
326+
"""
327+
update_reports_snapshot_config request example
328+
"""
329+
try:
330+
global account_id
331+
332+
print('\nupdate_reports_snapshot_config() result:')
333+
# begin-update_reports_snapshot_config
334+
335+
response = usage_reports_service.update_reports_snapshot_config(
336+
account_id=account_id, report_types=["account_summary", "enterprise_summary"]
337+
)
338+
snapshot_config = response.get_result()
339+
340+
print(json.dumps(snapshot_config, indent=2))
341+
342+
# end-update_reports_snapshot_config
343+
344+
except ApiException as e:
345+
pytest.fail(str(e))
346+
347+
@needscredentials
348+
def test_get_reports_snapshot_example(self):
349+
"""
350+
get_reports_snapshot request example
351+
"""
352+
try:
353+
global account_id, billing_month, snapshot_date_from, snapshot_date_to
354+
355+
print('\nget_reports_snapshot() result:')
356+
# begin-get_reports_snapshot
357+
358+
response = usage_reports_service.get_reports_snapshot(
359+
account_id=account_id,
360+
month=billing_month,
361+
date_from=snapshot_date_from,
362+
date_to=snapshot_date_to,
363+
)
364+
snapshot_list = response.get_result()
365+
366+
print(json.dumps(snapshot_list, indent=2))
367+
368+
# end-get_reports_snapshot
369+
370+
except ApiException as e:
371+
pytest.fail(str(e))
372+
373+
@needscredentials
374+
def test_delete_reports_snapshot_config_example(self):
375+
"""
376+
delete_reports_snapshot_config request example
377+
"""
378+
try:
379+
global account_id
380+
381+
# begin-delete_reports_snapshot_config
382+
383+
response = usage_reports_service.delete_reports_snapshot_config(
384+
account_id=account_id,
385+
)
386+
387+
# end-delete_reports_snapshot_config
388+
print('\ndelete_reports_snapshot_config() response status code: ', response.get_status_code())
389+
390+
except ApiException as e:
391+
pytest.fail(str(e))
392+
259393

260394
# endregion
261395
##############################################################################

0 commit comments

Comments
 (0)