diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 9fc124e43e09..46acd5f8116d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -611,6 +611,9 @@ sdk/ai/ai-projects @ganeshyb @GraceBrigham # PRLabel: %Mgmt /sdk/hybridkubernetes/arm-hybridkubernetes/ @qiaozha @MaryGao +# PRLabel: %Mgmt +/sdk/impactreporting/arm-impactreporting @qiaozha @MaryGao + # PRLabel: %Mgmt /sdk/informatica/arm-informaticadatamanagement @qiaozha @MaryGao diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 77573bfaae06..2955090f4c45 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -412,6 +412,9 @@ importers: '@rush-temp/arm-imagebuilder': specifier: file:./projects/arm-imagebuilder.tgz version: file:projects/arm-imagebuilder.tgz(@types/debug@4.1.12)(msw@2.7.2(@types/node@22.7.9)(typescript@5.7.3))(tsx@4.19.3)(vite@6.1.1(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.0))(yaml@2.7.0) + '@rush-temp/arm-impactreporting': + specifier: file:./projects/arm-impactreporting.tgz + version: file:projects/arm-impactreporting.tgz(@types/debug@4.1.12)(msw@2.7.2(@types/node@22.7.9)(typescript@5.7.3))(tsx@4.19.3)(vite@6.1.1(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.0))(yaml@2.7.0) '@rush-temp/arm-informaticadatamanagement': specifier: file:./projects/arm-informaticadatamanagement.tgz version: file:projects/arm-informaticadatamanagement.tgz(@types/debug@4.1.12)(msw@2.7.2(@types/node@22.7.9)(typescript@5.7.3))(tsx@4.19.3)(vite@6.1.1(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.0))(yaml@2.7.0) @@ -3032,6 +3035,10 @@ packages: resolution: {integrity: sha512-IP1RWGe4uVJR1CV2YiNb4GjTScDFgenPbTaM9a1USoJAUe/PQr1b+w4QxYGQvnnlIRLoA5g1ykDMndht0RuhsQ==, tarball: file:projects/arm-imagebuilder.tgz} version: 0.0.0 + '@rush-temp/arm-impactreporting@file:projects/arm-impactreporting.tgz': + resolution: {integrity: sha512-CoW/ZNsF7wxxCADBqAtGGH6l1clgUkubGPR7RZLjrWS5svhcEowq5DlvTWW7ATCyRjPajg7LMeNqPG521E0CtQ==, tarball: file:projects/arm-impactreporting.tgz} + version: 0.0.0 + '@rush-temp/arm-informaticadatamanagement@file:projects/arm-informaticadatamanagement.tgz': resolution: {integrity: sha512-VWMchjUXam3h8umFyj6oqBuvOX8cc6ypbCcYHAV58y8QO91DNV87PXzDDovGc91qOvfnLkkOshVqQs8IoiI2zw==, tarball: file:projects/arm-informaticadatamanagement.tgz} version: 0.0.0 @@ -4065,27 +4072,27 @@ packages: version: 0.0.0 '@rush-temp/synapse-access-control-1@file:projects/synapse-access-control-1.tgz': - resolution: {integrity: sha512-73sTFyBG1+Wc/9NXoX2juYwvRcyHcpR0Mlgj19spLxqJeD8ki2+kjrUE8uA/l62ZXiEahb2ZXT9XEwUsu2NGrg==, tarball: file:projects/synapse-access-control-1.tgz} + resolution: {integrity: sha512-om4Klf9wV9WpeVJnDyuoXjnhB1P/rdyEyEGhdU49mVuUS2PKFHS6dTgYqxcQhMLTE46pgB88WbznwhBbQZSteQ==, tarball: file:projects/synapse-access-control-1.tgz} version: 0.0.0 '@rush-temp/synapse-access-control@file:projects/synapse-access-control.tgz': - resolution: {integrity: sha512-Be8ArcdWpCQ2F1+qwaZYb5EbbDiUATLCOHWuTdFHayIZqjdDH5tn3VxTwFhrcizk+T7AZpFbpDmuPJNgwHkmmQ==, tarball: file:projects/synapse-access-control.tgz} + resolution: {integrity: sha512-H3nmRkUXq56ighVQQFLigcWd9xyAkWStxSPozKSOGzEPMve1mkxZDT6oVgpoXIzSR2rOBsRaxPJyT1nqYHyTsQ==, tarball: file:projects/synapse-access-control.tgz} version: 0.0.0 '@rush-temp/synapse-artifacts@file:projects/synapse-artifacts.tgz': - resolution: {integrity: sha512-yHvTLqTMdgt2suAsDrAaFOz08yMpD+4qgK3XbT0Kx+C6I4WgfKs8zCpCje2F6iBaKqf0S8QDb9Nq+NXsAQMt/Q==, tarball: file:projects/synapse-artifacts.tgz} + resolution: {integrity: sha512-kF7EQzTXhVbzg1qU2lfrOX9/fCUZXiWIaQgbyKorP43+aB7HwaPydGoxLX8xTIGr5TRwZrNQxW+d44pdcghgwg==, tarball: file:projects/synapse-artifacts.tgz} version: 0.0.0 '@rush-temp/synapse-managed-private-endpoints@file:projects/synapse-managed-private-endpoints.tgz': - resolution: {integrity: sha512-gLHDZ3gJohAWHqcIRZsEzOPEVPJ5pdDb7pWZs0G+hlruMiBlNs8SX0Kzw9d5Q2M6StQAk1VjVNpjeMxTv9aROQ==, tarball: file:projects/synapse-managed-private-endpoints.tgz} + resolution: {integrity: sha512-PI+pW+aqRHSn3El8cP0ZkhDuNAIvylcG4N8gwCODOGFwTo5qKnQsYWVCwkN69ciOm7//ugovlU+SRlHbzfA8RA==, tarball: file:projects/synapse-managed-private-endpoints.tgz} version: 0.0.0 '@rush-temp/synapse-monitoring@file:projects/synapse-monitoring.tgz': - resolution: {integrity: sha512-McFYyAZcOn/Utm9FrhTxtvICz3E0QXK0WqpC9Q8znntaA1j4Y55nBfzkmobaJCDW6ppQpXFjHpRHGeIXhTbLRQ==, tarball: file:projects/synapse-monitoring.tgz} + resolution: {integrity: sha512-6bJuu/NZHo9uOCzCnJEHnyh8dlT+wAmDikd7z2LRewKO1849MhYDtJceUb6gbpJuehfex7IAGCYn+cKSIOihOw==, tarball: file:projects/synapse-monitoring.tgz} version: 0.0.0 '@rush-temp/synapse-spark@file:projects/synapse-spark.tgz': - resolution: {integrity: sha512-qpLW3U7puI+Mkw4qk2BXPch6KokeEOpZwGgjvGLLtq4gtvRImcr4tseegeejAmewQzFWM4l3f/1l89b2zsuO2w==, tarball: file:projects/synapse-spark.tgz} + resolution: {integrity: sha512-Y5vv4MYjUliM1UMKYzCEoMf/EK7xVyh++zPjQAYxyiQmyUm3RBKH4/onVP1f/JcoA6WI1e94DTM5Y28VymvC5A==, tarball: file:projects/synapse-spark.tgz} version: 0.0.0 '@rush-temp/template-dpg@file:projects/template-dpg.tgz': @@ -14339,6 +14346,42 @@ snapshots: - webdriverio - yaml + '@rush-temp/arm-impactreporting@file:projects/arm-impactreporting.tgz(@types/debug@4.1.12)(msw@2.7.2(@types/node@22.7.9)(typescript@5.7.3))(tsx@4.19.3)(vite@6.1.1(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.0))(yaml@2.7.0)': + dependencies: + '@microsoft/api-extractor': 7.50.1(@types/node@18.19.76) + '@types/node': 18.19.76 + '@vitest/browser': 3.0.6(@types/node@18.19.76)(playwright@1.50.1)(typescript@5.6.3)(vite@6.1.1(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.0))(vitest@3.0.6) + '@vitest/coverage-istanbul': 3.0.6(vitest@3.0.6) + dotenv: 16.4.7 + eslint: 9.21.0 + playwright: 1.50.1 + tslib: 2.8.1 + typescript: 5.6.3 + vitest: 3.0.6(@types/debug@4.1.12)(@types/node@18.19.76)(@vitest/browser@3.0.6)(msw@2.7.2(@types/node@22.7.9)(typescript@5.7.3))(tsx@4.19.3)(yaml@2.7.0) + transitivePeerDependencies: + - '@edge-runtime/vm' + - '@types/debug' + - '@vitest/ui' + - bufferutil + - happy-dom + - jiti + - jsdom + - less + - lightningcss + - msw + - safaridriver + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + - tsx + - utf-8-validate + - vite + - webdriverio + - yaml + '@rush-temp/arm-informaticadatamanagement@file:projects/arm-informaticadatamanagement.tgz(@types/debug@4.1.12)(msw@2.7.2(@types/node@22.7.9)(typescript@5.7.3))(tsx@4.19.3)(vite@6.1.1(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.0))(yaml@2.7.0)': dependencies: '@azure/core-lro': 2.7.2 diff --git a/eng/ignore-links.txt b/eng/ignore-links.txt index 1bd3df16d140..5c1add0d404d 100644 --- a/eng/ignore-links.txt +++ b/eng/ignore-links.txt @@ -18,3 +18,4 @@ https://docs.microsoft.com/javascript/api/@azure/arm-terraform?view=azure-node-p https://docs.microsoft.com/javascript/api/@azure/arm-connectedcache?view=azure-node-preview https://docs.microsoft.com/javascript/api/@azure/arm-neonpostgres?view=azure-node-preview https://learn.microsoft.com/javascript/api/@azure/arm-pineconevectordb?view=azure-node-preview +https://learn.microsoft.com/javascript/api/@azure/arm-impactreporting?view=azure-node-preview diff --git a/rush.json b/rush.json index ea51b558f055..c78d3097f042 100644 --- a/rush.json +++ b/rush.json @@ -565,7 +565,9 @@ "projectFolder": "common/tools/dev-tool", "versionPolicyName": "utility", // Add Identity to decoupledLocalDependencies so that dev-tool uses the package from npm, avoiding a cyclic dependency. - "decoupledLocalDependencies": ["@azure/identity"] + "decoupledLocalDependencies": [ + "@azure/identity" + ] }, { "packageName": "@azure/eventgrid", @@ -605,7 +607,9 @@ { "packageName": "@azure/identity", "projectFolder": "sdk/identity/identity", - "decoupledLocalDependencies": ["@azure/keyvault-keys"], + "decoupledLocalDependencies": [ + "@azure/keyvault-keys" + ], "versionPolicyName": "client" }, { @@ -2318,6 +2322,11 @@ "projectFolder": "sdk/ai/ai-projects", "versionPolicyName": "client" }, + { + "packageName": "@azure/arm-impactreporting", + "projectFolder": "sdk/impactreporting/arm-impactreporting", + "versionPolicyName": "management" + }, { "packageName": "@azure/arm-pineconevectordb", "projectFolder": "sdk/pineconevectordb/arm-pineconevectordb", diff --git a/sdk/impactreporting/arm-impactreporting/CHANGELOG.md b/sdk/impactreporting/arm-impactreporting/CHANGELOG.md new file mode 100644 index 000000000000..7907d4221ae4 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 1.0.0-beta.1 (2025-02-20) + +### Features Added + +Initial release of the Azure Impact Reporting package diff --git a/sdk/impactreporting/arm-impactreporting/LICENSE b/sdk/impactreporting/arm-impactreporting/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +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. diff --git a/sdk/impactreporting/arm-impactreporting/README.md b/sdk/impactreporting/arm-impactreporting/README.md new file mode 100644 index 000000000000..e0c1ab4c2f64 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/README.md @@ -0,0 +1,115 @@ +# Azure Impact client library for JavaScript + +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure Impact client. + + + +Key links: + +- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/impactreporting/arm-impactreporting) +- [Package (NPM)](https://www.npmjs.com/package/@azure/arm-impactreporting) +- [API reference documentation](https://learn.microsoft.com/javascript/api/@azure/arm-impactreporting?view=azure-node-preview) +- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/impactreporting/arm-impactreporting/samples) + +## Getting started + +### Currently supported environments + +- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) +- Latest versions of Safari, Chrome, Edge and Firefox. + +See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. + +### Prerequisites + +- An [Azure subscription][azure_sub]. + +### Install the `@azure/arm-impactreporting` package + +Install the Azure Impact client library for JavaScript with `npm`: + +```bash +npm install @azure/arm-impactreporting +``` + +### Create and authenticate a `ImpactClient` + +To create a client object to access the Azure Impact API, you will need the `endpoint` of your Azure Impact resource and a `credential`. The Azure Impact client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure Impact resource in the [Azure Portal][azure_portal]. + +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/identity +``` + +You will also need to **register a new AAD application and grant access to Azure Impact** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). + +For more information about how to create an Azure AD Application check out [this guide](https://learn.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). + +Using Node.js and Node-like environments, you can use the `DefaultAzureCredential` class to authenticate the client. + +```ts snippet:ReadmeSampleCreateClient_Node +import { ImpactClient } from "../src/index.js"; +import { DefaultAzureCredential } from "@azure/identity"; + +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const client = new ImpactClient(new DefaultAzureCredential(), subscriptionId); +``` + +For browser environments, use the `InteractiveBrowserCredential` from the `@azure/identity` package to authenticate. + +```ts snippet:ReadmeSampleCreateClient_Browser +import { InteractiveBrowserCredential } from "@azure/identity"; +import { ImpactClient } from "../src/index.js"; + +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const credential = new InteractiveBrowserCredential({ + tenantId: "", + clientId: "", +}); +const client = new ImpactClient(credential, subscriptionId); +``` + + +### 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 + +### ImpactClient + +`ImpactClient` is the primary interface for developers using the Azure Impact client library. Explore the methods on this client object to understand the different features of the Azure Impact 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`: + +```ts snippet:SetLogLevel +import { setLogLevel } from "@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/impactreporting/arm-impactreporting/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) + +[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/impactreporting/arm-impactreporting/api-extractor.json b/sdk/impactreporting/arm-impactreporting/api-extractor.json new file mode 100644 index 000000000000..df5f9b2de86a --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/api-extractor.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "dist/esm/index.d.ts", + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "dist/arm-impactreporting.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} diff --git a/sdk/impactreporting/arm-impactreporting/assets.json b/sdk/impactreporting/arm-impactreporting/assets.json new file mode 100644 index 000000000000..a6fdeb0ca9a6 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "js", + "TagPrefix": "js/impactreporting/arm-impactreporting", + "Tag": "js/impactreporting/arm-impactreporting_44838c8b79" +} diff --git a/sdk/impactreporting/arm-impactreporting/eslint.config.mjs b/sdk/impactreporting/arm-impactreporting/eslint.config.mjs new file mode 100644 index 000000000000..a9fcfbef11ff --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/eslint.config.mjs @@ -0,0 +1,16 @@ +import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; + +export default azsdkEslint.config([ + { + rules: { + "@azure/azure-sdk/ts-modules-only-named": "warn", + "@azure/azure-sdk/ts-apiextractor-json-types": "warn", + "@azure/azure-sdk/ts-package-json-types": "warn", + "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", + "@azure/azure-sdk/ts-package-json-module": "off", + "@azure/azure-sdk/ts-package-json-files-required": "off", + "@azure/azure-sdk/ts-package-json-main-is-cjs": "off", + "tsdoc/syntax": "warn", + }, + }, +]); diff --git a/sdk/impactreporting/arm-impactreporting/package.json b/sdk/impactreporting/arm-impactreporting/package.json new file mode 100644 index 000000000000..6c191658d12f --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/package.json @@ -0,0 +1,164 @@ +{ + "name": "@azure/arm-impactreporting", + "version": "1.0.0-beta.1", + "description": "A generated SDK for ImpactClient.", + "engines": { + "node": ">=18.0.0" + }, + "sideEffects": false, + "autoPublish": false, + "tshy": { + "project": "./tsconfig.src.json", + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./models": "./src/models/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "react-native" + ], + "selfLink": false + }, + "type": "module", + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "files": [ + "dist/", + "README.md", + "LICENSE", + "review/", + "CHANGELOG.md" + ], + "sdk-type": "mgmt", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/impactreporting/arm-impactreporting/README.md", + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "//metadata": { + "constantPaths": [ + { + "path": "src/api/impactContext.ts", + "prefix": "userAgentInfo" + } + ] + }, + "dependencies": { + "@azure-rest/core-client": "^2.3.1", + "@azure/abort-controller": "^2.1.2", + "@azure/core-auth": "^1.9.0", + "@azure/core-lro": "^3.1.0", + "@azure/core-rest-pipeline": "^1.19.0", + "@azure/core-util": "^1.11.0", + "@azure/logger": "^1.1.4", + "tslib": "^2.8.1" + }, + "devDependencies": { + "@azure-tools/test-credential": "^2.0.0", + "@azure-tools/test-recorder": "^4.1.0", + "@azure-tools/test-utils-vitest": "^1.0.0", + "@azure/dev-tool": "^1.0.0", + "@azure/eslint-plugin-azure-sdk": "^3.0.0", + "@azure/identity": "^4.7.0", + "@microsoft/api-extractor": "^7.40.3", + "@types/node": "^18.0.0", + "@vitest/browser": "^3.0.3", + "@vitest/coverage-istanbul": "^3.0.3", + "dotenv": "^16.0.0", + "eslint": "^9.9.0", + "playwright": "^1.50.1", + "typescript": "~5.6.2", + "vitest": "^3.0.3" + }, + "scripts": { + "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", + "build:samples": "tsc -p tsconfig.samples.json && dev-tool samples publish -f", + "build:test": "npm run clean && dev-tool run build-package && dev-tool run build-test", + "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "clean": "dev-tool run vendored rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "execute:samples": "dev-tool samples run samples-dev", + "extract-api": "dev-tool run vendored rimraf review && dev-tool run vendored mkdirp ./review && dev-tool run extract-api", + "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "generate:client": "echo skipped", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "integration-test:browser": "echo skipped", + "integration-test:node": "echo skipped", + "lint": "echo skipped", + "lint:fix": "echo skipped", + "minify": "dev-tool run vendored uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", + "pack": "npm pack 2>&1", + "test": "npm run clean && dev-tool run build-package && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test", + "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser", + "test:node": "npm run clean && dev-tool run build-package && npm run unit-test:node && npm run integration-test:node", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:browser": "npm run build:test && dev-tool run test:vitest --browser", + "unit-test:node": "dev-tool run test:vitest", + "update-snippets": "dev-tool run update-snippets" + }, + "//sampleConfiguration": { + "productName": "@azure/arm-impactreporting", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://learn.microsoft.com/javascript/api/@azure/arm-impactreporting?view=azure-node-preview" + }, + "browser": "./dist/browser/index.js", + "react-native": "./dist/react-native/index.js", + "exports": { + "./package.json": "./package.json", + ".": { + "browser": { + "types": "./dist/browser/index.d.ts", + "default": "./dist/browser/index.js" + }, + "react-native": { + "types": "./dist/react-native/index.d.ts", + "default": "./dist/react-native/index.js" + }, + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + }, + "./models": { + "browser": { + "types": "./dist/browser/models/index.d.ts", + "default": "./dist/browser/models/index.js" + }, + "react-native": { + "types": "./dist/react-native/models/index.d.ts", + "default": "./dist/react-native/models/index.js" + }, + "import": { + "types": "./dist/esm/models/index.d.ts", + "default": "./dist/esm/models/index.js" + }, + "require": { + "types": "./dist/commonjs/models/index.d.ts", + "default": "./dist/commonjs/models/index.js" + } + } + }, + "main": "./dist/commonjs/index.js", + "types": "./dist/commonjs/index.d.ts", + "module": "./dist/esm/index.js" +} diff --git a/sdk/impactreporting/arm-impactreporting/review/arm-impactreporting-models.api.md b/sdk/impactreporting/arm-impactreporting/review/arm-impactreporting-models.api.md new file mode 100644 index 000000000000..ab82cd38bc9b --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/review/arm-impactreporting-models.api.md @@ -0,0 +1,342 @@ +## API Report File for "@azure/arm-impactreporting" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +// @public +export type ActionType = string; + +// @public +export interface ClientIncidentDetails { + clientIncidentId?: string; + clientIncidentSource?: IncidentSource; +} + +// @public +export type ConfidenceLevel = string; + +// @public +export interface Connectivity { + port?: number; + protocol?: Protocol; + source?: SourceOrTarget; + target?: SourceOrTarget; +} + +// @public +export interface Connector extends ProxyResource { + properties?: ConnectorProperties; +} + +// @public +export interface ConnectorProperties { + readonly connectorId: string; + connectorType: Platform; + readonly lastRunTimeStamp: Date; + readonly provisioningState?: ProvisioningState; + readonly tenantId: string; +} + +// @public +export interface ConnectorUpdate { + properties?: ConnectorUpdateProperties; +} + +// @public +export interface ConnectorUpdateProperties { + connectorType?: Platform; +} + +// @public +export interface Content { + description: string; + title: string; +} + +// @public +export type CreatedByType = string; + +// @public +export interface ErrorAdditionalInfo { + readonly info?: Record; + readonly type?: string; +} + +// @public +export interface ErrorDetail { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorDetailProperties { + errorCode?: string; + errorMessage?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export interface ExpectedValueRange { + max: number; + min: number; +} + +// @public +export interface ImpactCategory extends ProxyResource { + properties?: ImpactCategoryProperties; +} + +// @public +export interface ImpactCategoryProperties { + categoryId: string; + description?: string; + parentCategoryId?: string; + readonly provisioningState?: ProvisioningState; + requiredImpactProperties?: RequiredImpactProperties[]; +} + +// @public +export interface ImpactDetails { + endTime?: Date; + impactedResourceId: string; + impactId: string; + startTime: Date; +} + +// @public +export type IncidentSource = string; + +// @public +export interface Insight extends ProxyResource { + properties?: InsightProperties; +} + +// @public +export interface InsightProperties { + additionalDetails?: Record; + category: string; + content: Content; + eventId?: string; + eventTime?: Date; + groupId?: string; + impact: ImpactDetails; + insightUniqueId: string; + readonly provisioningState?: ProvisioningState; + status?: string; +} + +// @public +export enum KnownActionType { + Internal = "Internal" +} + +// @public +export enum KnownConfidenceLevel { + High = "High", + Low = "Low", + Medium = "Medium" +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownIncidentSource { + AzureDevops = "AzureDevops", + ICM = "ICM", + Jira = "Jira", + Other = "Other", + ServiceNow = "ServiceNow" +} + +// @public +export enum KnownMetricUnit { + Bytes = "Bytes", + ByteSeconds = "ByteSeconds", + BytesPerSecond = "BytesPerSecond", + Cores = "Cores", + Count = "Count", + CountPerSecond = "CountPerSecond", + MilliCores = "MilliCores", + MilliSeconds = "MilliSeconds", + NanoCores = "NanoCores", + Other = "Other", + Percent = "Percent", + Seconds = "Seconds" +} + +// @public +export enum KnownOrigin { + System = "system", + User = "user", + UserSystem = "user,system" +} + +// @public +export enum KnownPlatform { + AzureMonitor = "AzureMonitor" +} + +// @public +export enum KnownProtocol { + FTP = "FTP", + Http = "HTTP", + Https = "HTTPS", + Other = "Other", + RDP = "RDP", + SSH = "SSH", + TCP = "TCP", + UDP = "UDP" +} + +// @public +export enum KnownProvisioningState { + Canceled = "Canceled", + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export enum KnownToolset { + Ansible = "Ansible", + ARM = "ARM", + Chef = "Chef", + Other = "Other", + Portal = "Portal", + Puppet = "Puppet", + SDK = "SDK", + Shell = "Shell", + Terraform = "Terraform" +} + +// @public +export enum KnownVersions { + V20240501Preview = "2024-05-01-preview" +} + +// @public +export type MetricUnit = string; + +// @public +export interface Operation { + readonly actionType?: ActionType; + display?: OperationDisplay; + readonly isDataAction?: boolean; + readonly name?: string; + readonly origin?: Origin; +} + +// @public +export interface OperationDisplay { + readonly description?: string; + readonly operation?: string; + readonly provider?: string; + readonly resource?: string; +} + +// @public +export type Origin = string; + +// @public +interface Performance_2 { + actual?: number; + expected?: number; + expectedValueRange?: ExpectedValueRange; + metricName?: string; + unit?: MetricUnit; +} +export { Performance_2 as Performance } + +// @public +export type Platform = string; + +// @public +export type Protocol = string; + +// @public +export type ProvisioningState = string; + +// @public +export interface ProxyResource extends Resource { +} + +// @public +export interface RequiredImpactProperties { + allowedValues?: string[]; + name: string; +} + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export interface SourceOrTarget { + azureResourceId?: string; +} + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// @public +export type Toolset = string; + +// @public +export interface Workload { + context?: string; + toolset?: Toolset; +} + +// @public +export interface WorkloadImpact extends ProxyResource { + properties?: WorkloadImpactProperties; +} + +// @public +export interface WorkloadImpactProperties { + additionalProperties?: Record; + armCorrelationIds?: string[]; + clientIncidentDetails?: ClientIncidentDetails; + confidenceLevel?: ConfidenceLevel; + connectivity?: Connectivity; + endDateTime?: Date; + errorDetails?: ErrorDetailProperties; + impactCategory: string; + impactDescription?: string; + impactedResourceId: string; + impactGroupId?: string; + readonly impactUniqueId?: string; + performance?: Performance_2[]; + readonly provisioningState?: ProvisioningState; + readonly reportedTimeUtc?: Date; + startDateTime: Date; + workload?: Workload; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/impactreporting/arm-impactreporting/review/arm-impactreporting.api.md b/sdk/impactreporting/arm-impactreporting/review/arm-impactreporting.api.md new file mode 100644 index 000000000000..df9f6ec54f3f --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/review/arm-impactreporting.api.md @@ -0,0 +1,497 @@ +## API Report File for "@azure/arm-impactreporting" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { AbortSignalLike } from '@azure/abort-controller'; +import { ClientOptions } from '@azure-rest/core-client'; +import { OperationOptions } from '@azure-rest/core-client'; +import { OperationState } from '@azure/core-lro'; +import { PathUncheckedResponse } from '@azure-rest/core-client'; +import { Pipeline } from '@azure/core-rest-pipeline'; +import { PollerLike } from '@azure/core-lro'; +import { TokenCredential } from '@azure/core-auth'; + +// @public +export type ActionType = string; + +// @public +export interface ClientIncidentDetails { + clientIncidentId?: string; + clientIncidentSource?: IncidentSource; +} + +// @public +export type ConfidenceLevel = string; + +// @public +export interface Connectivity { + port?: number; + protocol?: Protocol; + source?: SourceOrTarget; + target?: SourceOrTarget; +} + +// @public +export interface Connector extends ProxyResource { + properties?: ConnectorProperties; +} + +// @public +export interface ConnectorProperties { + readonly connectorId: string; + connectorType: Platform; + readonly lastRunTimeStamp: Date; + readonly provisioningState?: ProvisioningState; + readonly tenantId: string; +} + +// @public +export interface ConnectorsCreateOrUpdateOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface ConnectorsDeleteOptionalParams extends OperationOptions { +} + +// @public +export interface ConnectorsGetOptionalParams extends OperationOptions { +} + +// @public +export interface ConnectorsListBySubscriptionOptionalParams extends OperationOptions { +} + +// @public +export interface ConnectorsOperations { + createOrUpdate: (connectorName: string, resource: Connector, options?: ConnectorsCreateOrUpdateOptionalParams) => PollerLike, Connector>; + delete: (connectorName: string, options?: ConnectorsDeleteOptionalParams) => Promise; + get: (connectorName: string, options?: ConnectorsGetOptionalParams) => Promise; + listBySubscription: (options?: ConnectorsListBySubscriptionOptionalParams) => PagedAsyncIterableIterator; + update: (connectorName: string, properties: ConnectorUpdate, options?: ConnectorsUpdateOptionalParams) => Promise; +} + +// @public +export interface ConnectorsUpdateOptionalParams extends OperationOptions { +} + +// @public +export interface ConnectorUpdate { + properties?: ConnectorUpdateProperties; +} + +// @public +export interface ConnectorUpdateProperties { + connectorType?: Platform; +} + +// @public +export interface Content { + description: string; + title: string; +} + +// @public +export type ContinuablePage = TPage & { + continuationToken?: string; +}; + +// @public +export type CreatedByType = string; + +// @public +export interface ErrorAdditionalInfo { + readonly info?: Record; + readonly type?: string; +} + +// @public +export interface ErrorDetail { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorDetailProperties { + errorCode?: string; + errorMessage?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export interface ExpectedValueRange { + max: number; + min: number; +} + +// @public +export interface ImpactCategoriesGetOptionalParams extends OperationOptions { +} + +// @public +export interface ImpactCategoriesListBySubscriptionOptionalParams extends OperationOptions { + categoryName?: string; +} + +// @public +export interface ImpactCategoriesOperations { + get: (impactCategoryName: string, options?: ImpactCategoriesGetOptionalParams) => Promise; + listBySubscription: (resourceType: string, options?: ImpactCategoriesListBySubscriptionOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export interface ImpactCategory extends ProxyResource { + properties?: ImpactCategoryProperties; +} + +// @public +export interface ImpactCategoryProperties { + categoryId: string; + description?: string; + parentCategoryId?: string; + readonly provisioningState?: ProvisioningState; + requiredImpactProperties?: RequiredImpactProperties[]; +} + +// @public (undocumented) +export class ImpactClient { + constructor(credential: TokenCredential, subscriptionId: string, options?: ImpactClientOptionalParams); + readonly connectors: ConnectorsOperations; + readonly impactCategories: ImpactCategoriesOperations; + readonly insights: InsightsOperations; + readonly operations: OperationsOperations; + readonly pipeline: Pipeline; + readonly workloadImpacts: WorkloadImpactsOperations; +} + +// @public +export interface ImpactClientOptionalParams extends ClientOptions { + apiVersion?: string; +} + +// @public +export interface ImpactDetails { + endTime?: Date; + impactedResourceId: string; + impactId: string; + startTime: Date; +} + +// @public +export type IncidentSource = string; + +// @public +export interface Insight extends ProxyResource { + properties?: InsightProperties; +} + +// @public +export interface InsightProperties { + additionalDetails?: Record; + category: string; + content: Content; + eventId?: string; + eventTime?: Date; + groupId?: string; + impact: ImpactDetails; + insightUniqueId: string; + readonly provisioningState?: ProvisioningState; + status?: string; +} + +// @public +export interface InsightsCreateOptionalParams extends OperationOptions { +} + +// @public +export interface InsightsDeleteOptionalParams extends OperationOptions { +} + +// @public +export interface InsightsGetOptionalParams extends OperationOptions { +} + +// @public +export interface InsightsListBySubscriptionOptionalParams extends OperationOptions { +} + +// @public +export interface InsightsOperations { + create: (workloadImpactName: string, insightName: string, resource: Insight, options?: InsightsCreateOptionalParams) => Promise; + delete: (workloadImpactName: string, insightName: string, options?: InsightsDeleteOptionalParams) => Promise; + get: (workloadImpactName: string, insightName: string, options?: InsightsGetOptionalParams) => Promise; + listBySubscription: (workloadImpactName: string, options?: InsightsListBySubscriptionOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export enum KnownActionType { + Internal = "Internal" +} + +// @public +export enum KnownConfidenceLevel { + High = "High", + Low = "Low", + Medium = "Medium" +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownIncidentSource { + AzureDevops = "AzureDevops", + ICM = "ICM", + Jira = "Jira", + Other = "Other", + ServiceNow = "ServiceNow" +} + +// @public +export enum KnownMetricUnit { + Bytes = "Bytes", + ByteSeconds = "ByteSeconds", + BytesPerSecond = "BytesPerSecond", + Cores = "Cores", + Count = "Count", + CountPerSecond = "CountPerSecond", + MilliCores = "MilliCores", + MilliSeconds = "MilliSeconds", + NanoCores = "NanoCores", + Other = "Other", + Percent = "Percent", + Seconds = "Seconds" +} + +// @public +export enum KnownOrigin { + System = "system", + User = "user", + UserSystem = "user,system" +} + +// @public +export enum KnownPlatform { + AzureMonitor = "AzureMonitor" +} + +// @public +export enum KnownProtocol { + FTP = "FTP", + Http = "HTTP", + Https = "HTTPS", + Other = "Other", + RDP = "RDP", + SSH = "SSH", + TCP = "TCP", + UDP = "UDP" +} + +// @public +export enum KnownProvisioningState { + Canceled = "Canceled", + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export enum KnownToolset { + Ansible = "Ansible", + ARM = "ARM", + Chef = "Chef", + Other = "Other", + Portal = "Portal", + Puppet = "Puppet", + SDK = "SDK", + Shell = "Shell", + Terraform = "Terraform" +} + +// @public +export enum KnownVersions { + V20240501Preview = "2024-05-01-preview" +} + +// @public +export type MetricUnit = string; + +// @public +export interface Operation { + readonly actionType?: ActionType; + display?: OperationDisplay; + readonly isDataAction?: boolean; + readonly name?: string; + readonly origin?: Origin; +} + +// @public +export interface OperationDisplay { + readonly description?: string; + readonly operation?: string; + readonly provider?: string; + readonly resource?: string; +} + +// @public +export interface OperationsListOptionalParams extends OperationOptions { +} + +// @public +export interface OperationsOperations { + list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export type Origin = string; + +// @public +export interface PagedAsyncIterableIterator { + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; + next(): Promise>; +} + +// @public +export interface PageSettings { + continuationToken?: string; +} + +// @public +interface Performance_2 { + actual?: number; + expected?: number; + expectedValueRange?: ExpectedValueRange; + metricName?: string; + unit?: MetricUnit; +} +export { Performance_2 as Performance } + +// @public +export type Platform = string; + +// @public +export type Protocol = string; + +// @public +export type ProvisioningState = string; + +// @public +export interface ProxyResource extends Resource { +} + +// @public +export interface RequiredImpactProperties { + allowedValues?: string[]; + name: string; +} + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export function restorePoller(client: ImpactClient, serializedState: string, sourceOperation: (...args: any[]) => PollerLike, TResult>, options?: RestorePollerOptions): PollerLike, TResult>; + +// @public (undocumented) +export interface RestorePollerOptions extends OperationOptions { + abortSignal?: AbortSignalLike; + processResponseBody?: (result: TResponse) => Promise; + updateIntervalInMs?: number; +} + +// @public +export interface SourceOrTarget { + azureResourceId?: string; +} + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// @public +export type Toolset = string; + +// @public +export interface Workload { + context?: string; + toolset?: Toolset; +} + +// @public +export interface WorkloadImpact extends ProxyResource { + properties?: WorkloadImpactProperties; +} + +// @public +export interface WorkloadImpactProperties { + additionalProperties?: Record; + armCorrelationIds?: string[]; + clientIncidentDetails?: ClientIncidentDetails; + confidenceLevel?: ConfidenceLevel; + connectivity?: Connectivity; + endDateTime?: Date; + errorDetails?: ErrorDetailProperties; + impactCategory: string; + impactDescription?: string; + impactedResourceId: string; + impactGroupId?: string; + readonly impactUniqueId?: string; + performance?: Performance_2[]; + readonly provisioningState?: ProvisioningState; + readonly reportedTimeUtc?: Date; + startDateTime: Date; + workload?: Workload; +} + +// @public +export interface WorkloadImpactsCreateOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface WorkloadImpactsDeleteOptionalParams extends OperationOptions { +} + +// @public +export interface WorkloadImpactsGetOptionalParams extends OperationOptions { +} + +// @public +export interface WorkloadImpactsListBySubscriptionOptionalParams extends OperationOptions { +} + +// @public +export interface WorkloadImpactsOperations { + create: (workloadImpactName: string, resource: WorkloadImpact, options?: WorkloadImpactsCreateOptionalParams) => PollerLike, WorkloadImpact>; + delete: (workloadImpactName: string, options?: WorkloadImpactsDeleteOptionalParams) => Promise; + get: (workloadImpactName: string, options?: WorkloadImpactsGetOptionalParams) => Promise; + listBySubscription: (options?: WorkloadImpactsListBySubscriptionOptionalParams) => PagedAsyncIterableIterator; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/impactreporting/arm-impactreporting/sample.env b/sdk/impactreporting/arm-impactreporting/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsCreateOrUpdateSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..1735671e23f4 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsCreateOrUpdateSample.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a Connector + * + * @summary create a Connector + * x-ms-original-file: 2024-05-01-preview/Connectors_CreateOrUpdate.json + */ +async function connectorsCreateOrUpdate(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "74f5e23f-d4d9-410a-bb4d-8f0608adb10d"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.connectors.createOrUpdate("testconnector1", { + properties: { + connectorType: "AzureMonitor", + connectorId: "", + tenantId: "", + lastRunTimeStamp: new Date(), + }, + }); + console.log(result); +} + +async function main(): Promise { + await connectorsCreateOrUpdate(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsDeleteSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsDeleteSample.ts new file mode 100644 index 000000000000..a2daca64d8ef --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a Connector + * + * @summary delete a Connector + * x-ms-original-file: 2024-05-01-preview/Connectors_Delete.json + */ +async function connectorsDelete(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "8F74B371-8573-4773-9BDA-D546505BDB3A"; + const client = new ImpactClient(credential, subscriptionId); + await client.connectors.delete("testconnector1"); +} + +async function main(): Promise { + await connectorsDelete(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsGetSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsGetSample.ts new file mode 100644 index 000000000000..42f3e7f1973a --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a Connector + * + * @summary get a Connector + * x-ms-original-file: 2024-05-01-preview/Connectors_Get.json + */ +async function connectorsGet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "74f5e23f-d4d9-410a-bb4d-8f0608adb10d"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.connectors.get("testconnector1"); + console.log(result); +} + +async function main(): Promise { + await connectorsGet(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsListBySubscriptionSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsListBySubscriptionSample.ts new file mode 100644 index 000000000000..7fc65bf1f6ac --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsListBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Connector resources by subscription ID + * + * @summary list Connector resources by subscription ID + * x-ms-original-file: 2024-05-01-preview/Connectors_ListBySubscription.json + */ +async function connectorsListBySubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "74f5e23f-d4d9-410a-bb4d-8f0608adb10d"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.connectors.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await connectorsListBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsUpdateSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsUpdateSample.ts new file mode 100644 index 000000000000..3d7422c68e43 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/connectorsConnectorsUpdateSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to update a Connector + * + * @summary update a Connector + * x-ms-original-file: 2024-05-01-preview/Connectors_Update.json + */ +async function connectorsUpdate(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "74f5e23f-d4d9-410a-bb4d-8f0608adb10d"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.connectors.update("testconnector1", { + properties: { connectorType: "AzureMonitor" }, + }); + console.log(result); +} + +async function main(): Promise { + await connectorsUpdate(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/impactCategoriesImpactCategoriesGetSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/impactCategoriesImpactCategoriesGetSample.ts new file mode 100644 index 000000000000..e2b845fdb997 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/impactCategoriesImpactCategoriesGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a ImpactCategory + * + * @summary get a ImpactCategory + * x-ms-original-file: 2024-05-01-preview/ImpactCategories_Get.json + */ +async function getWorkloadImpactResourceByName(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.impactCategories.get("ARMOperation.Create"); + console.log(result); +} + +async function main(): Promise { + await getWorkloadImpactResourceByName(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/impactCategoriesImpactCategoriesListBySubscriptionSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/impactCategoriesImpactCategoriesListBySubscriptionSample.ts new file mode 100644 index 000000000000..e48341a90423 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/impactCategoriesImpactCategoriesListBySubscriptionSample.ts @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list ImpactCategory resources by subscription + * + * @summary list ImpactCategory resources by subscription + * x-ms-original-file: 2024-05-01-preview/ImpactCategories_ListBySubscription.json + */ +async function getImpactCategoriesListBySubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.impactCategories.listBySubscription( + "microsoft.compute/virtualmachines", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await getImpactCategoriesListBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/insightsInsightsCreateSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/insightsInsightsCreateSample.ts new file mode 100644 index 000000000000..d8a91f35a5e8 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/insightsInsightsCreateSample.ts @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create Insight resource, This is Admin only operation + * + * @summary create Insight resource, This is Admin only operation + * x-ms-original-file: 2024-05-01-preview/Insights_Create.json + */ +async function creatingAnInsight(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.insights.create("impactid22", "insightId12", { + properties: { + content: { + title: "Impact Has been correlated to an outage", + description: + 'At 2018-11-08T00:00:00Z UTC, your services dependent on these resources VM1 may have experienced an issue.
We have identified an outage that affected these resources(s). You can look at outage information on NL2W-VCZ link.
', + }, + category: "repair", + status: "resolved", + eventTime: new Date("2023-06-15T04:00:00.009223Z"), + insightUniqueId: "00000000-0000-0000-0000-000000000000", + impact: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservername", + startTime: new Date("2023-06-15T01:00:00.009223Z"), + impactId: + "/subscriptions/00000000-0000-0000-0000-000000000000/providers/microsoft.Impact/workloadImpacts/impactid22", + }, + }, + }); + console.log(result); +} + +async function main(): Promise { + await creatingAnInsight(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/insightsInsightsDeleteSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/insightsInsightsDeleteSample.ts new file mode 100644 index 000000000000..d02a998caa29 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/insightsInsightsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete Insight resource, This is Admin only operation + * + * @summary delete Insight resource, This is Admin only operation + * x-ms-original-file: 2024-05-01-preview/Insights_Delete.json + */ +async function deleteAnInsight(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + await client.insights.delete("impactid22", "insightId12"); +} + +async function main(): Promise { + await deleteAnInsight(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/insightsInsightsGetSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/insightsInsightsGetSample.ts new file mode 100644 index 000000000000..88f2ab2cf7d4 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/insightsInsightsGetSample.ts @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get Insight resources by workloadImpactName and insightName + * + * @summary get Insight resources by workloadImpactName and insightName + * x-ms-original-file: 2024-05-01-preview/Insights_Get_diagnostics.json + */ +async function getInsightSampleForDiagnosticsCategory(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.insights.get("impactid", "insight1"); + console.log(result); +} + +/** + * This sample demonstrates how to get Insight resources by workloadImpactName and insightName + * + * @summary get Insight resources by workloadImpactName and insightName + * x-ms-original-file: 2024-05-01-preview/Insights_Get_mitigationAction.json + */ +async function getInsightSampleForMitigationActionCategory(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.insights.get("impactId", "HPCUASucceeded"); + console.log(result); +} + +/** + * This sample demonstrates how to get Insight resources by workloadImpactName and insightName + * + * @summary get Insight resources by workloadImpactName and insightName + * x-ms-original-file: 2024-05-01-preview/Insights_Get_servicehealth.json + */ +async function getInsightSampleForServiceHealthCategory(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.insights.get("impactid", "insightname"); + console.log(result); +} + +async function main(): Promise { + await getInsightSampleForDiagnosticsCategory(); + await getInsightSampleForMitigationActionCategory(); + await getInsightSampleForServiceHealthCategory(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/insightsInsightsListBySubscriptionSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/insightsInsightsListBySubscriptionSample.ts new file mode 100644 index 000000000000..3e9b5709f3c8 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/insightsInsightsListBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Insight resources by workloadImpactName + * + * @summary list Insight resources by workloadImpactName + * x-ms-original-file: 2024-05-01-preview/Insights_ListBySubscription.json + */ +async function listInsightResourcesByWorkloadImpactName(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.insights.listBySubscription("impactid22")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listInsightResourcesByWorkloadImpactName(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/operationsOperationsListSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/operationsOperationsListSample.ts new file mode 100644 index 000000000000..e2cf471680e2 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/operationsOperationsListSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2024-05-01-preview/Operations_List.json + */ +async function operationsList(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-00000000000"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await operationsList(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/workloadImpactsWorkloadImpactsCreateSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/workloadImpactsWorkloadImpactsCreateSample.ts new file mode 100644 index 000000000000..6de3ec7353d6 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/workloadImpactsWorkloadImpactsCreateSample.ts @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a WorkloadImpact + * + * @summary create a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadArmOperation_create.json + */ +async function reportingArmOperationFailure(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.create("impact-002", { + properties: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservercontext", + startDateTime: new Date("2022-06-15T05:59:46.6517821Z"), + impactDescription: "deletion of resource failed", + impactCategory: "ArmOperation", + armCorrelationIds: ["00000000-0000-0000-0000-000000000000"], + workload: { context: "webapp/scenario1", toolset: "Other" }, + clientIncidentDetails: { + clientIncidentId: "AA123", + clientIncidentSource: "Jira", + }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to create a WorkloadImpact + * + * @summary create a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadAvailability_Create.json + */ +async function reportingAvailabilityRelatedImpact(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.create("impact-002", { + properties: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservercontext", + startDateTime: new Date("2022-06-15T05:59:46.6517821Z"), + impactDescription: "read calls failed", + impactCategory: "Availability", + workload: { context: "webapp/scenario1", toolset: "Other" }, + clientIncidentDetails: { + clientIncidentId: "AA123", + clientIncidentSource: "Jira", + }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to create a WorkloadImpact + * + * @summary create a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadConnectivityImpact_Create.json + */ +async function reportingAConnectivityImpact(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.create("impact-001", { + properties: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservercontext", + startDateTime: new Date("2022-06-15T05:59:46.6517821Z"), + impactDescription: "conection failure", + impactCategory: "Resource.Connectivity", + connectivity: { + protocol: "TCP", + port: 1443, + source: { + azureResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceSub/providers/Microsoft.compute/virtualmachines/vm1", + }, + target: { + azureResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceSub/providers/Microsoft.compute/virtualmachines/vm2", + }, + }, + workload: { context: "webapp/scenario1", toolset: "Other" }, + clientIncidentDetails: { + clientIncidentId: "AA123", + clientIncidentSource: "Jira", + }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to create a WorkloadImpact + * + * @summary create a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadPerformance_Create.json + */ +async function reportingPerformanceRelatedImpact(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.create("impact-002", { + properties: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservercontext", + startDateTime: new Date("2022-06-15T05:59:46.6517821Z"), + impactDescription: "high cpu utilization", + impactCategory: "Resource.Performance", + workload: { context: "webapp/scenario1", toolset: "Other" }, + performance: [{ metricName: "CPU", actual: 90, expected: 60 }], + clientIncidentDetails: { + clientIncidentId: "AA123", + clientIncidentSource: "Jira", + }, + }, + }); + console.log(result); +} + +async function main(): Promise { + await reportingArmOperationFailure(); + await reportingAvailabilityRelatedImpact(); + await reportingAConnectivityImpact(); + await reportingPerformanceRelatedImpact(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/workloadImpactsWorkloadImpactsDeleteSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/workloadImpactsWorkloadImpactsDeleteSample.ts new file mode 100644 index 000000000000..a9f0195f563d --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/workloadImpactsWorkloadImpactsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a WorkloadImpact + * + * @summary delete a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadImpact_Delete.json + */ +async function deleteWorkloadImpactResourceByNameExample(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + await client.workloadImpacts.delete("impact-001"); +} + +async function main(): Promise { + await deleteWorkloadImpactResourceByNameExample(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/workloadImpactsWorkloadImpactsGetSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/workloadImpactsWorkloadImpactsGetSample.ts new file mode 100644 index 000000000000..1c9a19868a9e --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/workloadImpactsWorkloadImpactsGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a WorkloadImpact + * + * @summary get a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadImpact_Get.json + */ +async function getWorkloadImpactResourceByNameExample(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.get("impact-001"); + console.log(result); +} + +async function main(): Promise { + await getWorkloadImpactResourceByNameExample(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples-dev/workloadImpactsWorkloadImpactsListBySubscriptionSample.ts b/sdk/impactreporting/arm-impactreporting/samples-dev/workloadImpactsWorkloadImpactsListBySubscriptionSample.ts new file mode 100644 index 000000000000..4e6c9425f7bb --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples-dev/workloadImpactsWorkloadImpactsListBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list WorkloadImpact resources by subscription ID + * + * @summary list WorkloadImpact resources by subscription ID + * x-ms-original-file: 2024-05-01-preview/WorkloadImpacts_ListBySubscription.json + */ +async function listWorkloadImpactResourcesBySubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.workloadImpacts.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listWorkloadImpactResourcesBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/README.md b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/README.md new file mode 100644 index 000000000000..6dd615a2fdc6 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/README.md @@ -0,0 +1,80 @@ +# @azure/arm-impactreporting client library samples for JavaScript (Beta) + +These sample programs show how to use the JavaScript client libraries for @azure/arm-impactreporting in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | +| [connectorsConnectorsCreateOrUpdateSample.js][connectorsconnectorscreateorupdatesample] | create a Connector x-ms-original-file: 2024-05-01-preview/Connectors_CreateOrUpdate.json | +| [connectorsConnectorsDeleteSample.js][connectorsconnectorsdeletesample] | delete a Connector x-ms-original-file: 2024-05-01-preview/Connectors_Delete.json | +| [connectorsConnectorsGetSample.js][connectorsconnectorsgetsample] | get a Connector x-ms-original-file: 2024-05-01-preview/Connectors_Get.json | +| [connectorsConnectorsListBySubscriptionSample.js][connectorsconnectorslistbysubscriptionsample] | list Connector resources by subscription ID x-ms-original-file: 2024-05-01-preview/Connectors_ListBySubscription.json | +| [connectorsConnectorsUpdateSample.js][connectorsconnectorsupdatesample] | update a Connector x-ms-original-file: 2024-05-01-preview/Connectors_Update.json | +| [impactCategoriesImpactCategoriesGetSample.js][impactcategoriesimpactcategoriesgetsample] | get a ImpactCategory x-ms-original-file: 2024-05-01-preview/ImpactCategories_Get.json | +| [impactCategoriesImpactCategoriesListBySubscriptionSample.js][impactcategoriesimpactcategorieslistbysubscriptionsample] | list ImpactCategory resources by subscription x-ms-original-file: 2024-05-01-preview/ImpactCategories_ListBySubscription.json | +| [insightsInsightsCreateSample.js][insightsinsightscreatesample] | create Insight resource, This is Admin only operation x-ms-original-file: 2024-05-01-preview/Insights_Create.json | +| [insightsInsightsDeleteSample.js][insightsinsightsdeletesample] | delete Insight resource, This is Admin only operation x-ms-original-file: 2024-05-01-preview/Insights_Delete.json | +| [insightsInsightsGetSample.js][insightsinsightsgetsample] | get Insight resources by workloadImpactName and insightName x-ms-original-file: 2024-05-01-preview/Insights_Get_diagnostics.json | +| [insightsInsightsListBySubscriptionSample.js][insightsinsightslistbysubscriptionsample] | list Insight resources by workloadImpactName x-ms-original-file: 2024-05-01-preview/Insights_ListBySubscription.json | +| [operationsOperationsListSample.js][operationsoperationslistsample] | list the operations for the provider x-ms-original-file: 2024-05-01-preview/Operations_List.json | +| [workloadImpactsWorkloadImpactsCreateSample.js][workloadimpactsworkloadimpactscreatesample] | create a WorkloadImpact x-ms-original-file: 2024-05-01-preview/WorkloadArmOperation_create.json | +| [workloadImpactsWorkloadImpactsDeleteSample.js][workloadimpactsworkloadimpactsdeletesample] | delete a WorkloadImpact x-ms-original-file: 2024-05-01-preview/WorkloadImpact_Delete.json | +| [workloadImpactsWorkloadImpactsGetSample.js][workloadimpactsworkloadimpactsgetsample] | get a WorkloadImpact x-ms-original-file: 2024-05-01-preview/WorkloadImpact_Get.json | +| [workloadImpactsWorkloadImpactsListBySubscriptionSample.js][workloadimpactsworkloadimpactslistbysubscriptionsample] | list WorkloadImpact resources by subscription ID x-ms-original-file: 2024-05-01-preview/WorkloadImpacts_ListBySubscription.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node connectorsConnectorsCreateOrUpdateSample.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx dev-tool run vendored cross-env node connectorsConnectorsCreateOrUpdateSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[connectorsconnectorscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsCreateOrUpdateSample.js +[connectorsconnectorsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsDeleteSample.js +[connectorsconnectorsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsGetSample.js +[connectorsconnectorslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsListBySubscriptionSample.js +[connectorsconnectorsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsUpdateSample.js +[impactcategoriesimpactcategoriesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/impactCategoriesImpactCategoriesGetSample.js +[impactcategoriesimpactcategorieslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/impactCategoriesImpactCategoriesListBySubscriptionSample.js +[insightsinsightscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsCreateSample.js +[insightsinsightsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsDeleteSample.js +[insightsinsightsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsGetSample.js +[insightsinsightslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsListBySubscriptionSample.js +[operationsoperationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/operationsOperationsListSample.js +[workloadimpactsworkloadimpactscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsCreateSample.js +[workloadimpactsworkloadimpactsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsDeleteSample.js +[workloadimpactsworkloadimpactsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsGetSample.js +[workloadimpactsworkloadimpactslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsListBySubscriptionSample.js +[apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-impactreporting?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/impactreporting/arm-impactreporting/README.md diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsCreateOrUpdateSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsCreateOrUpdateSample.js new file mode 100644 index 000000000000..10ce858d79ab --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsCreateOrUpdateSample.js @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to create a Connector + * + * @summary create a Connector + * x-ms-original-file: 2024-05-01-preview/Connectors_CreateOrUpdate.json + */ +async function connectorsCreateOrUpdate() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "74f5e23f-d4d9-410a-bb4d-8f0608adb10d"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.connectors.createOrUpdate("testconnector1", { + properties: { + connectorType: "AzureMonitor", + connectorId: "", + tenantId: "", + lastRunTimeStamp: new Date(), + }, + }); + console.log(result); +} + +async function main() { + await connectorsCreateOrUpdate(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsDeleteSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsDeleteSample.js new file mode 100644 index 000000000000..0f973d2fb431 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsDeleteSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to delete a Connector + * + * @summary delete a Connector + * x-ms-original-file: 2024-05-01-preview/Connectors_Delete.json + */ +async function connectorsDelete() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "8F74B371-8573-4773-9BDA-D546505BDB3A"; + const client = new ImpactClient(credential, subscriptionId); + await client.connectors.delete("testconnector1"); +} + +async function main() { + await connectorsDelete(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsGetSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsGetSample.js new file mode 100644 index 000000000000..2ac0d5dca186 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsGetSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get a Connector + * + * @summary get a Connector + * x-ms-original-file: 2024-05-01-preview/Connectors_Get.json + */ +async function connectorsGet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "74f5e23f-d4d9-410a-bb4d-8f0608adb10d"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.connectors.get("testconnector1"); + console.log(result); +} + +async function main() { + await connectorsGet(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsListBySubscriptionSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsListBySubscriptionSample.js new file mode 100644 index 000000000000..5d8a382d07d5 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsListBySubscriptionSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list Connector resources by subscription ID + * + * @summary list Connector resources by subscription ID + * x-ms-original-file: 2024-05-01-preview/Connectors_ListBySubscription.json + */ +async function connectorsListBySubscription() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "74f5e23f-d4d9-410a-bb4d-8f0608adb10d"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.connectors.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await connectorsListBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsUpdateSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsUpdateSample.js new file mode 100644 index 000000000000..d6eb68a1d3d7 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/connectorsConnectorsUpdateSample.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to update a Connector + * + * @summary update a Connector + * x-ms-original-file: 2024-05-01-preview/Connectors_Update.json + */ +async function connectorsUpdate() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "74f5e23f-d4d9-410a-bb4d-8f0608adb10d"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.connectors.update("testconnector1", { + properties: { connectorType: "AzureMonitor" }, + }); + console.log(result); +} + +async function main() { + await connectorsUpdate(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/impactCategoriesImpactCategoriesGetSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/impactCategoriesImpactCategoriesGetSample.js new file mode 100644 index 000000000000..c740933c1a9a --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/impactCategoriesImpactCategoriesGetSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get a ImpactCategory + * + * @summary get a ImpactCategory + * x-ms-original-file: 2024-05-01-preview/ImpactCategories_Get.json + */ +async function getWorkloadImpactResourceByName() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.impactCategories.get("ARMOperation.Create"); + console.log(result); +} + +async function main() { + await getWorkloadImpactResourceByName(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/impactCategoriesImpactCategoriesListBySubscriptionSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/impactCategoriesImpactCategoriesListBySubscriptionSample.js new file mode 100644 index 000000000000..7791c84d7103 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/impactCategoriesImpactCategoriesListBySubscriptionSample.js @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list ImpactCategory resources by subscription + * + * @summary list ImpactCategory resources by subscription + * x-ms-original-file: 2024-05-01-preview/ImpactCategories_ListBySubscription.json + */ +async function getImpactCategoriesListBySubscription() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.impactCategories.listBySubscription( + "microsoft.compute/virtualmachines", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await getImpactCategoriesListBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsCreateSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsCreateSample.js new file mode 100644 index 000000000000..5a2d7d590346 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsCreateSample.js @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to create Insight resource, This is Admin only operation + * + * @summary create Insight resource, This is Admin only operation + * x-ms-original-file: 2024-05-01-preview/Insights_Create.json + */ +async function creatingAnInsight() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.insights.create("impactid22", "insightId12", { + properties: { + content: { + title: "Impact Has been correlated to an outage", + description: + 'At 2018-11-08T00:00:00Z UTC, your services dependent on these resources VM1 may have experienced an issue.
We have identified an outage that affected these resources(s). You can look at outage information on NL2W-VCZ link.
', + }, + category: "repair", + status: "resolved", + eventTime: new Date("2023-06-15T04:00:00.009223Z"), + insightUniqueId: "00000000-0000-0000-0000-000000000000", + impact: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservername", + startTime: new Date("2023-06-15T01:00:00.009223Z"), + impactId: + "/subscriptions/00000000-0000-0000-0000-000000000000/providers/microsoft.Impact/workloadImpacts/impactid22", + }, + }, + }); + console.log(result); +} + +async function main() { + await creatingAnInsight(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsDeleteSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsDeleteSample.js new file mode 100644 index 000000000000..98a30a7a9e5f --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsDeleteSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to delete Insight resource, This is Admin only operation + * + * @summary delete Insight resource, This is Admin only operation + * x-ms-original-file: 2024-05-01-preview/Insights_Delete.json + */ +async function deleteAnInsight() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + await client.insights.delete("impactid22", "insightId12"); +} + +async function main() { + await deleteAnInsight(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsGetSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsGetSample.js new file mode 100644 index 000000000000..cfda91738fb4 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsGetSample.js @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get Insight resources by workloadImpactName and insightName + * + * @summary get Insight resources by workloadImpactName and insightName + * x-ms-original-file: 2024-05-01-preview/Insights_Get_diagnostics.json + */ +async function getInsightSampleForDiagnosticsCategory() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.insights.get("impactid", "insight1"); + console.log(result); +} + +/** + * This sample demonstrates how to get Insight resources by workloadImpactName and insightName + * + * @summary get Insight resources by workloadImpactName and insightName + * x-ms-original-file: 2024-05-01-preview/Insights_Get_mitigationAction.json + */ +async function getInsightSampleForMitigationActionCategory() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.insights.get("impactId", "HPCUASucceeded"); + console.log(result); +} + +/** + * This sample demonstrates how to get Insight resources by workloadImpactName and insightName + * + * @summary get Insight resources by workloadImpactName and insightName + * x-ms-original-file: 2024-05-01-preview/Insights_Get_servicehealth.json + */ +async function getInsightSampleForServiceHealthCategory() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.insights.get("impactid", "insightname"); + console.log(result); +} + +async function main() { + await getInsightSampleForDiagnosticsCategory(); + await getInsightSampleForMitigationActionCategory(); + await getInsightSampleForServiceHealthCategory(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsListBySubscriptionSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsListBySubscriptionSample.js new file mode 100644 index 000000000000..fa4aaa1fca61 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/insightsInsightsListBySubscriptionSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list Insight resources by workloadImpactName + * + * @summary list Insight resources by workloadImpactName + * x-ms-original-file: 2024-05-01-preview/Insights_ListBySubscription.json + */ +async function listInsightResourcesByWorkloadImpactName() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.insights.listBySubscription("impactid22")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await listInsightResourcesByWorkloadImpactName(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/operationsOperationsListSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/operationsOperationsListSample.js new file mode 100644 index 000000000000..0f2dcf5b0a78 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/operationsOperationsListSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2024-05-01-preview/Operations_List.json + */ +async function operationsList() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-00000000000"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await operationsList(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/package.json b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/package.json new file mode 100644 index 000000000000..f7ae5c356551 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/package.json @@ -0,0 +1,33 @@ +{ + "name": "@azure-samples/arm-impactreporting-js-beta", + "private": true, + "version": "1.0.0", + "description": "@azure/arm-impactreporting client library samples for JavaScript (Beta)", + "engines": { + "node": ">=18.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/impactreporting/arm-impactreporting" + }, + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/impactreporting/arm-impactreporting", + "dependencies": { + "@azure/arm-impactreporting": "next", + "dotenv": "latest", + "@azure/identity": "^4.7.0" + } +} diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/sample.env b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsCreateSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsCreateSample.js new file mode 100644 index 000000000000..8ccb8590e158 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsCreateSample.js @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to create a WorkloadImpact + * + * @summary create a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadArmOperation_create.json + */ +async function reportingArmOperationFailure() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.create("impact-002", { + properties: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservercontext", + startDateTime: new Date("2022-06-15T05:59:46.6517821Z"), + impactDescription: "deletion of resource failed", + impactCategory: "ArmOperation", + armCorrelationIds: ["00000000-0000-0000-0000-000000000000"], + workload: { context: "webapp/scenario1", toolset: "Other" }, + clientIncidentDetails: { + clientIncidentId: "AA123", + clientIncidentSource: "Jira", + }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to create a WorkloadImpact + * + * @summary create a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadAvailability_Create.json + */ +async function reportingAvailabilityRelatedImpact() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.create("impact-002", { + properties: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservercontext", + startDateTime: new Date("2022-06-15T05:59:46.6517821Z"), + impactDescription: "read calls failed", + impactCategory: "Availability", + workload: { context: "webapp/scenario1", toolset: "Other" }, + clientIncidentDetails: { + clientIncidentId: "AA123", + clientIncidentSource: "Jira", + }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to create a WorkloadImpact + * + * @summary create a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadConnectivityImpact_Create.json + */ +async function reportingAConnectivityImpact() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.create("impact-001", { + properties: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservercontext", + startDateTime: new Date("2022-06-15T05:59:46.6517821Z"), + impactDescription: "conection failure", + impactCategory: "Resource.Connectivity", + connectivity: { + protocol: "TCP", + port: 1443, + source: { + azureResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceSub/providers/Microsoft.compute/virtualmachines/vm1", + }, + target: { + azureResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceSub/providers/Microsoft.compute/virtualmachines/vm2", + }, + }, + workload: { context: "webapp/scenario1", toolset: "Other" }, + clientIncidentDetails: { + clientIncidentId: "AA123", + clientIncidentSource: "Jira", + }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to create a WorkloadImpact + * + * @summary create a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadPerformance_Create.json + */ +async function reportingPerformanceRelatedImpact() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.create("impact-002", { + properties: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservercontext", + startDateTime: new Date("2022-06-15T05:59:46.6517821Z"), + impactDescription: "high cpu utilization", + impactCategory: "Resource.Performance", + workload: { context: "webapp/scenario1", toolset: "Other" }, + performance: [{ metricName: "CPU", actual: 90, expected: 60 }], + clientIncidentDetails: { + clientIncidentId: "AA123", + clientIncidentSource: "Jira", + }, + }, + }); + console.log(result); +} + +async function main() { + await reportingArmOperationFailure(); + await reportingAvailabilityRelatedImpact(); + await reportingAConnectivityImpact(); + await reportingPerformanceRelatedImpact(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsDeleteSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsDeleteSample.js new file mode 100644 index 000000000000..700e0849b296 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsDeleteSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to delete a WorkloadImpact + * + * @summary delete a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadImpact_Delete.json + */ +async function deleteWorkloadImpactResourceByNameExample() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + await client.workloadImpacts.delete("impact-001"); +} + +async function main() { + await deleteWorkloadImpactResourceByNameExample(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsGetSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsGetSample.js new file mode 100644 index 000000000000..53b6f9b6f87a --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsGetSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get a WorkloadImpact + * + * @summary get a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadImpact_Get.json + */ +async function getWorkloadImpactResourceByNameExample() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.get("impact-001"); + console.log(result); +} + +async function main() { + await getWorkloadImpactResourceByNameExample(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsListBySubscriptionSample.js b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsListBySubscriptionSample.js new file mode 100644 index 000000000000..22b8114656bc --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/javascript/workloadImpactsWorkloadImpactsListBySubscriptionSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { ImpactClient } = require("@azure/arm-impactreporting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list WorkloadImpact resources by subscription ID + * + * @summary list WorkloadImpact resources by subscription ID + * x-ms-original-file: 2024-05-01-preview/WorkloadImpacts_ListBySubscription.json + */ +async function listWorkloadImpactResourcesBySubscription() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.workloadImpacts.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await listWorkloadImpactResourcesBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/README.md b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/README.md new file mode 100644 index 000000000000..316d6c4c2b6e --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/README.md @@ -0,0 +1,93 @@ +# @azure/arm-impactreporting client library samples for TypeScript (Beta) + +These sample programs show how to use the TypeScript client libraries for @azure/arm-impactreporting in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | +| [connectorsConnectorsCreateOrUpdateSample.ts][connectorsconnectorscreateorupdatesample] | create a Connector x-ms-original-file: 2024-05-01-preview/Connectors_CreateOrUpdate.json | +| [connectorsConnectorsDeleteSample.ts][connectorsconnectorsdeletesample] | delete a Connector x-ms-original-file: 2024-05-01-preview/Connectors_Delete.json | +| [connectorsConnectorsGetSample.ts][connectorsconnectorsgetsample] | get a Connector x-ms-original-file: 2024-05-01-preview/Connectors_Get.json | +| [connectorsConnectorsListBySubscriptionSample.ts][connectorsconnectorslistbysubscriptionsample] | list Connector resources by subscription ID x-ms-original-file: 2024-05-01-preview/Connectors_ListBySubscription.json | +| [connectorsConnectorsUpdateSample.ts][connectorsconnectorsupdatesample] | update a Connector x-ms-original-file: 2024-05-01-preview/Connectors_Update.json | +| [impactCategoriesImpactCategoriesGetSample.ts][impactcategoriesimpactcategoriesgetsample] | get a ImpactCategory x-ms-original-file: 2024-05-01-preview/ImpactCategories_Get.json | +| [impactCategoriesImpactCategoriesListBySubscriptionSample.ts][impactcategoriesimpactcategorieslistbysubscriptionsample] | list ImpactCategory resources by subscription x-ms-original-file: 2024-05-01-preview/ImpactCategories_ListBySubscription.json | +| [insightsInsightsCreateSample.ts][insightsinsightscreatesample] | create Insight resource, This is Admin only operation x-ms-original-file: 2024-05-01-preview/Insights_Create.json | +| [insightsInsightsDeleteSample.ts][insightsinsightsdeletesample] | delete Insight resource, This is Admin only operation x-ms-original-file: 2024-05-01-preview/Insights_Delete.json | +| [insightsInsightsGetSample.ts][insightsinsightsgetsample] | get Insight resources by workloadImpactName and insightName x-ms-original-file: 2024-05-01-preview/Insights_Get_diagnostics.json | +| [insightsInsightsListBySubscriptionSample.ts][insightsinsightslistbysubscriptionsample] | list Insight resources by workloadImpactName x-ms-original-file: 2024-05-01-preview/Insights_ListBySubscription.json | +| [operationsOperationsListSample.ts][operationsoperationslistsample] | list the operations for the provider x-ms-original-file: 2024-05-01-preview/Operations_List.json | +| [workloadImpactsWorkloadImpactsCreateSample.ts][workloadimpactsworkloadimpactscreatesample] | create a WorkloadImpact x-ms-original-file: 2024-05-01-preview/WorkloadArmOperation_create.json | +| [workloadImpactsWorkloadImpactsDeleteSample.ts][workloadimpactsworkloadimpactsdeletesample] | delete a WorkloadImpact x-ms-original-file: 2024-05-01-preview/WorkloadImpact_Delete.json | +| [workloadImpactsWorkloadImpactsGetSample.ts][workloadimpactsworkloadimpactsgetsample] | get a WorkloadImpact x-ms-original-file: 2024-05-01-preview/WorkloadImpact_Get.json | +| [workloadImpactsWorkloadImpactsListBySubscriptionSample.ts][workloadimpactsworkloadimpactslistbysubscriptionsample] | list WorkloadImpact resources by subscription ID x-ms-original-file: 2024-05-01-preview/WorkloadImpacts_ListBySubscription.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/connectorsConnectorsCreateOrUpdateSample.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx dev-tool run vendored cross-env node dist/connectorsConnectorsCreateOrUpdateSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[connectorsconnectorscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsCreateOrUpdateSample.ts +[connectorsconnectorsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsDeleteSample.ts +[connectorsconnectorsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsGetSample.ts +[connectorsconnectorslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsListBySubscriptionSample.ts +[connectorsconnectorsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsUpdateSample.ts +[impactcategoriesimpactcategoriesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/impactCategoriesImpactCategoriesGetSample.ts +[impactcategoriesimpactcategorieslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/impactCategoriesImpactCategoriesListBySubscriptionSample.ts +[insightsinsightscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsCreateSample.ts +[insightsinsightsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsDeleteSample.ts +[insightsinsightsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsGetSample.ts +[insightsinsightslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsListBySubscriptionSample.ts +[operationsoperationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/operationsOperationsListSample.ts +[workloadimpactsworkloadimpactscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsCreateSample.ts +[workloadimpactsworkloadimpactsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsDeleteSample.ts +[workloadimpactsworkloadimpactsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsGetSample.ts +[workloadimpactsworkloadimpactslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsListBySubscriptionSample.ts +[apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-impactreporting?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/impactreporting/arm-impactreporting/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/package.json b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/package.json new file mode 100644 index 000000000000..a8722237d6ad --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/package.json @@ -0,0 +1,42 @@ +{ + "name": "@azure-samples/arm-impactreporting-ts-beta", + "private": true, + "version": "1.0.0", + "description": "@azure/arm-impactreporting client library samples for TypeScript (Beta)", + "engines": { + "node": ">=18.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/impactreporting/arm-impactreporting" + }, + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/impactreporting/arm-impactreporting", + "dependencies": { + "@azure/arm-impactreporting": "next", + "dotenv": "latest", + "@azure/identity": "^4.7.0" + }, + "devDependencies": { + "@types/node": "^18.0.0", + "typescript": "~5.7.2", + "rimraf": "latest" + } +} diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/sample.env b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsCreateOrUpdateSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..1735671e23f4 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsCreateOrUpdateSample.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a Connector + * + * @summary create a Connector + * x-ms-original-file: 2024-05-01-preview/Connectors_CreateOrUpdate.json + */ +async function connectorsCreateOrUpdate(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "74f5e23f-d4d9-410a-bb4d-8f0608adb10d"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.connectors.createOrUpdate("testconnector1", { + properties: { + connectorType: "AzureMonitor", + connectorId: "", + tenantId: "", + lastRunTimeStamp: new Date(), + }, + }); + console.log(result); +} + +async function main(): Promise { + await connectorsCreateOrUpdate(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsDeleteSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsDeleteSample.ts new file mode 100644 index 000000000000..a2daca64d8ef --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a Connector + * + * @summary delete a Connector + * x-ms-original-file: 2024-05-01-preview/Connectors_Delete.json + */ +async function connectorsDelete(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "8F74B371-8573-4773-9BDA-D546505BDB3A"; + const client = new ImpactClient(credential, subscriptionId); + await client.connectors.delete("testconnector1"); +} + +async function main(): Promise { + await connectorsDelete(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsGetSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsGetSample.ts new file mode 100644 index 000000000000..42f3e7f1973a --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a Connector + * + * @summary get a Connector + * x-ms-original-file: 2024-05-01-preview/Connectors_Get.json + */ +async function connectorsGet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "74f5e23f-d4d9-410a-bb4d-8f0608adb10d"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.connectors.get("testconnector1"); + console.log(result); +} + +async function main(): Promise { + await connectorsGet(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsListBySubscriptionSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsListBySubscriptionSample.ts new file mode 100644 index 000000000000..7fc65bf1f6ac --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsListBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Connector resources by subscription ID + * + * @summary list Connector resources by subscription ID + * x-ms-original-file: 2024-05-01-preview/Connectors_ListBySubscription.json + */ +async function connectorsListBySubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "74f5e23f-d4d9-410a-bb4d-8f0608adb10d"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.connectors.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await connectorsListBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsUpdateSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsUpdateSample.ts new file mode 100644 index 000000000000..3d7422c68e43 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/connectorsConnectorsUpdateSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to update a Connector + * + * @summary update a Connector + * x-ms-original-file: 2024-05-01-preview/Connectors_Update.json + */ +async function connectorsUpdate(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "74f5e23f-d4d9-410a-bb4d-8f0608adb10d"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.connectors.update("testconnector1", { + properties: { connectorType: "AzureMonitor" }, + }); + console.log(result); +} + +async function main(): Promise { + await connectorsUpdate(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/impactCategoriesImpactCategoriesGetSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/impactCategoriesImpactCategoriesGetSample.ts new file mode 100644 index 000000000000..e2b845fdb997 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/impactCategoriesImpactCategoriesGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a ImpactCategory + * + * @summary get a ImpactCategory + * x-ms-original-file: 2024-05-01-preview/ImpactCategories_Get.json + */ +async function getWorkloadImpactResourceByName(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.impactCategories.get("ARMOperation.Create"); + console.log(result); +} + +async function main(): Promise { + await getWorkloadImpactResourceByName(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/impactCategoriesImpactCategoriesListBySubscriptionSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/impactCategoriesImpactCategoriesListBySubscriptionSample.ts new file mode 100644 index 000000000000..e48341a90423 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/impactCategoriesImpactCategoriesListBySubscriptionSample.ts @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list ImpactCategory resources by subscription + * + * @summary list ImpactCategory resources by subscription + * x-ms-original-file: 2024-05-01-preview/ImpactCategories_ListBySubscription.json + */ +async function getImpactCategoriesListBySubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.impactCategories.listBySubscription( + "microsoft.compute/virtualmachines", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await getImpactCategoriesListBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsCreateSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsCreateSample.ts new file mode 100644 index 000000000000..d8a91f35a5e8 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsCreateSample.ts @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create Insight resource, This is Admin only operation + * + * @summary create Insight resource, This is Admin only operation + * x-ms-original-file: 2024-05-01-preview/Insights_Create.json + */ +async function creatingAnInsight(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.insights.create("impactid22", "insightId12", { + properties: { + content: { + title: "Impact Has been correlated to an outage", + description: + 'At 2018-11-08T00:00:00Z UTC, your services dependent on these resources VM1 may have experienced an issue.
We have identified an outage that affected these resources(s). You can look at outage information on NL2W-VCZ link.
', + }, + category: "repair", + status: "resolved", + eventTime: new Date("2023-06-15T04:00:00.009223Z"), + insightUniqueId: "00000000-0000-0000-0000-000000000000", + impact: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservername", + startTime: new Date("2023-06-15T01:00:00.009223Z"), + impactId: + "/subscriptions/00000000-0000-0000-0000-000000000000/providers/microsoft.Impact/workloadImpacts/impactid22", + }, + }, + }); + console.log(result); +} + +async function main(): Promise { + await creatingAnInsight(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsDeleteSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsDeleteSample.ts new file mode 100644 index 000000000000..d02a998caa29 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete Insight resource, This is Admin only operation + * + * @summary delete Insight resource, This is Admin only operation + * x-ms-original-file: 2024-05-01-preview/Insights_Delete.json + */ +async function deleteAnInsight(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + await client.insights.delete("impactid22", "insightId12"); +} + +async function main(): Promise { + await deleteAnInsight(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsGetSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsGetSample.ts new file mode 100644 index 000000000000..88f2ab2cf7d4 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsGetSample.ts @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get Insight resources by workloadImpactName and insightName + * + * @summary get Insight resources by workloadImpactName and insightName + * x-ms-original-file: 2024-05-01-preview/Insights_Get_diagnostics.json + */ +async function getInsightSampleForDiagnosticsCategory(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.insights.get("impactid", "insight1"); + console.log(result); +} + +/** + * This sample demonstrates how to get Insight resources by workloadImpactName and insightName + * + * @summary get Insight resources by workloadImpactName and insightName + * x-ms-original-file: 2024-05-01-preview/Insights_Get_mitigationAction.json + */ +async function getInsightSampleForMitigationActionCategory(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.insights.get("impactId", "HPCUASucceeded"); + console.log(result); +} + +/** + * This sample demonstrates how to get Insight resources by workloadImpactName and insightName + * + * @summary get Insight resources by workloadImpactName and insightName + * x-ms-original-file: 2024-05-01-preview/Insights_Get_servicehealth.json + */ +async function getInsightSampleForServiceHealthCategory(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.insights.get("impactid", "insightname"); + console.log(result); +} + +async function main(): Promise { + await getInsightSampleForDiagnosticsCategory(); + await getInsightSampleForMitigationActionCategory(); + await getInsightSampleForServiceHealthCategory(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsListBySubscriptionSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsListBySubscriptionSample.ts new file mode 100644 index 000000000000..3e9b5709f3c8 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/insightsInsightsListBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list Insight resources by workloadImpactName + * + * @summary list Insight resources by workloadImpactName + * x-ms-original-file: 2024-05-01-preview/Insights_ListBySubscription.json + */ +async function listInsightResourcesByWorkloadImpactName(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.insights.listBySubscription("impactid22")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listInsightResourcesByWorkloadImpactName(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/operationsOperationsListSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/operationsOperationsListSample.ts new file mode 100644 index 000000000000..e2cf471680e2 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/operationsOperationsListSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2024-05-01-preview/Operations_List.json + */ +async function operationsList(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-00000000000"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await operationsList(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsCreateSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsCreateSample.ts new file mode 100644 index 000000000000..6de3ec7353d6 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsCreateSample.ts @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a WorkloadImpact + * + * @summary create a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadArmOperation_create.json + */ +async function reportingArmOperationFailure(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.create("impact-002", { + properties: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservercontext", + startDateTime: new Date("2022-06-15T05:59:46.6517821Z"), + impactDescription: "deletion of resource failed", + impactCategory: "ArmOperation", + armCorrelationIds: ["00000000-0000-0000-0000-000000000000"], + workload: { context: "webapp/scenario1", toolset: "Other" }, + clientIncidentDetails: { + clientIncidentId: "AA123", + clientIncidentSource: "Jira", + }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to create a WorkloadImpact + * + * @summary create a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadAvailability_Create.json + */ +async function reportingAvailabilityRelatedImpact(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.create("impact-002", { + properties: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservercontext", + startDateTime: new Date("2022-06-15T05:59:46.6517821Z"), + impactDescription: "read calls failed", + impactCategory: "Availability", + workload: { context: "webapp/scenario1", toolset: "Other" }, + clientIncidentDetails: { + clientIncidentId: "AA123", + clientIncidentSource: "Jira", + }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to create a WorkloadImpact + * + * @summary create a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadConnectivityImpact_Create.json + */ +async function reportingAConnectivityImpact(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.create("impact-001", { + properties: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservercontext", + startDateTime: new Date("2022-06-15T05:59:46.6517821Z"), + impactDescription: "conection failure", + impactCategory: "Resource.Connectivity", + connectivity: { + protocol: "TCP", + port: 1443, + source: { + azureResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceSub/providers/Microsoft.compute/virtualmachines/vm1", + }, + target: { + azureResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceSub/providers/Microsoft.compute/virtualmachines/vm2", + }, + }, + workload: { context: "webapp/scenario1", toolset: "Other" }, + clientIncidentDetails: { + clientIncidentId: "AA123", + clientIncidentSource: "Jira", + }, + }, + }); + console.log(result); +} + +/** + * This sample demonstrates how to create a WorkloadImpact + * + * @summary create a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadPerformance_Create.json + */ +async function reportingPerformanceRelatedImpact(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.create("impact-002", { + properties: { + impactedResourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-rg/providers/Microsoft.Sql/sqlserver/dbservercontext", + startDateTime: new Date("2022-06-15T05:59:46.6517821Z"), + impactDescription: "high cpu utilization", + impactCategory: "Resource.Performance", + workload: { context: "webapp/scenario1", toolset: "Other" }, + performance: [{ metricName: "CPU", actual: 90, expected: 60 }], + clientIncidentDetails: { + clientIncidentId: "AA123", + clientIncidentSource: "Jira", + }, + }, + }); + console.log(result); +} + +async function main(): Promise { + await reportingArmOperationFailure(); + await reportingAvailabilityRelatedImpact(); + await reportingAConnectivityImpact(); + await reportingPerformanceRelatedImpact(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsDeleteSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsDeleteSample.ts new file mode 100644 index 000000000000..a9f0195f563d --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a WorkloadImpact + * + * @summary delete a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadImpact_Delete.json + */ +async function deleteWorkloadImpactResourceByNameExample(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + await client.workloadImpacts.delete("impact-001"); +} + +async function main(): Promise { + await deleteWorkloadImpactResourceByNameExample(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsGetSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsGetSample.ts new file mode 100644 index 000000000000..1c9a19868a9e --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a WorkloadImpact + * + * @summary get a WorkloadImpact + * x-ms-original-file: 2024-05-01-preview/WorkloadImpact_Get.json + */ +async function getWorkloadImpactResourceByNameExample(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const result = await client.workloadImpacts.get("impact-001"); + console.log(result); +} + +async function main(): Promise { + await getWorkloadImpactResourceByNameExample(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsListBySubscriptionSample.ts b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsListBySubscriptionSample.ts new file mode 100644 index 000000000000..4e6c9425f7bb --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/src/workloadImpactsWorkloadImpactsListBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "@azure/arm-impactreporting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list WorkloadImpact resources by subscription ID + * + * @summary list WorkloadImpact resources by subscription ID + * x-ms-original-file: 2024-05-01-preview/WorkloadImpacts_ListBySubscription.json + */ +async function listWorkloadImpactResourcesBySubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.workloadImpacts.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listWorkloadImpactResourcesBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/tsconfig.json b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/tsconfig.json new file mode 100644 index 000000000000..400db87cf648 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/samples/v1-beta/typescript/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "ES2023", + "module": "commonjs", + "lib": [], + "importHelpers": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node10", + "esModuleInterop": true, + "outDir": "./dist", + "resolveJsonModule": true + }, + "include": [ + "./src" + ] +} diff --git a/sdk/impactreporting/arm-impactreporting/src/api/connectors/index.ts b/sdk/impactreporting/arm-impactreporting/src/api/connectors/index.ts new file mode 100644 index 000000000000..5129690fd8c5 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/api/connectors/index.ts @@ -0,0 +1,264 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ImpactContext as Client, + ConnectorsCreateOrUpdateOptionalParams, + ConnectorsDeleteOptionalParams, + ConnectorsGetOptionalParams, + ConnectorsListBySubscriptionOptionalParams, + ConnectorsUpdateOptionalParams, +} from "../index.js"; +import { + Connector, + connectorSerializer, + connectorDeserializer, + errorResponseDeserializer, + ConnectorUpdate, + connectorUpdateSerializer, + _ConnectorListResult, + _connectorListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +export function _connectorsListBySubscriptionSend( + context: Client, + options: ConnectorsListBySubscriptionOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/connectors", + context.subscriptionId, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _connectorsListBySubscriptionDeserialize( + result: PathUncheckedResponse, +): Promise<_ConnectorListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _connectorListResultDeserializer(result.body); +} + +/** List Connector resources by subscription ID */ +export function connectorsListBySubscription( + context: Client, + options: ConnectorsListBySubscriptionOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _connectorsListBySubscriptionSend(context, options), + _connectorsListBySubscriptionDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _connectorsDeleteSend( + context: Client, + connectorName: string, + options: ConnectorsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/connectors/{connectorName}", + context.subscriptionId, + connectorName, + ) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _connectorsDeleteDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete a Connector */ +export async function connectorsDelete( + context: Client, + connectorName: string, + options: ConnectorsDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _connectorsDeleteSend(context, connectorName, options); + return _connectorsDeleteDeserialize(result); +} + +export function _connectorsUpdateSend( + context: Client, + connectorName: string, + properties: ConnectorUpdate, + options: ConnectorsUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/connectors/{connectorName}", + context.subscriptionId, + connectorName, + ) + .patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: connectorUpdateSerializer(properties), + }); +} + +export async function _connectorsUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return connectorDeserializer(result.body); +} + +/** Update a Connector */ +export async function connectorsUpdate( + context: Client, + connectorName: string, + properties: ConnectorUpdate, + options: ConnectorsUpdateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _connectorsUpdateSend(context, connectorName, properties, options); + return _connectorsUpdateDeserialize(result); +} + +export function _connectorsCreateOrUpdateSend( + context: Client, + connectorName: string, + resource: Connector, + options: ConnectorsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/connectors/{connectorName}", + context.subscriptionId, + connectorName, + ) + .put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: connectorSerializer(resource), + }); +} + +export async function _connectorsCreateOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return connectorDeserializer(result.body); +} + +/** Create a Connector */ +export function connectorsCreateOrUpdate( + context: Client, + connectorName: string, + resource: Connector, + options: ConnectorsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): PollerLike, Connector> { + return getLongRunningPoller(context, _connectorsCreateOrUpdateDeserialize, ["200", "201"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _connectorsCreateOrUpdateSend(context, connectorName, resource, options), + resourceLocationConfig: "azure-async-operation", + }) as PollerLike, Connector>; +} + +export function _connectorsGetSend( + context: Client, + connectorName: string, + options: ConnectorsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/connectors/{connectorName}", + context.subscriptionId, + connectorName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _connectorsGetDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return connectorDeserializer(result.body); +} + +/** Get a Connector */ +export async function connectorsGet( + context: Client, + connectorName: string, + options: ConnectorsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _connectorsGetSend(context, connectorName, options); + return _connectorsGetDeserialize(result); +} diff --git a/sdk/impactreporting/arm-impactreporting/src/api/impactCategories/index.ts b/sdk/impactreporting/arm-impactreporting/src/api/impactCategories/index.ts new file mode 100644 index 000000000000..2e508c6f7d61 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/api/impactCategories/index.ts @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ImpactContext as Client, + ImpactCategoriesGetOptionalParams, + ImpactCategoriesListBySubscriptionOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + ImpactCategory, + impactCategoryDeserializer, + _ImpactCategoryListResult, + _impactCategoryListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _impactCategoriesListBySubscriptionSend( + context: Client, + resourceType: string, + options: ImpactCategoriesListBySubscriptionOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/impactCategories", + context.subscriptionId, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { + "api-version": context.apiVersion, + categoryName: options?.categoryName, + resourceType: resourceType, + }, + }); +} + +export async function _impactCategoriesListBySubscriptionDeserialize( + result: PathUncheckedResponse, +): Promise<_ImpactCategoryListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _impactCategoryListResultDeserializer(result.body); +} + +/** List ImpactCategory resources by subscription */ +export function impactCategoriesListBySubscription( + context: Client, + resourceType: string, + options: ImpactCategoriesListBySubscriptionOptionalParams = { + requestOptions: {}, + }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _impactCategoriesListBySubscriptionSend(context, resourceType, options), + _impactCategoriesListBySubscriptionDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _impactCategoriesGetSend( + context: Client, + impactCategoryName: string, + options: ImpactCategoriesGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/impactCategories/{impactCategoryName}", + context.subscriptionId, + impactCategoryName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _impactCategoriesGetDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return impactCategoryDeserializer(result.body); +} + +/** Get a ImpactCategory */ +export async function impactCategoriesGet( + context: Client, + impactCategoryName: string, + options: ImpactCategoriesGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _impactCategoriesGetSend(context, impactCategoryName, options); + return _impactCategoriesGetDeserialize(result); +} diff --git a/sdk/impactreporting/arm-impactreporting/src/api/impactContext.ts b/sdk/impactreporting/arm-impactreporting/src/api/impactContext.ts new file mode 100644 index 000000000000..6fce5f6d3188 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/api/impactContext.ts @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { logger } from "../logger.js"; +import { KnownVersions } from "../models/models.js"; +import { Client, ClientOptions, getClient } from "@azure-rest/core-client"; +import { TokenCredential } from "@azure/core-auth"; + +export interface ImpactContext extends Client { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion: string; + /** The ID of the target subscription. The value must be an UUID. */ + subscriptionId: string; +} + +/** Optional parameters for the client. */ +export interface ImpactClientOptionalParams extends ClientOptions { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion?: string; +} + +export function createImpact( + credential: TokenCredential, + subscriptionId: string, + options: ImpactClientOptionalParams = {}, +): ImpactContext { + const endpointUrl = options.endpoint ?? options.baseUrl ?? "https://management.azure.com"; + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentInfo = `azsdk-js-arm-impactreporting/1.0.0-beta.1`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}` + : `azsdk-js-api ${userAgentInfo}`; + const { apiVersion: _, ...updatedOptions } = { + ...options, + userAgentOptions: { userAgentPrefix }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + credentials: { + scopes: options.credentials?.scopes ?? [`${endpointUrl}/.default`], + }, + }; + const clientContext = getClient(endpointUrl, credential, updatedOptions); + clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + const apiVersion = options.apiVersion ?? "2024-05-01-preview"; + clientContext.pipeline.addPolicy({ + name: "ClientApiVersionPolicy", + sendRequest: (req, next) => { + // Use the apiVersion defined in request url directly + // Append one if there is no apiVersion and we have one at client options + const url = new URL(req.url); + if (!url.searchParams.get("api-version")) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + + return next(req); + }, + }); + return { ...clientContext, apiVersion, subscriptionId } as ImpactContext; +} diff --git a/sdk/impactreporting/arm-impactreporting/src/api/index.ts b/sdk/impactreporting/arm-impactreporting/src/api/index.ts new file mode 100644 index 000000000000..28412b69f349 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/api/index.ts @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { createImpact, ImpactContext, ImpactClientOptionalParams } from "./impactContext.js"; +export { + ConnectorsListBySubscriptionOptionalParams, + ConnectorsDeleteOptionalParams, + ConnectorsUpdateOptionalParams, + ConnectorsCreateOrUpdateOptionalParams, + ConnectorsGetOptionalParams, + InsightsDeleteOptionalParams, + InsightsCreateOptionalParams, + InsightsListBySubscriptionOptionalParams, + InsightsGetOptionalParams, + ImpactCategoriesListBySubscriptionOptionalParams, + ImpactCategoriesGetOptionalParams, + WorkloadImpactsListBySubscriptionOptionalParams, + WorkloadImpactsDeleteOptionalParams, + WorkloadImpactsGetOptionalParams, + WorkloadImpactsCreateOptionalParams, + OperationsListOptionalParams, +} from "./options.js"; +export { + connectorsListBySubscription, + connectorsDelete, + connectorsUpdate, + connectorsCreateOrUpdate, + connectorsGet, +} from "./connectors/index.js"; +export { + impactCategoriesListBySubscription, + impactCategoriesGet, +} from "./impactCategories/index.js"; +export { + insightsDelete, + insightsCreate, + insightsListBySubscription, + insightsGet, +} from "./insights/index.js"; +export { operationsList } from "./operations/index.js"; +export { + workloadImpactsListBySubscription, + workloadImpactsDelete, + workloadImpactsGet, + workloadImpactsCreate, +} from "./workloadImpacts/index.js"; diff --git a/sdk/impactreporting/arm-impactreporting/src/api/insights/index.ts b/sdk/impactreporting/arm-impactreporting/src/api/insights/index.ts new file mode 100644 index 000000000000..5e22bfc024e2 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/api/insights/index.ts @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ImpactContext as Client, + InsightsCreateOptionalParams, + InsightsDeleteOptionalParams, + InsightsGetOptionalParams, + InsightsListBySubscriptionOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + Insight, + insightSerializer, + insightDeserializer, + _InsightListResult, + _insightListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _insightsDeleteSend( + context: Client, + workloadImpactName: string, + insightName: string, + options: InsightsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/workloadImpacts/{workloadImpactName}/insights/{insightName}", + context.subscriptionId, + workloadImpactName, + insightName, + ) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _insightsDeleteDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete Insight resource, This is Admin only operation */ +export async function insightsDelete( + context: Client, + workloadImpactName: string, + insightName: string, + options: InsightsDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _insightsDeleteSend(context, workloadImpactName, insightName, options); + return _insightsDeleteDeserialize(result); +} + +export function _insightsCreateSend( + context: Client, + workloadImpactName: string, + insightName: string, + resource: Insight, + options: InsightsCreateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/workloadImpacts/{workloadImpactName}/insights/{insightName}", + context.subscriptionId, + workloadImpactName, + insightName, + ) + .put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: insightSerializer(resource), + }); +} + +export async function _insightsCreateDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return insightDeserializer(result.body); +} + +/** Create Insight resource, This is Admin only operation */ +export async function insightsCreate( + context: Client, + workloadImpactName: string, + insightName: string, + resource: Insight, + options: InsightsCreateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _insightsCreateSend( + context, + workloadImpactName, + insightName, + resource, + options, + ); + return _insightsCreateDeserialize(result); +} + +export function _insightsListBySubscriptionSend( + context: Client, + workloadImpactName: string, + options: InsightsListBySubscriptionOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/workloadImpacts/{workloadImpactName}/insights", + context.subscriptionId, + workloadImpactName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _insightsListBySubscriptionDeserialize( + result: PathUncheckedResponse, +): Promise<_InsightListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _insightListResultDeserializer(result.body); +} + +/** List Insight resources by workloadImpactName */ +export function insightsListBySubscription( + context: Client, + workloadImpactName: string, + options: InsightsListBySubscriptionOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _insightsListBySubscriptionSend(context, workloadImpactName, options), + _insightsListBySubscriptionDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _insightsGetSend( + context: Client, + workloadImpactName: string, + insightName: string, + options: InsightsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/workloadImpacts/{workloadImpactName}/insights/{insightName}", + context.subscriptionId, + workloadImpactName, + insightName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _insightsGetDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return insightDeserializer(result.body); +} + +/** Get Insight resources by workloadImpactName and insightName */ +export async function insightsGet( + context: Client, + workloadImpactName: string, + insightName: string, + options: InsightsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _insightsGetSend(context, workloadImpactName, insightName, options); + return _insightsGetDeserialize(result); +} diff --git a/sdk/impactreporting/arm-impactreporting/src/api/operations/index.ts b/sdk/impactreporting/arm-impactreporting/src/api/operations/index.ts new file mode 100644 index 000000000000..802695eeea1a --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/api/operations/index.ts @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactContext as Client, OperationsListOptionalParams } from "../index.js"; +import { + errorResponseDeserializer, + _OperationListResult, + _operationListResultDeserializer, + Operation, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _operationsListSend( + context: Client, + options: OperationsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context.path("/providers/Microsoft.Impact/operations").get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _operationsListDeserialize( + result: PathUncheckedResponse, +): Promise<_OperationListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _operationListResultDeserializer(result.body); +} + +/** List the operations for the provider */ +export function operationsList( + context: Client, + options: OperationsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _operationsListSend(context, options), + _operationsListDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} diff --git a/sdk/impactreporting/arm-impactreporting/src/api/options.ts b/sdk/impactreporting/arm-impactreporting/src/api/options.ts new file mode 100644 index 000000000000..4770b2049724 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/api/options.ts @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface ConnectorsListBySubscriptionOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface ConnectorsDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface ConnectorsUpdateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface ConnectorsCreateOrUpdateOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface ConnectorsGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface InsightsDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface InsightsCreateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface InsightsListBySubscriptionOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface InsightsGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface ImpactCategoriesListBySubscriptionOptionalParams extends OperationOptions { + /** Filter by category name */ + categoryName?: string; +} + +/** Optional parameters. */ +export interface ImpactCategoriesGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface WorkloadImpactsListBySubscriptionOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface WorkloadImpactsDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface WorkloadImpactsGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface WorkloadImpactsCreateOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface OperationsListOptionalParams extends OperationOptions {} diff --git a/sdk/impactreporting/arm-impactreporting/src/api/workloadImpacts/index.ts b/sdk/impactreporting/arm-impactreporting/src/api/workloadImpacts/index.ts new file mode 100644 index 000000000000..6e1a7fed039f --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/api/workloadImpacts/index.ts @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + ImpactContext as Client, + WorkloadImpactsCreateOptionalParams, + WorkloadImpactsDeleteOptionalParams, + WorkloadImpactsGetOptionalParams, + WorkloadImpactsListBySubscriptionOptionalParams, +} from "../index.js"; +import { + errorResponseDeserializer, + WorkloadImpact, + workloadImpactSerializer, + workloadImpactDeserializer, + _WorkloadImpactListResult, + _workloadImpactListResultDeserializer, +} from "../../models/models.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +export function _workloadImpactsListBySubscriptionSend( + context: Client, + options: WorkloadImpactsListBySubscriptionOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/workloadImpacts", + context.subscriptionId, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _workloadImpactsListBySubscriptionDeserialize( + result: PathUncheckedResponse, +): Promise<_WorkloadImpactListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _workloadImpactListResultDeserializer(result.body); +} + +/** List WorkloadImpact resources by subscription ID */ +export function workloadImpactsListBySubscription( + context: Client, + options: WorkloadImpactsListBySubscriptionOptionalParams = { + requestOptions: {}, + }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _workloadImpactsListBySubscriptionSend(context, options), + _workloadImpactsListBySubscriptionDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _workloadImpactsDeleteSend( + context: Client, + workloadImpactName: string, + options: WorkloadImpactsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/workloadImpacts/{workloadImpactName}", + context.subscriptionId, + workloadImpactName, + ) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _workloadImpactsDeleteDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "204"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete a WorkloadImpact */ +export async function workloadImpactsDelete( + context: Client, + workloadImpactName: string, + options: WorkloadImpactsDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _workloadImpactsDeleteSend(context, workloadImpactName, options); + return _workloadImpactsDeleteDeserialize(result); +} + +export function _workloadImpactsGetSend( + context: Client, + workloadImpactName: string, + options: WorkloadImpactsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/workloadImpacts/{workloadImpactName}", + context.subscriptionId, + workloadImpactName, + ) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + }); +} + +export async function _workloadImpactsGetDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return workloadImpactDeserializer(result.body); +} + +/** Get a WorkloadImpact */ +export async function workloadImpactsGet( + context: Client, + workloadImpactName: string, + options: WorkloadImpactsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _workloadImpactsGetSend(context, workloadImpactName, options); + return _workloadImpactsGetDeserialize(result); +} + +export function _workloadImpactsCreateSend( + context: Client, + workloadImpactName: string, + resource: WorkloadImpact, + options: WorkloadImpactsCreateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/providers/Microsoft.Impact/workloadImpacts/{workloadImpactName}", + context.subscriptionId, + workloadImpactName, + ) + .put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + queryParameters: { "api-version": context.apiVersion }, + body: workloadImpactSerializer(resource), + }); +} + +export async function _workloadImpactsCreateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return workloadImpactDeserializer(result.body); +} + +/** Create a WorkloadImpact */ +export function workloadImpactsCreate( + context: Client, + workloadImpactName: string, + resource: WorkloadImpact, + options: WorkloadImpactsCreateOptionalParams = { requestOptions: {} }, +): PollerLike, WorkloadImpact> { + return getLongRunningPoller(context, _workloadImpactsCreateDeserialize, ["200", "201"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _workloadImpactsCreateSend(context, workloadImpactName, resource, options), + resourceLocationConfig: "azure-async-operation", + }) as PollerLike, WorkloadImpact>; +} diff --git a/sdk/impactreporting/arm-impactreporting/src/classic/connectors/index.ts b/sdk/impactreporting/arm-impactreporting/src/classic/connectors/index.ts new file mode 100644 index 000000000000..87f769230d47 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/classic/connectors/index.ts @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactContext } from "../../api/impactContext.js"; +import { + connectorsListBySubscription, + connectorsDelete, + connectorsUpdate, + connectorsCreateOrUpdate, + connectorsGet, +} from "../../api/connectors/index.js"; +import { Connector, ConnectorUpdate } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { PollerLike, OperationState } from "@azure/core-lro"; +import { + ConnectorsListBySubscriptionOptionalParams, + ConnectorsDeleteOptionalParams, + ConnectorsUpdateOptionalParams, + ConnectorsCreateOrUpdateOptionalParams, + ConnectorsGetOptionalParams, +} from "../../api/options.js"; + +/** Interface representing a Connectors operations. */ +export interface ConnectorsOperations { + /** List Connector resources by subscription ID */ + listBySubscription: ( + options?: ConnectorsListBySubscriptionOptionalParams, + ) => PagedAsyncIterableIterator; + /** Delete a Connector */ + delete: (connectorName: string, options?: ConnectorsDeleteOptionalParams) => Promise; + /** Update a Connector */ + update: ( + connectorName: string, + properties: ConnectorUpdate, + options?: ConnectorsUpdateOptionalParams, + ) => Promise; + /** Create a Connector */ + createOrUpdate: ( + connectorName: string, + resource: Connector, + options?: ConnectorsCreateOrUpdateOptionalParams, + ) => PollerLike, Connector>; + /** Get a Connector */ + get: (connectorName: string, options?: ConnectorsGetOptionalParams) => Promise; +} + +function _getConnectors(context: ImpactContext) { + return { + listBySubscription: (options?: ConnectorsListBySubscriptionOptionalParams) => + connectorsListBySubscription(context, options), + delete: (connectorName: string, options?: ConnectorsDeleteOptionalParams) => + connectorsDelete(context, connectorName, options), + update: ( + connectorName: string, + properties: ConnectorUpdate, + options?: ConnectorsUpdateOptionalParams, + ) => connectorsUpdate(context, connectorName, properties, options), + createOrUpdate: ( + connectorName: string, + resource: Connector, + options?: ConnectorsCreateOrUpdateOptionalParams, + ) => connectorsCreateOrUpdate(context, connectorName, resource, options), + get: (connectorName: string, options?: ConnectorsGetOptionalParams) => + connectorsGet(context, connectorName, options), + }; +} + +export function _getConnectorsOperations(context: ImpactContext): ConnectorsOperations { + return { + ..._getConnectors(context), + }; +} diff --git a/sdk/impactreporting/arm-impactreporting/src/classic/impactCategories/index.ts b/sdk/impactreporting/arm-impactreporting/src/classic/impactCategories/index.ts new file mode 100644 index 000000000000..8dbc30f3d5fc --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/classic/impactCategories/index.ts @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactContext } from "../../api/impactContext.js"; +import { + impactCategoriesListBySubscription, + impactCategoriesGet, +} from "../../api/impactCategories/index.js"; +import { ImpactCategory } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { + ImpactCategoriesListBySubscriptionOptionalParams, + ImpactCategoriesGetOptionalParams, +} from "../../api/options.js"; + +/** Interface representing a ImpactCategories operations. */ +export interface ImpactCategoriesOperations { + /** List ImpactCategory resources by subscription */ + listBySubscription: ( + resourceType: string, + options?: ImpactCategoriesListBySubscriptionOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get a ImpactCategory */ + get: ( + impactCategoryName: string, + options?: ImpactCategoriesGetOptionalParams, + ) => Promise; +} + +function _getImpactCategories(context: ImpactContext) { + return { + listBySubscription: ( + resourceType: string, + options?: ImpactCategoriesListBySubscriptionOptionalParams, + ) => impactCategoriesListBySubscription(context, resourceType, options), + get: (impactCategoryName: string, options?: ImpactCategoriesGetOptionalParams) => + impactCategoriesGet(context, impactCategoryName, options), + }; +} + +export function _getImpactCategoriesOperations(context: ImpactContext): ImpactCategoriesOperations { + return { + ..._getImpactCategories(context), + }; +} diff --git a/sdk/impactreporting/arm-impactreporting/src/classic/index.ts b/sdk/impactreporting/arm-impactreporting/src/classic/index.ts new file mode 100644 index 000000000000..b1b13b1c430b --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/classic/index.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { ConnectorsOperations } from "./connectors/index.js"; +export { ImpactCategoriesOperations } from "./impactCategories/index.js"; +export { InsightsOperations } from "./insights/index.js"; +export { OperationsOperations } from "./operations/index.js"; +export { WorkloadImpactsOperations } from "./workloadImpacts/index.js"; diff --git a/sdk/impactreporting/arm-impactreporting/src/classic/insights/index.ts b/sdk/impactreporting/arm-impactreporting/src/classic/insights/index.ts new file mode 100644 index 000000000000..72217e42b836 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/classic/insights/index.ts @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactContext } from "../../api/impactContext.js"; +import { + insightsDelete, + insightsCreate, + insightsListBySubscription, + insightsGet, +} from "../../api/insights/index.js"; +import { + InsightsDeleteOptionalParams, + InsightsCreateOptionalParams, + InsightsListBySubscriptionOptionalParams, + InsightsGetOptionalParams, +} from "../../api/options.js"; +import { Insight } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Insights operations. */ +export interface InsightsOperations { + /** Delete Insight resource, This is Admin only operation */ + delete: ( + workloadImpactName: string, + insightName: string, + options?: InsightsDeleteOptionalParams, + ) => Promise; + /** Create Insight resource, This is Admin only operation */ + create: ( + workloadImpactName: string, + insightName: string, + resource: Insight, + options?: InsightsCreateOptionalParams, + ) => Promise; + /** List Insight resources by workloadImpactName */ + listBySubscription: ( + workloadImpactName: string, + options?: InsightsListBySubscriptionOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get Insight resources by workloadImpactName and insightName */ + get: ( + workloadImpactName: string, + insightName: string, + options?: InsightsGetOptionalParams, + ) => Promise; +} + +function _getInsights(context: ImpactContext) { + return { + delete: ( + workloadImpactName: string, + insightName: string, + options?: InsightsDeleteOptionalParams, + ) => insightsDelete(context, workloadImpactName, insightName, options), + create: ( + workloadImpactName: string, + insightName: string, + resource: Insight, + options?: InsightsCreateOptionalParams, + ) => insightsCreate(context, workloadImpactName, insightName, resource, options), + listBySubscription: ( + workloadImpactName: string, + options?: InsightsListBySubscriptionOptionalParams, + ) => insightsListBySubscription(context, workloadImpactName, options), + get: (workloadImpactName: string, insightName: string, options?: InsightsGetOptionalParams) => + insightsGet(context, workloadImpactName, insightName, options), + }; +} + +export function _getInsightsOperations(context: ImpactContext): InsightsOperations { + return { + ..._getInsights(context), + }; +} diff --git a/sdk/impactreporting/arm-impactreporting/src/classic/operations/index.ts b/sdk/impactreporting/arm-impactreporting/src/classic/operations/index.ts new file mode 100644 index 000000000000..3b0ff4b255de --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/classic/operations/index.ts @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactContext } from "../../api/impactContext.js"; +import { operationsList } from "../../api/operations/index.js"; +import { OperationsListOptionalParams } from "../../api/options.js"; +import { Operation } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Operations operations. */ +export interface OperationsOperations { + /** List the operations for the provider */ + list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator; +} + +function _getOperations(context: ImpactContext) { + return { + list: (options?: OperationsListOptionalParams) => operationsList(context, options), + }; +} + +export function _getOperationsOperations(context: ImpactContext): OperationsOperations { + return { + ..._getOperations(context), + }; +} diff --git a/sdk/impactreporting/arm-impactreporting/src/classic/workloadImpacts/index.ts b/sdk/impactreporting/arm-impactreporting/src/classic/workloadImpacts/index.ts new file mode 100644 index 000000000000..cf6f4b205af5 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/classic/workloadImpacts/index.ts @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactContext } from "../../api/impactContext.js"; +import { + WorkloadImpactsListBySubscriptionOptionalParams, + WorkloadImpactsDeleteOptionalParams, + WorkloadImpactsGetOptionalParams, + WorkloadImpactsCreateOptionalParams, +} from "../../api/options.js"; +import { + workloadImpactsListBySubscription, + workloadImpactsDelete, + workloadImpactsGet, + workloadImpactsCreate, +} from "../../api/workloadImpacts/index.js"; +import { WorkloadImpact } from "../../models/models.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +/** Interface representing a WorkloadImpacts operations. */ +export interface WorkloadImpactsOperations { + /** List WorkloadImpact resources by subscription ID */ + listBySubscription: ( + options?: WorkloadImpactsListBySubscriptionOptionalParams, + ) => PagedAsyncIterableIterator; + /** Delete a WorkloadImpact */ + delete: ( + workloadImpactName: string, + options?: WorkloadImpactsDeleteOptionalParams, + ) => Promise; + /** Get a WorkloadImpact */ + get: ( + workloadImpactName: string, + options?: WorkloadImpactsGetOptionalParams, + ) => Promise; + /** Create a WorkloadImpact */ + create: ( + workloadImpactName: string, + resource: WorkloadImpact, + options?: WorkloadImpactsCreateOptionalParams, + ) => PollerLike, WorkloadImpact>; +} + +function _getWorkloadImpacts(context: ImpactContext) { + return { + listBySubscription: (options?: WorkloadImpactsListBySubscriptionOptionalParams) => + workloadImpactsListBySubscription(context, options), + delete: (workloadImpactName: string, options?: WorkloadImpactsDeleteOptionalParams) => + workloadImpactsDelete(context, workloadImpactName, options), + get: (workloadImpactName: string, options?: WorkloadImpactsGetOptionalParams) => + workloadImpactsGet(context, workloadImpactName, options), + create: ( + workloadImpactName: string, + resource: WorkloadImpact, + options?: WorkloadImpactsCreateOptionalParams, + ) => workloadImpactsCreate(context, workloadImpactName, resource, options), + }; +} + +export function _getWorkloadImpactsOperations(context: ImpactContext): WorkloadImpactsOperations { + return { + ..._getWorkloadImpacts(context), + }; +} diff --git a/sdk/impactreporting/arm-impactreporting/src/impactClient.ts b/sdk/impactreporting/arm-impactreporting/src/impactClient.ts new file mode 100644 index 000000000000..e2ebbed0cc7b --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/impactClient.ts @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { _getConnectorsOperations, ConnectorsOperations } from "./classic/connectors/index.js"; +import { _getInsightsOperations, InsightsOperations } from "./classic/insights/index.js"; +import { + _getImpactCategoriesOperations, + ImpactCategoriesOperations, +} from "./classic/impactCategories/index.js"; +import { + _getWorkloadImpactsOperations, + WorkloadImpactsOperations, +} from "./classic/workloadImpacts/index.js"; +import { _getOperationsOperations, OperationsOperations } from "./classic/operations/index.js"; +import { createImpact, ImpactContext, ImpactClientOptionalParams } from "./api/index.js"; +import { Pipeline } from "@azure/core-rest-pipeline"; +import { TokenCredential } from "@azure/core-auth"; + +export { ImpactClientOptionalParams } from "./api/impactContext.js"; + +export class ImpactClient { + private _client: ImpactContext; + /** The pipeline used by this client to make requests */ + public readonly pipeline: Pipeline; + + constructor( + credential: TokenCredential, + subscriptionId: string, + options: ImpactClientOptionalParams = {}, + ) { + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-client` + : `azsdk-js-client`; + this._client = createImpact(credential, subscriptionId, { + ...options, + userAgentOptions: { userAgentPrefix }, + }); + this.pipeline = this._client.pipeline; + this.connectors = _getConnectorsOperations(this._client); + this.insights = _getInsightsOperations(this._client); + this.impactCategories = _getImpactCategoriesOperations(this._client); + this.workloadImpacts = _getWorkloadImpactsOperations(this._client); + this.operations = _getOperationsOperations(this._client); + } + + /** The operation groups for connectors */ + public readonly connectors: ConnectorsOperations; + /** The operation groups for insights */ + public readonly insights: InsightsOperations; + /** The operation groups for impactCategories */ + public readonly impactCategories: ImpactCategoriesOperations; + /** The operation groups for workloadImpacts */ + public readonly workloadImpacts: WorkloadImpactsOperations; + /** The operation groups for operations */ + public readonly operations: OperationsOperations; +} diff --git a/sdk/impactreporting/arm-impactreporting/src/index.ts b/sdk/impactreporting/arm-impactreporting/src/index.ts new file mode 100644 index 000000000000..e8779624e675 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/index.ts @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + PageSettings, + ContinuablePage, + PagedAsyncIterableIterator, +} from "./static-helpers/pagingHelpers.js"; + +export { ImpactClient } from "./impactClient.js"; +export { restorePoller, RestorePollerOptions } from "./restorePollerHelpers.js"; +export { + Connector, + ConnectorProperties, + KnownProvisioningState, + ProvisioningState, + KnownPlatform, + Platform, + ProxyResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + ConnectorUpdate, + ConnectorUpdateProperties, + Insight, + InsightProperties, + Content, + ImpactDetails, + ImpactCategory, + ImpactCategoryProperties, + RequiredImpactProperties, + WorkloadImpact, + WorkloadImpactProperties, + Performance, + ExpectedValueRange, + KnownMetricUnit, + MetricUnit, + Connectivity, + KnownProtocol, + Protocol, + SourceOrTarget, + ErrorDetailProperties, + Workload, + KnownToolset, + Toolset, + KnownConfidenceLevel, + ConfidenceLevel, + ClientIncidentDetails, + KnownIncidentSource, + IncidentSource, + Operation, + OperationDisplay, + KnownOrigin, + Origin, + KnownActionType, + ActionType, + KnownVersions, +} from "./models/index.js"; +export { + ImpactClientOptionalParams, + ConnectorsListBySubscriptionOptionalParams, + ConnectorsDeleteOptionalParams, + ConnectorsUpdateOptionalParams, + ConnectorsCreateOrUpdateOptionalParams, + ConnectorsGetOptionalParams, + InsightsDeleteOptionalParams, + InsightsCreateOptionalParams, + InsightsListBySubscriptionOptionalParams, + InsightsGetOptionalParams, + ImpactCategoriesListBySubscriptionOptionalParams, + ImpactCategoriesGetOptionalParams, + WorkloadImpactsListBySubscriptionOptionalParams, + WorkloadImpactsDeleteOptionalParams, + WorkloadImpactsGetOptionalParams, + WorkloadImpactsCreateOptionalParams, + OperationsListOptionalParams, +} from "./api/index.js"; +export { + ConnectorsOperations, + ImpactCategoriesOperations, + InsightsOperations, + OperationsOperations, + WorkloadImpactsOperations, +} from "./classic/index.js"; +export { PageSettings, ContinuablePage, PagedAsyncIterableIterator }; diff --git a/sdk/impactreporting/arm-impactreporting/src/logger.ts b/sdk/impactreporting/arm-impactreporting/src/logger.ts new file mode 100644 index 000000000000..e896b1670063 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/logger.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createClientLogger } from "@azure/logger"; +export const logger = createClientLogger("arm-impactreporting"); diff --git a/sdk/impactreporting/arm-impactreporting/src/models/index.ts b/sdk/impactreporting/arm-impactreporting/src/models/index.ts new file mode 100644 index 000000000000..f27031594f2a --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/models/index.ts @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + Connector, + ConnectorProperties, + KnownProvisioningState, + ProvisioningState, + KnownPlatform, + Platform, + ProxyResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + ConnectorUpdate, + ConnectorUpdateProperties, + Insight, + InsightProperties, + Content, + ImpactDetails, + ImpactCategory, + ImpactCategoryProperties, + RequiredImpactProperties, + WorkloadImpact, + WorkloadImpactProperties, + Performance, + ExpectedValueRange, + KnownMetricUnit, + MetricUnit, + Connectivity, + KnownProtocol, + Protocol, + SourceOrTarget, + ErrorDetailProperties, + Workload, + KnownToolset, + Toolset, + KnownConfidenceLevel, + ConfidenceLevel, + ClientIncidentDetails, + KnownIncidentSource, + IncidentSource, + Operation, + OperationDisplay, + KnownOrigin, + Origin, + KnownActionType, + ActionType, + KnownVersions, +} from "./models.js"; diff --git a/sdk/impactreporting/arm-impactreporting/src/models/models.ts b/sdk/impactreporting/arm-impactreporting/src/models/models.ts new file mode 100644 index 000000000000..629869e75989 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/models/models.ts @@ -0,0 +1,1218 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** A connector is a resource that can be used to proactively report impacts against workloads in Azure to Microsoft. */ +export interface Connector extends ProxyResource { + /** The resource-specific properties for this resource. */ + properties?: ConnectorProperties; +} + +export function connectorSerializer(item: Connector): any { + return { + properties: !item["properties"] + ? item["properties"] + : connectorPropertiesSerializer(item["properties"]), + }; +} + +export function connectorDeserializer(item: any): Connector { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : connectorPropertiesDeserializer(item["properties"]), + }; +} + +/** Details of the Connector. */ +export interface ConnectorProperties { + /** Resource provisioning state. */ + readonly provisioningState?: ProvisioningState; + /** unique id of the connector. */ + readonly connectorId: string; + /** tenant id of this connector */ + readonly tenantId: string; + /** connector type */ + connectorType: Platform; + /** last run time stamp of this connector in UTC time zone */ + readonly lastRunTimeStamp: Date; +} + +export function connectorPropertiesSerializer(item: ConnectorProperties): any { + return { connectorType: item["connectorType"] }; +} + +export function connectorPropertiesDeserializer(item: any): ConnectorProperties { + return { + provisioningState: item["provisioningState"], + connectorId: item["connectorId"], + tenantId: item["tenantId"], + connectorType: item["connectorType"], + lastRunTimeStamp: new Date(item["lastRunTimeStamp"]), + }; +} + +/** Provisioning state of the resource. */ +export enum KnownProvisioningState { + /** Provisioning Succeeded */ + Succeeded = "Succeeded", + /** Provisioning Failed */ + Failed = "Failed", + /** Provisioning Canceled */ + Canceled = "Canceled", +} + +/** + * Provisioning state of the resource. \ + * {@link KnownProvisioningState} can be used interchangeably with ProvisioningState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Succeeded**: Provisioning Succeeded \ + * **Failed**: Provisioning Failed \ + * **Canceled**: Provisioning Canceled + */ +export type ProvisioningState = string; + +/** Enum for connector types */ +export enum KnownPlatform { + /** Type of Azure Monitor */ + AzureMonitor = "AzureMonitor", +} + +/** + * Enum for connector types \ + * {@link KnownPlatform} can be used interchangeably with Platform, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **AzureMonitor**: Type of Azure Monitor + */ +export type Platform = string; + +/** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */ +export interface ProxyResource extends Resource {} + +export function proxyResourceSerializer(item: ProxyResource): any { + return item; +} + +export function proxyResourceDeserializer(item: any): ProxyResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + }; +} + +/** Common fields that are returned in the response for all Azure Resource Manager resources */ +export interface Resource { + /** Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} */ + readonly id?: string; + /** The name of the resource */ + readonly name?: string; + /** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */ + readonly type?: string; + /** Azure Resource Manager metadata containing createdBy and modifiedBy information. */ + readonly systemData?: SystemData; +} + +export function resourceSerializer(item: Resource): any { + return item; +} + +export function resourceDeserializer(item: any): Resource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + }; +} + +/** Metadata pertaining to creation and last modification of the resource. */ +export interface SystemData { + /** The identity that created the resource. */ + createdBy?: string; + /** The type of identity that created the resource. */ + createdByType?: CreatedByType; + /** The timestamp of resource creation (UTC). */ + createdAt?: Date; + /** The identity that last modified the resource. */ + lastModifiedBy?: string; + /** The type of identity that last modified the resource. */ + lastModifiedByType?: CreatedByType; + /** The timestamp of resource last modification (UTC) */ + lastModifiedAt?: Date; +} + +export function systemDataDeserializer(item: any): SystemData { + return { + createdBy: item["createdBy"], + createdByType: item["createdByType"], + createdAt: !item["createdAt"] ? item["createdAt"] : new Date(item["createdAt"]), + lastModifiedBy: item["lastModifiedBy"], + lastModifiedByType: item["lastModifiedByType"], + lastModifiedAt: !item["lastModifiedAt"] + ? item["lastModifiedAt"] + : new Date(item["lastModifiedAt"]), + }; +} + +/** The kind of entity that created the resource. */ +export enum KnownCreatedByType { + /** The entity was created by a user. */ + User = "User", + /** The entity was created by an application. */ + Application = "Application", + /** The entity was created by a managed identity. */ + ManagedIdentity = "ManagedIdentity", + /** The entity was created by a key. */ + Key = "Key", +} + +/** + * The kind of entity that created the resource. \ + * {@link KnowncreatedByType} can be used interchangeably with createdByType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **User**: The entity was created by a user. \ + * **Application**: The entity was created by an application. \ + * **ManagedIdentity**: The entity was created by a managed identity. \ + * **Key**: The entity was created by a key. + */ +export type CreatedByType = string; + +/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. */ +export interface ErrorResponse { + /** The error object. */ + error?: ErrorDetail; +} + +export function errorResponseDeserializer(item: any): ErrorResponse { + return { + error: !item["error"] ? item["error"] : errorDetailDeserializer(item["error"]), + }; +} + +/** The error detail. */ +export interface ErrorDetail { + /** The error code. */ + readonly code?: string; + /** The error message. */ + readonly message?: string; + /** The error target. */ + readonly target?: string; + /** The error details. */ + readonly details?: ErrorDetail[]; + /** The error additional info. */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +export function errorDetailDeserializer(item: any): ErrorDetail { + return { + code: item["code"], + message: item["message"], + target: item["target"], + details: !item["details"] ? item["details"] : errorDetailArrayDeserializer(item["details"]), + additionalInfo: !item["additionalInfo"] + ? item["additionalInfo"] + : errorAdditionalInfoArrayDeserializer(item["additionalInfo"]), + }; +} + +export function errorDetailArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorDetailDeserializer(item); + }); +} + +export function errorAdditionalInfoArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorAdditionalInfoDeserializer(item); + }); +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** The additional info type. */ + readonly type?: string; + /** The additional info. */ + readonly info?: Record; +} + +export function errorAdditionalInfoDeserializer(item: any): ErrorAdditionalInfo { + return { + type: item["type"], + info: !item["info"] ? item["info"] : _errorAdditionalInfoInfoDeserializer(item["info"]), + }; +} + +/** model interface _ErrorAdditionalInfoInfo */ +export interface _ErrorAdditionalInfoInfo {} + +export function _errorAdditionalInfoInfoDeserializer(item: any): _ErrorAdditionalInfoInfo { + return item; +} + +/** The type used for update operations of the Connector. */ +export interface ConnectorUpdate { + /** The resource-specific properties for this resource. */ + properties?: ConnectorUpdateProperties; +} + +export function connectorUpdateSerializer(item: ConnectorUpdate): any { + return { + properties: !item["properties"] + ? item["properties"] + : connectorUpdatePropertiesSerializer(item["properties"]), + }; +} + +/** The updatable properties of the Connector. */ +export interface ConnectorUpdateProperties { + /** connector type */ + connectorType?: Platform; +} + +export function connectorUpdatePropertiesSerializer(item: ConnectorUpdateProperties): any { + return { connectorType: item["connectorType"] }; +} + +/** The response of a Connector list operation. */ +export interface _ConnectorListResult { + /** The Connector items on this page */ + value: Connector[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _connectorListResultDeserializer(item: any): _ConnectorListResult { + return { + value: connectorArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function connectorArraySerializer(result: Array): any[] { + return result.map((item) => { + return connectorSerializer(item); + }); +} + +export function connectorArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return connectorDeserializer(item); + }); +} + +/** Insight resource */ +export interface Insight extends ProxyResource { + /** The resource-specific properties for this resource. */ + properties?: InsightProperties; +} + +export function insightSerializer(item: Insight): any { + return { + properties: !item["properties"] + ? item["properties"] + : insightPropertiesSerializer(item["properties"]), + }; +} + +export function insightDeserializer(item: any): Insight { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : insightPropertiesDeserializer(item["properties"]), + }; +} + +/** Impact category properties. */ +export interface InsightProperties { + /** Resource provisioning state. */ + readonly provisioningState?: ProvisioningState; + /** category of the insight. */ + category: string; + /** status of the insight. example resolved, repaired, other. */ + status?: string; + /** Identifier of the event that has been correlated with this insight. This can be used to aggregate insights for the same event. */ + eventId?: string; + /** Identifier that can be used to group similar insights. */ + groupId?: string; + /** Contains title & description for the insight */ + content: Content; + /** Time of the event, which has been correlated the impact. */ + eventTime?: Date; + /** unique id of the insight. */ + insightUniqueId: string; + /** details of of the impact for which insight has been generated. */ + impact: ImpactDetails; + /** additional details of the insight. */ + additionalDetails?: Record; +} + +export function insightPropertiesSerializer(item: InsightProperties): any { + return { + category: item["category"], + status: item["status"], + eventId: item["eventId"], + groupId: item["groupId"], + content: contentSerializer(item["content"]), + eventTime: !item["eventTime"] ? item["eventTime"] : item["eventTime"].toISOString(), + insightUniqueId: item["insightUniqueId"], + impact: impactDetailsSerializer(item["impact"]), + additionalDetails: !item["additionalDetails"] + ? item["additionalDetails"] + : _insightPropertiesAdditionalDetailsSerializer(item["additionalDetails"]), + }; +} + +export function insightPropertiesDeserializer(item: any): InsightProperties { + return { + provisioningState: item["provisioningState"], + category: item["category"], + status: item["status"], + eventId: item["eventId"], + groupId: item["groupId"], + content: contentDeserializer(item["content"]), + eventTime: !item["eventTime"] ? item["eventTime"] : new Date(item["eventTime"]), + insightUniqueId: item["insightUniqueId"], + impact: impactDetailsDeserializer(item["impact"]), + additionalDetails: !item["additionalDetails"] + ? item["additionalDetails"] + : _insightPropertiesAdditionalDetailsDeserializer(item["additionalDetails"]), + }; +} + +/** Article details of the insight like title, description etc */ +export interface Content { + /** Title of the insight */ + title: string; + /** Description of the insight */ + description: string; +} + +export function contentSerializer(item: Content): any { + return { title: item["title"], description: item["description"] }; +} + +export function contentDeserializer(item: any): Content { + return { + title: item["title"], + description: item["description"], + }; +} + +/** details of of the impact for which insight has been generated. */ +export interface ImpactDetails { + /** List of impacted Azure resources. */ + impactedResourceId: string; + /** Time at which impact was started according to reported impact. */ + startTime: Date; + /** Time at which impact was ended according to reported impact. */ + endTime?: Date; + /** Azure Id of the impact. */ + impactId: string; +} + +export function impactDetailsSerializer(item: ImpactDetails): any { + return { + impactedResourceId: item["impactedResourceId"], + startTime: item["startTime"].toISOString(), + endTime: !item["endTime"] ? item["endTime"] : item["endTime"].toISOString(), + impactId: item["impactId"], + }; +} + +export function impactDetailsDeserializer(item: any): ImpactDetails { + return { + impactedResourceId: item["impactedResourceId"], + startTime: new Date(item["startTime"]), + endTime: !item["endTime"] ? item["endTime"] : new Date(item["endTime"]), + impactId: item["impactId"], + }; +} + +/** model interface _InsightPropertiesAdditionalDetails */ +export interface _InsightPropertiesAdditionalDetails {} + +export function _insightPropertiesAdditionalDetailsSerializer( + item: _InsightPropertiesAdditionalDetails, +): any { + return item; +} + +export function _insightPropertiesAdditionalDetailsDeserializer( + item: any, +): _InsightPropertiesAdditionalDetails { + return item; +} + +/** The response of a Insight list operation. */ +export interface _InsightListResult { + /** The Insight items on this page */ + value: Insight[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _insightListResultDeserializer(item: any): _InsightListResult { + return { + value: insightArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function insightArraySerializer(result: Array): any[] { + return result.map((item) => { + return insightSerializer(item); + }); +} + +export function insightArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return insightDeserializer(item); + }); +} + +/** ImpactCategory resource */ +export interface ImpactCategory extends ProxyResource { + /** The resource-specific properties for this resource. */ + properties?: ImpactCategoryProperties; +} + +export function impactCategoryDeserializer(item: any): ImpactCategory { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : impactCategoryPropertiesDeserializer(item["properties"]), + }; +} + +/** Impact category properties. */ +export interface ImpactCategoryProperties { + /** Resource provisioning state. */ + readonly provisioningState?: ProvisioningState; + /** Unique ID of the category */ + categoryId: string; + /** Unique ID of the parent category */ + parentCategoryId?: string; + /** Description of the category */ + description?: string; + /** The workloadImpact properties which are required when reporting with the impact category */ + requiredImpactProperties?: RequiredImpactProperties[]; +} + +export function impactCategoryPropertiesDeserializer(item: any): ImpactCategoryProperties { + return { + provisioningState: item["provisioningState"], + categoryId: item["categoryId"], + parentCategoryId: item["parentCategoryId"], + description: item["description"], + requiredImpactProperties: !item["requiredImpactProperties"] + ? item["requiredImpactProperties"] + : requiredImpactPropertiesArrayDeserializer(item["requiredImpactProperties"]), + }; +} + +export function requiredImpactPropertiesArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return requiredImpactPropertiesDeserializer(item); + }); +} + +/** Required impact properties */ +export interface RequiredImpactProperties { + /** Name of the property */ + name: string; + /** Allowed values values for the property */ + allowedValues?: string[]; +} + +export function requiredImpactPropertiesDeserializer(item: any): RequiredImpactProperties { + return { + name: item["name"], + allowedValues: !item["allowedValues"] + ? item["allowedValues"] + : item["allowedValues"].map((p: any) => { + return p; + }), + }; +} + +/** The response of a ImpactCategory list operation. */ +export interface _ImpactCategoryListResult { + /** The ImpactCategory items on this page */ + value: ImpactCategory[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _impactCategoryListResultDeserializer(item: any): _ImpactCategoryListResult { + return { + value: impactCategoryArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function impactCategoryArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return impactCategoryDeserializer(item); + }); +} + +/** Workload Impact properties */ +export interface WorkloadImpact extends ProxyResource { + /** The resource-specific properties for this resource. */ + properties?: WorkloadImpactProperties; +} + +export function workloadImpactSerializer(item: WorkloadImpact): any { + return { + properties: !item["properties"] + ? item["properties"] + : workloadImpactPropertiesSerializer(item["properties"]), + }; +} + +export function workloadImpactDeserializer(item: any): WorkloadImpact { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : workloadImpactPropertiesDeserializer(item["properties"]), + }; +} + +/** Workload impact properties */ +export interface WorkloadImpactProperties { + /** Resource provisioning state. */ + readonly provisioningState?: ProvisioningState; + /** Time at which impact was observed */ + startDateTime: Date; + /** Time at which impact has ended */ + endDateTime?: Date; + /** Azure resource id of the impacted resource */ + impactedResourceId: string; + /** Unique ID of the impact (UUID) */ + readonly impactUniqueId?: string; + /** Time at which impact is reported */ + readonly reportedTimeUtc?: Date; + /** Category of the impact, details can found from /impactCategories API */ + impactCategory: string; + /** A detailed description of the impact */ + impactDescription?: string; + /** The ARM correlation ids, this is important field for control plane related impacts */ + armCorrelationIds?: string[]; + /** Details about performance issue. Applicable for performance impacts. */ + performance?: Performance[]; + /** Details about connectivity issue. Applicable when root resource causing the issue is not identified. For example, when a VM is impacted due to a network issue, the impacted resource is identified as the VM, but the root cause is the network. In such cases, the connectivity field will have the details about the network issue */ + connectivity?: Connectivity; + /** Additional fields related to impact, applicable fields per resource type are list under /impactCategories API */ + additionalProperties?: Record; + /** ARM error code and error message associated with the impact */ + errorDetails?: ErrorDetailProperties; + /** Information about the impacted workload */ + workload?: Workload; + /** Use this field to group impacts */ + impactGroupId?: string; + /** Degree of confidence on the impact being a platform issue */ + confidenceLevel?: ConfidenceLevel; + /** Client incident details ex: incidentId , incident source */ + clientIncidentDetails?: ClientIncidentDetails; +} + +export function workloadImpactPropertiesSerializer(item: WorkloadImpactProperties): any { + return { + startDateTime: item["startDateTime"].toISOString(), + endDateTime: !item["endDateTime"] ? item["endDateTime"] : item["endDateTime"].toISOString(), + impactedResourceId: item["impactedResourceId"], + impactCategory: item["impactCategory"], + impactDescription: item["impactDescription"], + armCorrelationIds: !item["armCorrelationIds"] + ? item["armCorrelationIds"] + : item["armCorrelationIds"].map((p: any) => { + return p; + }), + performance: !item["performance"] + ? item["performance"] + : performanceArraySerializer(item["performance"]), + connectivity: !item["connectivity"] + ? item["connectivity"] + : connectivitySerializer(item["connectivity"]), + additionalProperties: !item["additionalProperties"] + ? item["additionalProperties"] + : _workloadImpactPropertiesAdditionalPropertiesSerializer(item["additionalProperties"]), + errorDetails: !item["errorDetails"] + ? item["errorDetails"] + : errorDetailPropertiesSerializer(item["errorDetails"]), + workload: !item["workload"] ? item["workload"] : workloadSerializer(item["workload"]), + impactGroupId: item["impactGroupId"], + confidenceLevel: item["confidenceLevel"], + clientIncidentDetails: !item["clientIncidentDetails"] + ? item["clientIncidentDetails"] + : clientIncidentDetailsSerializer(item["clientIncidentDetails"]), + }; +} + +export function workloadImpactPropertiesDeserializer(item: any): WorkloadImpactProperties { + return { + provisioningState: item["provisioningState"], + startDateTime: new Date(item["startDateTime"]), + endDateTime: !item["endDateTime"] ? item["endDateTime"] : new Date(item["endDateTime"]), + impactedResourceId: item["impactedResourceId"], + impactUniqueId: item["impactUniqueId"], + reportedTimeUtc: !item["reportedTimeUtc"] + ? item["reportedTimeUtc"] + : new Date(item["reportedTimeUtc"]), + impactCategory: item["impactCategory"], + impactDescription: item["impactDescription"], + armCorrelationIds: !item["armCorrelationIds"] + ? item["armCorrelationIds"] + : item["armCorrelationIds"].map((p: any) => { + return p; + }), + performance: !item["performance"] + ? item["performance"] + : performanceArrayDeserializer(item["performance"]), + connectivity: !item["connectivity"] + ? item["connectivity"] + : connectivityDeserializer(item["connectivity"]), + additionalProperties: !item["additionalProperties"] + ? item["additionalProperties"] + : _workloadImpactPropertiesAdditionalPropertiesDeserializer(item["additionalProperties"]), + errorDetails: !item["errorDetails"] + ? item["errorDetails"] + : errorDetailPropertiesDeserializer(item["errorDetails"]), + workload: !item["workload"] ? item["workload"] : workloadDeserializer(item["workload"]), + impactGroupId: item["impactGroupId"], + confidenceLevel: item["confidenceLevel"], + clientIncidentDetails: !item["clientIncidentDetails"] + ? item["clientIncidentDetails"] + : clientIncidentDetailsDeserializer(item["clientIncidentDetails"]), + }; +} + +export function performanceArraySerializer(result: Array): any[] { + return result.map((item) => { + return performanceSerializer(item); + }); +} + +export function performanceArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return performanceDeserializer(item); + }); +} + +/** Details about impacted performance metrics. Applicable for performance related impact */ +export interface Performance { + /** Name of the Metric examples: Disk, IOPs, CPU, GPU, Memory, details can be found from /impactCategories API */ + metricName?: string; + /** Threshold value for the metric */ + expected?: number; + /** Observed value for the metric */ + actual?: number; + /** Max and Min Threshold values for the metric */ + expectedValueRange?: ExpectedValueRange; + /** Unit of the metric ex: Bytes, Percentage, Count, Seconds, Milliseconds, Bytes/Second, Count/Second, etc.., Other */ + unit?: MetricUnit; +} + +export function performanceSerializer(item: Performance): any { + return { + metricName: item["metricName"], + expected: item["expected"], + actual: item["actual"], + expectedValueRange: !item["expectedValueRange"] + ? item["expectedValueRange"] + : expectedValueRangeSerializer(item["expectedValueRange"]), + unit: item["unit"], + }; +} + +export function performanceDeserializer(item: any): Performance { + return { + metricName: item["metricName"], + expected: item["expected"], + actual: item["actual"], + expectedValueRange: !item["expectedValueRange"] + ? item["expectedValueRange"] + : expectedValueRangeDeserializer(item["expectedValueRange"]), + unit: item["unit"], + }; +} + +/** Max and Min Threshold values for the metric */ +export interface ExpectedValueRange { + /** Min threshold value for the metric */ + min: number; + /** Max threshold value for the metric */ + max: number; +} + +export function expectedValueRangeSerializer(item: ExpectedValueRange): any { + return { min: item["min"], max: item["max"] }; +} + +export function expectedValueRangeDeserializer(item: any): ExpectedValueRange { + return { + min: item["min"], + max: item["max"], + }; +} + +/** List of unit of the metric. */ +export enum KnownMetricUnit { + /** When measurement is in ByteSeconds */ + ByteSeconds = "ByteSeconds", + /** When measurement is in Bytes */ + Bytes = "Bytes", + /** When measurement is in BytesPerSecond */ + BytesPerSecond = "BytesPerSecond", + /** When measurement is in Cores */ + Cores = "Cores", + /** When measurement is in Count */ + Count = "Count", + /** When measurement is in CountPerSecond */ + CountPerSecond = "CountPerSecond", + /** When measurement is in MilliCores */ + MilliCores = "MilliCores", + /** When measurement is in MilliSeconds */ + MilliSeconds = "MilliSeconds", + /** When measurement is in NanoCores */ + NanoCores = "NanoCores", + /** When measurement is in Percent */ + Percent = "Percent", + /** When measurement is in Seconds */ + Seconds = "Seconds", + /** When measurement is in Other than listed */ + Other = "Other", +} + +/** + * List of unit of the metric. \ + * {@link KnownMetricUnit} can be used interchangeably with MetricUnit, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **ByteSeconds**: When measurement is in ByteSeconds \ + * **Bytes**: When measurement is in Bytes \ + * **BytesPerSecond**: When measurement is in BytesPerSecond \ + * **Cores**: When measurement is in Cores \ + * **Count**: When measurement is in Count \ + * **CountPerSecond**: When measurement is in CountPerSecond \ + * **MilliCores**: When measurement is in MilliCores \ + * **MilliSeconds**: When measurement is in MilliSeconds \ + * **NanoCores**: When measurement is in NanoCores \ + * **Percent**: When measurement is in Percent \ + * **Seconds**: When measurement is in Seconds \ + * **Other**: When measurement is in Other than listed + */ +export type MetricUnit = string; + +/** Details about connectivity issue. Applicable when root resource causing the issue is not identified. For example, when a VM is impacted due to a network issue, the impacted resource could be VM or the network. In such cases, the connectivity field will have the details about both VM and network. */ +export interface Connectivity { + /** Protocol used for the connection */ + protocol?: Protocol; + /** Port number for the connection */ + port?: number; + /** Source from which the connection was attempted */ + source?: SourceOrTarget; + /** target which connection was attempted */ + target?: SourceOrTarget; +} + +export function connectivitySerializer(item: Connectivity): any { + return { + protocol: item["protocol"], + port: item["port"], + source: !item["source"] ? item["source"] : sourceOrTargetSerializer(item["source"]), + target: !item["target"] ? item["target"] : sourceOrTargetSerializer(item["target"]), + }; +} + +export function connectivityDeserializer(item: any): Connectivity { + return { + protocol: item["protocol"], + port: item["port"], + source: !item["source"] ? item["source"] : sourceOrTargetDeserializer(item["source"]), + target: !item["target"] ? item["target"] : sourceOrTargetDeserializer(item["target"]), + }; +} + +/** List of protocols */ +export enum KnownProtocol { + /** When communication protocol is TCP */ + TCP = "TCP", + /** When communication protocol is UDP */ + UDP = "UDP", + /** When communication protocol is HTTP */ + Http = "HTTP", + /** When communication protocol is HTTPS */ + Https = "HTTPS", + /** When communication protocol is RDP */ + RDP = "RDP", + /** When communication protocol is FTP */ + FTP = "FTP", + /** When communication protocol is SSH */ + SSH = "SSH", + /** When communication protocol is Other */ + Other = "Other", +} + +/** + * List of protocols \ + * {@link KnownProtocol} can be used interchangeably with Protocol, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **TCP**: When communication protocol is TCP \ + * **UDP**: When communication protocol is UDP \ + * **Http**: When communication protocol is HTTP \ + * **Https**: When communication protocol is HTTPS \ + * **RDP**: When communication protocol is RDP \ + * **FTP**: When communication protocol is FTP \ + * **SSH**: When communication protocol is SSH \ + * **Other**: When communication protocol is Other + */ +export type Protocol = string; + +/** Resource details */ +export interface SourceOrTarget { + /** Azure resource id, example /subscription/{subscription}/resourceGroup/{rg}/Microsoft.compute/virtualMachine/{vmName} */ + azureResourceId?: string; +} + +export function sourceOrTargetSerializer(item: SourceOrTarget): any { + return { azureResourceId: item["azureResourceId"] }; +} + +export function sourceOrTargetDeserializer(item: any): SourceOrTarget { + return { + azureResourceId: item["azureResourceId"], + }; +} + +/** model interface _WorkloadImpactPropertiesAdditionalProperties */ +export interface _WorkloadImpactPropertiesAdditionalProperties {} + +export function _workloadImpactPropertiesAdditionalPropertiesSerializer( + item: _WorkloadImpactPropertiesAdditionalProperties, +): any { + return item; +} + +export function _workloadImpactPropertiesAdditionalPropertiesDeserializer( + item: any, +): _WorkloadImpactPropertiesAdditionalProperties { + return item; +} + +/** ARM error code and error message associated with the impact */ +export interface ErrorDetailProperties { + /** ARM Error code associated with the impact. */ + errorCode?: string; + /** ARM Error Message associated with the impact */ + errorMessage?: string; +} + +export function errorDetailPropertiesSerializer(item: ErrorDetailProperties): any { + return { errorCode: item["errorCode"], errorMessage: item["errorMessage"] }; +} + +export function errorDetailPropertiesDeserializer(item: any): ErrorDetailProperties { + return { + errorCode: item["errorCode"], + errorMessage: item["errorMessage"], + }; +} + +/** Information about the impacted workload */ +export interface Workload { + /** the scenario for the workload */ + context?: string; + /** Tool used to interact with Azure. SDK, AzPortal, etc.., Other */ + toolset?: Toolset; +} + +export function workloadSerializer(item: Workload): any { + return { context: item["context"], toolset: item["toolset"] }; +} + +export function workloadDeserializer(item: any): Workload { + return { + context: item["context"], + toolset: item["toolset"], + }; +} + +/** List of azure interfaces. */ +export enum KnownToolset { + /** If communication toolset is Terraform */ + Terraform = "Terraform", + /** If communication toolset is Puppet */ + Puppet = "Puppet", + /** If communication toolset is Chef */ + Chef = "Chef", + /** If communication toolset is SDK */ + SDK = "SDK", + /** If communication toolset is Ansible */ + Ansible = "Ansible", + /** If communication toolset is ARM */ + ARM = "ARM", + /** If communication toolset is Portal */ + Portal = "Portal", + /** If communication toolset is Shell */ + Shell = "Shell", + /** If communication toolset is Other */ + Other = "Other", +} + +/** + * List of azure interfaces. \ + * {@link KnownToolset} can be used interchangeably with Toolset, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Terraform**: If communication toolset is Terraform \ + * **Puppet**: If communication toolset is Puppet \ + * **Chef**: If communication toolset is Chef \ + * **SDK**: If communication toolset is SDK \ + * **Ansible**: If communication toolset is Ansible \ + * **ARM**: If communication toolset is ARM \ + * **Portal**: If communication toolset is Portal \ + * **Shell**: If communication toolset is Shell \ + * **Other**: If communication toolset is Other + */ +export type Toolset = string; + +/** Degree of confidence on the impact being a platform issue. */ +export enum KnownConfidenceLevel { + /** Low confidence on azure being the source of impact */ + Low = "Low", + /** Medium confidence on azure being the source of impact */ + Medium = "Medium", + /** High confidence on azure being the source of impact */ + High = "High", +} + +/** + * Degree of confidence on the impact being a platform issue. \ + * {@link KnownConfidenceLevel} can be used interchangeably with ConfidenceLevel, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Low**: Low confidence on azure being the source of impact \ + * **Medium**: Medium confidence on azure being the source of impact \ + * **High**: High confidence on azure being the source of impact + */ +export type ConfidenceLevel = string; + +/** Client incident details ex: incidentId , incident source */ +export interface ClientIncidentDetails { + /** Client incident id. ex : id of the incident created to investigate and address the impact if any. */ + clientIncidentId?: string; + /** Client incident source. ex : source system name where the incident is created */ + clientIncidentSource?: IncidentSource; +} + +export function clientIncidentDetailsSerializer(item: ClientIncidentDetails): any { + return { + clientIncidentId: item["clientIncidentId"], + clientIncidentSource: item["clientIncidentSource"], + }; +} + +export function clientIncidentDetailsDeserializer(item: any): ClientIncidentDetails { + return { + clientIncidentId: item["clientIncidentId"], + clientIncidentSource: item["clientIncidentSource"], + }; +} + +/** List of incident interfaces. */ +export enum KnownIncidentSource { + /** When source of Incident is AzureDevops */ + AzureDevops = "AzureDevops", + /** When source of Incident is Microsoft ICM */ + ICM = "ICM", + /** When source of Incident is Jira */ + Jira = "Jira", + /** When source of Incident is ServiceNow */ + ServiceNow = "ServiceNow", + /** When source of Incident is Other */ + Other = "Other", +} + +/** + * List of incident interfaces. \ + * {@link KnownIncidentSource} can be used interchangeably with IncidentSource, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **AzureDevops**: When source of Incident is AzureDevops \ + * **ICM**: When source of Incident is Microsoft ICM \ + * **Jira**: When source of Incident is Jira \ + * **ServiceNow**: When source of Incident is ServiceNow \ + * **Other**: When source of Incident is Other + */ +export type IncidentSource = string; + +/** The response of a WorkloadImpact list operation. */ +export interface _WorkloadImpactListResult { + /** The WorkloadImpact items on this page */ + value: WorkloadImpact[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _workloadImpactListResultDeserializer(item: any): _WorkloadImpactListResult { + return { + value: workloadImpactArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function workloadImpactArraySerializer(result: Array): any[] { + return result.map((item) => { + return workloadImpactSerializer(item); + }); +} + +export function workloadImpactArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return workloadImpactDeserializer(item); + }); +} + +/** A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. */ +export interface _OperationListResult { + /** The Operation items on this page */ + value: Operation[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _operationListResultDeserializer(item: any): _OperationListResult { + return { + value: operationArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function operationArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return operationDeserializer(item); + }); +} + +/** Details of a REST API operation, returned from the Resource Provider Operations API */ +export interface Operation { + /** The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" */ + readonly name?: string; + /** Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. */ + readonly isDataAction?: boolean; + /** Localized display information for this particular operation. */ + display?: OperationDisplay; + /** The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */ + readonly origin?: Origin; + /** Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */ + readonly actionType?: ActionType; +} + +export function operationDeserializer(item: any): Operation { + return { + name: item["name"], + isDataAction: item["isDataAction"], + display: !item["display"] ? item["display"] : operationDisplayDeserializer(item["display"]), + origin: item["origin"], + actionType: item["actionType"], + }; +} + +/** Localized display information for and operation. */ +export interface OperationDisplay { + /** The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". */ + readonly provider?: string; + /** The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". */ + readonly resource?: string; + /** The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". */ + readonly operation?: string; + /** The short, localized friendly description of the operation; suitable for tool tips and detailed views. */ + readonly description?: string; +} + +export function operationDisplayDeserializer(item: any): OperationDisplay { + return { + provider: item["provider"], + resource: item["resource"], + operation: item["operation"], + description: item["description"], + }; +} + +/** The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */ +export enum KnownOrigin { + /** Indicates the operation is initiated by a user. */ + User = "user", + /** Indicates the operation is initiated by a system. */ + System = "system", + /** Indicates the operation is initiated by a user or system. */ + UserSystem = "user,system", +} + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" \ + * {@link KnownOrigin} can be used interchangeably with Origin, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **User**: Indicates the operation is initiated by a user. \ + * **System**: Indicates the operation is initiated by a system. \ + * **UserSystem**: Indicates the operation is initiated by a user or system. + */ +export type Origin = string; + +/** Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */ +export enum KnownActionType { + /** Actions are for internal-only APIs. */ + Internal = "Internal", +} + +/** + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. \ + * {@link KnownActionType} can be used interchangeably with ActionType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Internal**: Actions are for internal-only APIs. + */ +export type ActionType = string; + +/** API Versions */ +export enum KnownVersions { + /** May 01, 2024 Preview API Version */ + V20240501Preview = "2024-05-01-preview", +} diff --git a/sdk/impactreporting/arm-impactreporting/src/restorePollerHelpers.ts b/sdk/impactreporting/arm-impactreporting/src/restorePollerHelpers.ts new file mode 100644 index 000000000000..a438aeafc8da --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/restorePollerHelpers.ts @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "./impactClient.js"; +import { _connectorsCreateOrUpdateDeserialize } from "./api/connectors/index.js"; +import { _workloadImpactsCreateDeserialize } from "./api/workloadImpacts/index.js"; +import { getLongRunningPoller } from "./static-helpers/pollingHelpers.js"; +import { OperationOptions, PathUncheckedResponse } from "@azure-rest/core-client"; +import { AbortSignalLike } from "@azure/abort-controller"; +import { + PollerLike, + OperationState, + deserializeState, + ResourceLocationConfig, +} from "@azure/core-lro"; + +export interface RestorePollerOptions< + TResult, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +> extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** + * The signal which can be used to abort requests. + */ + abortSignal?: AbortSignalLike; + /** Deserialization function for raw response body */ + processResponseBody?: (result: TResponse) => Promise; +} + +/** + * Creates a poller from the serialized state of another poller. This can be + * useful when you want to create pollers on a different host or a poller + * needs to be constructed after the original one is not in scope. + */ +export function restorePoller( + client: ImpactClient, + serializedState: string, + sourceOperation: (...args: any[]) => PollerLike, TResult>, + options?: RestorePollerOptions, +): PollerLike, TResult> { + const pollerConfig = deserializeState(serializedState).config; + const { initialRequestUrl, requestMethod, metadata } = pollerConfig; + if (!initialRequestUrl || !requestMethod) { + throw new Error( + `Invalid serialized state: ${serializedState} for sourceOperation ${sourceOperation?.name}`, + ); + } + const resourceLocationConfig = metadata?.["resourceLocationConfig"] as + | ResourceLocationConfig + | undefined; + const { deserializer, expectedStatuses = [] } = + getDeserializationHelper(initialRequestUrl, requestMethod) ?? {}; + const deserializeHelper = options?.processResponseBody ?? deserializer; + if (!deserializeHelper) { + throw new Error( + `Please ensure the operation is in this client! We can't find its deserializeHelper for ${sourceOperation?.name}.`, + ); + } + return getLongRunningPoller( + (client as any)["_client"] ?? client, + deserializeHelper as (result: TResponse) => Promise, + expectedStatuses, + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + resourceLocationConfig, + restoreFrom: serializedState, + initialRequestUrl, + }, + ); +} + +interface DeserializationHelper { + deserializer: Function; + expectedStatuses: string[]; +} + +const deserializeMap: Record = { + "PUT /subscriptions/{subscriptionId}/providers/Microsoft.Impact/connectors/{connectorName}": { + deserializer: _connectorsCreateOrUpdateDeserialize, + expectedStatuses: ["200", "201"], + }, + "PUT /subscriptions/{subscriptionId}/providers/Microsoft.Impact/workloadImpacts/{workloadImpactName}": + { + deserializer: _workloadImpactsCreateDeserialize, + expectedStatuses: ["200", "201"], + }, +}; + +function getDeserializationHelper( + urlStr: string, + method: string, +): DeserializationHelper | undefined { + const path = new URL(urlStr).pathname; + const pathParts = path.split("/"); + + // Traverse list to match the longest candidate + // matchedLen: the length of candidate path + // matchedValue: the matched status code array + let matchedLen = -1, + matchedValue: DeserializationHelper | undefined; + + // Iterate the responseMap to find a match + for (const [key, value] of Object.entries(deserializeMap)) { + // Extracting the path from the map key which is in format + // GET /path/foo + if (!key.startsWith(method)) { + continue; + } + const candidatePath = getPathFromMapKey(key); + // Get each part of the url path + const candidateParts = candidatePath.split("/"); + + // track if we have found a match to return the values found. + let found = true; + for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) { + if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) { + const start = candidateParts[i]!.indexOf("}") + 1, + end = candidateParts[i]?.length; + // If the current part of the candidate is a "template" part + // Try to use the suffix of pattern to match the path + // {guid} ==> $ + // {guid}:export ==> :export$ + const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test( + pathParts[j] || "", + ); + + if (!isMatched) { + found = false; + break; + } + continue; + } + + // If the candidate part is not a template and + // the parts don't match mark the candidate as not found + // to move on with the next candidate path. + if (candidateParts[i] !== pathParts[j]) { + found = false; + break; + } + } + + // We finished evaluating the current candidate parts + // Update the matched value if and only if we found the longer pattern + if (found && candidatePath.length > matchedLen) { + matchedLen = candidatePath.length; + matchedValue = value; + } + } + + return matchedValue; +} + +function getPathFromMapKey(mapKey: string): string { + const pathStart = mapKey.indexOf("/"); + return mapKey.slice(pathStart); +} diff --git a/sdk/impactreporting/arm-impactreporting/src/static-helpers/pagingHelpers.ts b/sdk/impactreporting/arm-impactreporting/src/static-helpers/pagingHelpers.ts new file mode 100644 index 000000000000..ce33af5f4178 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/static-helpers/pagingHelpers.ts @@ -0,0 +1,241 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; +import { RestError } from "@azure/core-rest-pipeline"; + +/** + * Options for the byPage method + */ +export interface PageSettings { + /** + * A reference to a specific page to start iterating from. + */ + continuationToken?: string; +} + +/** + * An interface that describes a page of results. + */ +export type ContinuablePage = TPage & { + /** + * The token that keeps track of where to continue the iterator + */ + continuationToken?: string; +}; + +/** + * An interface that allows async iterable iteration both to completion and by page. + */ +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * The next method, part of the iteration protocol + */ + next(): Promise>; + /** + * The connection to the async iterator, part of the iteration protocol + */ + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + /** + * Return an AsyncIterableIterator that works a page at a time + */ + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; +} + +/** + * An interface that describes how to communicate with the service. + */ +export interface PagedResult< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * Link to the first page of results. + */ + firstPageLink?: string; + /** + * A method that returns a page of results. + */ + getPage: (pageLink?: string) => Promise<{ page: TPage; nextPageLink?: string } | undefined>; + /** + * a function to implement the `byPage` method on the paged async iterator. + */ + byPage?: (settings?: TPageSettings) => AsyncIterableIterator>; + + /** + * A function to extract elements from a page. + */ + toElements?: (page: TPage) => TElement[]; +} + +/** + * Options for the paging helper + */ +export interface BuildPagedAsyncIteratorOptions { + itemName?: string; + nextLinkName?: string; +} + +/** + * Helper to paginate results in a generic way and return a PagedAsyncIterableIterator + */ +export function buildPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +>( + client: Client, + getInitialResponse: () => PromiseLike, + processResponseBody: (result: TResponse) => PromiseLike, + expectedStatuses: string[], + options: BuildPagedAsyncIteratorOptions = {}, +): PagedAsyncIterableIterator { + const itemName = options.itemName ?? "value"; + const nextLinkName = options.nextLinkName ?? "nextLink"; + const pagedResult: PagedResult = { + getPage: async (pageLink?: string) => { + const result = + pageLink === undefined + ? await getInitialResponse() + : await client.pathUnchecked(pageLink).get(); + checkPagingRequest(result, expectedStatuses); + const results = await processResponseBody(result as TResponse); + const nextLink = getNextLink(results, nextLinkName); + const values = getElements(results, itemName) as TPage; + return { + page: values, + nextPageLink: nextLink, + }; + }, + byPage: (settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }, + }; + return getPagedAsyncIterator(pagedResult); +} + +/** + * returns an async iterator that iterates over results. It also has a `byPage` + * method that returns pages of items at once. + * + * @param pagedResult - an object that specifies how to get pages. + * @returns a paged async iterator that iterates over results. + */ + +function getPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +>( + pagedResult: PagedResult, +): PagedAsyncIterableIterator { + const iter = getItemAsyncIterator(pagedResult); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: + pagedResult?.byPage ?? + ((settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }), + }; +} + +async function* getItemAsyncIterator( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + for await (const page of pages) { + yield* page as unknown as TElement[]; + } +} + +async function* getPageAsyncIterator( + pagedResult: PagedResult, + options: { + pageLink?: string; + } = {}, +): AsyncIterableIterator> { + const { pageLink } = options; + let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink); + if (!response) { + return; + } + let result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + while (response.nextPageLink) { + response = await pagedResult.getPage(response.nextPageLink); + if (!response) { + return; + } + result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + } +} + +/** + * Gets for the value of nextLink in the body + */ +function getNextLink(body: unknown, nextLinkName?: string): string | undefined { + if (!nextLinkName) { + return undefined; + } + + const nextLink = (body as Record)[nextLinkName]; + + if (typeof nextLink !== "string" && typeof nextLink !== "undefined" && nextLink !== null) { + throw new RestError( + `Body Property ${nextLinkName} should be a string or undefined or null but got ${typeof nextLink}`, + ); + } + + if (nextLink === null) { + return undefined; + } + + return nextLink; +} + +/** + * Gets the elements of the current request in the body. + */ +function getElements(body: unknown, itemName: string): T[] { + const value = (body as Record)[itemName] as T[]; + if (!Array.isArray(value)) { + throw new RestError( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`, + ); + } + + return value ?? []; +} + +/** + * Checks if a request failed + */ +function checkPagingRequest(response: PathUncheckedResponse, expectedStatuses: string[]): void { + if (!expectedStatuses.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response, + ); + } +} diff --git a/sdk/impactreporting/arm-impactreporting/src/static-helpers/pollingHelpers.ts b/sdk/impactreporting/arm-impactreporting/src/static-helpers/pollingHelpers.ts new file mode 100644 index 000000000000..f01c41bab69d --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/src/static-helpers/pollingHelpers.ts @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + PollerLike, + OperationState, + ResourceLocationConfig, + RunningOperation, + createHttpPoller, + OperationResponse, +} from "@azure/core-lro"; + +import { Client, PathUncheckedResponse, createRestError } from "@azure-rest/core-client"; +import { AbortSignalLike } from "@azure/abort-controller"; + +export interface GetLongRunningPollerOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** + * The signal which can be used to abort requests. + */ + abortSignal?: AbortSignalLike; + /** + * The potential location of the result of the LRO if specified by the LRO extension in the swagger. + */ + resourceLocationConfig?: ResourceLocationConfig; + /** + * The original url of the LRO + * Should not be null when restoreFrom is set + */ + initialRequestUrl?: string; + /** + * A serialized poller which can be used to resume an existing paused Long-Running-Operation. + */ + restoreFrom?: string; + /** + * The function to get the initial response + */ + getInitialResponse?: () => PromiseLike; +} +export function getLongRunningPoller( + client: Client, + processResponseBody: (result: TResponse) => Promise, + expectedStatuses: string[], + options: GetLongRunningPollerOptions, +): PollerLike, TResult> { + const { restoreFrom, getInitialResponse } = options; + if (!restoreFrom && !getInitialResponse) { + throw new Error("Either restoreFrom or getInitialResponse must be specified"); + } + let initialResponse: TResponse | undefined = undefined; + const pollAbortController = new AbortController(); + const poller: RunningOperation = { + sendInitialRequest: async () => { + if (!getInitialResponse) { + throw new Error("getInitialResponse is required when initializing a new poller"); + } + initialResponse = await getInitialResponse(); + return getLroResponse(initialResponse, expectedStatuses); + }, + sendPollRequest: async ( + path: string, + pollOptions?: { + abortSignal?: AbortSignalLike; + }, + ) => { + // The poll request would both listen to the user provided abort signal and the poller's own abort signal + function abortListener(): void { + pollAbortController.abort(); + } + const abortSignal = pollAbortController.signal; + if (options.abortSignal?.aborted) { + pollAbortController.abort(); + } else if (pollOptions?.abortSignal?.aborted) { + pollAbortController.abort(); + } else if (!abortSignal.aborted) { + options.abortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + pollOptions?.abortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + } + let response; + try { + response = await client.pathUnchecked(path).get({ abortSignal }); + } finally { + options.abortSignal?.removeEventListener("abort", abortListener); + pollOptions?.abortSignal?.removeEventListener("abort", abortListener); + } + + return getLroResponse(response as TResponse, expectedStatuses); + }, + }; + return createHttpPoller(poller, { + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: options?.resourceLocationConfig, + restoreFrom: options?.restoreFrom, + processResult: (result: unknown) => { + return processResponseBody(result as TResponse); + }, + }); +} +/** + * Converts a Rest Client response to a response that the LRO implementation understands + * @param response - a rest client http response + * @param deserializeFn - deserialize function to convert Rest response to modular output + * @returns - An LRO response that the LRO implementation understands + */ +function getLroResponse( + response: TResponse, + expectedStatuses: string[], +): OperationResponse { + if (!expectedStatuses.includes(response.status)) { + throw createRestError(response); + } + + return { + flatResponse: response, + rawResponse: { + ...response, + statusCode: Number.parseInt(response.status), + body: response.body, + }, + }; +} diff --git a/sdk/impactreporting/arm-impactreporting/test/public/impactreporting_operations_test.spec.ts b/sdk/impactreporting/arm-impactreporting/test/public/impactreporting_operations_test.spec.ts new file mode 100644 index 000000000000..a9ca3aa30eea --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/test/public/impactreporting_operations_test.spec.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { env, Recorder, isPlaybackMode } from "@azure-tools/test-recorder"; +import { createTestCredential } from "@azure-tools/test-credential"; +import { assert, beforeEach, afterEach, it, describe } from "vitest"; +import { createRecorder } from "./utils/recordedClient.js"; +import { ImpactClient } from "../../src/impactClient.js"; + +export const testPollingOptions = { + updateIntervalInMs: isPlaybackMode() ? 0 : undefined, +}; + +describe("Impactreporting test", () => { + let recorder: Recorder; + let subscriptionId: string; + let client: ImpactClient; + + beforeEach(async (context) => { + process.env.SystemRoot = process.env.SystemRoot || "C:\\Windows"; + recorder = await createRecorder(context); + subscriptionId = env.SUBSCRIPTION_ID || ""; + // This is an example of how the environment variables are used + const credential = createTestCredential(); + client = new ImpactClient(credential, subscriptionId, recorder.configureClientOptions({})); + }); + + afterEach(async function () { + await recorder.stop(); + }); + it("operations list test", async function () { + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + assert.notEqual(resArray.length, 0); + }); +}); diff --git a/sdk/impactreporting/arm-impactreporting/test/public/utils/recordedClient.ts b/sdk/impactreporting/arm-impactreporting/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..14dcd9fa397c --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/test/public/utils/recordedClient.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { Recorder, RecorderStartOptions, VitestTestContext } from "@azure-tools/test-recorder"; + +const replaceableVariables: Record = { + SUBSCRIPTION_ID: "azure_subscription_id", +}; + +const recorderEnvSetup: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables, +}; + +/** + * creates the recorder and reads the environment variables from the `.env` file. + * Should be called first in the test suite to make sure environment variables are + * read before they are being used. + */ +export async function createRecorder(context: VitestTestContext): Promise { + const recorder = new Recorder(context); + await recorder.start(recorderEnvSetup); + return recorder; +} diff --git a/sdk/impactreporting/arm-impactreporting/test/snippets.spec.ts b/sdk/impactreporting/arm-impactreporting/test/snippets.spec.ts new file mode 100644 index 000000000000..1dc675094968 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/test/snippets.spec.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ImpactClient } from "../src/index.js"; +import { DefaultAzureCredential, InteractiveBrowserCredential } from "@azure/identity"; +import { setLogLevel } from "@azure/logger"; +import { describe, it } from "vitest"; + +describe("snippets", () => { + it("ReadmeSampleCreateClient_Node", async () => { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new ImpactClient(new DefaultAzureCredential(), subscriptionId); + }); + + it("ReadmeSampleCreateClient_Browser", async () => { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new InteractiveBrowserCredential({ + tenantId: "", + clientId: "", + }); + const client = new ImpactClient(credential, subscriptionId); + }); + + it("SetLogLevel", async () => { + setLogLevel("info"); + }); +}); diff --git a/sdk/impactreporting/arm-impactreporting/tsconfig.browser.config.json b/sdk/impactreporting/arm-impactreporting/tsconfig.browser.config.json new file mode 100644 index 000000000000..75871518e3a0 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/tsconfig.browser.config.json @@ -0,0 +1,3 @@ +{ + "extends": ["./tsconfig.test.json", "../../../tsconfig.browser.base.json"] +} diff --git a/sdk/impactreporting/arm-impactreporting/tsconfig.json b/sdk/impactreporting/arm-impactreporting/tsconfig.json new file mode 100644 index 000000000000..19ceb382b521 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/tsconfig.json @@ -0,0 +1,13 @@ +{ + "references": [ + { + "path": "./tsconfig.src.json" + }, + { + "path": "./tsconfig.samples.json" + }, + { + "path": "./tsconfig.test.json" + } + ] +} diff --git a/sdk/impactreporting/arm-impactreporting/tsconfig.samples.json b/sdk/impactreporting/arm-impactreporting/tsconfig.samples.json new file mode 100644 index 000000000000..de467f0f9e25 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/tsconfig.samples.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.samples.base.json", + "compilerOptions": { + "paths": { + "@azure/arm-impactreporting": ["./dist/esm"] + } + } +} diff --git a/sdk/impactreporting/arm-impactreporting/tsconfig.src.json b/sdk/impactreporting/arm-impactreporting/tsconfig.src.json new file mode 100644 index 000000000000..bae70752dd38 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/tsconfig.src.json @@ -0,0 +1,3 @@ +{ + "extends": "../../../tsconfig.lib.json" +} diff --git a/sdk/impactreporting/arm-impactreporting/tsconfig.test.json b/sdk/impactreporting/arm-impactreporting/tsconfig.test.json new file mode 100644 index 000000000000..290ca214aebc --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/tsconfig.test.json @@ -0,0 +1,3 @@ +{ + "extends": ["./tsconfig.src.json", "../../../tsconfig.test.base.json"] +} diff --git a/sdk/impactreporting/arm-impactreporting/tsp-location.yaml b/sdk/impactreporting/arm-impactreporting/tsp-location.yaml new file mode 100644 index 000000000000..b92ea15f1eec --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/impact/Impact.Management +commit: 13f7c56aecf4cc42dfc14f72b6eb4ba2b8d470c5 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/impactreporting/arm-impactreporting/vitest.browser.config.ts b/sdk/impactreporting/arm-impactreporting/vitest.browser.config.ts new file mode 100644 index 000000000000..182729ab5ce9 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/vitest.browser.config.ts @@ -0,0 +1,17 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig, mergeConfig } from "vitest/config"; +import viteConfig from "../../../vitest.browser.shared.config.ts"; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + include: ["dist-test/browser/test/**/*.spec.js",], + testTimeout: 1200000, + hookTimeout: 1200000, + }, + }), +); diff --git a/sdk/impactreporting/arm-impactreporting/vitest.config.ts b/sdk/impactreporting/arm-impactreporting/vitest.config.ts new file mode 100644 index 000000000000..40e031385dd8 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/vitest.config.ts @@ -0,0 +1,16 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig, mergeConfig } from "vitest/config"; +import viteConfig from "../../../vitest.shared.config.ts"; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + testTimeout: 1200000, + hookTimeout: 1200000, + }, + }), +); diff --git a/sdk/impactreporting/arm-impactreporting/vitest.esm.config.ts b/sdk/impactreporting/arm-impactreporting/vitest.esm.config.ts new file mode 100644 index 000000000000..a70127279fc9 --- /dev/null +++ b/sdk/impactreporting/arm-impactreporting/vitest.esm.config.ts @@ -0,0 +1,12 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { mergeConfig } from "vitest/config"; +import vitestConfig from "./vitest.config.ts"; +import vitestEsmConfig from "../../../vitest.esm.shared.config.ts"; + +export default mergeConfig( + vitestConfig, + vitestEsmConfig +); diff --git a/sdk/impactreporting/ci.mgmt.yml b/sdk/impactreporting/ci.mgmt.yml new file mode 100644 index 000000000000..e42891b25f3d --- /dev/null +++ b/sdk/impactreporting/ci.mgmt.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/impactreporting/arm-impactreporting + - sdk/impactreporting/ci.mgmt.yml +pr: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/impactreporting/arm-impactreporting + - sdk/impactreporting/ci.mgmt.yml +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: sdk/impactreporting + Artifacts: + - name: azure-arm-impactreporting + safeName: azurearmimpactreporting