From e7e54f0b2c01a4a5b2e4a66cc73282a042cced47 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 14 Dec 2021 04:03:23 +0000 Subject: [PATCH] CodeGen from PR 16543 in Azure/azure-rest-api-specs Merge 169f17d2a6db19ce87cb0519b2c95eb5696ccff0 into 925e8285703ddd461588d8f5fbf14bd97c286fab --- .../cognitiveservices-anomalydetector/LICENSE | 21 + .../README.md | 260 +--- .../api-extractor.json | 18 + .../package.json | 91 +- .../rollup.config.js | 211 ++- .../src/anomalyDetectorClient.ts | 642 +++++++-- .../src/anomalyDetectorClientContext.ts | 51 - .../src/index.ts | 11 + .../src/models/index.ts | 779 +++++++---- .../src/models/mappers.ts | 1153 +++++++++++++++-- .../src/models/parameters.ts | 156 ++- .../test/sampleTest.ts | 48 + .../tsconfig.json | 6 +- 13 files changed, 2679 insertions(+), 768 deletions(-) create mode 100644 sdk/cognitiveservices/cognitiveservices-anomalydetector/LICENSE create mode 100644 sdk/cognitiveservices/cognitiveservices-anomalydetector/api-extractor.json delete mode 100644 sdk/cognitiveservices/cognitiveservices-anomalydetector/src/anomalyDetectorClientContext.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-anomalydetector/src/index.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-anomalydetector/test/sampleTest.ts diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/LICENSE b/sdk/cognitiveservices/cognitiveservices-anomalydetector/LICENSE new file mode 100644 index 000000000000..ccb63b166732 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-anomalydetector/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/README.md b/sdk/cognitiveservices/cognitiveservices-anomalydetector/README.md index 08b1f2af8d6d..84aa8fd041f3 100644 --- a/sdk/cognitiveservices/cognitiveservices-anomalydetector/README.md +++ b/sdk/cognitiveservices/cognitiveservices-anomalydetector/README.md @@ -1,219 +1,97 @@ -## An isomorphic javascript sdk for - AnomalyDetectorClient +# Azure Anomaly Detector client library for JavaScript -This package contains an isomorphic SDK for AnomalyDetectorClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure Anomaly Detector client. + +The Anomaly Detector API detects anomalies automatically in time series data. It supports two kinds of mode, one is for stateless using, another is for stateful using. In stateless mode, there are three functionalities. Entire Detect is for detecting the whole series with model trained by the time series, Last Detect is detecting last point with model trained by points before. ChangePoint Detect is for detecting trend changes in time series. In stateful mode, user can store time series, the stored time series will be used for detection anomalies. Under this mode, user can still use the above three functionalities by only giving a time range without preparing time series in client side. Besides the above three functionalities, stateful model also provide group based detection and labeling service. By leveraging labeling service user can provide labels for each detection result, these labels will be used for retuning or regenerating detection models. Inconsistency detection is a kind of group based detection, this detection will find inconsistency ones in a set of time series. By using anomaly detector service, business customers can discover incidents and establish a logic flow for root cause analysis. + +[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cognitiveservices/cognitiveservices-anomalydetector) | +[Package (NPM)](https://www.npmjs.com/package/@azure/cognitiveservices-anomalydetector) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/cognitiveservices-anomalydetector?view=azure-node-preview) | +[Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cognitiveservices/cognitiveservices-anomalydetector/samples) + +## Getting started ### Currently supported environments - [LTS versions of Node.js](https://nodejs.org/about/releases/) -- Latest versions of Safari, Chrome, Edge, and Firefox. +- Latest versions of Safari, Chrome, Edge and Firefox. + +### Prerequisites + +- An [Azure subscription][azure_sub]. + +### Install the `@azure/cognitiveservices-anomalydetector` package -### How to Install +Install the Azure Anomaly Detector client library for JavaScript with `npm`: ```bash npm install @azure/cognitiveservices-anomalydetector ``` -### How to use +### Create and authenticate a `AnomalyDetectorClient` -#### nodejs - Authentication, client creation and entireDetect as an example written in TypeScript. +To create a client object to access the Azure Anomaly Detector API, you will need the `endpoint` of your Azure Anomaly Detector resource and a `credential`. The Azure Anomaly Detector client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure Anomaly Detector resource in the [Azure Portal][azure_portal]. -##### Install @azure/ms-rest-azure-js +You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). + +To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: ```bash -npm install @azure/ms-rest-azure-js +npm install @azure/identity ``` -##### Sample code -The following sample determines anamolies with the given time series. To know more, refer to the [Azure Documentation on Anomaly Detectors](https://docs.microsoft.com/azure/cognitive-services/anomaly-detector/) +You will also need to **register a new AAD application and grant access to Azure Anomaly Detector** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). +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`. + +For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). ```javascript const { AnomalyDetectorClient } = require("@azure/cognitiveservices-anomalydetector"); -const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js"); - -async function main() { - const anomalyDetectorKey = process.env["anomalyDetectorKey"] || ""; - const anomalyDetectorEndPoint = - process.env["anomalyDetectorEndPoint"] || ""; - - const cognitiveServiceCredentials = new CognitiveServicesCredentials(anomalyDetectorKey); - - const client = new AnomalyDetectorClient(cognitiveServiceCredentials, anomalyDetectorEndPoint); - - const body = { - series: [ - { - timestamp: new Date("December 15, 2018"), - value: 1.01 - }, - { - timestamp: new Date("December 16, 2018"), - value: 1.02 - }, - { - timestamp: new Date("December 17, 2018"), - value: 1.03 - }, - { - timestamp: new Date("December 18, 2018"), - value: 1.04 - }, - { - timestamp: new Date("December 19, 2018"), - value: 1.05 - }, - { - timestamp: new Date("December 20, 2018"), - value: 1.06 - }, - { - timestamp: new Date("December 21, 2018"), - value: 1.07 - }, - { - timestamp: new Date("December 22, 2018"), - value: 1.08 - }, - { - timestamp: new Date("December 23, 2018"), - value: 1.09 - }, - { - timestamp: new Date("December 24, 2018"), - value: 1.1 - }, - { - timestamp: new Date("December 25, 2018"), - value: 1.11 - }, - { - timestamp: new Date("December 26, 2018"), - value: 1.12 - } - ], - granularity: "daily", - customInterval: 1, - period: 1, - maxAnomalyRatio: 0.3, - sensitivity: 1 - }; - - client - .entireDetect(body) - .then((result) => { - console.log("The result is:"); - console.log(result); - }) - .catch((err) => { - console.log("An error occurred:"); - console.error(err); - }); -} - -main(); +const { DefaultAzureCredential } = require("@azure/identity"); +const client = new AnomalyDetectorClient("", new DefaultAzureCredential()); ``` -#### browser - Authentication, client creation and entireDetect as an example written in JavaScript. - -##### Sample code - -- index.html - -```html - - - - @azure/cognitiveservices-anomalydetector sample - - - - - - + +### JavaScript Bundle +To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). + +## Key concepts + +### AnomalyDetectorClient + +`AnomalyDetectorClient` is the primary interface for developers using the Azure Anomaly Detector client library. Explore the methods on this client object to understand the different features of the Azure Anomaly Detector service that you can access. + +## Troubleshooting + +### 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`: + +```javascript +const { setLogLevel } = require("@azure/logger"); +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 + +Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cognitiveservices/cognitiveservices-anomalydetector/samples) directory for detailed examples on how to use this library. + +## Contributing + +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code. + ## Related projects -- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) +- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcognitiveservices%2Fcognitiveservices-anomalydetector%2FREADME.png) + +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_sub]: https://azure.microsoft.com/free/ +[azure_sub]: https://azure.microsoft.com/free/ +[azure_portal]: https://portal.azure.com +[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity +[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/api-extractor.json b/sdk/cognitiveservices/cognitiveservices-anomalydetector/api-extractor.json new file mode 100644 index 000000000000..86cb55efa2e7 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-anomalydetector/api-extractor.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", + "docModel": { "enabled": true }, + "apiReport": { "enabled": true, "reportFolder": "./review" }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/cognitiveservices-anomalydetector.d.ts" + }, + "messages": { + "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "extractorMessageReporting": { + "ae-missing-release-tag": { "logLevel": "none" }, + "ae-unresolved-link": { "logLevel": "none" } + } + } +} diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/package.json b/sdk/cognitiveservices/cognitiveservices-anomalydetector/package.json index efb6a15b120d..f47d92687c50 100644 --- a/sdk/cognitiveservices/cognitiveservices-anomalydetector/package.json +++ b/sdk/cognitiveservices/cognitiveservices-anomalydetector/package.json @@ -1,56 +1,89 @@ { "name": "@azure/cognitiveservices-anomalydetector", + "sdk-type": "client", "author": "Microsoft Corporation", - "description": "AnomalyDetectorClient Library with typescript type definitions for node.js and browser.", - "version": "2.1.0", + "description": "A generated SDK for AnomalyDetectorClient.", + "version": "1.0.0-beta.1", + "engines": { "node": ">=12.0.0" }, "dependencies": { - "@azure/ms-rest-js": "^2.0.4", - "tslib": "^1.10.0" + "@azure/core-paging": "^1.2.0", + "@azure/core-client": "^1.0.0", + "@azure/core-auth": "^1.3.0", + "@azure/core-rest-pipeline": "^1.1.0", + "tslib": "^2.2.0" }, - "keywords": [ - "node", - "azure", - "typescript", - "browser", - "isomorphic" - ], + "keywords": ["node", "azure", "typescript", "browser", "isomorphic"], "license": "MIT", - "main": "./dist/cognitiveservices-anomalydetector.js", - "module": "./esm/anomalyDetectorClient.js", - "types": "./esm/anomalyDetectorClient.d.ts", + "main": "./dist/index.js", + "module": "./dist-esm/src/index.js", + "types": "./types/cognitiveservices-anomalydetector.d.ts", "devDependencies": { - "typescript": "^3.5.3", - "rollup": "^1.18.0", - "rollup-plugin-node-resolve": "^5.2.0", + "@microsoft/api-extractor": "^7.18.11", + "@rollup/plugin-commonjs": "11.0.2", + "@rollup/plugin-json": "^4.0.0", + "@rollup/plugin-multi-entry": "^3.0.0", + "@rollup/plugin-node-resolve": "^8.0.0", + "mkdirp": "^1.0.4", + "rollup": "^1.16.3", "rollup-plugin-sourcemaps": "^0.4.2", - "uglify-js": "^3.6.0" + "typescript": "~4.2.0", + "uglify-js": "^3.4.9", + "rimraf": "^3.0.0", + "@azure/identity": "^2.0.1", + "@azure-tools/test-recorder": "^1.0.0", + "mocha": "^7.1.1", + "cross-env": "^7.0.2" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cognitiveservices/cognitiveservices-anomalydetector", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" }, - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, + "bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, "files": [ "dist/**/*.js", "dist/**/*.js.map", "dist/**/*.d.ts", "dist/**/*.d.ts.map", - "esm/**/*.js", - "esm/**/*.js.map", - "esm/**/*.d.ts", - "esm/**/*.d.ts.map", + "dist-esm/**/*.js", + "dist-esm/**/*.js.map", + "dist-esm/**/*.d.ts", + "dist-esm/**/*.d.ts.map", "src/**/*.ts", "README.md", + "LICENSE", "rollup.config.js", - "tsconfig.json" + "tsconfig.json", + "review/*", + "CHANGELOG.md", + "types/*" ], "scripts": { - "build": "tsc && rollup -c rollup.config.js && npm run minify", - "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/cognitiveservices-anomalydetector.js.map'\" -o ./dist/cognitiveservices-anomalydetector.min.js ./dist/cognitiveservices-anomalydetector.js", - "prepack": "npm install && npm run build" + "build": "npm run clean && tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", + "prepack": "npm run build", + "pack": "npm pack 2>&1", + "extract-api": "api-extractor run --local", + "lint": "echo skipped", + "audit": "echo skipped", + "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "build:node": "echo skipped", + "build:browser": "echo skipped", + "build:test": "echo skipped", + "build:samples": "echo skipped.", + "check-format": "echo skipped", + "execute:samples": "echo skipped", + "format": "echo skipped", + "test": "npm run integration-test", + "test:node": "echo skipped", + "test:browser": "echo skipped", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", + "unit-test:browser": "echo skipped", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", + "integration-test:browser": "echo skipped", + "docs": "echo skipped" }, "sideEffects": false, "autoPublish": true diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/rollup.config.js b/sdk/cognitiveservices/cognitiveservices-anomalydetector/rollup.config.js index 4c53d6821d8e..9be1955eb7f1 100644 --- a/sdk/cognitiveservices/cognitiveservices-anomalydetector/rollup.config.js +++ b/sdk/cognitiveservices/cognitiveservices-anomalydetector/rollup.config.js @@ -1,37 +1,188 @@ -import rollup from "rollup"; -import nodeResolve from "rollup-plugin-node-resolve"; +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import nodeResolve from "@rollup/plugin-node-resolve"; +import cjs from "@rollup/plugin-commonjs"; import sourcemaps from "rollup-plugin-sourcemaps"; +import multiEntry from "@rollup/plugin-multi-entry"; +import json from "@rollup/plugin-json"; + +import nodeBuiltins from "builtin-modules"; + +/** + * Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api. + * + * NOTE: this manual configuration is only needed because OpenTelemetry uses an + * __exportStar downleveled helper function to declare its exports which confuses + * rollup's automatic discovery mechanism. + * + * @returns an object reference that can be `...`'d into your cjs() configuration. + */ +export function openTelemetryCommonJs() { + const namedExports = {}; + + for (const key of [ + "@opentelemetry/api", + "@azure/core-tracing/node_modules/@opentelemetry/api" + ]) { + namedExports[key] = [ + "SpanKind", + "TraceFlags", + "getSpan", + "setSpan", + "SpanStatusCode", + "getSpanContext", + "setSpanContext" + ]; + } + + const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"]; + + for (const version of releasedOpenTelemetryVersions) { + namedExports[ + // working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path. + `../../../common/temp/node_modules/.pnpm/@opentelemetry/api@${version}/node_modules/@opentelemetry/api/build/src/index.js` + ] = [ + "SpanKind", + "TraceFlags", + "getSpan", + "setSpan", + "StatusCode", + "CanonicalCode", + "getSpanContext", + "setSpanContext" + ]; + } + + return namedExports; +} + +// #region Warning Handler /** - * @type {rollup.RollupFileOptions} + * A function that can determine whether a rollupwarning should be ignored. If + * the function returns `true`, then the warning will not be displayed. */ -const config = { - input: "./esm/anomalyDetectorClient.js", - external: [ - "@azure/ms-rest-js", - "@azure/ms-rest-azure-js" - ], - output: { - file: "./dist/cognitiveservices-anomalydetector.js", - format: "umd", - name: "Azure.CognitiveservicesAnomalydetector", - sourcemap: true, - globals: { - "@azure/ms-rest-js": "msRest", - "@azure/ms-rest-azure-js": "msRestAzure" + +function ignoreNiseSinonEvalWarnings(warning) { + return ( + warning.code === "EVAL" && + warning.id && + (warning.id.includes("node_modules/nise") || + warning.id.includes("node_modules/sinon")) === true + ); +} + +function ignoreChaiCircularDependencyWarnings(warning) { + return ( + warning.code === "CIRCULAR_DEPENDENCY" && + warning.importer && warning.importer.includes("node_modules/chai") === true + ); +} + +const warningInhibitors = [ + ignoreChaiCircularDependencyWarnings, + ignoreNiseSinonEvalWarnings +]; + +/** + * Construct a warning handler for the shared rollup configuration + * that ignores certain warnings that are not relevant to testing. + */ +function makeOnWarnForTesting() { + return (warning, warn) => { + // If every inhibitor returns false (i.e. no inhibitors), then show the warning + if (warningInhibitors.every((inhib) => !inhib(warning))) { + warn(warning); + } + }; +} + +// #endregion + +function makeBrowserTestConfig() { + const config = { + input: { + include: ["dist-esm/test/**/*.spec.js"], + exclude: ["dist-esm/test/**/node/**"] }, - banner: `/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */` - }, - plugins: [ - nodeResolve({ mainFields: ['module', 'main'] }), - sourcemaps() - ] + output: { + file: `dist-test/index.browser.js`, + format: "umd", + sourcemap: true + }, + preserveSymlinks: false, + plugins: [ + multiEntry({ exports: false }), + nodeResolve({ + mainFields: ["module", "browser"] + }), + cjs({ + namedExports: { + // Chai's strange internal architecture makes it impossible to statically + // analyze its exports. + chai: [ + "version", + "use", + "util", + "config", + "expect", + "should", + "assert" + ], + ...openTelemetryCommonJs() + } + }), + json(), + sourcemaps() + //viz({ filename: "dist-test/browser-stats.html", sourcemap: true }) + ], + onwarn: makeOnWarnForTesting(), + // Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, + // rollup started respecting the "sideEffects" field in package.json. Since + // our package.json sets "sideEffects=false", this also applies to test + // code, which causes all tests to be removed by tree-shaking. + treeshake: false + }; + + return config; +} + +const defaultConfigurationOptions = { + disableBrowserBundle: false }; -export default config; +export function makeConfig(pkg, options) { + options = { + ...defaultConfigurationOptions, + ...(options || {}) + }; + + const baseConfig = { + // Use the package's module field if it has one + input: pkg["module"] || "dist-esm/src/index.js", + external: [ + ...nodeBuiltins, + ...Object.keys(pkg.dependencies), + ...Object.keys(pkg.devDependencies) + ], + output: { file: "dist/index.js", format: "cjs", sourcemap: true }, + preserveSymlinks: false, + plugins: [sourcemaps(), nodeResolve(), cjs()] + }; + + const config = [baseConfig]; + + if (!options.disableBrowserBundle) { + config.push(makeBrowserTestConfig()); + } + + return config; +} + +export default makeConfig(require("./package.json")); diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/anomalyDetectorClient.ts b/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/anomalyDetectorClient.ts index d81adaa8a315..92186794b998 100644 --- a/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/anomalyDetectorClient.ts +++ b/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/anomalyDetectorClient.ts @@ -1,209 +1,589 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import * as msRest from "@azure/ms-rest-js"; -import * as Models from "./models"; -import * as Mappers from "./models/mappers"; +import * as coreClient from "@azure/core-client"; +import * as coreAuth from "@azure/core-auth"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; import * as Parameters from "./models/parameters"; -import { AnomalyDetectorClientContext } from "./anomalyDetectorClientContext"; +import * as Mappers from "./models/mappers"; +import { + AnomalyDetectorClientOptionalParams, + ModelSnapshot, + ListMultivariateModelNextOptionalParams, + ListMultivariateModelOptionalParams, + DetectRequest, + DetectEntireSeriesOptionalParams, + DetectEntireSeriesResponse, + DetectLastPointOptionalParams, + DetectLastPointResponse, + ChangePointDetectRequest, + DetectChangePointOptionalParams, + DetectChangePointResponse, + ModelInfo, + TrainMultivariateModelOptionalParams, + TrainMultivariateModelResponse, + ListMultivariateModelResponse, + GetMultivariateModelOptionalParams, + GetMultivariateModelResponse, + DeleteMultivariateModelOptionalParams, + DetectionRequest, + DetectAnomalyOptionalParams, + DetectAnomalyResponse, + GetDetectionResultOptionalParams, + GetDetectionResultResponse, + ExportModelOptionalParams, + ExportModelResponse, + LastDetectionRequest, + LastDetectAnomalyOptionalParams, + LastDetectAnomalyResponse, + ListMultivariateModelNextResponse +} from "./models"; + +/// +export class AnomalyDetectorClient extends coreClient.ServiceClient { + endpoint: string; + apiVersion: string; -class AnomalyDetectorClient extends AnomalyDetectorClientContext { /** * Initializes a new instance of the AnomalyDetectorClient class. - * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: - * https://westus2.api.cognitive.microsoft.com). * @param credentials Subscription credentials which uniquely identify client subscription. - * @param [options] The parameter options + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://westus2.api.cognitive.microsoft.com). + * @param options The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, endpoint: string, options?: msRest.ServiceClientOptions) { - super(credentials, endpoint, options); + constructor( + credentials: coreAuth.TokenCredential, + endpoint: string, + options?: AnomalyDetectorClientOptionalParams + ) { + if (credentials === undefined) { + throw new Error("'credentials' cannot be null"); + } + if (endpoint === undefined) { + throw new Error("'endpoint' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + const defaults: AnomalyDetectorClientOptionalParams = { + requestContentType: "application/json; charset=utf-8", + credential: credentials + }; + + const packageDetails = `azsdk-js-cognitiveservices-anomalydetector/1.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` + : `${packageDetails}`; + + const optionsWithDefaults = { + ...defaults, + ...options, + userAgentOptions: { + userAgentPrefix + }, + baseUri: options.endpoint || "{Endpoint}/anomalydetector/{ApiVersion}" + }; + super(optionsWithDefaults); + // Parameter assignments + this.endpoint = endpoint; + + // Assigning values to Constant parameters + this.apiVersion = options.apiVersion || "v1.1-preview.1"; } /** - * This operation generates a model using an entire series, each point is detected with the same - * model. With this method, points before and after a certain point are used to determine whether - * it is an anomaly. The entire detection can give user an overall status of the time series. - * @summary Detect anomalies for the entire series in batch. - * @param body Time series points and period if needed. Advanced model parameters can also be set - * in the request. - * @param [options] The optional parameters - * @returns Promise + * List models of a subscription + * @param options The options parameters. */ - entireDetect(body: Models.Request, options?: msRest.RequestOptionsBase): Promise; - /** - * @param body Time series points and period if needed. Advanced model parameters can also be set - * in the request. - * @param callback The callback - */ - entireDetect(body: Models.Request, callback: msRest.ServiceCallback): void; + public listMultivariateModel( + options?: ListMultivariateModelOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listMultivariateModelPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listMultivariateModelPagingPage(options); + } + }; + } + + private async *listMultivariateModelPagingPage( + options?: ListMultivariateModelOptionalParams + ): AsyncIterableIterator { + let result = await this._listMultivariateModel(options); + yield result.models || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listMultivariateModelNext( + continuationToken, + options + ); + continuationToken = result.nextLink; + yield result.models || []; + } + } + + private async *listMultivariateModelPagingAll( + options?: ListMultivariateModelOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listMultivariateModelPagingPage(options)) { + yield* page; + } + } + /** - * @param body Time series points and period if needed. Advanced model parameters can also be set - * in the request. - * @param options The optional parameters - * @param callback The callback + * This operation generates a model with an entire series, each point is detected with the same model. + * With this method, points before and after a certain point are used to determine whether it is an + * anomaly. The entire detection can give user an overall status of the time series. + * @param body Time series points and period if needed. Advanced model parameters can also be set in + * the request. + * @param options The options parameters. */ - entireDetect(body: Models.Request, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - entireDetect(body: Models.Request, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + detectEntireSeries( + body: DetectRequest, + options?: DetectEntireSeriesOptionalParams + ): Promise { return this.sendOperationRequest( - { - body, - options - }, - entireDetectOperationSpec, - callback) as Promise; + { body, options }, + detectEntireSeriesOperationSpec + ); } /** * This operation generates a model using points before the latest one. With this method, only * historical points are used to determine whether the target point is an anomaly. The latest point * detecting operation matches the scenario of real-time monitoring of business metrics. - * @summary Detect anomaly status of the latest point in time series. - * @param body Time series points and period if needed. Advanced model parameters can also be set - * in the request. - * @param [options] The optional parameters - * @returns Promise + * @param body Time series points and period if needed. Advanced model parameters can also be set in + * the request. + * @param options The options parameters. */ - lastDetect(body: Models.Request, options?: msRest.RequestOptionsBase): Promise; + detectLastPoint( + body: DetectRequest, + options?: DetectLastPointOptionalParams + ): Promise { + return this.sendOperationRequest( + { body, options }, + detectLastPointOperationSpec + ); + } + /** - * @param body Time series points and period if needed. Advanced model parameters can also be set - * in the request. - * @param callback The callback + * Evaluate change point score of every series point + * @param body Time series points and granularity is needed. Advanced model parameters can also be set + * in the request if needed. + * @param options The options parameters. */ - lastDetect(body: Models.Request, callback: msRest.ServiceCallback): void; + detectChangePoint( + body: ChangePointDetectRequest, + options?: DetectChangePointOptionalParams + ): Promise { + return this.sendOperationRequest( + { body, options }, + detectChangePointOperationSpec + ); + } + /** - * @param body Time series points and period if needed. Advanced model parameters can also be set - * in the request. - * @param options The optional parameters - * @param callback The callback + * Create and train a multivariate anomaly detection model. The request must include a source parameter + * to indicate an externally accessible Azure storage Uri (preferably a Shared Access Signature Uri). + * All time-series used in generate the model must be zipped into one single file. Each time-series + * will be in a single CSV file in which the first column is timestamp and the second column is value. + * @param body Training request + * @param options The options parameters. */ - lastDetect(body: Models.Request, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - lastDetect(body: Models.Request, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + trainMultivariateModel( + body: ModelInfo, + options?: TrainMultivariateModelOptionalParams + ): Promise { return this.sendOperationRequest( - { - body, - options - }, - lastDetectOperationSpec, - callback) as Promise; + { body, options }, + trainMultivariateModelOperationSpec + ); } /** - * Evaluate change point score of every series point - * @summary Detect change point for the entire series - * @param body Time series points and granularity is needed. Advanced model parameters can also be - * set in the request if needed. - * @param [options] The optional parameters - * @returns Promise + * List models of a subscription + * @param options The options parameters. */ - changePointDetect(body: Models.ChangePointDetectRequest, options?: msRest.RequestOptionsBase): Promise; + private _listMultivariateModel( + options?: ListMultivariateModelOptionalParams + ): Promise { + return this.sendOperationRequest( + { options }, + listMultivariateModelOperationSpec + ); + } + /** - * @param body Time series points and granularity is needed. Advanced model parameters can also be - * set in the request if needed. - * @param callback The callback + * Get detailed information of multivariate model, including the training status and variables used in + * the model. + * @param modelId Model identifier. + * @param options The options parameters. */ - changePointDetect(body: Models.ChangePointDetectRequest, callback: msRest.ServiceCallback): void; + getMultivariateModel( + modelId: string, + options?: GetMultivariateModelOptionalParams + ): Promise { + return this.sendOperationRequest( + { modelId, options }, + getMultivariateModelOperationSpec + ); + } + /** - * @param body Time series points and granularity is needed. Advanced model parameters can also be - * set in the request if needed. - * @param options The optional parameters - * @param callback The callback + * Delete an existing multivariate model according to the modelId + * @param modelId Model identifier. + * @param options The options parameters. */ - changePointDetect(body: Models.ChangePointDetectRequest, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - changePointDetect(body: Models.ChangePointDetectRequest, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + deleteMultivariateModel( + modelId: string, + options?: DeleteMultivariateModelOptionalParams + ): Promise { return this.sendOperationRequest( - { - body, - options - }, - changePointDetectOperationSpec, - callback) as Promise; + { modelId, options }, + deleteMultivariateModelOperationSpec + ); + } + + /** + * Submit detection multivariate anomaly task with the trained model of modelId, the input schema + * should be the same with the training request. Thus request will be complete asynchronously and will + * return a resultId for querying the detection result.The request should be a source link to indicate + * an externally accessible Azure storage Uri (preferably a Shared Access Signature Uri). All + * time-series used in generate the model must be zipped into one single file. Each time-series will be + * as follows: the first column is timestamp and the second column is value. + * @param modelId Model identifier. + * @param body Detect anomaly request + * @param options The options parameters. + */ + detectAnomaly( + modelId: string, + body: DetectionRequest, + options?: DetectAnomalyOptionalParams + ): Promise { + return this.sendOperationRequest( + { modelId, body, options }, + detectAnomalyOperationSpec + ); + } + + /** + * Get multivariate anomaly detection result based on resultId returned by the DetectAnomalyAsync api + * @param resultId Result identifier. + * @param options The options parameters. + */ + getDetectionResult( + resultId: string, + options?: GetDetectionResultOptionalParams + ): Promise { + return this.sendOperationRequest( + { resultId, options }, + getDetectionResultOperationSpec + ); + } + + /** + * Export multivariate anomaly detection model based on modelId + * @param modelId Model identifier. + * @param options The options parameters. + */ + exportModel( + modelId: string, + options?: ExportModelOptionalParams + ): Promise { + return this.sendOperationRequest( + { modelId, options }, + exportModelOperationSpec + ); + } + + /** + * Synchronized API for anomaly detection. + * @param modelId Model identifier. + * @param body Request for last detection. + * @param options The options parameters. + */ + lastDetectAnomaly( + modelId: string, + body: LastDetectionRequest, + options?: LastDetectAnomalyOptionalParams + ): Promise { + return this.sendOperationRequest( + { modelId, body, options }, + lastDetectAnomalyOperationSpec + ); } -} + /** + * ListMultivariateModelNext + * @param nextLink The nextLink from the previous successful call to the ListMultivariateModel method. + * @param options The options parameters. + */ + private _listMultivariateModelNext( + nextLink: string, + options?: ListMultivariateModelNextOptionalParams + ): Promise { + return this.sendOperationRequest( + { nextLink, options }, + listMultivariateModelNextOperationSpec + ); + } +} // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const entireDetectOperationSpec: msRest.OperationSpec = { +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const detectEntireSeriesOperationSpec: coreClient.OperationSpec = { + path: "/timeseries/entire/detect", httpMethod: "POST", - path: "timeseries/entire/detect", - urlParameters: [ - Parameters.endpoint - ], - requestBody: { - parameterPath: "body", - mapper: { - ...Mappers.Request, - required: true + responses: { + 200: { + bodyMapper: Mappers.EntireDetectResponse + }, + default: { + bodyMapper: Mappers.AnomalyDetectorError, + headersMapper: + Mappers.AnomalyDetectorClientDetectEntireSeriesExceptionHeaders + } + }, + requestBody: Parameters.body, + urlParameters: [Parameters.endpoint, Parameters.apiVersion], + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", + serializer +}; +const detectLastPointOperationSpec: coreClient.OperationSpec = { + path: "/timeseries/last/detect", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.LastDetectResponse + }, + default: { + bodyMapper: Mappers.AnomalyDetectorError, + headersMapper: + Mappers.AnomalyDetectorClientDetectLastPointExceptionHeaders } }, + requestBody: Parameters.body, + urlParameters: [Parameters.endpoint, Parameters.apiVersion], + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", + serializer +}; +const detectChangePointOperationSpec: coreClient.OperationSpec = { + path: "/timeseries/changepoint/detect", + httpMethod: "POST", responses: { 200: { - bodyMapper: Mappers.EntireDetectResponse + bodyMapper: Mappers.ChangePointDetectResponse }, default: { - bodyMapper: Mappers.APIError + bodyMapper: Mappers.AnomalyDetectorError, + headersMapper: + Mappers.AnomalyDetectorClientDetectChangePointExceptionHeaders } }, + requestBody: Parameters.body1, + urlParameters: [Parameters.endpoint, Parameters.apiVersion], + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", serializer }; - -const lastDetectOperationSpec: msRest.OperationSpec = { +const trainMultivariateModelOperationSpec: coreClient.OperationSpec = { + path: "/multivariate/models", httpMethod: "POST", - path: "timeseries/last/detect", - urlParameters: [ - Parameters.endpoint - ], - requestBody: { - parameterPath: "body", - mapper: { - ...Mappers.Request, - required: true + responses: { + 201: { + headersMapper: Mappers.AnomalyDetectorClientTrainMultivariateModelHeaders + }, + default: { + bodyMapper: Mappers.ErrorResponse, + headersMapper: + Mappers.AnomalyDetectorClientTrainMultivariateModelExceptionHeaders } }, + requestBody: Parameters.body2, + urlParameters: [Parameters.endpoint, Parameters.apiVersion], + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", + serializer +}; +const listMultivariateModelOperationSpec: coreClient.OperationSpec = { + path: "/multivariate/models", + httpMethod: "GET", responses: { 200: { - bodyMapper: Mappers.LastDetectResponse + bodyMapper: Mappers.ModelList }, default: { - bodyMapper: Mappers.APIError + bodyMapper: Mappers.ErrorResponse, + headersMapper: + Mappers.AnomalyDetectorClientListMultivariateModelExceptionHeaders } }, + queryParameters: [Parameters.skip, Parameters.top], + urlParameters: [Parameters.endpoint, Parameters.apiVersion], + headerParameters: [Parameters.accept], serializer }; - -const changePointDetectOperationSpec: msRest.OperationSpec = { +const getMultivariateModelOperationSpec: coreClient.OperationSpec = { + path: "/multivariate/models/{modelId}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.Model + }, + default: { + bodyMapper: Mappers.ErrorResponse, + headersMapper: + Mappers.AnomalyDetectorClientGetMultivariateModelExceptionHeaders + } + }, + urlParameters: [ + Parameters.endpoint, + Parameters.apiVersion, + Parameters.modelId + ], + headerParameters: [Parameters.accept], + serializer +}; +const deleteMultivariateModelOperationSpec: coreClient.OperationSpec = { + path: "/multivariate/models/{modelId}", + httpMethod: "DELETE", + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse, + headersMapper: + Mappers.AnomalyDetectorClientDeleteMultivariateModelExceptionHeaders + } + }, + urlParameters: [ + Parameters.endpoint, + Parameters.apiVersion, + Parameters.modelId + ], + headerParameters: [Parameters.accept], + serializer +}; +const detectAnomalyOperationSpec: coreClient.OperationSpec = { + path: "/multivariate/models/{modelId}/detect", httpMethod: "POST", - path: "timeseries/changePoint/detect", + responses: { + 201: { + headersMapper: Mappers.AnomalyDetectorClientDetectAnomalyHeaders + }, + default: { + bodyMapper: Mappers.ErrorResponse, + headersMapper: Mappers.AnomalyDetectorClientDetectAnomalyExceptionHeaders + } + }, + requestBody: Parameters.body3, urlParameters: [ - Parameters.endpoint + Parameters.endpoint, + Parameters.apiVersion, + Parameters.modelId ], - requestBody: { - parameterPath: "body", - mapper: { - ...Mappers.ChangePointDetectRequest, - required: true + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", + serializer +}; +const getDetectionResultOperationSpec: coreClient.OperationSpec = { + path: "/multivariate/results/{resultId}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.DetectionResult + }, + default: { + bodyMapper: Mappers.ErrorResponse, + headersMapper: + Mappers.AnomalyDetectorClientGetDetectionResultExceptionHeaders } }, + urlParameters: [ + Parameters.endpoint, + Parameters.apiVersion, + Parameters.resultId + ], + headerParameters: [Parameters.accept], + serializer +}; +const exportModelOperationSpec: coreClient.OperationSpec = { + path: "/multivariate/models/{modelId}/export", + httpMethod: "GET", responses: { 200: { - bodyMapper: Mappers.ChangePointDetectResponse + bodyMapper: { type: { name: "Stream" }, serializedName: "parsedResponse" } }, default: { - bodyMapper: Mappers.APIError + bodyMapper: Mappers.ErrorResponse, + headersMapper: Mappers.AnomalyDetectorClientExportModelExceptionHeaders } }, + urlParameters: [ + Parameters.endpoint, + Parameters.apiVersion, + Parameters.modelId + ], + headerParameters: [Parameters.accept1], serializer }; - -export { - AnomalyDetectorClient, - AnomalyDetectorClientContext, - Models as AnomalyDetectorModels, - Mappers as AnomalyDetectorMappers +const lastDetectAnomalyOperationSpec: coreClient.OperationSpec = { + path: "/multivariate/models/{modelId}/last/detect", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.LastDetectionResult + }, + default: { + bodyMapper: Mappers.ErrorResponse, + headersMapper: + Mappers.AnomalyDetectorClientLastDetectAnomalyExceptionHeaders + } + }, + requestBody: Parameters.body4, + urlParameters: [ + Parameters.endpoint, + Parameters.apiVersion, + Parameters.modelId + ], + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", + serializer +}; +const listMultivariateModelNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ModelList + }, + default: { + bodyMapper: Mappers.ErrorResponse, + headersMapper: + Mappers.AnomalyDetectorClientListMultivariateModelNextExceptionHeaders + } + }, + queryParameters: [Parameters.skip, Parameters.top], + urlParameters: [ + Parameters.endpoint, + Parameters.apiVersion, + Parameters.nextLink + ], + headerParameters: [Parameters.accept], + serializer }; diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/anomalyDetectorClientContext.ts b/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/anomalyDetectorClientContext.ts deleted file mode 100644 index f6ed770578e9..000000000000 --- a/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/anomalyDetectorClientContext.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -import * as msRest from "@azure/ms-rest-js"; - -const packageName = "@azure/cognitiveservices-anomalydetector"; -const packageVersion = "2.1.0"; - -export class AnomalyDetectorClientContext extends msRest.ServiceClient { - endpoint: string; - credentials: msRest.ServiceClientCredentials; - - /** - * Initializes a new instance of the AnomalyDetectorClientContext class. - * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: - * https://westus2.api.cognitive.microsoft.com). - * @param credentials Subscription credentials which uniquely identify client subscription. - * @param [options] The parameter options - */ - constructor(credentials: msRest.ServiceClientCredentials, endpoint: string, options?: msRest.ServiceClientOptions) { - if (endpoint == undefined) { - throw new Error("'endpoint' cannot be null."); - } - if (credentials == undefined) { - throw new Error("'credentials' cannot be null."); - } - - if (!options) { - options = {}; - } - - if (!options.userAgent) { - const defaultUserAgent = msRest.getDefaultUserAgentValue(); - options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; - } - - super(credentials, options); - - this.baseUri = "{Endpoint}/anomalydetector/v1.0"; - this.requestContentType = "application/json; charset=utf-8"; - this.endpoint = endpoint; - this.credentials = credentials; - } -} diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/index.ts b/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/index.ts new file mode 100644 index 000000000000..e16f1dbfe136 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +/// +export * from "./models"; +export { AnomalyDetectorClient } from "./anomalyDetectorClient"; diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/models/index.ts b/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/models/index.ts index 2a2dd8864f0a..7407c23772c9 100644 --- a/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/models/index.ts +++ b/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/models/index.ts @@ -1,295 +1,604 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ +import * as coreClient from "@azure/core-client"; -import * as msRest from "@azure/ms-rest-js"; - -/** - * Error information returned by the API. - */ -export interface APIError { - /** - * The error code. - */ - code?: any; - /** - * A message explaining the error reported by the service. - */ - message?: string; -} - -/** - * An interface representing Point. - */ -export interface Point { - /** - * Timestamp of a data point (ISO8601 format). - */ - timestamp: Date; - /** - * The measurement of that point, should be float. - */ - value: number; -} - -/** - * An interface representing Request. - */ -export interface Request { - /** - * Time series data points. Points should be sorted by timestamp in ascending order to match the - * anomaly detection result. If the data is not sorted correctly or there is duplicated - * timestamp, the API will not work. In such case, an error message will be returned. - */ - series: Point[]; - /** - * Possible values include: 'yearly', 'monthly', 'weekly', 'daily', 'hourly', 'minutely', - * 'secondly' - */ - granularity: Granularity; - /** - * Custom Interval is used to set non-standard time interval, for example, if the series is 5 - * minutes, request can be set as {"granularity":"minutely", "customInterval":5}. - */ +/** The request of entire or last anomaly detection. */ +export interface DetectRequest { + /** Time series data points. Points should be sorted by timestamp in ascending order to match the anomaly detection result. If the data is not sorted correctly or there is duplicated timestamp, the API will not work. In such case, an error message will be returned. */ + series: TimeSeriesPoint[]; + /** 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 series point can be absent. */ + granularity?: TimeGranularity; + /** Custom Interval is used to set non-standard time interval, for example, if the series is 5 minutes, request can be set as {"granularity":"minutely", "customInterval":5}. */ 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. - */ + /** Optional argument, periodic value of a time series. If the value is null or does not present, the API will determine the period automatically. */ period?: number; - /** - * Optional argument, advanced model parameter, max anomaly ratio in a time series. - */ + /** Optional argument, advanced model parameter, max 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 accepted. - */ + /** Optional argument, advanced model parameter, between 0-99, the lower the value is, the larger the margin value will be which means less anomalies will be accepted. */ sensitivity?: number; + /** Used to specify how to deal with missing values in the input series, it's used when granularity is not "none". */ + imputeMode?: ImputeMode; + /** Used to specify the value to fill, it's used when granularity is not "none" and imputeMode is "fixed". */ + imputeFixedValue?: number; } -/** - * An interface representing EntireDetectResponse. - */ +/** The definition of input timeseries points. */ +export interface TimeSeriesPoint { + /** Optional argument, timestamp of a data point (ISO8601 format). */ + timestamp?: Date; + /** The measurement of that point, should be float. */ + value: number; +} + +/** The response of entire anomaly detection. */ export interface EntireDetectResponse { - /** - * Frequency extracted from the series, zero means no recurrent pattern has been found. - */ + /** 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 array is - * consistent with the input series. - */ + /** ExpectedValues contain 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 - * consistent with the input series. - */ + /** UpperMargins contain upper margin of each input point. UpperMargin is used to calculate upperBoundary, which equals to expectedValue + (100 - marginScale)*upperMargin. Anomalies in response can be filtered by upperBoundary and lowerBoundary. By adjusting marginScale value, less significant anomalies can be filtered in client side. The index of the array is consistent with the input series. */ upperMargins: number[]; - /** - * LowerMargins contain lower margin of each input point. LowerMargin is used to calculate - * lowerBoundary, which equals to expectedValue - (100 - marginScale)*lowerMargin. Points between - * the boundary can be marked as normal ones in client side. The index of the array is consistent - * with the input series. - */ + /** LowerMargins contain lower margin of each input point. LowerMargin is used to calculate lowerBoundary, which equals to expectedValue - (100 - marginScale)*lowerMargin. Points between the boundary can be marked as normal ones in client side. The index of the array is consistent with the input series. */ 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 is consistent with the input - * series. - */ + /** IsAnomaly contains anomaly properties for each input point. True means an anomaly either negative or positive has been detected. The index of the array is consistent with the input series. */ isAnomaly: boolean[]; - /** - * IsNegativeAnomaly contains anomaly status in negative direction for each input point. True - * means a negative anomaly has been detected. A negative anomaly means the point is detected as - * an anomaly and its real value is smaller than the expected one. The index of the array is - * consistent with the input series. - */ + /** IsNegativeAnomaly contains anomaly status in negative direction for each input point. True means a negative anomaly has been detected. A negative anomaly means the point is detected as an anomaly and its real value is smaller than the expected one. The index of the array is consistent with the input series. */ isNegativeAnomaly: boolean[]; - /** - * IsPositiveAnomaly contain anomaly status in positive direction for each input point. True - * means a positive anomaly has been detected. A positive anomaly means the point is detected as - * an anomaly and its real value is larger than the expected one. The index of the array is - * consistent with the input series. - */ + /** IsPositiveAnomaly contain anomaly status in positive direction for each input point. True means a positive anomaly has been detected. A positive anomaly means the point is detected as an anomaly and its real value is larger than the expected one. The index of the array is consistent with the input series. */ 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?: number[]; } -/** - * An interface representing LastDetectResponse. - */ +/** Error information returned by the API. */ +export interface AnomalyDetectorError { + /** The error code. */ + code?: AnomalyDetectorErrorCodes; + /** A message explaining the error reported by the service. */ + message?: string; +} + +/** The response of last anomaly detection. */ export interface LastDetectResponse { - /** - * Frequency extracted from the series, zero means no recurrent pattern has been found. - */ + /** Frequency extracted from the series, zero means no recurrent pattern has been found. */ period: number; - /** - * Suggested input series points needed for detecting the latest point. - */ + /** Suggested input series points needed for detecting the latest point. */ suggestedWindow: number; - /** - * Expected value of the latest point. - */ + /** Expected value of the latest point. */ expectedValue: number; - /** - * Upper margin of the latest point. UpperMargin is used to calculate upperBoundary, which equals - * to expectedValue + (100 - marginScale)*upperMargin. If the value of latest point is between - * upperBoundary and lowerBoundary, it should be treated as normal value. By adjusting - * marginScale value, anomaly status of latest point can be changed. - */ + /** Upper margin of the latest point. UpperMargin is used to calculate upperBoundary, which equals to expectedValue + (100 - marginScale)*upperMargin. If the value of latest point is between upperBoundary and lowerBoundary, it should be treated as normal value. By adjusting marginScale value, anomaly status of latest point can be changed. */ upperMargin: number; - /** - * Lower margin of the latest point. LowerMargin is used to calculate lowerBoundary, which equals - * to expectedValue - (100 - marginScale)*lowerMargin. - */ + /** Lower margin of the latest point. LowerMargin is used to calculate lowerBoundary, which equals 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 negative direction or positive direction. */ isAnomaly: boolean; - /** - * Anomaly status in negative direction of the latest point. True means the latest point is an - * anomaly and its real value is smaller than the expected one. - */ + /** Anomaly status in negative direction of the latest point. True means the latest point is an anomaly and its real value is smaller than the expected one. */ isNegativeAnomaly: boolean; - /** - * Anomaly status in positive direction of the latest point. True means the latest point is an - * anomaly and its real value is larger than the expected one. - */ + /** Anomaly status in positive direction of the latest point. True means the latest point is an anomaly and its real value is larger than the expected one. */ 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?: number; } -/** - * An interface representing ChangePointDetectRequest. - */ +/** The request of change point detection. */ export interface ChangePointDetectRequest { - /** - * Time series data points. Points should be sorted by timestamp in ascending order to match the - * change point detection result. - */ - series: Point[]; - /** - * Can only be one of yearly, monthly, weekly, daily, hourly, minutely or secondly. Granularity - * is used for verify whether input series is valid. Possible values include: 'yearly', - * 'monthly', 'weekly', 'daily', 'hourly', 'minutely', 'secondly' - */ - granularity: Granularity; - /** - * Custom Interval is used to set non-standard time interval, for example, if the series is 5 - * minutes, request can be set as {"granularity":"minutely", "customInterval":5}. - */ + /** Time series data points. Points should be sorted by timestamp in ascending order to match the change point detection result. */ + series: TimeSeriesPoint[]; + /** Can only be one of yearly, monthly, weekly, daily, hourly, minutely or secondly. Granularity is used for verify whether input series is valid. */ + granularity: TimeGranularity; + /** Custom Interval is used to set non-standard time interval, for example, if the series is 5 minutes, request can be set as {"granularity":"minutely", "customInterval":5}. */ 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. - */ + /** Optional argument, periodic value of a time series. If the value is null or does not present, the API will determine the period automatically. */ period?: number; - /** - * Optional argument, advanced model parameter, a default stableTrendWindow will be used in - * detection. - */ + /** Optional argument, advanced model parameter, a default stableTrendWindow 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 be accepted. - */ + /** Optional argument, advanced model parameter, between 0.0-1.0, the lower the value is, the larger the trend error will be which means less change point will be accepted. */ threshold?: number; } -/** - * An interface representing ChangePointDetectResponse. - */ +/** The response of change point detection. */ export interface ChangePointDetectResponse { /** * Frequency extracted from the series, zero means no recurrent pattern has been found. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - 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 array is consistent with the - * input series. - */ - isChangePoint: boolean[]; - /** - * the change point confidence of each point - */ - confidenceScores: number[]; + 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 array is consistent with the input series. */ + isChangePoint?: boolean[]; + /** the change point confidence of each point */ + confidenceScores?: number[]; +} + +/** Train result of a model including status, errors and diagnose info for model and variables. */ +export interface ModelInfo { + /** An optional field, indicating how many previous points will be used to compute the anomaly score of the subsequent point. */ + slidingWindow?: number; + alignPolicy?: AlignPolicy; + /** Source link to the input variables. Each variable should be a csv file with two columns, `timestamp` and `value`. By default, the file name of the variable will be used as its variable name. */ + source: string; + /** A required field, indicating the start time of training data. Should be date-time. */ + startTime: Date; + /** A required field, indicating the end time of training data. Should be date-time. */ + endTime: Date; + /** An optional field. The name of the model whose maximum length is 24. */ + displayName?: string; + /** + * Model training status. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly status?: ModelStatus; + /** + * Error messages when failed to create a model. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly errors?: ErrorResponse[]; + /** NOTE: This property will not be serialized. It can only be populated by the server. */ + readonly diagnosticsInfo?: DiagnosticsInfo; +} + +export interface AlignPolicy { + /** An optional field, indicating how we align different variables to the same time-range. Either Inner or Outer. */ + alignMode?: AlignMode; + /** An optional field, indicating how missing values will be filled. One of Previous, Subsequent, Linear, Zero, Fixed, and NotFill. Cannot be set to NotFill, when the alignMode is Outer. */ + fillNAMethod?: FillNAMethod; + /** An optional field. Required when fillNAMethod is Fixed. */ + paddingValue?: number; +} + +export interface ErrorResponse { + /** The error code. */ + code: string; + /** The message explaining the error reported by the service. */ + message: string; +} + +export interface DiagnosticsInfo { + modelState?: ModelState; + variableStates?: VariableState[]; +} + +export interface ModelState { + /** Epoch id */ + epochIds?: number[]; + trainLosses?: number[]; + validationLosses?: number[]; + latenciesInSeconds?: number[]; +} + +export interface VariableState { + /** Variable name. */ + variable?: string; + /** Proportion of NaN values filled of the variable. */ + filledNARatio?: number; + /** Number of effective points counted. */ + effectiveCount?: number; + /** Start time of the variable. */ + startTime?: Date; + /** End time of the variable. */ + endTime?: Date; +} + +/** Response of listing models. */ +export interface ModelList { + /** List of models */ + models: ModelSnapshot[]; + /** Current count of trained multivariate models. */ + currentCount: number; + /** Max number of models that can be trained for this subscription. */ + maxCount: number; + /** The link to fetch more models. */ + nextLink?: string; +} + +export interface ModelSnapshot { + /** Model identifier. */ + modelId: string; + /** Date and time (UTC) when the model was created. */ + createdTime: Date; + /** Date and time (UTC) when the model was last updated. */ + lastUpdatedTime: Date; + /** + * Model training status. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly status: ModelStatus; + displayName?: string; + /** Total number of variables. */ + variablesCount: number; +} + +/** Response of getting a model. */ +export interface Model { + /** Model identifier. */ + modelId: string; + /** Date and time (UTC) when the model was created. */ + createdTime: Date; + /** Date and time (UTC) when the model was last updated. */ + lastUpdatedTime: Date; + /** Train result of a model including status, errors and diagnose info for model and variables. */ + modelInfo?: ModelInfo; +} + +/** Detection request. */ +export interface DetectionRequest { + /** Source link to the input variables. Each variable should be a csv with two columns, `timestamp` and `value`. The file name of the variable will be used as its name. The variables used in detection should be exactly the same with those used in the training phase. */ + source: string; + /** A required field, indicating the start time of data for detection. Should be date-time. */ + startTime: Date; + /** A required field, indicating the end time of data for detection. Should be date-time. */ + endTime: Date; +} + +/** Response of the given resultId. */ +export interface DetectionResult { + resultId: string; + summary: DetectionResultSummary; + /** Detection result for each timestamp. */ + results: AnomalyState[]; +} + +export interface DetectionResultSummary { + /** Status of detection results. One of CREATED, RUNNING, READY, and FAILED. */ + status: DetectionStatus; + /** Error message when detection is failed. */ + errors?: ErrorResponse[]; + variableStates?: VariableState[]; + /** Detection request. */ + setupInfo: DetectionRequest; +} + +export interface AnomalyState { + /** timestamp */ + timestamp: Date; + value?: AnomalyValue; + /** Error message for the current timestamp */ + errors?: ErrorResponse[]; +} + +export interface AnomalyValue { + /** True if an anomaly is detected at the current timestamp. */ + isAnomaly: boolean; + /** Indicates the significance of the anomaly. The higher the severity, the more significant the anomaly. */ + severity: number; + /** Raw score from the model. */ + score: number; + interpretation?: AnomalyInterpretation[]; +} + +export interface AnomalyInterpretation { + variable?: string; + contributionScore?: number; + correlationChanges?: CorrelationChanges; +} + +export interface CorrelationChanges { + /** correlated variables */ + changedVariables?: string[]; + /** changes in correlation */ + changedValues?: number[]; +} + +export interface LastDetectionRequest { + /** variables */ + variables: VariableValues[]; + /** number of timestamps on which the model detects */ + detectingPoints: number; +} + +export interface VariableValues { + /** variable name */ + name: string; + /** timestamps */ + timestamps: string[]; + /** values */ + values: number[]; +} + +export interface LastDetectionResult { + variableStates?: VariableState[]; + results?: AnomalyState[]; +} + +/** Defines headers for AnomalyDetectorClient_detectEntireSeries operation. */ +export interface AnomalyDetectorClientDetectEntireSeriesExceptionHeaders { + /** error code */ + xMsErrorCode?: string; +} + +/** Defines headers for AnomalyDetectorClient_detectLastPoint operation. */ +export interface AnomalyDetectorClientDetectLastPointExceptionHeaders { + /** error code */ + xMsErrorCode?: string; +} + +/** Defines headers for AnomalyDetectorClient_detectChangePoint operation. */ +export interface AnomalyDetectorClientDetectChangePointExceptionHeaders { + /** error code */ + xMsErrorCode?: string; +} + +/** Defines headers for AnomalyDetectorClient_trainMultivariateModel operation. */ +export interface AnomalyDetectorClientTrainMultivariateModelHeaders { + /** Location and ID of the model. */ + location?: string; +} + +/** Defines headers for AnomalyDetectorClient_trainMultivariateModel operation. */ +export interface AnomalyDetectorClientTrainMultivariateModelExceptionHeaders { + /** error code */ + xMsErrorCode?: string; +} + +/** Defines headers for AnomalyDetectorClient_listMultivariateModel operation. */ +export interface AnomalyDetectorClientListMultivariateModelExceptionHeaders { + /** error code */ + xMsErrorCode?: string; +} + +/** Defines headers for AnomalyDetectorClient_getMultivariateModel operation. */ +export interface AnomalyDetectorClientGetMultivariateModelExceptionHeaders { + /** error code */ + xMsErrorCode?: string; +} + +/** Defines headers for AnomalyDetectorClient_deleteMultivariateModel operation. */ +export interface AnomalyDetectorClientDeleteMultivariateModelExceptionHeaders { + /** error code */ + xMsErrorCode?: string; +} + +/** Defines headers for AnomalyDetectorClient_detectAnomaly operation. */ +export interface AnomalyDetectorClientDetectAnomalyHeaders { + /** Location and ID of the detection result. */ + location?: string; +} + +/** Defines headers for AnomalyDetectorClient_detectAnomaly operation. */ +export interface AnomalyDetectorClientDetectAnomalyExceptionHeaders { + /** error code */ + xMsErrorCode?: string; +} + +/** Defines headers for AnomalyDetectorClient_getDetectionResult operation. */ +export interface AnomalyDetectorClientGetDetectionResultExceptionHeaders { + /** error code */ + xMsErrorCode?: string; +} + +/** Defines headers for AnomalyDetectorClient_exportModel operation. */ +export interface AnomalyDetectorClientExportModelExceptionHeaders { + /** error code */ + xMsErrorCode?: string; +} + +/** Defines headers for AnomalyDetectorClient_lastDetectAnomaly operation. */ +export interface AnomalyDetectorClientLastDetectAnomalyExceptionHeaders { + /** error code */ + xMsErrorCode?: string; +} + +/** Defines headers for AnomalyDetectorClient_listMultivariateModelNext operation. */ +export interface AnomalyDetectorClientListMultivariateModelNextExceptionHeaders { + /** error code */ + xMsErrorCode?: string; +} + +/** Known values of {@link ImputeMode} that the service accepts. */ +export enum KnownImputeMode { + Auto = "auto", + Previous = "previous", + Linear = "linear", + Fixed = "fixed", + Zero = "zero", + NotFill = "notFill" } /** - * Defines values for Granularity. - * Possible values include: 'yearly', 'monthly', 'weekly', 'daily', 'hourly', 'minutely', - * 'secondly' - * @readonly - * @enum {string} + * Defines values for ImputeMode. \ + * {@link KnownImputeMode} can be used interchangeably with ImputeMode, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **auto** \ + * **previous** \ + * **linear** \ + * **fixed** \ + * **zero** \ + * **notFill** */ -export type Granularity = 'yearly' | 'monthly' | 'weekly' | 'daily' | 'hourly' | 'minutely' | 'secondly'; +export type ImputeMode = string; + +/** Known values of {@link AnomalyDetectorErrorCodes} that the service accepts. */ +export enum KnownAnomalyDetectorErrorCodes { + InvalidCustomInterval = "InvalidCustomInterval", + BadArgument = "BadArgument", + InvalidGranularity = "InvalidGranularity", + InvalidPeriod = "InvalidPeriod", + InvalidModelArgument = "InvalidModelArgument", + InvalidSeries = "InvalidSeries", + InvalidJsonFormat = "InvalidJsonFormat", + RequiredGranularity = "RequiredGranularity", + RequiredSeries = "RequiredSeries", + InvalidImputeMode = "InvalidImputeMode", + InvalidImputeFixedValue = "InvalidImputeFixedValue" +} /** - * Contains response data for the entireDetect operation. + * Defines values for AnomalyDetectorErrorCodes. \ + * {@link KnownAnomalyDetectorErrorCodes} can be used interchangeably with AnomalyDetectorErrorCodes, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **InvalidCustomInterval** \ + * **BadArgument** \ + * **InvalidGranularity** \ + * **InvalidPeriod** \ + * **InvalidModelArgument** \ + * **InvalidSeries** \ + * **InvalidJsonFormat** \ + * **RequiredGranularity** \ + * **RequiredSeries** \ + * **InvalidImputeMode** \ + * **InvalidImputeFixedValue** */ -export type EntireDetectResponse2 = EntireDetectResponse & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: EntireDetectResponse; - }; -}; +export type AnomalyDetectorErrorCodes = string; + +/** Known values of {@link FillNAMethod} that the service accepts. */ +export enum KnownFillNAMethod { + Previous = "Previous", + Subsequent = "Subsequent", + Linear = "Linear", + Zero = "Zero", + Fixed = "Fixed", + NotFill = "NotFill" +} /** - * Contains response data for the lastDetect operation. + * Defines values for FillNAMethod. \ + * {@link KnownFillNAMethod} can be used interchangeably with FillNAMethod, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Previous** \ + * **Subsequent** \ + * **Linear** \ + * **Zero** \ + * **Fixed** \ + * **NotFill** */ -export type LastDetectResponse2 = LastDetectResponse & { +export type FillNAMethod = string; +/** Defines values for TimeGranularity. */ +export type TimeGranularity = + | "yearly" + | "monthly" + | "weekly" + | "daily" + | "hourly" + | "minutely" + | "secondly" + | "microsecond" + | "none"; +/** Defines values for AlignMode. */ +export type AlignMode = "Inner" | "Outer"; +/** Defines values for ModelStatus. */ +export type ModelStatus = "CREATED" | "RUNNING" | "READY" | "FAILED"; +/** Defines values for DetectionStatus. */ +export type DetectionStatus = "CREATED" | "RUNNING" | "READY" | "FAILED"; + +/** Optional parameters. */ +export interface DetectEntireSeriesOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the detectEntireSeries operation. */ +export type DetectEntireSeriesResponse = EntireDetectResponse; + +/** Optional parameters. */ +export interface DetectLastPointOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the detectLastPoint operation. */ +export type DetectLastPointResponse = LastDetectResponse; + +/** Optional parameters. */ +export interface DetectChangePointOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the detectChangePoint operation. */ +export type DetectChangePointResponse = ChangePointDetectResponse; + +/** Optional parameters. */ +export interface TrainMultivariateModelOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the trainMultivariateModel operation. */ +export type TrainMultivariateModelResponse = AnomalyDetectorClientTrainMultivariateModelHeaders; + +/** Optional parameters. */ +export interface ListMultivariateModelOptionalParams + extends coreClient.OperationOptions { + /** $skip indicates how many models will be skipped. */ + skip?: number; + /** $top indicates how many models will be fetched. */ + top?: number; +} + +/** Contains response data for the listMultivariateModel operation. */ +export type ListMultivariateModelResponse = ModelList; + +/** Optional parameters. */ +export interface GetMultivariateModelOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the getMultivariateModel operation. */ +export type GetMultivariateModelResponse = Model; + +/** Optional parameters. */ +export interface DeleteMultivariateModelOptionalParams + extends coreClient.OperationOptions {} + +/** Optional parameters. */ +export interface DetectAnomalyOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the detectAnomaly operation. */ +export type DetectAnomalyResponse = AnomalyDetectorClientDetectAnomalyHeaders; + +/** Optional parameters. */ +export interface GetDetectionResultOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the getDetectionResult operation. */ +export type GetDetectionResultResponse = DetectionResult; + +/** Optional parameters. */ +export interface ExportModelOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the exportModel operation. */ +export type ExportModelResponse = { /** - * The underlying HTTP response. + * BROWSER ONLY + * + * The response body as a browser Blob. + * Always `undefined` in node.js. */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: LastDetectResponse; - }; -}; - -/** - * Contains response data for the changePointDetect operation. - */ -export type ChangePointDetectResponse2 = ChangePointDetectResponse & { + blobBody?: Promise; /** - * The underlying HTTP response. + * NODEJS ONLY + * + * The response body as a node.js Readable stream. + * Always `undefined` in the browser. */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ChangePointDetectResponse; - }; + readableStreamBody?: NodeJS.ReadableStream; }; + +/** Optional parameters. */ +export interface LastDetectAnomalyOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the lastDetectAnomaly operation. */ +export type LastDetectAnomalyResponse = LastDetectionResult; + +/** Optional parameters. */ +export interface ListMultivariateModelNextOptionalParams + extends coreClient.OperationOptions { + /** $skip indicates how many models will be skipped. */ + skip?: number; + /** $top indicates how many models will be fetched. */ + top?: number; +} + +/** Contains response data for the listMultivariateModelNext operation. */ +export type ListMultivariateModelNextResponse = ModelList; + +/** Optional parameters. */ +export interface AnomalyDetectorClientOptionalParams + extends coreClient.ServiceClientOptions { + /** Anomaly Detector API version (for example, v1.0). */ + apiVersion?: string; + /** Overrides client endpoint. */ + endpoint?: string; +} diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/models/mappers.ts b/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/models/mappers.ts index 4b01013f1d28..f9b53660d803 100644 --- a/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/models/mappers.ts +++ b/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/models/mappers.ts @@ -1,82 +1,32 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import * as msRest from "@azure/ms-rest-js"; +import * as coreClient from "@azure/core-client"; - -export const APIError: msRest.CompositeMapper = { - serializedName: "APIError", - type: { - name: "Composite", - className: "APIError", - modelProperties: { - code: { - serializedName: "code", - type: { - name: "Object" - } - }, - message: { - serializedName: "message", - type: { - name: "String" - } - } - } - } -}; - -export const Point: msRest.CompositeMapper = { - serializedName: "Point", - type: { - name: "Composite", - className: "Point", - modelProperties: { - timestamp: { - required: true, - serializedName: "timestamp", - type: { - name: "DateTime" - } - }, - value: { - required: true, - serializedName: "value", - type: { - name: "Number" - } - } - } - } -}; - -export const Request: msRest.CompositeMapper = { - serializedName: "Request", +export const DetectRequest: coreClient.CompositeMapper = { type: { name: "Composite", - className: "Request", + className: "DetectRequest", modelProperties: { series: { - required: true, serializedName: "series", + required: true, type: { name: "Sequence", element: { type: { name: "Composite", - className: "Point" + className: "TimeSeriesPoint" } } } }, granularity: { - required: true, - nullable: false, serializedName: "granularity", type: { name: "Enum", @@ -87,7 +37,9 @@ export const Request: msRest.CompositeMapper = { "daily", "hourly", "minutely", - "secondly" + "secondly", + "microsecond", + "none" ] } }, @@ -114,27 +66,60 @@ export const Request: msRest.CompositeMapper = { type: { name: "Number" } + }, + imputeMode: { + serializedName: "imputeMode", + type: { + name: "String" + } + }, + imputeFixedValue: { + serializedName: "imputeFixedValue", + type: { + name: "Number" + } + } + } + } +}; + +export const TimeSeriesPoint: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "TimeSeriesPoint", + modelProperties: { + timestamp: { + serializedName: "timestamp", + type: { + name: "DateTime" + } + }, + value: { + serializedName: "value", + required: true, + type: { + name: "Number" + } } } } }; -export const EntireDetectResponse: msRest.CompositeMapper = { - serializedName: "EntireDetectResponse", +export const EntireDetectResponse: coreClient.CompositeMapper = { type: { name: "Composite", className: "EntireDetectResponse", modelProperties: { period: { - required: true, serializedName: "period", + required: true, type: { name: "Number" } }, expectedValues: { - required: true, serializedName: "expectedValues", + required: true, type: { name: "Sequence", element: { @@ -145,8 +130,8 @@ export const EntireDetectResponse: msRest.CompositeMapper = { } }, upperMargins: { - required: true, serializedName: "upperMargins", + required: true, type: { name: "Sequence", element: { @@ -157,8 +142,8 @@ export const EntireDetectResponse: msRest.CompositeMapper = { } }, lowerMargins: { - required: true, serializedName: "lowerMargins", + required: true, type: { name: "Sequence", element: { @@ -169,8 +154,8 @@ export const EntireDetectResponse: msRest.CompositeMapper = { } }, isAnomaly: { - required: true, serializedName: "isAnomaly", + required: true, type: { name: "Sequence", element: { @@ -181,8 +166,8 @@ export const EntireDetectResponse: msRest.CompositeMapper = { } }, isNegativeAnomaly: { - required: true, serializedName: "isNegativeAnomaly", + required: true, type: { name: "Sequence", element: { @@ -193,8 +178,8 @@ export const EntireDetectResponse: msRest.CompositeMapper = { } }, isPositiveAnomaly: { - required: true, serializedName: "isPositiveAnomaly", + required: true, type: { name: "Sequence", element: { @@ -203,100 +188,135 @@ export const EntireDetectResponse: msRest.CompositeMapper = { } } } + }, + severity: { + serializedName: "severity", + type: { + name: "Sequence", + element: { + type: { + name: "Number" + } + } + } + } + } + } +}; + +export const AnomalyDetectorError: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorError", + modelProperties: { + code: { + serializedName: "code", + type: { + name: "String" + } + }, + message: { + serializedName: "message", + type: { + name: "String" + } } } } }; -export const LastDetectResponse: msRest.CompositeMapper = { - serializedName: "LastDetectResponse", +export const LastDetectResponse: coreClient.CompositeMapper = { type: { name: "Composite", className: "LastDetectResponse", modelProperties: { period: { - required: true, serializedName: "period", + required: true, type: { name: "Number" } }, suggestedWindow: { - required: true, serializedName: "suggestedWindow", + required: true, type: { name: "Number" } }, expectedValue: { - required: true, serializedName: "expectedValue", + required: true, type: { name: "Number" } }, upperMargin: { - required: true, serializedName: "upperMargin", + required: true, type: { name: "Number" } }, lowerMargin: { - required: true, serializedName: "lowerMargin", + required: true, type: { name: "Number" } }, isAnomaly: { - required: true, serializedName: "isAnomaly", + required: true, type: { name: "Boolean" } }, isNegativeAnomaly: { - required: true, serializedName: "isNegativeAnomaly", + required: true, type: { name: "Boolean" } }, isPositiveAnomaly: { - required: true, serializedName: "isPositiveAnomaly", + required: true, type: { name: "Boolean" } + }, + severity: { + serializedName: "severity", + type: { + name: "Number" + } } } } }; -export const ChangePointDetectRequest: msRest.CompositeMapper = { - serializedName: "ChangePointDetectRequest", +export const ChangePointDetectRequest: coreClient.CompositeMapper = { type: { name: "Composite", className: "ChangePointDetectRequest", modelProperties: { series: { - required: true, serializedName: "series", + required: true, type: { name: "Sequence", element: { type: { name: "Composite", - className: "Point" + className: "TimeSeriesPoint" } } } }, granularity: { - required: true, - nullable: false, serializedName: "granularity", + required: true, type: { name: "Enum", allowedValues: [ @@ -306,7 +326,9 @@ export const ChangePointDetectRequest: msRest.CompositeMapper = { "daily", "hourly", "minutely", - "secondly" + "secondly", + "microsecond", + "none" ] } }, @@ -338,21 +360,19 @@ export const ChangePointDetectRequest: msRest.CompositeMapper = { } }; -export const ChangePointDetectResponse: msRest.CompositeMapper = { - serializedName: "ChangePointDetectResponse", +export const ChangePointDetectResponse: coreClient.CompositeMapper = { type: { name: "Composite", className: "ChangePointDetectResponse", modelProperties: { period: { - required: true, serializedName: "period", + readOnly: true, type: { name: "Number" } }, isChangePoint: { - required: true, serializedName: "isChangePoint", type: { name: "Sequence", @@ -364,7 +384,6 @@ export const ChangePointDetectResponse: msRest.CompositeMapper = { } }, confidenceScores: { - required: true, serializedName: "confidenceScores", type: { name: "Sequence", @@ -378,3 +397,959 @@ export const ChangePointDetectResponse: msRest.CompositeMapper = { } } }; + +export const ModelInfo: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ModelInfo", + modelProperties: { + slidingWindow: { + serializedName: "slidingWindow", + type: { + name: "Number" + } + }, + alignPolicy: { + serializedName: "alignPolicy", + type: { + name: "Composite", + className: "AlignPolicy" + } + }, + source: { + serializedName: "source", + required: true, + type: { + name: "String" + } + }, + startTime: { + serializedName: "startTime", + required: true, + type: { + name: "DateTime" + } + }, + endTime: { + serializedName: "endTime", + required: true, + type: { + name: "DateTime" + } + }, + displayName: { + constraints: { + MaxLength: 24 + }, + serializedName: "displayName", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + readOnly: true, + type: { + name: "Enum", + allowedValues: ["CREATED", "RUNNING", "READY", "FAILED"] + } + }, + errors: { + serializedName: "errors", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorResponse" + } + } + } + }, + diagnosticsInfo: { + serializedName: "diagnosticsInfo", + type: { + name: "Composite", + className: "DiagnosticsInfo" + } + } + } + } +}; + +export const AlignPolicy: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AlignPolicy", + modelProperties: { + alignMode: { + serializedName: "alignMode", + type: { + name: "Enum", + allowedValues: ["Inner", "Outer"] + } + }, + fillNAMethod: { + serializedName: "fillNAMethod", + type: { + name: "String" + } + }, + paddingValue: { + serializedName: "paddingValue", + type: { + name: "Number" + } + } + } + } +}; + +export const ErrorResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + code: { + serializedName: "code", + required: true, + type: { + name: "String" + } + }, + message: { + serializedName: "message", + required: true, + type: { + name: "String" + } + } + } + } +}; + +export const DiagnosticsInfo: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "DiagnosticsInfo", + modelProperties: { + modelState: { + serializedName: "modelState", + type: { + name: "Composite", + className: "ModelState" + } + }, + variableStates: { + serializedName: "variableStates", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "VariableState" + } + } + } + } + } + } +}; + +export const ModelState: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ModelState", + modelProperties: { + epochIds: { + serializedName: "epochIds", + type: { + name: "Sequence", + element: { + type: { + name: "Number" + } + } + } + }, + trainLosses: { + serializedName: "trainLosses", + type: { + name: "Sequence", + element: { + type: { + name: "Number" + } + } + } + }, + validationLosses: { + serializedName: "validationLosses", + type: { + name: "Sequence", + element: { + type: { + name: "Number" + } + } + } + }, + latenciesInSeconds: { + serializedName: "latenciesInSeconds", + type: { + name: "Sequence", + element: { + type: { + name: "Number" + } + } + } + } + } + } +}; + +export const VariableState: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "VariableState", + modelProperties: { + variable: { + serializedName: "variable", + type: { + name: "String" + } + }, + filledNARatio: { + constraints: { + InclusiveMaximum: 1, + InclusiveMinimum: 0 + }, + serializedName: "filledNARatio", + type: { + name: "Number" + } + }, + effectiveCount: { + serializedName: "effectiveCount", + type: { + name: "Number" + } + }, + startTime: { + serializedName: "startTime", + type: { + name: "DateTime" + } + }, + endTime: { + serializedName: "endTime", + type: { + name: "DateTime" + } + } + } + } +}; + +export const ModelList: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ModelList", + modelProperties: { + models: { + serializedName: "models", + required: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ModelSnapshot" + } + } + } + }, + currentCount: { + serializedName: "currentCount", + required: true, + type: { + name: "Number" + } + }, + maxCount: { + serializedName: "maxCount", + required: true, + type: { + name: "Number" + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const ModelSnapshot: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ModelSnapshot", + modelProperties: { + modelId: { + serializedName: "modelId", + required: true, + type: { + name: "Uuid" + } + }, + createdTime: { + serializedName: "createdTime", + required: true, + type: { + name: "DateTime" + } + }, + lastUpdatedTime: { + serializedName: "lastUpdatedTime", + required: true, + type: { + name: "DateTime" + } + }, + status: { + serializedName: "status", + required: true, + readOnly: true, + type: { + name: "Enum", + allowedValues: ["CREATED", "RUNNING", "READY", "FAILED"] + } + }, + displayName: { + serializedName: "displayName", + type: { + name: "String" + } + }, + variablesCount: { + serializedName: "variablesCount", + required: true, + type: { + name: "Number" + } + } + } + } +}; + +export const Model: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Model", + modelProperties: { + modelId: { + serializedName: "modelId", + required: true, + type: { + name: "Uuid" + } + }, + createdTime: { + serializedName: "createdTime", + required: true, + type: { + name: "DateTime" + } + }, + lastUpdatedTime: { + serializedName: "lastUpdatedTime", + required: true, + type: { + name: "DateTime" + } + }, + modelInfo: { + serializedName: "modelInfo", + type: { + name: "Composite", + className: "ModelInfo" + } + } + } + } +}; + +export const DetectionRequest: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "DetectionRequest", + modelProperties: { + source: { + serializedName: "source", + required: true, + type: { + name: "String" + } + }, + startTime: { + serializedName: "startTime", + required: true, + type: { + name: "DateTime" + } + }, + endTime: { + serializedName: "endTime", + required: true, + type: { + name: "DateTime" + } + } + } + } +}; + +export const DetectionResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "DetectionResult", + modelProperties: { + resultId: { + serializedName: "resultId", + required: true, + type: { + name: "Uuid" + } + }, + summary: { + serializedName: "summary", + type: { + name: "Composite", + className: "DetectionResultSummary" + } + }, + results: { + serializedName: "results", + required: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "AnomalyState" + } + } + } + } + } + } +}; + +export const DetectionResultSummary: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "DetectionResultSummary", + modelProperties: { + status: { + serializedName: "status", + required: true, + type: { + name: "Enum", + allowedValues: ["CREATED", "RUNNING", "READY", "FAILED"] + } + }, + errors: { + serializedName: "errors", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorResponse" + } + } + } + }, + variableStates: { + serializedName: "variableStates", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "VariableState" + } + } + } + }, + setupInfo: { + serializedName: "setupInfo", + type: { + name: "Composite", + className: "DetectionRequest" + } + } + } + } +}; + +export const AnomalyState: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyState", + modelProperties: { + timestamp: { + serializedName: "timestamp", + required: true, + type: { + name: "DateTime" + } + }, + value: { + serializedName: "value", + type: { + name: "Composite", + className: "AnomalyValue" + } + }, + errors: { + serializedName: "errors", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorResponse" + } + } + } + } + } + } +}; + +export const AnomalyValue: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyValue", + modelProperties: { + isAnomaly: { + serializedName: "isAnomaly", + required: true, + type: { + name: "Boolean" + } + }, + severity: { + constraints: { + InclusiveMaximum: 1, + InclusiveMinimum: 0 + }, + serializedName: "severity", + required: true, + type: { + name: "Number" + } + }, + score: { + constraints: { + InclusiveMaximum: 2, + InclusiveMinimum: 0 + }, + serializedName: "score", + required: true, + type: { + name: "Number" + } + }, + interpretation: { + serializedName: "interpretation", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "AnomalyInterpretation" + } + } + } + } + } + } +}; + +export const AnomalyInterpretation: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyInterpretation", + modelProperties: { + variable: { + serializedName: "variable", + type: { + name: "String" + } + }, + contributionScore: { + serializedName: "contributionScore", + type: { + name: "Number" + } + }, + correlationChanges: { + serializedName: "correlationChanges", + type: { + name: "Composite", + className: "CorrelationChanges" + } + } + } + } +}; + +export const CorrelationChanges: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CorrelationChanges", + modelProperties: { + changedVariables: { + serializedName: "changedVariables", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + changedValues: { + serializedName: "changedValues", + type: { + name: "Sequence", + element: { + type: { + name: "Number" + } + } + } + } + } + } +}; + +export const LastDetectionRequest: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "LastDetectionRequest", + modelProperties: { + variables: { + serializedName: "variables", + required: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "VariableValues" + } + } + } + }, + detectingPoints: { + serializedName: "detectingPoints", + required: true, + type: { + name: "Number" + } + } + } + } +}; + +export const VariableValues: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "VariableValues", + modelProperties: { + name: { + serializedName: "name", + required: true, + type: { + name: "String" + } + }, + timestamps: { + serializedName: "timestamps", + required: true, + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + values: { + serializedName: "values", + required: true, + type: { + name: "Sequence", + element: { + type: { + name: "Number" + } + } + } + } + } + } +}; + +export const LastDetectionResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "LastDetectionResult", + modelProperties: { + variableStates: { + serializedName: "variableStates", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "VariableState" + } + } + } + }, + results: { + serializedName: "results", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "AnomalyState" + } + } + } + } + } + } +}; + +export const AnomalyDetectorClientDetectEntireSeriesExceptionHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientDetectEntireSeriesExceptionHeaders", + modelProperties: { + xMsErrorCode: { + serializedName: "x-ms-error-code", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientDetectLastPointExceptionHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientDetectLastPointExceptionHeaders", + modelProperties: { + xMsErrorCode: { + serializedName: "x-ms-error-code", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientDetectChangePointExceptionHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientDetectChangePointExceptionHeaders", + modelProperties: { + xMsErrorCode: { + serializedName: "x-ms-error-code", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientTrainMultivariateModelHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientTrainMultivariateModelHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientTrainMultivariateModelExceptionHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientTrainMultivariateModelExceptionHeaders", + modelProperties: { + xMsErrorCode: { + serializedName: "x-ms-error-code", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientListMultivariateModelExceptionHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientListMultivariateModelExceptionHeaders", + modelProperties: { + xMsErrorCode: { + serializedName: "x-ms-error-code", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientGetMultivariateModelExceptionHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientGetMultivariateModelExceptionHeaders", + modelProperties: { + xMsErrorCode: { + serializedName: "x-ms-error-code", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientDeleteMultivariateModelExceptionHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientDeleteMultivariateModelExceptionHeaders", + modelProperties: { + xMsErrorCode: { + serializedName: "x-ms-error-code", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientDetectAnomalyHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientDetectAnomalyHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientDetectAnomalyExceptionHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientDetectAnomalyExceptionHeaders", + modelProperties: { + xMsErrorCode: { + serializedName: "x-ms-error-code", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientGetDetectionResultExceptionHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientGetDetectionResultExceptionHeaders", + modelProperties: { + xMsErrorCode: { + serializedName: "x-ms-error-code", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientExportModelExceptionHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientExportModelExceptionHeaders", + modelProperties: { + xMsErrorCode: { + serializedName: "x-ms-error-code", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientLastDetectAnomalyExceptionHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientLastDetectAnomalyExceptionHeaders", + modelProperties: { + xMsErrorCode: { + serializedName: "x-ms-error-code", + type: { + name: "String" + } + } + } + } +}; + +export const AnomalyDetectorClientListMultivariateModelNextExceptionHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AnomalyDetectorClientListMultivariateModelNextExceptionHeaders", + modelProperties: { + xMsErrorCode: { + serializedName: "x-ms-error-code", + type: { + name: "String" + } + } + } + } +}; diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/models/parameters.ts b/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/models/parameters.ts index ef1746ab6352..a63f0d397f11 100644 --- a/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/models/parameters.ts +++ b/sdk/cognitiveservices/cognitiveservices-anomalydetector/src/models/parameters.ts @@ -1,21 +1,159 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import * as msRest from "@azure/ms-rest-js"; +import { + OperationParameter, + OperationURLParameter, + OperationQueryParameter +} from "@azure/core-client"; +import { + DetectRequest as DetectRequestMapper, + ChangePointDetectRequest as ChangePointDetectRequestMapper, + ModelInfo as ModelInfoMapper, + DetectionRequest as DetectionRequestMapper, + LastDetectionRequest as LastDetectionRequestMapper +} from "../models/mappers"; -export const endpoint: msRest.OperationURLParameter = { +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String" + } + } +}; + +export const body: OperationParameter = { + parameterPath: "body", + mapper: DetectRequestMapper +}; + +export const accept: OperationParameter = { + parameterPath: "accept", + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Accept", + type: { + name: "String" + } + } +}; + +export const endpoint: OperationURLParameter = { parameterPath: "endpoint", mapper: { - required: true, serializedName: "Endpoint", - defaultValue: '', + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const apiVersion: OperationURLParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "v1.1-preview.1", + isConstant: true, + serializedName: "ApiVersion", + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const body1: OperationParameter = { + parameterPath: "body", + mapper: ChangePointDetectRequestMapper +}; + +export const body2: OperationParameter = { + parameterPath: "body", + mapper: ModelInfoMapper +}; + +export const skip: OperationQueryParameter = { + parameterPath: ["options", "skip"], + mapper: { + defaultValue: 0, + serializedName: "$skip", + type: { + name: "Number" + } + } +}; + +export const top: OperationQueryParameter = { + parameterPath: ["options", "top"], + mapper: { + defaultValue: 5, + serializedName: "$top", + type: { + name: "Number" + } + } +}; + +export const modelId: OperationURLParameter = { + parameterPath: "modelId", + mapper: { + serializedName: "modelId", + required: true, + type: { + name: "Uuid" + } + } +}; + +export const body3: OperationParameter = { + parameterPath: "body", + mapper: DetectionRequestMapper +}; + +export const resultId: OperationURLParameter = { + parameterPath: "resultId", + mapper: { + serializedName: "resultId", + required: true, + type: { + name: "Uuid" + } + } +}; + +export const accept1: OperationParameter = { + parameterPath: "accept", + mapper: { + defaultValue: "application/zip, application/json", + isConstant: true, + serializedName: "Accept", + type: { + name: "String" + } + } +}; + +export const body4: OperationParameter = { + parameterPath: "body", + mapper: LastDetectionRequestMapper +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", + mapper: { + serializedName: "nextLink", + required: true, type: { name: "String" } diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/test/sampleTest.ts b/sdk/cognitiveservices/cognitiveservices-anomalydetector/test/sampleTest.ts new file mode 100644 index 000000000000..7ed89b043e1b --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-anomalydetector/test/sampleTest.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + env, + record, + RecorderEnvironmentSetup, + Recorder +} from "@azure-tools/test-recorder"; +import * as assert from "assert"; + +const recorderEnvSetup: RecorderEnvironmentSetup = { + replaceableVariables: { + 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" + }, + customizationsOnRecordings: [ + (recording: any): any => + recording.replace( + /"access_token":"[^"]*"/g, + `"access_token":"access_token"` + ) + ], + queryParametersToSkip: [] +}; + +describe("My test", () => { + let recorder: Recorder; + + beforeEach(async function() { + recorder = record(this, recorderEnvSetup); + }); + + afterEach(async function() { + await recorder.stop(); + }); + + it("sample test", async function() { + console.log("Hi, I'm a test!"); + }); +}); diff --git a/sdk/cognitiveservices/cognitiveservices-anomalydetector/tsconfig.json b/sdk/cognitiveservices/cognitiveservices-anomalydetector/tsconfig.json index 422b584abd5e..6e3251194117 100644 --- a/sdk/cognitiveservices/cognitiveservices-anomalydetector/tsconfig.json +++ b/sdk/cognitiveservices/cognitiveservices-anomalydetector/tsconfig.json @@ -3,7 +3,7 @@ "module": "es6", "moduleResolution": "node", "strict": true, - "target": "es5", + "target": "es6", "sourceMap": true, "declarationMap": true, "esModuleInterop": true, @@ -11,9 +11,9 @@ "forceConsistentCasingInFileNames": true, "lib": ["es6", "dom"], "declaration": true, - "outDir": "./esm", + "outDir": "./dist-esm", "importHelpers": true }, - "include": ["./src/**/*.ts"], + "include": ["./src/**/*.ts", "./test/**/*.ts"], "exclude": ["node_modules"] }