GoogleCloudPlatform / GoogleCloudPlatform/python-docs-samples

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

オープン
#10,906 コメント 0 件 リアクション 0 件 担当者 1 名 @donmccasland に割り当て済み GitHub で見る
api: monitoring priority: p3 samples type: feature request
主要言語
Jupyter Notebook
スター
8.1k
フォーク
6.7k
平均マージ
4日 2時間
マージ済み PR(30日)
16

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。