diff --git a/google/cloud/monitoring_v3/services/metric_service/client.py b/google/cloud/monitoring_v3/services/metric_service/client.py index 78b942d8..8a31011e 100644 --- a/google/cloud/monitoring_v3/services/metric_service/client.py +++ b/google/cloud/monitoring_v3/services/metric_service/client.py @@ -166,14 +166,14 @@ def transport(self) -> MetricServiceTransport: return self._transport '''@staticmethod - def metric_descriptor_path(project: str,) -> str: + def metric_descriptor_path(project: str,metric_descriptor: str,) -> str: """Returns a fully-qualified metric_descriptor string.""" - return "projects/{project}/metricDescriptors/{metric_descriptor=**}".format(project=project, ) + return "projects/{project}/metricDescriptors/{metric_descriptor=**}".format(project=project, metric_descriptor=metric_descriptor, ) @staticmethod def parse_metric_descriptor_path(path: str) -> Dict[str,str]: """Parses a metric_descriptor path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/metricDescriptors/{metric_descriptor=**}$", path) + m = re.match(r"^projects/(?P.+?)/metricDescriptors/(?P.+?)$", path) return m.groupdict() if m else {}''' @staticmethod diff --git a/tests/unit/gapic/monitoring_v3/test_metric_service.py b/tests/unit/gapic/monitoring_v3/test_metric_service.py index 6bdd95b0..744cd166 100644 --- a/tests/unit/gapic/monitoring_v3/test_metric_service.py +++ b/tests/unit/gapic/monitoring_v3/test_metric_service.py @@ -3548,14 +3548,16 @@ def test_metric_service_transport_channel_mtls_with_adc(transport_class): """def test_metric_descriptor_path(): project = "squid" - expected = "projects/{project}/metricDescriptors/{metric_descriptor=**}".format(project=project, ) - actual = MetricServiceClient.metric_descriptor_path(project) + metric_descriptor = "clam" + expected = "projects/{project}/metricDescriptors/{metric_descriptor=**}".format(project=project, metric_descriptor=metric_descriptor, ) + actual = MetricServiceClient.metric_descriptor_path(project, metric_descriptor) assert expected == actual def test_parse_metric_descriptor_path(): expected = { - "project": "clam", + "project": "whelk", + "metric_descriptor": "octopus", } path = MetricServiceClient.metric_descriptor_path(**expected) @@ -3567,8 +3569,8 @@ def test_parse_metric_descriptor_path(): def test_monitored_resource_descriptor_path(): - project = "whelk" - monitored_resource_descriptor = "octopus" + project = "oyster" + monitored_resource_descriptor = "nudibranch" expected = "projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}".format( project=project, monitored_resource_descriptor=monitored_resource_descriptor, ) @@ -3580,8 +3582,8 @@ def test_monitored_resource_descriptor_path(): def test_parse_monitored_resource_descriptor_path(): expected = { - "project": "oyster", - "monitored_resource_descriptor": "nudibranch", + "project": "cuttlefish", + "monitored_resource_descriptor": "mussel", } path = MetricServiceClient.monitored_resource_descriptor_path(**expected) @@ -3591,8 +3593,8 @@ def test_parse_monitored_resource_descriptor_path(): def test_time_series_path(): - project = "cuttlefish" - time_series = "mussel" + project = "winkle" + time_series = "nautilus" expected = "projects/{project}/timeSeries/{time_series}".format( project=project, time_series=time_series, ) @@ -3602,8 +3604,8 @@ def test_time_series_path(): def test_parse_time_series_path(): expected = { - "project": "winkle", - "time_series": "nautilus", + "project": "scallop", + "time_series": "abalone", } path = MetricServiceClient.time_series_path(**expected) @@ -3613,7 +3615,7 @@ def test_parse_time_series_path(): def test_common_billing_account_path(): - billing_account = "scallop" + billing_account = "squid" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3623,7 +3625,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "abalone", + "billing_account": "clam", } path = MetricServiceClient.common_billing_account_path(**expected) @@ -3633,7 +3635,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "squid" + folder = "whelk" expected = "folders/{folder}".format(folder=folder,) actual = MetricServiceClient.common_folder_path(folder) assert expected == actual @@ -3641,7 +3643,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "clam", + "folder": "octopus", } path = MetricServiceClient.common_folder_path(**expected) @@ -3651,7 +3653,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "whelk" + organization = "oyster" expected = "organizations/{organization}".format(organization=organization,) actual = MetricServiceClient.common_organization_path(organization) assert expected == actual @@ -3659,7 +3661,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "octopus", + "organization": "nudibranch", } path = MetricServiceClient.common_organization_path(**expected) @@ -3669,7 +3671,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "oyster" + project = "cuttlefish" expected = "projects/{project}".format(project=project,) actual = MetricServiceClient.common_project_path(project) assert expected == actual @@ -3677,7 +3679,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "nudibranch", + "project": "mussel", } path = MetricServiceClient.common_project_path(**expected) @@ -3687,8 +3689,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "cuttlefish" - location = "mussel" + project = "winkle" + location = "nautilus" expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -3698,8 +3700,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "winkle", - "location": "nautilus", + "project": "scallop", + "location": "abalone", } path = MetricServiceClient.common_location_path(**expected)