diff --git a/sdk/monitor/azure-monitor-query/README.md b/sdk/monitor/azure-monitor-query/README.md index 68001099c9d2..0d86dc3adf2a 100644 --- a/sdk/monitor/azure-monitor-query/README.md +++ b/sdk/monitor/azure-monitor-query/README.md @@ -21,10 +21,10 @@ pip install azure-monitor-query --pre ``` ### Authenticate the client -A **token credential** is necessary to instantiate both the LogsClient and the MetricsClient object. +A **token credential** is necessary to instantiate both the LogsQueryClient and the MetricsQueryClient object. ```Python -from azure.monitor.query import LogsClient +from azure.monitor.query import LogsQueryClient from azure.identity import ClientSecretCredential @@ -34,11 +34,11 @@ credential = ClientSecretCredential( tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = LogsClient(credential) +client = LogsQueryClient(credential) ``` ```Python -from azure.monitor.query import MetricsClient +from azure.monitor.query import MetricsQueryClient from azure.identity import ClientSecretCredential @@ -48,7 +48,7 @@ credential = ClientSecretCredential( tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = MetricsClient(credential) +client = MetricsQueryClient(credential) ``` ## Key concepts @@ -111,7 +111,7 @@ time-stamped data. Each set of metric values is a time series with the following ```Python import os import pandas as pd -from azure.monitor.query import LogsClient +from azure.monitor.query import LogsQueryClient from azure.identity import ClientSecretCredential @@ -121,7 +121,7 @@ credential = ClientSecretCredential( tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = LogsClient(credential) +client = LogsQueryClient(credential) # Response time trend # request duration over the last 12 hours. @@ -145,7 +145,7 @@ for table in response.tables: ```Python import os import pandas as pd -from azure.monitor.query import LogsClient, LogsQueryRequest +from azure.monitor.query import LogsQueryClient, LogsQueryRequest from azure.identity import ClientSecretCredential @@ -155,7 +155,7 @@ credential = ClientSecretCredential( tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = LogsClient(credential) +client = LogsQueryClient(credential) requests = [ LogsQueryRequest( @@ -191,7 +191,7 @@ for response in response.responses: ```Python import os import pandas as pd -from azure.monitor.query import LogsClient +from azure.monitor.query import LogsQueryClient from azure.identity import ClientSecretCredential @@ -201,7 +201,7 @@ credential = ClientSecretCredential( tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = LogsClient(credential) +client = LogsQueryClient(credential) response = client.query( os.environ['LOG_WORKSPACE_ID'], @@ -218,7 +218,7 @@ for table in response.tables: ```Python import os -from azure.monitor.query import MetricsClient +from azure.monitor.query import MetricsQueryClient from azure.identity import ClientSecretCredential @@ -228,7 +228,7 @@ credential = ClientSecretCredential( tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = MetricsClient(credential) +client = MetricsQueryClient(credential) response = client.query(os.environ['METRICS_RESOURCE_URI'], metric_names=["Microsoft.CognitiveServices/accounts"]) ``` 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 139e06a9fc66..5d3104f2d801 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py @@ -4,8 +4,8 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- -from ._log_query_client import LogsClient -from ._metrics_query_client import MetricsClient +from ._log_query_client import LogsQueryClient +from ._metrics_query_client import MetricsQueryClient from ._models import ( LogsQueryResults, @@ -28,7 +28,7 @@ from ._version import VERSION __all__ = [ - "LogsClient", + "LogsQueryClient", "LogsBatchResults", "LogsBatchResultError", "LogsQueryResults", @@ -36,7 +36,7 @@ "LogsQueryResultTable", "LogsQueryRequest", "LogsErrorDetails", - "MetricsClient", + "MetricsQueryClient", "MetricNamespace", "MetricDefinition", "MetricsResult", diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_helpers.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_helpers.py index 6f686274361f..2010a5f4afee 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_helpers.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_helpers.py @@ -5,7 +5,7 @@ # license information. # -------------------------------------------------------------------------- -from typing import Mapping, TYPE_CHECKING +from typing import TYPE_CHECKING from azure.core.exceptions import HttpResponseError from azure.core.pipeline.policies import BearerTokenCredentialPolicy diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_log_query_client.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_log_query_client.py index 2b5352688278..c7a36e89892b 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_log_query_client.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_log_query_client.py @@ -18,12 +18,12 @@ from azure.core.credentials import TokenCredential -class LogsClient(object): - """LogsClient +class LogsQueryClient(object): + """LogsQueryClient :param credential: The credential to authenticate the client :type credential: ~azure.core.credentials.TokenCredential - :keyword endpoint: The endpoint to connect to. Defaults to 'https://api.loganalytics.io/v1'. + :keyword endpoint: The endpoint to connect to. Defaults to 'https://api.loganalytics.io'. :paramtype endpoint: str """ @@ -133,11 +133,11 @@ def batch_query(self, queries, **kwargs): def close(self): # type: () -> None - """Close the :class:`~azure.monitor.query.LogsClient` session.""" + """Close the :class:`~azure.monitor.query.LogsQueryClient` session.""" return self._client.close() def __enter__(self): - # type: () -> LogsClient + # type: () -> LogsQueryClient self._client.__enter__() # pylint:disable=no-member return self 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 d5a92a6b879f..54b2af234654 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 @@ -7,6 +7,7 @@ # pylint: disable=anomalous-backslash-in-string +from datetime import time from typing import TYPE_CHECKING, Any from ._generated._monitor_query_client import ( @@ -19,21 +20,23 @@ if TYPE_CHECKING: from azure.core.credentials import TokenCredential from azure.core.paging import ItemPaged - from ._models import MetricNamespace -class MetricsClient(object): - """MetricsClient +class MetricsQueryClient(object): + """MetricsQueryClient :param credential: The credential to authenticate the client :type credential: ~azure.core.credentials.TokenCredential + :keyword endpoint: The endpoint to connect to. Defaults to 'https://management.azure.com'. + :paramtype endpoint: str """ def __init__(self, credential, **kwargs): # type: (TokenCredential, Any) -> None + endpoint = kwargs.pop('endpoint', 'https://management.azure.com') self._client = MonitorQueryClient( credential=credential, - base_url='https://management.azure.com', + base_url=endpoint, authentication_policy=get_metrics_authentication_policy(credential), **kwargs ) @@ -41,17 +44,17 @@ def __init__(self, credential, **kwargs): self._namespace_op = self._client.metric_namespaces self._definitions_op = self._client.metric_definitions - def query(self, resource_uri, metric_names, **kwargs): - # type: (str, list, Any) -> MetricsResult + def query(self, resource_uri, metric_names, timespan=None, **kwargs): + # type: (str, list, str, Any) -> MetricsResult """Lists the metric values for a resource. :param resource_uri: The identifier of the resource. :type resource_uri: str :param metric_names: The names of the metrics to retrieve. :type metric_names: list - :keyword timespan: The timespan of the query. It is a string with the following format + :param timespan: The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. - :paramtype timespan: str + :type timespan: str :keyword interval: The interval (i.e. timegrain) of the query. :paramtype interval: ~datetime.timedelta :keyword aggregation: The list of aggregation types (comma separated) to retrieve. @@ -84,6 +87,7 @@ def query(self, resource_uri, metric_names, **kwargs): :raises: ~azure.core.exceptions.HttpResponseError """ kwargs.setdefault("metricnames", ",".join(metric_names)) + kwargs.setdefault("timespan", timespan) generated = self._metrics_op.list(resource_uri, connection_verify=False, **kwargs) return MetricsResult._from_generated(generated) # pylint: disable=protected-access @@ -105,7 +109,7 @@ def list_metric_namespaces(self, resource_uri, **kwargs): cls=kwargs.pop( "cls", lambda objs: [ - MetricNamespace._from_generated(x) for x in objs + MetricNamespace._from_generated(x) for x in objs # pylint: disable=protected-access ] ), **kwargs) @@ -128,18 +132,18 @@ def list_metric_definitions(self, resource_uri, metric_namespace=None, **kwargs) cls=kwargs.pop( "cls", lambda objs: [ - MetricDefinition._from_generated(x) for x in objs + MetricDefinition._from_generated(x) for x in objs # pylint: disable=protected-access ] ), **kwargs) def close(self): # type: () -> None - """Close the :class:`~azure.monitor.query.MetricsClient` session.""" + """Close the :class:`~azure.monitor.query.MetricsQueryClient` session.""" return self._client.close() def __enter__(self): - # type: () -> MetricsClient + # type: () -> MetricsQueryClient self._client.__enter__() # pylint:disable=no-member return self 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 7673a37149bd..f84a258d2119 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -147,7 +147,7 @@ def _from_generated(cls, generated): ) class LogsQueryRequest(InternalLogQueryRequest): - """An single request in a batch. + """A single request in a batch. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/__init__.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/__init__.py index 6c76710ba777..316114b34044 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/__init__.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/__init__.py @@ -4,10 +4,10 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- -from ._log_query_client_async import LogsClient -from ._metrics_query_client_async import MetricsClient +from ._log_query_client_async import LogsQueryClient +from ._metrics_query_client_async import MetricsQueryClient __all__ = [ - "LogsClient", - "MetricsClient" + "LogsQueryClient", + "MetricsQueryClient" ] diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_log_query_client_async.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_log_query_client_async.py index dc5f59c02572..e8eddc27c4f4 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_log_query_client_async.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_log_query_client_async.py @@ -17,8 +17,8 @@ from azure.core.credentials_async import AsyncTokenCredential -class LogsClient(object): - """LogsClient +class LogsQueryClient(object): + """LogsQueryClient :param credential: The credential to authenticate the client :type credential: ~azure.core.credentials_async.AsyncTokenCredential @@ -106,9 +106,10 @@ async def batch_query( queries: Union[Sequence[Dict], Sequence[LogsQueryRequest]], **kwargs: Any ) -> LogsBatchResults: - """Execute an Analytics query. + """Execute a list of analytics queries. Each request can be either a LogQueryRequest + object or an equivalent serialized model. - Executes an Analytics query for data. + The response is returned in the same order as that of the requests sent. :param queries: The list of queries that should be processed :type queries: list[dict] or list[~azure.monitor.query.LogsQueryRequest] @@ -129,7 +130,7 @@ async def batch_query( await self._query_op.batch(batch, **kwargs), request_order ) - async def __aenter__(self) -> "LogsClient": + async def __aenter__(self) -> "LogsQueryClient": await self._client.__aenter__() return self @@ -137,5 +138,5 @@ async def __aexit__(self, *args: "Any") -> None: await self._client.__aexit__(*args) async def close(self) -> None: - """Close the :class:`~azure.monitor.query.aio.LogsClient` session.""" + """Close the :class:`~azure.monitor.query.aio.LogsQueryClient` session.""" await self._client.__aexit__() 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 3cbe043d035e..e4450b5e6091 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 @@ -15,39 +15,42 @@ MonitorQueryClient, ) from .._models import MetricsResult, MetricDefinition, MetricNamespace -from .._helpers import get_authentication_policy -from .._models import MetricNamespace +from .._helpers import get_metrics_authentication_policy if TYPE_CHECKING: from azure.core.credentials_async import AsyncTokenCredential -class MetricsClient(object): - """MetricsClient +class MetricsQueryClient(object): + """MetricsQueryClient :param credential: The credential to authenticate the client :type credential: ~azure.core.credentials.TokenCredential + :keyword endpoint: The endpoint to connect to. Defaults to 'https://management.azure.com'. + :paramtype endpoint: str """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + endpoint = kwargs.pop('endpoint', 'https://management.azure.com') self._client = MonitorQueryClient( credential=credential, - authentication_policy=get_authentication_policy(credential), + base_url=endpoint, + authentication_policy=get_metrics_authentication_policy(credential), **kwargs ) self._metrics_op = self._client.metrics self._namespace_op = self._client.metric_namespaces self._definitions_op = self._client.metric_definitions - async def query(self, resource_uri: str, metric_names: List, **kwargs: Any) -> MetricsResult: + async def query(self, resource_uri: str, metric_names: List, timespan :str = None, **kwargs: Any) -> MetricsResult: """Lists the metric values for a resource. :param resource_uri: The identifier of the resource. :type resource_uri: str :param metric_names: The names of the metrics to retrieve. :type metric_names: list - :keyword timespan: The timespan of the query. It is a string with the following format + :param timespan: The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. - :paramtype timespan: str + :type timespan: str :keyword interval: The interval (i.e. timegrain) of the query. :paramtype interval: ~datetime.timedelta :keyword aggregation: The list of aggregation types (comma separated) to retrieve. @@ -80,6 +83,7 @@ async def query(self, resource_uri: str, metric_names: List, **kwargs: Any) -> M :raises: ~azure.core.exceptions.HttpResponseError """ kwargs.setdefault("metric_names", ",".join(metric_names)) + kwargs.setdefault("timespan", timespan) generated = await self._metrics_op.list(resource_uri, connection_verify=False, **kwargs) return MetricsResult._from_generated(generated) # pylint: disable=protected-access @@ -100,7 +104,7 @@ async def list_metric_namespaces(self, resource_uri: str, **kwargs: Any) -> Item cls=kwargs.pop( "cls", lambda objs: [ - MetricNamespace._from_generated(x) for x in objs + MetricNamespace._from_generated(x) for x in objs # pylint: disable=protected-access ] ), **kwargs) @@ -127,12 +131,12 @@ async def list_metric_definitions( cls=kwargs.pop( "cls", lambda objs: [ - MetricDefinition._from_generated(x) for x in objs + MetricDefinition._from_generated(x) for x in objs # pylint: disable=protected-access ] ), **kwargs) - async def __aenter__(self) -> "MetricsClient": + async def __aenter__(self) -> "MetricsQueryClient": await self._client.__aenter__() return self @@ -140,5 +144,5 @@ async def __aexit__(self, *args: "Any") -> None: await self._client.__aexit__(*args) async def close(self) -> None: - """Close the :class:`~azure.monitor.query.aio.MetricsClient` session.""" + """Close the :class:`~azure.monitor.query.aio.MetricsQueryClient` session.""" await self._client.__aexit__() diff --git a/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py b/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py index b359cb30f191..a0ec5658a5a8 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py @@ -3,7 +3,7 @@ import os import pandas as pd -from azure.monitor.query import LogsClient +from azure.monitor.query import LogsQueryClient from azure.identity import ClientSecretCredential @@ -13,7 +13,7 @@ tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = LogsClient(credential) +client = LogsQueryClient(credential) requests = [ { diff --git a/sdk/monitor/azure-monitor-query/samples/sample_batch_query_build.py b/sdk/monitor/azure-monitor-query/samples/sample_batch_query_build.py index 955d5c9eed54..4c9a3e6f24c2 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_batch_query_build.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_batch_query_build.py @@ -3,7 +3,7 @@ import os import pandas as pd -from azure.monitor.query import LogsClient, LogsQueryRequest +from azure.monitor.query import LogsQueryClient, LogsQueryRequest from azure.identity import ClientSecretCredential @@ -13,7 +13,7 @@ tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = LogsClient(credential) +client = LogsQueryClient(credential) requests = [ LogsQueryRequest( diff --git a/sdk/monitor/azure-monitor-query/samples/sample_log_query_client.py b/sdk/monitor/azure-monitor-query/samples/sample_log_query_client.py index c7b0c258603e..df37a8079306 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_log_query_client.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_log_query_client.py @@ -4,7 +4,7 @@ import os import pandas as pd from datetime import timedelta -from azure.monitor.query import LogsClient +from azure.monitor.query import LogsQueryClient from azure.identity import ClientSecretCredential @@ -14,7 +14,7 @@ tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = LogsClient(credential) +client = LogsQueryClient(credential) # Response time trend # request duration over the last 12 hours. diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py b/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py index d03986a0a4ee..0891b8c7ebda 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py @@ -2,7 +2,7 @@ # Licensed under the MIT License. import os -from azure.monitor.query import MetricsClient +from azure.monitor.query import MetricsQueryClient from azure.identity import ClientSecretCredential credential = ClientSecretCredential( @@ -11,7 +11,7 @@ tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = MetricsClient(credential) +client = MetricsQueryClient(credential) metrics_uri = os.environ['METRICS_RESOURCE_URI'] response = client.list_metric_definitions(metrics_uri, metric_namespace='microsoft.eventgrid/topics') diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py b/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py index 7c6bdb0735ab..a7bbbda4e95e 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py @@ -2,7 +2,7 @@ # Licensed under the MIT License. import os -from azure.monitor.query import MetricsClient +from azure.monitor.query import MetricsQueryClient from azure.identity import ClientSecretCredential credential = ClientSecretCredential( @@ -11,7 +11,7 @@ tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = MetricsClient(credential) +client = MetricsQueryClient(credential) metrics_uri = os.environ['METRICS_RESOURCE_URI'] response = client.list_metric_namespaces(metrics_uri) 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 e0eed23fabe9..b0b390b534fd 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 @@ -3,7 +3,7 @@ import os import urllib3 -from azure.monitor.query import MetricsClient +from azure.monitor.query import MetricsQueryClient from azure.identity import ClientSecretCredential urllib3.disable_warnings() @@ -14,7 +14,7 @@ tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = MetricsClient(credential) +client = MetricsQueryClient(credential) metrics_uri = os.environ['METRICS_RESOURCE_URI'] response = client.query( diff --git a/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py b/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py index 2207dc80dd1a..9b1c0b19bd3c 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py @@ -3,7 +3,7 @@ import os import pandas as pd -from azure.monitor.query import LogsClient +from azure.monitor.query import LogsQueryClient from azure.identity import ClientSecretCredential @@ -13,7 +13,7 @@ tenant_id = os.environ['AZURE_TENANT_ID'] ) -client = LogsClient(credential) +client = LogsQueryClient(credential) response = client.query( os.environ['LOG_WORKSPACE_ID'], diff --git a/sdk/monitor/azure-monitor-query/tests/async/test_logs_client_async.py b/sdk/monitor/azure-monitor-query/tests/async/test_logs_client_async.py index c34d32620c17..415df83393ee 100644 --- a/sdk/monitor/azure-monitor-query/tests/async/test_logs_client_async.py +++ b/sdk/monitor/azure-monitor-query/tests/async/test_logs_client_async.py @@ -3,7 +3,7 @@ from azure.identity.aio import ClientSecretCredential from azure.core.exceptions import HttpResponseError from azure.monitor.query import LogsQueryRequest -from azure.monitor.query.aio import LogsClient +from azure.monitor.query.aio import LogsQueryClient def _credential(): credential = ClientSecretCredential( @@ -16,7 +16,7 @@ def _credential(): @pytest.mark.live_test_only async def test_logs_auth(): credential = _credential() - client = LogsClient(credential) + client = LogsQueryClient(credential) query = """AppRequests | where TimeGenerated > ago(12h) | summarize avgRequestDuration=avg(DurationMs) by bin(TimeGenerated, 10m), _ResourceId""" @@ -29,7 +29,7 @@ async def test_logs_auth(): @pytest.mark.live_test_only async def test_logs_server_timeout(): - client = LogsClient(_credential()) + client = LogsQueryClient(_credential()) with pytest.raises(HttpResponseError) as e: response = await client.query( @@ -41,7 +41,7 @@ async def test_logs_server_timeout(): @pytest.mark.live_test_only async def test_logs_batch_query(): - client = LogsClient(_credential()) + client = LogsQueryClient(_credential()) requests = [ LogsQueryRequest( 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 256994708dea..f6612500149d 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.aio import MetricsClient +from azure.monitor.query.aio import MetricsQueryClient def _credential(): credential = ClientSecretCredential( @@ -15,7 +15,7 @@ def _credential(): @pytest.mark.live_test_only async def test_metrics_auth(): credential = _credential() - client = MetricsClient(credential) + client = MetricsQueryClient(credential) # returns LogsQueryResults response = await client.query(os.environ['METRICS_RESOURCE_URI'], metric_names=["PublishSuccessCount"], timespan='P2D') @@ -24,7 +24,7 @@ async def test_metrics_auth(): @pytest.mark.live_test_only async def test_metrics_namespaces(): - client = MetricsClient(_credential()) + client = MetricsQueryClient(_credential()) response = await client.list_metric_namespaces(os.environ['METRICS_RESOURCE_URI']) @@ -32,7 +32,7 @@ async def test_metrics_namespaces(): @pytest.mark.live_test_only async def test_metrics_definitions(): - client = MetricsClient(_credential()) + client = MetricsQueryClient(_credential()) response = await client.list_metric_definitions(os.environ['METRICS_RESOURCE_URI'], metric_namespace='microsoft.eventgrid/topics') diff --git a/sdk/monitor/azure-monitor-query/tests/test_logs_client.py b/sdk/monitor/azure-monitor-query/tests/test_logs_client.py index e6de47b071f3..750ef9cefee6 100644 --- a/sdk/monitor/azure-monitor-query/tests/test_logs_client.py +++ b/sdk/monitor/azure-monitor-query/tests/test_logs_client.py @@ -2,7 +2,7 @@ import os from azure.identity import ClientSecretCredential from azure.core.exceptions import HttpResponseError -from azure.monitor.query import LogsClient, LogsQueryRequest +from azure.monitor.query import LogsQueryClient, LogsQueryRequest def _credential(): credential = ClientSecretCredential( @@ -15,7 +15,7 @@ def _credential(): @pytest.mark.live_test_only def test_logs_auth(): credential = _credential() - client = LogsClient(credential) + client = LogsQueryClient(credential) query = """AppRequests | where TimeGenerated > ago(12h) | summarize avgRequestDuration=avg(DurationMs) by bin(TimeGenerated, 10m), _ResourceId""" @@ -28,7 +28,7 @@ def test_logs_auth(): @pytest.mark.live_test_only def test_logs_server_timeout(): - client = LogsClient(_credential()) + client = LogsQueryClient(_credential()) with pytest.raises(HttpResponseError) as e: response = client.query( @@ -40,7 +40,7 @@ def test_logs_server_timeout(): @pytest.mark.live_test_only def test_logs_batch_query(): - client = LogsClient(_credential()) + client = LogsQueryClient(_credential()) requests = [ LogsQueryRequest( 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 f85d1bec0e22..737419212a41 100644 --- a/sdk/monitor/azure-monitor-query/tests/test_metrics_client.py +++ b/sdk/monitor/azure-monitor-query/tests/test_metrics_client.py @@ -1,7 +1,7 @@ import pytest import os from azure.identity import ClientSecretCredential -from azure.monitor.query import MetricsClient +from azure.monitor.query import MetricsQueryClient def _credential(): credential = ClientSecretCredential( @@ -14,7 +14,7 @@ def _credential(): @pytest.mark.liveTest def test_metrics_auth(): credential = _credential() - client = MetricsClient(credential) + client = MetricsQueryClient(credential) # returns LogsQueryResults response = client.query(os.environ['METRICS_RESOURCE_URI'], metric_names=["PublishSuccessCount"], timespan='P2D') @@ -23,7 +23,7 @@ def test_metrics_auth(): @pytest.mark.liveTest def test_metrics_namespaces(): - client = MetricsClient(_credential()) + client = MetricsQueryClient(_credential()) response = client.list_metric_namespaces(os.environ['METRICS_RESOURCE_URI']) @@ -31,7 +31,7 @@ def test_metrics_namespaces(): @pytest.mark.liveTest def test_metrics_definitions(): - client = MetricsClient(_credential()) + client = MetricsQueryClient(_credential()) response = client.list_metric_definitions(os.environ['METRICS_RESOURCE_URI'], metric_namespace='microsoft.eventgrid/topics') diff --git a/sdk/nspkg/azure-monitor-nspkg/CHANGELOG.md b/sdk/nspkg/azure-monitor-nspkg/CHANGELOG.md deleted file mode 100644 index cf818fb2bdeb..000000000000 --- a/sdk/nspkg/azure-monitor-nspkg/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -# Release History - -## 1.0.0 (2021-06-08) diff --git a/sdk/nspkg/azure-monitor-nspkg/MANIFEST.in b/sdk/nspkg/azure-monitor-nspkg/MANIFEST.in deleted file mode 100644 index 944d91b3b7df..000000000000 --- a/sdk/nspkg/azure-monitor-nspkg/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include *.md -include azure/__init__.py -include azure/monitor/__init__.py diff --git a/sdk/nspkg/azure-monitor-nspkg/README.md b/sdk/nspkg/azure-monitor-nspkg/README.md deleted file mode 100644 index 049095aa81af..000000000000 --- a/sdk/nspkg/azure-monitor-nspkg/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Microsoft Azure SDK for Python - -This is the Microsoft Azure monitor Services namespace package. - -This package is not intended to be installed directly by the end user. - -Since version 3.0, this is Python 2 package only, Python 3.x SDKs will use `PEP420 ` as namespace package strategy. -To avoid issues with package servers that does not support `python_requires`, a Python 3 package is installed but is empty. - -It provides the necessary files for other packages to extend the azure.ai namespace. - -If you are looking to install the Azure client libraries, see the -`azure `__ bundle package. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fsdk%2Ftextanalytics%2Fazure-ai-nspkg%2FREADME.png) \ No newline at end of file diff --git a/sdk/nspkg/azure-monitor-nspkg/azure/__init__.py b/sdk/nspkg/azure-monitor-nspkg/azure/__init__.py deleted file mode 100644 index 69e3be50dac4..000000000000 --- a/sdk/nspkg/azure-monitor-nspkg/azure/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/sdk/nspkg/azure-monitor-nspkg/azure/monitor/__init__.py b/sdk/nspkg/azure-monitor-nspkg/azure/monitor/__init__.py deleted file mode 100644 index 69e3be50dac4..000000000000 --- a/sdk/nspkg/azure-monitor-nspkg/azure/monitor/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/sdk/nspkg/azure-monitor-nspkg/sdk_packaging.toml b/sdk/nspkg/azure-monitor-nspkg/sdk_packaging.toml deleted file mode 100644 index e7687fdae93b..000000000000 --- a/sdk/nspkg/azure-monitor-nspkg/sdk_packaging.toml +++ /dev/null @@ -1,2 +0,0 @@ -[packaging] -auto_update = false \ No newline at end of file diff --git a/sdk/nspkg/azure-monitor-nspkg/setup.py b/sdk/nspkg/azure-monitor-nspkg/setup.py deleted file mode 100644 index 3c5449f2c305..000000000000 --- a/sdk/nspkg/azure-monitor-nspkg/setup.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python - -#------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -#-------------------------------------------------------------------------- -import sys -from setuptools import setup - -# azure v0.x is not compatible with this package -# azure v0.x used to have a __version__ attribute (newer versions don't) -try: - import azure - try: - ver = azure.__version__ - raise Exception( - 'This package is incompatible with azure=={}. '.format(ver) + - 'Uninstall it with "pip uninstall azure".' - ) - except AttributeError: - pass -except ImportError: - pass - -PACKAGES = [] -# Do an empty package on Python 3 and not python_requires, since not everybody is ready -# https://github.com/Azure/azure-sdk-for-python/issues/3447 -# https://github.com/Azure/azure-sdk-for-python/issues/3481 -if sys.version_info[0] < 3: - PACKAGES = ['azure.monitor'] - -setup( - name='azure-monitor-nspkg', - version='1.0.0', - description='Microsoft Azure monitor Namespace Package [Internal]', - long_description=open('README.md', 'r').read(), - license='MIT License', - author='Microsoft Corporation', - author_email='azpysdkhelp@microsoft.com', - url='https://github.com/Azure/azure-sdk-for-python', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'License :: OSI Approved :: MIT License', - ], - zip_safe=False, - packages=PACKAGES, - install_requires=[ - 'azure-nspkg>=3.0.0', - ] -) diff --git a/sdk/nspkg/ci.yml b/sdk/nspkg/ci.yml index a0a616ddd8ab..ffb881ee82fe 100644 --- a/sdk/nspkg/ci.yml +++ b/sdk/nspkg/ci.yml @@ -59,9 +59,6 @@ extends: - name: azure-messaging-nspkg safeName: azuremessagingnspkg skipVerifyChangeLog: true - - name: azure-monitor-nspkg - safeName: azuremonitornspkg - skipVerifyChangeLog: true - name: azure-purview-nspkg safeName: azurepurviewnspkg skipVerifyChangeLog: true