From e2104dc9f6006dcfe1aa98d3b85b126ed51f6a22 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Sun, 22 Aug 2021 15:47:58 -0700 Subject: [PATCH 1/8] time stamp --- sdk/monitor/azure-monitor-query/CHANGELOG.md | 1 + .../azure-monitor-query/azure/monitor/query/_models.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index c5cbf831efbe..5492ce08c723 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -22,6 +22,7 @@ - `LogsQueryResult` now returns `datetime` objects for a time values. - `LogsBatchQuery` doesn't accept a `request_id` anymore. - `MetricsMetadataValues` is removed. A dictionary is used instead. +- `time_stamp` is renamed to `timestamp` in `MetricValue` type. ### Bugs Fixed 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 49264f9ac651..537184c963d6 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -401,8 +401,8 @@ class MetricValue(object): All required parameters must be populated in order to send to Azure. - :ivar time_stamp: Required. The timestamp for the metric value in ISO 8601 format. - :vartype time_stamp: ~datetime.datetime + :ivar timestamp: Required. The timestamp for the metric value in ISO 8601 format. + :vartype timestamp: ~datetime.datetime :ivar average: The average value in the time range. :vartype average: float :ivar minimum: The least value in the time range. @@ -420,7 +420,7 @@ def __init__( **kwargs ): # type: (Any) -> None - self.time_stamp = kwargs['time_stamp'] + self.timestamp = kwargs['timestamp'] self.average = kwargs.get('average', None) self.minimum = kwargs.get('minimum', None) self.maximum = kwargs.get('maximum', None) @@ -432,7 +432,7 @@ def _from_generated(cls, generated): if not generated: return cls() return cls( - time_stamp=generated.time_stamp, + timestamp=generated.time_stamp, average=generated.average, minimum=generated.minimum, maximum=generated.maximum, From d33619d7a09801a166b00443e44e4c6462fd113d Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Mon, 23 Aug 2021 08:07:13 -0700 Subject: [PATCH 2/8] Rename AggragationType to MetricAggregationType --- sdk/monitor/azure-monitor-query/CHANGELOG.md | 1 + sdk/monitor/azure-monitor-query/README.md | 4 ++-- .../azure-monitor-query/azure/monitor/query/__init__.py | 4 ++-- .../azure/monitor/query/_metrics_query_client.py | 2 +- .../azure-monitor-query/azure/monitor/query/_models.py | 6 +++--- .../azure/monitor/query/aio/_metrics_query_client_async.py | 2 +- .../samples/sample_metrics_query_client.py | 4 ++-- .../tests/async/test_metrics_client_async.py | 6 +++--- .../tests/perfstress_tests/metric_query.py | 4 ++-- .../azure-monitor-query/tests/test_metrics_client.py | 6 +++--- 10 files changed, 20 insertions(+), 19 deletions(-) diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index 5492ce08c723..7eedbd2eed37 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -23,6 +23,7 @@ - `LogsBatchQuery` doesn't accept a `request_id` anymore. - `MetricsMetadataValues` is removed. A dictionary is used instead. - `time_stamp` is renamed to `timestamp` in `MetricValue` type. +- `AggregationType` is renamed to `MetricAggregationType`. ### Bugs Fixed diff --git a/sdk/monitor/azure-monitor-query/README.md b/sdk/monitor/azure-monitor-query/README.md index a87aa1ae263d..c2a15edb6929 100644 --- a/sdk/monitor/azure-monitor-query/README.md +++ b/sdk/monitor/azure-monitor-query/README.md @@ -313,7 +313,7 @@ MetricsResult ```python import os from datetime import datetime, timedelta -from azure.monitor.query import MetricsQueryClient, AggregationType +from azure.monitor.query import MetricsQueryClient, MetricAggregationType from azure.identity import DefaultAzureCredential credential = DefaultAzureCredential() @@ -323,7 +323,7 @@ metrics_uri = os.environ['METRICS_RESOURCE_URI'] response = client.query( metrics_uri, metric_names=["MatchedEventCount"], - aggregations=[AggregationType.COUNT] + aggregations=[MetricAggregationType.COUNT] ) for metric in response.metrics: 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 13d5a58a442f..d2e37e5d82e0 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py @@ -8,7 +8,7 @@ from ._metrics_query_client import MetricsQueryClient from ._models import ( - AggregationType, + MetricAggregationType, LogsBatchQueryResult, LogsQueryResult, LogsQueryResultTable, @@ -27,7 +27,7 @@ from ._version import VERSION __all__ = [ - "AggregationType", + "MetricAggregationType", "LogsQueryClient", "LogsBatchQueryResult", "LogsBatchResultError", 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 cc3d69571b4b..7428ee30191e 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 @@ -72,7 +72,7 @@ def query(self, resource_uri, metric_names, **kwargs): or tuple[~datetime.datetime, ~datetime.datetime] :keyword granularity: The granularity (i.e. timegrain) of the query. :paramtype granularity: ~datetime.timedelta - :keyword aggregations: The list of aggregation types to retrieve. Use `azure.monitor.query.AggregationType` + :keyword aggregations: The list of aggregation types to retrieve. Use `azure.monitor.query.MetricAggregationType` enum to get each aggregation type. :paramtype aggregations: list[str] :keyword max_results: The maximum number of records to retrieve. 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 537184c963d6..4daf80ac06d7 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -344,9 +344,9 @@ class MetricDefinition(object): :keyword primary_aggregation_type: the primary aggregation type value defining how to use the values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", "Total". - :paramtype primary_aggregation_type: str or ~monitor_query_client.models.AggregationType + :paramtype primary_aggregation_type: str or ~monitor_query_client.models.MetricAggregationType :keyword supported_aggregation_types: the collection of what aggregation types are supported. - :paramtype supported_aggregation_types: list[str or ~monitor_query_client.models.AggregationType] + :paramtype supported_aggregation_types: list[str or ~monitor_query_client.models.MetricAggregationType] :keyword metric_availabilities: the collection of what aggregation intervals are available to be queried. :paramtype metric_availabilities: list[~monitor_query_client.models.MetricAvailability] @@ -552,7 +552,7 @@ def _from_generated(cls, generated): ) -class AggregationType(str, Enum): +class MetricAggregationType(str, Enum): """The aggregation type of the metric. """ 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 ed307d6e6fc7..94de65457991 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 @@ -67,7 +67,7 @@ async def query( or tuple[~datetime.datetime, ~datetime.datetime] :keyword granularity: The interval (i.e. timegrain) of the query. :paramtype granularity: ~datetime.timedelta - :keyword aggregations: The list of aggregation types to retrieve. Use `azure.monitor.query.AggregationType` + :keyword aggregations: The list of aggregation types to retrieve. Use `azure.monitor.query.MetricAggregationType` enum to get each aggregation type. :paramtype aggregations: list[str] :keyword max_results: The maximum number of records to retrieve. diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metrics_query_client.py b/sdk/monitor/azure-monitor-query/samples/sample_metrics_query_client.py index 15c6dcbdf157..224d7f05e8ea 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metrics_query_client.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metrics_query_client.py @@ -4,7 +4,7 @@ import os from datetime import datetime, timedelta import urllib3 -from azure.monitor.query import MetricsQueryClient, AggregationType +from azure.monitor.query import MetricsQueryClient, MetricAggregationType from azure.identity import DefaultAzureCredential urllib3.disable_warnings() @@ -21,7 +21,7 @@ metrics_uri, metric_names=["MatchedEventCount", "DeliverySuccesssCount"], timespan=timedelta(days=1), - aggregations=[AggregationType.COUNT] + aggregations=[MetricAggregationType.COUNT] ) for metric in response.metrics: diff --git a/sdk/monitor/azure-monitor-query/tests/async/test_metrics_client_async.py b/sdk/monitor/azure-monitor-query/tests/async/test_metrics_client_async.py index ab796d7d0924..e205e67734e2 100644 --- a/sdk/monitor/azure-monitor-query/tests/async/test_metrics_client_async.py +++ b/sdk/monitor/azure-monitor-query/tests/async/test_metrics_client_async.py @@ -2,7 +2,7 @@ import pytest import os from azure.identity.aio import ClientSecretCredential -from azure.monitor.query import AggregationType +from azure.monitor.query import MetricAggregationType from azure.monitor.query.aio import MetricsQueryClient def _credential(): @@ -22,7 +22,7 @@ async def test_metrics_auth(): os.environ['METRICS_RESOURCE_URI'], metric_names=["MatchedEventCount"], timespan=timedelta(days=1), - aggregations=[AggregationType.COUNT] + aggregations=[MetricAggregationType.COUNT] ) assert response assert response.metrics @@ -37,7 +37,7 @@ async def test_metrics_granularity(): metric_names=["MatchedEventCount"], timespan=timedelta(days=1), granularity=timedelta(minutes=5), - aggregations=[AggregationType.COUNT] + aggregations=[MetricAggregationType.COUNT] ) assert response assert response.granularity == timedelta(minutes=5) diff --git a/sdk/monitor/azure-monitor-query/tests/perfstress_tests/metric_query.py b/sdk/monitor/azure-monitor-query/tests/perfstress_tests/metric_query.py index 11995ed8812c..f91e2c9a3b23 100644 --- a/sdk/monitor/azure-monitor-query/tests/perfstress_tests/metric_query.py +++ b/sdk/monitor/azure-monitor-query/tests/perfstress_tests/metric_query.py @@ -8,7 +8,7 @@ from datetime import datetime, timezone from azure_devtools.perfstress_tests import PerfStressTest -from azure.monitor.query import MetricsQueryClient as SyncMetricsQueryClient, AggregationType +from azure.monitor.query import MetricsQueryClient as SyncMetricsQueryClient, MetricAggregationType from azure.monitor.query.aio import MetricsQueryClient as AsyncMetricsQueryClient from azure.identity import DefaultAzureCredential as SyncDefaultAzureCredential @@ -21,7 +21,7 @@ def __init__(self, arguments): # auth configuration self.metrics_uri = self.get_from_env('METRICS_RESOURCE_URI') self.names = ["MatchedEventCount"] - self.aggregations = [AggregationType.COUNT] + self.aggregations = [MetricAggregationType.COUNT] # Create clients self.metrics_client = SyncMetricsQueryClient( diff --git a/sdk/monitor/azure-monitor-query/tests/test_metrics_client.py b/sdk/monitor/azure-monitor-query/tests/test_metrics_client.py index 082da65c4385..ecdb7e7c8a3a 100644 --- a/sdk/monitor/azure-monitor-query/tests/test_metrics_client.py +++ b/sdk/monitor/azure-monitor-query/tests/test_metrics_client.py @@ -2,7 +2,7 @@ import os from datetime import datetime, timedelta from azure.identity import ClientSecretCredential -from azure.monitor.query import MetricsQueryClient, AggregationType +from azure.monitor.query import MetricsQueryClient, MetricAggregationType def _credential(): credential = ClientSecretCredential( @@ -20,7 +20,7 @@ def test_metrics_auth(): os.environ['METRICS_RESOURCE_URI'], metric_names=["MatchedEventCount"], timespan=timedelta(days=1), - aggregations=[AggregationType.COUNT] + aggregations=[MetricAggregationType.COUNT] ) assert response assert response.metrics @@ -34,7 +34,7 @@ def test_metrics_granularity(): metric_names=["MatchedEventCount"], timespan=timedelta(days=1), granularity=timedelta(minutes=5), - aggregations=[AggregationType.COUNT] + aggregations=[MetricAggregationType.COUNT] ) assert response assert response.granularity == timedelta(minutes=5) From a5e3906099517d7cea6c4d190dcf2df1f876a356 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Mon, 23 Aug 2021 08:33:17 -0700 Subject: [PATCH 3/8] Metric Class --- sdk/monitor/azure-monitor-query/CHANGELOG.md | 2 ++ .../azure/monitor/query/__init__.py | 2 ++ .../azure/monitor/query/_models.py | 21 ++++++++++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index 7eedbd2eed37..04108c05be61 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -5,6 +5,8 @@ ### Features Added - Added additional `display_description` attribute to the `Metric` type. +- Added a `MetricClass` enum to provide the class of a metric. +- Added a `metric_class` attribute to the `MetricDefinition` type. ### Breaking Changes 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 d2e37e5d82e0..0f2fcd69f29a 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py @@ -21,6 +21,7 @@ TimeSeriesElement, Metric, MetricValue, + MetricClass, MetricAvailability ) @@ -42,6 +43,7 @@ "TimeSeriesElement", "Metric", "MetricValue", + "MetricClass", "MetricAvailability" ] 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 4daf80ac06d7..377f255a499b 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -326,6 +326,18 @@ def _from_generated(cls, generated): fully_qualified_namespace=fully_qualified_namespace ) + +class MetricClass(str, Enum): + """The class of the metric. + """ + + AVAILABILITY = "Availability" + TRANSACTIONS = "Transactions" + ERRORS = "Errors" + LATENCY = "Latency" + SATURATION = "Saturation" + + class MetricDefinition(object): """Metric definition class specifies the metadata for a metric. @@ -344,12 +356,15 @@ class MetricDefinition(object): :keyword primary_aggregation_type: the primary aggregation type value defining how to use the values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", "Total". - :paramtype primary_aggregation_type: str or ~monitor_query_client.models.MetricAggregationType + :paramtype primary_aggregation_type: str or ~azure.monitor.query.MetricAggregationType + :keyword metric_class: The class of the metric. Possible values include: "Availability", + "Transactions", "Errors", "Latency", "Saturation". + :paramtype metric_class: str or ~azure.monitor.query.MetricClass :keyword supported_aggregation_types: the collection of what aggregation types are supported. - :paramtype supported_aggregation_types: list[str or ~monitor_query_client.models.MetricAggregationType] + :paramtype supported_aggregation_types: list[str or ~azure.monitor.query.MetricAggregationType] :keyword metric_availabilities: the collection of what aggregation intervals are available to be queried. - :paramtype metric_availabilities: list[~monitor_query_client.models.MetricAvailability] + :paramtype metric_availabilities: list[~azure.monitor.query.MetricAvailability] :keyword id: the resource identifier of the metric definition. :paramtype id: str :keyword dimensions: the name and the display name of the dimension, i.e. it is a localizable From 6678346cc1e679317fd665f9a82cd8777ea47b6b Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Mon, 23 Aug 2021 08:36:05 -0700 Subject: [PATCH 4/8] logs batch result --- sdk/monitor/azure-monitor-query/CHANGELOG.md | 1 + .../azure/monitor/query/__init__.py | 2 -- .../azure/monitor/query/_models.py | 27 ------------------- 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index 04108c05be61..3c798b059a6c 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -26,6 +26,7 @@ - `MetricsMetadataValues` is removed. A dictionary is used instead. - `time_stamp` is renamed to `timestamp` in `MetricValue` type. - `AggregationType` is renamed to `MetricAggregationType`. +- Removed `LogsBatchResultError` type. ### Bugs Fixed 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 0f2fcd69f29a..31d7adbc0708 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py @@ -14,7 +14,6 @@ LogsQueryResultTable, LogsQueryResultColumn, MetricsResult, - LogsBatchResultError, LogsBatchQuery, MetricNamespace, MetricDefinition, @@ -31,7 +30,6 @@ "MetricAggregationType", "LogsQueryClient", "LogsBatchQueryResult", - "LogsBatchResultError", "LogsQueryResult", "LogsQueryResultColumn", "LogsQueryResultTable", 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 377f255a499b..af64c33cb62c 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -264,33 +264,6 @@ def _from_generated(cls, generated): ) -class LogsBatchResultError(object): - """Error response for a batch request. - - :ivar message: The error message describing the cause of the error. - :vartype message: str - :param code: The error code. - :vartype code: str - :param details: The details of the error. - :vartype inner_error: list[~azure.monitor.query.ErrorDetails] - """ - def __init__(self, **kwargs): - # type: (Any) -> None - self.message = kwargs.get("message", None) - self.code = kwargs.get("code", None) - self.details = kwargs.get("details", None) - - @classmethod - def _from_generated(cls, generated): - if not generated: - return cls() - return cls( - message=generated.inner_error.message, - code=generated.code, - details=generated.inner_error.details - ) - - class MetricNamespace(object): """Metric namespace class specifies the metadata for a metric namespace. From 9057dd7c8255d48c60a66fa98e5236a5d98e59b7 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Mon, 23 Aug 2021 08:55:40 -0700 Subject: [PATCH 5/8] MetricNamespaceClassification --- sdk/monitor/azure-monitor-query/CHANGELOG.md | 1 + .../azure/monitor/query/__init__.py | 2 ++ .../azure/monitor/query/_models.py | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index 3c798b059a6c..ad1951c6345b 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -7,6 +7,7 @@ - Added additional `display_description` attribute to the `Metric` type. - Added a `MetricClass` enum to provide the class of a metric. - Added a `metric_class` attribute to the `MetricDefinition` type. +- Added a `MetricNamespaceClassification` enum to support the `namespace_classification` attribute on `MetricNamespace` type. ### Breaking Changes 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 31d7adbc0708..3683694944f1 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py @@ -16,6 +16,7 @@ MetricsResult, LogsBatchQuery, MetricNamespace, + MetricNamespaceClassification, MetricDefinition, TimeSeriesElement, Metric, @@ -36,6 +37,7 @@ "LogsBatchQuery", "MetricsQueryClient", "MetricNamespace", + "MetricNamespaceClassification", "MetricDefinition", "MetricsResult", "TimeSeriesElement", 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 af64c33cb62c..f27095eebbf2 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -264,6 +264,15 @@ def _from_generated(cls, generated): ) +class MetricNamespaceClassification(str, Enum): + """Kind of namespace + """ + + PLATFORM = "Platform" + CUSTOM = "Custom" + QOS = "Qos" + + class MetricNamespace(object): """Metric namespace class specifies the metadata for a metric namespace. @@ -275,6 +284,8 @@ class MetricNamespace(object): :paramtype name: str :keyword fully_qualified_namespace: The fully qualified namespace name. :paramtype fully_qualified_namespace: str + :keyword namespace_classification: Kind of namespace. Possible values include: "Platform", "Custom", "Qos". + :paramtype namespace_classification: str or ~azure.monitor.query.MetricNamespaceClassification """ def __init__( self, @@ -284,6 +295,7 @@ def __init__( self.type = kwargs.get('type', None) self.name = kwargs.get('name', None) self.fully_qualified_namespace = kwargs.get('fully_qualified_namespace', None) + self.namespace_classification = kwargs.get('namespace_classification', None) @classmethod def _from_generated(cls, generated): @@ -296,7 +308,8 @@ def _from_generated(cls, generated): id=generated.id, type=generated.type, name=generated.name, - fully_qualified_namespace=fully_qualified_namespace + fully_qualified_namespace=fully_qualified_namespace, + namespace_classification=generated.classification ) @@ -359,6 +372,7 @@ def __init__( self.metric_availabilities = kwargs.get('metric_availabilities', None) # type: List[MetricAvailability] self.id = kwargs.get('id', None) # type: Optional[str] self.dimensions = kwargs.get('dimensions', None) # type: Optional[List[str]] + self.metric_class = kwargs.get('metric_class', None) # type: Optional[str] @classmethod def _from_generated(cls, generated): @@ -375,6 +389,7 @@ def _from_generated(cls, generated): unit=generated.unit, primary_aggregation_type=generated.primary_aggregation_type, supported_aggregation_types=generated.supported_aggregation_types, + metric_class=generated.metric_class, metric_availabilities=[ MetricAvailability._from_generated( # pylint: disable=protected-access val From 005f8f24fffe6f717c679bb1591daf6c6b1ec62c Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Mon, 23 Aug 2021 09:36:36 -0700 Subject: [PATCH 6/8] LogsTable + LogsTableColumn --- sdk/monitor/azure-monitor-query/CHANGELOG.md | 2 ++ sdk/monitor/azure-monitor-query/README.md | 4 ++-- .../azure/monitor/query/__init__.py | 8 ++++---- .../azure/monitor/query/_models.py | 20 +++++++++---------- .../sample_log_query_client_async.py | 2 +- .../sample_log_query_client_without_pandas.py | 2 +- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index ad1951c6345b..ea4ae667b247 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -28,6 +28,8 @@ - `time_stamp` is renamed to `timestamp` in `MetricValue` type. - `AggregationType` is renamed to `MetricAggregationType`. - Removed `LogsBatchResultError` type. +- `LogsQueryResultTable` is named to `LogsTable` +- `LogsQueryResultColumn` is renamed to `LogsTableColumn` ### Bugs Fixed diff --git a/sdk/monitor/azure-monitor-query/README.md b/sdk/monitor/azure-monitor-query/README.md index c2a15edb6929..8d3d209f4c24 100644 --- a/sdk/monitor/azure-monitor-query/README.md +++ b/sdk/monitor/azure-monitor-query/README.md @@ -226,10 +226,10 @@ LogsQueryResult / LogsBatchQueryResult |---statistics |---visualization |---error -|---tables (list of `LogsQueryResultTable` objects) +|---tables (list of `LogsTable` objects) |---name |---rows - |---columns (list of `LogsQueryResultColumn` objects) + |---columns (list of `LogsTableColumn` objects) |---name |---type ``` 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 3683694944f1..386aec140be1 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py @@ -11,8 +11,8 @@ MetricAggregationType, LogsBatchQueryResult, LogsQueryResult, - LogsQueryResultTable, - LogsQueryResultColumn, + LogsTable, + LogsTableColumn, MetricsResult, LogsBatchQuery, MetricNamespace, @@ -32,8 +32,8 @@ "LogsQueryClient", "LogsBatchQueryResult", "LogsQueryResult", - "LogsQueryResultColumn", - "LogsQueryResultTable", + "LogsTableColumn", + "LogsTable", "LogsBatchQuery", "MetricsQueryClient", "MetricNamespace", 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 f27095eebbf2..26f4093e22bf 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -16,7 +16,7 @@ ) -class LogsQueryResultTable(object): +class LogsTable(object): """Contains the columns and rows for one table in a query response. All required parameters must be populated in order to send to Azure. @@ -24,12 +24,12 @@ class LogsQueryResultTable(object): :param name: Required. The name of the table. :type name: str :param columns: Required. The list of columns in this table. - :type columns: list[~azure.monitor.query.LogsQueryResultColumn] + :type columns: list[~azure.monitor.query.LogsTableColumn] :param rows: Required. The resulting rows from this query. :type rows: list[list[str]] """ def __init__(self, name, columns, rows): - # type: (str, List[LogsQueryResultColumn], List[List[str]]) -> None + # type: (str, List[LogsTableColumn], List[List[str]]) -> None self.name = name self.columns = columns self.rows = [process_row(self.columns, row) for row in rows] @@ -38,12 +38,12 @@ def __init__(self, name, columns, rows): def _from_generated(cls, generated): return cls( name=generated.name, - columns=[LogsQueryResultColumn(name=col.name, type=col.type) for col in generated.columns], + columns=[LogsTableColumn(name=col.name, type=col.type) for col in generated.columns], rows=generated.rows ) -class LogsQueryResultColumn(InternalColumn): +class LogsTableColumn(InternalColumn): """A column in a table. :ivar name: The name of this column. @@ -59,7 +59,7 @@ class LogsQueryResultColumn(InternalColumn): def __init__(self, **kwargs): # type: (Any) -> None - super(LogsQueryResultColumn, self).__init__(**kwargs) + super(LogsTableColumn, self).__init__(**kwargs) self.name = kwargs.get("name", None) self.type = kwargs.get("type", None) @@ -68,7 +68,7 @@ class LogsQueryResult(object): """Contains the tables, columns & rows resulting from a query. :ivar tables: The list of tables, columns and rows. - :vartype tables: list[~azure.monitor.query.LogsQueryResultTable] + :vartype tables: list[~azure.monitor.query.LogsTable] :ivar statistics: This will include a statistics property in the response that describes various performance statistics such as query execution time and resource usage. :vartype statistics: object @@ -92,7 +92,7 @@ def _from_generated(cls, generated): tables = None if generated.tables is not None: tables = [ - LogsQueryResultTable._from_generated( # pylint: disable=protected-access + LogsTable._from_generated( # pylint: disable=protected-access table ) for table in generated.tables ] @@ -222,7 +222,7 @@ class LogsBatchQueryResult(object): :ivar status: status code of the response. :vartype status: int :ivar tables: The list of tables, columns and rows. - :vartype tables: list[~azure.monitor.query.LogsQueryResultTable] + :vartype tables: list[~azure.monitor.query.LogsTable] :ivar statistics: This will include a statistics property in the response that describes various performance statistics such as query execution time and resource usage. :vartype statistics: object @@ -250,7 +250,7 @@ def _from_generated(cls, generated): tables = None if generated.body.tables is not None: tables = [ - LogsQueryResultTable._from_generated( # pylint: disable=protected-access + LogsTable._from_generated( # pylint: disable=protected-access table ) for table in generated.body.tables ] diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_client_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_client_async.py index 4aebbde5e27f..15aa900e6a26 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_client_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_client_async.py @@ -42,7 +42,7 @@ async def logs_query(): # if you dont want to use pandas - here's how you can process it. - #response.tables is a LogsQueryResultTable + #response.tables is a LogsTable for table in response.tables: for col in table.columns: #LogsQueryResultColumn print(col.name + "/"+ col.type + " | ", end="") diff --git a/sdk/monitor/azure-monitor-query/samples/sample_log_query_client_without_pandas.py b/sdk/monitor/azure-monitor-query/samples/sample_log_query_client_without_pandas.py index f6a1bff2517d..da3aa5dd0cab 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_log_query_client_without_pandas.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_log_query_client_without_pandas.py @@ -22,7 +22,7 @@ if not response.tables: print("No results for the query") -#response.tables is a LogsQueryResultTable +#response.tables is a LogsTable for table in response.tables: for col in table.columns: #LogsQueryResultColumn print(col.name + "/"+ col.type + " | ", end="") From 4d03a99dec73eca572135ab9ec68331668fad592 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Mon, 23 Aug 2021 10:12:03 -0700 Subject: [PATCH 7/8] lint --- .../azure/monitor/query/_metrics_query_client.py | 6 +++--- .../azure-monitor-query/azure/monitor/query/_models.py | 2 +- .../azure/monitor/query/aio/_metrics_query_client_async.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) 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 7428ee30191e..aae99348a479 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 @@ -72,8 +72,8 @@ def query(self, resource_uri, metric_names, **kwargs): or tuple[~datetime.datetime, ~datetime.datetime] :keyword granularity: The granularity (i.e. timegrain) of the query. :paramtype granularity: ~datetime.timedelta - :keyword aggregations: The list of aggregation types to retrieve. Use `azure.monitor.query.MetricAggregationType` - enum to get each aggregation type. + :keyword aggregations: The list of aggregation types to retrieve. Use + `azure.monitor.query.MetricAggregationType` enum to get each aggregation type. :paramtype aggregations: list[str] :keyword max_results: The maximum number of records to retrieve. Valid only if $filter is specified. @@ -134,7 +134,7 @@ def list_metric_namespaces(self, resource_uri, **kwargs): :keyword start_time: The ISO 8601 conform Date start time from which to query for metric namespaces. :paramtype start_time: str - :return: An iterator like instance of either MetricNamespaceCollection or the result of cls(response) + :return: An iterator like instance of either MetricNamespace or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.monitor.query.MetricNamespace] :raises: ~azure.core.exceptions.HttpResponseError """ 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 26f4093e22bf..2b3a33672ec6 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -324,7 +324,7 @@ class MetricClass(str, Enum): SATURATION = "Saturation" -class MetricDefinition(object): +class MetricDefinition(object): #pylint: disable=too-many-instance-attributes """Metric definition class specifies the metadata for a metric. :keyword dimension_required: Flag to indicate whether the dimension is required. 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 94de65457991..e31247a8bf05 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 @@ -118,7 +118,7 @@ def list_metric_namespaces(self, resource_uri: str, **kwargs: Any) -> AsyncItemP :keyword start_time: The ISO 8601 conform Date start time from which to query for metric namespaces. :paramtype start_time: str - :return: An iterator like instance of either MetricNamespaceCollection or the result of cls(response) + :return: An iterator like instance of either MetricNamespace or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.monitor.query.MetricNamespace] :raises: ~azure.core.exceptions.HttpResponseError """ From 815ae786696bbd8ba30fdeeecf553efe3a4c8e0a Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Mon, 23 Aug 2021 11:24:52 -0700 Subject: [PATCH 8/8] more lint --- .../azure/monitor/query/aio/_metrics_query_client_async.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 e31247a8bf05..dfdc2906f38b 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 @@ -67,8 +67,8 @@ async def query( or tuple[~datetime.datetime, ~datetime.datetime] :keyword granularity: The interval (i.e. timegrain) of the query. :paramtype granularity: ~datetime.timedelta - :keyword aggregations: The list of aggregation types to retrieve. Use `azure.monitor.query.MetricAggregationType` - enum to get each aggregation type. + :keyword aggregations: The list of aggregation types to retrieve. + Use `azure.monitor.query.MetricAggregationType` enum to get each aggregation type. :paramtype aggregations: list[str] :keyword max_results: The maximum number of records to retrieve. Valid only if $filter is specified.