Skip to content

Commit ea3fc20

Browse files
authored
add multivariate anomaly detetor sample for v1.1 (Azure#23517)
### Packages impacted by this PR ### Issues associated with this PR ### Describe the problem that is addressed by this PR ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
1 parent 7c813ab commit ea3fc20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4182
-3
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 54 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/ignore-links.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ https://docs.microsoft.com/javascript/api/@azure-rest/arm-network?view=azure-nod
2929
https://docs.microsoft.com/javascript/api/@azure/arm-securitydevops?view=azure-node-preview
3030
https://docs.microsoft.com/javascript/api/@azure/arm-devhub?view=azure-node-preview
3131
https://docs.microsoft.com/javascript/api/@azure-rest/load-testing
32+
https://docs.microsoft.com/javascript/api/@azure-rest/ai-anomaly-detector?view=azure-node-preview
3233
https://docs.microsoft.com/javascript/api/@azure/arm-elasticsan?view=azure-node-preview
3334
https://docs.microsoft.com/javascript/api/@azure/arm-appcomplianceautomation?view=azure-node-preview

rush.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@
366366
"projectFolder": "sdk/anomalydetector/ai-anomaly-detector",
367367
"versionPolicyName": "client"
368368
},
369+
{
370+
"packageName": "@azure-rest/ai-anomaly-detector",
371+
"projectFolder": "sdk/anomalydetector/ai-anomaly-detector-rest",
372+
"versionPolicyName": "client"
373+
},
369374
{
370375
"packageName": "@azure/ai-form-recognizer",
371376
"projectFolder": "sdk/formrecognizer/ai-form-recognizer",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"plugins": ["@azure/azure-sdk"],
3+
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
4+
"rules": {
5+
"@azure/azure-sdk/ts-modules-only-named": "warn",
6+
"@azure/azure-sdk/ts-apiextractor-json-types": "warn",
7+
"@azure/azure-sdk/ts-package-json-types": "warn",
8+
"@azure/azure-sdk/ts-package-json-engine-is-present": "warn",
9+
"tsdoc/syntax": "warn"
10+
}
11+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022 Microsoft
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Azure AnomalyDetectorRest REST client library for JavaScript
2+
3+
AnomalyDetector Rest Client
4+
5+
**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library**
6+
7+
Key links:
8+
9+
- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/anomalydetector/ai-anomaly-detector-rest)
10+
- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/ai-anomaly-detector)
11+
- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/ai-anomaly-detector?view=azure-node-preview)
12+
- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/anomalydetector/ai-anomaly-detector-rest/samples)
13+
14+
## Getting started
15+
16+
### Currently supported environments
17+
18+
- LTS versions of Node.js
19+
20+
### Prerequisites
21+
22+
- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package.
23+
24+
### Install the `@azure-rest/ai-anomaly-detector` package
25+
26+
Install the Azure AnomalyDetectorRest REST client REST client library for JavaScript with `npm`:
27+
28+
```bash
29+
npm install @azure-rest/ai-anomaly-detector
30+
```
31+
32+
### Create and authenticate a `AnomalyDetectorRestClient`
33+
34+
To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token),
35+
provide an instance of the desired credential type obtained from the
36+
[@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library.
37+
38+
To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity)
39+
40+
After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use.
41+
As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential)
42+
can be used to authenticate the client.
43+
44+
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
45+
AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
46+
47+
## Troubleshooting
48+
49+
### Logging
50+
51+
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`:
52+
53+
```javascript
54+
const { setLogLevel } = require("@azure/logger");
55+
56+
setLogLevel("info");
57+
```
58+
59+
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).
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3+
"mainEntryPointFilePath": "./types/src/index.d.ts",
4+
"docModel": { "enabled": true },
5+
"apiReport": { "enabled": true, "reportFolder": "./review" },
6+
"dtsRollup": {
7+
"enabled": true,
8+
"untrimmedFilePath": "",
9+
"publicTrimmedFilePath": "./types/ai-anomaly-detector.d.ts"
10+
},
11+
"messages": {
12+
"tsdocMessageReporting": { "default": { "logLevel": "none" } },
13+
"extractorMessageReporting": {
14+
"ae-missing-release-tag": { "logLevel": "none" },
15+
"ae-unresolved-link": { "logLevel": "none" }
16+
}
17+
}
18+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
// https://github.com/karma-runner/karma-chrome-launcher
5+
process.env.CHROME_BIN = require("puppeteer").executablePath();
6+
require("dotenv").config();
7+
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
8+
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
9+
10+
module.exports = function(config) {
11+
config.set({
12+
// base path that will be used to resolve all patterns (eg. files, exclude)
13+
basePath: "./",
14+
15+
// frameworks to use
16+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
17+
frameworks: ["source-map-support", "mocha"],
18+
19+
plugins: [
20+
"karma-mocha",
21+
"karma-mocha-reporter",
22+
"karma-chrome-launcher",
23+
"karma-edge-launcher",
24+
"karma-firefox-launcher",
25+
"karma-ie-launcher",
26+
"karma-env-preprocessor",
27+
"karma-coverage",
28+
"karma-sourcemap-loader",
29+
"karma-junit-reporter",
30+
"karma-source-map-support"
31+
],
32+
33+
// list of files / patterns to load in the browser
34+
files: [
35+
"dist-test/index.browser.js",
36+
{
37+
pattern: "dist-test/index.browser.js.map",
38+
type: "html",
39+
included: false,
40+
served: true
41+
}
42+
],
43+
44+
// list of files / patterns to exclude
45+
exclude: [],
46+
47+
// preprocess matching files before serving them to the browser
48+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
49+
preprocessors: {
50+
"**/*.js": ["sourcemap", "env"]
51+
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
52+
// Preprocess source file to calculate code coverage, however this will make source file unreadable
53+
// "dist-test/index.js": ["coverage"]
54+
},
55+
56+
envPreprocessor: [
57+
"TEST_MODE",
58+
"ENDPOINT",
59+
"AZURE_CLIENT_SECRET",
60+
"AZURE_CLIENT_ID",
61+
"AZURE_TENANT_ID",
62+
"SUBSCRIPTION_ID"
63+
],
64+
65+
// test results reporter to use
66+
// possible values: 'dots', 'progress'
67+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
68+
reporters: ["mocha", "coverage", "junit"],
69+
70+
coverageReporter: {
71+
// specify a common output directory
72+
dir: "coverage-browser/",
73+
reporters: [
74+
{ type: "json", subdir: ".", file: "coverage.json" },
75+
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
76+
{ type: "html", subdir: "html" },
77+
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }
78+
]
79+
},
80+
81+
junitReporter: {
82+
outputDir: "", // results will be saved as $outputDir/$browserName.xml
83+
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
84+
suite: "", // suite will become the package name attribute in xml testsuite element
85+
useBrowserName: false, // add browser name to report and classes names
86+
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
87+
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
88+
properties: {} // key value pair of properties to add to the <properties> section of the report
89+
},
90+
91+
// web server port
92+
port: 9876,
93+
94+
// enable / disable colors in the output (reporters and logs)
95+
colors: true,
96+
97+
// level of logging
98+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
99+
logLevel: config.LOG_INFO,
100+
101+
// enable / disable watching file and executing tests whenever any file changes
102+
autoWatch: false,
103+
104+
// --no-sandbox allows our tests to run in Linux without having to change the system.
105+
// --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.
106+
browsers: ["ChromeHeadlessNoSandbox"],
107+
customLaunchers: {
108+
ChromeHeadlessNoSandbox: {
109+
base: "ChromeHeadless",
110+
flags: ["--no-sandbox", "--disable-web-security"]
111+
}
112+
},
113+
114+
// Continuous Integration mode
115+
// if true, Karma captures browsers, runs the tests and exits
116+
singleRun: false,
117+
118+
// Concurrency level
119+
// how many browser should be started simultaneous
120+
concurrency: 1,
121+
122+
browserNoActivityTimeout: 60000000,
123+
browserDisconnectTimeout: 10000,
124+
browserDisconnectTolerance: 3,
125+
126+
client: {
127+
mocha: {
128+
// change Karma's debug.html to the mocha web reporter
129+
reporter: "html",
130+
timeout: "600000"
131+
}
132+
}
133+
});
134+
};

0 commit comments

Comments
 (0)