Skip to content

Commit

Permalink
Prepare monitor for release (Azure#24332)
Browse files Browse the repository at this point in the history
* doc changes

* changelog

* oops
  • Loading branch information
rakshith91 authored May 18, 2022
1 parent 11d1e5d commit 2c72db1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion sdk/monitor/azure-monitor-query/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release History

## 1.0.2 (Unreleased)
## 1.0.2 (2022-05-06)

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# 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 datetime import timedelta, datetime
from azure.core.exceptions import HttpResponseError
from azure.core.tracing.decorator import distributed_trace

Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
21 changes: 12 additions & 9 deletions sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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 = {
Expand Down

0 comments on commit 2c72db1

Please sign in to comment.