From bd1fd4b63f39bc11e8db47a58100b5d1e30e384d Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 3 May 2023 23:10:11 +0000 Subject: [PATCH] CodeGen from PR 23806 in Azure/azure-rest-api-specs Merge e3d002f33c299574f43c2489848b0f10cdcf957b into 058b50f427b5c09a4c7486e737e337a008c5a471 --- common/config/rush/pnpm-lock.yaml | 6 +- .../ai-anomaly-detector-rest/README.md | 280 +++--------------- .../api-extractor.json | 25 +- .../ai-anomaly-detector-rest/karma.conf.js | 7 +- .../ai-anomaly-detector-rest/package.json | 36 +-- .../review/ai-anomaly-detector.api.md | 48 ++- .../src/anomalyDetector.ts | 54 ++++ .../src/anomalyDetectorRest.ts | 47 --- .../src/clientDefinitions.ts | 87 +++--- .../ai-anomaly-detector-rest/src/index.ts | 6 +- .../src/isUnexpected.ts | 49 ++- .../ai-anomaly-detector-rest/src/models.ts | 193 ++++++------ .../src/outputModels.ts | 239 +++++++-------- .../src/paginateHelper.ts | 41 ++- .../src/parameters.ts | 32 +- .../ai-anomaly-detector-rest/src/responses.ts | 29 +- .../test/public/sampleTest.spec.ts | 23 ++ .../test/public/utils/recordedClient.ts | 23 +- .../ai-anomaly-detector-rest/tsconfig.json | 10 +- sdk/anomalydetector/ci.yml | 9 +- 20 files changed, 557 insertions(+), 687 deletions(-) create mode 100644 sdk/anomalydetector/ai-anomaly-detector-rest/src/anomalyDetector.ts delete mode 100644 sdk/anomalydetector/ai-anomaly-detector-rest/src/anomalyDetectorRest.ts create mode 100644 sdk/anomalydetector/ai-anomaly-detector-rest/test/public/sampleTest.spec.ts diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 3071a32ae3ea..8c861f134d64 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -9162,7 +9162,7 @@ packages: dev: false file:projects/ai-anomaly-detector.tgz: - resolution: {integrity: sha512-tTBMpzWakjsOAmgNwOSzP4OhMwLE9wvW06WDsHh1wnaUUAvesQGpjJNFz1Vyg84SbFqyXJqDFx/ik/mNrjGcIA==, tarball: file:projects/ai-anomaly-detector.tgz} + resolution: {integrity: sha512-h9Dpiak3KHG24rlraazIAVwvDTSFG8BZyc3/1DdoC3D1wVKL8Vlp6q5oLeeCIRS2BuV0dtbsewNUUevK721qzg==, tarball: file:projects/ai-anomaly-detector.tgz} name: '@rush-temp/ai-anomaly-detector' version: 0.0.0 dependencies: @@ -9187,7 +9187,7 @@ packages: karma-mocha-reporter: 2.2.5_karma@6.4.2 karma-source-map-support: 1.4.0 karma-sourcemap-loader: 0.3.8 - mkdirp: 1.0.4 + mkdirp: 2.1.6 mocha: 7.2.0 mocha-junit-reporter: 1.23.3_mocha@7.2.0 nyc: 15.1.0 @@ -15895,7 +15895,7 @@ packages: dev: false file:projects/communication-rooms.tgz: - resolution: {integrity: sha512-MWKqSMfk8nSMa06UaTb9zmyhqNzJHHdxqKvtjLUGw3ULCN+SopfAL4owdy0rfkvZ+2UEH3OBmxnbwJbuASIIWA==, tarball: file:projects/communication-rooms.tgz} + resolution: {integrity: sha512-1jxME+P4umHDyg1wNfAWpx4pTbspvARTojOKayxAUPp6cEj0FqFIxb/GAW62LQRE3RcHwH7oxPZQuEozv2Ocww==, tarball: file:projects/communication-rooms.tgz} name: '@rush-temp/communication-rooms' version: 0.0.0 dependencies: diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/README.md b/sdk/anomalydetector/ai-anomaly-detector-rest/README.md index 51c034c3e479..f15b9a8ad818 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/README.md +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/README.md @@ -1,30 +1,50 @@ -# Azure AnomalyDetectorRest REST client library for JavaScript +# Azure AnomalyDetector REST client library for JavaScript + +The Anomaly Detector API detects anomalies automatically in time series data. +It supports both a stateless detection mode and a +stateful detection mode. In stateless mode, there are three functionalities. Entire +Detect is for detecting the whole series, with the model trained by the time series. +Last Detect is for detecting the last point, with the model trained by points before. +ChangePoint Detect is for detecting trend changes in the time series. In stateful +mode, the user can store time series. The stored time series will be used for +detection anomalies. In this mode, the user can still use the preceding three +functionalities by only giving a time range without preparing time series on the +client side. Besides the preceding three functionalities, the stateful model +provides group-based detection and labeling services. By using the labeling +service, the 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 that finds inconsistencies in +a set of time series. By using the anomaly detector service, business customers can +discover incidents and establish a logic flow for root cause analysis. + +**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library** + +Key links: -[Anomaly Detector](https://learn.microsoft.com/azure/cognitive-services/Anomaly-Detector/overview) is an AI service with a set of APIs, which enables you to monitor and detect anomalies in your time series data with little machine learning (ML) knowledge, either batch validation or real-time inference. - -Please refer to our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library. +- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/anomalydetector/ai-anomaly-detector-rest) +- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/ai-anomaly-detector) +- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/ai-anomaly-detector?view=azure-node-preview) +- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/anomalydetector/ai-anomaly-detector-rest/samples) ## Getting started -### Prerequisites +### Currently supported environments - LTS versions of Node.js -- You need an [Azure subscription][azure_sub] to use this package. -- An existing Cognitive Services Anomaly Detector instance. + +### Prerequisites + +- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package. ### Install the `@azure-rest/ai-anomaly-detector` package -Install the Azure AnomalyDetectorRest REST client REST client library for JavaScript with `npm`: +Install the Azure AnomalyDetector REST client REST client library for JavaScript with `npm`: ```bash npm install @azure-rest/ai-anomaly-detector ``` -|SDK version|Supported API version of service | -|-------------|---------------| -|1.0.0-beta.1| 1.1| - -### Create and authenticate a `AnomalyDetectorRestClient` +### Create and authenticate a `AnomalyDetectorClient` To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token), provide an instance of the desired credential type obtained from the @@ -39,208 +59,8 @@ can be used to authenticate the client. Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET -## Key concepts - -With the Anomaly Detector, you can either detect anomalies in one variable using **Univariate Anomaly Detection**, or detect anomalies in multiple variables with **Multivariate Anomaly Detection**. - -|Feature |Description | -|---------|---------| -|Univariate Anomaly Detection | Detect anomalies in one variable, like revenue, cost, etc. The model was selected automatically based on your data pattern. | -|Multivariate Anomaly Detection| Detect anomalies in multiple variables with correlations, which are usually gathered from equipment or other complex system. The underlying model used is Graph attention network.| - -### Univariate Anomaly Detection - -The Univariate Anomaly Detection API enables you to monitor and detect abnormalities in your time series data without having to know machine learning. The algorithms adapt by automatically identifying and applying the best-fitting models to your data, regardless of industry, scenario, or data volume. Using your time series data, the API determines boundaries for anomaly detection, expected values, and which data points are anomalies. - -Using the Anomaly Detector doesn't require any prior experience in machine learning, and the REST API enables you to easily integrate the service into your applications and processes. - -With the Univariate Anomaly Detection, you can automatically detect anomalies throughout your time series data, or as they occur in real-time. - -|Feature |Description | -|---------|---------| -| Streaming detection| Detect anomalies in your streaming data by using previously seen data points to determine if your latest one is an anomaly. This operation generates a model using the data points you send, and determines if the target point is an anomaly. By calling the API with each new data point you generate, you can monitor your data as it's created. | -| Batch detection | Use your time series to detect any anomalies that might exist throughout your data. This operation generates a model using your entire time series data, with each point analyzed with the same model. | -| Change points detection | Use your time series to detect any trend change points that exist in your data. This operation generates a model using your entire time series data, with each point analyzed with the same model. | - -### Multivariate Anomaly Detection - -The **Multivariate Anomaly Detection** APIs further enable developers by easily integrating advanced AI for detecting anomalies from groups of metrics, without the need for machine learning knowledge or labeled data. Dependencies and inter-correlations between up to 300 different signals are now automatically counted as key factors. This new capability helps you to proactively protect your complex systems such as software applications, servers, factory machines, spacecraft, or even your business, from failures. - -With the Multivariate Anomaly Detection, you can automatically detect anomalies throughout your time series data, or as they occur in real-time. There are three processes to use Multivariate Anomaly Detection. - -- **Training**: Use Train Model API to create and train a model, then use Get Model Status API to get the status and model metadata. -- **Inference**: - - Use Async Inference API to trigger an asynchronous inference process and use Get Inference results API to get detection results on a batch of data. - - You could also use Sync Inference API to trigger a detection on one timestamp every time. -- **Other operations**: List Model API and Delete Model API are supported in Multivariate Anomaly Detection model for model management. - -### Thread safety - -We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. - -## Examples - -The following section provides several code snippets covering some of the most common Anomaly Detector service tasks, including: - -- [Univariate Anomaly Detection - Batch detection](#batch-detection) -- [Univariate Anomaly Detection - Streaming detection](#streaming-detection) -- [Univariate Anomaly Detection - Detect change points](#detect-change-points) -- [Multivariate Anomaly Detection](#multivariate-anomaly-detection-sample) - -### Batch detection - -```typescript -const apiKey = process.env["ANOMALY_DETECTOR_API_KEY"] || ""; -const endpoint = process.env["ANOMALY_DETECTOR_ENDPOINT"] || ""; -const timeSeriesDataPath = "./samples-dev/example-data/request-data.csv"; - -function read_series_from_file(path: string): Array { - let result = Array(); - let input = fs.readFileSync(path).toString(); - let parsed = parse(input, { skip_empty_lines: true }); - parsed.forEach(function (e: Array) { - result.push({ timestamp: new Date(e[0]), value: Number(e[1]) }); - }); - return result; -} - -export async function main() { - // create client - const credential = new AzureKeyCredential(apiKey); - const client = AnomalyDetector(endpoint, credential); - - // construct request - const options: DetectUnivariateEntireSeriesParameters = { - body: { - granularity: "daily", - imputeMode: "auto", - maxAnomalyRatio: 0.25, - sensitivity: 95, - series: read_series_from_file(timeSeriesDataPath), - }, - headers: { "Content-Type": "application/json" }, - }; - - // get last detect result - const result = await client.path("/timeseries/entire/detect").post(options); - if (isUnexpected(result)) { - throw result; - } - - if (result.body.isAnomaly) { - result.body.isAnomaly.forEach(function (anomaly, index) { - if (anomaly === true) { - console.log(index); - } - }); - } else { - console.log("There is no anomaly detected from the series."); - } -``` - -### Streaming Detection - -```typescript -const apiKey = process.env["ANOMALY_DETECTOR_API_KEY"] || ""; -const endpoint = process.env["ANOMALY_DETECTOR_ENDPOINT"] || ""; -const timeSeriesDataPath = "./samples-dev/example-data/request-data.csv"; - -function read_series_from_file(path: string): Array { - let result = Array(); - let input = fs.readFileSync(path).toString(); - let parsed = parse(input, { skip_empty_lines: true }); - parsed.forEach(function (e: Array) { - result.push({ timestamp: new Date(e[0]), value: Number(e[1]) }); - }); - return result; -} - -export async function main() { - // create client - const credential = new AzureKeyCredential(apiKey); - const client = AnomalyDetector(endpoint, credential); - - // construct request - const options: DetectUnivariateLastPointParameters = { - body: { - granularity: "daily", - imputeFixedValue: 800, - imputeMode: "fixed", - maxAnomalyRatio: 0.25, - sensitivity: 95, - series: read_series_from_file(timeSeriesDataPath), - }, - headers: { "Content-Type": "application/json" }, - }; - - // get last detect result - const result = await client.path("/timeseries/last/detect").post(options); - if (isUnexpected(result)) { - throw result; - } - - if (result.body.isAnomaly) { - console.log("The latest point is detected as anomaly."); - } else { - console.log("The latest point is not detected as anomaly."); - } -``` - -### Detect change points - -```typescript -const apiKey = process.env["ANOMALY_DETECTOR_API_KEY"] || ""; -const endpoint = process.env["ANOMALY_DETECTOR_ENDPOINT"] || ""; -const timeSeriesDataPath = "./samples-dev/example-data/request-data.csv"; - -function read_series_from_file(path: string): Array { - let result = Array(); - let input = fs.readFileSync(path).toString(); - let parsed = parse(input, { skip_empty_lines: true }); - parsed.forEach(function (e: Array) { - result.push({ timestamp: new Date(e[0]), value: Number(e[1]) }); - }); - return result; -} - -export async function main() { - const credential = new AzureKeyCredential(apiKey); - const client = AnomalyDetector(endpoint, credential); - const options: DetectUnivariateChangePointParameters = { - body: { - granularity: "daily", - series: read_series_from_file(timeSeriesDataPath), - }, - headers: { "Content-Type": "application/json" }, - }; - const result = await client.path("/timeseries/changepoint/detect").post(options); - if (isUnexpected(result)) { - throw result; - } - - if (result.body.isChangePoint === undefined) throw new Error("Empty isChangePoint"); - if ( - result.body.isChangePoint.some(function (changePoint) { - return changePoint === true; - }) - ) { - console.log("Change points were detected from the series at index:"); - result.body.isChangePoint.forEach(function (changePoint, index) { - if (changePoint === true) console.log(index); - }); - } else { - console.log("There is no change point detected from the series."); - } -``` - -### Multivariate Anomaly Detection Sample - -To see how to use Anomaly Detector library to conduct Multivariate Anomaly Detection, see this [sample](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/anomalydetector/ai-anomaly-detector-rest/samples/v1-beta/typescript/src/sample_multivariate_detection.ts). - ## Troubleshooting -### General - ### Logging Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: @@ -252,37 +72,3 @@ setLogLevel("info"); ``` For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). - -## Next steps - -These code samples show common scenario operations with the Azure Anomaly Detector library. More samples can be found under the [samples](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/anomalydetector/Azure.AI.AnomalyDetector/tests/samples/) directory. - -- Univariate Anomaly Detection - Batch Detection: [sample_detect_entire_series_anomaly.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/anomalydetector/ai-anomaly-detector-rest/samples/v1-beta/typescript/src/sample_detect_entire_series_anomaly.ts) - -- Univariate Anomaly Detection - Streaming Detection: [ample_detect_last_point_anomaly.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/anomalydetector/ai-anomaly-detector-rest/samples/v1-beta/typescript/src/sample_detect_last_point_anomaly.ts) - -- Univariate Anomaly Detection - Change Point Detection: [sample_detect_change_point.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/anomalydetector/ai-anomaly-detector-rest/samples/v1-beta/typescript/src/sample_detect_change_point.ts) - -- Multivariate Anomaly Detection: [sample_multivariate_detection.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/anomalydetector/ai-anomaly-detector-rest/samples/v1-beta/typescript/src/sample_multivariate_detection.ts) - -### Additional documentation - -For more extensive documentation on Azure Anomaly Detector, see the [Anomaly Detector documentation](https://learn.microsoft.com/azure/cognitive-services/anomaly-detector/overview) on docs.microsoft.com. - -## Contributing - -This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [cla.microsoft.com][cla]. - -When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. - -This project has adopted the [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [opencode@microsoft.com][coc_contact] with any additional questions or comments. - - -[cla]: https://cla.microsoft.com -[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ -[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ -[coc_contact]: mailto:opencode@microsoft.com -- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/anomalydetector/ai-anomaly-detector-rest) -- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/ai-anomaly-detector) -- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/ai-anomaly-detector?view=azure-node-preview) -- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/anomalydetector/ai-anomaly-detector-rest/samples) diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/api-extractor.json b/sdk/anomalydetector/ai-anomaly-detector-rest/api-extractor.json index 7f28e42bfa01..2f95d42364ec 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/api-extractor.json +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./types/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/ai-anomaly-detector.d.ts" }, "messages": { - "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, "extractorMessageReporting": { - "ae-missing-release-tag": { "logLevel": "none" }, - "ae-unresolved-link": { "logLevel": "none" } + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } } } -} +} \ No newline at end of file diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/karma.conf.js b/sdk/anomalydetector/ai-anomaly-detector-rest/karma.conf.js index c247204a3c9d..a9d5f1b5fc59 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/karma.conf.js +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/karma.conf.js @@ -53,8 +53,11 @@ module.exports = function (config) { envPreprocessor: [ "TEST_MODE", - "ANOMALY_DETECTOR_API_KEY", - "ANOMALY_DETECTOR_ENDPOINT", + "ENDPOINT", + "AZURE_CLIENT_SECRET", + "AZURE_CLIENT_ID", + "AZURE_TENANT_ID", + "SUBSCRIPTION_ID", "RECORDINGS_RELATIVE_PATH", ], diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/package.json b/sdk/anomalydetector/ai-anomaly-detector-rest/package.json index fc9fa3e13b00..dfbcd676d99d 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/package.json +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/package.json @@ -2,8 +2,8 @@ "name": "@azure-rest/ai-anomaly-detector", "sdk-type": "client", "author": "Microsoft Corporation", - "version": "1.0.0-beta.2", - "description": "A generated SDK for AnomalyDetectorRest.", + "version": "1.0.0-beta.1", + "description": "undefined", "keywords": [ "node", "azure", @@ -38,12 +38,12 @@ "build:samples": "echo skipped.", "build:test": "tsc -p . && dev-tool run bundle", "build:debug": "tsc -p . && dev-tool run bundle && api-extractor run --local", - "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", + "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"test/**/*.ts\"", "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log", - "execute:samples": "dev-tool samples run samples-dev", + "execute:samples": "echo skipped", "extract-api": "rimraf review && mkdirp ./review && api-extractor run --local", - "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", - "generate:client": "autorest --typescript swagger/README.md && npm run format", + "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"test/**/*.ts\"", + "generate:client": "echo skipped", "integration-test:browser": "dev-tool run test:browser", "integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'", "integration-test": "npm run integration-test:node && npm run integration-test:browser", @@ -62,12 +62,11 @@ "autoPublish": false, "dependencies": { "@azure/core-auth": "^1.3.0", - "@azure-rest/core-client": "^1.0.0", + "@azure-rest/core-client": "^1.1.2", "@azure/core-rest-pipeline": "^1.8.0", "@azure/logger": "^1.0.0", "tslib": "^2.2.0", - "@azure/core-paging": "^1.2.0", - "@azure/core-lro": "^2.2.0" + "@azure/core-paging": "^1.5.0" }, "devDependencies": { "@microsoft/api-extractor": "^7.31.1", @@ -75,7 +74,7 @@ "@types/node": "^14.0.0", "dotenv": "^16.0.0", "eslint": "^8.0.0", - "mkdirp": "^1.0.4", + "mkdirp": "^2.1.2", "prettier": "^2.5.1", "rimraf": "^3.0.0", "source-map-support": "^0.5.9", @@ -101,27 +100,18 @@ "karma-source-map-support": "~1.4.0", "karma-sourcemap-loader": "^0.3.8", "karma": "^6.2.0", - "nyc": "^15.0.0", - "csv-parse": "^5.0.3" + "nyc": "^15.0.0" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/anomalydetector/ai-anomaly-detector-rest/README.md", "//metadata": { "constantPaths": [ { - "path": "swagger/README.md", - "prefix": "package-version" + "path": "src/anomalyDetector.ts", + "prefix": "userAgentInfo" } ] }, "browser": { "./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js" - }, - "//sampleConfiguration": { - "productName": "AnomalyDetectorRest", - "productSlugs": [ - "azure" - ], - "disableDocsMs": true, - "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure-rest/ai-anomaly-detector?view=azure-node-preview" } -} +} \ No newline at end of file diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/review/ai-anomaly-detector.api.md b/sdk/anomalydetector/ai-anomaly-detector-rest/review/ai-anomaly-detector.api.md index 9fc01e2a7bf9..ef69e0c17cdf 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/review/ai-anomaly-detector.api.md +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/review/ai-anomaly-detector.api.md @@ -16,14 +16,14 @@ import { StreamableMethod } from '@azure-rest/core-client'; // @public export interface AlignPolicy { - alignMode?: "Inner" | "Outer"; + alignMode?: string; fillNAMethod?: string; paddingValue?: number; } // @public export interface AlignPolicyOutput { - alignMode?: "Inner" | "Outer"; + alignMode?: string; fillNAMethod?: string; paddingValue?: number; } @@ -36,21 +36,21 @@ export interface AnomalyDetectionModelOutput { modelInfo?: ModelInfoOutput; } -// @public -export interface AnomalyDetectorErrorOutput { - code?: string; - message?: string; -} - // @public (undocumented) -export type AnomalyDetectorRestClient = Client & { +export type AnomalyDetectorClient = Client & { path: Routes; }; // @public (undocumented) -export interface AnomalyDetectorRestClientOptions extends ClientOptions { +export interface AnomalyDetectorClientOptions extends ClientOptions { // (undocumented) - ApiVersion?: string; + apiVersion?: string; +} + +// @public +export interface AnomalyDetectorErrorOutput { + code: string; + message: string; } // @public @@ -81,7 +81,7 @@ export interface CorrelationChangesOutput { } // @public -function createClient(Endpoint: string, credentials: KeyCredential, options?: AnomalyDetectorRestClientOptions): AnomalyDetectorRestClient; +function createClient(endpoint: string, credentials: KeyCredential, options?: AnomalyDetectorClientOptions): AnomalyDetectorClient; export default createClient; // @public (undocumented) @@ -214,7 +214,7 @@ export interface DetectUnivariateChangePointBodyParam { // @public (undocumented) export interface DetectUnivariateChangePointDefaultHeaders { - "x-ms-error-code"?: string; + "x-ms-error-code": string; } // @public (undocumented) @@ -250,7 +250,7 @@ export interface DetectUnivariateEntireSeriesBodyParam { // @public (undocumented) export interface DetectUnivariateEntireSeriesDefaultHeaders { - "x-ms-error-code"?: string; + "x-ms-error-code": string; } // @public (undocumented) @@ -286,7 +286,7 @@ export interface DetectUnivariateLastPointBodyParam { // @public (undocumented) export interface DetectUnivariateLastPointDefaultHeaders { - "x-ms-error-code"?: string; + "x-ms-error-code": string; } // @public (undocumented) @@ -465,12 +465,10 @@ export interface ModelInfo { alignPolicy?: AlignPolicy; dataSchema?: string; dataSource: string; - diagnosticsInfo?: DiagnosticsInfo; displayName?: string; endTime: Date | string; slidingWindow?: number; startTime: Date | string; - status?: "CREATED" | "RUNNING" | "READY" | "FAILED"; } // @public @@ -478,13 +476,13 @@ export interface ModelInfoOutput { alignPolicy?: AlignPolicyOutput; dataSchema?: string; dataSource: string; - diagnosticsInfo?: DiagnosticsInfoOutput; + readonly diagnosticsInfo?: DiagnosticsInfoOutput; displayName?: string; endTime: string; readonly errors?: Array; slidingWindow?: number; startTime: string; - status?: "CREATED" | "RUNNING" | "READY" | "FAILED"; + readonly status?: string; } // @public @@ -516,7 +514,7 @@ export interface MultivariateBatchDetectionOptions { dataSource: string; endTime: Date | string; startTime: Date | string; - topContributorCount: number; + topContributorCount?: number; } // @public @@ -524,14 +522,14 @@ export interface MultivariateBatchDetectionOptionsOutput { dataSource: string; endTime: string; startTime: string; - topContributorCount: number; + topContributorCount?: number; } // @public export interface MultivariateBatchDetectionResultSummaryOutput { errors?: Array; setupInfo: MultivariateBatchDetectionOptionsOutput; - status: "CREATED" | "RUNNING" | "READY" | "FAILED"; + status: string; variableStates?: Array; } @@ -544,7 +542,7 @@ export interface MultivariateDetectionResultOutput { // @public export interface MultivariateLastDetectionOptions { - topContributorCount: number; + topContributorCount?: number; variables: Array; } @@ -638,7 +636,7 @@ export type TrainMultivariateModelParameters = TrainMultivariateModelBodyParam & // @public export interface UnivariateChangePointDetectionOptions { customInterval?: number; - granularity: "yearly" | "monthly" | "weekly" | "daily" | "hourly" | "minutely" | "secondly" | "microsecond" | "none"; + granularity: string; period?: number; series: Array; stableTrendWindow?: number; @@ -655,7 +653,7 @@ export interface UnivariateChangePointDetectionResultOutput { // @public export interface UnivariateDetectionOptions { customInterval?: number; - granularity?: "yearly" | "monthly" | "weekly" | "daily" | "hourly" | "minutely" | "secondly" | "microsecond" | "none"; + granularity?: string; imputeFixedValue?: number; imputeMode?: string; maxAnomalyRatio?: number; diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/src/anomalyDetector.ts b/sdk/anomalydetector/ai-anomaly-detector-rest/src/anomalyDetector.ts new file mode 100644 index 000000000000..77fde2d59c3e --- /dev/null +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/src/anomalyDetector.ts @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { getClient, ClientOptions } from "@azure-rest/core-client"; +import { KeyCredential } from "@azure/core-auth"; +import { AnomalyDetectorClient } from "./clientDefinitions"; + +export interface AnomalyDetectorClientOptions extends ClientOptions { + apiVersion?: string; +} + +/** + * Initialize a new instance of `AnomalyDetectorClient` + * @param endpoint type: string, Supported Azure Cognitive Services endpoints (protocol and host name, such as + * https://westus2.api.cognitive.microsoft.com). + * @param credentials type: KeyCredential, uniquely identify client credential + * @param options type: AnomalyDetectorClientOptions, the parameter for all optional parameters + */ +export default function createClient( + endpoint: string, + credentials: KeyCredential, + options: AnomalyDetectorClientOptions = {} +): AnomalyDetectorClient { + const apiVersion = options.apiVersion ?? "v1.1"; + const baseUrl = + options.baseUrl ?? `${endpoint}/anomalydetector/${apiVersion}`; + + options = { + ...options, + credentials: { + apiKeyHeaderName: "Ocp-Apim-Subscription-Key", + }, + }; + + const userAgentInfo = `azsdk-js-ai-anomaly-detector-rest/1.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` + : `${userAgentInfo}`; + options = { + ...options, + userAgentOptions: { + userAgentPrefix, + }, + }; + + const client = getClient( + baseUrl, + credentials, + options + ) as AnomalyDetectorClient; + + return client; +} diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/src/anomalyDetectorRest.ts b/sdk/anomalydetector/ai-anomaly-detector-rest/src/anomalyDetectorRest.ts deleted file mode 100644 index 14acd1631107..000000000000 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/src/anomalyDetectorRest.ts +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { getClient, ClientOptions } from "@azure-rest/core-client"; -import { KeyCredential } from "@azure/core-auth"; -import { AnomalyDetectorRestClient } from "./clientDefinitions"; - -export interface AnomalyDetectorRestClientOptions extends ClientOptions { - ApiVersion?: string; -} - -/** - * Initialize a new instance of the class AnomalyDetectorRestClient class. - * @param Endpoint type: string - * @param credentials type: KeyCredential - */ -export default function createClient( - Endpoint: string, - credentials: KeyCredential, - options: AnomalyDetectorRestClientOptions = {} -): AnomalyDetectorRestClient { - const ApiVersion = options.ApiVersion ?? "v1.1"; - const baseUrl = options.baseUrl ?? `${Endpoint}/anomalydetector/${ApiVersion}`; - - options = { - ...options, - credentials: { - apiKeyHeaderName: "Ocp-Apim-Subscription-Key", - }, - }; - - const userAgentInfo = `azsdk-js-ai-anomaly-detector-rest/1.0.0-beta.1`; - const userAgentPrefix = - options.userAgentOptions && options.userAgentOptions.userAgentPrefix - ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` - : `${userAgentInfo}`; - options = { - ...options, - userAgentOptions: { - userAgentPrefix, - }, - }; - - const client = getClient(baseUrl, credentials, options) as AnomalyDetectorRestClient; - - return client; -} diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/src/clientDefinitions.ts b/sdk/anomalydetector/ai-anomaly-detector-rest/src/clientDefinitions.ts index e20bc51133f4..6687f149f379 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/src/clientDefinitions.ts +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/src/clientDefinitions.ts @@ -39,43 +39,46 @@ import { Client, StreamableMethod } from "@azure-rest/core-client"; export interface DetectUnivariateEntireSeries { /** - * This operation generates a model with an entire series, each point is detected + * This operation generates a model with an entire series. Each point is detected * with the same model. With this method, points before and after a certain point - * are used to determine whether it is an anomaly. The entire detection can give + * are used to determine whether it's an anomaly. The entire detection can give the * user an overall status of the time series. */ post( options: DetectUnivariateEntireSeriesParameters ): StreamableMethod< - DetectUnivariateEntireSeries200Response | DetectUnivariateEntireSeriesDefaultResponse + | DetectUnivariateEntireSeries200Response + | DetectUnivariateEntireSeriesDefaultResponse >; } export interface DetectUnivariateLastPoint { /** - * This operation generates a model using the points that you sent into the API, + * This operation generates a model by using the points that you sent in to the API * and based on all data to determine whether the last point is anomalous. */ post( options: DetectUnivariateLastPointParameters ): StreamableMethod< - DetectUnivariateLastPoint200Response | DetectUnivariateLastPointDefaultResponse + | DetectUnivariateLastPoint200Response + | DetectUnivariateLastPointDefaultResponse >; } export interface DetectUnivariateChangePoint { - /** Evaluate change point score of every series point */ + /** Evaluate the change point score of every series point. */ post( options: DetectUnivariateChangePointParameters ): StreamableMethod< - DetectUnivariateChangePoint200Response | DetectUnivariateChangePointDefaultResponse + | DetectUnivariateChangePoint200Response + | DetectUnivariateChangePointDefaultResponse >; } export interface GetMultivariateBatchDetectionResult { /** - * For asynchronous inference, get multivariate anomaly detection result based on - * resultId returned by the BatchDetectAnomaly api. + * For asynchronous inference, get a multivariate anomaly detection result based on the + * resultId value that the BatchDetectAnomaly API returns. */ get( options?: GetMultivariateBatchDetectionResultParameters @@ -88,63 +91,76 @@ export interface GetMultivariateBatchDetectionResult { export interface TrainMultivariateModel { /** * Create and train a multivariate anomaly detection model. The request must - * include a source parameter to indicate an externally accessible Azure blob - * storage URI.There are two types of data input: An URI pointed to an Azure blob - * storage folder which contains multiple CSV files, and each CSV file contains - * two columns, timestamp and variable. Another type of input is an URI pointed to - * a CSV file in Azure blob storage, which contains all the variables and a - * timestamp column. + * include a source parameter to indicate an Azure Blob + * Storage URI that's accessible to the service. There are two types of data input. The Blob Storage URI can point to an Azure Blob + * Storage folder that contains multiple CSV files, where each CSV file has + * two columns, time stamp and variable. Or the Blob Storage URI can point to a single blob that contains a CSV file that has all the variables and a + * time stamp column. + * The model object will be created and returned in the response, but the + * training process happens asynchronously. To check the training status, call + * GetMultivariateModel with the modelId value and check the status field in the + * modelInfo object. */ post( options: TrainMultivariateModelParameters - ): StreamableMethod; + ): StreamableMethod< + TrainMultivariateModel201Response | TrainMultivariateModelDefaultResponse + >; /** List models of a resource. */ get( options?: ListMultivariateModelsParameters - ): StreamableMethod; + ): StreamableMethod< + ListMultivariateModels200Response | ListMultivariateModelsDefaultResponse + >; } export interface DeleteMultivariateModel { - /** Delete an existing multivariate model according to the modelId */ + /** Delete an existing multivariate model according to the modelId value. */ delete( options?: DeleteMultivariateModelParameters - ): StreamableMethod; + ): StreamableMethod< + DeleteMultivariateModel204Response | DeleteMultivariateModelDefaultResponse + >; /** - * Get detailed information of multivariate model, including the training status + * Get detailed information about the multivariate model, including the training status * and variables used in the model. */ get( options?: GetMultivariateModelParameters - ): StreamableMethod; + ): StreamableMethod< + GetMultivariateModel200Response | GetMultivariateModelDefaultResponse + >; } export interface DetectMultivariateBatchAnomaly { /** - * Submit multivariate anomaly detection task with the modelId of trained model - * and inference data, the input schema should be the same with the training - * request. The request will complete asynchronously and return a resultId to - * query the detection result.The request should be a source link to indicate an - * externally accessible Azure storage Uri, either pointed to an Azure blob - * storage folder, or pointed to a CSV file in Azure blob storage. + * Submit a multivariate anomaly detection task with the modelId value of a trained model + * and inference data. The input schema should be the same with the training + * request. The request will finish asynchronously and return a resultId value to + * query the detection result. The request should be a source link to indicate an + * externally accessible Azure Storage URI that either points to an Azure Blob + * Storage folder or points to a CSV file in Azure Blob Storage. */ post( options: DetectMultivariateBatchAnomalyParameters ): StreamableMethod< - DetectMultivariateBatchAnomaly202Response | DetectMultivariateBatchAnomalyDefaultResponse + | DetectMultivariateBatchAnomaly202Response + | DetectMultivariateBatchAnomalyDefaultResponse >; } export interface DetectMultivariateLastAnomaly { /** - * Submit multivariate anomaly detection task with the modelId of trained model - * and inference data, and the inference data should be put into request body in a - * JSON format. The request will complete synchronously and return the detection + * Submit a multivariate anomaly detection task with the modelId value of a trained model + * and inference data. The inference data should be put into the request body in + * JSON format. The request will finish synchronously and return the detection * immediately in the response body. */ post( options: DetectMultivariateLastAnomalyParameters ): StreamableMethod< - DetectMultivariateLastAnomaly200Response | DetectMultivariateLastAnomalyDefaultResponse + | DetectMultivariateLastAnomaly200Response + | DetectMultivariateLastAnomalyDefaultResponse >; } @@ -163,7 +179,10 @@ export interface Routes { /** Resource for '/multivariate/models' has methods for the following verbs: post, get */ (path: "/multivariate/models"): TrainMultivariateModel; /** Resource for '/multivariate/models/\{modelId\}' has methods for the following verbs: delete, get */ - (path: "/multivariate/models/{modelId}", modelId: string): DeleteMultivariateModel; + ( + path: "/multivariate/models/{modelId}", + modelId: string + ): DeleteMultivariateModel; /** Resource for '/multivariate/models/\{modelId\}:detect-batch' has methods for the following verbs: post */ ( path: "/multivariate/models/{modelId}:detect-batch", @@ -176,6 +195,6 @@ export interface Routes { ): DetectMultivariateLastAnomaly; } -export type AnomalyDetectorRestClient = Client & { +export type AnomalyDetectorClient = Client & { path: Routes; }; diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/src/index.ts b/sdk/anomalydetector/ai-anomaly-detector-rest/src/index.ts index d3f1ebbb3305..e97d4949efb6 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/src/index.ts +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/src/index.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import AnomalyDetectorRest from "./anomalyDetectorRest"; +import AnomalyDetector from "./anomalyDetector"; -export * from "./anomalyDetectorRest"; +export * from "./anomalyDetector"; export * from "./parameters"; export * from "./responses"; export * from "./clientDefinitions"; @@ -12,4 +12,4 @@ export * from "./models"; export * from "./outputModels"; export * from "./paginateHelper"; -export default AnomalyDetectorRest; +export default AnomalyDetector; diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/src/isUnexpected.ts b/sdk/anomalydetector/ai-anomaly-detector-rest/src/isUnexpected.ts index cd16b86b3e22..8ce5481e555c 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/src/isUnexpected.ts +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/src/isUnexpected.ts @@ -38,13 +38,19 @@ const responseMap: Record = { }; export function isUnexpected( - response: DetectUnivariateEntireSeries200Response | DetectUnivariateEntireSeriesDefaultResponse + response: + | DetectUnivariateEntireSeries200Response + | DetectUnivariateEntireSeriesDefaultResponse ): response is DetectUnivariateEntireSeriesDefaultResponse; export function isUnexpected( - response: DetectUnivariateLastPoint200Response | DetectUnivariateLastPointDefaultResponse + response: + | DetectUnivariateLastPoint200Response + | DetectUnivariateLastPointDefaultResponse ): response is DetectUnivariateLastPointDefaultResponse; export function isUnexpected( - response: DetectUnivariateChangePoint200Response | DetectUnivariateChangePointDefaultResponse + response: + | DetectUnivariateChangePoint200Response + | DetectUnivariateChangePointDefaultResponse ): response is DetectUnivariateChangePointDefaultResponse; export function isUnexpected( response: @@ -52,16 +58,24 @@ export function isUnexpected( | GetMultivariateBatchDetectionResultDefaultResponse ): response is GetMultivariateBatchDetectionResultDefaultResponse; export function isUnexpected( - response: TrainMultivariateModel201Response | TrainMultivariateModelDefaultResponse + response: + | TrainMultivariateModel201Response + | TrainMultivariateModelDefaultResponse ): response is TrainMultivariateModelDefaultResponse; export function isUnexpected( - response: ListMultivariateModels200Response | ListMultivariateModelsDefaultResponse + response: + | ListMultivariateModels200Response + | ListMultivariateModelsDefaultResponse ): response is ListMultivariateModelsDefaultResponse; export function isUnexpected( - response: DeleteMultivariateModel204Response | DeleteMultivariateModelDefaultResponse + response: + | DeleteMultivariateModel204Response + | DeleteMultivariateModelDefaultResponse ): response is DeleteMultivariateModelDefaultResponse; export function isUnexpected( - response: GetMultivariateModel200Response | GetMultivariateModelDefaultResponse + response: + | GetMultivariateModel200Response + | GetMultivariateModelDefaultResponse ): response is GetMultivariateModelDefaultResponse; export function isUnexpected( response: @@ -69,7 +83,9 @@ export function isUnexpected( | DetectMultivariateBatchAnomalyDefaultResponse ): response is DetectMultivariateBatchAnomalyDefaultResponse; export function isUnexpected( - response: DetectMultivariateLastAnomaly200Response | DetectMultivariateLastAnomalyDefaultResponse + response: + | DetectMultivariateLastAnomaly200Response + | DetectMultivariateLastAnomalyDefaultResponse ): response is DetectMultivariateLastAnomalyDefaultResponse; export function isUnexpected( response: @@ -136,17 +152,24 @@ function getParametrizedPathSuccess(method: string, path: string): string[] { // track if we have found a match to return the values found. let found = true; - for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) { - if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) { + for ( + let i = candidateParts.length - 1, j = pathParts.length - 1; + i >= 1 && j >= 1; + i--, j-- + ) { + if ( + candidateParts[i]?.startsWith("{") && + candidateParts[i]?.indexOf("}") !== -1 + ) { const start = candidateParts[i]!.indexOf("}") + 1, end = candidateParts[i]?.length; // If the current part of the candidate is a "template" part // Try to use the suffix of pattern to match the path // {guid} ==> $ // {guid}:export ==> :export$ - const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test( - pathParts[j] || "" - ); + const isMatched = new RegExp( + `${candidateParts[i]?.slice(start, end)}` + ).test(pathParts[j] || ""); if (!isMatched) { found = false; diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/src/models.ts b/sdk/anomalydetector/ai-anomaly-detector-rest/src/models.ts index dc9d9ad37870..e889bed7004a 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/src/models.ts +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/src/models.ts @@ -1,245 +1,224 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -/** The request of entire or last anomaly detection. */ +/** Request of the entire or last anomaly detection. */ export interface UnivariateDetectionOptions { /** - * Time series data points. Points should be sorted by timestamp in ascending + * Time series data points. Points should be sorted by time stamp 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. + * correctly or there's a duplicated time stamp, the API won't work. In such + * a case, an error message is returned. */ series: Array; /** - * Optional argument, can be one of yearly, monthly, weekly, daily, hourly, - * minutely, secondly, microsecond or none. If granularity is not present, it will - * be none by default. If granularity is none, the timestamp property in time + * Argument that indicates time granularity. If granularity is not present, the value + * is none by default. If granularity is none, the time stamp property in the time * series point can be absent. + * + * Possible values: yearly, monthly, weekly, daily, hourly, minutely, secondly, microsecond, none */ - granularity?: - | "yearly" - | "monthly" - | "weekly" - | "daily" - | "hourly" - | "minutely" - | "secondly" - | "microsecond" - | "none"; + granularity?: string; /** - * 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", + * A custom interval is used to set a nonstandard time interval. For example, if the + * series is 5 minutes, the request can be set as {"granularity":"minutely", * "customInterval":5}. */ customInterval?: number; /** - * Optional argument, periodic value of a time series. If the value is null or - * does not present, the API will determine the period automatically. + * Argument that indicates the periodic value of a time series. If the value is null or + * is not present, the API determines the period automatically. */ period?: number; - /** Optional argument, advanced model parameter, max anomaly ratio in a time series. */ + /** Argument that indicates an advanced model parameter. It's the maximum anomaly ratio in a time series. */ maxAnomalyRatio?: number; /** - * 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 + * Argument that indicates an advanced model parameter between 0 and 99. The lower the value + * is, the larger the margin value is, which means fewer anomalies will be * accepted. */ sensitivity?: number; /** - * Used to specify how to deal with missing values in the input series, it's used + * Specifies how to deal with missing values in the input series. It's used * when granularity is not "none". * * Possible values: auto, previous, linear, fixed, zero, notFill */ imputeMode?: string; /** - * Used to specify the value to fill, it's used when granularity is not "none" + * Specifies the value to fill. It's used when granularity is not "none" * and imputeMode is "fixed". */ imputeFixedValue?: number; } -/** The definition of input timeseries points. */ +/** Definition of input time series points. */ export interface TimeSeriesPoint { - /** Optional argument, timestamp of a data point (ISO8601 format). */ + /** Argument that indicates the time stamp of a data point (ISO8601 format). */ timestamp?: Date | string; - /** The measurement of that point, should be float. */ + /** Measurement of that point. */ value: number; } -/** The request of change point detection. */ +/** Request of change point detection. */ export interface UnivariateChangePointDetectionOptions { /** - * Time series data points. Points should be sorted by timestamp in ascending + * Time series data points. Points should be sorted by time stamp in ascending * order to match the change point detection result. */ series: Array; /** - * Can only be one of yearly, monthly, weekly, daily, hourly, minutely or - * secondly. Granularity is used for verify whether input series is valid. + * Granularity is used to verify whether the input series is valid. + * + * Possible values: yearly, monthly, weekly, daily, hourly, minutely, secondly, microsecond, none */ - granularity: - | "yearly" - | "monthly" - | "weekly" - | "daily" - | "hourly" - | "minutely" - | "secondly" - | "microsecond" - | "none"; + granularity: string; /** - * 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", + * A custom interval is used to set a nonstandard time interval. For example, if the + * series is 5 minutes, the request can be set as {"granularity":"minutely", * "customInterval":5}. */ customInterval?: number; /** - * Optional argument, periodic value of a time series. If the value is null or - * does not present, the API will determine the period automatically. + * Argument that indicates the periodic value of a time series. If the value is null or + * not present, the API will determine the period automatically. */ period?: number; /** - * Optional argument, advanced model parameter, a default stableTrendWindow will + * Argument that indicates an advanced model parameter. A default stableTrendWindow value will * be used in detection. */ stableTrendWindow?: number; /** - * 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 + * Argument that indicates an advanced model parameter between 0.0 and 1.0. The lower the + * value is, the larger the trend error is, which means less change point will * be accepted. */ threshold?: number; } -/** ErrorResponse contains code and message that shows the error information. */ +/** Error information that the API returned. */ export interface ErrorResponse { - /** The error code. */ + /** Error code. */ code: string; - /** The message explaining the error reported by the service. */ + /** Message that explains the error that the service reported. */ message: string; } -/** Variable Status. */ +/** Variable status. */ export interface VariableState { /** Variable name in variable states. */ variable?: string; /** Proportion of missing values that need to be filled by fillNAMethod. */ filledNARatio?: number; - /** Number of effective data points before applying fillNAMethod. */ + /** Number of effective data points before fillNAMethod is applied. */ effectiveCount?: number; - /** First valid timestamp with value of input data. */ + /** First valid time stamp with a value of input data. */ firstTimestamp?: Date | string; - /** Last valid timestamp with value of input data. */ + /** Last valid time stamp with a value of input data. */ lastTimestamp?: Date | string; } /** - * Detection request for batch inference. This is an asynchronous inference which + * Detection request for batch inference. This is an asynchronous inference that * will need another API to get detection results. */ export interface MultivariateBatchDetectionOptions { /** - * Source link to the input data to indicate an accessible Azure storage Uri, - * either pointed to an Azure blob storage folder, or pointed to a CSV file in - * Azure blob storage based on you data schema selection. The data schema should - * be exactly the same with those used in the training phase. + * Source link to the input data to indicate an accessible Azure Storage URI. + * It either points to an Azure Blob Storage folder or points to a CSV file in + * Azure Blob Storage, based on your data schema selection. The data schema should + * be exactly the same as those used in the training phase. The input data must + * contain at least slidingWindow entries preceding the start time of the data + * to be detected. */ dataSource: string; + /** Number of top contributed variables for one anomalous time stamp in the response. */ + topContributorCount?: number; /** - * An optional field, which is used to specify the number of top contributed - * variables for one anomalous timestamp in the response. The default number is - * 10. - */ - topContributorCount: number; - /** - * A required field, indicating the start time of data for detection, which should - * be date-time of ISO 8601 format. + * Start date/time of data for detection, which should + * be in ISO 8601 format. */ startTime: Date | string; /** - * A required field, indicating the end time of data for detection, which should - * be date-time of ISO 8601 format. + * End date/time of data for detection, which should + * be in ISO 8601 format. */ endTime: Date | string; } /** - * Training result of a model including its status, errors and diagnostics + * Training result of a model, including its status, errors, and diagnostics * information. */ export interface ModelInfo { /** - * Source link to the input data to indicate an accessible Azure storage Uri, - * either pointed to an Azure blob storage folder, or pointed to a CSV file in - * Azure blob storage based on you data schema selection. + * Source link to the input data to indicate an accessible Azure Storage URI. + * It either points to an Azure Blob Storage folder or points to a CSV file in + * Azure Blob Storage, based on your data schema selection. */ dataSource: string; /** - * Data schema of input data source: OneTable or MultiTable. The default - * DataSchema is OneTable. + * Data schema of the input data source. The default + * is OneTable. * * Possible values: OneTable, MultiTable */ dataSchema?: string; /** - * A required field, indicating the start time of training data, which should be - * date-time of ISO 8601 format. + * Start date/time of training data, which should be + * in ISO 8601 format. */ startTime: Date | string; /** - * A required field, indicating the end time of training data, which should be - * date-time of ISO 8601 format. + * End date/time of training data, which should be + * in ISO 8601 format. */ endTime: Date | string; /** - * An optional field. The display name of the model whose maximum length is 24 + * Display name of the model. Maximum length is 24 * characters. */ displayName?: string; /** - * An optional field, indicating how many previous timestamps will be used to - * detect whether the timestamp is anomaly or not. + * Number of previous time stamps that will be used to + * detect whether the time stamp is an anomaly or not. */ slidingWindow?: number; - /** An optional field, indicating the manner to align multiple variables. */ + /** Manner of aligning multiple variables. */ alignPolicy?: AlignPolicy; - /** Model status. One of CREATED, RUNNING, READY, and FAILED. */ - status?: "CREATED" | "RUNNING" | "READY" | "FAILED"; - /** Diagnostics information to help inspect the states of model or variable. */ - diagnosticsInfo?: DiagnosticsInfo; } -/** An optional field, indicating the manner to align multiple variables. */ +/** Manner of aligning multiple variables. */ export interface AlignPolicy { /** - * An optional field, indicating how to align different variables to the same - * time-range. Either Inner or Outer. + * Field that indicates how to align different variables to the same + * time range. + * + * Possible values: Inner, Outer */ - alignMode?: "Inner" | "Outer"; + alignMode?: string; /** - * An optional field, indicating how missing values will be filled. One of - * Previous, Subsequent, Linear, Zero, Fixed. + * Field that indicates how missing values will be filled. * * Possible values: Previous, Subsequent, Linear, Zero, Fixed */ fillNAMethod?: string; - /** An optional field. Required when fillNAMethod is Fixed. */ + /** Field that's required when fillNAMethod is Fixed. */ paddingValue?: number; } -/** Diagnostics information to help inspect the states of model or variable. */ +/** Diagnostics information to help inspect the states of a model or variable. */ export interface DiagnosticsInfo { /** Model status. */ modelState?: ModelState; - /** Variable Status. */ + /** Variable status. */ variableStates?: Array; } /** Model status. */ export interface ModelState { /** - * This indicates the number of passes of the entire training dataset the + * Number of passes of the entire training dataset that the * algorithm has completed. */ epochIds?: number[]; @@ -257,26 +236,26 @@ export interface ModelState { latenciesInSeconds?: number[]; } -/** Request of last detection. */ +/** Request of the last detection. */ export interface MultivariateLastDetectionOptions { /** - * This contains the inference data, including the name, timestamps(ISO 8601) and + * Contains the inference data, including the name, time stamps (ISO 8601), and * values of variables. */ variables: Array; /** - * An optional field, which is used to specify the number of top contributed - * variables for one anomalous timestamp in the response. The default number is + * Number of top contributed + * variables for one anomalous time stamp in the response. The default is * 10. */ - topContributorCount: number; + topContributorCount?: number; } /** Variable values. */ export interface VariableValues { - /** Variable name of last detection request. */ + /** Variable name of the last detection request. */ variable: string; - /** Timestamps of last detection request */ + /** Time stamps of the last detection request. */ timestamps: string[]; /** Values of variables. */ values: number[]; diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/src/outputModels.ts b/sdk/anomalydetector/ai-anomaly-detector-rest/src/outputModels.ts index 2b12f7cf41fe..b5c2149261d8 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/src/outputModels.ts +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/src/outputModels.ts @@ -1,78 +1,78 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -/** The response of entire anomaly detection. */ +/** Response of the entire anomaly detection. */ export interface UnivariateEntireDetectionResultOutput { /** - * Frequency extracted from the series, zero means no recurrent pattern has been + * Frequency extracted from the series. Zero means no recurrent pattern has been * found. */ period: number; /** - * ExpectedValues contain expected value for each input point. The index of the + * Expected value for each input point. The index of the * array is consistent with the input series. */ expectedValues: number[]; /** - * 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 + * Upper margin of each input point. UpperMargin is used to + * calculate upperBoundary, which is equal to expectedValue + (100 - + * marginScale)*upperMargin. Anomalies in the response can be filtered by + * upperBoundary and lowerBoundary. Adjusting the marginScale value can help filter less + * significant anomalies on the client side. The index of the array is * consistent with the input series. */ upperMargins: number[]; /** - * LowerMargins contain lower margin of each input point. LowerMargin is used to - * calculate lowerBoundary, which equals to expectedValue - (100 - + * Lower margin of each input point. LowerMargin is used to + * calculate lowerBoundary, which is equal 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 + * ones on the client side. The index of the array is consistent with the input * series. */ lowerMargins: number[]; /** - * IsAnomaly contains anomaly properties for each input point. True means an - * anomaly either negative or positive has been detected. The index of the array + * 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. */ isAnomaly: boolean[]; /** - * IsNegativeAnomaly contains anomaly status in negative direction for each input + * Anomaly status in a 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. */ isNegativeAnomaly: boolean[]; /** - * IsPositiveAnomaly contain anomaly status in positive direction for each input + * Anomaly status in a 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. */ isPositiveAnomaly: boolean[]; /** - * The severity score for each input point. The larger the value is, the more - * sever the anomaly is. For normal points, the "severity" is always 0. + * Severity score for each input point. The larger the value is, the more + * severe the anomaly is. For normal points, the severity is always 0. */ severity?: number[]; } -/** Error information returned by the API. */ +/** Error information that the API returned. */ export interface AnomalyDetectorErrorOutput { /** - * The error code. + * Error code. * * Possible values: InvalidCustomInterval, BadArgument, InvalidGranularity, InvalidPeriod, InvalidModelArgument, InvalidSeries, InvalidJsonFormat, RequiredGranularity, RequiredSeries, InvalidImputeMode, InvalidImputeFixedValue */ - code?: string; - /** A message explaining the error reported by the service. */ - message?: string; + code: string; + /** Message that explains the error that the service reported. */ + message: string; } -/** The response of last anomaly detection. */ +/** Response of the last anomaly detection. */ export interface UnivariateLastDetectionResultOutput { /** - * Frequency extracted from the series, zero means no recurrent pattern has been + * Frequency extracted from the series. Zero means no recurrent pattern has been * found. */ period: number; @@ -82,259 +82,262 @@ export interface UnivariateLastDetectionResultOutput { expectedValue: number; /** * Upper margin of the latest point. UpperMargin is used to calculate - * upperBoundary, which equals to expectedValue + (100 - marginScale)*upperMargin. + * upperBoundary, which is equal 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. + * should be treated as a normal value. Adjusting the marginScale value enables the anomaly + * status of the latest point to be changed. */ upperMargin: number; /** * Lower margin of the latest point. LowerMargin is used to calculate - * lowerBoundary, which equals to expectedValue - (100 - marginScale)*lowerMargin. - * + * lowerBoundary, which is equal to expectedValue - (100 - marginScale)*lowerMargin. */ lowerMargin: number; /** - * Anomaly status of the latest point, true means the latest point is an anomaly - * either in negative direction or positive direction. + * Anomaly status of the latest point. True means the latest point is an anomaly, + * either in the negative direction or in the positive direction. */ isAnomaly: boolean; /** - * Anomaly status in negative direction of the latest point. True means the latest + * Anomaly status of the latest point in a negative direction. True means the latest * point is an anomaly and its real value is smaller than the expected one. */ isNegativeAnomaly: boolean; /** - * Anomaly status in positive direction of the latest point. True means the latest + * Anomaly status of the latest point in a positive direction. True means the latest * point is an anomaly and its real value is larger than the expected one. */ isPositiveAnomaly: boolean; /** - * The severity score for the last input point. The larger the value is, the more - * sever the anomaly is. For normal points, the "severity" is always 0. + * Severity score for the last input point. The larger the value is, the more + * severe the anomaly is. For normal points, the severity is always 0. */ severity?: number; } -/** The response of change point detection. */ +/** Response of change point detection. */ export interface UnivariateChangePointDetectionResultOutput { /** - * Frequency extracted from the series, zero means no recurrent pattern has been + * Frequency extracted from the series. Zero means no recurrent pattern has been * found. */ readonly period?: number; /** - * isChangePoint contains change point properties for each input point. True means - * an anomaly either negative or positive has been detected. The index of the + * 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. */ isChangePoint?: boolean[]; - /** the change point confidence of each point */ + /** Change point confidence of each point. */ confidenceScores?: number[]; } -/** Detection results for the given resultId. */ +/** Detection results for the resultId value. */ export interface MultivariateDetectionResultOutput { - /** Result identifier, which is used to fetch the results of an inference call. */ + /** Result identifier that's used to fetch the results of an inference call. */ resultId: string; /** Multivariate anomaly detection status. */ summary: MultivariateBatchDetectionResultSummaryOutput; - /** Detection result for each timestamp. */ + /** Detection result for each time stamp. */ results: Array; } /** Multivariate anomaly detection status. */ export interface MultivariateBatchDetectionResultSummaryOutput { - /** Status of detection results. One of CREATED, RUNNING, READY, and FAILED. */ - status: "CREATED" | "RUNNING" | "READY" | "FAILED"; - /** Error message when detection is failed. */ + /** + * Status of detection results. + * + * Possible values: CREATED, RUNNING, READY, FAILED + */ + status: string; + /** Error message when detection fails. */ errors?: Array; - /** Variable Status. */ + /** Variable status. */ variableStates?: Array; /** - * Detection request for batch inference. This is an asynchronous inference which + * Detection request for batch inference. This is an asynchronous inference that * will need another API to get detection results. */ setupInfo: MultivariateBatchDetectionOptionsOutput; } -/** ErrorResponse contains code and message that shows the error information. */ +/** Error information that the API returned. */ export interface ErrorResponseOutput { - /** The error code. */ + /** Error code. */ code: string; - /** The message explaining the error reported by the service. */ + /** Message that explains the error that the service reported. */ message: string; } -/** Variable Status. */ +/** Variable status. */ export interface VariableStateOutput { /** Variable name in variable states. */ variable?: string; /** Proportion of missing values that need to be filled by fillNAMethod. */ filledNARatio?: number; - /** Number of effective data points before applying fillNAMethod. */ + /** Number of effective data points before fillNAMethod is applied. */ effectiveCount?: number; - /** First valid timestamp with value of input data. */ + /** First valid time stamp with a value of input data. */ firstTimestamp?: string; - /** Last valid timestamp with value of input data. */ + /** Last valid time stamp with a value of input data. */ lastTimestamp?: string; } /** - * Detection request for batch inference. This is an asynchronous inference which + * Detection request for batch inference. This is an asynchronous inference that * will need another API to get detection results. */ export interface MultivariateBatchDetectionOptionsOutput { /** - * Source link to the input data to indicate an accessible Azure storage Uri, - * either pointed to an Azure blob storage folder, or pointed to a CSV file in - * Azure blob storage based on you data schema selection. The data schema should - * be exactly the same with those used in the training phase. + * Source link to the input data to indicate an accessible Azure Storage URI. + * It either points to an Azure Blob Storage folder or points to a CSV file in + * Azure Blob Storage, based on your data schema selection. The data schema should + * be exactly the same as those used in the training phase. The input data must + * contain at least slidingWindow entries preceding the start time of the data + * to be detected. */ dataSource: string; + /** Number of top contributed variables for one anomalous time stamp in the response. */ + topContributorCount?: number; /** - * An optional field, which is used to specify the number of top contributed - * variables for one anomalous timestamp in the response. The default number is - * 10. - */ - topContributorCount: number; - /** - * A required field, indicating the start time of data for detection, which should - * be date-time of ISO 8601 format. + * Start date/time of data for detection, which should + * be in ISO 8601 format. */ startTime: string; /** - * A required field, indicating the end time of data for detection, which should - * be date-time of ISO 8601 format. + * End date/time of data for detection, which should + * be in ISO 8601 format. */ endTime: string; } /** Anomaly status and information. */ export interface AnomalyStateOutput { - /** The timestamp for this anomaly. */ + /** Time stamp for this anomaly. */ timestamp: string; - /** The detailed value of this anomalous timestamp. */ + /** Detailed value of this anomalous time stamp. */ value?: AnomalyValueOutput; - /** Error message for the current timestamp. */ + /** Error message for the current time stamp. */ errors?: Array; } -/** Detailed information of the anomalous timestamp. */ +/** Detailed information of the anomalous time stamp. */ export interface AnomalyValueOutput { - /** True if an anomaly is detected at the current timestamp. */ + /** True if an anomaly is detected at the current time stamp. */ isAnomaly: boolean; /** * Indicates the significance of the anomaly. The higher the severity, the more * significant the anomaly is. */ severity: number; - /** - * Raw anomaly score of severity, will help indicate the degree of abnormality as - * well. - */ + /** Raw anomaly score of severity, to help indicate the degree of abnormality. */ score: number; - /** Interpretation of this anomalous timestamp. */ + /** Interpretation of this anomalous time stamp. */ interpretation?: Array; } -/** Interpretation of the anomalous timestamp. */ +/** Interpretation of the anomalous time stamp. */ export interface AnomalyInterpretationOutput { /** Variable. */ variable?: string; /** - * This score shows the percentage contributing to the anomalous timestamp. A + * This score shows the percentage that contributes to the anomalous time stamp. It's a * number between 0 and 1. */ contributionScore?: number; - /** Correlation changes among the anomalous variables */ + /** Correlation changes among the anomalous variables. */ correlationChanges?: CorrelationChangesOutput; } -/** Correlation changes among the anomalous variables */ +/** Correlation changes among the anomalous variables. */ export interface CorrelationChangesOutput { - /** The correlated variables that have correlation changes under an anomaly. */ + /** Correlated variables that have correlation changes under an anomaly. */ changedVariables?: string[]; } /** - * Training result of a model including its status, errors and diagnostics + * Training result of a model, including its status, errors, and diagnostics * information. */ export interface ModelInfoOutput { /** - * Source link to the input data to indicate an accessible Azure storage Uri, - * either pointed to an Azure blob storage folder, or pointed to a CSV file in - * Azure blob storage based on you data schema selection. + * Source link to the input data to indicate an accessible Azure Storage URI. + * It either points to an Azure Blob Storage folder or points to a CSV file in + * Azure Blob Storage, based on your data schema selection. */ dataSource: string; /** - * Data schema of input data source: OneTable or MultiTable. The default - * DataSchema is OneTable. + * Data schema of the input data source. The default + * is OneTable. * * Possible values: OneTable, MultiTable */ dataSchema?: string; /** - * A required field, indicating the start time of training data, which should be - * date-time of ISO 8601 format. + * Start date/time of training data, which should be + * in ISO 8601 format. */ startTime: string; /** - * A required field, indicating the end time of training data, which should be - * date-time of ISO 8601 format. + * End date/time of training data, which should be + * in ISO 8601 format. */ endTime: string; /** - * An optional field. The display name of the model whose maximum length is 24 + * Display name of the model. Maximum length is 24 * characters. */ displayName?: string; /** - * An optional field, indicating how many previous timestamps will be used to - * detect whether the timestamp is anomaly or not. + * Number of previous time stamps that will be used to + * detect whether the time stamp is an anomaly or not. */ slidingWindow?: number; - /** An optional field, indicating the manner to align multiple variables. */ + /** Manner of aligning multiple variables. */ alignPolicy?: AlignPolicyOutput; - /** Model status. One of CREATED, RUNNING, READY, and FAILED. */ - status?: "CREATED" | "RUNNING" | "READY" | "FAILED"; - /** Error messages when failed to create a model. */ + /** + * Model status. + * + * Possible values: CREATED, RUNNING, READY, FAILED + */ + readonly status?: string; + /** Error messages after failure to create a model. */ readonly errors?: Array; - /** Diagnostics information to help inspect the states of model or variable. */ - diagnosticsInfo?: DiagnosticsInfoOutput; + /** Diagnostics information to help inspect the states of a model or variable. */ + readonly diagnosticsInfo?: DiagnosticsInfoOutput; } -/** An optional field, indicating the manner to align multiple variables. */ +/** Manner of aligning multiple variables. */ export interface AlignPolicyOutput { /** - * An optional field, indicating how to align different variables to the same - * time-range. Either Inner or Outer. + * Field that indicates how to align different variables to the same + * time range. + * + * Possible values: Inner, Outer */ - alignMode?: "Inner" | "Outer"; + alignMode?: string; /** - * An optional field, indicating how missing values will be filled. One of - * Previous, Subsequent, Linear, Zero, Fixed. + * Field that indicates how missing values will be filled. * * Possible values: Previous, Subsequent, Linear, Zero, Fixed */ fillNAMethod?: string; - /** An optional field. Required when fillNAMethod is Fixed. */ + /** Field that's required when fillNAMethod is Fixed. */ paddingValue?: number; } -/** Diagnostics information to help inspect the states of model or variable. */ +/** Diagnostics information to help inspect the states of a model or variable. */ export interface DiagnosticsInfoOutput { /** Model status. */ modelState?: ModelStateOutput; - /** Variable Status. */ + /** Variable status. */ variableStates?: Array; } /** Model status. */ export interface ModelStateOutput { /** - * This indicates the number of passes of the entire training dataset the + * Number of passes of the entire training dataset that the * algorithm has completed. */ epochIds?: number[]; @@ -361,7 +364,7 @@ export interface AnomalyDetectionModelOutput { /** Date and time (UTC) when the model was last updated. */ lastUpdatedTime: string; /** - * Training result of a model including its status, errors and diagnostics + * Training result of a model, including its status, errors, and diagnostics * information. */ modelInfo?: ModelInfoOutput; @@ -375,13 +378,13 @@ export interface ModelListOutput { currentCount: number; /** Maximum number of models that can be trained for this Anomaly Detector resource. */ maxCount: number; - /** The link to fetch more models. */ + /** Link to fetch more models. */ nextLink?: string; } -/** Results of last detection. */ +/** Results of the last detection. */ export interface MultivariateLastDetectionResultOutput { - /** Variable Status. */ + /** Variable status. */ variableStates?: Array; /** Anomaly status and information. */ results?: Array; diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/src/paginateHelper.ts b/sdk/anomalydetector/ai-anomaly-detector-rest/src/paginateHelper.ts index 69b5ad462f48..f76b0eb29747 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/src/paginateHelper.ts +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/src/paginateHelper.ts @@ -1,8 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from "@azure/core-paging"; -import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; +import { + getPagedAsyncIterator, + PagedAsyncIterableIterator, + PagedResult, +} from "@azure/core-paging"; +import { + Client, + createRestError, + PathUncheckedResponse, +} from "@azure-rest/core-client"; /** * Helper type to extract the type of an array @@ -73,7 +81,9 @@ export function paginate( typeof customGetPage === "function" ? customGetPage : async (pageLink: string) => { - const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get(); + const result = firstRun + ? initialResponse + : await client.pathUnchecked(pageLink).get(); firstRun = false; checkPagingRequest(result); const nextLink = getNextLink(result.body, nextLinkName); @@ -99,7 +109,9 @@ function getNextLink(body: unknown, nextLinkName?: string): string | undefined { const nextLink = (body as Record)[nextLinkName]; if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { - throw new Error(`Body Property ${nextLinkName} should be a string or undefined`); + throw new Error( + `Body Property ${nextLinkName} should be a string or undefined` + ); } return nextLink; @@ -127,7 +139,18 @@ function getElements(body: unknown, itemName: string): T[] { * Checks if a request failed */ function checkPagingRequest(response: PathUncheckedResponse): void { - const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"]; + const Http2xxStatusCodes = [ + "200", + "201", + "202", + "203", + "204", + "205", + "206", + "207", + "208", + "226", + ]; if (!Http2xxStatusCodes.includes(response.status)) { throw createRestError( `Pagination failed with unexpected statusCode ${response.status}`, @@ -150,7 +173,9 @@ function getPaginationProperties(initialResponse: PathUncheckedResponse) { let itemName: string | undefined; for (const name of nextLinkNames) { - const nextLink = (initialResponse.body as Record)[name] as string; + const nextLink = (initialResponse.body as Record)[ + name + ] as string; if (nextLink) { nextLinkName = name; break; @@ -158,7 +183,9 @@ function getPaginationProperties(initialResponse: PathUncheckedResponse) { } for (const name of itemNames) { - const item = (initialResponse.body as Record)[name] as string; + const item = (initialResponse.body as Record)[ + name + ] as string; if (item) { itemName = name; break; diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/src/parameters.ts b/sdk/anomalydetector/ai-anomaly-detector-rest/src/parameters.ts index 59bea177843b..3afdbee37bf6 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/src/parameters.ts +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/src/parameters.ts @@ -15,24 +15,24 @@ export interface DetectUnivariateEntireSeriesBodyParam { body: UnivariateDetectionOptions; } -export type DetectUnivariateEntireSeriesParameters = DetectUnivariateEntireSeriesBodyParam & - RequestParameters; +export type DetectUnivariateEntireSeriesParameters = + DetectUnivariateEntireSeriesBodyParam & RequestParameters; export interface DetectUnivariateLastPointBodyParam { /** Method of univariate anomaly detection. */ body: UnivariateDetectionOptions; } -export type DetectUnivariateLastPointParameters = DetectUnivariateLastPointBodyParam & - RequestParameters; +export type DetectUnivariateLastPointParameters = + DetectUnivariateLastPointBodyParam & RequestParameters; export interface DetectUnivariateChangePointBodyParam { /** Method of univariate anomaly detection. */ body: UnivariateChangePointDetectionOptions; } -export type DetectUnivariateChangePointParameters = DetectUnivariateChangePointBodyParam & - RequestParameters; +export type DetectUnivariateChangePointParameters = + DetectUnivariateChangePointBodyParam & RequestParameters; export type GetMultivariateBatchDetectionResultParameters = RequestParameters; export interface TrainMultivariateModelBodyParam { @@ -40,12 +40,13 @@ export interface TrainMultivariateModelBodyParam { body: ModelInfo; } -export type TrainMultivariateModelParameters = TrainMultivariateModelBodyParam & RequestParameters; +export type TrainMultivariateModelParameters = TrainMultivariateModelBodyParam & + RequestParameters; export interface ListMultivariateModelsQueryParamProperties { - /** Skip indicates how many models will be skipped. */ + /** The number of result items to skip. */ skip?: number; - /** Top indicates how many models will be fetched. */ + /** The number of result items to return. */ top?: number; } @@ -53,7 +54,8 @@ export interface ListMultivariateModelsQueryParam { queryParameters?: ListMultivariateModelsQueryParamProperties; } -export type ListMultivariateModelsParameters = ListMultivariateModelsQueryParam & RequestParameters; +export type ListMultivariateModelsParameters = + ListMultivariateModelsQueryParam & RequestParameters; export type DeleteMultivariateModelParameters = RequestParameters; export type GetMultivariateModelParameters = RequestParameters; @@ -62,13 +64,13 @@ export interface DetectMultivariateBatchAnomalyBodyParam { body: MultivariateBatchDetectionOptions; } -export type DetectMultivariateBatchAnomalyParameters = DetectMultivariateBatchAnomalyBodyParam & - RequestParameters; +export type DetectMultivariateBatchAnomalyParameters = + DetectMultivariateBatchAnomalyBodyParam & RequestParameters; export interface DetectMultivariateLastAnomalyBodyParam { - /** Request of last detection. */ + /** Request of the last detection. */ body: MultivariateLastDetectionOptions; } -export type DetectMultivariateLastAnomalyParameters = DetectMultivariateLastAnomalyBodyParam & - RequestParameters; +export type DetectMultivariateLastAnomalyParameters = + DetectMultivariateLastAnomalyBodyParam & RequestParameters; diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/src/responses.ts b/sdk/anomalydetector/ai-anomaly-detector-rest/src/responses.ts index d61497335541..cc8d0552e7ab 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/src/responses.ts +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/src/responses.ts @@ -23,10 +23,11 @@ export interface DetectUnivariateEntireSeries200Response extends HttpResponse { export interface DetectUnivariateEntireSeriesDefaultHeaders { /** Error code. */ - "x-ms-error-code"?: string; + "x-ms-error-code": string; } -export interface DetectUnivariateEntireSeriesDefaultResponse extends HttpResponse { +export interface DetectUnivariateEntireSeriesDefaultResponse + extends HttpResponse { status: string; body: AnomalyDetectorErrorOutput; headers: RawHttpHeaders & DetectUnivariateEntireSeriesDefaultHeaders; @@ -40,7 +41,7 @@ export interface DetectUnivariateLastPoint200Response extends HttpResponse { export interface DetectUnivariateLastPointDefaultHeaders { /** Error code. */ - "x-ms-error-code"?: string; + "x-ms-error-code": string; } export interface DetectUnivariateLastPointDefaultResponse extends HttpResponse { @@ -57,17 +58,19 @@ export interface DetectUnivariateChangePoint200Response extends HttpResponse { export interface DetectUnivariateChangePointDefaultHeaders { /** Error code. */ - "x-ms-error-code"?: string; + "x-ms-error-code": string; } -export interface DetectUnivariateChangePointDefaultResponse extends HttpResponse { +export interface DetectUnivariateChangePointDefaultResponse + extends HttpResponse { status: string; body: AnomalyDetectorErrorOutput; headers: RawHttpHeaders & DetectUnivariateChangePointDefaultHeaders; } /** The request has succeeded. */ -export interface GetMultivariateBatchDetectionResult200Response extends HttpResponse { +export interface GetMultivariateBatchDetectionResult200Response + extends HttpResponse { status: "200"; body: MultivariateDetectionResultOutput; } @@ -77,7 +80,8 @@ export interface GetMultivariateBatchDetectionResultDefaultHeaders { "x-ms-error-code"?: string; } -export interface GetMultivariateBatchDetectionResultDefaultResponse extends HttpResponse { +export interface GetMultivariateBatchDetectionResultDefaultResponse + extends HttpResponse { status: string; body: ErrorResponseOutput; headers: RawHttpHeaders & GetMultivariateBatchDetectionResultDefaultHeaders; @@ -157,14 +161,15 @@ export interface GetMultivariateModelDefaultResponse extends HttpResponse { } export interface DetectMultivariateBatchAnomaly202Headers { - /** Id of the detection result. */ + /** ID of the detection result. */ "operation-id": string; /** Location of the detection result. */ "operation-location": string; } /** The request has been accepted for processing, but processing has not yet completed. */ -export interface DetectMultivariateBatchAnomaly202Response extends HttpResponse { +export interface DetectMultivariateBatchAnomaly202Response + extends HttpResponse { status: "202"; body: MultivariateDetectionResultOutput; headers: RawHttpHeaders & DetectMultivariateBatchAnomaly202Headers; @@ -175,7 +180,8 @@ export interface DetectMultivariateBatchAnomalyDefaultHeaders { "x-ms-error-code"?: string; } -export interface DetectMultivariateBatchAnomalyDefaultResponse extends HttpResponse { +export interface DetectMultivariateBatchAnomalyDefaultResponse + extends HttpResponse { status: string; body: ErrorResponseOutput; headers: RawHttpHeaders & DetectMultivariateBatchAnomalyDefaultHeaders; @@ -192,7 +198,8 @@ export interface DetectMultivariateLastAnomalyDefaultHeaders { "x-ms-error-code"?: string; } -export interface DetectMultivariateLastAnomalyDefaultResponse extends HttpResponse { +export interface DetectMultivariateLastAnomalyDefaultResponse + extends HttpResponse { status: string; body: ErrorResponseOutput; headers: RawHttpHeaders & DetectMultivariateLastAnomalyDefaultHeaders; diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/test/public/sampleTest.spec.ts b/sdk/anomalydetector/ai-anomaly-detector-rest/test/public/sampleTest.spec.ts new file mode 100644 index 000000000000..bce68e428645 --- /dev/null +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/test/public/sampleTest.spec.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { Recorder } from "@azure-tools/test-recorder"; +import { assert } from "chai"; +import { createRecorder } from "./utils/recordedClient"; +import { Context } from "mocha"; + +describe("My test", () => { + let recorder: Recorder; + + beforeEach(async function (this: Context) { + recorder = await createRecorder(this); + }); + + afterEach(async function () { + await recorder.stop(); + }); + + it("sample test", async function () { + assert.equal(1, 1); + }); +}); diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/test/public/utils/recordedClient.ts b/sdk/anomalydetector/ai-anomaly-detector-rest/test/public/utils/recordedClient.ts index 37c7faf4a17b..6cc58bc15e11 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/test/public/utils/recordedClient.ts +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/test/public/utils/recordedClient.ts @@ -2,19 +2,15 @@ // Licensed under the MIT license. import { Context } from "mocha"; -import { - Recorder, - RecorderStartOptions, - assertEnvironmentVariable, -} from "@azure-tools/test-recorder"; +import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder"; import "./env"; -import AnomalyDetector, { AnomalyDetectorRestClient } from "../../../src"; -import { AzureKeyCredential } from "@azure/core-auth"; const envSetupForPlayback: Record = { - ANOMALY_DETECTOR_ENDPOINT: "https://endpoint/", - ANOMALY_DETECTOR_API_KEY: "fake_key", - ANOMALY_DETECTOR_DATA_URL: "https://endpoint-docs/data", + ENDPOINT: "https://endpoint", + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id", }; const recorderEnvSetup: RecorderStartOptions = { @@ -31,10 +27,3 @@ export async function createRecorder(context: Context): Promise { await recorder.start(recorderEnvSetup); return recorder; } - -export async function createClient(recorder: Recorder): Promise { - const endpoint = assertEnvironmentVariable("ANOMALY_DETECTOR_ENDPOINT"); - const key = assertEnvironmentVariable("ANOMALY_DETECTOR_API_KEY"); - const credential = new AzureKeyCredential(key); - return AnomalyDetector(endpoint, credential, recorder.configureClientOptions({})); -} diff --git a/sdk/anomalydetector/ai-anomaly-detector-rest/tsconfig.json b/sdk/anomalydetector/ai-anomaly-detector-rest/tsconfig.json index f356aca5b6f1..d5bf593423c9 100644 --- a/sdk/anomalydetector/ai-anomaly-detector-rest/tsconfig.json +++ b/sdk/anomalydetector/ai-anomaly-detector-rest/tsconfig.json @@ -2,8 +2,10 @@ "extends": "../../../tsconfig.package", "compilerOptions": { "outDir": "./dist-esm", - "declarationDir": "./types", - "paths": { "@azure-rest/ai-anomaly-detector": ["./src/index"] } + "declarationDir": "./types" }, - "include": ["src/**/*.ts", "./test/**/*.ts", "samples-dev/**/*.ts"] -} + "include": [ + "src/**/*.ts", + "./test/**/*.ts" + ] +} \ No newline at end of file diff --git a/sdk/anomalydetector/ci.yml b/sdk/anomalydetector/ci.yml index 7fd7030600df..14fdc0409ca8 100644 --- a/sdk/anomalydetector/ci.yml +++ b/sdk/anomalydetector/ci.yml @@ -1,6 +1,5 @@ -# DO NOT EDIT THIS FILE -# This file is generated automatically and any changes will be lost. - +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + trigger: branches: include: @@ -11,7 +10,6 @@ trigger: include: - sdk/anomalydetector/ - eng/common/ - pr: branches: include: @@ -19,10 +17,11 @@ pr: - feature/* - release/* - hotfix/* + exclude: + - feature/v4 paths: include: - sdk/anomalydetector/ - extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: