diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/CHANGELOG.md b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/CHANGELOG.md index 87bf98acac0a..9adc787ce87c 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/CHANGELOG.md +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/CHANGELOG.md @@ -1,5 +1,12 @@ # Release History +## 0.3.0 (2020-07-23) + +**Features** + + - Added `change_point_detect` method to the client. + - Added new models `ChangePointDetectRequest` and `ChangePointDetectResponse` + ## 0.2.0 (2019-04-12) **Bugfixes** diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/README.md b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/README.md index 0a390518db03..9bc0b1c5149c 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/README.md +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/README.md @@ -1,23 +1,21 @@ -## Microsoft Azure SDK for Python +# Microsoft Azure SDK for Python -This is the Microsoft Azure Cognitive Services Anomaly Detector Client -Library. +This is the Microsoft Azure Cognitive Services Anomaly Detector 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 [Github repo](https://github.com/Azure/azure-sdk-for-python/) -This package has been tested with Python 2.7, 3.4, 3.5, 3.6 and 3.7. -For a more complete set of Azure libraries, see the -[azure](https://pypi.python.org/pypi/azure) bundle package. +# Usage -## Usage - -For code examples, see [Cognitive Services Anomaly -Detector](https://docs.microsoft.com/python/api/overview/azure/cognitive-services) +For code examples, see [Cognitive Services Anomaly Detector](https://docs.microsoft.com/python/api/overview/azure/cognitive-services) on docs.microsoft.com. -## 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) +# 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. -![image](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-cognitiveservices-anomalydetector%2FREADME.png) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-cognitiveservices-anomalydetector%2FREADME.png) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/__init__.py index e22707628100..09815430d029 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/__init__.py @@ -9,10 +9,11 @@ # regenerated. # -------------------------------------------------------------------------- -from .anomaly_detector_client import AnomalyDetectorClient -from .version import VERSION +from ._configuration import AnomalyDetectorClientConfiguration +from ._anomaly_detector_client import AnomalyDetectorClient +__all__ = ['AnomalyDetectorClient', 'AnomalyDetectorClientConfiguration'] -__all__ = ['AnomalyDetectorClient'] +from .version import VERSION __version__ = VERSION diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/_anomaly_detector_client.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/_anomaly_detector_client.py new file mode 100644 index 000000000000..90aa08443be1 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/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.0' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/_configuration.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/_configuration.py new file mode 100644 index 000000000000..4c641ff8f4eb --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/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/v1.0' + + 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-cognitiveservices-anomalydetector/{}'.format(VERSION)) + + self.endpoint = endpoint + self.credentials = credentials diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/__init__.py index 5d93442123bc..ebfd87212e6a 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/__init__.py @@ -10,26 +10,32 @@ # -------------------------------------------------------------------------- try: - from .api_error_py3 import APIError, APIErrorException - from .point_py3 import Point - from .request_py3 import Request - from .entire_detect_response_py3 import EntireDetectResponse - from .last_detect_response_py3 import LastDetectResponse + from ._models_py3 import APIError, APIErrorException + from ._models_py3 import ChangePointDetectRequest + from ._models_py3 import ChangePointDetectResponse + from ._models_py3 import EntireDetectResponse + from ._models_py3 import LastDetectResponse + from ._models_py3 import Point + from ._models_py3 import Request except (SyntaxError, ImportError): - from .api_error import APIError, APIErrorException - from .point import Point - from .request import Request - from .entire_detect_response import EntireDetectResponse - from .last_detect_response import LastDetectResponse -from .anomaly_detector_client_enums import ( + from ._models import APIError, APIErrorException + from ._models import ChangePointDetectRequest + from ._models import ChangePointDetectResponse + from ._models import EntireDetectResponse + from ._models import LastDetectResponse + from ._models import Point + from ._models import Request +from ._anomaly_detector_client_enums import ( Granularity, ) __all__ = [ 'APIError', 'APIErrorException', - 'Point', - 'Request', + 'ChangePointDetectRequest', + 'ChangePointDetectResponse', 'EntireDetectResponse', 'LastDetectResponse', + 'Point', + 'Request', 'Granularity', ] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/anomaly_detector_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/_anomaly_detector_client_enums.py similarity index 96% rename from sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/anomaly_detector_client_enums.py rename to sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/_anomaly_detector_client_enums.py index 7ccdf28e6f4e..50b02b1f3b23 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/anomaly_detector_client_enums.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/_anomaly_detector_client_enums.py @@ -20,3 +20,4 @@ class Granularity(str, Enum): daily = "daily" hourly = "hourly" minutely = "minutely" + secondly = "secondly" diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/_models.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/_models.py new file mode 100644 index 000000000000..469f73e6c057 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/_models.py @@ -0,0 +1,366 @@ +# 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 APIError(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(APIError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class APIErrorException(HttpOperationError): + """Server responsed with exception of type: 'APIError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(APIErrorException, self).__init__(deserialize, response, 'APIError', *args) + + +class ChangePointDetectRequest(Model): + """ChangePointDetectRequest. + + 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.cognitiveservices.anomalydetector.models.Point] + :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', 'minutely', 'secondly' + :type granularity: str or + ~azure.cognitiveservices.anomalydetector.models.Granularity + :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': '[Point]'}, + 'granularity': {'key': 'granularity', 'type': 'Granularity'}, + '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): + """ChangePointDetectResponse. + + 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 is_change_point: Required. 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: Required. the change point confidence of each + point + :type confidence_scores: list[float] + """ + + _validation = { + 'period': {'required': True}, + 'is_change_point': {'required': True}, + 'confidence_scores': {'required': 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 = kwargs.get('period', None) + self.is_change_point = kwargs.get('is_change_point', None) + self.confidence_scores = kwargs.get('confidence_scores', None) + + +class EntireDetectResponse(Model): + """EntireDetectResponse. + + 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] + """ + + _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]'}, + } + + 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) + + +class LastDetectResponse(Model): + """LastDetectResponse. + + 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 + """ + + _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'}, + } + + 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) + + +class Point(Model): + """Point. + + All required parameters must be populated in order to send to Azure. + + :param timestamp: Required. 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 = { + 'timestamp': {'required': True}, + 'value': {'required': True}, + } + + _attribute_map = { + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(Point, self).__init__(**kwargs) + self.timestamp = kwargs.get('timestamp', None) + self.value = kwargs.get('value', None) + + +class Request(Model): + """Request. + + 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.cognitiveservices.anomalydetector.models.Point] + :param granularity: Required. Possible values include: 'yearly', + 'monthly', 'weekly', 'daily', 'hourly', 'minutely', 'secondly' + :type granularity: str or + ~azure.cognitiveservices.anomalydetector.models.Granularity + :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 + """ + + _validation = { + 'series': {'required': True}, + 'granularity': {'required': True}, + } + + _attribute_map = { + 'series': {'key': 'series', 'type': '[Point]'}, + 'granularity': {'key': 'granularity', 'type': 'Granularity'}, + 'custom_interval': {'key': 'customInterval', 'type': 'int'}, + 'period': {'key': 'period', 'type': 'int'}, + 'max_anomaly_ratio': {'key': 'maxAnomalyRatio', 'type': 'float'}, + 'sensitivity': {'key': 'sensitivity', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(Request, 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) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/_models_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/_models_py3.py new file mode 100644 index 000000000000..5f28270cc0a1 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/_models_py3.py @@ -0,0 +1,366 @@ +# 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 APIError(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(APIError, self).__init__(**kwargs) + self.code = code + self.message = message + + +class APIErrorException(HttpOperationError): + """Server responsed with exception of type: 'APIError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(APIErrorException, self).__init__(deserialize, response, 'APIError', *args) + + +class ChangePointDetectRequest(Model): + """ChangePointDetectRequest. + + 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.cognitiveservices.anomalydetector.models.Point] + :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', 'minutely', 'secondly' + :type granularity: str or + ~azure.cognitiveservices.anomalydetector.models.Granularity + :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': '[Point]'}, + 'granularity': {'key': 'granularity', 'type': 'Granularity'}, + '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): + """ChangePointDetectResponse. + + 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 is_change_point: Required. 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: Required. the change point confidence of each + point + :type confidence_scores: list[float] + """ + + _validation = { + 'period': {'required': True}, + 'is_change_point': {'required': True}, + 'confidence_scores': {'required': True}, + } + + _attribute_map = { + 'period': {'key': 'period', 'type': 'int'}, + 'is_change_point': {'key': 'isChangePoint', 'type': '[bool]'}, + 'confidence_scores': {'key': 'confidenceScores', 'type': '[float]'}, + } + + def __init__(self, *, period: int, is_change_point, confidence_scores, **kwargs) -> None: + super(ChangePointDetectResponse, self).__init__(**kwargs) + self.period = period + self.is_change_point = is_change_point + self.confidence_scores = confidence_scores + + +class EntireDetectResponse(Model): + """EntireDetectResponse. + + 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] + """ + + _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]'}, + } + + def __init__(self, *, period: int, expected_values, upper_margins, lower_margins, is_anomaly, is_negative_anomaly, is_positive_anomaly, **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 + + +class LastDetectResponse(Model): + """LastDetectResponse. + + 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 + """ + + _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'}, + } + + 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, **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 + + +class Point(Model): + """Point. + + All required parameters must be populated in order to send to Azure. + + :param timestamp: Required. 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 = { + 'timestamp': {'required': True}, + 'value': {'required': True}, + } + + _attribute_map = { + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__(self, *, timestamp, value: float, **kwargs) -> None: + super(Point, self).__init__(**kwargs) + self.timestamp = timestamp + self.value = value + + +class Request(Model): + """Request. + + 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.cognitiveservices.anomalydetector.models.Point] + :param granularity: Required. Possible values include: 'yearly', + 'monthly', 'weekly', 'daily', 'hourly', 'minutely', 'secondly' + :type granularity: str or + ~azure.cognitiveservices.anomalydetector.models.Granularity + :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 + """ + + _validation = { + 'series': {'required': True}, + 'granularity': {'required': True}, + } + + _attribute_map = { + 'series': {'key': 'series', 'type': '[Point]'}, + 'granularity': {'key': 'granularity', 'type': 'Granularity'}, + 'custom_interval': {'key': 'customInterval', 'type': 'int'}, + 'period': {'key': 'period', 'type': 'int'}, + 'max_anomaly_ratio': {'key': 'maxAnomalyRatio', 'type': 'float'}, + 'sensitivity': {'key': 'sensitivity', 'type': 'int'}, + } + + def __init__(self, *, series, granularity, custom_interval: int=None, period: int=None, max_anomaly_ratio: float=None, sensitivity: int=None, **kwargs) -> None: + super(Request, 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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/api_error.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/api_error.py deleted file mode 100644 index 43212ed45cb7..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/api_error.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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 APIError(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(APIError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class APIErrorException(HttpOperationError): - """Server responsed with exception of type: 'APIError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(APIErrorException, self).__init__(deserialize, response, 'APIError', *args) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/api_error_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/api_error_py3.py deleted file mode 100644 index e47967991688..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/api_error_py3.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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 APIError(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(APIError, self).__init__(**kwargs) - self.code = code - self.message = message - - -class APIErrorException(HttpOperationError): - """Server responsed with exception of type: 'APIError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(APIErrorException, self).__init__(deserialize, response, 'APIError', *args) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/entire_detect_response.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/entire_detect_response.py deleted file mode 100644 index 037cb3153051..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/entire_detect_response.py +++ /dev/null @@ -1,86 +0,0 @@ -# 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 - - -class EntireDetectResponse(Model): - """EntireDetectResponse. - - 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] - """ - - _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]'}, - } - - 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) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/entire_detect_response_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/entire_detect_response_py3.py deleted file mode 100644 index 6b23e37e38af..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/entire_detect_response_py3.py +++ /dev/null @@ -1,86 +0,0 @@ -# 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 - - -class EntireDetectResponse(Model): - """EntireDetectResponse. - - 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] - """ - - _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]'}, - } - - def __init__(self, *, period: int, expected_values, upper_margins, lower_margins, is_anomaly, is_negative_anomaly, is_positive_anomaly, **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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/last_detect_response.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/last_detect_response.py deleted file mode 100644 index d1228b4c8872..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/last_detect_response.py +++ /dev/null @@ -1,84 +0,0 @@ -# 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 - - -class LastDetectResponse(Model): - """LastDetectResponse. - - 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 - """ - - _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'}, - } - - 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) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/last_detect_response_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/last_detect_response_py3.py deleted file mode 100644 index e525762dfcfb..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/last_detect_response_py3.py +++ /dev/null @@ -1,84 +0,0 @@ -# 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 - - -class LastDetectResponse(Model): - """LastDetectResponse. - - 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 - """ - - _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'}, - } - - 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, **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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/point.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/point.py deleted file mode 100644 index 828ad19a112b..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/point.py +++ /dev/null @@ -1,39 +0,0 @@ -# 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 - - -class Point(Model): - """Point. - - All required parameters must be populated in order to send to Azure. - - :param timestamp: Required. 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 = { - 'timestamp': {'required': True}, - 'value': {'required': True}, - } - - _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'value': {'key': 'value', 'type': 'float'}, - } - - def __init__(self, **kwargs): - super(Point, self).__init__(**kwargs) - self.timestamp = kwargs.get('timestamp', None) - self.value = kwargs.get('value', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/point_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/point_py3.py deleted file mode 100644 index d0196e275de8..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/point_py3.py +++ /dev/null @@ -1,39 +0,0 @@ -# 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 - - -class Point(Model): - """Point. - - All required parameters must be populated in order to send to Azure. - - :param timestamp: Required. 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 = { - 'timestamp': {'required': True}, - 'value': {'required': True}, - } - - _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'value': {'key': 'value', 'type': 'float'}, - } - - def __init__(self, *, timestamp, value: float, **kwargs) -> None: - super(Point, self).__init__(**kwargs) - self.timestamp = timestamp - self.value = value diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/request.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/request.py deleted file mode 100644 index c4a18346b05c..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/request.py +++ /dev/null @@ -1,69 +0,0 @@ -# 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 - - -class Request(Model): - """Request. - - 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.cognitiveservices.anomalydetector.models.Point] - :param granularity: Required. Can only be one of yearly, monthly, weekly, - daily, hourly or minutely. Granularity is used for verify whether input - series is valid. Possible values include: 'yearly', 'monthly', 'weekly', - 'daily', 'hourly', 'minutely' - :type granularity: str or - ~azure.cognitiveservices.anomalydetector.models.Granularity - :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 - """ - - _validation = { - 'series': {'required': True}, - 'granularity': {'required': True}, - } - - _attribute_map = { - 'series': {'key': 'series', 'type': '[Point]'}, - 'granularity': {'key': 'granularity', 'type': 'Granularity'}, - 'custom_interval': {'key': 'customInterval', 'type': 'int'}, - 'period': {'key': 'period', 'type': 'int'}, - 'max_anomaly_ratio': {'key': 'maxAnomalyRatio', 'type': 'float'}, - 'sensitivity': {'key': 'sensitivity', 'type': 'int'}, - } - - def __init__(self, **kwargs): - super(Request, 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) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/request_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/request_py3.py deleted file mode 100644 index 908313b3f87b..000000000000 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/models/request_py3.py +++ /dev/null @@ -1,69 +0,0 @@ -# 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 - - -class Request(Model): - """Request. - - 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.cognitiveservices.anomalydetector.models.Point] - :param granularity: Required. Can only be one of yearly, monthly, weekly, - daily, hourly or minutely. Granularity is used for verify whether input - series is valid. Possible values include: 'yearly', 'monthly', 'weekly', - 'daily', 'hourly', 'minutely' - :type granularity: str or - ~azure.cognitiveservices.anomalydetector.models.Granularity - :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 - """ - - _validation = { - 'series': {'required': True}, - 'granularity': {'required': True}, - } - - _attribute_map = { - 'series': {'key': 'series', 'type': '[Point]'}, - 'granularity': {'key': 'granularity', 'type': 'Granularity'}, - 'custom_interval': {'key': 'customInterval', 'type': 'int'}, - 'period': {'key': 'period', 'type': 'int'}, - 'max_anomaly_ratio': {'key': 'maxAnomalyRatio', 'type': 'float'}, - 'sensitivity': {'key': 'sensitivity', 'type': 'int'}, - } - - def __init__(self, *, series, granularity, custom_interval: int=None, period: int=None, max_anomaly_ratio: float=None, sensitivity: int=None, **kwargs) -> None: - super(Request, 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 diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/operations/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/operations/__init__.py new file mode 100644 index 000000000000..ed756e4e57b2 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/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/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/anomaly_detector_client.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/operations/_anomaly_detector_client_operations.py similarity index 69% rename from sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/anomaly_detector_client.py rename to sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/operations/_anomaly_detector_client_operations.py index 6383d31e16d9..b8187294ac19 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/anomaly_detector_client.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/operations/_anomaly_detector_client_operations.py @@ -9,68 +9,11 @@ # regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Configuration, Serializer, Deserializer -from .version import VERSION from msrest.pipeline import ClientRawResponse -from . import models +from .. import models -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/v1.0' - - super(AnomalyDetectorClientConfiguration, self).__init__(base_url) - - self.add_user_agent('azure-cognitiveservices-anomalydetector/{}'.format(VERSION)) - - self.endpoint = endpoint - self.credentials = credentials - - -class AnomalyDetectorClient(SDKClient): - """The Anomaly Detector API detects anomalies automatically in time series data. It supports two functionalities, one is for detecting the whole series with model trained by the timeseries, another is detecting last point with model trained by points before. By using this 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.0' - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - +class AnomalyDetectorClientOperationsMixin(object): def entire_detect( self, body, custom_headers=None, raw=False, **operation_config): @@ -124,7 +67,6 @@ def entire_detect( raise models.APIErrorException(self._deserialize, response) deserialized = None - if response.status_code == 200: deserialized = self._deserialize('EntireDetectResponse', response) @@ -187,7 +129,6 @@ def last_detect( raise models.APIErrorException(self._deserialize, response) deserialized = None - if response.status_code == 200: deserialized = self._deserialize('LastDetectResponse', response) @@ -197,3 +138,63 @@ def last_detect( return deserialized last_detect.metadata = {'url': '/timeseries/last/detect'} + + def change_point_detect( + 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.cognitiveservices.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.cognitiveservices.anomalydetector.models.ChangePointDetectResponse + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.change_point_detect.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, '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.APIErrorException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ChangePointDetectResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + change_point_detect.metadata = {'url': '/timeseries/changePoint/detect'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/version.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/version.py index 9bd1dfac7ecb..3e682bbd5fb1 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/version.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/azure/cognitiveservices/anomalydetector/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.2.0" +VERSION = "0.3.0" diff --git a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/setup.py b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/setup.py index c385fc97b96a..4d86e35869b2 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/setup.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-anomalydetector/setup.py @@ -36,7 +36,9 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +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) @@ -64,10 +66,10 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'License :: OSI Approved :: MIT License', ], zip_safe=False,