Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
Update monitoring samples to use more descriptive variable names [(#1…
Browse files Browse the repository at this point in the history
…058)](GoogleCloudPlatform/python-docs-samples#1058)

Change-Id: I648cd686a10399b7f92373fdcd48708396fd7140
  • Loading branch information
Jon Wayne Parrott authored Aug 8, 2017
1 parent 12ffc45 commit a468e06
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions samples/snippets/v3/cloud-client/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ def create_metric_descriptor():
# [END create_metric_descriptor]


def delete_metric_descriptor(descriptor):
def delete_metric_descriptor(descriptor_name):
# [START delete_metric_descriptor]
client = monitoring.Client()
descriptor = client.metric_descriptor(
descriptor
)

descriptor = client.metric_descriptor(descriptor_name)
descriptor.delete()
print('Deleted metric descriptor.')

print('Deleted metric descriptor {}.'.format(descriptor_name))
# [END delete_metric_descriptor]


Expand Down Expand Up @@ -119,17 +119,17 @@ def list_monitored_resources():
# [END list_monitored_resources]


def get_monitored_resource_descriptor(type_):
def get_monitored_resource_descriptor(resource_type_name):
# [START get_monitored_resources]
client = monitoring.Client()
print(client.fetch_resource_descriptor(type_))
print(client.fetch_resource_descriptor(resource_type_name))
# [END get_monitored_resources]


def get_metric_descriptor(type_):
def get_metric_descriptor(metric_type_name):
# [START get_metric_descriptor]
client = monitoring.Client()
print(client.fetch_metric_descriptor(type_))
print(client.fetch_metric_descriptor(metric_type_name))
# [END get_metric_descriptor]


Expand All @@ -155,7 +155,7 @@ def get_metric_descriptor(type_):
)

get_metric_descriptor_parser.add_argument(
'--metric',
'--metric-type-name',
help='The metric type of the metric descriptor to see details about.',
required=True
)
Expand All @@ -166,7 +166,7 @@ def get_metric_descriptor(type_):
)

delete_metric_descriptor_parser.add_argument(
'--metric',
'--metric-descriptor-name',
help='Metric descriptor to delete',
required=True
)
Expand All @@ -182,7 +182,7 @@ def get_metric_descriptor(type_):
)

get_resource_parser.add_argument(
'--resource',
'--resource-type-name',
help='Monitored resource to view more information about.',
required=True
)
Expand Down Expand Up @@ -219,13 +219,13 @@ def get_metric_descriptor(type_):
if args.command == 'list-metric-descriptors':
list_metric_descriptors()
if args.command == 'get-metric-descriptor':
get_metric_descriptor(args.metric)
get_metric_descriptor(args.metric_type_name)
if args.command == 'delete-metric-descriptor':
delete_metric_descriptor(args.metric)
delete_metric_descriptor(args.metric_descriptor_name)
if args.command == 'list-resources':
list_monitored_resources()
if args.command == 'get-resource':
get_monitored_resource_descriptor(args.resource)
get_monitored_resource_descriptor(args.resource_type_name)
if args.command == 'write-time-series':
write_time_series()
if args.command == 'list-time-series':
Expand Down

0 comments on commit a468e06

Please sign in to comment.