Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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 Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

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

Mô tả

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.

Ngôn ngữ chính
Jupyter Notebook
Star
8.1k
Fork
6.7k
Merge trung bình
4 ngày 4 giờ
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của GoogleCloudPlatform/python-docs-samples

Tất cả issue của GoogleCloudPlatform/python-docs-samples

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.