diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_client.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_client.py index 428247c60f5d..cfc109590480 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_client.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_client.py @@ -22,6 +22,7 @@ EnrichmentStatusQueryOption, SeriesIdentity, FeedbackDimensionFilter, + DimensionGroupIdentity, ) from ._generated import MicrosoftAzureMetricsAdvisorRESTAPIOpenAPIV2 as _Client from ._helpers import convert_to_sub_feedback, convert_datetime, get_authentication_policy @@ -378,7 +379,8 @@ def _list_anomalies_for_detection_configuration(self, detection_configuration_id # type: (...) -> ItemPaged[DataPointAnomaly] skip = kwargs.pop('skip', None) - filter_condition = kwargs.pop('filter', None) + condition = kwargs.pop('filter', None) + filter_condition = condition._to_generated() if condition else None converted_start_time = convert_datetime(start_time) converted_end_time = convert_datetime(end_time) detection_anomaly_result_query = DetectionAnomalyResultQuery( @@ -496,7 +498,7 @@ def list_anomaly_dimension_values( :param Union[str, datetime.datetime] start_time: start time filter under chosen time mode. :param Union[str, datetime.datetime] end_time: end time filter under chosen time mode. :keyword int skip: - :paramtype dimension_filter: ~azure.ai.metricsadvisor.models.DimensionGroupIdentity + :keyword Dict[str, str] dimension_filter: filter specfic dimension name and values. :return: Dimension values of anomalies. :rtype: ~azure.core.paging.ItemPaged[str] :raises ~azure.core.exceptions.HttpResponseError: @@ -512,7 +514,8 @@ def list_anomaly_dimension_values( """ skip = kwargs.pop('skip', None) - dimension_filter = kwargs.pop('dimension_filter', None) + dimension = kwargs.pop('dimension_filter', None) + dimension_filter = DimensionGroupIdentity(dimension=dimension) converted_start_time = convert_datetime(start_time) converted_end_time = convert_datetime(end_time) anomaly_dimension_query = AnomalyDimensionQuery( @@ -543,7 +546,8 @@ def _list_incidents_for_alert(self, alert_configuration_id, alert_id, **kwargs): def _list_incidents_for_detection_configuration(self, detection_configuration_id, start_time, end_time, **kwargs): # type: (str, Union[str, datetime.datetime], Union[str, datetime.datetime], Any) -> ItemPaged[AnomalyIncident] - filter_condition = kwargs.pop('filter', None) + condition = kwargs.pop('filter', None) + filter_condition = condition._to_generated() if condition else None converted_start_time = convert_datetime(start_time) converted_end_time = convert_datetime(end_time) diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/aio/_metrics_advisor_client_async.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/aio/_metrics_advisor_client_async.py index b3bcc2df2e8e..2e84b0f87798 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/aio/_metrics_advisor_client_async.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/aio/_metrics_advisor_client_async.py @@ -26,6 +26,7 @@ TimeMode as AlertQueryTimeMode, SeriesIdentity, FeedbackDimensionFilter, + DimensionGroupIdentity, ) from .._generated.aio import MicrosoftAzureMetricsAdvisorRESTAPIOpenAPIV2 as _ClientAsync from .._helpers import convert_to_sub_feedback, convert_datetime, get_authentication_policy @@ -378,7 +379,8 @@ def _list_anomalies_for_detection_configuration( # type: (...) -> AsyncItemPaged[DataPointAnomaly] skip = kwargs.pop('skip', None) - filter_condition = kwargs.pop('filter', None) + condition = kwargs.pop('filter', None) + filter_condition = condition._to_generated() if condition else None converted_start_time = convert_datetime(start_time) converted_end_time = convert_datetime(end_time) detection_anomaly_result_query = DetectionAnomalyResultQuery( @@ -494,7 +496,7 @@ def list_anomaly_dimension_values( :param Union[str, datetime.datetime] start_time: start time filter under chosen time mode. :param Union[str, datetime.datetime] end_time: end time filter under chosen time mode. :keyword int skip: - :paramtype dimension_filter: ~azure.ai.metricsadvisor.models.DimensionGroupIdentity + :keyword Dict[str, str] dimension_filter: filter specfic dimension name and values. :return: Dimension values of anomalies. :rtype: ~azure.core.async_paging.AsyncItemPaged[str] :raises ~azure.core.exceptions.HttpResponseError: @@ -510,7 +512,8 @@ def list_anomaly_dimension_values( """ skip = kwargs.pop('skip', None) - dimension_filter = kwargs.pop('dimension_filter', None) + dimension = kwargs.pop('dimension_filter', None) + dimension_filter = DimensionGroupIdentity(dimension=dimension) converted_start_time = convert_datetime(start_time) converted_end_time = convert_datetime(end_time) anomaly_dimension_query = AnomalyDimensionQuery( @@ -545,7 +548,8 @@ def _list_incidents_for_detection_configuration( **kwargs: Any ) -> AsyncItemPaged[AnomalyIncident]: - filter_condition = kwargs.pop('filter', None) + condition = kwargs.pop('filter', None) + filter_condition = condition._to_generated() if condition else None converted_start_time = convert_datetime(start_time) converted_end_time = convert_datetime(end_time) diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/__init__.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/__init__.py index c79ec7e14c01..3d2d24af780b 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/__init__.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/__init__.py @@ -47,7 +47,6 @@ from .._generated.models import ( FeedbackQueryTimeMode, RootCause, - DetectionAnomalyFilterCondition, DimensionGroupIdentity, DetectionIncidentFilterCondition, EnrichmentStatus, @@ -120,6 +119,7 @@ DatasourceServicePrincipalInKeyVault, DatasourceCredential, DataFeedSource, + DetectionAnomalyFilterCondition, ) diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/_models.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/_models.py index b05aba2c821a..2f0fb60b08a9 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/_models.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/_models.py @@ -94,6 +94,7 @@ ServicePrincipalInKVParamPatch as _ServicePrincipalInKVParamPatch, ServicePrincipalInKVCredential as _ServicePrincipalInKVCredential, ServicePrincipalInKVParam as _ServicePrincipalInKVParam, + DetectionAnomalyFilterCondition as _DetectionAnomalyFilterCondition, ) if TYPE_CHECKING: @@ -3841,3 +3842,40 @@ def _to_generated_patch(self): data_source_credential_description=self.description, parameters=param_patch, ) + +class DetectionAnomalyFilterCondition(msrest.serialization.Model): + """DetectionAnomalyFilterCondition. + + :param series_group_key: dimension filter. + :type series_group_key: dict[str, str] + :param severity_filter: + :type severity_filter: ~azure.ai.metricsadvisor.models.SeverityFilterCondition + """ + + _attribute_map = { + 'series_group_key': {'key': 'seriesGroupKey', 'type': '{str}'}, + 'severity_filter': {'key': 'severityFilter', 'type': 'SeverityFilterCondition'}, + } + + def __init__( + self, + **kwargs + ): + super(DetectionAnomalyFilterCondition, self).__init__(**kwargs) + self.series_group_key = kwargs.get('series_group_key', None) + self.severity_filter = kwargs.get('severity_filter', None) + + @classmethod + def _from_generated(cls, source): + series_group_key = source.dimension_filter.dimension if source.dimension_filter else None + return cls( + series_group_key=series_group_key, + severity_filter=source.severity_filter.key_vault_endpoint + ) + + def _to_generated(self): + dimension_filter = _DimensionGroupIdentity(dimension=self.series_group_key) + return _DetectionAnomalyFilterCondition( + dimension_filter=dimension_filter, + severity_filter=self.severity_filter + )