Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Michael-fore opened this issue Nov 4, 2023 · 0 comments
Open

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

Michael-fore opened this issue Nov 4, 2023 · 0 comments
Assignees
Labels
api: monitoring Issues related to the Cloud Monitoring API. priority: p3 Desirable enhancement or fix. May not be included in next release. samples Issues that are directly related to samples. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@Michael-fore
Copy link

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.

@Michael-fore Michael-fore added priority: p3 Desirable enhancement or fix. May not be included in next release. triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Nov 4, 2023
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Nov 4, 2023
@leahecole leahecole added api: monitoring Issues related to the Cloud Monitoring API. and removed triage me I really want to be triaged. labels Nov 6, 2023
@leahecole leahecole assigned donmccasland and unassigned leahecole Nov 6, 2023
@Michael-fore Michael-fore changed the title Change snippits.py to need less latering when copy and pasted Change snippits.py to need less altering when copy and pasted Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: monitoring Issues related to the Cloud Monitoring API. priority: p3 Desirable enhancement or fix. May not be included in next release. samples Issues that are directly related to samples. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants