Skip to content

Commit 2c72db1

Browse files
authored
Prepare monitor for release (Azure#24332)
* doc changes * changelog * oops
1 parent 11d1e5d commit 2c72db1

3 files changed

Lines changed: 26 additions & 19 deletions

File tree

sdk/monitor/azure-monitor-query/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release History
22

3-
## 1.0.2 (Unreleased)
3+
## 1.0.2 (2022-05-06)
44

55
- This version and all future versions will require Python 3.6+. Python 2.7 is no longer supported.
66

sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
# license information.
66
# --------------------------------------------------------------------------
77

8-
from typing import TYPE_CHECKING, Any, Union, Sequence, Dict, List, cast
8+
from typing import TYPE_CHECKING, Any, Union, Sequence, Dict, List, cast, Tuple
9+
from datetime import timedelta, datetime
910
from azure.core.exceptions import HttpResponseError
1011
from azure.core.tracing.decorator import distributed_trace
1112

@@ -24,7 +25,6 @@
2425

2526
if TYPE_CHECKING:
2627
from azure.core.credentials import TokenCredential
27-
from datetime import timedelta, datetime
2828

2929

3030
class LogsQueryClient(object): # pylint: disable=client-accepts-api-version-keyword
@@ -66,8 +66,16 @@ def __init__(self, credential, **kwargs):
6666
self._query_op = self._client.query
6767

6868
@distributed_trace
69-
def query_workspace(self, workspace_id, query, **kwargs):
70-
# type: (str, str, Any) -> Union[LogsQueryResult, LogsQueryPartialResult]
69+
def query_workspace(
70+
self,
71+
workspace_id: str,
72+
query: str,
73+
*,
74+
timespan: Union[
75+
timedelta, Tuple[datetime, timedelta], Tuple[datetime, datetime]
76+
],
77+
**kwargs: Any
78+
) -> Union[LogsQueryResult, LogsQueryPartialResult]:
7179
"""Execute a Kusto query.
7280
7381
Executes a Kusto query for data.
@@ -104,11 +112,7 @@ def query_workspace(self, workspace_id, query, **kwargs):
104112
:dedent: 0
105113
:caption: Get a response for a single Log Query
106114
"""
107-
if "timespan" not in kwargs:
108-
raise TypeError(
109-
"query() missing 1 required keyword-only argument: 'timespan'"
110-
)
111-
timespan = construct_iso8601(kwargs.pop("timespan"))
115+
timespan = construct_iso8601(timespan)
112116
include_statistics = kwargs.pop("include_statistics", False)
113117
include_visualization = kwargs.pop("include_visualization", False)
114118
server_timeout = kwargs.pop("server_timeout", None)

sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
from enum import Enum
99
import uuid
10-
from typing import Any, Optional, List
10+
from datetime import datetime, timedelta
11+
from typing import Any, Optional, List, Union, Tuple
1112
from azure.core import CaseInsensitiveEnumMeta
1213

1314
from ._helpers import construct_iso8601, process_row
@@ -189,13 +190,15 @@ class LogsBatchQuery(object):
189190
"""
190191

191192
def __init__(
192-
self, workspace_id, query, **kwargs
193-
): # pylint: disable=super-init-not-called
194-
# type: (str, str, Any) -> None
195-
if "timespan" not in kwargs:
196-
raise TypeError(
197-
"LogsBatchQuery() missing 1 required keyword-only argument: 'timespan'"
198-
)
193+
self,
194+
workspace_id: str,
195+
query: str,
196+
*,
197+
timespan: Union[
198+
timedelta, Tuple[datetime, timedelta], Tuple[datetime, datetime]
199+
],
200+
**kwargs: Any
201+
) -> None: # pylint: disable=super-init-not-called
199202
include_statistics = kwargs.pop("include_statistics", False)
200203
include_visualization = kwargs.pop("include_visualization", False)
201204
server_timeout = kwargs.pop("server_timeout", None)
@@ -212,7 +215,7 @@ def __init__(
212215
prefer += "include-render=true"
213216

214217
headers = {"Prefer": prefer}
215-
timespan = construct_iso8601(kwargs.pop("timespan"))
218+
timespan = construct_iso8601(timespan)
216219
additional_workspaces = kwargs.pop("additional_workspaces", None)
217220
self.id = str(uuid.uuid4())
218221
self.body = {

0 commit comments

Comments
 (0)