From 09b0101e193d54188e7452d21105cc3ecbf8b89b Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Wed, 6 Oct 2021 12:32:35 -0700 Subject: [PATCH 1/4] Remove audience --- sdk/monitor/azure-monitor-query/CHANGELOG.md | 1 - .../azure/monitor/query/_logs_query_client.py | 2 -- .../azure/monitor/query/_metrics_query_client.py | 2 -- .../azure/monitor/query/aio/_logs_query_client_async.py | 2 -- .../azure/monitor/query/aio/_metrics_query_client_async.py | 2 -- 5 files changed, 9 deletions(-) diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index f250c47dd4e2..e34f264b3406 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -9,7 +9,6 @@ - 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 `MetricsQueryResult` can now be accessed by metric names. -- Added `audience` keyword to support providing credential scope when creating clients. ### Breaking Changes diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py index 24db36531e8b..908a0cef6ec0 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py @@ -49,8 +49,6 @@ class LogsQueryClient(object): :type credential: ~azure.core.credentials.TokenCredential :keyword endpoint: The endpoint to connect to. Defaults to 'https://api.loganalytics.io'. :paramtype endpoint: str - :keyword audience: URL to use for credential authentication with AAD. - :paramtype audience: str """ def __init__(self, credential, **kwargs): 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 31e762761c85..5c1dc2b739fe 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 @@ -44,8 +44,6 @@ class MetricsQueryClient(object): :type credential: ~azure.core.credentials.TokenCredential :keyword endpoint: The endpoint to connect to. Defaults to 'https://management.azure.com'. :paramtype endpoint: str - :keyword audience: URL to use for credential authentication with AAD. - :paramtype audience: str """ def __init__(self, credential, **kwargs): diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py index 4e4df78df924..5f608d194337 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py @@ -35,8 +35,6 @@ class LogsQueryClient(object): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :keyword endpoint: The endpoint to connect to. Defaults to 'https://api.loganalytics.io/v1'. :paramtype endpoint: str - :keyword audience: URL to use for credential authentication with AAD. - :paramtype audience: str """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: 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 6751b11b6c39..cadec7a5770a 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 @@ -32,8 +32,6 @@ class MetricsQueryClient(object): :type credential: ~azure.core.credentials.TokenCredential :keyword endpoint: The endpoint to connect to. Defaults to 'https://management.azure.com'. :paramtype endpoint: str - :keyword audience: URL to use for credential authentication with AAD. - :paramtype audience: str """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: From 4c72c20f439943a1744120249f173664a9111088 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Wed, 6 Oct 2021 12:56:48 -0700 Subject: [PATCH 2/4] mapping mypy fix --- .../azure-monitor-query/azure/monitor/query/_models.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 f42064048c66..7a4f81d76fb8 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -7,7 +7,7 @@ from enum import Enum import uuid -from typing import Any, Optional, List +from typing import Any, Optional, List, Mapping from ._helpers import construct_iso8601, process_row from ._generated.models import ( @@ -235,10 +235,10 @@ class LogsQueryResult(object): :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 + :vartype statistics: Mapping :ivar visualization: This will include a visualization property in the response that specifies the type of visualization selected by the query and any properties for that visualization. - :vartype visualization: object + :vartype visualization: Mapping :ivar status: The status of the result. Always 'Success' for an instance of a LogsQueryResult. :vartype status: ~azure.monitor.query.LogsQueryStatus @@ -585,10 +585,10 @@ class LogsQueryPartialResult(object): :vartype partial_data: 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 + :vartype statistics: Mapping :ivar visualization: This will include a visualization property in the response that specifies the type of visualization selected by the query and any properties for that visualization. - :vartype visualization: object + :vartype visualization: Mapping :ivar partial_error: The partial errror info :vartype partial_error: ~azure.monitor.query.LogsQueryError :ivar status: The status of the result. Always 'PartialError' for an instance of a LogsQueryPartialResult. From ad4d7c77caa0d176a4adf6f14ae07aadca6c5955 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Wed, 6 Oct 2021 13:45:30 -0700 Subject: [PATCH 3/4] lint --- .../azure/monitor/query/_logs_query_client.py | 2 +- sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py | 2 +- .../azure/monitor/query/aio/_logs_query_client_async.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py index 908a0cef6ec0..254a989d5de4 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py @@ -60,7 +60,7 @@ def __init__(self, credential, **kwargs): self._endpoint = endpoint self._client = MonitorQueryClient( credential=credential, - authentication_policy=get_authentication_policy(credential, audience), + authentication_policy=get_authentication_policy(credential, "https://api.loganalytics.io"), base_url=self._endpoint, **kwargs ) 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 7a4f81d76fb8..1b7b30da04de 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -7,7 +7,7 @@ from enum import Enum import uuid -from typing import Any, Optional, List, Mapping +from typing import Any, Optional, List from ._helpers import construct_iso8601, process_row from ._generated.models import ( diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py index 5f608d194337..424915b0bc49 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py @@ -45,7 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: self._endpoint = endpoint self._client = MonitorQueryClient( credential=credential, - authentication_policy=get_authentication_policy(credential, audience), + authentication_policy=get_authentication_policy(credential, "https://api.loganalytics.io"), base_url=self._endpoint, **kwargs ) From 4ebbc1e348be070db173e04a71cc7cad571baf17 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Wed, 6 Oct 2021 13:49:53 -0700 Subject: [PATCH 4/4] endpoint --- .../azure/monitor/query/_logs_query_client.py | 7 +++---- .../azure/monitor/query/aio/_logs_query_client_async.py | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py index 254a989d5de4..9f95c97860d1 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py @@ -53,15 +53,14 @@ class LogsQueryClient(object): def __init__(self, credential, **kwargs): # type: (TokenCredential, Any) -> None - audience = kwargs.pop("audience", None) - endpoint = kwargs.pop("endpoint", "https://api.loganalytics.io/v1") + endpoint = kwargs.pop("endpoint", "https://api.loganalytics.io") if not endpoint.startswith("https://") and not endpoint.startswith("http://"): endpoint = "https://" + endpoint self._endpoint = endpoint self._client = MonitorQueryClient( credential=credential, - authentication_policy=get_authentication_policy(credential, "https://api.loganalytics.io"), - base_url=self._endpoint, + authentication_policy=get_authentication_policy(credential, endpoint), + base_url=self._endpoint.rstrip('/') + "/v1", **kwargs ) self._query_op = self._client.query diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py index 424915b0bc49..7c49bbac5df2 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py @@ -38,15 +38,14 @@ class LogsQueryClient(object): """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - audience = kwargs.pop("audience", None) - endpoint = kwargs.pop("endpoint", "https://api.loganalytics.io/v1") + endpoint = kwargs.pop("endpoint", "https://api.loganalytics.io") if not endpoint.startswith("https://") and not endpoint.startswith("http://"): endpoint = "https://" + endpoint self._endpoint = endpoint self._client = MonitorQueryClient( credential=credential, - authentication_policy=get_authentication_policy(credential, "https://api.loganalytics.io"), - base_url=self._endpoint, + authentication_policy=get_authentication_policy(credential, endpoint), + base_url=self._endpoint.rstrip('/') + "/v1", **kwargs ) self._query_op = self._client.query