Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/services/cognitiveServicesAnomalyDetector/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
55 changes: 55 additions & 0 deletions lib/services/cognitiveServicesAnomalyDetector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
uid: azure-cognitiveservices-anomalydetector
summary: *content

---
**This SDK will be deprecated next year and will be replaced by a new TypeScript-based isomorphic SDK (found at https://github.com/Azure/azure-sdk-for-js) which works on Node.js and browsers.**
## Microsoft Azure SDK for Node.js - AnomalyDetectorClient

This project provides a Node.js package for accessing Azure. Right now it supports:
- **Node.js version 6.x.x or higher**

### Features


### How to Install

```bash
npm install azure-cognitiveservices-anomalydetector
```

### How to use

#### Authentication, client creation, and entireDetect as an example.

```javascript
const msRest = require("ms-rest");
const AnomalyDetectorClient = require("azure-cognitiveservices-anomalydetector");
const token = "<access_token>";
const creds = new msRest.TokenCredentials(token);
const subscriptionId = "<Subscription_Id>";
const client = new AnomalyDetectorClient(creds, subscriptionId);
const body = {
series: [{
timestamp: new Date().toISOString(),
value: 1.01
}],
granularity: "yearly",
customInterval: 1,
period: 1,
maxAnomalyRatio: 1.01,
sensitivity: 1
};

client.entireDetect(body).then((result) => {
console.log("The result is:");
console.log(result);
}).catch((err) => {
console.log('An error occurred:');
console.dir(err, {depth: null, colors: true});
});
```

### Related projects

- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node)
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
/*
* 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.
*/

import { ServiceClient, ServiceClientOptions, ServiceCallback, HttpOperationResponse, ServiceClientCredentials } from 'ms-rest';
import * as models from "./models";

export default class AnomalyDetectorClient extends ServiceClient {
/**
* @class
* Initializes a new instance of the AnomalyDetectorClient class.
* @constructor
*
* @param {credentials} credentials - Subscription credentials which uniquely identify client subscription.
*
* @param {string} endpoint - Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).
*
* @param {object} [options] - The parameter options
*
* @param {Array} [options.filters] - Filters to be added to the request pipeline
*
* @param {object} [options.requestOptions] - Options for the underlying request object
* {@link https://github.com/request/request#requestoptions-callback Options doc}
*
* @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy
*
*/
constructor(credentials: ServiceClientCredentials, endpoint: string, options?: ServiceClientOptions);

credentials: ServiceClientCredentials;

endpoint: string;


/**
* @summary Find anomalies for the entire series in batch.
*
* The operation will generate a model using the entire series, each point will
* be detected with the same model. In this method, points before and after a
* certain point will be used to determine whether it's an anomaly. The entire
* detection can give user an overall status of the time series.
*
* @param {object} body Time series points and period if needed. Advanced model
* parameters can also be set in the request.
*
* @param {array} body.series 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.
*
* @param {string} body.granularity 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'
*
* @param {number} [body.customInterval] 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}.
*
* @param {number} [body.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.
*
* @param {number} [body.maxAnomalyRatio] Optional argument, advanced model
* parameter, max anomaly ratio in a time series.
*
* @param {number} [body.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.
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @returns {Promise} A promise is returned
*
* @resolve {HttpOperationResponse<EntireDetectResponse>} - The deserialized result object.
*
* @reject {Error|ServiceError} - The error object.
*/
entireDetectWithHttpOperationResponse(body: models.Request, options?: { customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.EntireDetectResponse>>;

/**
* @summary Find anomalies for the entire series in batch.
*
* The operation will generate a model using the entire series, each point will
* be detected with the same model. In this method, points before and after a
* certain point will be used to determine whether it's an anomaly. The entire
* detection can give user an overall status of the time series.
*
* @param {object} body Time series points and period if needed. Advanced model
* parameters can also be set in the request.
*
* @param {array} body.series 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.
*
* @param {string} body.granularity 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'
*
* @param {number} [body.customInterval] 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}.
*
* @param {number} [body.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.
*
* @param {number} [body.maxAnomalyRatio] Optional argument, advanced model
* parameter, max anomaly ratio in a time series.
*
* @param {number} [body.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.
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {ServiceCallback} [optionalCallback] - The optional callback.
*
* @returns {ServiceCallback|Promise} If a callback was passed as the last
* parameter then it returns the callback else returns a Promise.
*
* {Promise} A promise is returned.
*
* @resolve {EntireDetectResponse} - The deserialized result object.
*
* @reject {Error|ServiceError} - The error object.
*
* {ServiceCallback} optionalCallback(err, result, request, response)
*
* {Error|ServiceError} err - The Error object if an error occurred, null otherwise.
*
* {EntireDetectResponse} [result] - The deserialized result object if an error did not occur.
* See {@link EntireDetectResponse} for more information.
*
* {WebResource} [request] - The HTTP Request object if an error did not occur.
*
* {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur.
*/
entireDetect(body: models.Request, options?: { customHeaders? : { [headerName: string]: string; } }): Promise<models.EntireDetectResponse>;
entireDetect(body: models.Request, callback: ServiceCallback<models.EntireDetectResponse>): void;
entireDetect(body: models.Request, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.EntireDetectResponse>): void;


/**
* @summary Detect anomaly status of the latest point in time series.
*
* The operation will generate a model using points before the latest one, In
* this method, only history points are used for determine whether the target
* point is an anomaly. Latest point detecting matches the scenario of
* real-time monitoring of business metrics.
*
* @param {object} body Time series points and period if needed. Advanced model
* parameters can also be set in the request.
*
* @param {array} body.series 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.
*
* @param {string} body.granularity 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'
*
* @param {number} [body.customInterval] 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}.
*
* @param {number} [body.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.
*
* @param {number} [body.maxAnomalyRatio] Optional argument, advanced model
* parameter, max anomaly ratio in a time series.
*
* @param {number} [body.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.
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @returns {Promise} A promise is returned
*
* @resolve {HttpOperationResponse<LastDetectResponse>} - The deserialized result object.
*
* @reject {Error|ServiceError} - The error object.
*/
lastDetectWithHttpOperationResponse(body: models.Request, options?: { customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.LastDetectResponse>>;

/**
* @summary Detect anomaly status of the latest point in time series.
*
* The operation will generate a model using points before the latest one, In
* this method, only history points are used for determine whether the target
* point is an anomaly. Latest point detecting matches the scenario of
* real-time monitoring of business metrics.
*
* @param {object} body Time series points and period if needed. Advanced model
* parameters can also be set in the request.
*
* @param {array} body.series 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.
*
* @param {string} body.granularity 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'
*
* @param {number} [body.customInterval] 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}.
*
* @param {number} [body.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.
*
* @param {number} [body.maxAnomalyRatio] Optional argument, advanced model
* parameter, max anomaly ratio in a time series.
*
* @param {number} [body.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.
*
* @param {object} [options] Optional Parameters.
*
* @param {object} [options.customHeaders] Headers that will be added to the
* request
*
* @param {ServiceCallback} [optionalCallback] - The optional callback.
*
* @returns {ServiceCallback|Promise} If a callback was passed as the last
* parameter then it returns the callback else returns a Promise.
*
* {Promise} A promise is returned.
*
* @resolve {LastDetectResponse} - The deserialized result object.
*
* @reject {Error|ServiceError} - The error object.
*
* {ServiceCallback} optionalCallback(err, result, request, response)
*
* {Error|ServiceError} err - The Error object if an error occurred, null otherwise.
*
* {LastDetectResponse} [result] - The deserialized result object if an error did not occur.
* See {@link LastDetectResponse} for more information.
*
* {WebResource} [request] - The HTTP Request object if an error did not occur.
*
* {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur.
*/
lastDetect(body: models.Request, options?: { customHeaders? : { [headerName: string]: string; } }): Promise<models.LastDetectResponse>;
lastDetect(body: models.Request, callback: ServiceCallback<models.LastDetectResponse>): void;
lastDetect(body: models.Request, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.LastDetectResponse>): void;
}

export { AnomalyDetectorClient, models as AnomalyDetectorModels };
Loading