Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#10,906 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

This issue has not been assessed yet.

Description

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.

Dominant language
Jupyter Notebook
Stars
8.1k
Forks
6.7k
Avg merge
4d 4h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from GoogleCloudPlatform/python-docs-samples

All issues in GoogleCloudPlatform/python-docs-samples

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.