GoogleCloudPlatform / GoogleCloudPlatform/python-docs-samples

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

Đang mở
#10,906 0 bình luận 0 reaction 1 người được giao Được giao cho @donmccasland Xem trên GitHub
api: monitoring priority: p3 samples type: feature request
Ngôn ngữ chính
Jupyter Notebook
Star
8.1k
Fork
6.7k
Merge trung bình
4 ngày 2 giờ
Pull request đã merge (30 ngày)
16

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.