diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/CHANGELOG.md b/sdk/anomalydetector/azure-ai-anomalydetector/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/MANIFEST.in b/sdk/anomalydetector/azure-ai-anomalydetector/MANIFEST.in new file mode 100644 index 000000000000..a047c034e9b7 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/MANIFEST.in @@ -0,0 +1,6 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/ai/__init__.py + diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/README.md b/sdk/anomalydetector/azure-ai-anomalydetector/README.md new file mode 100644 index 000000000000..2803dd994dd3 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/README.md @@ -0,0 +1,27 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-ai-anomalydetector%2FREADME.png) diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/_meta.json b/sdk/anomalydetector/azure-ai-anomalydetector/_meta.json new file mode 100644 index 000000000000..0fd42a361887 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/_meta.json @@ -0,0 +1,8 @@ +{ + "autorest": "V2", + "use": "@microsoft.azure/autorest.python@~4.0.71", + "commit": "725b20c866d7f4a6512adff8d0647f0fe3baa069", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/cognitiveservices/data-plane/AnomalyDetector/readme.md --keep-version-file --multiapi --no-async --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --use=@microsoft.azure/autorest.python@~4.0.71 --version=V2", + "readme": "specification/cognitiveservices/data-plane/AnomalyDetector/readme.md" +} \ No newline at end of file diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/__init__.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/__init__.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/__init__.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/__init__.py new file mode 100644 index 000000000000..09815430d029 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from ._configuration import AnomalyDetectorClientConfiguration +from ._anomaly_detector_client import AnomalyDetectorClient +__all__ = ['AnomalyDetectorClient', 'AnomalyDetectorClientConfiguration'] + +from .version import VERSION + +__version__ = VERSION + diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_anomaly_detector_client.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_anomaly_detector_client.py new file mode 100644 index 000000000000..6d1ed3453487 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_anomaly_detector_client.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import AnomalyDetectorClientConfiguration +from .operations import AnomalyDetectorClientOperationsMixin +from . import models + + +class AnomalyDetectorClient(AnomalyDetectorClientOperationsMixin, SDKClient): + """The Anomaly Detector API detects anomalies automatically in time series data. It supports two kinds of mode, one is for stateless using, another is for stateful using. In stateless mode, there are three functionalities. Entire Detect is for detecting the whole series with model trained by the time series, Last Detect is detecting last point with model trained by points before. ChangePoint Detect is for detecting trend changes in time series. In stateful mode, user can store time series, the stored time series will be used for detection anomalies. Under this mode, user can still use the above three functionalities by only giving a time range without preparing time series in client side. Besides the above three functionalities, stateful model also provide group based detection and labeling service. By leveraging labeling service user can provide labels for each detection result, these labels will be used for retuning or regenerating detection models. Inconsistency detection is a kind of group based detection, this detection will find inconsistency ones in a set of time series. By using anomaly detector service, business customers can discover incidents and establish a logic flow for root cause analysis. + + :ivar config: Configuration for client. + :vartype config: AnomalyDetectorClientConfiguration + + :param endpoint: Supported Cognitive Services endpoints (protocol and + hostname, for example: https://westus2.api.cognitive.microsoft.com). + :type endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, endpoint, credentials): + + self.config = AnomalyDetectorClientConfiguration(endpoint, credentials) + super(AnomalyDetectorClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '1.1-preview.1' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_configuration.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_configuration.py new file mode 100644 index 000000000000..6b4522263cac --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/_configuration.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest import Configuration + +from .version import VERSION + + +class AnomalyDetectorClientConfiguration(Configuration): + """Configuration for AnomalyDetectorClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Supported Cognitive Services endpoints (protocol and + hostname, for example: https://westus2.api.cognitive.microsoft.com). + :type endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, endpoint, credentials): + + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + base_url = '{Endpoint}/anomalydetector/{ApiVersion}' + + super(AnomalyDetectorClientConfiguration, self).__init__(base_url) + + # Starting Autorest.Python 4.0.64, make connection pool activated by default + self.keep_alive = True + + self.add_user_agent('azure-ai-anomalydetector/{}'.format(VERSION)) + + self.endpoint = endpoint + self.credentials = credentials diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/__init__.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/__init__.py new file mode 100644 index 000000000000..2a382f0aff07 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/__init__.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import AlignPolicy + from ._models_py3 import AnomalyDetectorError, AnomalyDetectorErrorException + from ._models_py3 import AnomalyInterpretation + from ._models_py3 import AnomalyState + from ._models_py3 import AnomalyValue + from ._models_py3 import ChangePointDetectRequest + from ._models_py3 import ChangePointDetectResponse + from ._models_py3 import CorrelationChanges + from ._models_py3 import DetectionRequest + from ._models_py3 import DetectionResult + from ._models_py3 import DetectionResultSummary + from ._models_py3 import DetectRequest + from ._models_py3 import DiagnosticsInfo + from ._models_py3 import EntireDetectResponse + from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import LastDetectionRequest + from ._models_py3 import LastDetectionResult + from ._models_py3 import LastDetectResponse + from ._models_py3 import Model + from ._models_py3 import ModelInfo + from ._models_py3 import ModelList + from ._models_py3 import ModelSnapshot + from ._models_py3 import ModelState + from ._models_py3 import TimeSeriesPoint + from ._models_py3 import VariableState + from ._models_py3 import VariableValues +except (SyntaxError, ImportError): + from ._models import AlignPolicy + from ._models import AnomalyDetectorError, AnomalyDetectorErrorException + from ._models import AnomalyInterpretation + from ._models import AnomalyState + from ._models import AnomalyValue + from ._models import ChangePointDetectRequest + from ._models import ChangePointDetectResponse + from ._models import CorrelationChanges + from ._models import DetectionRequest + from ._models import DetectionResult + from ._models import DetectionResultSummary + from ._models import DetectRequest + from ._models import DiagnosticsInfo + from ._models import EntireDetectResponse + from ._models import ErrorResponse, ErrorResponseException + from ._models import LastDetectionRequest + from ._models import LastDetectionResult + from ._models import LastDetectResponse + from ._models import Model + from ._models import ModelInfo + from ._models import ModelList + from ._models import ModelSnapshot + from ._models import ModelState + from ._models import TimeSeriesPoint + from ._models import VariableState + from ._models import VariableValues +from ._anomaly_detector_client_enums import ( + AlignMode, + DetectionStatus, + FillNAMethod, + ImputeMode, + ModelStatus, + TimeGranularity, +) + +__all__ = [ + 'AlignPolicy', + 'AnomalyDetectorError', 'AnomalyDetectorErrorException', + 'AnomalyInterpretation', + 'AnomalyState', + 'AnomalyValue', + 'ChangePointDetectRequest', + 'ChangePointDetectResponse', + 'CorrelationChanges', + 'DetectionRequest', + 'DetectionResult', + 'DetectionResultSummary', + 'DetectRequest', + 'DiagnosticsInfo', + 'EntireDetectResponse', + 'ErrorResponse', 'ErrorResponseException', + 'LastDetectionRequest', + 'LastDetectionResult', + 'LastDetectResponse', + 'Model', + 'ModelInfo', + 'ModelList', + 'ModelSnapshot', + 'ModelState', + 'TimeSeriesPoint', + 'VariableState', + 'VariableValues', + 'TimeGranularity', + 'ImputeMode', + 'AlignMode', + 'FillNAMethod', + 'ModelStatus', + 'DetectionStatus', +] diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_anomaly_detector_client_enums.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_anomaly_detector_client_enums.py new file mode 100644 index 000000000000..841ff0ad1f48 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_anomaly_detector_client_enums.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum + + +class TimeGranularity(str, Enum): + + yearly = "yearly" + monthly = "monthly" + weekly = "weekly" + daily = "daily" + hourly = "hourly" + per_minute = "minutely" + per_second = "secondly" + microsecond = "microsecond" + none = "none" + + +class ImputeMode(str, Enum): + + auto = "auto" + previous = "previous" + linear = "linear" + fixed = "fixed" + zero = "zero" + not_fill = "notFill" + + +class AlignMode(str, Enum): + + inner = "Inner" + outer = "Outer" + + +class FillNAMethod(str, Enum): + + previous = "Previous" + subsequent = "Subsequent" + linear = "Linear" + zero = "Zero" + fixed = "Fixed" + not_fill = "NotFill" + + +class ModelStatus(str, Enum): + + created = "CREATED" + running = "RUNNING" + ready = "READY" + failed = "FAILED" + + +class DetectionStatus(str, Enum): + + created = "CREATED" + running = "RUNNING" + ready = "READY" + failed = "FAILED" diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_models.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_models.py new file mode 100644 index 000000000000..cfbf488a25a3 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_models.py @@ -0,0 +1,1038 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class AlignPolicy(Model): + """AlignPolicy. + + :param align_mode: An optional field, indicating how we align different + variables to the same time-range. Either Inner or Outer. Possible values + include: 'Inner', 'Outer' + :type align_mode: str or ~azure.ai.anomalydetector.models.AlignMode + :param fill_na_method: An optional field, indicating how missing values + will be filled. One of Previous, Subsequent, Linear, Zero, Fixed, and + NotFill. Cannot be set to NotFill, when the alignMode is Outer. Possible + values include: 'Previous', 'Subsequent', 'Linear', 'Zero', 'Fixed', + 'NotFill' + :type fill_na_method: str or ~azure.ai.anomalydetector.models.FillNAMethod + :param padding_value: An optional field. Required when fillNAMethod is + Fixed. + :type padding_value: float + """ + + _attribute_map = { + 'align_mode': {'key': 'alignMode', 'type': 'AlignMode'}, + 'fill_na_method': {'key': 'fillNAMethod', 'type': 'str'}, + 'padding_value': {'key': 'paddingValue', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(AlignPolicy, self).__init__(**kwargs) + self.align_mode = kwargs.get('align_mode', None) + self.fill_na_method = kwargs.get('fill_na_method', None) + self.padding_value = kwargs.get('padding_value', None) + + +class AnomalyDetectorError(Model): + """Error information returned by the API. + + :param code: The error code. + :type code: object + :param message: A message explaining the error reported by the service. + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'object'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(AnomalyDetectorError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class AnomalyDetectorErrorException(HttpOperationError): + """Server responsed with exception of type: 'AnomalyDetectorError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(AnomalyDetectorErrorException, self).__init__(deserialize, response, 'AnomalyDetectorError', *args) + + +class AnomalyInterpretation(Model): + """AnomalyInterpretation. + + :param variable: + :type variable: str + :param contribution_score: + :type contribution_score: float + :param correlation_changes: + :type correlation_changes: + ~azure.ai.anomalydetector.models.CorrelationChanges + """ + + _attribute_map = { + 'variable': {'key': 'variable', 'type': 'str'}, + 'contribution_score': {'key': 'contributionScore', 'type': 'float'}, + 'correlation_changes': {'key': 'correlationChanges', 'type': 'CorrelationChanges'}, + } + + def __init__(self, **kwargs): + super(AnomalyInterpretation, self).__init__(**kwargs) + self.variable = kwargs.get('variable', None) + self.contribution_score = kwargs.get('contribution_score', None) + self.correlation_changes = kwargs.get('correlation_changes', None) + + +class AnomalyState(Model): + """AnomalyState. + + All required parameters must be populated in order to send to Azure. + + :param timestamp: Required. timestamp + :type timestamp: datetime + :param value: + :type value: ~azure.ai.anomalydetector.models.AnomalyValue + :param errors: Error message for the current timestamp + :type errors: list[~azure.ai.anomalydetector.models.ErrorResponse] + """ + + _validation = { + 'timestamp': {'required': True}, + } + + _attribute_map = { + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'value': {'key': 'value', 'type': 'AnomalyValue'}, + 'errors': {'key': 'errors', 'type': '[ErrorResponse]'}, + } + + def __init__(self, **kwargs): + super(AnomalyState, self).__init__(**kwargs) + self.timestamp = kwargs.get('timestamp', None) + self.value = kwargs.get('value', None) + self.errors = kwargs.get('errors', None) + + +class AnomalyValue(Model): + """AnomalyValue. + + All required parameters must be populated in order to send to Azure. + + :param is_anomaly: Required. True if an anomaly is detected at the current + timestamp. + :type is_anomaly: bool + :param severity: Required. Indicates the significance of the anomaly. The + higher the severity, the more significant the anomaly. + :type severity: float + :param score: Required. Raw score from the model. + :type score: float + :param interpretation: + :type interpretation: + list[~azure.ai.anomalydetector.models.AnomalyInterpretation] + """ + + _validation = { + 'is_anomaly': {'required': True}, + 'severity': {'required': True, 'maximum': 1, 'minimum': 0}, + 'score': {'required': True, 'maximum': 2, 'minimum': 0}, + } + + _attribute_map = { + 'is_anomaly': {'key': 'isAnomaly', 'type': 'bool'}, + 'severity': {'key': 'severity', 'type': 'float'}, + 'score': {'key': 'score', 'type': 'float'}, + 'interpretation': {'key': 'interpretation', 'type': '[AnomalyInterpretation]'}, + } + + def __init__(self, **kwargs): + super(AnomalyValue, self).__init__(**kwargs) + self.is_anomaly = kwargs.get('is_anomaly', None) + self.severity = kwargs.get('severity', None) + self.score = kwargs.get('score', None) + self.interpretation = kwargs.get('interpretation', None) + + +class ChangePointDetectRequest(Model): + """The request of change point detection. + + All required parameters must be populated in order to send to Azure. + + :param series: Required. Time series data points. Points should be sorted + by timestamp in ascending order to match the change point detection + result. + :type series: list[~azure.ai.anomalydetector.models.TimeSeriesPoint] + :param granularity: Required. Can only be one of yearly, monthly, weekly, + daily, hourly, minutely or secondly. Granularity is used for verify + whether input series is valid. Possible values include: 'yearly', + 'monthly', 'weekly', 'daily', 'hourly', 'perMinute', 'perSecond', + 'microsecond', 'none' + :type granularity: str or ~azure.ai.anomalydetector.models.TimeGranularity + :param custom_interval: Custom Interval is used to set non-standard time + interval, for example, if the series is 5 minutes, request can be set as + {"granularity":"minutely", "customInterval":5}. + :type custom_interval: int + :param period: Optional argument, periodic value of a time series. If the + value is null or does not present, the API will determine the period + automatically. + :type period: int + :param stable_trend_window: Optional argument, advanced model parameter, a + default stableTrendWindow will be used in detection. + :type stable_trend_window: int + :param threshold: Optional argument, advanced model parameter, between + 0.0-1.0, the lower the value is, the larger the trend error will be which + means less change point will be accepted. + :type threshold: float + """ + + _validation = { + 'series': {'required': True}, + 'granularity': {'required': True}, + } + + _attribute_map = { + 'series': {'key': 'series', 'type': '[TimeSeriesPoint]'}, + 'granularity': {'key': 'granularity', 'type': 'TimeGranularity'}, + 'custom_interval': {'key': 'customInterval', 'type': 'int'}, + 'period': {'key': 'period', 'type': 'int'}, + 'stable_trend_window': {'key': 'stableTrendWindow', 'type': 'int'}, + 'threshold': {'key': 'threshold', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(ChangePointDetectRequest, self).__init__(**kwargs) + self.series = kwargs.get('series', None) + self.granularity = kwargs.get('granularity', None) + self.custom_interval = kwargs.get('custom_interval', None) + self.period = kwargs.get('period', None) + self.stable_trend_window = kwargs.get('stable_trend_window', None) + self.threshold = kwargs.get('threshold', None) + + +class ChangePointDetectResponse(Model): + """The response of change point detection. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar period: Frequency extracted from the series, zero means no recurrent + pattern has been found. + :vartype period: int + :param is_change_point: isChangePoint contains change point properties for + each input point. True means an anomaly either negative or positive has + been detected. The index of the array is consistent with the input series. + :type is_change_point: list[bool] + :param confidence_scores: the change point confidence of each point + :type confidence_scores: list[float] + """ + + _validation = { + 'period': {'readonly': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'is_change_point': {'key': 'isChangePoint', 'type': '[bool]'}, + 'confidence_scores': {'key': 'confidenceScores', 'type': '[float]'}, + } + + def __init__(self, **kwargs): + super(ChangePointDetectResponse, self).__init__(**kwargs) + self.period = None + self.is_change_point = kwargs.get('is_change_point', None) + self.confidence_scores = kwargs.get('confidence_scores', None) + + +class CorrelationChanges(Model): + """CorrelationChanges. + + :param changed_variables: correlated variables + :type changed_variables: list[str] + :param changed_values: changes in correlation + :type changed_values: list[float] + """ + + _attribute_map = { + 'changed_variables': {'key': 'changedVariables', 'type': '[str]'}, + 'changed_values': {'key': 'changedValues', 'type': '[float]'}, + } + + def __init__(self, **kwargs): + super(CorrelationChanges, self).__init__(**kwargs) + self.changed_variables = kwargs.get('changed_variables', None) + self.changed_values = kwargs.get('changed_values', None) + + +class DetectionRequest(Model): + """Detection request. + + All required parameters must be populated in order to send to Azure. + + :param source: Required. Source link to the input variables. Each variable + should be a csv with two columns, `timestamp` and `value`. The file name + of the variable will be used as its name. The variables used in detection + should be exactly the same with those used in the training phase. + :type source: str + :param start_time: Required. A required field, indicating the start time + of data for detection. Should be date-time. + :type start_time: datetime + :param end_time: Required. A required field, indicating the end time of + data for detection. Should be date-time. + :type end_time: datetime + """ + + _validation = { + 'source': {'required': True}, + 'start_time': {'required': True}, + 'end_time': {'required': True}, + } + + _attribute_map = { + 'source': {'key': 'source', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(DetectionRequest, self).__init__(**kwargs) + self.source = kwargs.get('source', None) + self.start_time = kwargs.get('start_time', None) + self.end_time = kwargs.get('end_time', None) + + +class DetectionResult(Model): + """Response of the given resultId. + + All required parameters must be populated in order to send to Azure. + + :param result_id: Required. + :type result_id: str + :param summary: Required. + :type summary: ~azure.ai.anomalydetector.models.DetectionResultSummary + :param results: Required. Detection result for each timestamp. + :type results: list[~azure.ai.anomalydetector.models.AnomalyState] + """ + + _validation = { + 'result_id': {'required': True}, + 'summary': {'required': True}, + 'results': {'required': True}, + } + + _attribute_map = { + 'result_id': {'key': 'resultId', 'type': 'str'}, + 'summary': {'key': 'summary', 'type': 'DetectionResultSummary'}, + 'results': {'key': 'results', 'type': '[AnomalyState]'}, + } + + def __init__(self, **kwargs): + super(DetectionResult, self).__init__(**kwargs) + self.result_id = kwargs.get('result_id', None) + self.summary = kwargs.get('summary', None) + self.results = kwargs.get('results', None) + + +class DetectionResultSummary(Model): + """DetectionResultSummary. + + All required parameters must be populated in order to send to Azure. + + :param status: Required. Status of detection results. One of CREATED, + RUNNING, READY, and FAILED. Possible values include: 'CREATED', 'RUNNING', + 'READY', 'FAILED' + :type status: str or ~azure.ai.anomalydetector.models.DetectionStatus + :param errors: Error message when detection is failed. + :type errors: list[~azure.ai.anomalydetector.models.ErrorResponse] + :param variable_states: + :type variable_states: + list[~azure.ai.anomalydetector.models.VariableState] + :param setup_info: Required. + :type setup_info: ~azure.ai.anomalydetector.models.DetectionRequest + """ + + _validation = { + 'status': {'required': True}, + 'setup_info': {'required': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'DetectionStatus'}, + 'errors': {'key': 'errors', 'type': '[ErrorResponse]'}, + 'variable_states': {'key': 'variableStates', 'type': '[VariableState]'}, + 'setup_info': {'key': 'setupInfo', 'type': 'DetectionRequest'}, + } + + def __init__(self, **kwargs): + super(DetectionResultSummary, self).__init__(**kwargs) + self.status = kwargs.get('status', None) + self.errors = kwargs.get('errors', None) + self.variable_states = kwargs.get('variable_states', None) + self.setup_info = kwargs.get('setup_info', None) + + +class DetectRequest(Model): + """The request of entire or last anomaly detection. + + All required parameters must be populated in order to send to Azure. + + :param series: Required. Time series data points. Points should be sorted + by timestamp in ascending order to match the anomaly detection result. If + the data is not sorted correctly or there is duplicated timestamp, the API + will not work. In such case, an error message will be returned. + :type series: list[~azure.ai.anomalydetector.models.TimeSeriesPoint] + :param granularity: Possible values include: 'yearly', 'monthly', + 'weekly', 'daily', 'hourly', 'perMinute', 'perSecond', 'microsecond', + 'none' + :type granularity: str or ~azure.ai.anomalydetector.models.TimeGranularity + :param custom_interval: Custom Interval is used to set non-standard time + interval, for example, if the series is 5 minutes, request can be set as + {"granularity":"minutely", "customInterval":5}. + :type custom_interval: int + :param period: Optional argument, periodic value of a time series. If the + value is null or does not present, the API will determine the period + automatically. + :type period: int + :param max_anomaly_ratio: Optional argument, advanced model parameter, max + anomaly ratio in a time series. + :type max_anomaly_ratio: float + :param sensitivity: Optional argument, advanced model parameter, between + 0-99, the lower the value is, the larger the margin value will be which + means less anomalies will be accepted. + :type sensitivity: int + :param impute_mode: Used to specify how to deal with missing values in the + input series, it's used when granularity is not "none". Possible values + include: 'auto', 'previous', 'linear', 'fixed', 'zero', 'notFill' + :type impute_mode: str or ~azure.ai.anomalydetector.models.ImputeMode + :param impute_fixed_value: Used to specify the value to fill, it's used + when granularity is not "none" and imputeMode is "fixed". + :type impute_fixed_value: float + """ + + _validation = { + 'series': {'required': True}, + } + + _attribute_map = { + 'series': {'key': 'series', 'type': '[TimeSeriesPoint]'}, + 'granularity': {'key': 'granularity', 'type': 'TimeGranularity'}, + 'custom_interval': {'key': 'customInterval', 'type': 'int'}, + 'period': {'key': 'period', 'type': 'int'}, + 'max_anomaly_ratio': {'key': 'maxAnomalyRatio', 'type': 'float'}, + 'sensitivity': {'key': 'sensitivity', 'type': 'int'}, + 'impute_mode': {'key': 'imputeMode', 'type': 'str'}, + 'impute_fixed_value': {'key': 'imputeFixedValue', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(DetectRequest, self).__init__(**kwargs) + self.series = kwargs.get('series', None) + self.granularity = kwargs.get('granularity', None) + self.custom_interval = kwargs.get('custom_interval', None) + self.period = kwargs.get('period', None) + self.max_anomaly_ratio = kwargs.get('max_anomaly_ratio', None) + self.sensitivity = kwargs.get('sensitivity', None) + self.impute_mode = kwargs.get('impute_mode', None) + self.impute_fixed_value = kwargs.get('impute_fixed_value', None) + + +class DiagnosticsInfo(Model): + """DiagnosticsInfo. + + :param model_state: + :type model_state: ~azure.ai.anomalydetector.models.ModelState + :param variable_states: + :type variable_states: + list[~azure.ai.anomalydetector.models.VariableState] + """ + + _attribute_map = { + 'model_state': {'key': 'modelState', 'type': 'ModelState'}, + 'variable_states': {'key': 'variableStates', 'type': '[VariableState]'}, + } + + def __init__(self, **kwargs): + super(DiagnosticsInfo, self).__init__(**kwargs) + self.model_state = kwargs.get('model_state', None) + self.variable_states = kwargs.get('variable_states', None) + + +class EntireDetectResponse(Model): + """The response of entire anomaly detection. + + All required parameters must be populated in order to send to Azure. + + :param period: Required. Frequency extracted from the series, zero means + no recurrent pattern has been found. + :type period: int + :param expected_values: Required. ExpectedValues contain expected value + for each input point. The index of the array is consistent with the input + series. + :type expected_values: list[float] + :param upper_margins: Required. UpperMargins contain upper margin of each + input point. UpperMargin is used to calculate upperBoundary, which equals + to expectedValue + (100 - marginScale)*upperMargin. Anomalies in response + can be filtered by upperBoundary and lowerBoundary. By adjusting + marginScale value, less significant anomalies can be filtered in client + side. The index of the array is consistent with the input series. + :type upper_margins: list[float] + :param lower_margins: Required. LowerMargins contain lower margin of each + input point. LowerMargin is used to calculate lowerBoundary, which equals + to expectedValue - (100 - marginScale)*lowerMargin. Points between the + boundary can be marked as normal ones in client side. The index of the + array is consistent with the input series. + :type lower_margins: list[float] + :param is_anomaly: Required. IsAnomaly contains anomaly properties for + each input point. True means an anomaly either negative or positive has + been detected. The index of the array is consistent with the input series. + :type is_anomaly: list[bool] + :param is_negative_anomaly: Required. IsNegativeAnomaly contains anomaly + status in negative direction for each input point. True means a negative + anomaly has been detected. A negative anomaly means the point is detected + as an anomaly and its real value is smaller than the expected one. The + index of the array is consistent with the input series. + :type is_negative_anomaly: list[bool] + :param is_positive_anomaly: Required. IsPositiveAnomaly contain anomaly + status in positive direction for each input point. True means a positive + anomaly has been detected. A positive anomaly means the point is detected + as an anomaly and its real value is larger than the expected one. The + index of the array is consistent with the input series. + :type is_positive_anomaly: list[bool] + :param severity: The severity score for each input point. The larger the + value is, the more sever the anomaly is. For normal points, the "severity" + is always 0. + :type severity: list[float] + """ + + _validation = { + 'period': {'required': True}, + 'expected_values': {'required': True}, + 'upper_margins': {'required': True}, + 'lower_margins': {'required': True}, + 'is_anomaly': {'required': True}, + 'is_negative_anomaly': {'required': True}, + 'is_positive_anomaly': {'required': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'expected_values': {'key': 'expectedValues', 'type': '[float]'}, + 'upper_margins': {'key': 'upperMargins', 'type': '[float]'}, + 'lower_margins': {'key': 'lowerMargins', 'type': '[float]'}, + 'is_anomaly': {'key': 'isAnomaly', 'type': '[bool]'}, + 'is_negative_anomaly': {'key': 'isNegativeAnomaly', 'type': '[bool]'}, + 'is_positive_anomaly': {'key': 'isPositiveAnomaly', 'type': '[bool]'}, + 'severity': {'key': 'severity', 'type': '[float]'}, + } + + def __init__(self, **kwargs): + super(EntireDetectResponse, self).__init__(**kwargs) + self.period = kwargs.get('period', None) + self.expected_values = kwargs.get('expected_values', None) + self.upper_margins = kwargs.get('upper_margins', None) + self.lower_margins = kwargs.get('lower_margins', None) + self.is_anomaly = kwargs.get('is_anomaly', None) + self.is_negative_anomaly = kwargs.get('is_negative_anomaly', None) + self.is_positive_anomaly = kwargs.get('is_positive_anomaly', None) + self.severity = kwargs.get('severity', None) + + +class ErrorResponse(Model): + """ErrorResponse. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. The error code. + :type code: str + :param message: Required. The message explaining the error reported by the + service. + :type message: str + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ErrorResponse, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class LastDetectionRequest(Model): + """LastDetectionRequest. + + All required parameters must be populated in order to send to Azure. + + :param variables: Required. variables + :type variables: list[~azure.ai.anomalydetector.models.VariableValues] + :param detecting_points: Required. number of timestamps on which the model + detects + :type detecting_points: int + """ + + _validation = { + 'variables': {'required': True}, + 'detecting_points': {'required': True}, + } + + _attribute_map = { + 'variables': {'key': 'variables', 'type': '[VariableValues]'}, + 'detecting_points': {'key': 'detectingPoints', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(LastDetectionRequest, self).__init__(**kwargs) + self.variables = kwargs.get('variables', None) + self.detecting_points = kwargs.get('detecting_points', None) + + +class LastDetectionResult(Model): + """LastDetectionResult. + + :param variable_states: + :type variable_states: + list[~azure.ai.anomalydetector.models.VariableState] + :param results: + :type results: list[~azure.ai.anomalydetector.models.AnomalyState] + """ + + _attribute_map = { + 'variable_states': {'key': 'variableStates', 'type': '[VariableState]'}, + 'results': {'key': 'results', 'type': '[AnomalyState]'}, + } + + def __init__(self, **kwargs): + super(LastDetectionResult, self).__init__(**kwargs) + self.variable_states = kwargs.get('variable_states', None) + self.results = kwargs.get('results', None) + + +class LastDetectResponse(Model): + """The response of last anomaly detection. + + All required parameters must be populated in order to send to Azure. + + :param period: Required. Frequency extracted from the series, zero means + no recurrent pattern has been found. + :type period: int + :param suggested_window: Required. Suggested input series points needed + for detecting the latest point. + :type suggested_window: int + :param expected_value: Required. Expected value of the latest point. + :type expected_value: float + :param upper_margin: Required. Upper margin of the latest point. + UpperMargin is used to calculate upperBoundary, which equals to + expectedValue + (100 - marginScale)*upperMargin. If the value of latest + point is between upperBoundary and lowerBoundary, it should be treated as + normal value. By adjusting marginScale value, anomaly status of latest + point can be changed. + :type upper_margin: float + :param lower_margin: Required. Lower margin of the latest point. + LowerMargin is used to calculate lowerBoundary, which equals to + expectedValue - (100 - marginScale)*lowerMargin. + :type lower_margin: float + :param is_anomaly: Required. Anomaly status of the latest point, true + means the latest point is an anomaly either in negative direction or + positive direction. + :type is_anomaly: bool + :param is_negative_anomaly: Required. Anomaly status in negative direction + of the latest point. True means the latest point is an anomaly and its + real value is smaller than the expected one. + :type is_negative_anomaly: bool + :param is_positive_anomaly: Required. Anomaly status in positive direction + of the latest point. True means the latest point is an anomaly and its + real value is larger than the expected one. + :type is_positive_anomaly: bool + :param severity: The severity score for the last input point. The larger + the value is, the more sever the anomaly is. For normal points, the + "severity" is always 0. + :type severity: float + """ + + _validation = { + 'period': {'required': True}, + 'suggested_window': {'required': True}, + 'expected_value': {'required': True}, + 'upper_margin': {'required': True}, + 'lower_margin': {'required': True}, + 'is_anomaly': {'required': True}, + 'is_negative_anomaly': {'required': True}, + 'is_positive_anomaly': {'required': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'suggested_window': {'key': 'suggestedWindow', 'type': 'int'}, + 'expected_value': {'key': 'expectedValue', 'type': 'float'}, + 'upper_margin': {'key': 'upperMargin', 'type': 'float'}, + 'lower_margin': {'key': 'lowerMargin', 'type': 'float'}, + 'is_anomaly': {'key': 'isAnomaly', 'type': 'bool'}, + 'is_negative_anomaly': {'key': 'isNegativeAnomaly', 'type': 'bool'}, + 'is_positive_anomaly': {'key': 'isPositiveAnomaly', 'type': 'bool'}, + 'severity': {'key': 'severity', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(LastDetectResponse, self).__init__(**kwargs) + self.period = kwargs.get('period', None) + self.suggested_window = kwargs.get('suggested_window', None) + self.expected_value = kwargs.get('expected_value', None) + self.upper_margin = kwargs.get('upper_margin', None) + self.lower_margin = kwargs.get('lower_margin', None) + self.is_anomaly = kwargs.get('is_anomaly', None) + self.is_negative_anomaly = kwargs.get('is_negative_anomaly', None) + self.is_positive_anomaly = kwargs.get('is_positive_anomaly', None) + self.severity = kwargs.get('severity', None) + + +class Model(Model): + """Response of getting a model. + + All required parameters must be populated in order to send to Azure. + + :param model_id: Required. Model identifier. + :type model_id: str + :param created_time: Required. Date and time (UTC) when the model was + created. + :type created_time: datetime + :param last_updated_time: Required. Date and time (UTC) when the model was + last updated. + :type last_updated_time: datetime + :param model_info: + :type model_info: ~azure.ai.anomalydetector.models.ModelInfo + """ + + _validation = { + 'model_id': {'required': True}, + 'created_time': {'required': True}, + 'last_updated_time': {'required': True}, + } + + _attribute_map = { + 'model_id': {'key': 'modelId', 'type': 'str'}, + 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, + 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, + 'model_info': {'key': 'modelInfo', 'type': 'ModelInfo'}, + } + + def __init__(self, **kwargs): + super(Model, self).__init__(**kwargs) + self.model_id = kwargs.get('model_id', None) + self.created_time = kwargs.get('created_time', None) + self.last_updated_time = kwargs.get('last_updated_time', None) + self.model_info = kwargs.get('model_info', None) + + +class ModelInfo(Model): + """Train result of a model including status, errors and diagnose info for + model and variables. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param sliding_window: An optional field, indicating how many previous + points will be used to compute the anomaly score of the subsequent point. + :type sliding_window: int + :param align_policy: + :type align_policy: ~azure.ai.anomalydetector.models.AlignPolicy + :param source: Required. Source link to the input variables. Each variable + should be a csv file with two columns, `timestamp` and `value`. By + default, the file name of the variable will be used as its variable name. + :type source: str + :param start_time: Required. A required field, indicating the start time + of training data. Should be date-time. + :type start_time: datetime + :param end_time: Required. A required field, indicating the end time of + training data. Should be date-time. + :type end_time: datetime + :param display_name: An optional field. The name of the model whose + maximum length is 24. + :type display_name: str + :param status: Possible values include: 'CREATED', 'RUNNING', 'READY', + 'FAILED' + :type status: str or ~azure.ai.anomalydetector.models.ModelStatus + :ivar errors: Error messages when failed to create a model. + :vartype errors: list[~azure.ai.anomalydetector.models.ErrorResponse] + :param diagnostics_info: + :type diagnostics_info: ~azure.ai.anomalydetector.models.DiagnosticsInfo + """ + + _validation = { + 'source': {'required': True}, + 'start_time': {'required': True}, + 'end_time': {'required': True}, + 'display_name': {'max_length': 24}, + 'errors': {'readonly': True}, + } + + _attribute_map = { + 'sliding_window': {'key': 'slidingWindow', 'type': 'int'}, + 'align_policy': {'key': 'alignPolicy', 'type': 'AlignPolicy'}, + 'source': {'key': 'source', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'ModelStatus'}, + 'errors': {'key': 'errors', 'type': '[ErrorResponse]'}, + 'diagnostics_info': {'key': 'diagnosticsInfo', 'type': 'DiagnosticsInfo'}, + } + + def __init__(self, **kwargs): + super(ModelInfo, self).__init__(**kwargs) + self.sliding_window = kwargs.get('sliding_window', None) + self.align_policy = kwargs.get('align_policy', None) + self.source = kwargs.get('source', None) + self.start_time = kwargs.get('start_time', None) + self.end_time = kwargs.get('end_time', None) + self.display_name = kwargs.get('display_name', None) + self.status = kwargs.get('status', None) + self.errors = None + self.diagnostics_info = kwargs.get('diagnostics_info', None) + + +class ModelList(Model): + """Response of listing models. + + All required parameters must be populated in order to send to Azure. + + :param models_property: Required. List of models + :type models_property: + list[~azure.ai.anomalydetector.models.ModelSnapshot] + :param current_count: Required. Current count of trained multivariate + models. + :type current_count: int + :param max_count: Required. Max number of models that can be trained for + this subscription. + :type max_count: int + :param next_link: The link to fetch more models. + :type next_link: str + """ + + _validation = { + 'models_property': {'required': True}, + 'current_count': {'required': True}, + 'max_count': {'required': True}, + } + + _attribute_map = { + 'models_property': {'key': 'models', 'type': '[ModelSnapshot]'}, + 'current_count': {'key': 'currentCount', 'type': 'int'}, + 'max_count': {'key': 'maxCount', 'type': 'int'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ModelList, self).__init__(**kwargs) + self.models_property = kwargs.get('models_property', None) + self.current_count = kwargs.get('current_count', None) + self.max_count = kwargs.get('max_count', None) + self.next_link = kwargs.get('next_link', None) + + +class ModelSnapshot(Model): + """ModelSnapshot. + + All required parameters must be populated in order to send to Azure. + + :param model_id: Required. Model identifier. + :type model_id: str + :param created_time: Required. Date and time (UTC) when the model was + created. + :type created_time: datetime + :param last_updated_time: Required. Date and time (UTC) when the model was + last updated. + :type last_updated_time: datetime + :param status: Required. Possible values include: 'CREATED', 'RUNNING', + 'READY', 'FAILED' + :type status: str or ~azure.ai.anomalydetector.models.ModelStatus + :param display_name: + :type display_name: str + :param variables_count: Required. Total number of variables. + :type variables_count: int + """ + + _validation = { + 'model_id': {'required': True}, + 'created_time': {'required': True}, + 'last_updated_time': {'required': True}, + 'status': {'required': True}, + 'variables_count': {'required': True}, + } + + _attribute_map = { + 'model_id': {'key': 'modelId', 'type': 'str'}, + 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, + 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, + 'status': {'key': 'status', 'type': 'ModelStatus'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'variables_count': {'key': 'variablesCount', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(ModelSnapshot, self).__init__(**kwargs) + self.model_id = kwargs.get('model_id', None) + self.created_time = kwargs.get('created_time', None) + self.last_updated_time = kwargs.get('last_updated_time', None) + self.status = kwargs.get('status', None) + self.display_name = kwargs.get('display_name', None) + self.variables_count = kwargs.get('variables_count', None) + + +class ModelState(Model): + """ModelState. + + :param epoch_ids: Epoch id + :type epoch_ids: list[int] + :param train_losses: + :type train_losses: list[float] + :param validation_losses: + :type validation_losses: list[float] + :param latencies_in_seconds: + :type latencies_in_seconds: list[float] + """ + + _attribute_map = { + 'epoch_ids': {'key': 'epochIds', 'type': '[int]'}, + 'train_losses': {'key': 'trainLosses', 'type': '[float]'}, + 'validation_losses': {'key': 'validationLosses', 'type': '[float]'}, + 'latencies_in_seconds': {'key': 'latenciesInSeconds', 'type': '[float]'}, + } + + def __init__(self, **kwargs): + super(ModelState, self).__init__(**kwargs) + self.epoch_ids = kwargs.get('epoch_ids', None) + self.train_losses = kwargs.get('train_losses', None) + self.validation_losses = kwargs.get('validation_losses', None) + self.latencies_in_seconds = kwargs.get('latencies_in_seconds', None) + + +class TimeSeriesPoint(Model): + """The definition of input timeseries points. + + All required parameters must be populated in order to send to Azure. + + :param timestamp: Optional argument, timestamp of a data point (ISO8601 + format). + :type timestamp: datetime + :param value: Required. The measurement of that point, should be float. + :type value: float + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(TimeSeriesPoint, self).__init__(**kwargs) + self.timestamp = kwargs.get('timestamp', None) + self.value = kwargs.get('value', None) + + +class VariableState(Model): + """VariableState. + + :param variable: Variable name. + :type variable: str + :param filled_na_ratio: Proportion of NaN values filled of the variable. + :type filled_na_ratio: float + :param effective_count: Number of effective points counted. + :type effective_count: int + :param start_time: Start time of the variable. + :type start_time: datetime + :param end_time: End time of the variable. + :type end_time: datetime + """ + + _validation = { + 'filled_na_ratio': {'maximum': 1, 'minimum': 0}, + } + + _attribute_map = { + 'variable': {'key': 'variable', 'type': 'str'}, + 'filled_na_ratio': {'key': 'filledNARatio', 'type': 'float'}, + 'effective_count': {'key': 'effectiveCount', 'type': 'int'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(VariableState, self).__init__(**kwargs) + self.variable = kwargs.get('variable', None) + self.filled_na_ratio = kwargs.get('filled_na_ratio', None) + self.effective_count = kwargs.get('effective_count', None) + self.start_time = kwargs.get('start_time', None) + self.end_time = kwargs.get('end_time', None) + + +class VariableValues(Model): + """VariableValues. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. variable name + :type name: str + :param timestamps: Required. timestamps + :type timestamps: list[str] + :param values: Required. values + :type values: list[float] + """ + + _validation = { + 'name': {'required': True}, + 'timestamps': {'required': True}, + 'values': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'timestamps': {'key': 'timestamps', 'type': '[str]'}, + 'values': {'key': 'values', 'type': '[float]'}, + } + + def __init__(self, **kwargs): + super(VariableValues, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.timestamps = kwargs.get('timestamps', None) + self.values = kwargs.get('values', None) diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_models_py3.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_models_py3.py new file mode 100644 index 000000000000..9bb2dafbb5af --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/models/_models_py3.py @@ -0,0 +1,1038 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class AlignPolicy(Model): + """AlignPolicy. + + :param align_mode: An optional field, indicating how we align different + variables to the same time-range. Either Inner or Outer. Possible values + include: 'Inner', 'Outer' + :type align_mode: str or ~azure.ai.anomalydetector.models.AlignMode + :param fill_na_method: An optional field, indicating how missing values + will be filled. One of Previous, Subsequent, Linear, Zero, Fixed, and + NotFill. Cannot be set to NotFill, when the alignMode is Outer. Possible + values include: 'Previous', 'Subsequent', 'Linear', 'Zero', 'Fixed', + 'NotFill' + :type fill_na_method: str or ~azure.ai.anomalydetector.models.FillNAMethod + :param padding_value: An optional field. Required when fillNAMethod is + Fixed. + :type padding_value: float + """ + + _attribute_map = { + 'align_mode': {'key': 'alignMode', 'type': 'AlignMode'}, + 'fill_na_method': {'key': 'fillNAMethod', 'type': 'str'}, + 'padding_value': {'key': 'paddingValue', 'type': 'float'}, + } + + def __init__(self, *, align_mode=None, fill_na_method=None, padding_value: float=None, **kwargs) -> None: + super(AlignPolicy, self).__init__(**kwargs) + self.align_mode = align_mode + self.fill_na_method = fill_na_method + self.padding_value = padding_value + + +class AnomalyDetectorError(Model): + """Error information returned by the API. + + :param code: The error code. + :type code: object + :param message: A message explaining the error reported by the service. + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'object'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, *, code=None, message: str=None, **kwargs) -> None: + super(AnomalyDetectorError, self).__init__(**kwargs) + self.code = code + self.message = message + + +class AnomalyDetectorErrorException(HttpOperationError): + """Server responsed with exception of type: 'AnomalyDetectorError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(AnomalyDetectorErrorException, self).__init__(deserialize, response, 'AnomalyDetectorError', *args) + + +class AnomalyInterpretation(Model): + """AnomalyInterpretation. + + :param variable: + :type variable: str + :param contribution_score: + :type contribution_score: float + :param correlation_changes: + :type correlation_changes: + ~azure.ai.anomalydetector.models.CorrelationChanges + """ + + _attribute_map = { + 'variable': {'key': 'variable', 'type': 'str'}, + 'contribution_score': {'key': 'contributionScore', 'type': 'float'}, + 'correlation_changes': {'key': 'correlationChanges', 'type': 'CorrelationChanges'}, + } + + def __init__(self, *, variable: str=None, contribution_score: float=None, correlation_changes=None, **kwargs) -> None: + super(AnomalyInterpretation, self).__init__(**kwargs) + self.variable = variable + self.contribution_score = contribution_score + self.correlation_changes = correlation_changes + + +class AnomalyState(Model): + """AnomalyState. + + All required parameters must be populated in order to send to Azure. + + :param timestamp: Required. timestamp + :type timestamp: datetime + :param value: + :type value: ~azure.ai.anomalydetector.models.AnomalyValue + :param errors: Error message for the current timestamp + :type errors: list[~azure.ai.anomalydetector.models.ErrorResponse] + """ + + _validation = { + 'timestamp': {'required': True}, + } + + _attribute_map = { + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'value': {'key': 'value', 'type': 'AnomalyValue'}, + 'errors': {'key': 'errors', 'type': '[ErrorResponse]'}, + } + + def __init__(self, *, timestamp, value=None, errors=None, **kwargs) -> None: + super(AnomalyState, self).__init__(**kwargs) + self.timestamp = timestamp + self.value = value + self.errors = errors + + +class AnomalyValue(Model): + """AnomalyValue. + + All required parameters must be populated in order to send to Azure. + + :param is_anomaly: Required. True if an anomaly is detected at the current + timestamp. + :type is_anomaly: bool + :param severity: Required. Indicates the significance of the anomaly. The + higher the severity, the more significant the anomaly. + :type severity: float + :param score: Required. Raw score from the model. + :type score: float + :param interpretation: + :type interpretation: + list[~azure.ai.anomalydetector.models.AnomalyInterpretation] + """ + + _validation = { + 'is_anomaly': {'required': True}, + 'severity': {'required': True, 'maximum': 1, 'minimum': 0}, + 'score': {'required': True, 'maximum': 2, 'minimum': 0}, + } + + _attribute_map = { + 'is_anomaly': {'key': 'isAnomaly', 'type': 'bool'}, + 'severity': {'key': 'severity', 'type': 'float'}, + 'score': {'key': 'score', 'type': 'float'}, + 'interpretation': {'key': 'interpretation', 'type': '[AnomalyInterpretation]'}, + } + + def __init__(self, *, is_anomaly: bool, severity: float, score: float, interpretation=None, **kwargs) -> None: + super(AnomalyValue, self).__init__(**kwargs) + self.is_anomaly = is_anomaly + self.severity = severity + self.score = score + self.interpretation = interpretation + + +class ChangePointDetectRequest(Model): + """The request of change point detection. + + All required parameters must be populated in order to send to Azure. + + :param series: Required. Time series data points. Points should be sorted + by timestamp in ascending order to match the change point detection + result. + :type series: list[~azure.ai.anomalydetector.models.TimeSeriesPoint] + :param granularity: Required. Can only be one of yearly, monthly, weekly, + daily, hourly, minutely or secondly. Granularity is used for verify + whether input series is valid. Possible values include: 'yearly', + 'monthly', 'weekly', 'daily', 'hourly', 'perMinute', 'perSecond', + 'microsecond', 'none' + :type granularity: str or ~azure.ai.anomalydetector.models.TimeGranularity + :param custom_interval: Custom Interval is used to set non-standard time + interval, for example, if the series is 5 minutes, request can be set as + {"granularity":"minutely", "customInterval":5}. + :type custom_interval: int + :param period: Optional argument, periodic value of a time series. If the + value is null or does not present, the API will determine the period + automatically. + :type period: int + :param stable_trend_window: Optional argument, advanced model parameter, a + default stableTrendWindow will be used in detection. + :type stable_trend_window: int + :param threshold: Optional argument, advanced model parameter, between + 0.0-1.0, the lower the value is, the larger the trend error will be which + means less change point will be accepted. + :type threshold: float + """ + + _validation = { + 'series': {'required': True}, + 'granularity': {'required': True}, + } + + _attribute_map = { + 'series': {'key': 'series', 'type': '[TimeSeriesPoint]'}, + 'granularity': {'key': 'granularity', 'type': 'TimeGranularity'}, + 'custom_interval': {'key': 'customInterval', 'type': 'int'}, + 'period': {'key': 'period', 'type': 'int'}, + 'stable_trend_window': {'key': 'stableTrendWindow', 'type': 'int'}, + 'threshold': {'key': 'threshold', 'type': 'float'}, + } + + def __init__(self, *, series, granularity, custom_interval: int=None, period: int=None, stable_trend_window: int=None, threshold: float=None, **kwargs) -> None: + super(ChangePointDetectRequest, self).__init__(**kwargs) + self.series = series + self.granularity = granularity + self.custom_interval = custom_interval + self.period = period + self.stable_trend_window = stable_trend_window + self.threshold = threshold + + +class ChangePointDetectResponse(Model): + """The response of change point detection. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar period: Frequency extracted from the series, zero means no recurrent + pattern has been found. + :vartype period: int + :param is_change_point: isChangePoint contains change point properties for + each input point. True means an anomaly either negative or positive has + been detected. The index of the array is consistent with the input series. + :type is_change_point: list[bool] + :param confidence_scores: the change point confidence of each point + :type confidence_scores: list[float] + """ + + _validation = { + 'period': {'readonly': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'is_change_point': {'key': 'isChangePoint', 'type': '[bool]'}, + 'confidence_scores': {'key': 'confidenceScores', 'type': '[float]'}, + } + + def __init__(self, *, is_change_point=None, confidence_scores=None, **kwargs) -> None: + super(ChangePointDetectResponse, self).__init__(**kwargs) + self.period = None + self.is_change_point = is_change_point + self.confidence_scores = confidence_scores + + +class CorrelationChanges(Model): + """CorrelationChanges. + + :param changed_variables: correlated variables + :type changed_variables: list[str] + :param changed_values: changes in correlation + :type changed_values: list[float] + """ + + _attribute_map = { + 'changed_variables': {'key': 'changedVariables', 'type': '[str]'}, + 'changed_values': {'key': 'changedValues', 'type': '[float]'}, + } + + def __init__(self, *, changed_variables=None, changed_values=None, **kwargs) -> None: + super(CorrelationChanges, self).__init__(**kwargs) + self.changed_variables = changed_variables + self.changed_values = changed_values + + +class DetectionRequest(Model): + """Detection request. + + All required parameters must be populated in order to send to Azure. + + :param source: Required. Source link to the input variables. Each variable + should be a csv with two columns, `timestamp` and `value`. The file name + of the variable will be used as its name. The variables used in detection + should be exactly the same with those used in the training phase. + :type source: str + :param start_time: Required. A required field, indicating the start time + of data for detection. Should be date-time. + :type start_time: datetime + :param end_time: Required. A required field, indicating the end time of + data for detection. Should be date-time. + :type end_time: datetime + """ + + _validation = { + 'source': {'required': True}, + 'start_time': {'required': True}, + 'end_time': {'required': True}, + } + + _attribute_map = { + 'source': {'key': 'source', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + } + + def __init__(self, *, source: str, start_time, end_time, **kwargs) -> None: + super(DetectionRequest, self).__init__(**kwargs) + self.source = source + self.start_time = start_time + self.end_time = end_time + + +class DetectionResult(Model): + """Response of the given resultId. + + All required parameters must be populated in order to send to Azure. + + :param result_id: Required. + :type result_id: str + :param summary: Required. + :type summary: ~azure.ai.anomalydetector.models.DetectionResultSummary + :param results: Required. Detection result for each timestamp. + :type results: list[~azure.ai.anomalydetector.models.AnomalyState] + """ + + _validation = { + 'result_id': {'required': True}, + 'summary': {'required': True}, + 'results': {'required': True}, + } + + _attribute_map = { + 'result_id': {'key': 'resultId', 'type': 'str'}, + 'summary': {'key': 'summary', 'type': 'DetectionResultSummary'}, + 'results': {'key': 'results', 'type': '[AnomalyState]'}, + } + + def __init__(self, *, result_id: str, summary, results, **kwargs) -> None: + super(DetectionResult, self).__init__(**kwargs) + self.result_id = result_id + self.summary = summary + self.results = results + + +class DetectionResultSummary(Model): + """DetectionResultSummary. + + All required parameters must be populated in order to send to Azure. + + :param status: Required. Status of detection results. One of CREATED, + RUNNING, READY, and FAILED. Possible values include: 'CREATED', 'RUNNING', + 'READY', 'FAILED' + :type status: str or ~azure.ai.anomalydetector.models.DetectionStatus + :param errors: Error message when detection is failed. + :type errors: list[~azure.ai.anomalydetector.models.ErrorResponse] + :param variable_states: + :type variable_states: + list[~azure.ai.anomalydetector.models.VariableState] + :param setup_info: Required. + :type setup_info: ~azure.ai.anomalydetector.models.DetectionRequest + """ + + _validation = { + 'status': {'required': True}, + 'setup_info': {'required': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'DetectionStatus'}, + 'errors': {'key': 'errors', 'type': '[ErrorResponse]'}, + 'variable_states': {'key': 'variableStates', 'type': '[VariableState]'}, + 'setup_info': {'key': 'setupInfo', 'type': 'DetectionRequest'}, + } + + def __init__(self, *, status, setup_info, errors=None, variable_states=None, **kwargs) -> None: + super(DetectionResultSummary, self).__init__(**kwargs) + self.status = status + self.errors = errors + self.variable_states = variable_states + self.setup_info = setup_info + + +class DetectRequest(Model): + """The request of entire or last anomaly detection. + + All required parameters must be populated in order to send to Azure. + + :param series: Required. Time series data points. Points should be sorted + by timestamp in ascending order to match the anomaly detection result. If + the data is not sorted correctly or there is duplicated timestamp, the API + will not work. In such case, an error message will be returned. + :type series: list[~azure.ai.anomalydetector.models.TimeSeriesPoint] + :param granularity: Possible values include: 'yearly', 'monthly', + 'weekly', 'daily', 'hourly', 'perMinute', 'perSecond', 'microsecond', + 'none' + :type granularity: str or ~azure.ai.anomalydetector.models.TimeGranularity + :param custom_interval: Custom Interval is used to set non-standard time + interval, for example, if the series is 5 minutes, request can be set as + {"granularity":"minutely", "customInterval":5}. + :type custom_interval: int + :param period: Optional argument, periodic value of a time series. If the + value is null or does not present, the API will determine the period + automatically. + :type period: int + :param max_anomaly_ratio: Optional argument, advanced model parameter, max + anomaly ratio in a time series. + :type max_anomaly_ratio: float + :param sensitivity: Optional argument, advanced model parameter, between + 0-99, the lower the value is, the larger the margin value will be which + means less anomalies will be accepted. + :type sensitivity: int + :param impute_mode: Used to specify how to deal with missing values in the + input series, it's used when granularity is not "none". Possible values + include: 'auto', 'previous', 'linear', 'fixed', 'zero', 'notFill' + :type impute_mode: str or ~azure.ai.anomalydetector.models.ImputeMode + :param impute_fixed_value: Used to specify the value to fill, it's used + when granularity is not "none" and imputeMode is "fixed". + :type impute_fixed_value: float + """ + + _validation = { + 'series': {'required': True}, + } + + _attribute_map = { + 'series': {'key': 'series', 'type': '[TimeSeriesPoint]'}, + 'granularity': {'key': 'granularity', 'type': 'TimeGranularity'}, + 'custom_interval': {'key': 'customInterval', 'type': 'int'}, + 'period': {'key': 'period', 'type': 'int'}, + 'max_anomaly_ratio': {'key': 'maxAnomalyRatio', 'type': 'float'}, + 'sensitivity': {'key': 'sensitivity', 'type': 'int'}, + 'impute_mode': {'key': 'imputeMode', 'type': 'str'}, + 'impute_fixed_value': {'key': 'imputeFixedValue', 'type': 'float'}, + } + + def __init__(self, *, series, granularity=None, custom_interval: int=None, period: int=None, max_anomaly_ratio: float=None, sensitivity: int=None, impute_mode=None, impute_fixed_value: float=None, **kwargs) -> None: + super(DetectRequest, self).__init__(**kwargs) + self.series = series + self.granularity = granularity + self.custom_interval = custom_interval + self.period = period + self.max_anomaly_ratio = max_anomaly_ratio + self.sensitivity = sensitivity + self.impute_mode = impute_mode + self.impute_fixed_value = impute_fixed_value + + +class DiagnosticsInfo(Model): + """DiagnosticsInfo. + + :param model_state: + :type model_state: ~azure.ai.anomalydetector.models.ModelState + :param variable_states: + :type variable_states: + list[~azure.ai.anomalydetector.models.VariableState] + """ + + _attribute_map = { + 'model_state': {'key': 'modelState', 'type': 'ModelState'}, + 'variable_states': {'key': 'variableStates', 'type': '[VariableState]'}, + } + + def __init__(self, *, model_state=None, variable_states=None, **kwargs) -> None: + super(DiagnosticsInfo, self).__init__(**kwargs) + self.model_state = model_state + self.variable_states = variable_states + + +class EntireDetectResponse(Model): + """The response of entire anomaly detection. + + All required parameters must be populated in order to send to Azure. + + :param period: Required. Frequency extracted from the series, zero means + no recurrent pattern has been found. + :type period: int + :param expected_values: Required. ExpectedValues contain expected value + for each input point. The index of the array is consistent with the input + series. + :type expected_values: list[float] + :param upper_margins: Required. UpperMargins contain upper margin of each + input point. UpperMargin is used to calculate upperBoundary, which equals + to expectedValue + (100 - marginScale)*upperMargin. Anomalies in response + can be filtered by upperBoundary and lowerBoundary. By adjusting + marginScale value, less significant anomalies can be filtered in client + side. The index of the array is consistent with the input series. + :type upper_margins: list[float] + :param lower_margins: Required. LowerMargins contain lower margin of each + input point. LowerMargin is used to calculate lowerBoundary, which equals + to expectedValue - (100 - marginScale)*lowerMargin. Points between the + boundary can be marked as normal ones in client side. The index of the + array is consistent with the input series. + :type lower_margins: list[float] + :param is_anomaly: Required. IsAnomaly contains anomaly properties for + each input point. True means an anomaly either negative or positive has + been detected. The index of the array is consistent with the input series. + :type is_anomaly: list[bool] + :param is_negative_anomaly: Required. IsNegativeAnomaly contains anomaly + status in negative direction for each input point. True means a negative + anomaly has been detected. A negative anomaly means the point is detected + as an anomaly and its real value is smaller than the expected one. The + index of the array is consistent with the input series. + :type is_negative_anomaly: list[bool] + :param is_positive_anomaly: Required. IsPositiveAnomaly contain anomaly + status in positive direction for each input point. True means a positive + anomaly has been detected. A positive anomaly means the point is detected + as an anomaly and its real value is larger than the expected one. The + index of the array is consistent with the input series. + :type is_positive_anomaly: list[bool] + :param severity: The severity score for each input point. The larger the + value is, the more sever the anomaly is. For normal points, the "severity" + is always 0. + :type severity: list[float] + """ + + _validation = { + 'period': {'required': True}, + 'expected_values': {'required': True}, + 'upper_margins': {'required': True}, + 'lower_margins': {'required': True}, + 'is_anomaly': {'required': True}, + 'is_negative_anomaly': {'required': True}, + 'is_positive_anomaly': {'required': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'expected_values': {'key': 'expectedValues', 'type': '[float]'}, + 'upper_margins': {'key': 'upperMargins', 'type': '[float]'}, + 'lower_margins': {'key': 'lowerMargins', 'type': '[float]'}, + 'is_anomaly': {'key': 'isAnomaly', 'type': '[bool]'}, + 'is_negative_anomaly': {'key': 'isNegativeAnomaly', 'type': '[bool]'}, + 'is_positive_anomaly': {'key': 'isPositiveAnomaly', 'type': '[bool]'}, + 'severity': {'key': 'severity', 'type': '[float]'}, + } + + def __init__(self, *, period: int, expected_values, upper_margins, lower_margins, is_anomaly, is_negative_anomaly, is_positive_anomaly, severity=None, **kwargs) -> None: + super(EntireDetectResponse, self).__init__(**kwargs) + self.period = period + self.expected_values = expected_values + self.upper_margins = upper_margins + self.lower_margins = lower_margins + self.is_anomaly = is_anomaly + self.is_negative_anomaly = is_negative_anomaly + self.is_positive_anomaly = is_positive_anomaly + self.severity = severity + + +class ErrorResponse(Model): + """ErrorResponse. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. The error code. + :type code: str + :param message: Required. The message explaining the error reported by the + service. + :type message: str + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, *, code: str, message: str, **kwargs) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.code = code + self.message = message + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class LastDetectionRequest(Model): + """LastDetectionRequest. + + All required parameters must be populated in order to send to Azure. + + :param variables: Required. variables + :type variables: list[~azure.ai.anomalydetector.models.VariableValues] + :param detecting_points: Required. number of timestamps on which the model + detects + :type detecting_points: int + """ + + _validation = { + 'variables': {'required': True}, + 'detecting_points': {'required': True}, + } + + _attribute_map = { + 'variables': {'key': 'variables', 'type': '[VariableValues]'}, + 'detecting_points': {'key': 'detectingPoints', 'type': 'int'}, + } + + def __init__(self, *, variables, detecting_points: int, **kwargs) -> None: + super(LastDetectionRequest, self).__init__(**kwargs) + self.variables = variables + self.detecting_points = detecting_points + + +class LastDetectionResult(Model): + """LastDetectionResult. + + :param variable_states: + :type variable_states: + list[~azure.ai.anomalydetector.models.VariableState] + :param results: + :type results: list[~azure.ai.anomalydetector.models.AnomalyState] + """ + + _attribute_map = { + 'variable_states': {'key': 'variableStates', 'type': '[VariableState]'}, + 'results': {'key': 'results', 'type': '[AnomalyState]'}, + } + + def __init__(self, *, variable_states=None, results=None, **kwargs) -> None: + super(LastDetectionResult, self).__init__(**kwargs) + self.variable_states = variable_states + self.results = results + + +class LastDetectResponse(Model): + """The response of last anomaly detection. + + All required parameters must be populated in order to send to Azure. + + :param period: Required. Frequency extracted from the series, zero means + no recurrent pattern has been found. + :type period: int + :param suggested_window: Required. Suggested input series points needed + for detecting the latest point. + :type suggested_window: int + :param expected_value: Required. Expected value of the latest point. + :type expected_value: float + :param upper_margin: Required. Upper margin of the latest point. + UpperMargin is used to calculate upperBoundary, which equals to + expectedValue + (100 - marginScale)*upperMargin. If the value of latest + point is between upperBoundary and lowerBoundary, it should be treated as + normal value. By adjusting marginScale value, anomaly status of latest + point can be changed. + :type upper_margin: float + :param lower_margin: Required. Lower margin of the latest point. + LowerMargin is used to calculate lowerBoundary, which equals to + expectedValue - (100 - marginScale)*lowerMargin. + :type lower_margin: float + :param is_anomaly: Required. Anomaly status of the latest point, true + means the latest point is an anomaly either in negative direction or + positive direction. + :type is_anomaly: bool + :param is_negative_anomaly: Required. Anomaly status in negative direction + of the latest point. True means the latest point is an anomaly and its + real value is smaller than the expected one. + :type is_negative_anomaly: bool + :param is_positive_anomaly: Required. Anomaly status in positive direction + of the latest point. True means the latest point is an anomaly and its + real value is larger than the expected one. + :type is_positive_anomaly: bool + :param severity: The severity score for the last input point. The larger + the value is, the more sever the anomaly is. For normal points, the + "severity" is always 0. + :type severity: float + """ + + _validation = { + 'period': {'required': True}, + 'suggested_window': {'required': True}, + 'expected_value': {'required': True}, + 'upper_margin': {'required': True}, + 'lower_margin': {'required': True}, + 'is_anomaly': {'required': True}, + 'is_negative_anomaly': {'required': True}, + 'is_positive_anomaly': {'required': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'suggested_window': {'key': 'suggestedWindow', 'type': 'int'}, + 'expected_value': {'key': 'expectedValue', 'type': 'float'}, + 'upper_margin': {'key': 'upperMargin', 'type': 'float'}, + 'lower_margin': {'key': 'lowerMargin', 'type': 'float'}, + 'is_anomaly': {'key': 'isAnomaly', 'type': 'bool'}, + 'is_negative_anomaly': {'key': 'isNegativeAnomaly', 'type': 'bool'}, + 'is_positive_anomaly': {'key': 'isPositiveAnomaly', 'type': 'bool'}, + 'severity': {'key': 'severity', 'type': 'float'}, + } + + def __init__(self, *, period: int, suggested_window: int, expected_value: float, upper_margin: float, lower_margin: float, is_anomaly: bool, is_negative_anomaly: bool, is_positive_anomaly: bool, severity: float=None, **kwargs) -> None: + super(LastDetectResponse, self).__init__(**kwargs) + self.period = period + self.suggested_window = suggested_window + self.expected_value = expected_value + self.upper_margin = upper_margin + self.lower_margin = lower_margin + self.is_anomaly = is_anomaly + self.is_negative_anomaly = is_negative_anomaly + self.is_positive_anomaly = is_positive_anomaly + self.severity = severity + + +class Model(Model): + """Response of getting a model. + + All required parameters must be populated in order to send to Azure. + + :param model_id: Required. Model identifier. + :type model_id: str + :param created_time: Required. Date and time (UTC) when the model was + created. + :type created_time: datetime + :param last_updated_time: Required. Date and time (UTC) when the model was + last updated. + :type last_updated_time: datetime + :param model_info: + :type model_info: ~azure.ai.anomalydetector.models.ModelInfo + """ + + _validation = { + 'model_id': {'required': True}, + 'created_time': {'required': True}, + 'last_updated_time': {'required': True}, + } + + _attribute_map = { + 'model_id': {'key': 'modelId', 'type': 'str'}, + 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, + 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, + 'model_info': {'key': 'modelInfo', 'type': 'ModelInfo'}, + } + + def __init__(self, *, model_id: str, created_time, last_updated_time, model_info=None, **kwargs) -> None: + super(Model, self).__init__(**kwargs) + self.model_id = model_id + self.created_time = created_time + self.last_updated_time = last_updated_time + self.model_info = model_info + + +class ModelInfo(Model): + """Train result of a model including status, errors and diagnose info for + model and variables. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param sliding_window: An optional field, indicating how many previous + points will be used to compute the anomaly score of the subsequent point. + :type sliding_window: int + :param align_policy: + :type align_policy: ~azure.ai.anomalydetector.models.AlignPolicy + :param source: Required. Source link to the input variables. Each variable + should be a csv file with two columns, `timestamp` and `value`. By + default, the file name of the variable will be used as its variable name. + :type source: str + :param start_time: Required. A required field, indicating the start time + of training data. Should be date-time. + :type start_time: datetime + :param end_time: Required. A required field, indicating the end time of + training data. Should be date-time. + :type end_time: datetime + :param display_name: An optional field. The name of the model whose + maximum length is 24. + :type display_name: str + :param status: Possible values include: 'CREATED', 'RUNNING', 'READY', + 'FAILED' + :type status: str or ~azure.ai.anomalydetector.models.ModelStatus + :ivar errors: Error messages when failed to create a model. + :vartype errors: list[~azure.ai.anomalydetector.models.ErrorResponse] + :param diagnostics_info: + :type diagnostics_info: ~azure.ai.anomalydetector.models.DiagnosticsInfo + """ + + _validation = { + 'source': {'required': True}, + 'start_time': {'required': True}, + 'end_time': {'required': True}, + 'display_name': {'max_length': 24}, + 'errors': {'readonly': True}, + } + + _attribute_map = { + 'sliding_window': {'key': 'slidingWindow', 'type': 'int'}, + 'align_policy': {'key': 'alignPolicy', 'type': 'AlignPolicy'}, + 'source': {'key': 'source', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'ModelStatus'}, + 'errors': {'key': 'errors', 'type': '[ErrorResponse]'}, + 'diagnostics_info': {'key': 'diagnosticsInfo', 'type': 'DiagnosticsInfo'}, + } + + def __init__(self, *, source: str, start_time, end_time, sliding_window: int=None, align_policy=None, display_name: str=None, status=None, diagnostics_info=None, **kwargs) -> None: + super(ModelInfo, self).__init__(**kwargs) + self.sliding_window = sliding_window + self.align_policy = align_policy + self.source = source + self.start_time = start_time + self.end_time = end_time + self.display_name = display_name + self.status = status + self.errors = None + self.diagnostics_info = diagnostics_info + + +class ModelList(Model): + """Response of listing models. + + All required parameters must be populated in order to send to Azure. + + :param models_property: Required. List of models + :type models_property: + list[~azure.ai.anomalydetector.models.ModelSnapshot] + :param current_count: Required. Current count of trained multivariate + models. + :type current_count: int + :param max_count: Required. Max number of models that can be trained for + this subscription. + :type max_count: int + :param next_link: The link to fetch more models. + :type next_link: str + """ + + _validation = { + 'models_property': {'required': True}, + 'current_count': {'required': True}, + 'max_count': {'required': True}, + } + + _attribute_map = { + 'models_property': {'key': 'models', 'type': '[ModelSnapshot]'}, + 'current_count': {'key': 'currentCount', 'type': 'int'}, + 'max_count': {'key': 'maxCount', 'type': 'int'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, models_property, current_count: int, max_count: int, next_link: str=None, **kwargs) -> None: + super(ModelList, self).__init__(**kwargs) + self.models_property = models_property + self.current_count = current_count + self.max_count = max_count + self.next_link = next_link + + +class ModelSnapshot(Model): + """ModelSnapshot. + + All required parameters must be populated in order to send to Azure. + + :param model_id: Required. Model identifier. + :type model_id: str + :param created_time: Required. Date and time (UTC) when the model was + created. + :type created_time: datetime + :param last_updated_time: Required. Date and time (UTC) when the model was + last updated. + :type last_updated_time: datetime + :param status: Required. Possible values include: 'CREATED', 'RUNNING', + 'READY', 'FAILED' + :type status: str or ~azure.ai.anomalydetector.models.ModelStatus + :param display_name: + :type display_name: str + :param variables_count: Required. Total number of variables. + :type variables_count: int + """ + + _validation = { + 'model_id': {'required': True}, + 'created_time': {'required': True}, + 'last_updated_time': {'required': True}, + 'status': {'required': True}, + 'variables_count': {'required': True}, + } + + _attribute_map = { + 'model_id': {'key': 'modelId', 'type': 'str'}, + 'created_time': {'key': 'createdTime', 'type': 'iso-8601'}, + 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, + 'status': {'key': 'status', 'type': 'ModelStatus'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'variables_count': {'key': 'variablesCount', 'type': 'int'}, + } + + def __init__(self, *, model_id: str, created_time, last_updated_time, status, variables_count: int, display_name: str=None, **kwargs) -> None: + super(ModelSnapshot, self).__init__(**kwargs) + self.model_id = model_id + self.created_time = created_time + self.last_updated_time = last_updated_time + self.status = status + self.display_name = display_name + self.variables_count = variables_count + + +class ModelState(Model): + """ModelState. + + :param epoch_ids: Epoch id + :type epoch_ids: list[int] + :param train_losses: + :type train_losses: list[float] + :param validation_losses: + :type validation_losses: list[float] + :param latencies_in_seconds: + :type latencies_in_seconds: list[float] + """ + + _attribute_map = { + 'epoch_ids': {'key': 'epochIds', 'type': '[int]'}, + 'train_losses': {'key': 'trainLosses', 'type': '[float]'}, + 'validation_losses': {'key': 'validationLosses', 'type': '[float]'}, + 'latencies_in_seconds': {'key': 'latenciesInSeconds', 'type': '[float]'}, + } + + def __init__(self, *, epoch_ids=None, train_losses=None, validation_losses=None, latencies_in_seconds=None, **kwargs) -> None: + super(ModelState, self).__init__(**kwargs) + self.epoch_ids = epoch_ids + self.train_losses = train_losses + self.validation_losses = validation_losses + self.latencies_in_seconds = latencies_in_seconds + + +class TimeSeriesPoint(Model): + """The definition of input timeseries points. + + All required parameters must be populated in order to send to Azure. + + :param timestamp: Optional argument, timestamp of a data point (ISO8601 + format). + :type timestamp: datetime + :param value: Required. The measurement of that point, should be float. + :type value: float + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, *, value: float, timestamp=None, **kwargs) -> None: + super(TimeSeriesPoint, self).__init__(**kwargs) + self.timestamp = timestamp + self.value = value + + +class VariableState(Model): + """VariableState. + + :param variable: Variable name. + :type variable: str + :param filled_na_ratio: Proportion of NaN values filled of the variable. + :type filled_na_ratio: float + :param effective_count: Number of effective points counted. + :type effective_count: int + :param start_time: Start time of the variable. + :type start_time: datetime + :param end_time: End time of the variable. + :type end_time: datetime + """ + + _validation = { + 'filled_na_ratio': {'maximum': 1, 'minimum': 0}, + } + + _attribute_map = { + 'variable': {'key': 'variable', 'type': 'str'}, + 'filled_na_ratio': {'key': 'filledNARatio', 'type': 'float'}, + 'effective_count': {'key': 'effectiveCount', 'type': 'int'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + } + + def __init__(self, *, variable: str=None, filled_na_ratio: float=None, effective_count: int=None, start_time=None, end_time=None, **kwargs) -> None: + super(VariableState, self).__init__(**kwargs) + self.variable = variable + self.filled_na_ratio = filled_na_ratio + self.effective_count = effective_count + self.start_time = start_time + self.end_time = end_time + + +class VariableValues(Model): + """VariableValues. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. variable name + :type name: str + :param timestamps: Required. timestamps + :type timestamps: list[str] + :param values: Required. values + :type values: list[float] + """ + + _validation = { + 'name': {'required': True}, + 'timestamps': {'required': True}, + 'values': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'timestamps': {'key': 'timestamps', 'type': '[str]'}, + 'values': {'key': 'values', 'type': '[float]'}, + } + + def __init__(self, *, name: str, timestamps, values, **kwargs) -> None: + super(VariableValues, self).__init__(**kwargs) + self.name = name + self.timestamps = timestamps + self.values = values diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/operations/__init__.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/operations/__init__.py new file mode 100644 index 000000000000..ed756e4e57b2 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/operations/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from ._anomaly_detector_client_operations import AnomalyDetectorClientOperationsMixin + +__all__ = [ + 'AnomalyDetectorClientOperationsMixin', +] diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/operations/_anomaly_detector_client_operations.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/operations/_anomaly_detector_client_operations.py new file mode 100644 index 000000000000..5763758c5c47 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/operations/_anomaly_detector_client_operations.py @@ -0,0 +1,699 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse +from .. import models + + +class AnomalyDetectorClientOperationsMixin(object): + + def detect_entire_series( + self, body, custom_headers=None, raw=False, **operation_config): + """Detect anomalies for the entire series in batch. + + This operation generates a model with an entire series, each point is + detected with the same model. With this method, points before and after + a certain point are used to determine whether it is an anomaly. The + entire detection can give user an overall status of the time series. + + :param body: Time series points and period if needed. Advanced model + parameters can also be set in the request. + :type body: ~azure.ai.anomalydetector.models.DetectRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: EntireDetectResponse or ClientRawResponse if raw=true + :rtype: ~azure.ai.anomalydetector.models.EntireDetectResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`AnomalyDetectorErrorException` + """ + # Construct URL + url = self.detect_entire_series.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'ApiVersion': self._serialize.url("self.api_version", self.api_version, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'DetectRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.AnomalyDetectorErrorException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('EntireDetectResponse', response) + header_dict = { + 'x-ms-error-code': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + detect_entire_series.metadata = {'url': '/timeseries/entire/detect'} + + def detect_last_point( + self, body, custom_headers=None, raw=False, **operation_config): + """Detect anomaly status of the latest point in time series. + + This operation generates a model using points before the latest one. + With this method, only historical points are used to determine whether + the target point is an anomaly. The latest point detecting operation + matches the scenario of real-time monitoring of business metrics. + + :param body: Time series points and period if needed. Advanced model + parameters can also be set in the request. + :type body: ~azure.ai.anomalydetector.models.DetectRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: LastDetectResponse or ClientRawResponse if raw=true + :rtype: ~azure.ai.anomalydetector.models.LastDetectResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`AnomalyDetectorErrorException` + """ + # Construct URL + url = self.detect_last_point.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'ApiVersion': self._serialize.url("self.api_version", self.api_version, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'DetectRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.AnomalyDetectorErrorException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('LastDetectResponse', response) + header_dict = { + 'x-ms-error-code': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + detect_last_point.metadata = {'url': '/timeseries/last/detect'} + + def detect_change_point( + self, body, custom_headers=None, raw=False, **operation_config): + """Detect change point for the entire series. + + Evaluate change point score of every series point. + + :param body: Time series points and granularity is needed. Advanced + model parameters can also be set in the request if needed. + :type body: ~azure.ai.anomalydetector.models.ChangePointDetectRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ChangePointDetectResponse or ClientRawResponse if raw=true + :rtype: ~azure.ai.anomalydetector.models.ChangePointDetectResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`AnomalyDetectorErrorException` + """ + # Construct URL + url = self.detect_change_point.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'ApiVersion': self._serialize.url("self.api_version", self.api_version, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'ChangePointDetectRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.AnomalyDetectorErrorException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ChangePointDetectResponse', response) + header_dict = { + 'x-ms-error-code': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + detect_change_point.metadata = {'url': '/timeseries/changepoint/detect'} + + def train_multivariate_model( + self, body, custom_headers=None, raw=False, **operation_config): + """Train a Multivariate Anomaly Detection Model. + + Create and train a multivariate anomaly detection model. The request + must include a source parameter to indicate an externally accessible + Azure storage Uri (preferably a Shared Access Signature Uri). All + time-series used in generate the model must be zipped into one single + file. Each time-series will be in a single CSV file in which the first + column is timestamp and the second column is value. + + :param body: Training request + :type body: ~azure.ai.anomalydetector.models.ModelInfo + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.train_multivariate_model.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'ApiVersion': self._serialize.url("self.api_version", self.api_version, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'ModelInfo') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [201]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + client_raw_response.add_headers({ + 'Location': 'str', + 'x-ms-error-code': 'str', + }) + return client_raw_response + train_multivariate_model.metadata = {'url': '/multivariate/models'} + + def list_multivariate_model( + self, skip=0, top=5, custom_headers=None, raw=False, **operation_config): + """List Multivariate Models. + + List models of a subscription. + + :param skip: $skip indicates how many models will be skipped. + :type skip: int + :param top: $top indicates how many models will be fetched. + :type top: int + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ModelList or ClientRawResponse if raw=true + :rtype: ~azure.ai.anomalydetector.models.ModelList or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.list_multivariate_model.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'ApiVersion': self._serialize.url("self.api_version", self.api_version, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ModelList', response) + header_dict = { + 'x-ms-error-code': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + list_multivariate_model.metadata = {'url': '/multivariate/models'} + + def get_multivariate_model( + self, model_id, custom_headers=None, raw=False, **operation_config): + """Get Multivariate Model. + + Get detailed information of multivariate model, including the training + status and variables used in the model. + + :param model_id: Model identifier. + :type model_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Model or ClientRawResponse if raw=true + :rtype: ~azure.ai.anomalydetector.models.Model or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_multivariate_model.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'ApiVersion': self._serialize.url("self.api_version", self.api_version, 'str', skip_quote=True), + 'modelId': self._serialize.url("model_id", model_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Model', response) + header_dict = { + 'x-ms-error-code': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + get_multivariate_model.metadata = {'url': '/multivariate/models/{modelId}'} + + def delete_multivariate_model( + self, model_id, custom_headers=None, raw=False, **operation_config): + """Delete Multivariate Model. + + Delete an existing multivariate model according to the modelId. + + :param model_id: Model identifier. + :type model_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.delete_multivariate_model.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'ApiVersion': self._serialize.url("self.api_version", self.api_version, 'str', skip_quote=True), + 'modelId': self._serialize.url("model_id", model_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + client_raw_response.add_headers({ + 'x-ms-error-code': 'str', + }) + return client_raw_response + delete_multivariate_model.metadata = {'url': '/multivariate/models/{modelId}'} + + def detect_anomaly( + self, model_id, body, custom_headers=None, raw=False, **operation_config): + """Detect Multivariate Anomaly. + + Submit detection multivariate anomaly task with the trained model of + modelId, the input schema should be the same with the training request. + Thus request will be complete asynchronously and will return a resultId + for querying the detection result.The request should be a source link + to indicate an externally accessible Azure storage Uri (preferably a + Shared Access Signature Uri). All time-series used in generate the + model must be zipped into one single file. Each time-series will be as + follows: the first column is timestamp and the second column is value. + + :param model_id: Model identifier. + :type model_id: str + :param body: Detect anomaly request + :type body: ~azure.ai.anomalydetector.models.DetectionRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.detect_anomaly.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'ApiVersion': self._serialize.url("self.api_version", self.api_version, 'str', skip_quote=True), + 'modelId': self._serialize.url("model_id", model_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'DetectionRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [201]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + client_raw_response.add_headers({ + 'Location': 'str', + 'x-ms-error-code': 'str', + }) + return client_raw_response + detect_anomaly.metadata = {'url': '/multivariate/models/{modelId}/detect'} + + def get_detection_result( + self, result_id, custom_headers=None, raw=False, **operation_config): + """Get Multivariate Anomaly Detection Result. + + Get multivariate anomaly detection result based on resultId returned by + the DetectAnomalyAsync api. + + :param result_id: Result identifier. + :type result_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: DetectionResult or ClientRawResponse if raw=true + :rtype: ~azure.ai.anomalydetector.models.DetectionResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_detection_result.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'ApiVersion': self._serialize.url("self.api_version", self.api_version, 'str', skip_quote=True), + 'resultId': self._serialize.url("result_id", result_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DetectionResult', response) + header_dict = { + 'x-ms-error-code': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + get_detection_result.metadata = {'url': '/multivariate/results/{resultId}'} + + def export_model( + self, model_id, custom_headers=None, raw=False, **operation_config): + """Export Multivariate Anomaly Detection Model as Zip file. + + Export multivariate anomaly detection model based on modelId. + + :param model_id: Model identifier. + :type model_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: str or ClientRawResponse if raw=true + :rtype: str or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.export_model.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'ApiVersion': self._serialize.url("self.api_version", self.api_version, 'str', skip_quote=True), + 'modelId': self._serialize.url("model_id", model_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('str', response) + header_dict = { + 'x-ms-error-code': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + export_model.metadata = {'url': '/multivariate/models/{modelId}/export'} + + def last_detect_anomaly( + self, model_id, body, custom_headers=None, raw=False, **operation_config): + """Detect anomalies in the last a few points of the request body. + + Synchronized API for anomaly detection. + + :param model_id: Model identifier. + :type model_id: str + :param body: Request for last detection. + :type body: ~azure.ai.anomalydetector.models.LastDetectionRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: LastDetectionResult or ClientRawResponse if raw=true + :rtype: ~azure.ai.anomalydetector.models.LastDetectionResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.last_detect_anomaly.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'ApiVersion': self._serialize.url("self.api_version", self.api_version, 'str', skip_quote=True), + 'modelId': self._serialize.url("model_id", model_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(body, 'LastDetectionRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('LastDetectionResult', response) + header_dict = { + 'x-ms-error-code': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + last_detect_anomaly.metadata = {'url': '/multivariate/models/{modelId}/last/detect'} diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/version.py b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/version.py new file mode 100644 index 000000000000..9bd1dfac7ecb --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/azure/ai/anomalydetector/version.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +VERSION = "0.2.0" + diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/sdk_packaging.toml b/sdk/anomalydetector/azure-ai-anomalydetector/sdk_packaging.toml new file mode 100644 index 000000000000..31eb7d17e3d3 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/sdk_packaging.toml @@ -0,0 +1,8 @@ +[packaging] +package_name = "azure-ai-anomalydetector" +package_nspkg = "azure-ai-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = true diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/setup.cfg b/sdk/anomalydetector/azure-ai-anomalydetector/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/anomalydetector/azure-ai-anomalydetector/setup.py b/sdk/anomalydetector/azure-ai-anomalydetector/setup.py new file mode 100644 index 000000000000..b49e45b71da5 --- /dev/null +++ b/sdk/anomalydetector/azure-ai-anomalydetector/setup.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-ai-anomalydetector" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.ai', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'msrestazure>=0.4.32,<2.0.0', + 'azure-common~=1.1', + ], + extras_require={ + ":python_version<'3.0'": ['azure-ai-nspkg'], + } +) diff --git a/sdk/anomalydetector/ci.yml b/sdk/anomalydetector/ci.yml new file mode 100644 index 000000000000..3b765ea657fd --- /dev/null +++ b/sdk/anomalydetector/ci.yml @@ -0,0 +1,35 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - master + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/ai-anomalydetector/ + +pr: + branches: + include: + - master + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/ai-anomalydetector/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: ai-anomalydetector + Artifacts: + - name: azure-mgmt-ai-anomalydetector + safeName: azuremgmtai-anomalydetector