Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# pylint: disable=anomalous-backslash-in-string

from typing import TYPE_CHECKING, Any, Union
from typing import TYPE_CHECKING, Any

from ._generated._monitor_query_client import (
MonitorQueryClient,
Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(self, credential, **kwargs):
self._namespace_op = self._client.metric_namespaces
self._definitions_op = self._client.metric_definitions

async def query(self, resource_uri, metricnames, **kwargs):
def query(self, resource_uri, metricnames, **kwargs):
# type: (str, list, Any) -> MetricsResult
"""Lists the metric values for a resource.

Expand Down Expand Up @@ -82,9 +82,9 @@ async def query(self, resource_uri, metricnames, **kwargs):
:raises: ~azure.core.exceptions.HttpResponseError
"""
kwargs.setdefault("metricnames", ",".join(metricnames))
return await self._metrics_op.list(resource_uri, connection_verify=False, **kwargs)
return self._metrics_op.list(resource_uri, connection_verify=False, **kwargs)

async def list_metric_namespaces(self, resource_uri, **kwargs):
def list_metric_namespaces(self, resource_uri, **kwargs):
# type: (str, Any) -> ItemPaged[MetricNamespace]
"""Lists the metric namespaces for the resource.

Expand All @@ -97,9 +97,9 @@ async def list_metric_namespaces(self, resource_uri, **kwargs):
:rtype: ~azure.core.paging.ItemPaged[~azure.monitor.query.MetricNamespace]
:raises: ~azure.core.exceptions.HttpResponseError
"""
return await self._namespace_op.list(resource_uri, **kwargs)
return self._namespace_op.list(resource_uri, **kwargs)

async def list_metric_definitions(self, resource_uri, **kwargs):
def list_metric_definitions(self, resource_uri, **kwargs):
# type: (str, Any) -> ItemPaged[MetricDefinition]
"""Lists the metric definitions for the resource.

Expand All @@ -111,15 +111,18 @@ async def list_metric_definitions(self, resource_uri, **kwargs):
:rtype: ~azure.core.paging.ItemPaged[~azure.monitor.query.MetricDefinition]
:raises: ~azure.core.exceptions.HttpResponseError
"""
return await self._namespace_op.list(resource_uri, **kwargs)
return self._namespace_op.list(resource_uri, **kwargs)

async def __aenter__(self) -> "MetricsClient":
await self._client.__aenter__()
return self
def close(self):
# type: () -> None
"""Close the :class:`~azure.monitor.query.MetricsClient` session."""
return self._client.close()

async def __aexit__(self, *args: "Any") -> None:
await self._client.__aexit__(*args)
def __enter__(self):
# type: () -> MetricsClient
self._client.__enter__() # pylint:disable=no-member
return self

async def close(self) -> None:
"""Close the :class:`~azure.monitor.query.aio.MetricsClient` session."""
await self._client.__aexit__()
def __exit__(self, *args):
# type: (*Any) -> None
self._client.__exit__(*args) # pylint:disable=no-member
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

# pylint: disable=anomalous-backslash-in-string

from typing import TYPE_CHECKING, Any, Union
from typing import TYPE_CHECKING, Any

from ._generated._monitor_query_client import (
from .._generated.aio._monitor_query_client import (
MonitorQueryClient,
)

from ._helpers import get_authentication_policy
from .._helpers import get_authentication_policy

if TYPE_CHECKING:
from azure.core.credentials import TokenCredential
from azure.core.paging import ItemPaged
from ._models import MetricsResult, MetricNamespace, MetricDefinition
from .._models import MetricsResult, MetricNamespace, MetricDefinition


class MetricsClient(object):
Expand All @@ -39,7 +39,7 @@ def __init__(self, credential, **kwargs):
self._namespace_op = self._client.metric_namespaces
self._definitions_op = self._client.metric_definitions

def query(self, resource_uri, metricnames, **kwargs):
async def query(self, resource_uri, metricnames, **kwargs):
# type: (str, list, Any) -> MetricsResult
"""Lists the metric values for a resource.

Expand Down Expand Up @@ -82,9 +82,9 @@ def query(self, resource_uri, metricnames, **kwargs):
:raises: ~azure.core.exceptions.HttpResponseError
"""
kwargs.setdefault("metricnames", ",".join(metricnames))
return self._metrics_op.list(resource_uri, connection_verify=False, **kwargs)
return await self._metrics_op.list(resource_uri, connection_verify=False, **kwargs)

def list_metric_namespaces(self, resource_uri, **kwargs):
async def list_metric_namespaces(self, resource_uri, **kwargs):
# type: (str, Any) -> ItemPaged[MetricNamespace]
"""Lists the metric namespaces for the resource.

Expand All @@ -97,9 +97,9 @@ def list_metric_namespaces(self, resource_uri, **kwargs):
:rtype: ~azure.core.paging.ItemPaged[~azure.monitor.query.MetricNamespace]
:raises: ~azure.core.exceptions.HttpResponseError
"""
return self._namespace_op.list(resource_uri, **kwargs)
return await self._namespace_op.list(resource_uri, **kwargs)

def list_metric_definitions(self, resource_uri, **kwargs):
async def list_metric_definitions(self, resource_uri, **kwargs):
# type: (str, Any) -> ItemPaged[MetricDefinition]
"""Lists the metric definitions for the resource.

Expand All @@ -111,18 +111,15 @@ def list_metric_definitions(self, resource_uri, **kwargs):
:rtype: ~azure.core.paging.ItemPaged[~azure.monitor.query.MetricDefinition]
:raises: ~azure.core.exceptions.HttpResponseError
"""
return self._namespace_op.list(resource_uri, **kwargs)
return await self._namespace_op.list(resource_uri, **kwargs)

def close(self):
# type: () -> None
"""Close the :class:`~azure.monitor.query.MetricsClient` session."""
return self._client.close()

def __enter__(self):
# type: () -> MetricsClient
self._client.__enter__() # pylint:disable=no-member
async def __aenter__(self) -> "MetricsClient":
await self._client.__aenter__()
return self

def __exit__(self, *args):
# type: (*Any) -> None
self._client.__exit__(*args) # pylint:disable=no-member
async def __aexit__(self, *args: "Any") -> None:
await self._client.__aexit__(*args)

async def close(self) -> None:
"""Close the :class:`~azure.monitor.query.aio.MetricsClient` session."""
await self._client.__aexit__()