From 868c0fcaf6a3c68ac281d7c21112c90492a1624d Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Tue, 29 Sep 2020 13:46:32 -0700 Subject: [PATCH 1/4] mypy work --- eng/tox/mypy_hard_failure_packages.py | 3 +- .../azure-ai-metricsadvisor/azure/__init__.py | 2 +- .../azure/ai/__init__.py | 2 +- .../azure/ai/metricsadvisor/_helpers.py | 11 ++- .../_metrics_advisor_administration_client.py | 99 ++++++++++--------- .../metricsadvisor/_metrics_advisor_client.py | 78 ++++++++------- .../_metrics_advisor_key_credential_policy.py | 2 + ...ics_advisor_administration_client_async.py | 46 +++++---- .../aio/_metrics_advisor_client_async.py | 86 ++++++++-------- .../ai/metricsadvisor/models/__init__.py | 4 +- .../azure/ai/metricsadvisor/models/_models.py | 16 +-- .../azure-ai-metricsadvisor/mypy.ini | 12 +++ 12 files changed, 202 insertions(+), 159 deletions(-) create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/mypy.ini diff --git a/eng/tox/mypy_hard_failure_packages.py b/eng/tox/mypy_hard_failure_packages.py index 4f458daf44aa..7c5f0a33de2b 100644 --- a/eng/tox/mypy_hard_failure_packages.py +++ b/eng/tox/mypy_hard_failure_packages.py @@ -10,5 +10,6 @@ "azure-eventhub", "azure-servicebus", "azure-ai-textanalytics", - "azure-ai-formrecognizer" + "azure-ai-formrecognizer", + "azure-ai-metricsadvisor" ] diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/__init__.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/__init__.py index 69e3be50dac4..0d1f7edf5dc6 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/__init__.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/__init__.py @@ -1 +1 @@ -__path__ = __import__('pkgutil').extend_path(__path__, __name__) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/__init__.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/__init__.py index 69e3be50dac4..0d1f7edf5dc6 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/__init__.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/__init__.py @@ -1 +1 @@ -__path__ = __import__('pkgutil').extend_path(__path__, __name__) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_helpers.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_helpers.py index f4023ecf83d5..e2427981585b 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_helpers.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_helpers.py @@ -13,6 +13,7 @@ import datetime import six from msrest import Serializer +from azure.core.exceptions import HttpResponseError from .models import ( DataFeedGranularityType, DataFeedGranularity, @@ -178,11 +179,11 @@ def convert_to_generated_data_feed_type( def convert_to_sub_feedback(feedback): # type: (MetricFeedback) -> Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback] if feedback.feedback_type == "Anomaly": - return AnomalyFeedback._from_generated(feedback) + return AnomalyFeedback._from_generated(feedback) # type: ignore if feedback.feedback_type == "ChangePoint": - return ChangePointFeedback._from_generated(feedback) + return ChangePointFeedback._from_generated(feedback) # type: ignore if feedback.feedback_type == "Comment": - return CommentFeedback._from_generated(feedback) + return CommentFeedback._from_generated(feedback) # type: ignore if feedback.feedback_type == "Period": - return PeriodFeedback._from_generated(feedback) - return None + return PeriodFeedback._from_generated(feedback) # type: ignore + raise HttpResponseError("Invalid feedback type returned in the response.") diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_administration_client.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_administration_client.py index f9256b97695b..a7cb662acde6 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_administration_client.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_administration_client.py @@ -11,6 +11,7 @@ Any, List, Union, + cast, TYPE_CHECKING ) import datetime @@ -18,34 +19,38 @@ from azure.core.tracing.decorator import distributed_trace from ._generated._azure_cognitive_service_metrics_advisor_restapi_open_ap_iv2 \ import AzureCognitiveServiceMetricsAdvisorRESTAPIOpenAPIV2 as _Client -from ._generated.models import AnomalyAlertingConfiguration as _AnomalyAlertingConfiguration -from ._generated.models import AzureApplicationInsightsDataFeed as _AzureApplicationInsightsDataFeed -from ._generated.models import AzureBlobDataFeed as _AzureBlobDataFeed -from ._generated.models import AzureCosmosDBDataFeed as _AzureCosmosDBDataFeed -from ._generated.models import AzureDataExplorerDataFeed as _AzureDataExplorerDataFeed -from ._generated.models import AzureTableDataFeed as _AzureTableDataFeed -from ._generated.models import HttpRequestDataFeed as _HttpRequestDataFeed -from ._generated.models import InfluxDBDataFeed as _InfluxDBDataFeed -from ._generated.models import MySqlDataFeed as _MySqlDataFeed -from ._generated.models import PostgreSqlDataFeed as _PostgreSqlDataFeed -from ._generated.models import MongoDBDataFeed as _MongoDBDataFeed -from ._generated.models import SQLServerDataFeed as _SQLServerDataFeed -from ._generated.models import AzureDataLakeStorageGen2DataFeed as _AzureDataLakeStorageGen2DataFeed -from ._generated.models import AzureDataLakeStorageGen2DataFeedPatch as _AzureDataLakeStorageGen2DataFeedPatch -from ._generated.models import ElasticsearchDataFeed as _ElasticsearchDataFeed -from ._generated.models import ElasticsearchDataFeedPatch as _ElasticsearchDataFeedPatch -from ._generated.models import AzureApplicationInsightsDataFeedPatch as _AzureApplicationInsightsDataFeedPatch -from ._generated.models import AzureBlobDataFeedPatch as _AzureBlobDataFeedPatch -from ._generated.models import AzureCosmosDBDataFeedPatch as _AzureCosmosDBDataFeedPatch -from ._generated.models import AzureDataExplorerDataFeedPatch as _AzureDataExplorerDataFeedPatch -from ._generated.models import AzureTableDataFeedPatch as _AzureTableDataFeedPatch -from ._generated.models import HttpRequestDataFeedPatch as _HttpRequestDataFeedPatch -from ._generated.models import InfluxDBDataFeedPatch as _InfluxDBDataFeedPatch -from ._generated.models import MySqlDataFeedPatch as _MySqlDataFeedPatch -from ._generated.models import PostgreSqlDataFeedPatch as _PostgreSqlDataFeedPatch -from ._generated.models import MongoDBDataFeedPatch as _MongoDBDataFeedPatch -from ._generated.models import SQLServerDataFeedPatch as _SQLServerDataFeedPatch -from ._generated.models import AnomalyDetectionConfiguration as _AnomalyDetectionConfiguration +from ._generated.models import ( + AnomalyAlertingConfiguration as _AnomalyAlertingConfiguration, + AzureApplicationInsightsDataFeed as _AzureApplicationInsightsDataFeed, + AzureBlobDataFeed as _AzureBlobDataFeed, + AzureCosmosDBDataFeed as _AzureCosmosDBDataFeed, + AzureDataExplorerDataFeed as _AzureDataExplorerDataFeed, + AzureTableDataFeed as _AzureTableDataFeed, + HttpRequestDataFeed as _HttpRequestDataFeed, + InfluxDBDataFeed as _InfluxDBDataFeed, + MySqlDataFeed as _MySqlDataFeed, + PostgreSqlDataFeed as _PostgreSqlDataFeed, + MongoDBDataFeed as _MongoDBDataFeed, + SQLServerDataFeed as _SQLServerDataFeed, + AzureDataLakeStorageGen2DataFeed as _AzureDataLakeStorageGen2DataFeed, + AzureDataLakeStorageGen2DataFeedPatch as _AzureDataLakeStorageGen2DataFeedPatch, + ElasticsearchDataFeed as _ElasticsearchDataFeed, + ElasticsearchDataFeedPatch as _ElasticsearchDataFeedPatch, + AzureApplicationInsightsDataFeedPatch as _AzureApplicationInsightsDataFeedPatch, + AzureBlobDataFeedPatch as _AzureBlobDataFeedPatch, + AzureCosmosDBDataFeedPatch as _AzureCosmosDBDataFeedPatch, + AzureDataExplorerDataFeedPatch as _AzureDataExplorerDataFeedPatch, + AzureTableDataFeedPatch as _AzureTableDataFeedPatch, + HttpRequestDataFeedPatch as _HttpRequestDataFeedPatch, + InfluxDBDataFeedPatch as _InfluxDBDataFeedPatch, + MySqlDataFeedPatch as _MySqlDataFeedPatch, + PostgreSqlDataFeedPatch as _PostgreSqlDataFeedPatch, + MongoDBDataFeedPatch as _MongoDBDataFeedPatch, + SQLServerDataFeedPatch as _SQLServerDataFeedPatch, + AnomalyDetectionConfiguration as _AnomalyDetectionConfiguration, + IngestionProgressResetOptions as _IngestionProgressResetOptions, + IngestionStatusQueryOptions as _IngestionStatusQueryOptions, +) from ._version import SDK_MONIKER from ._metrics_advisor_key_credential_policy import MetricsAdvisorKeyCredentialPolicy from ._helpers import ( @@ -218,7 +223,7 @@ def create_anomaly_alert_configuration( """ cross_metrics_operator = kwargs.pop("cross_metrics_operator", None) - response_headers = self._client.create_anomaly_alerting_configuration( + response_headers = self._client.create_anomaly_alerting_configuration( # type: ignore _AnomalyAlertingConfiguration( name=name, metric_alerting_configurations=[ @@ -289,7 +294,7 @@ def create_data_feed( options=options ) - response_headers = self._client.create_data_feed( + response_headers = self._client.create_data_feed( # type: ignore data_feed_detail, cls=lambda pipeline_response, _, response_headers: response_headers, **kwargs @@ -330,8 +335,8 @@ def create_hook( if hook.hook_type == "Webhook": hook_request = hook._to_generated(name) - response_headers = self._client.create_hook( - hook_request, + response_headers = self._client.create_hook( # type: ignore + hook_request, # type: ignore cls=lambda pipeline_response, _, response_headers: response_headers, **kwargs ) @@ -387,7 +392,7 @@ def create_metric_anomaly_detection_configuration( if series_detection_conditions else None, ) - response_headers = self._client.create_anomaly_detection_configuration( + response_headers = self._client.create_anomaly_detection_configuration( # type: ignore config, cls=lambda pipeline_response, _, response_headers: response_headers, **kwargs @@ -561,10 +566,10 @@ def refresh_data_feed_ingestion( """ self._client.reset_data_feed_ingestion_status( data_feed_id, - body={ - "start_time": start_time, - "end_time": end_time - }, + body=_IngestionProgressResetOptions( + start_time=start_time, + end_time=end_time + ), **kwargs ) @@ -963,6 +968,7 @@ def update_hook( else: hook_id = hook.id if hook.hook_type == "Email": + hook = cast(EmailHook, hook) hook_patch = hook._to_generated_patch( name=update.pop("hookName", None), description=update.pop("description", None), @@ -971,6 +977,7 @@ def update_hook( ) elif hook.hook_type == "Webhook": + hook = cast(WebHook, hook) hook_patch = hook._to_generated_patch( name=update.pop("hookName", None), description=update.pop("description", None), @@ -1021,7 +1028,7 @@ def _convert_to_hook_type(hook): return EmailHook._from_generated(hook) return WebHook._from_generated(hook) - return self._client.list_hooks( + return self._client.list_hooks( # type: ignore hook_name=hook_name, skip=skip, cls=kwargs.pop("cls", lambda hooks: [_convert_to_hook_type(hook) for hook in hooks]), @@ -1066,7 +1073,7 @@ def list_data_feeds( creator = kwargs.pop("creator", None) skip = kwargs.pop("skip", None) - return self._client.list_data_feeds( + return self._client.list_data_feeds( # type: ignore data_feed_name=data_feed_name, data_source_type=data_source_type, granularity_name=granularity_type, @@ -1101,7 +1108,7 @@ def list_anomaly_alert_configurations( :dedent: 4 :caption: List all anomaly alert configurations for specific anomaly detection configuration """ - return self._client.get_anomaly_alerting_configurations_by_anomaly_detection_configuration( + return self._client.get_anomaly_alerting_configurations_by_anomaly_detection_configuration( # type: ignore detection_configuration_id, cls=kwargs.pop("cls", lambda confs: [ AnomalyAlertConfiguration._from_generated(conf) for conf in confs @@ -1133,7 +1140,7 @@ def list_metric_anomaly_detection_configurations( :dedent: 4 :caption: List all anomaly detection configurations for a specific metric """ - return self._client.get_anomaly_detection_configurations_by_metric( + return self._client.get_anomaly_detection_configurations_by_metric( # type: ignore metric_id, cls=kwargs.pop("cls", lambda confs: [ AnomalyDetectionConfiguration._from_generated(conf) for conf in confs @@ -1174,12 +1181,12 @@ def list_data_feed_ingestion_status( skip = kwargs.pop("skip", None) - return self._client.get_data_feed_ingestion_status( + return self._client.get_data_feed_ingestion_status( # type: ignore data_feed_id=data_feed_id, - body={ - "start_time": start_time, - "end_time": end_time - }, + body=_IngestionStatusQueryOptions( + start_time=start_time, + end_time=end_time + ), skip=skip, **kwargs ) 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 e52bc11967bf..47b43260c135 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 @@ -6,7 +6,7 @@ # pylint: disable=protected-access -from typing import List, Union, Dict, TYPE_CHECKING +from typing import List, Union, Dict, Any, cast, TYPE_CHECKING import datetime from azure.core.tracing.decorator import distributed_trace @@ -51,7 +51,6 @@ if TYPE_CHECKING: from ._generated.models import ( - MetricFeedback, SeriesResult, EnrichmentStatus, MetricSeriesItem as MetricSeriesDefinition, @@ -92,7 +91,7 @@ def __init__(self, endpoint, credential, **kwargs): self._endpoint = endpoint self._credential = credential self._config.user_agent_policy = UserAgentPolicy( - sdk_moniker=SDK_MONIKER, **kwargs + base_user_agent=None, sdk_moniker=SDK_MONIKER, **kwargs ) pipeline = kwargs.get("pipeline") @@ -165,7 +164,7 @@ def _create_pipeline(self, credential, endpoint=None, aad_mode=False, **kwargs): @distributed_trace def add_feedback(self, feedback, **kwargs): - # type: (Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback], dict) -> None + # type: (Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback], Any) -> None """Create a new metric feedback. @@ -196,7 +195,7 @@ def add_feedback(self, feedback, **kwargs): @distributed_trace def get_feedback(self, feedback_id, **kwargs): - # type: (str, dict) -> Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback] + # type: (str, Any) -> Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback] """Get a metric feedback by its id. @@ -228,7 +227,7 @@ def get_feedback(self, feedback_id, **kwargs): @distributed_trace def list_feedbacks(self, metric_id, **kwargs): - # type: (str, dict) -> ItemPaged[Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback]] + # type: (str, Any) -> ItemPaged[Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback]] """List feedback on the given metric. @@ -279,7 +278,7 @@ def list_feedbacks(self, metric_id, **kwargs): time_mode=time_mode, ) - return self._client.list_metric_feedbacks( + return self._client.list_metric_feedbacks( # type: ignore skip=skip, body=feedback_filter, cls=kwargs.pop("cls", lambda result: [ @@ -290,7 +289,7 @@ def list_feedbacks(self, metric_id, **kwargs): @distributed_trace def list_incident_root_causes(self, detection_configuration_id, incident_id, **kwargs): - # type: (str, str, dict) -> ItemPaged[IncidentRootCause] + # type: (str, str, Any) -> ItemPaged[IncidentRootCause] """Query root cause for incident. @@ -306,7 +305,7 @@ def list_incident_root_causes(self, detection_configuration_id, incident_id, **k 401: ClientAuthenticationError } - return self._client.get_root_cause_of_incident_by_anomaly_detection_configuration( + return self._client.get_root_cause_of_incident_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, incident_id=incident_id, error_map=error_map, @@ -320,9 +319,9 @@ def list_incident_root_causes(self, detection_configuration_id, incident_id, **k def list_metric_enriched_series_data( self, detection_configuration_id, # type: str series, # type: Union[List[SeriesIdentity], List[Dict[str, str]]] - start_time, # type: datetime - end_time, # type: datetime - **kwargs # type: dict + start_time, # type: datetime.datetime + end_time, # type: datetime.datetime + **kwargs # type: Any ): # type: (...) -> ItemPaged[SeriesResult] """Query series enriched by anomaly detection. @@ -340,17 +339,20 @@ def list_metric_enriched_series_data( 401: ClientAuthenticationError } - detection_series_query = DetectionSeriesQuery( - start_time=start_time, - end_time=end_time, - series=[ + series_list = [ SeriesIdentity(dimension=dimension) for dimension in series if isinstance(dimension, dict) - ] or series, + ] or series + + series_list = cast(List[SeriesIdentity], series_list) + detection_series_query = DetectionSeriesQuery( + start_time=start_time, + end_time=end_time, + series=series_list ) - return self._client.get_series_by_anomaly_detection_configuration( + return self._client.get_series_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, body=detection_series_query, error_map=error_map, @@ -358,7 +360,7 @@ def list_metric_enriched_series_data( @distributed_trace def list_alerts_for_alert_configuration(self, alert_configuration_id, start_time, end_time, time_mode, **kwargs): - # type: (str, datetime, datetime, Union[str, TimeMode], dict) -> ItemPaged[Alert] + # type: (str, datetime.datetime, datetime.datetime, Union[str, TimeMode], Any) -> ItemPaged[Alert] """Query alerts under anomaly alert configuration. @@ -394,7 +396,7 @@ def list_alerts_for_alert_configuration(self, alert_configuration_id, start_time time_mode=time_mode, ) - return self._client.get_alerts_by_anomaly_alerting_configuration( + return self._client.get_alerts_by_anomaly_alerting_configuration( # type: ignore configuration_id=alert_configuration_id, skip=skip, body=alerting_result_query, @@ -404,7 +406,7 @@ def list_alerts_for_alert_configuration(self, alert_configuration_id, start_time @distributed_trace def list_anomalies_for_alert(self, alert_configuration_id, alert_id, **kwargs): - # type: (str, str, dict) -> ItemPaged[Anomaly] + # type: (str, str, Any) -> ItemPaged[Anomaly] """Query anomalies under a specific alert. @@ -431,7 +433,7 @@ def list_anomalies_for_alert(self, alert_configuration_id, alert_id, **kwargs): skip = kwargs.pop('skip', None) - return self._client.get_anomalies_from_alert_by_anomaly_alerting_configuration( + return self._client.get_anomalies_from_alert_by_anomaly_alerting_configuration( # type: ignore configuration_id=alert_configuration_id, alert_id=alert_id, skip=skip, @@ -441,7 +443,7 @@ def list_anomalies_for_alert(self, alert_configuration_id, alert_id, **kwargs): @distributed_trace def list_anomalies_for_detection_configuration(self, detection_configuration_id, start_time, end_time, **kwargs): - # type: (str, datetime, datetime, dict) -> ItemPaged[Anomaly] + # type: (str, datetime.datetime, datetime.datetime, Any) -> ItemPaged[Anomaly] """Query anomalies under anomaly detection configuration. @@ -468,7 +470,7 @@ def list_anomalies_for_detection_configuration(self, detection_configuration_id, filter=filter_condition, ) - return self._client.get_anomalies_by_anomaly_detection_configuration( + return self._client.get_anomalies_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, skip=skip, body=detection_anomaly_result_query, @@ -484,7 +486,7 @@ def list_dimension_values_for_detection_configuration( end_time, **kwargs ): - # type: (str, str, datetime, datetime, dict) -> ItemPaged[str] + # type: (str, str, datetime.datetime, datetime.datetime, Any) -> ItemPaged[str] """Query dimension values of anomalies. @@ -513,7 +515,7 @@ def list_dimension_values_for_detection_configuration( dimension_filter=dimension_filter, ) - return self._client.get_dimension_of_anomalies_by_anomaly_detection_configuration( + return self._client.get_dimension_of_anomalies_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, skip=skip, body=anomaly_dimension_query, @@ -522,7 +524,7 @@ def list_dimension_values_for_detection_configuration( @distributed_trace def list_incidents_for_alert(self, alert_configuration_id, alert_id, **kwargs): - # type: (str, str, dict) -> ItemPaged[Incident] + # type: (str, str, Any) -> ItemPaged[Incident] """Query incidents under a specific alert. @@ -541,7 +543,7 @@ def list_incidents_for_alert(self, alert_configuration_id, alert_id, **kwargs): skip = kwargs.pop('skip', None) - return self._client.get_incidents_from_alert_by_anomaly_alerting_configuration( + return self._client.get_incidents_from_alert_by_anomaly_alerting_configuration( # type: ignore configuration_id=alert_configuration_id, alert_id=alert_id, skip=skip, @@ -551,7 +553,7 @@ def list_incidents_for_alert(self, alert_configuration_id, alert_id, **kwargs): @distributed_trace def list_incidents_for_detection_configuration(self, detection_configuration_id, start_time, end_time, **kwargs): - # type: (str, datetime, datetime, dict) -> ItemPaged[Incident] + # type: (str, datetime.datetime, datetime.datetime, Any) -> ItemPaged[Incident] """Query incidents under a specific alert. @@ -577,7 +579,7 @@ def list_incidents_for_detection_configuration(self, detection_configuration_id, filter=filter_condition, ) - return self._client.get_incidents_by_anomaly_detection_configuration( + return self._client.get_incidents_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, body=detection_incident_result_query, cls=lambda objs: [Incident._from_generated(x) for x in objs], @@ -586,7 +588,7 @@ def list_incidents_for_detection_configuration(self, detection_configuration_id, @distributed_trace def list_metric_dimension_values(self, metric_id, dimension_name, **kwargs): - # type: (str, str, dict) -> ItemPaged[str] + # type: (str, str, Any) -> ItemPaged[str] """List dimension from certain metric. @@ -613,7 +615,7 @@ def list_metric_dimension_values(self, metric_id, dimension_name, **kwargs): dimension_value_filter=dimension_value_filter, ) - return self._client.get_metric_dimension( + return self._client.get_metric_dimension( # type: ignore metric_id=metric_id, body=metric_dimension_query_options, skip=skip, @@ -622,7 +624,7 @@ def list_metric_dimension_values(self, metric_id, dimension_name, **kwargs): @distributed_trace def list_metrics_series_data(self, metric_id, start_time, end_time, series_to_filter, **kwargs): - # type: (str, datetime, datetime, List[Dict[str, str]], dict) -> ItemPaged[MetricSeriesData] + # type: (str, datetime.datetime, datetime.datetime, List[Dict[str, str]], Any) -> ItemPaged[MetricSeriesData] """Get time series data from metric. @@ -646,7 +648,7 @@ def list_metrics_series_data(self, metric_id, start_time, end_time, series_to_fi series=series_to_filter, ) - return self._client.get_metric_data( + return self._client.get_metric_data( # type: ignore metric_id=metric_id, body=metric_data_query_options, error_map=error_map, @@ -655,7 +657,7 @@ def list_metrics_series_data(self, metric_id, start_time, end_time, series_to_fi @distributed_trace def list_metric_series_definitions(self, metric_id, active_since, **kwargs): - # type: (str, datetime, dict) -> ItemPaged[MetricSeriesDefinition] + # type: (str, datetime.datetime, Any) -> ItemPaged[MetricSeriesDefinition] """List series (dimension combinations) from metric. @@ -685,7 +687,7 @@ def list_metric_series_definitions(self, metric_id, active_since, **kwargs): dimension_filter=dimension_filter, ) - return self._client.get_metric_series( + return self._client.get_metric_series( # type: ignore metric_id=metric_id, body=metric_series_query_options, skip=skip, @@ -694,7 +696,7 @@ def list_metric_series_definitions(self, metric_id, active_since, **kwargs): @distributed_trace def list_metric_enrichment_status(self, metric_id, start_time, end_time, **kwargs): - # type: (str, datetime, datetime, dict) -> ItemPaged[EnrichmentStatus] + # type: (str, datetime.datetime, datetime.datetime, Any) -> ItemPaged[EnrichmentStatus] """Query anomaly detection status. @@ -717,7 +719,7 @@ def list_metric_enrichment_status(self, metric_id, start_time, end_time, **kwarg end_time=end_time, ) - return self._client.get_enrichment_status_by_metric( + return self._client.get_enrichment_status_by_metric( # type: ignore metric_id=metric_id, skip=skip, body=enrichment_status_query_option, diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_key_credential_policy.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_key_credential_policy.py index 1070537260ab..bf12f61fdc40 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_key_credential_policy.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_key_credential_policy.py @@ -4,12 +4,14 @@ # license information. # -------------------------------------------------------------------------- +from typing import Any from azure.core.pipeline.policies import SansIOHTTPPolicy from ._metrics_advisor_key_credential import MetricsAdvisorKeyCredential _API_KEY_HEADER_NAME = "Ocp-Apim-Subscription-Key" _X_API_KEY_HEADER_NAME = "x-api-key" + class MetricsAdvisorKeyCredentialPolicy(SansIOHTTPPolicy): """Adds a key header for the provided credential. diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/aio/_metrics_advisor_administration_client_async.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/aio/_metrics_advisor_administration_client_async.py index ad8ec42ab839..df20dfe0e3ca 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/aio/_metrics_advisor_administration_client_async.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/aio/_metrics_advisor_administration_client_async.py @@ -11,6 +11,7 @@ Any, List, Union, + cast ) import datetime import six @@ -18,9 +19,13 @@ from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.async_paging import AsyncItemPaged from .._generated.aio import AzureCognitiveServiceMetricsAdvisorRESTAPIOpenAPIV2 as _ClientAsync -from .._generated.models import AnomalyAlertingConfiguration as _AnomalyAlertingConfiguration -from .._generated.models import AnomalyDetectionConfiguration as _AnomalyDetectionConfiguration -from .._generated.models import IngestionStatus as DataFeedIngestionStatus +from .._generated.models import ( + AnomalyAlertingConfiguration as _AnomalyAlertingConfiguration, + AnomalyDetectionConfiguration as _AnomalyDetectionConfiguration, + IngestionStatus as DataFeedIngestionStatus, + IngestionProgressResetOptions as _IngestionProgressResetOptions, + IngestionStatusQueryOptions as _IngestionStatusQueryOptions, +) from .._version import SDK_MONIKER from .._metrics_advisor_key_credential import MetricsAdvisorKeyCredential from .._metrics_advisor_key_credential_policy import MetricsAdvisorKeyCredentialPolicy @@ -138,7 +143,7 @@ async def create_anomaly_alert_configuration( cls=lambda pipeline_response, _, response_headers: response_headers, **kwargs ) - + response_headers = cast(dict, response_headers) config_id = response_headers["Location"].split("configurations/")[1] return await self.get_anomaly_alert_configuration(config_id) @@ -201,6 +206,7 @@ async def create_data_feed( cls=lambda pipeline_response, _, response_headers: response_headers, **kwargs ) + response_headers = cast(dict, response_headers) data_feed_id = response_headers["Location"].split("dataFeeds/")[1] return await self.get_data_feed(data_feed_id) @@ -238,10 +244,11 @@ async def create_hook( hook_request = hook._to_generated(name) response_headers = await self._client.create_hook( - hook_request, + hook_request, # type: ignore cls=lambda pipeline_response, _, response_headers: response_headers, **kwargs ) + response_headers = cast(dict, response_headers) hook_id = response_headers["Location"].split("hooks/")[1] return await self.get_hook(hook_id) @@ -299,6 +306,7 @@ async def create_metric_anomaly_detection_configuration( cls=lambda pipeline_response, _, response_headers: response_headers, **kwargs ) + response_headers = cast(dict, response_headers) config_id = response_headers["Location"].split("configurations/")[1] return await self.get_metric_anomaly_detection_configuration(config_id) @@ -468,10 +476,10 @@ async def refresh_data_feed_ingestion( """ await self._client.reset_data_feed_ingestion_status( data_feed_id, - body={ - "start_time": start_time, - "end_time": end_time - }, + body=_IngestionProgressResetOptions( + start_time=start_time, + end_time=end_time + ), **kwargs ) @@ -866,6 +874,7 @@ async def update_hook( else: hook_id = hook.id if hook.hook_type == "Email": + hook = cast(EmailHook, hook) hook_patch = hook._to_generated_patch( name=update.pop("hookName", None), description=update.pop("description", None), @@ -874,6 +883,7 @@ async def update_hook( ) elif hook.hook_type == "Webhook": + hook = cast(WebHook, hook) hook_patch = hook._to_generated_patch( name=update.pop("hookName", None), description=update.pop("description", None), @@ -923,7 +933,7 @@ def _convert_to_hook_type(hook): return EmailHook._from_generated(hook) return WebHook._from_generated(hook) - return self._client.list_hooks( + return self._client.list_hooks( # type: ignore hook_name=hook_name, skip=skip, cls=kwargs.pop("cls", lambda hooks: [_convert_to_hook_type(hook) for hook in hooks]), @@ -967,7 +977,7 @@ def list_data_feeds( creator = kwargs.pop("creator", None) skip = kwargs.pop("skip", None) - return self._client.list_data_feeds( + return self._client.list_data_feeds( # type: ignore data_feed_name=data_feed_name, data_source_type=data_source_type, granularity_name=granularity_type, @@ -1001,7 +1011,7 @@ def list_anomaly_alert_configurations( :dedent: 4 :caption: List all anomaly alert configurations for specific anomaly detection configuration """ - return self._client.get_anomaly_alerting_configurations_by_anomaly_detection_configuration( + return self._client.get_anomaly_alerting_configurations_by_anomaly_detection_configuration( # type: ignore detection_configuration_id, cls=kwargs.pop("cls", lambda confs: [ AnomalyAlertConfiguration._from_generated(conf) for conf in confs @@ -1032,7 +1042,7 @@ def list_metric_anomaly_detection_configurations( :dedent: 4 :caption: List all anomaly detection configurations for a specific metric """ - return self._client.get_anomaly_detection_configurations_by_metric( + return self._client.get_anomaly_detection_configurations_by_metric( # type: ignore metric_id, cls=kwargs.pop("cls", lambda confs: [ AnomalyDetectionConfiguration._from_generated(conf) for conf in confs @@ -1073,12 +1083,12 @@ def list_data_feed_ingestion_status( skip = kwargs.pop("skip", None) - return self._client.get_data_feed_ingestion_status( + return self._client.get_data_feed_ingestion_status( # type: ignore data_feed_id=data_feed_id, - body={ - "start_time": start_time, - "end_time": end_time - }, + body=_IngestionStatusQueryOptions( + start_time=start_time, + end_time=end_time + ), skip=skip, **kwargs ) 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 826692dc8b75..9bc951e63987 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 @@ -6,7 +6,7 @@ # pylint:disable=protected-access -from typing import List, Union, Dict, TYPE_CHECKING +from typing import List, Union, Dict, Any, cast, TYPE_CHECKING import datetime from azure.core.tracing.decorator import distributed_trace @@ -54,7 +54,6 @@ if TYPE_CHECKING: from azure.core.async_paging import AsyncItemPaged from .._generated.models import ( - MetricFeedback, SeriesResult, EnrichmentStatus, MetricSeriesItem as MetricSeriesDefinition @@ -92,7 +91,7 @@ def __init__(self, endpoint, credential, **kwargs): self._endpoint = endpoint self._credential = credential self._config.user_agent_policy = UserAgentPolicy( - sdk_moniker=SDK_MONIKER, **kwargs + base_user_agent=None, sdk_moniker=SDK_MONIKER, **kwargs ) pipeline = kwargs.get("pipeline") @@ -164,7 +163,7 @@ def _create_pipeline(self, credential, endpoint=None, aad_mode=False, **kwargs): @distributed_trace_async async def add_feedback(self, feedback, **kwargs): - # type: (Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback], dict) -> None + # type: (Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback], Any) -> None """Create a new metric feedback. @@ -195,7 +194,7 @@ async def add_feedback(self, feedback, **kwargs): @distributed_trace_async async def get_feedback(self, feedback_id, **kwargs): - # type: (str, dict) -> Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback] + # type: (str, Any) -> Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback] """Get a metric feedback by its id. @@ -230,7 +229,7 @@ async def get_feedback(self, feedback_id, **kwargs): @distributed_trace def list_feedbacks( self, metric_id, # type: str - **kwargs # type: dict + **kwargs # type: Any ): # type: (...) -> AsyncItemPaged[Union[AnomalyFeedback, ChangePointFeedback, CommentFeedback, PeriodFeedback]] @@ -283,7 +282,7 @@ def list_feedbacks( time_mode=time_mode, ) - return self._client.list_metric_feedbacks( + return self._client.list_metric_feedbacks( # type: ignore skip=skip, body=feedback_filter, cls=kwargs.pop("cls", lambda result: [ @@ -294,7 +293,7 @@ def list_feedbacks( @distributed_trace def list_incident_root_causes(self, detection_configuration_id, incident_id, **kwargs): - # type: (str, str, dict) -> AsyncItemPaged[IncidentRootCause] + # type: (str, str, Any) -> AsyncItemPaged[IncidentRootCause] """Query root cause for incident. @@ -309,7 +308,7 @@ def list_incident_root_causes(self, detection_configuration_id, incident_id, **k error_map = { 401: ClientAuthenticationError } - return self._client.get_root_cause_of_incident_by_anomaly_detection_configuration( + return self._client.get_root_cause_of_incident_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, incident_id=incident_id, error_map=error_map, @@ -323,9 +322,9 @@ def list_incident_root_causes(self, detection_configuration_id, incident_id, **k def list_metric_enriched_series_data( self, detection_configuration_id, # type: str series, # type: Union[List[SeriesIdentity], List[Dict[str, str]]] - start_time, # type: datetime - end_time, # type: datetime - **kwargs # type: dict + start_time, # type: datetime.datetime + end_time, # type: datetime.datetime + **kwargs # type: Any ): # type: (...) -> AsyncItemPaged[SeriesResult] """Query series enriched by anomaly detection. @@ -343,17 +342,20 @@ def list_metric_enriched_series_data( 401: ClientAuthenticationError } - detection_series_query = DetectionSeriesQuery( - start_time=start_time, - end_time=end_time, - series=[ + series_list = [ SeriesIdentity(dimension=dimension) for dimension in series if isinstance(dimension, dict) - ] or series, + ] or series + + series_list = cast(List[SeriesIdentity], series_list) + detection_series_query = DetectionSeriesQuery( + start_time=start_time, + end_time=end_time, + series=series_list ) - return self._client.get_series_by_anomaly_detection_configuration( + return self._client.get_series_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, body=detection_series_query, error_map=error_map, @@ -361,7 +363,7 @@ def list_metric_enriched_series_data( @distributed_trace def list_alerts_for_alert_configuration(self, alert_configuration_id, start_time, end_time, time_mode, **kwargs): - # type: (str, datetime, datetime, Union[str, TimeMode], dict) -> AsyncItemPaged[Alert] + # type: (str, datetime.datetime, datetime.datetime, Union[str, TimeMode], Any) -> AsyncItemPaged[Alert] """Query alerts under anomaly alert configuration. :param alert_configuration_id: anomaly alert configuration unique id. @@ -396,7 +398,7 @@ def list_alerts_for_alert_configuration(self, alert_configuration_id, start_time time_mode=time_mode, ) - return self._client.get_alerts_by_anomaly_alerting_configuration( + return self._client.get_alerts_by_anomaly_alerting_configuration( # type: ignore configuration_id=alert_configuration_id, skip=skip, body=alerting_result_query, @@ -406,7 +408,7 @@ def list_alerts_for_alert_configuration(self, alert_configuration_id, start_time @distributed_trace def list_anomalies_for_alert(self, alert_configuration_id, alert_id, **kwargs): - # type: (str, str, dict) -> AsyncItemPaged[Anomaly] + # type: (str, str, Any) -> AsyncItemPaged[Anomaly] """Query anomalies under a specific alert. @@ -433,7 +435,7 @@ def list_anomalies_for_alert(self, alert_configuration_id, alert_id, **kwargs): skip = kwargs.pop('skip', None) - return self._client.get_anomalies_from_alert_by_anomaly_alerting_configuration( + return self._client.get_anomalies_from_alert_by_anomaly_alerting_configuration( # type: ignore configuration_id=alert_configuration_id, alert_id=alert_id, skip=skip, @@ -443,7 +445,7 @@ def list_anomalies_for_alert(self, alert_configuration_id, alert_id, **kwargs): @distributed_trace def list_anomalies_for_detection_configuration(self, detection_configuration_id, start_time, end_time, **kwargs): - # type: (str, datetime, datetime, dict) -> AsyncItemPaged[Anomaly] + # type: (str, datetime.datetime, datetime.datetime, Any) -> AsyncItemPaged[Anomaly] """Query anomalies under anomaly detection configuration. @@ -470,7 +472,7 @@ def list_anomalies_for_detection_configuration(self, detection_configuration_id, filter=filter_condition, ) - return self._client.get_anomalies_by_anomaly_detection_configuration( + return self._client.get_anomalies_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, skip=skip, body=detection_anomaly_result_query, @@ -486,7 +488,7 @@ def list_dimension_values_for_detection_configuration( end_time, **kwargs ): - # type: (str, str, datetime, datetime, dict) -> AsyncItemPaged[str] + # type: (str, str, datetime.datetime, datetime.datetime, Any) -> AsyncItemPaged[str] """Query dimension values of anomalies. @@ -515,7 +517,7 @@ def list_dimension_values_for_detection_configuration( dimension_filter=dimension_filter, ) - return self._client.get_dimension_of_anomalies_by_anomaly_detection_configuration( + return self._client.get_dimension_of_anomalies_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, skip=skip, body=anomaly_dimension_query, @@ -524,7 +526,7 @@ def list_dimension_values_for_detection_configuration( @distributed_trace def list_incidents_for_alert(self, alert_configuration_id, alert_id, **kwargs): - # type: (str, str, dict) -> AsyncItemPaged[Incident] + # type: (str, str, Any) -> AsyncItemPaged[Incident] """Query incidents under a specific alert. @@ -543,7 +545,7 @@ def list_incidents_for_alert(self, alert_configuration_id, alert_id, **kwargs): skip = kwargs.pop('skip', None) - return self._client.get_incidents_from_alert_by_anomaly_alerting_configuration( + return self._client.get_incidents_from_alert_by_anomaly_alerting_configuration( # type: ignore configuration_id=alert_configuration_id, alert_id=alert_id, skip=skip, @@ -553,7 +555,7 @@ def list_incidents_for_alert(self, alert_configuration_id, alert_id, **kwargs): @distributed_trace def list_incidents_for_detection_configuration(self, detection_configuration_id, start_time, end_time, **kwargs): - # type: (str, datetime, datetime, dict) -> AsyncItemPaged[Incident] + # type: (str, datetime.datetime, datetime.datetime, Any) -> AsyncItemPaged[Incident] """Query incidents under a specific alert. @@ -579,7 +581,7 @@ def list_incidents_for_detection_configuration(self, detection_configuration_id, filter=filter_condition, ) - return self._client.get_incidents_by_anomaly_detection_configuration( + return self._client.get_incidents_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, body=detection_incident_result_query, cls=lambda objs: [Incident._from_generated(x) for x in objs], @@ -588,7 +590,7 @@ def list_incidents_for_detection_configuration(self, detection_configuration_id, @distributed_trace def list_metric_dimension_values(self, metric_id, dimension_name, **kwargs): - # type: (str, str, dict) -> AsyncItemPaged[str] + # type: (str, str, Any) -> AsyncItemPaged[str] """List dimension from certain metric. @@ -615,7 +617,7 @@ def list_metric_dimension_values(self, metric_id, dimension_name, **kwargs): dimension_value_filter=dimension_value_filter, ) - return self._client.get_metric_dimension( + return self._client.get_metric_dimension( # type: ignore metric_id=metric_id, body=metric_dimension_query_options, skip=skip, @@ -623,8 +625,14 @@ def list_metric_dimension_values(self, metric_id, dimension_name, **kwargs): **kwargs) @distributed_trace - def list_metrics_series_data(self, metric_id, start_time, end_time, series_to_filter, **kwargs): - # type: (str, List[Dict[str, str]], datetime, datetime, dict) -> AsyncItemPaged[MetricSeriesData] + def list_metrics_series_data( + self, metric_id, # type: str + start_time, # type: datetime.datetime + end_time, # type: datetime.datetime + series_to_filter, # type: List[Dict[str, str]] + **kwargs # type: Any + ): + # type: (...) -> AsyncItemPaged[MetricSeriesData] """Get time series data from metric. @@ -648,7 +656,7 @@ def list_metrics_series_data(self, metric_id, start_time, end_time, series_to_fi series=series_to_filter, ) - return self._client.get_metric_data( + return self._client.get_metric_data( # type: ignore metric_id=metric_id, body=metric_data_query_options, error_map=error_map, @@ -657,7 +665,7 @@ def list_metrics_series_data(self, metric_id, start_time, end_time, series_to_fi @distributed_trace def list_metric_series_definitions(self, metric_id, active_since, **kwargs): - # type: (str, datetime, dict) -> AsyncItemPaged[MetricSeriesDefinition] + # type: (str, datetime.datetime, Any) -> AsyncItemPaged[MetricSeriesDefinition] """List series (dimension combinations) from metric. @@ -687,7 +695,7 @@ def list_metric_series_definitions(self, metric_id, active_since, **kwargs): dimension_filter=dimension_filter, ) - return self._client.get_metric_series( + return self._client.get_metric_series( # type: ignore metric_id=metric_id, body=metric_series_query_options, skip=skip, @@ -696,7 +704,7 @@ def list_metric_series_definitions(self, metric_id, active_since, **kwargs): @distributed_trace def list_metric_enrichment_status(self, metric_id, start_time, end_time, **kwargs): - # type: (str, datetime, datetime, dict) -> AsyncItemPaged[EnrichmentStatus] + # type: (str, datetime.datetime, datetime.datetime, Any) -> AsyncItemPaged[EnrichmentStatus] """Query anomaly detection status. @@ -719,7 +727,7 @@ def list_metric_enrichment_status(self, metric_id, start_time, end_time, **kwarg end_time=end_time, ) - return self._client.get_enrichment_status_by_metric( + return self._client.get_enrichment_status_by_metric( # type: ignore metric_id=metric_id, skip=skip, body=enrichment_status_query_option, 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 aceb8f41259d..38babfa94517 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 @@ -38,6 +38,7 @@ AnomalyValue, ChangePointValue, PeriodType, + FeedbackType ) from .._generated.models import ( @@ -47,7 +48,6 @@ DetectionAnomalyFilterCondition, DimensionGroupIdentity, DetectionIncidentFilterCondition, - AnomalyDetectionConfiguration, DimensionGroupConfiguration, SeriesConfiguration, EnrichmentStatus, @@ -171,7 +171,6 @@ "WebHook", "DataFeedIngestionProgress", "DetectionConditionsOperator", - "AnomalyDetectionConfiguration", "MetricAnomalyAlertConditions", "EnrichmentStatus", "DataFeedGranularityType", @@ -196,4 +195,5 @@ "AnomalyValue", "ChangePointValue", "PeriodType", + "FeedbackType" ) 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 3b494c8b4ca5..a42fad5dc5e1 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 @@ -1884,7 +1884,7 @@ def __init__( @classmethod def _from_generated(cls, anomaly_result): - # type: (AnomalyResult) -> Anomaly + # type: (AnomalyResult) -> Union[Anomaly, None] if not anomaly_result: return None severity = None @@ -1969,7 +1969,7 @@ def __init__( @classmethod def _from_generated(cls, incident_result): - # type: (IncidentResult) -> Incident + # type: (IncidentResult) -> Union[Incident, None] if not incident_result: return None dimension_key = incident_result.root_node.dimension if incident_result.root_node else None @@ -2029,7 +2029,7 @@ def __init__( @classmethod def _from_generated(cls, root_cause): - # type: (RootCause) -> IncidentRootCause + # type: (RootCause) -> Union[IncidentRootCause, None] if not root_cause: return None dimension_key = root_cause.root_cause.dimension if root_cause.root_cause else None @@ -2126,7 +2126,7 @@ def __init__( @classmethod def _from_generated(cls, anomaly_feedback): - # type: (_AnomalyFeedback) -> AnomalyFeedback + # type: (_AnomalyFeedback) -> Union[AnomalyFeedback, None] if not anomaly_feedback: return None dimension_key = anomaly_feedback.dimension_filter.dimension @@ -2236,7 +2236,7 @@ def __init__( @classmethod def _from_generated(cls, change_point_feedback): - # type: (_ChangePointFeedback) -> ChangePointFeedback + # type: (_ChangePointFeedback) -> Union[ChangePointFeedback, None] if not change_point_feedback: return None dimension_key = change_point_feedback.dimension_filter.dimension @@ -2340,7 +2340,7 @@ def __init__( @classmethod def _from_generated(cls, comment_feedback): - # type: (_CommentFeedback) -> CommentFeedback + # type: (_CommentFeedback) -> Union[CommentFeedback, None] if not comment_feedback: return None dimension_key = comment_feedback.dimension_filter.dimension @@ -2440,7 +2440,7 @@ def __init__( @classmethod def _from_generated(cls, period_feedback): - # type: (_PeriodFeedback) -> PeriodFeedback + # type: (_PeriodFeedback) -> Union[PeriodFeedback, None] if not period_feedback: return None dimension_key = period_feedback.dimension_filter.dimension @@ -2460,7 +2460,7 @@ def _to_generated(self): # type: (PeriodFeedback) -> _PeriodFeedback dimension_filter = FeedbackDimensionFilter(dimension=self.dimension_key) value = PeriodFeedbackValue(period_type=self.period_type, period_value=self.value) - return _CommentFeedback( + return _PeriodFeedback( feedback_id=self.id, created_time=self.created_time, user_principal=self.user_principal, diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/mypy.ini b/sdk/metricsadvisor/azure-ai-metricsadvisor/mypy.ini new file mode 100644 index 000000000000..7ec314633b6e --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/mypy.ini @@ -0,0 +1,12 @@ +[mypy] +python_version = 3.6 +warn_unused_configs = True +ignore_missing_imports = True + +# Per-module options: + +[mypy-azure.ai.metricsadvisor._generated.*] +ignore_errors = True + +[mypy-azure.core.*] +ignore_errors = True From 8fad5c8a0b510c774b72f4c2fba7917ea70fc542 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Tue, 29 Sep 2020 14:28:06 -0700 Subject: [PATCH 2/4] remove error map, this is done in gen code --- .../metricsadvisor/_metrics_advisor_client.py | 60 ------------------ .../aio/_metrics_advisor_client_async.py | 61 +------------------ 2 files changed, 1 insertion(+), 120 deletions(-) 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 47b43260c135..9954a45c294e 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 @@ -184,13 +184,9 @@ def add_feedback(self, feedback, **kwargs): :dedent: 4 :caption: Add new feedback. """ - error_map = { - 401: ClientAuthenticationError - } return self._client.create_metric_feedback( body=feedback._to_generated(), - error_map=error_map, **kwargs) @distributed_trace @@ -216,13 +212,9 @@ def get_feedback(self, feedback_id, **kwargs): :dedent: 4 :caption: Get a metric feedback by its id. """ - error_map = { - 401: ClientAuthenticationError - } return convert_to_sub_feedback(self._client.get_metric_feedback( feedback_id=feedback_id, - error_map=error_map, **kwargs)) @distributed_trace @@ -256,9 +248,6 @@ def list_feedbacks(self, metric_id, **kwargs): :dedent: 4 :caption: List feedback on the given metric. """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) dimension_filter = None @@ -284,7 +273,6 @@ def list_feedbacks(self, metric_id, **kwargs): cls=kwargs.pop("cls", lambda result: [ convert_to_sub_feedback(x) for x in result ]), - error_map=error_map, **kwargs) @distributed_trace @@ -301,14 +289,10 @@ def list_incident_root_causes(self, detection_configuration_id, incident_id, **k :rtype: ItemPaged[~azure.ai.metriscadvisor.models.IncidentRootCause] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } return self._client.get_root_cause_of_incident_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, incident_id=incident_id, - error_map=error_map, cls=kwargs.pop("cls", lambda result: [ IncidentRootCause._from_generated(x) for x in result ]), @@ -335,9 +319,6 @@ def list_metric_enriched_series_data( :rtype: ItemPaged[~azure.ai.metricsadvisor.models.SeriesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } series_list = [ SeriesIdentity(dimension=dimension) @@ -355,7 +336,6 @@ def list_metric_enriched_series_data( return self._client.get_series_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, body=detection_series_query, - error_map=error_map, **kwargs) @distributed_trace @@ -384,9 +364,6 @@ def list_alerts_for_alert_configuration(self, alert_configuration_id, start_time :dedent: 4 :caption: Query anomaly detection results. """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) @@ -400,7 +377,6 @@ def list_alerts_for_alert_configuration(self, alert_configuration_id, start_time configuration_id=alert_configuration_id, skip=skip, body=alerting_result_query, - error_map=error_map, cls=kwargs.pop("cls", lambda alerts: [Alert._from_generated(alert) for alert in alerts]), **kwargs) @@ -427,9 +403,6 @@ def list_anomalies_for_alert(self, alert_configuration_id, alert_id, **kwargs): :dedent: 4 :caption: Query anomalies using alert id. """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) @@ -438,7 +411,6 @@ def list_anomalies_for_alert(self, alert_configuration_id, alert_id, **kwargs): alert_id=alert_id, skip=skip, cls=lambda objs: [Anomaly._from_generated(x) for x in objs], - error_map=error_map, **kwargs) @distributed_trace @@ -458,9 +430,6 @@ def list_anomalies_for_detection_configuration(self, detection_configuration_id, :rtype: ~azure.core.paging.ItemPaged[~azure.ai.metricsadvisor.models.Anomaly] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) filter_condition = kwargs.pop('filter', None) @@ -475,7 +444,6 @@ def list_anomalies_for_detection_configuration(self, detection_configuration_id, skip=skip, body=detection_anomaly_result_query, cls=lambda objs: [Anomaly._from_generated(x) for x in objs], - error_map=error_map, **kwargs) @distributed_trace @@ -502,9 +470,6 @@ def list_dimension_values_for_detection_configuration( :rtype: ~azure.core.paging.ItemPaged[str] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) dimension_filter = kwargs.pop('dimension_filter', None) @@ -519,7 +484,6 @@ def list_dimension_values_for_detection_configuration( configuration_id=detection_configuration_id, skip=skip, body=anomaly_dimension_query, - error_map=error_map, **kwargs) @distributed_trace @@ -537,9 +501,6 @@ def list_incidents_for_alert(self, alert_configuration_id, alert_id, **kwargs): :rtype: ~azure.core.paging.ItemPaged[~azure.ai.metriscadvisor.models.Incident] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) @@ -548,7 +509,6 @@ def list_incidents_for_alert(self, alert_configuration_id, alert_id, **kwargs): alert_id=alert_id, skip=skip, cls=lambda objs: [Incident._from_generated(x) for x in objs], - error_map=error_map, **kwargs) @distributed_trace @@ -567,9 +527,6 @@ def list_incidents_for_detection_configuration(self, detection_configuration_id, :rtype: ~azure.core.paging.ItemPaged[~azure.ai.metriscadvisor.models.Incident] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } filter_condition = kwargs.pop('filter', None) @@ -583,7 +540,6 @@ def list_incidents_for_detection_configuration(self, detection_configuration_id, configuration_id=detection_configuration_id, body=detection_incident_result_query, cls=lambda objs: [Incident._from_generated(x) for x in objs], - error_map=error_map, **kwargs) @distributed_trace @@ -603,9 +559,6 @@ def list_metric_dimension_values(self, metric_id, dimension_name, **kwargs): :rtype: ~azure.core.paging.ItemPaged[str] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) dimension_value_filter = kwargs.pop('dimension_value_filter', None) @@ -619,7 +572,6 @@ def list_metric_dimension_values(self, metric_id, dimension_name, **kwargs): metric_id=metric_id, body=metric_dimension_query_options, skip=skip, - error_map=error_map, **kwargs) @distributed_trace @@ -638,9 +590,6 @@ def list_metrics_series_data(self, metric_id, start_time, end_time, series_to_fi :rtype: ItemPaged[~azure.ai.metriscadvisor.models.MetricSeriesData] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } metric_data_query_options = MetricDataQueryOptions( start_time=start_time, @@ -651,7 +600,6 @@ def list_metrics_series_data(self, metric_id, start_time, end_time, series_to_fi return self._client.get_metric_data( # type: ignore metric_id=metric_id, body=metric_data_query_options, - error_map=error_map, cls=kwargs.pop("cls", lambda result: [MetricSeriesData._from_generated(series) for series in result]), **kwargs) @@ -675,9 +623,6 @@ def list_metric_series_definitions(self, metric_id, active_since, **kwargs): :rtype: ~azure.core.paging.ItemPaged[~azure.ai.metriscadvisor.models.MetricSeriesDefinition] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) dimension_filter = kwargs.pop('dimension_filter', None) @@ -691,7 +636,6 @@ def list_metric_series_definitions(self, metric_id, active_since, **kwargs): metric_id=metric_id, body=metric_series_query_options, skip=skip, - error_map=error_map, **kwargs) @distributed_trace @@ -709,9 +653,6 @@ def list_metric_enrichment_status(self, metric_id, start_time, end_time, **kwarg :rtype: ~azure.core.paging.ItemPaged[~azure.ai.metriscadvisor.models.EnrichmentStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) enrichment_status_query_option = EnrichmentStatusQueryOption( @@ -723,5 +664,4 @@ def list_metric_enrichment_status(self, metric_id, start_time, end_time, **kwarg metric_id=metric_id, skip=skip, body=enrichment_status_query_option, - error_map=error_map, **kwargs) 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 9bc951e63987..fc23a4dcd44e 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 @@ -183,13 +183,9 @@ async def add_feedback(self, feedback, **kwargs): :dedent: 4 :caption: Add new feedback. """ - error_map = { - 401: ClientAuthenticationError - } return await self._client.create_metric_feedback( body=feedback._to_generated(), - error_map=error_map, **kwargs) @distributed_trace_async @@ -215,13 +211,9 @@ async def get_feedback(self, feedback_id, **kwargs): :dedent: 4 :caption: Get a metric feedback by its id. """ - error_map = { - 401: ClientAuthenticationError - } feedback = await self._client.get_metric_feedback( feedback_id=feedback_id, - error_map=error_map, **kwargs) return convert_to_sub_feedback(feedback) @@ -260,9 +252,6 @@ def list_feedbacks( :dedent: 4 :caption: List feedback on the given metric. """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) dimension_filter = None @@ -288,7 +277,6 @@ def list_feedbacks( cls=kwargs.pop("cls", lambda result: [ convert_to_sub_feedback(x) for x in result ]), - error_map=error_map, **kwargs) @distributed_trace @@ -305,13 +293,10 @@ def list_incident_root_causes(self, detection_configuration_id, incident_id, **k :rtype: AsyncItemPaged[~azure.ai.metriscadvisor.models.IncidentRootCause] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } + return self._client.get_root_cause_of_incident_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, incident_id=incident_id, - error_map=error_map, cls=kwargs.pop("cls", lambda result: [ IncidentRootCause._from_generated(x) for x in result ]), @@ -338,9 +323,6 @@ def list_metric_enriched_series_data( :rtype: AsyncItemPaged[~azure.ai.metricsadvisor.models.SeriesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } series_list = [ SeriesIdentity(dimension=dimension) @@ -358,7 +340,6 @@ def list_metric_enriched_series_data( return self._client.get_series_by_anomaly_detection_configuration( # type: ignore configuration_id=detection_configuration_id, body=detection_series_query, - error_map=error_map, **kwargs) @distributed_trace @@ -386,9 +367,6 @@ def list_alerts_for_alert_configuration(self, alert_configuration_id, start_time :dedent: 4 :caption: Query anomaly detection results. """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) @@ -402,7 +380,6 @@ def list_alerts_for_alert_configuration(self, alert_configuration_id, start_time configuration_id=alert_configuration_id, skip=skip, body=alerting_result_query, - error_map=error_map, cls=kwargs.pop("cls", lambda alerts: [Alert._from_generated(alert) for alert in alerts]), **kwargs) @@ -429,9 +406,6 @@ def list_anomalies_for_alert(self, alert_configuration_id, alert_id, **kwargs): :dedent: 4 :caption: Query anomalies using alert id. """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) @@ -440,7 +414,6 @@ def list_anomalies_for_alert(self, alert_configuration_id, alert_id, **kwargs): alert_id=alert_id, skip=skip, cls=lambda objs: [Anomaly._from_generated(x) for x in objs], - error_map=error_map, **kwargs) @distributed_trace @@ -460,9 +433,6 @@ def list_anomalies_for_detection_configuration(self, detection_configuration_id, :rtype: ~azure.core.paging.AsyncItemPaged[~azure.ai.metricsadvisor.models.Anomaly] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) filter_condition = kwargs.pop('filter', None) @@ -477,7 +447,6 @@ def list_anomalies_for_detection_configuration(self, detection_configuration_id, skip=skip, body=detection_anomaly_result_query, cls=lambda objs: [Anomaly._from_generated(x) for x in objs], - error_map=error_map, **kwargs) @distributed_trace @@ -504,9 +473,6 @@ def list_dimension_values_for_detection_configuration( :rtype: ~azure.core.paging.AsyncItemPaged[str] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) dimension_filter = kwargs.pop('dimension_filter', None) @@ -521,7 +487,6 @@ def list_dimension_values_for_detection_configuration( configuration_id=detection_configuration_id, skip=skip, body=anomaly_dimension_query, - error_map=error_map, **kwargs) @distributed_trace @@ -539,9 +504,6 @@ def list_incidents_for_alert(self, alert_configuration_id, alert_id, **kwargs): :rtype: ~azure.core.paging.AsyncItemPaged[~azure.ai.metriscadvisor.models.Incident] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) @@ -550,7 +512,6 @@ def list_incidents_for_alert(self, alert_configuration_id, alert_id, **kwargs): alert_id=alert_id, skip=skip, cls=lambda objs: [Incident._from_generated(x) for x in objs], - error_map=error_map, **kwargs) @distributed_trace @@ -569,9 +530,6 @@ def list_incidents_for_detection_configuration(self, detection_configuration_id, :rtype: ~azure.core.paging.AsyncItemPaged[~azure.ai.metriscadvisor.models.Incident] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } filter_condition = kwargs.pop('filter', None) @@ -585,7 +543,6 @@ def list_incidents_for_detection_configuration(self, detection_configuration_id, configuration_id=detection_configuration_id, body=detection_incident_result_query, cls=lambda objs: [Incident._from_generated(x) for x in objs], - error_map=error_map, **kwargs) @distributed_trace @@ -605,9 +562,6 @@ def list_metric_dimension_values(self, metric_id, dimension_name, **kwargs): :rtype: ~azure.core.paging.AsyncItemPaged[str] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) dimension_value_filter = kwargs.pop('dimension_value_filter', None) @@ -621,7 +575,6 @@ def list_metric_dimension_values(self, metric_id, dimension_name, **kwargs): metric_id=metric_id, body=metric_dimension_query_options, skip=skip, - error_map=error_map, **kwargs) @distributed_trace @@ -646,9 +599,6 @@ def list_metrics_series_data( :rtype: AsyncItemPaged[~azure.ai.metriscadvisor.models.MetricSeriesData] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } metric_data_query_options = MetricDataQueryOptions( start_time=start_time, @@ -659,7 +609,6 @@ def list_metrics_series_data( return self._client.get_metric_data( # type: ignore metric_id=metric_id, body=metric_data_query_options, - error_map=error_map, cls=kwargs.pop("cls", lambda result: [MetricSeriesData._from_generated(series) for series in result]), **kwargs) @@ -683,9 +632,6 @@ def list_metric_series_definitions(self, metric_id, active_since, **kwargs): :rtype: ~azure.core.paging.AsyncItemPaged[~azure.ai.metriscadvisor.models.MetricSeriesDefinition] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) dimension_filter = kwargs.pop('dimension_filter', None) @@ -699,7 +645,6 @@ def list_metric_series_definitions(self, metric_id, active_since, **kwargs): metric_id=metric_id, body=metric_series_query_options, skip=skip, - error_map=error_map, **kwargs) @distributed_trace @@ -717,9 +662,6 @@ def list_metric_enrichment_status(self, metric_id, start_time, end_time, **kwarg :rtype: ~azure.core.paging.AsyncItemPaged[~azure.ai.metriscadvisor.models.EnrichmentStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - error_map = { - 401: ClientAuthenticationError - } skip = kwargs.pop('skip', None) enrichment_status_query_option = EnrichmentStatusQueryOption( @@ -731,5 +673,4 @@ def list_metric_enrichment_status(self, metric_id, start_time, end_time, **kwarg metric_id=metric_id, skip=skip, body=enrichment_status_query_option, - error_map=error_map, **kwargs) From f978b17ce913bcf11e9122a1a4b8525e07fc8b15 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Tue, 29 Sep 2020 14:54:29 -0700 Subject: [PATCH 3/4] add back kwargs on models --- .../metricsadvisor/_metrics_advisor_client.py | 1 - .../aio/_metrics_advisor_client_async.py | 1 - .../azure/ai/metricsadvisor/models/_models.py | 92 +++++++++++-------- 3 files changed, 56 insertions(+), 38 deletions(-) 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 9954a45c294e..199ffb8a2be5 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 @@ -20,7 +20,6 @@ HttpLoggingPolicy, ) from azure.core.pipeline.transport import RequestsTransport -from azure.core.exceptions import ClientAuthenticationError from ._metrics_advisor_key_credential import MetricsAdvisorKeyCredential from ._metrics_advisor_key_credential_policy import MetricsAdvisorKeyCredentialPolicy from ._generated._configuration import AzureCognitiveServiceMetricsAdvisorRESTAPIOpenAPIV2Configuration 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 fc23a4dcd44e..5d9bdf2f680c 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 @@ -21,7 +21,6 @@ HttpLoggingPolicy, ) from azure.core.pipeline.transport import AioHttpTransport -from azure.core.exceptions import ClientAuthenticationError from .._metrics_advisor_key_credential import MetricsAdvisorKeyCredential from .._metrics_advisor_key_credential_policy import MetricsAdvisorKeyCredentialPolicy from .._generated.aio._configuration import AzureCognitiveServiceMetricsAdvisorRESTAPIOpenAPIV2Configuration 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 a42fad5dc5e1..76cada75e397 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 @@ -451,8 +451,8 @@ class TopNGroupScope(object): :type min_top_count: int """ - def __init__(self, top, period, min_top_count): - # type: (int, int, int) -> None + def __init__(self, top, period, min_top_count, **kwargs): # pylint: disable=unused-argument + # type: (int, int, int, Any) -> None self.top = top self.period = period self.min_top_count = min_top_count @@ -469,8 +469,8 @@ class SeverityCondition(object): :type max_alert_severity: str or ~azure.ai.metricsadvisor.models.Severity """ - def __init__(self, min_alert_severity, max_alert_severity): - # type: (Union[str, Severity], Union[str, Severity]) -> None + def __init__(self, min_alert_severity, max_alert_severity, **kwargs): # pylint: disable=unused-argument + # type: (Union[str, Severity], Union[str, Severity], Any) -> None self.min_alert_severity = min_alert_severity self.max_alert_severity = max_alert_severity @@ -486,8 +486,8 @@ class MetricAnomalyAlertSnoozeCondition(object): :type only_for_successive: bool """ - def __init__(self, auto_snooze, snooze_scope, only_for_successive): - # type: (int, Union[str, SnoozeScope], bool) -> None + def __init__(self, auto_snooze, snooze_scope, only_for_successive, **kwargs): # pylint: disable=unused-argument + # type: (int, Union[str, SnoozeScope], bool, Any) -> None self.auto_snooze = auto_snooze self.snooze_scope = snooze_scope self.only_for_successive = only_for_successive @@ -751,8 +751,8 @@ class AzureApplicationInsightsDataFeed(object): :type query: str """ - def __init__(self, azure_cloud, application_id, api_key, query): - # type: (str, str, str, str) -> None + def __init__(self, azure_cloud, application_id, api_key, query, **kwargs): # pylint: disable=unused-argument + # type: (str, str, str, str, Any) -> None self.data_source_type = 'AzureApplicationInsights' # type: str self.azure_cloud = azure_cloud self.application_id = application_id @@ -788,8 +788,8 @@ class AzureBlobDataFeed(object): :type blob_template: str """ - def __init__(self, connection_string, container, blob_template): - # type: (str, str, str) -> None + def __init__(self, connection_string, container, blob_template, **kwargs): # pylint: disable=unused-argument + # type: (str, str, str, Any) -> None self.data_source_type = 'AzureBlob' # type: str self.connection_string = connection_string self.container = container @@ -824,8 +824,14 @@ class AzureCosmosDBDataFeed(object): :type collection_id: str """ - def __init__(self, connection_string, sql_query, database, collection_id): - # type: (str, str, str, str) -> None + def __init__( + self, connection_string, + sql_query, + database, + collection_id, + **kwargs + ): # pylint: disable=unused-argument + # type: (str, str, str, str, Any) -> None self.data_source_type = 'AzureCosmosDB' # type: str self.connection_string = connection_string self.sql_query = sql_query @@ -859,8 +865,8 @@ class AzureDataExplorerDataFeed(object): :type query: str """ - def __init__(self, connection_string, query): - # type: (str, str) -> None + def __init__(self, connection_string, query, **kwargs): # pylint: disable=unused-argument + # type: (str, str, Any) -> None self.data_source_type = 'AzureDataExplorer' # type: str self.connection_string = connection_string self.query = query @@ -890,8 +896,8 @@ class AzureTableDataFeed(object): :type table: str """ - def __init__(self, connection_string, query, table): - # type: (str, str, str) -> None + def __init__(self, connection_string, query, table, **kwargs): # pylint: disable=unused-argument + # type: (str, str, str, Any) -> None self.data_source_type = 'AzureTable' # type: str self.connection_string = connection_string self.query = query @@ -965,8 +971,15 @@ class InfluxDBDataFeed(object): :type query: str """ - def __init__(self, connection_string, database, user_name, password, query): - # type: (str, str, str, str, str) -> None + def __init__( + self, connection_string, + database, + user_name, + password, + query, + **kwargs + ): # pylint: disable=unused-argument + # type: (str, str, str, str, str, Any) -> None self.data_source_type = 'InfluxDB' # type: str self.connection_string = connection_string self.database = database @@ -1003,8 +1016,8 @@ class MySqlDataFeed(object): :type query: str """ - def __init__(self, connection_string, query): - # type: (str, str) -> None + def __init__(self, connection_string, query, **kwargs): # pylint: disable=unused-argument + # type: (str, str, Any) -> None self.data_source_type = 'MySql' # type: str self.connection_string = connection_string self.query = query @@ -1032,8 +1045,8 @@ class PostgreSqlDataFeed(object): :type query: str """ - def __init__(self, connection_string, query): - # type: (str, str) -> None + def __init__(self, connection_string, query, **kwargs): # pylint: disable=unused-argument + # type: (str, str, Any) -> None self.data_source_type = 'PostgreSql' # type: str self.connection_string = connection_string self.query = query @@ -1061,8 +1074,8 @@ class SQLServerDataFeed(object): :type query: str """ - def __init__(self, connection_string, query): - # type: (str, str) -> None + def __init__(self, connection_string, query, **kwargs): # pylint: disable=unused-argument + # type: (str, str, Any) -> None self.data_source_type = 'SqlServer' # type: str self.connection_string = connection_string self.query = query @@ -1102,9 +1115,10 @@ def __init__( account_key, file_system_name, directory_template, - file_template - ): - # type: (str, str, str, str, str) -> None + file_template, + **kwargs + ): # pylint: disable=unused-argument + # type: (str, str, str, str, str, Any) -> None self.data_source_type = 'AzureDataLakeStorageGen2' # type: str self.account_name = account_name self.account_key = account_key @@ -1145,8 +1159,8 @@ class ElasticsearchDataFeed(object): :type query: str """ - def __init__(self, host, port, auth_header, query): - # type: (str, str, str, str) -> None + def __init__(self, host, port, auth_header, query, **kwargs): # pylint: disable=unused-argument + # type: (str, str, str, str, Any) -> None self.data_source_type = 'Elasticsearch' # type: str self.host = host self.port = port @@ -1182,8 +1196,8 @@ class MongoDBDataFeed(object): :type command: str """ - def __init__(self, connection_string, database, command): - # type: (str, str, str) -> None + def __init__(self, connection_string, database, command, **kwargs): # pylint: disable=unused-argument + # type: (str, str, str, Any) -> None self.data_source_type = 'MongoDB' # type: str self.connection_string = connection_string self.database = database @@ -1428,7 +1442,8 @@ def __init__( within_range, # type: bool anomaly_detector_direction, # type: Union[str, AnomalyDetectorDirection] suppress_condition, # type: SuppressCondition - ): + **kwargs # type: Any + ): # pylint: disable=unused-argument # type: (...) -> None self.change_percentage = change_percentage self.shift_point = shift_point @@ -1468,8 +1483,8 @@ class SuppressCondition(object): :type min_ratio: float """ - def __init__(self, min_number, min_ratio): - # type: (int, float) -> None + def __init__(self, min_number, min_ratio, **kwargs): # pylint: disable=unused-argument + # type: (int, float, Any) -> None self.min_number = min_number self.min_ratio = min_ratio @@ -1494,8 +1509,13 @@ class SmartDetectionCondition(object): :type suppress_condition: ~azure.ai.metricsadvisor.models.SuppressCondition """ - def __init__(self, sensitivity, anomaly_detector_direction, suppress_condition): - # type: (float, Union[str, AnomalyDetectorDirection], SuppressCondition) -> None + def __init__( + self, sensitivity, + anomaly_detector_direction, + suppress_condition, + **kwargs + ): # pylint: disable=unused-argument + # type: (float, Union[str, AnomalyDetectorDirection], SuppressCondition, Any) -> None self.sensitivity = sensitivity self.anomaly_detector_direction = anomaly_detector_direction self.suppress_condition = suppress_condition From c0ff1c809c28d8eeab6fd712125db024ca300b5e Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Tue, 29 Sep 2020 15:16:11 -0700 Subject: [PATCH 4/4] pylint fix --- .../azure/ai/metricsadvisor/_metrics_advisor_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 199ffb8a2be5..51baf515185a 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 @@ -7,7 +7,7 @@ # pylint: disable=protected-access from typing import List, Union, Dict, Any, cast, TYPE_CHECKING -import datetime +import datetime # pylint:disable=unused-import from azure.core.tracing.decorator import distributed_trace from azure.core.pipeline import Pipeline