Skip to content
This repository was archived by the owner on Dec 31, 2023. It is now read-only.
4 changes: 2 additions & 2 deletions samples/snippets/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
# to use your own Cloud project.
'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
# 'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
# If you need to use a specific version of pip,
# change pip_version_override to the string representation
# of the version number, for example, "20.2.4"
Expand Down
24 changes: 12 additions & 12 deletions samples/snippets/sample_default_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
def set_usage_export_bucket(project_id: str, bucket_name: str,
report_name_prefix: str = "") -> None:
"""
Set Compute Engine usage export bucket for the Cloud Project.
This sample presents how to interpret default value for the name prefix
parameter.
Set Compute Engine usage export bucket for the Cloud project.
This sample presents how to interpret the default value for the
report name prefix parameter.

Args:
project_id: project ID or project number of the project to update.
bucket_name: Google Cloud Storage Bucket used to store Compute Engine
bucket_name: Google Cloud Storage bucket used to store Compute Engine
usage reports. An existing Google Cloud Storage bucket is required.
report_name_prefix: Report Name Prefix which defaults to an empty string
report_name_prefix: Prefix of the usage report name which defaults to an empty string
to showcase default values behaviour.
"""
usage_export_location = compute_v1.UsageExportLocation(
Expand All @@ -48,10 +48,10 @@ def set_usage_export_bucket(project_id: str, bucket_name: str,
)

if not report_name_prefix:
# Sending an empty value for report_name_prefix will result in the
# next usage report generated to have the default prefix value
# Sending an empty value for report_name_prefix results in the
# next usage report being generated with the default prefix value
# "usage_gce". (ref: https://cloud.google.com/compute/docs/reference/rest/v1/projects/setUsageExportBucket)
print("Setting report_name_prefix to empty value will cause the report "
print("Setting report_name_prefix to empty value causes the report "
"to have the default prefix of `usage_gce`.")

projects_client = compute_v1.ProjectsClient()
Expand All @@ -66,7 +66,7 @@ def set_usage_export_bucket(project_id: str, bucket_name: str,
# [START compute_usage_report_get]
def get_usage_export_bucket(project_id: str) -> compute_v1.UsageExportLocation:
"""
Retrieve Compute Engine usage export bucket for the Cloud Project.
Retrieve Compute Engine usage export bucket for the Cloud project.
Replaces the empty value returned by the API with the default value used
to generate report file names.

Expand All @@ -82,13 +82,13 @@ def get_usage_export_bucket(project_id: str) -> compute_v1.UsageExportLocation:
uel = project_data.usage_export_location

if not uel.bucket_name:
# The Usage Reports are disabled.
# The usage reports are disabled.
return uel

if not uel.report_name_prefix:
# Although the server sent the empty value, the next usage report
# Although the server sent the empty string value, the next usage report
# generated with these settings still has the default prefix value
# "usage_gce". (ref: https://cloud.google.com/compute/docs/reference/rest/v1/projects/get)
# "usage_gce". (see https://cloud.google.com/compute/docs/reference/rest/v1/projects/get)
print('Report name prefix not set, replacing with default value of '
'`usage_gce`.')
uel.report_name_prefix = 'usage_gce'
Expand Down