Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

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

未關閉
#10,906 0 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

這個 Issue 還沒有評估資料。

描述

api: monitoring priority: p3 samples type: feature request

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.

主要語言
Jupyter Notebook
星號
8.1k
分支
6.7k
平均合併
4 天 4 小時
30 天內合併 PR
8

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

GoogleCloudPlatform/python-docs-samples 的其他 Issue

查看 GoogleCloudPlatform/python-docs-samples 的全部 Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。