From c85c9d7291103db8ffe88642c00773054502457f Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Fri, 6 May 2022 10:48:05 -0700 Subject: [PATCH 1/4] doc changes --- .../azure/monitor/query/_logs_query_client.py | 20 +++++++++++------- .../azure/monitor/query/_models.py | 21 +++++++++++-------- 2 files changed, 24 insertions(+), 17 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 b4621a3eb143..7fd0f143910c 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 @@ -5,7 +5,7 @@ # license information. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Any, Union, Sequence, Dict, List, cast +from typing import TYPE_CHECKING, Any, Union, Sequence, Dict, List, cast, Tuple from azure.core.exceptions import HttpResponseError from azure.core.tracing.decorator import distributed_trace @@ -66,8 +66,16 @@ def __init__(self, credential, **kwargs): self._query_op = self._client.query @distributed_trace - def query_workspace(self, workspace_id, query, **kwargs): - # type: (str, str, Any) -> Union[LogsQueryResult, LogsQueryPartialResult] + def query_workspace( + self, + workspace_id: str, + query: str, + *, + timespan: Union[ + timedelta, Tuple[datetime, timedelta], Tuple[datetime, datetime] + ], + **kwargs: Any + ) -> Union[LogsQueryResult, LogsQueryPartialResult]: """Execute a Kusto query. Executes a Kusto query for data. @@ -104,11 +112,7 @@ def query_workspace(self, workspace_id, query, **kwargs): :dedent: 0 :caption: Get a response for a single Log Query """ - if "timespan" not in kwargs: - raise TypeError( - "query() missing 1 required keyword-only argument: 'timespan'" - ) - timespan = construct_iso8601(kwargs.pop("timespan")) + timespan = construct_iso8601(timespan) include_statistics = kwargs.pop("include_statistics", False) include_visualization = kwargs.pop("include_visualization", False) server_timeout = kwargs.pop("server_timeout", None) 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 ffd9a864b30a..0cf49c50d8ec 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,8 @@ from enum import Enum import uuid -from typing import Any, Optional, List +from datetime import datetime, timedelta +from typing import Any, Optional, List, Union, Tuple from azure.core import CaseInsensitiveEnumMeta from ._helpers import construct_iso8601, process_row @@ -189,13 +190,15 @@ class LogsBatchQuery(object): """ def __init__( - self, workspace_id, query, **kwargs - ): # pylint: disable=super-init-not-called - # type: (str, str, Any) -> None - if "timespan" not in kwargs: - raise TypeError( - "LogsBatchQuery() missing 1 required keyword-only argument: 'timespan'" - ) + self, + workspace_id: str, + query: str, + *, + timespan: Union[ + timedelta, Tuple[datetime, timedelta], Tuple[datetime, datetime] + ], + **kwargs: Any + ) -> None: # pylint: disable=super-init-not-called include_statistics = kwargs.pop("include_statistics", False) include_visualization = kwargs.pop("include_visualization", False) server_timeout = kwargs.pop("server_timeout", None) @@ -212,7 +215,7 @@ def __init__( prefer += "include-render=true" headers = {"Prefer": prefer} - timespan = construct_iso8601(kwargs.pop("timespan")) + timespan = construct_iso8601(timespan) additional_workspaces = kwargs.pop("additional_workspaces", None) self.id = str(uuid.uuid4()) self.body = { From 7b6c6a7a6e5afe74a28e2c2588a5ea2c91ed75c0 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Fri, 6 May 2022 10:48:46 -0700 Subject: [PATCH 2/4] changelog --- sdk/monitor/azure-monitor-query/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index 62dcea1bbd27..51ab8547e9f8 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.0.2 (Unreleased) +## 1.0.2 (2021-05-06) - This version and all future versions will require Python 3.6+. Python 2.7 is no longer supported. From 9da19af3c01a94d2ec8eec9658fc4c5dbb07b26e Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Fri, 6 May 2022 11:02:34 -0700 Subject: [PATCH 3/4] oops --- .../azure/monitor/query/_logs_query_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7fd0f143910c..f55787a4ba1a 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 @@ -6,6 +6,7 @@ # -------------------------------------------------------------------------- from typing import TYPE_CHECKING, Any, Union, Sequence, Dict, List, cast, Tuple +from datetime import timedelta, datetime from azure.core.exceptions import HttpResponseError from azure.core.tracing.decorator import distributed_trace @@ -24,7 +25,6 @@ if TYPE_CHECKING: from azure.core.credentials import TokenCredential - from datetime import timedelta, datetime class LogsQueryClient(object): # pylint: disable=client-accepts-api-version-keyword From 21f6fa0f5510d865354718a5e6094039fcb192e7 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Fri, 6 May 2022 12:02:53 -0700 Subject: [PATCH 4/4] Update sdk/monitor/azure-monitor-query/CHANGELOG.md --- sdk/monitor/azure-monitor-query/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index 51ab8547e9f8..f325ff0921eb 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.0.2 (2021-05-06) +## 1.0.2 (2022-05-06) - This version and all future versions will require Python 3.6+. Python 2.7 is no longer supported.