Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare monitor for release #24332

Merged
merged 4 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 (2021-05-06)
rakshith91 marked this conversation as resolved.
Show resolved Hide resolved

- 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