diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index ddd660be7f11..11fa24cf682f 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -11,6 +11,11 @@ - `include_render` is now renamed to `include_visualization` in the query API. - `LogsQueryResult` and `LogsBatchQueryResult` now return `visualization` instead of `render`. - `start_time`, `duration` and `end_time` are now replaced with a single param called `timespan` +- `resourceregion` is renamed to `resource_region` in the MetricResult type. +- `top` is renamed to `max_results` in the metric's `query` API. +- `metric_namespace_name` is renamed to `fully_qualified_namespace` +- `is_dimension_required` is renamed to `dimension_required` +- `time_grain` is renamed to `granularity` ### Bugs Fixed diff --git a/sdk/monitor/azure-monitor-query/README.md b/sdk/monitor/azure-monitor-query/README.md index 4805006ccdb1..336a887da4e5 100644 --- a/sdk/monitor/azure-monitor-query/README.md +++ b/sdk/monitor/azure-monitor-query/README.md @@ -297,7 +297,7 @@ MetricsResult |---timespan |---cost |---namespace -|---resourceregion +|---resource_region |---metrics (list of `Metric` objects) |---id |---type diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_metrics_query_client.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_metrics_query_client.py index 4f0e4a5fe53b..0b45d1bc10b3 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_metrics_query_client.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_metrics_query_client.py @@ -73,10 +73,10 @@ def query(self, resource_uri, metric_names, **kwargs): :keyword aggregations: The list of aggregation types to retrieve. Use `azure.monitor.query.AggregationType` enum to get each aggregation type. :paramtype aggregations: list[str] - :keyword top: The maximum number of records to retrieve. + :keyword max_results: The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10. - :paramtype top: int + :paramtype max_results: int :keyword orderby: The aggregation to use for sorting results and the direction of the sort. Only one order can be specified. Examples: sum asc. @@ -116,6 +116,7 @@ def query(self, resource_uri, metric_names, **kwargs): timespan = construct_iso8601(kwargs.pop("timespan", None)) kwargs.setdefault("metricnames", ",".join(metric_names)) kwargs.setdefault("timespan", timespan) + kwargs.setdefault("top", kwargs.pop("max_results", None)) generated = self._metrics_op.list(resource_uri, connection_verify=False, **kwargs) return MetricsResult._from_generated(generated) # pylint: disable=protected-access 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 79e36c32f3cf..400f9f19f04a 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -121,8 +121,8 @@ class MetricsResult(object): :vartype interval: ~datetime.timedelta :ivar namespace: The namespace of the metrics that has been queried. :vartype namespace: str - :ivar resourceregion: The region of the resource that has been queried for metrics. - :vartype resourceregion: str + :ivar resource_region: The region of the resource that has been queried for metrics. + :vartype resource_region: str :ivar metrics: Required. The value of the collection. :vartype metrics: list[~monitor_query_client.models.Metric] """ @@ -132,7 +132,7 @@ def __init__(self, **kwargs): self.timespan = kwargs["timespan"] self.interval = kwargs.get("interval", None) self.namespace = kwargs.get("namespace", None) - self.resourceregion = kwargs.get("resourceregion", None) + self.resource_region = kwargs.get("resource_region", None) self.metrics = kwargs["metrics"] @classmethod @@ -144,7 +144,7 @@ def _from_generated(cls, generated): timespan=generated.timespan, interval=generated.interval, namespace=generated.namespace, - resourceregion=generated.resourceregion, + resource_region=generated.resourceregion, metrics=[Metric._from_generated(m) for m in generated.value] # pylint: disable=protected-access ) @@ -302,8 +302,8 @@ class MetricNamespace(object): :paramtype type: str :keyword name: The name of the namespace. :paramtype name: str - :keyword metric_namespace_name: The fully qualified namespace name. - :paramtype metric_namespace_name: str + :keyword fully_qualified_namespace: The fully qualified namespace name. + :paramtype fully_qualified_namespace: str """ def __init__( self, @@ -312,27 +312,27 @@ def __init__( self.id = kwargs.get('id', None) self.type = kwargs.get('type', None) self.name = kwargs.get('name', None) - self.metric_namespace_name = kwargs.get('metric_namespace_name', None) + self.fully_qualified_namespace = kwargs.get('fully_qualified_namespace', None) @classmethod def _from_generated(cls, generated): if not generated: return cls() - metric_namespace_name = None + fully_qualified_namespace = None if generated.properties: - metric_namespace_name = generated.properties.metric_namespace_name + fully_qualified_namespace = generated.properties.metric_namespace_name return cls( id=generated.id, type=generated.type, name=generated.name, - metric_namespace_name=metric_namespace_name + fully_qualified_namespace=fully_qualified_namespace ) class MetricDefinition(object): """Metric definition class specifies the metadata for a metric. - :keyword is_dimension_required: Flag to indicate whether the dimension is required. - :paramtype is_dimension_required: bool + :keyword dimension_required: Flag to indicate whether the dimension is required. + :paramtype dimension_required: bool :keyword resource_id: the resource identifier of the resource that emitted the metric. :paramtype resource_id: str :keyword namespace: the namespace the metric belongs to. @@ -363,7 +363,7 @@ def __init__( **kwargs ): # type: (Any) -> None - self.is_dimension_required = kwargs.get('is_dimension_required', None) # type: Optional[bool] + self.dimension_required = kwargs.get('dimension_required', None) # type: Optional[bool] self.resource_id = kwargs.get('resource_id', None) # type: Optional[str] self.namespace = kwargs.get('namespace', None) # type: Optional[str] self.name = kwargs.get('name', None) # type: Optional[str] @@ -382,7 +382,7 @@ def _from_generated(cls, generated): if generated.dimensions is not None: dimensions = [d.value for d in generated.dimensions] return cls( - is_dimension_required=generated.is_dimension_required, + dimension_required=generated.is_dimension_required, resource_id=generated.resource_id, namespace=generated.namespace, name=generated.name.value, @@ -552,9 +552,9 @@ class MetricAvailability(object): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. - :keyword time_grain: the time grain specifies the aggregation interval for the metric. Expressed + :keyword granularity: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. - :paramtype time_grain: ~datetime.timedelta + :paramtype granularity: ~datetime.timedelta :keyword retention: the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. :paramtype retention: ~datetime.timedelta @@ -564,7 +564,7 @@ def __init__( **kwargs ): # type: (Any) -> None - self.time_grain = kwargs.get('time_grain', None) + self.granularity = kwargs.get('granularity', None) self.retention = kwargs.get('retention', None) @classmethod @@ -572,7 +572,7 @@ def _from_generated(cls, generated): if not generated: return cls() return cls( - time_grain=generated.time_grain, + granularity=generated.time_grain, retention=generated.retention ) diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py index a7095ef6f081..69da6544cb8c 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py @@ -67,10 +67,10 @@ async def query( :keyword aggregations: The list of aggregation types to retrieve. Use `azure.monitor.query.AggregationType` enum to get each aggregation type. :paramtype aggregations: list[str] - :keyword top: The maximum number of records to retrieve. + :keyword max_results: The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10. - :paramtype top: int + :paramtype max_results: int :keyword orderby: The aggregation to use for sorting results and the direction of the sort. Only one order can be specified. Examples: sum asc. @@ -97,6 +97,7 @@ async def query( timespan = construct_iso8601(kwargs.pop('timespan', None)) kwargs.setdefault("metricnames", ",".join(metric_names)) kwargs.setdefault("timespan", timespan) + kwargs.setdefault("top", kwargs.pop("max_results", None)) aggregations = kwargs.pop("aggregations", None) if aggregations: kwargs.setdefault("aggregation", ",".join(aggregations))