From 17117b5abdc296e5b876d938dfe584969ab4820d Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Mon, 4 Oct 2021 13:27:53 -0700 Subject: [PATCH] Rename metrics result to metrics query result (#21036) --- sdk/monitor/azure-monitor-query/CHANGELOG.md | 3 ++- sdk/monitor/azure-monitor-query/README.md | 4 ++-- .../azure/monitor/query/__init__.py | 4 ++-- .../azure/monitor/query/_metrics_query_client.py | 10 +++++----- .../azure-monitor-query/azure/monitor/query/_models.py | 2 +- .../monitor/query/aio/_metrics_query_client_async.py | 10 +++++----- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index 9e5e8a21872d..f250c47dd4e2 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -8,7 +8,7 @@ - Added `status` attribute to `LogsQueryResult`. - Added `LogsQueryStatus` Enum to describe the status of a result. - Added a new `LogsTableRow` type that represents a single row in a table. -- Items in `metrics` list in `MetricsResult` can now be accessed by metric names. +- Items in `metrics` list in `MetricsQueryResult` can now be accessed by metric names. - Added `audience` keyword to support providing credential scope when creating clients. ### Breaking Changes @@ -19,6 +19,7 @@ - `query_workspace` API now returns a union of `LogsQueryPartialResult` and `LogsQueryResult`. - `query_batch` API now returns a union of `LogsQueryPartialResult`, `LogsQueryError` and `LogsQueryResult`. - `metric_namespace` is renamed to `namespace` and is a keyword-only argument in `list_metric_definitions` API. +- `MetricsResult` is renamed to `MetricsQueryResult`. ## 1.0.0b4 (2021-09-09) diff --git a/sdk/monitor/azure-monitor-query/README.md b/sdk/monitor/azure-monitor-query/README.md index c806d89345ba..e40bacc0b17f 100644 --- a/sdk/monitor/azure-monitor-query/README.md +++ b/sdk/monitor/azure-monitor-query/README.md @@ -337,10 +337,10 @@ for metric in response.metrics: #### Handle metrics query response -The metrics query API returns a `MetricsResult` object. The `MetricsResult` object contains properties such as a list of `Metric`-typed objects, `granularity`, `namespace`, and `timespan`. The `Metric` objects list can be accessed using the `metrics` param. Each `Metric` object in this list contains a list of `TimeSeriesElement` objects. Each `TimeSeriesElement` object contains `data` and `metadata_values` properties. In visual form, the object hierarchy of the response resembles the following structure: +The metrics query API returns a `MetricsQueryResult` object. The `MetricsQueryResult` object contains properties such as a list of `Metric`-typed objects, `granularity`, `namespace`, and `timespan`. The `Metric` objects list can be accessed using the `metrics` param. Each `Metric` object in this list contains a list of `TimeSeriesElement` objects. Each `TimeSeriesElement` object contains `data` and `metadata_values` properties. In visual form, the object hierarchy of the response resembles the following structure: ``` -MetricsResult +MetricsQueryResult |---granularity |---timespan |---cost diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py index 497c0e804256..ab85c804c763 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py @@ -16,7 +16,7 @@ LogsQueryPartialResult, LogsQueryStatus, LogsTableRow, - MetricsResult, + MetricsQueryResult, LogsBatchQuery, MetricNamespace, MetricNamespaceClassification, @@ -46,7 +46,7 @@ "MetricNamespaceClassification", "MetricDefinition", "MetricUnit", - "MetricsResult", + "MetricsQueryResult", "TimeSeriesElement", "Metric", "MetricValue", diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_metrics_query_client.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_metrics_query_client.py index e730db1c7f26..31e762761c85 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_metrics_query_client.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_metrics_query_client.py @@ -15,7 +15,7 @@ MonitorQueryClient, ) -from ._models import MetricsResult, MetricDefinition, MetricNamespace +from ._models import MetricsQueryResult, MetricDefinition, MetricNamespace from ._helpers import get_metrics_authentication_policy, construct_iso8601 if TYPE_CHECKING: @@ -67,7 +67,7 @@ def __init__(self, credential, **kwargs): @distributed_trace def query_resource(self, resource_uri, metric_names, **kwargs): - # type: (str, List[str], Any) -> MetricsResult + # type: (str, List[str], Any) -> MetricsQueryResult """Lists the metric values for a resource. :param resource_uri: The identifier of the resource. @@ -104,8 +104,8 @@ def query_resource(self, resource_uri, metric_names, **kwargs): :paramtype filter: str :keyword metric_namespace: Metric namespace to query metric definitions for. :paramtype metric_namespace: str - :return: A MetricsResult object. - :rtype: ~azure.monitor.query.MetricsResult + :return: A MetricsQueryResult object. + :rtype: ~azure.monitor.query.MetricsQueryResult :raises: ~azure.core.exceptions.HttpResponseError .. admonition:: Example: @@ -130,7 +130,7 @@ def query_resource(self, resource_uri, metric_names, **kwargs): generated = self._metrics_op.list( resource_uri, connection_verify=False, **kwargs ) - return MetricsResult._from_generated( # pylint: disable=protected-access + return MetricsQueryResult._from_generated( # pylint: disable=protected-access generated ) diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py index e391eaf4e45e..f42064048c66 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -96,7 +96,7 @@ def __getitem__(self, column): return self._row[column] -class MetricsResult(object): +class MetricsQueryResult(object): """The response to a metrics query. :ivar cost: The integer value representing the cost of the query, for data case. diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py index 707272d39ac4..6751b11b6c39 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py @@ -17,7 +17,7 @@ from .._generated.aio._monitor_query_client import ( MonitorQueryClient, ) -from .._models import MetricsResult, MetricDefinition, MetricNamespace +from .._models import MetricsQueryResult, MetricDefinition, MetricNamespace from ._helpers_asyc import get_metrics_authentication_policy from .._helpers import construct_iso8601 @@ -55,7 +55,7 @@ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: @distributed_trace_async async def query_resource( self, resource_uri: str, metric_names: List[str], **kwargs: Any - ) -> MetricsResult: + ) -> MetricsQueryResult: """Lists the metric values for a resource. **Note**: Although the start_time, end_time, duration are optional parameters, it is highly @@ -95,8 +95,8 @@ async def query_resource( :paramtype filter: str :keyword metric_namespace: Metric namespace to query metric definitions for. :paramtype metric_namespace: str - :return: A MetricsResult object. - :rtype: ~azure.monitor.query.MetricsResult + :return: A MetricsQueryResult object. + :rtype: ~azure.monitor.query.MetricsQueryResult :raises: ~azure.core.exceptions.HttpResponseError """ timespan = construct_iso8601(kwargs.pop("timespan", None)) @@ -111,7 +111,7 @@ async def query_resource( generated = await self._metrics_op.list( resource_uri, connection_verify=False, **kwargs ) - return MetricsResult._from_generated( # pylint: disable=protected-access + return MetricsQueryResult._from_generated( # pylint: disable=protected-access generated )