Skip to content

feat(Usage Reports): add billing snapshot config service to usage reports #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions examples/test_usage_reports_v4_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,26 @@ def setup_class(cls):
global billing_month
billing_month = config.get("BILLING_MONTH")

global cos_bucket
cos_bucket = config.get("COS_BUCKET")

global cos_location
cos_location = config.get("COS_LOCATION")

global snapshot_date_from
snapshot_date_from = config.get("DATE_FROM")

global snapshot_date_to
snapshot_date_to = config.get("DATE_TO")

assert account_id is not None
assert resource_group_id is not None
assert org_id is not None
assert billing_month is not None
assert cos_bucket is not None
assert cos_location is not None
assert snapshot_date_from is not None
assert snapshot_date_to is not None

print('Setup complete.')

Expand Down Expand Up @@ -256,6 +272,124 @@ def test_get_resource_usage_org_example(self):
except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_create_reports_snapshot_config_example(self):
"""
create_reports_snapshot_config request example
"""
try:
global account_id, cos_bucket, cos_location

print('\ncreate_reports_snapshot_config() result:')
# begin-create_reports_snapshot_config

response = usage_reports_service.create_reports_snapshot_config(
account_id=account_id,
interval='daily',
cos_bucket=cos_bucket,
cos_location=cos_location,
)
snapshot_config = response.get_result()

print(json.dumps(snapshot_config, indent=2))

# end-create_reports_snapshot_config

except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_get_reports_snapshot_config_example(self):
"""
get_reports_snapshot_config request example
"""
try:
global account_id

print('\nget_reports_snapshot_config() result:')
# begin-get_reports_snapshot_config

response = usage_reports_service.get_reports_snapshot_config(
account_id=account_id,
)
snapshot_config = response.get_result()

print(json.dumps(snapshot_config, indent=2))

# end-get_reports_snapshot_config

except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_update_reports_snapshot_config_example(self):
"""
update_reports_snapshot_config request example
"""
try:
global account_id

print('\nupdate_reports_snapshot_config() result:')
# begin-update_reports_snapshot_config

response = usage_reports_service.update_reports_snapshot_config(
account_id=account_id, report_types=["account_summary", "enterprise_summary"]
)
snapshot_config = response.get_result()

print(json.dumps(snapshot_config, indent=2))

# end-update_reports_snapshot_config

except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_get_reports_snapshot_example(self):
"""
get_reports_snapshot request example
"""
try:
global account_id, billing_month, snapshot_date_from, snapshot_date_to

print('\nget_reports_snapshot() result:')
# begin-get_reports_snapshot

response = usage_reports_service.get_reports_snapshot(
account_id=account_id,
month=billing_month,
date_from=snapshot_date_from,
date_to=snapshot_date_to,
)
snapshot_list = response.get_result()

print(json.dumps(snapshot_list, indent=2))

# end-get_reports_snapshot

except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_delete_reports_snapshot_config_example(self):
"""
delete_reports_snapshot_config request example
"""
try:
global account_id

# begin-delete_reports_snapshot_config

response = usage_reports_service.delete_reports_snapshot_config(
account_id=account_id,
)

# end-delete_reports_snapshot_config
print('\ndelete_reports_snapshot_config() response status code: ', response.get_status_code())

except ApiException as e:
pytest.fail(str(e))


# endregion
##############################################################################
Expand Down
Loading