GoogleCloudPlatform / GoogleCloudPlatform/python-docs-samples

Change snippits.py to need less altering when copy and pasted

Ouverte
#10,906 0 commentaires 0 réactions 1 personne assignée Assignée à @donmccasland Voir sur GitHub
api: monitoring priority: p3 samples type: feature request
Langage dominant
Jupyter Notebook
Étoiles
8.1k
Forks
6.7k
Merge moyen
4 j 2 h
PR mergées (30 j)
16

Description

Just opened this because in the PR default comment it asked to create an issue before creating a PR.

In short, it would just be nice to have less typing needed when copying a snippet.

```
def get_monitored_resource_descriptor(
project_id: str, resource_type_name: str
) -> monitored_resource_pb2.MonitoredResourceDescriptor:
"""Prints monitored resource description by type

Args:
project_id: Google Cloud project id
resource_type_name: a monitored resource type

Returns:
An object that describes the monitored resource
"""
# [START monitoring_get_resource]
from google.cloud import monitoring_v3

client = monitoring_v3.MetricServiceClient()
resource_path = (
f"projects/{project_id}/monitoredResourceDescriptors/{resource_type_name}"
)
descriptor = client.get_monitored_resource_descriptor(name=resource_path)
pprint.pprint(descriptor)
# [END monitoring_get_resource]
return descriptor
```

to

```
def get_monitored_resource_descriptor(
project_id: str, resource_type_name: str
) -> monitored_resource_pb2.MonitoredResourceDescriptor:
"""Prints monitored resource description by type

Args:
project_id: Google Cloud project id
resource_type_name: a monitored resource type

Returns:
An object that describes the monitored resource
"""
# [START monitoring_get_resource]
import time
from google.cloud import monitoring_v3

project_id = 'MY_PROJECT_ID'

client = monitoring_v3.MetricServiceClient()
resource_path = (
f"projects/{project_id}/monitoredResourceDescriptors/{resource_type_name}"
)
descriptor = client.get_monitored_resource_descriptor(name=resource_path)
pprint.pprint(descriptor)
# [END monitoring_get_resource]
return descriptor
```

Super minor but wanted to see if anyone else felt the same way.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.