From bb48ace9cebc67bc31a7f67effd0d249821ecfe3 Mon Sep 17 00:00:00 2001 From: kazrael2119 <98569699+kazrael2119@users.noreply.github.com> Date: Fri, 28 Apr 2023 11:37:52 +0800 Subject: [PATCH] selfhelp release (#25678) https://github.com/Azure/sdk-release-request/issues/4034 --- common/config/rush/pnpm-lock.yaml | 36 +- eng/ignore-links.txt | 1 + rush.json | 9 +- sdk/selfhelp/arm-selfhelp/CHANGELOG.md | 5 + sdk/selfhelp/arm-selfhelp/LICENSE | 21 + sdk/selfhelp/arm-selfhelp/README.md | 108 +++ sdk/selfhelp/arm-selfhelp/_meta.json | 8 + sdk/selfhelp/arm-selfhelp/api-extractor.json | 31 + sdk/selfhelp/arm-selfhelp/assets.json | 6 + sdk/selfhelp/arm-selfhelp/package.json | 123 ++++ .../arm-selfhelp/review/arm-selfhelp.api.md | 310 +++++++++ sdk/selfhelp/arm-selfhelp/rollup.config.js | 122 ++++ sdk/selfhelp/arm-selfhelp/sample.env | 4 + .../diagnosticsCheckNameAvailabilitySample.ts | 68 ++ .../samples-dev/diagnosticsCreateSample.ts | 40 ++ .../samples-dev/diagnosticsGetSample.ts | 37 ++ .../discoverySolutionListSample.ts | 39 ++ .../samples-dev/operationsListSample.ts | 37 ++ .../samples/v1-beta/javascript/README.md | 58 ++ .../diagnosticsCheckNameAvailabilitySample.js | 62 ++ .../javascript/diagnosticsCreateSample.js | 35 + .../javascript/diagnosticsGetSample.js | 35 + .../javascript/discoverySolutionListSample.js | 37 ++ .../javascript/operationsListSample.js | 35 + .../samples/v1-beta/javascript/package.json | 32 + .../samples/v1-beta/javascript/sample.env | 4 + .../samples/v1-beta/typescript/README.md | 71 ++ .../samples/v1-beta/typescript/package.json | 41 ++ .../samples/v1-beta/typescript/sample.env | 4 + .../diagnosticsCheckNameAvailabilitySample.ts | 68 ++ .../typescript/src/diagnosticsCreateSample.ts | 40 ++ .../typescript/src/diagnosticsGetSample.ts | 37 ++ .../src/discoverySolutionListSample.ts | 39 ++ .../typescript/src/operationsListSample.ts | 37 ++ .../samples/v1-beta/typescript/tsconfig.json | 17 + sdk/selfhelp/arm-selfhelp/src/helpRP.ts | 144 ++++ sdk/selfhelp/arm-selfhelp/src/index.ts | 13 + sdk/selfhelp/arm-selfhelp/src/lroImpl.ts | 42 ++ sdk/selfhelp/arm-selfhelp/src/models/index.ts | 485 ++++++++++++++ .../arm-selfhelp/src/models/mappers.ts | 619 ++++++++++++++++++ .../arm-selfhelp/src/models/parameters.ts | 136 ++++ .../src/operations/diagnostics.ts | 249 +++++++ .../src/operations/discoverySolution.ts | 179 +++++ .../arm-selfhelp/src/operations/index.ts | 11 + .../arm-selfhelp/src/operations/operations.ts | 149 +++++ .../src/operationsInterfaces/diagnostics.ts | 80 +++ .../operationsInterfaces/discoverySolution.ts | 34 + .../src/operationsInterfaces/index.ts | 11 + .../src/operationsInterfaces/operations.ts | 22 + sdk/selfhelp/arm-selfhelp/src/pagingHelper.ts | 39 ++ .../test/selfhelp_operations_test.spec.ts | 73 +++ sdk/selfhelp/arm-selfhelp/tsconfig.json | 33 + sdk/selfhelp/ci.mgmt.yml | 38 ++ 53 files changed, 4009 insertions(+), 5 deletions(-) create mode 100644 sdk/selfhelp/arm-selfhelp/CHANGELOG.md create mode 100644 sdk/selfhelp/arm-selfhelp/LICENSE create mode 100644 sdk/selfhelp/arm-selfhelp/README.md create mode 100644 sdk/selfhelp/arm-selfhelp/_meta.json create mode 100644 sdk/selfhelp/arm-selfhelp/api-extractor.json create mode 100644 sdk/selfhelp/arm-selfhelp/assets.json create mode 100644 sdk/selfhelp/arm-selfhelp/package.json create mode 100644 sdk/selfhelp/arm-selfhelp/review/arm-selfhelp.api.md create mode 100644 sdk/selfhelp/arm-selfhelp/rollup.config.js create mode 100644 sdk/selfhelp/arm-selfhelp/sample.env create mode 100644 sdk/selfhelp/arm-selfhelp/samples-dev/diagnosticsCheckNameAvailabilitySample.ts create mode 100644 sdk/selfhelp/arm-selfhelp/samples-dev/diagnosticsCreateSample.ts create mode 100644 sdk/selfhelp/arm-selfhelp/samples-dev/diagnosticsGetSample.ts create mode 100644 sdk/selfhelp/arm-selfhelp/samples-dev/discoverySolutionListSample.ts create mode 100644 sdk/selfhelp/arm-selfhelp/samples-dev/operationsListSample.ts create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/README.md create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsCheckNameAvailabilitySample.js create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsCreateSample.js create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsGetSample.js create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/discoverySolutionListSample.js create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/operationsListSample.js create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/package.json create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/sample.env create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/README.md create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/package.json create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/sample.env create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsCheckNameAvailabilitySample.ts create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsCreateSample.ts create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsGetSample.ts create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/discoverySolutionListSample.ts create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/operationsListSample.ts create mode 100644 sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/tsconfig.json create mode 100644 sdk/selfhelp/arm-selfhelp/src/helpRP.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/index.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/lroImpl.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/models/index.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/models/mappers.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/models/parameters.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/operations/diagnostics.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/operations/discoverySolution.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/operations/index.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/operations/operations.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/diagnostics.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/discoverySolution.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/index.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/operations.ts create mode 100644 sdk/selfhelp/arm-selfhelp/src/pagingHelper.ts create mode 100644 sdk/selfhelp/arm-selfhelp/test/selfhelp_operations_test.spec.ts create mode 100644 sdk/selfhelp/arm-selfhelp/tsconfig.json create mode 100644 sdk/selfhelp/ci.mgmt.yml diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 642388ff1f8d..a05fda1569af 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -184,6 +184,7 @@ specifiers: '@rush-temp/arm-security': file:./projects/arm-security.tgz '@rush-temp/arm-securitydevops': file:./projects/arm-securitydevops.tgz '@rush-temp/arm-securityinsight': file:./projects/arm-securityinsight.tgz + '@rush-temp/arm-selfhelp': file:./projects/arm-selfhelp.tgz '@rush-temp/arm-serialconsole': file:./projects/arm-serialconsole.tgz '@rush-temp/arm-servicebus': file:./projects/arm-servicebus.tgz '@rush-temp/arm-servicefabric': file:./projects/arm-servicefabric.tgz @@ -523,6 +524,7 @@ dependencies: '@rush-temp/arm-security': file:projects/arm-security.tgz '@rush-temp/arm-securitydevops': file:projects/arm-securitydevops.tgz '@rush-temp/arm-securityinsight': file:projects/arm-securityinsight.tgz + '@rush-temp/arm-selfhelp': file:projects/arm-selfhelp.tgz '@rush-temp/arm-serialconsole': file:projects/arm-serialconsole.tgz '@rush-temp/arm-servicebus': file:projects/arm-servicebus.tgz '@rush-temp/arm-servicefabric': file:projects/arm-servicefabric.tgz @@ -3775,7 +3777,7 @@ packages: dependencies: semver: 7.5.0 shelljs: 0.8.5 - typescript: 5.1.0-dev.20230424 + typescript: 5.1.0-dev.20230426 dev: false /ecdsa-sig-formatter/1.0.11: @@ -8435,8 +8437,8 @@ packages: hasBin: true dev: false - /typescript/5.1.0-dev.20230424: - resolution: {integrity: sha512-yhQpzzjyLCyXORVY8AgJYaWpm235ZzG/boelYvgloE7v+kCucAdegsBf7duLJzXc/8+wABR2diYMbjPpd5c3Ww==} + /typescript/5.1.0-dev.20230426: + resolution: {integrity: sha512-zQ4BsUQeM5CFScIVsyY0XOMCn/VYav7z5CT6nlOSqI/CJ3DVn86JWE/DwkK44c39RyKCmtwB9hz+BWcb7bem/g==} engines: {node: '>=14.17'} hasBin: true dev: false @@ -14288,6 +14290,34 @@ packages: - supports-color dev: false + file:projects/arm-selfhelp.tgz: + resolution: {integrity: sha512-p8aapHDpKa8OpG/SM/+3ZVTZOk2UqRru20IRlBe++/8BVqP3PaOqyaX1FBM9L9v0AaetNazNSd819VRM4QehjA==, tarball: file:projects/arm-selfhelp.tgz} + name: '@rush-temp/arm-selfhelp' + version: 0.0.0 + dependencies: + '@azure/identity': 2.1.0 + '@microsoft/api-extractor': 7.34.4_@types+node@14.18.42 + '@rollup/plugin-commonjs': 24.1.0_rollup@2.79.1 + '@rollup/plugin-json': 6.0.0_rollup@2.79.1 + '@rollup/plugin-multi-entry': 6.0.0_rollup@2.79.1 + '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 + '@types/chai': 4.3.4 + '@types/node': 14.18.42 + chai: 4.3.7 + cross-env: 7.0.3 + dotenv: 16.0.3 + mkdirp: 2.1.6 + mocha: 7.2.0 + rimraf: 3.0.2 + rollup: 2.79.1 + rollup-plugin-sourcemaps: 0.6.3_c43y4oaxxwie3ialrfuzfwwhqq + tslib: 2.5.0 + typescript: 5.0.4 + uglify-js: 3.17.4 + transitivePeerDependencies: + - supports-color + dev: false + file:projects/arm-serialconsole.tgz: resolution: {integrity: sha512-rwKniNU5RJVCBYDtKN9a/X9MNAgcThj2vfi6cocZc9ibLmDZUvydavNNWyULbD4LwMQH3zxHOcrVoKuUtah5fQ==, tarball: file:projects/arm-serialconsole.tgz} name: '@rush-temp/arm-serialconsole' diff --git a/eng/ignore-links.txt b/eng/ignore-links.txt index f7aafe2b177d..eb15622ee72b 100644 --- a/eng/ignore-links.txt +++ b/eng/ignore-links.txt @@ -11,3 +11,4 @@ https://docs.microsoft.com/javascript/api/@azure/arm-voiceservices?view=azure-no https://docs.microsoft.com/javascript/api/@azure/arm-graphservices?view=azure-node-preview https://docs.microsoft.com/javascript/api/@azure/arm-newrelicobservability?view=azure-node-preview https://docs.microsoft.com/javascript/api/@azure/arm-paloaltonetworksngfw?view=azure-node-preview +https://docs.microsoft.com/javascript/api/@azure/arm-selfhelp?view=azure-node-preview diff --git a/rush.json b/rush.json index ac0cc8a78e21..22359d9b512c 100644 --- a/rush.json +++ b/rush.json @@ -1,7 +1,7 @@ /** * This is the main configuration file for Rush. * For full documentation, please see https://rushjs.io - */ { + */{ "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json", /** * (Required) This specifies the version of the Rush engine to be used in this repo. @@ -1972,6 +1972,11 @@ "packageName": "@azure/arm-paloaltonetworksngfw", "projectFolder": "sdk/paloaltonetworksngfw/arm-paloaltonetworksngfw", "versionPolicyName": "management" + }, + { + "packageName": "@azure/arm-selfhelp", + "projectFolder": "sdk/selfhelp/arm-selfhelp", + "versionPolicyName": "management" } ] -} +} \ No newline at end of file diff --git a/sdk/selfhelp/arm-selfhelp/CHANGELOG.md b/sdk/selfhelp/arm-selfhelp/CHANGELOG.md new file mode 100644 index 000000000000..4f29327dba04 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2023-04-27) + +The package of @azure/arm-selfhelp is using our next generation design principles. To learn more, please refer to our documentation [Quick Start](https://aka.ms/js-track2-quickstart). diff --git a/sdk/selfhelp/arm-selfhelp/LICENSE b/sdk/selfhelp/arm-selfhelp/LICENSE new file mode 100644 index 000000000000..3a1d9b6f24f7 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2023 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/selfhelp/arm-selfhelp/README.md b/sdk/selfhelp/arm-selfhelp/README.md new file mode 100644 index 000000000000..79fe7daaaf54 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/README.md @@ -0,0 +1,108 @@ +# Azure HelpRP client library for JavaScript + +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure HelpRP client. + +Help RP provider + +[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/selfhelp/arm-selfhelp) | +[Package (NPM)](https://www.npmjs.com/package/@azure/arm-selfhelp) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-selfhelp?view=azure-node-preview) | +[Samples](https://github.com/Azure-Samples/azure-samples-js-management) + +## 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-selfhelp` package + +Install the Azure HelpRP client library for JavaScript with `npm`: + +```bash +npm install @azure/arm-selfhelp +``` + +### Create and authenticate a `HelpRP` + +To create a client object to access the Azure HelpRP API, you will need the `endpoint` of your Azure HelpRP resource and a `credential`. The Azure HelpRP client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure HelpRP 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 HelpRP** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`. + +For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). + +```javascript +const { HelpRP } = require("@azure/arm-selfhelp"); +const { DefaultAzureCredential } = require("@azure/identity"); +// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. + +const client = new HelpRP(new DefaultAzureCredential()); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new HelpRP(credential); +``` + + +### 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 + +### HelpRP + +`HelpRP` is the primary interface for developers using the Azure HelpRP client library. Explore the methods on this client object to understand the different features of the Azure HelpRP service that you can access. + +## Troubleshooting + +### Logging + +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: + +```javascript +const { setLogLevel } = require("@azure/logger"); +setLogLevel("info"); +``` + +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). + +## Next steps + +Please take a look at the [samples](https://github.com/Azure-Samples/azure-samples-js-management) 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) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fselfhelp%2Farm-selfhelp%2FREADME.png) + +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_sub]: https://azure.microsoft.com/free/ +[azure_sub]: https://azure.microsoft.com/free/ +[azure_portal]: https://portal.azure.com +[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity +[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential diff --git a/sdk/selfhelp/arm-selfhelp/_meta.json b/sdk/selfhelp/arm-selfhelp/_meta.json new file mode 100644 index 000000000000..c5c14c4f0777 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/_meta.json @@ -0,0 +1,8 @@ +{ + "commit": "2e2f8781fac5b72af86895d2e97ee0b1fab02048", + "readme": "specification/help/resource-manager/readme.md", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\help\\resource-manager\\readme.md --use=@autorest/typescript@6.0.1 --generate-sample=true", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "release_tool": "@azure-tools/js-sdk-release-tools@2.6.2", + "use": "@autorest/typescript@6.0.1" +} \ No newline at end of file diff --git a/sdk/selfhelp/arm-selfhelp/api-extractor.json b/sdk/selfhelp/arm-selfhelp/api-extractor.json new file mode 100644 index 000000000000..726486ad8051 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/api-extractor.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/arm-selfhelp.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} \ No newline at end of file diff --git a/sdk/selfhelp/arm-selfhelp/assets.json b/sdk/selfhelp/arm-selfhelp/assets.json new file mode 100644 index 000000000000..55f39628bb29 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "js", + "TagPrefix": "js/selfhelp/arm-selfhelp", + "Tag": "js/selfhelp/arm-selfhelp_0633afaf92" +} diff --git a/sdk/selfhelp/arm-selfhelp/package.json b/sdk/selfhelp/arm-selfhelp/package.json new file mode 100644 index 000000000000..523e3a32bbd5 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/package.json @@ -0,0 +1,123 @@ +{ + "name": "@azure/arm-selfhelp", + "sdk-type": "mgmt", + "author": "Microsoft Corporation", + "description": "A generated SDK for HelpRP.", + "version": "1.0.0-beta.1", + "engines": { + "node": ">=14.0.0" + }, + "dependencies": { + "@azure/core-lro": "^2.5.0", + "@azure/abort-controller": "^1.0.0", + "@azure/core-paging": "^1.2.0", + "@azure/core-client": "^1.7.0", + "@azure/core-auth": "^1.3.0", + "@azure/core-rest-pipeline": "^1.8.0", + "tslib": "^2.2.0" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/index.js", + "module": "./dist-esm/src/index.js", + "types": "./types/arm-selfhelp.d.ts", + "devDependencies": { + "@microsoft/api-extractor": "^7.31.1", + "@rollup/plugin-commonjs": "^24.0.0", + "@rollup/plugin-json": "^6.0.0", + "@rollup/plugin-multi-entry": "^6.0.0", + "@rollup/plugin-node-resolve": "^13.1.3", + "mkdirp": "^2.1.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", + "typescript": "~5.0.0", + "uglify-js": "^3.4.9", + "rimraf": "^3.0.0", + "dotenv": "^16.0.0", + "@azure/identity": "^2.0.1", + "@azure-tools/test-recorder": "^3.0.0", + "@azure-tools/test-credential": "^1.0.0", + "mocha": "^7.1.1", + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^14.0.0", + "@azure/dev-tool": "^1.0.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/Azure/azure-sdk-for-js.git" + }, + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "files": [ + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map", + "dist-esm/**/*.js", + "dist-esm/**/*.js.map", + "dist-esm/**/*.d.ts", + "dist-esm/**/*.d.ts.map", + "src/**/*.ts", + "README.md", + "LICENSE", + "rollup.config.js", + "tsconfig.json", + "review/*", + "CHANGELOG.md", + "types/*" + ], + "scripts": { + "build": "npm run clean && tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", + "prepack": "npm run build", + "pack": "npm pack 2>&1", + "extract-api": "api-extractor run --local", + "lint": "echo skipped", + "audit": "echo skipped", + "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "build:node": "echo skipped", + "build:browser": "echo skipped", + "build:test": "echo skipped", + "build:samples": "echo skipped.", + "check-format": "echo skipped", + "execute:samples": "echo skipped", + "format": "echo skipped", + "test": "npm run integration-test", + "test:node": "echo skipped", + "test:browser": "echo skipped", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", + "unit-test:browser": "echo skipped", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" + }, + "sideEffects": false, + "//metadata": { + "constantPaths": [ + { + "path": "src/helpRP.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/selfhelp/arm-selfhelp", + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-selfhelp?view=azure-node-preview" + } +} \ No newline at end of file diff --git a/sdk/selfhelp/arm-selfhelp/review/arm-selfhelp.api.md b/sdk/selfhelp/arm-selfhelp/review/arm-selfhelp.api.md new file mode 100644 index 000000000000..6ea3e7aecd3d --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/review/arm-selfhelp.api.md @@ -0,0 +1,310 @@ +## API Report File for "@azure/arm-selfhelp" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import * as coreAuth from '@azure/core-auth'; +import * as coreClient from '@azure/core-client'; +import { OperationState } from '@azure/core-lro'; +import { PagedAsyncIterableIterator } from '@azure/core-paging'; +import { SimplePollerLike } from '@azure/core-lro'; + +// @public +export type ActionType = string; + +// @public +export interface CheckNameAvailabilityRequest { + name?: string; + type?: string; +} + +// @public +export interface CheckNameAvailabilityResponse { + message?: string; + nameAvailable?: boolean; + reason?: string; +} + +// @public +export type CreatedByType = string; + +// @public +export interface Diagnostic { + error?: ErrorModel; + insights?: Insight[]; + solutionId?: string; + status?: Status; +} + +// @public +export interface DiagnosticInvocation { + additionalParameters?: { + [propertyName: string]: string; + }; + solutionId?: string; +} + +// @public +export interface DiagnosticResource extends ProxyResource { + readonly acceptedAt?: string; + readonly diagnostics?: Diagnostic[]; + globalParameters?: { + [propertyName: string]: string; + }; + insights?: DiagnosticInvocation[]; + readonly provisioningState?: ProvisioningState; +} + +// @public +export interface Diagnostics { + beginCreate(scope: string, diagnosticsResourceName: string, options?: DiagnosticsCreateOptionalParams): Promise, DiagnosticsCreateResponse>>; + beginCreateAndWait(scope: string, diagnosticsResourceName: string, options?: DiagnosticsCreateOptionalParams): Promise; + checkNameAvailability(scope: string, options?: DiagnosticsCheckNameAvailabilityOptionalParams): Promise; + get(scope: string, diagnosticsResourceName: string, options?: DiagnosticsGetOptionalParams): Promise; +} + +// @public +export interface DiagnosticsCheckNameAvailabilityOptionalParams extends coreClient.OperationOptions { + checkNameAvailabilityRequest?: CheckNameAvailabilityRequest; +} + +// @public +export type DiagnosticsCheckNameAvailabilityResponse = CheckNameAvailabilityResponse; + +// @public +export interface DiagnosticsCreateOptionalParams extends coreClient.OperationOptions { + diagnosticResourceRequest?: DiagnosticResource; + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type DiagnosticsCreateResponse = DiagnosticResource; + +// @public +export interface DiagnosticsGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type DiagnosticsGetResponse = DiagnosticResource; + +// @public +export interface DiscoveryResponse { + nextLink?: string; + value?: SolutionMetadataResource[]; +} + +// @public +export interface DiscoverySolution { + list(scope: string, options?: DiscoverySolutionListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface DiscoverySolutionListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type DiscoverySolutionListNextResponse = DiscoveryResponse; + +// @public +export interface DiscoverySolutionListOptionalParams extends coreClient.OperationOptions { + filter?: string; + skiptoken?: string; +} + +// @public +export type DiscoverySolutionListResponse = DiscoveryResponse; + +// @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 ErrorModel { + readonly code?: string; + details?: ErrorModel[]; + readonly message?: string; + readonly type?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export function getContinuationToken(page: unknown): string | undefined; + +// @public (undocumented) +export class HelpRP extends coreClient.ServiceClient { + // (undocumented) + $host: string; + constructor(credentials: coreAuth.TokenCredential, options?: HelpRPOptionalParams); + // (undocumented) + apiVersion: string; + // (undocumented) + diagnostics: Diagnostics; + // (undocumented) + discoverySolution: DiscoverySolution; + // (undocumented) + operations: Operations; +} + +// @public +export interface HelpRPOptionalParams extends coreClient.ServiceClientOptions { + $host?: string; + apiVersion?: string; + endpoint?: string; +} + +// @public +export type ImportanceLevel = string; + +// @public +export interface Insight { + id?: string; + importanceLevel?: ImportanceLevel; + results?: string; + title?: string; +} + +// @public +export enum KnownActionType { + Internal = "Internal" +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownImportanceLevel { + Critical = "Critical", + Information = "Information", + Warning = "Warning" +} + +// @public +export enum KnownOrigin { + System = "system", + User = "user", + UserSystem = "user,system" +} + +// @public +export enum KnownProvisioningState { + Canceled = "Canceled", + Failed = "Failed", + PartialComplete = "PartialComplete", + Succeeded = "Succeeded" +} + +// @public +export enum KnownStatus { + Failed = "Failed", + MissingInputs = "MissingInputs", + Running = "Running", + Succeeded = "Succeeded", + Timeout = "Timeout" +} + +// @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 OperationListResult { + readonly nextLink?: string; + readonly value?: Operation[]; +} + +// @public +export interface Operations { + list(options?: OperationsListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface OperationsListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationsListNextResponse = OperationListResult; + +// @public +export interface OperationsListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationsListResponse = OperationListResult; + +// @public +export type Origin = string; + +// @public +export type ProvisioningState = string; + +// @public +export interface ProxyResource extends Resource { +} + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export interface SolutionMetadataResource extends ProxyResource { + description?: string; + requiredParameterSets?: string[][]; + solutionId?: string; + solutionType?: string; +} + +// @public +export type Status = string; + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/selfhelp/arm-selfhelp/rollup.config.js b/sdk/selfhelp/arm-selfhelp/rollup.config.js new file mode 100644 index 000000000000..3f89d7309da5 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/rollup.config.js @@ -0,0 +1,122 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import nodeResolve from "@rollup/plugin-node-resolve"; +import cjs from "@rollup/plugin-commonjs"; +import sourcemaps from "rollup-plugin-sourcemaps"; +import multiEntry from "@rollup/plugin-multi-entry"; +import json from "@rollup/plugin-json"; + +import nodeBuiltins from "builtin-modules"; + +// #region Warning Handler + +/** + * A function that can determine whether a rollup warning should be ignored. If + * the function returns `true`, then the warning will not be displayed. + */ + +function ignoreNiseSinonEval(warning) { + return ( + warning.code === "EVAL" && + warning.id && + (warning.id.includes("node_modules/nise") || + warning.id.includes("node_modules/sinon")) === true + ); +} + +function ignoreChaiCircularDependency(warning) { + return ( + warning.code === "CIRCULAR_DEPENDENCY" && + warning.importer && warning.importer.includes("node_modules/chai") === true + ); +} + +const warningInhibitors = [ignoreChaiCircularDependency, ignoreNiseSinonEval]; + +/** + * Construct a warning handler for the shared rollup configuration + * that ignores certain warnings that are not relevant to testing. + */ +function makeOnWarnForTesting() { + return (warning, warn) => { + // If every inhibitor returns false (i.e. no inhibitors), then show the warning + if (warningInhibitors.every((inhib) => !inhib(warning))) { + warn(warning); + } + }; +} + +// #endregion + +function makeBrowserTestConfig() { + const config = { + input: { + include: ["dist-esm/test/**/*.spec.js"], + exclude: ["dist-esm/test/**/node/**"] + }, + output: { + file: `dist-test/index.browser.js`, + format: "umd", + sourcemap: true + }, + preserveSymlinks: false, + plugins: [ + multiEntry({ exports: false }), + nodeResolve({ + mainFields: ["module", "browser"] + }), + cjs(), + json(), + sourcemaps() + //viz({ filename: "dist-test/browser-stats.html", sourcemap: true }) + ], + onwarn: makeOnWarnForTesting(), + // Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, + // rollup started respecting the "sideEffects" field in package.json. Since + // our package.json sets "sideEffects=false", this also applies to test + // code, which causes all tests to be removed by tree-shaking. + treeshake: false + }; + + return config; +} + +const defaultConfigurationOptions = { + disableBrowserBundle: false +}; + +export function makeConfig(pkg, options) { + options = { + ...defaultConfigurationOptions, + ...(options || {}) + }; + + const baseConfig = { + // Use the package's module field if it has one + input: pkg["module"] || "dist-esm/src/index.js", + external: [ + ...nodeBuiltins, + ...Object.keys(pkg.dependencies), + ...Object.keys(pkg.devDependencies) + ], + output: { file: "dist/index.js", format: "cjs", sourcemap: true }, + preserveSymlinks: false, + plugins: [sourcemaps(), nodeResolve()] + }; + + const config = [baseConfig]; + + if (!options.disableBrowserBundle) { + config.push(makeBrowserTestConfig()); + } + + return config; +} + +export default makeConfig(require("./package.json")); diff --git a/sdk/selfhelp/arm-selfhelp/sample.env b/sdk/selfhelp/arm-selfhelp/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/selfhelp/arm-selfhelp/samples-dev/diagnosticsCheckNameAvailabilitySample.ts b/sdk/selfhelp/arm-selfhelp/samples-dev/diagnosticsCheckNameAvailabilitySample.ts new file mode 100644 index 000000000000..9dd01890f755 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples-dev/diagnosticsCheckNameAvailabilitySample.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + CheckNameAvailabilityRequest, + DiagnosticsCheckNameAvailabilityOptionalParams, + HelpRP +} from "@azure/arm-selfhelp"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to This API is used to check the uniqueness of a resource name used for a diagnostic check. + * + * @summary This API is used to check the uniqueness of a resource name used for a diagnostic check. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CheckNameAvailabilityForDiagnosticWhenNameIsAvailable.json + */ +async function exampleWhenNameIsAvailableForADiagnosticResource() { + const scope = "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6"; + const checkNameAvailabilityRequest: CheckNameAvailabilityRequest = { + name: "sampleName", + type: "Microsoft.Help/diagnostics" + }; + const options: DiagnosticsCheckNameAvailabilityOptionalParams = { + checkNameAvailabilityRequest + }; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const result = await client.diagnostics.checkNameAvailability(scope, options); + console.log(result); +} + +/** + * This sample demonstrates how to This API is used to check the uniqueness of a resource name used for a diagnostic check. + * + * @summary This API is used to check the uniqueness of a resource name used for a diagnostic check. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CheckNameAvailabilityForDiagnosticWhenNameIsNotAvailable.json + */ +async function exampleWhenNameIsNotAvailableForADiagnosticResource() { + const scope = "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6"; + const checkNameAvailabilityRequest: CheckNameAvailabilityRequest = { + name: "sampleName", + type: "Microsoft.Help/diagnostics" + }; + const options: DiagnosticsCheckNameAvailabilityOptionalParams = { + checkNameAvailabilityRequest + }; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const result = await client.diagnostics.checkNameAvailability(scope, options); + console.log(result); +} + +async function main() { + exampleWhenNameIsAvailableForADiagnosticResource(); + exampleWhenNameIsNotAvailableForADiagnosticResource(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples-dev/diagnosticsCreateSample.ts b/sdk/selfhelp/arm-selfhelp/samples-dev/diagnosticsCreateSample.ts new file mode 100644 index 000000000000..5daff5c027b0 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples-dev/diagnosticsCreateSample.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { HelpRP } from "@azure/arm-selfhelp"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Diagnostics tells you precisely the root cause of the issue and how to address it. You can get diagnostics once you discover and identify the relevant solution for your Azure issue.

You can create diagnostics using the ‘solutionId’ from Solution Discovery API response and ‘additionalParameters’

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API + * + * @summary Diagnostics tells you precisely the root cause of the issue and how to address it. You can get diagnostics once you discover and identify the relevant solution for your Azure issue.

You can create diagnostics using the ‘solutionId’ from Solution Discovery API response and ‘additionalParameters’

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CreateDiagnosticForKeyVaultResource.json + */ +async function createsADiagnosticForAKeyVaultResource() { + const scope = + "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; + const diagnosticsResourceName = "VMNotWorkingInsight"; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const result = await client.diagnostics.beginCreateAndWait( + scope, + diagnosticsResourceName + ); + console.log(result); +} + +async function main() { + createsADiagnosticForAKeyVaultResource(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples-dev/diagnosticsGetSample.ts b/sdk/selfhelp/arm-selfhelp/samples-dev/diagnosticsGetSample.ts new file mode 100644 index 000000000000..f08f6656e2e8 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples-dev/diagnosticsGetSample.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { HelpRP } from "@azure/arm-selfhelp"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. + * + * @summary Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/GetDiagnosticForKeyVaultResource.json + */ +async function getsADiagnosticForAKeyVaultResource() { + const scope = + "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; + const diagnosticsResourceName = "VMNotWorkingInsight"; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const result = await client.diagnostics.get(scope, diagnosticsResourceName); + console.log(result); +} + +async function main() { + getsADiagnosticForAKeyVaultResource(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples-dev/discoverySolutionListSample.ts b/sdk/selfhelp/arm-selfhelp/samples-dev/discoverySolutionListSample.ts new file mode 100644 index 000000000000..34d5254bdf05 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples-dev/discoverySolutionListSample.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { HelpRP } from "@azure/arm-selfhelp"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Solutions Discovery is the initial point of entry within Help API, which helps you identify the relevant solutions for your Azure issue.

You can discover solutions using resourceUri OR resourceUri + problemClassificationId.

We will do our best in returning relevant diagnostics for your Azure issue.

Get the problemClassificationId(s) using this [reference](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP).

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API. + * + * @summary Solutions Discovery is the initial point of entry within Help API, which helps you identify the relevant solutions for your Azure issue.

You can discover solutions using resourceUri OR resourceUri + problemClassificationId.

We will do our best in returning relevant diagnostics for your Azure issue.

Get the problemClassificationId(s) using this [reference](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP).

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/ListDiscoverySolutionsForKeyVaultResource.json + */ +async function listDiscoverySolutionsForAKeyVaultResource() { + const scope = + "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const resArray = new Array(); + for await (let item of client.discoverySolution.list(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listDiscoverySolutionsForAKeyVaultResource(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples-dev/operationsListSample.ts b/sdk/selfhelp/arm-selfhelp/samples-dev/operationsListSample.ts new file mode 100644 index 000000000000..41b98266f6d8 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples-dev/operationsListSample.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { HelpRP } from "@azure/arm-selfhelp"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Returns list of operations. + * + * @summary Returns list of operations. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/ListOperations.json + */ +async function listAllOperations() { + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllOperations(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/README.md b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/README.md new file mode 100644 index 000000000000..87e5223f1998 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/README.md @@ -0,0 +1,58 @@ +# client library samples for JavaScript (Beta) + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [diagnosticsCheckNameAvailabilitySample.js][diagnosticschecknameavailabilitysample] | This API is used to check the uniqueness of a resource name used for a diagnostic check. x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CheckNameAvailabilityForDiagnosticWhenNameIsAvailable.json | +| [diagnosticsCreateSample.js][diagnosticscreatesample] | Diagnostics tells you precisely the root cause of the issue and how to address it. You can get diagnostics once you discover and identify the relevant solution for your Azure issue.

You can create diagnostics using the ‘solutionId’ from Solution Discovery API response and ‘additionalParameters’

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CreateDiagnosticForKeyVaultResource.json | +| [diagnosticsGetSample.js][diagnosticsgetsample] | Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/GetDiagnosticForKeyVaultResource.json | +| [discoverySolutionListSample.js][discoverysolutionlistsample] | Solutions Discovery is the initial point of entry within Help API, which helps you identify the relevant solutions for your Azure issue.

You can discover solutions using resourceUri OR resourceUri + problemClassificationId.

We will do our best in returning relevant diagnostics for your Azure issue.

Get the problemClassificationId(s) using this [reference](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP).

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API. x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/ListDiscoverySolutionsForKeyVaultResource.json | +| [operationsListSample.js][operationslistsample] | Returns list of operations. x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/ListOperations.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 diagnosticsCheckNameAvailabilitySample.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 cross-env node diagnosticsCheckNameAvailabilitySample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[diagnosticschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsCheckNameAvailabilitySample.js +[diagnosticscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsCreateSample.js +[diagnosticsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsGetSample.js +[discoverysolutionlistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/discoverySolutionListSample.js +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/operationsListSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-selfhelp?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/selfhelp/arm-selfhelp/README.md diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsCheckNameAvailabilitySample.js b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsCheckNameAvailabilitySample.js new file mode 100644 index 000000000000..d301c98b79df --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsCheckNameAvailabilitySample.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { HelpRP } = require("@azure/arm-selfhelp"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to This API is used to check the uniqueness of a resource name used for a diagnostic check. + * + * @summary This API is used to check the uniqueness of a resource name used for a diagnostic check. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CheckNameAvailabilityForDiagnosticWhenNameIsAvailable.json + */ +async function exampleWhenNameIsAvailableForADiagnosticResource() { + const scope = "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6"; + const checkNameAvailabilityRequest = { + name: "sampleName", + type: "Microsoft.Help/diagnostics", + }; + const options = { + checkNameAvailabilityRequest, + }; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const result = await client.diagnostics.checkNameAvailability(scope, options); + console.log(result); +} + +/** + * This sample demonstrates how to This API is used to check the uniqueness of a resource name used for a diagnostic check. + * + * @summary This API is used to check the uniqueness of a resource name used for a diagnostic check. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CheckNameAvailabilityForDiagnosticWhenNameIsNotAvailable.json + */ +async function exampleWhenNameIsNotAvailableForADiagnosticResource() { + const scope = "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6"; + const checkNameAvailabilityRequest = { + name: "sampleName", + type: "Microsoft.Help/diagnostics", + }; + const options = { + checkNameAvailabilityRequest, + }; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const result = await client.diagnostics.checkNameAvailability(scope, options); + console.log(result); +} + +async function main() { + exampleWhenNameIsAvailableForADiagnosticResource(); + exampleWhenNameIsNotAvailableForADiagnosticResource(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsCreateSample.js b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsCreateSample.js new file mode 100644 index 000000000000..d0d30a1c0023 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsCreateSample.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { HelpRP } = require("@azure/arm-selfhelp"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Diagnostics tells you precisely the root cause of the issue and how to address it. You can get diagnostics once you discover and identify the relevant solution for your Azure issue.

You can create diagnostics using the ‘solutionId’ from Solution Discovery API response and ‘additionalParameters’

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API + * + * @summary Diagnostics tells you precisely the root cause of the issue and how to address it. You can get diagnostics once you discover and identify the relevant solution for your Azure issue.

You can create diagnostics using the ‘solutionId’ from Solution Discovery API response and ‘additionalParameters’

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CreateDiagnosticForKeyVaultResource.json + */ +async function createsADiagnosticForAKeyVaultResource() { + const scope = + "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; + const diagnosticsResourceName = "VMNotWorkingInsight"; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const result = await client.diagnostics.beginCreateAndWait(scope, diagnosticsResourceName); + console.log(result); +} + +async function main() { + createsADiagnosticForAKeyVaultResource(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsGetSample.js b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsGetSample.js new file mode 100644 index 000000000000..1ee946802f01 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/diagnosticsGetSample.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { HelpRP } = require("@azure/arm-selfhelp"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. + * + * @summary Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/GetDiagnosticForKeyVaultResource.json + */ +async function getsADiagnosticForAKeyVaultResource() { + const scope = + "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; + const diagnosticsResourceName = "VMNotWorkingInsight"; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const result = await client.diagnostics.get(scope, diagnosticsResourceName); + console.log(result); +} + +async function main() { + getsADiagnosticForAKeyVaultResource(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/discoverySolutionListSample.js b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/discoverySolutionListSample.js new file mode 100644 index 000000000000..e018e02dc5e5 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/discoverySolutionListSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { HelpRP } = require("@azure/arm-selfhelp"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Solutions Discovery is the initial point of entry within Help API, which helps you identify the relevant solutions for your Azure issue.

You can discover solutions using resourceUri OR resourceUri + problemClassificationId.

We will do our best in returning relevant diagnostics for your Azure issue.

Get the problemClassificationId(s) using this [reference](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP).

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API. + * + * @summary Solutions Discovery is the initial point of entry within Help API, which helps you identify the relevant solutions for your Azure issue.

You can discover solutions using resourceUri OR resourceUri + problemClassificationId.

We will do our best in returning relevant diagnostics for your Azure issue.

Get the problemClassificationId(s) using this [reference](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP).

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/ListDiscoverySolutionsForKeyVaultResource.json + */ +async function listDiscoverySolutionsForAKeyVaultResource() { + const scope = + "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const resArray = new Array(); + for await (let item of client.discoverySolution.list(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listDiscoverySolutionsForAKeyVaultResource(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/operationsListSample.js b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/operationsListSample.js new file mode 100644 index 000000000000..8e01e1adf303 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/operationsListSample.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { HelpRP } = require("@azure/arm-selfhelp"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Returns list of operations. + * + * @summary Returns list of operations. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/ListOperations.json + */ +async function listAllOperations() { + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllOperations(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/package.json b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/package.json new file mode 100644 index 000000000000..d058e51b49fa --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-selfhelp-js-beta", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript (Beta)", + "engines": { + "node": ">=14.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/selfhelp/arm-selfhelp" + }, + "keywords": [ + "node", + "azure", + "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/selfhelp/arm-selfhelp", + "dependencies": { + "@azure/arm-selfhelp": "next", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/sample.env b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/javascript/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/README.md b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/README.md new file mode 100644 index 000000000000..55bb5b89d641 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/README.md @@ -0,0 +1,71 @@ +# client library samples for TypeScript (Beta) + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [diagnosticsCheckNameAvailabilitySample.ts][diagnosticschecknameavailabilitysample] | This API is used to check the uniqueness of a resource name used for a diagnostic check. x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CheckNameAvailabilityForDiagnosticWhenNameIsAvailable.json | +| [diagnosticsCreateSample.ts][diagnosticscreatesample] | Diagnostics tells you precisely the root cause of the issue and how to address it. You can get diagnostics once you discover and identify the relevant solution for your Azure issue.

You can create diagnostics using the ‘solutionId’ from Solution Discovery API response and ‘additionalParameters’

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CreateDiagnosticForKeyVaultResource.json | +| [diagnosticsGetSample.ts][diagnosticsgetsample] | Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/GetDiagnosticForKeyVaultResource.json | +| [discoverySolutionListSample.ts][discoverysolutionlistsample] | Solutions Discovery is the initial point of entry within Help API, which helps you identify the relevant solutions for your Azure issue.

You can discover solutions using resourceUri OR resourceUri + problemClassificationId.

We will do our best in returning relevant diagnostics for your Azure issue.

Get the problemClassificationId(s) using this [reference](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP).

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API. x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/ListDiscoverySolutionsForKeyVaultResource.json | +| [operationsListSample.ts][operationslistsample] | Returns list of operations. x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/ListOperations.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/diagnosticsCheckNameAvailabilitySample.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 cross-env node dist/diagnosticsCheckNameAvailabilitySample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[diagnosticschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsCheckNameAvailabilitySample.ts +[diagnosticscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsCreateSample.ts +[diagnosticsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsGetSample.ts +[discoverysolutionlistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/discoverySolutionListSample.ts +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/operationsListSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-selfhelp?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/selfhelp/arm-selfhelp/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/package.json b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/package.json new file mode 100644 index 000000000000..07262c793483 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-selfhelp-ts-beta", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript (Beta)", + "engines": { + "node": ">=14.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/selfhelp/arm-selfhelp" + }, + "keywords": [ + "node", + "azure", + "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/selfhelp/arm-selfhelp", + "dependencies": { + "@azure/arm-selfhelp": "next", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^14.0.0", + "typescript": "~5.0.0", + "rimraf": "latest" + } +} diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/sample.env b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsCheckNameAvailabilitySample.ts b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsCheckNameAvailabilitySample.ts new file mode 100644 index 000000000000..9dd01890f755 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsCheckNameAvailabilitySample.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + CheckNameAvailabilityRequest, + DiagnosticsCheckNameAvailabilityOptionalParams, + HelpRP +} from "@azure/arm-selfhelp"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to This API is used to check the uniqueness of a resource name used for a diagnostic check. + * + * @summary This API is used to check the uniqueness of a resource name used for a diagnostic check. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CheckNameAvailabilityForDiagnosticWhenNameIsAvailable.json + */ +async function exampleWhenNameIsAvailableForADiagnosticResource() { + const scope = "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6"; + const checkNameAvailabilityRequest: CheckNameAvailabilityRequest = { + name: "sampleName", + type: "Microsoft.Help/diagnostics" + }; + const options: DiagnosticsCheckNameAvailabilityOptionalParams = { + checkNameAvailabilityRequest + }; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const result = await client.diagnostics.checkNameAvailability(scope, options); + console.log(result); +} + +/** + * This sample demonstrates how to This API is used to check the uniqueness of a resource name used for a diagnostic check. + * + * @summary This API is used to check the uniqueness of a resource name used for a diagnostic check. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CheckNameAvailabilityForDiagnosticWhenNameIsNotAvailable.json + */ +async function exampleWhenNameIsNotAvailableForADiagnosticResource() { + const scope = "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6"; + const checkNameAvailabilityRequest: CheckNameAvailabilityRequest = { + name: "sampleName", + type: "Microsoft.Help/diagnostics" + }; + const options: DiagnosticsCheckNameAvailabilityOptionalParams = { + checkNameAvailabilityRequest + }; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const result = await client.diagnostics.checkNameAvailability(scope, options); + console.log(result); +} + +async function main() { + exampleWhenNameIsAvailableForADiagnosticResource(); + exampleWhenNameIsNotAvailableForADiagnosticResource(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsCreateSample.ts b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsCreateSample.ts new file mode 100644 index 000000000000..5daff5c027b0 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsCreateSample.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { HelpRP } from "@azure/arm-selfhelp"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Diagnostics tells you precisely the root cause of the issue and how to address it. You can get diagnostics once you discover and identify the relevant solution for your Azure issue.

You can create diagnostics using the ‘solutionId’ from Solution Discovery API response and ‘additionalParameters’

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API + * + * @summary Diagnostics tells you precisely the root cause of the issue and how to address it. You can get diagnostics once you discover and identify the relevant solution for your Azure issue.

You can create diagnostics using the ‘solutionId’ from Solution Discovery API response and ‘additionalParameters’

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/CreateDiagnosticForKeyVaultResource.json + */ +async function createsADiagnosticForAKeyVaultResource() { + const scope = + "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; + const diagnosticsResourceName = "VMNotWorkingInsight"; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const result = await client.diagnostics.beginCreateAndWait( + scope, + diagnosticsResourceName + ); + console.log(result); +} + +async function main() { + createsADiagnosticForAKeyVaultResource(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsGetSample.ts b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsGetSample.ts new file mode 100644 index 000000000000..f08f6656e2e8 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/diagnosticsGetSample.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { HelpRP } from "@azure/arm-selfhelp"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. + * + * @summary Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/GetDiagnosticForKeyVaultResource.json + */ +async function getsADiagnosticForAKeyVaultResource() { + const scope = + "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; + const diagnosticsResourceName = "VMNotWorkingInsight"; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const result = await client.diagnostics.get(scope, diagnosticsResourceName); + console.log(result); +} + +async function main() { + getsADiagnosticForAKeyVaultResource(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/discoverySolutionListSample.ts b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/discoverySolutionListSample.ts new file mode 100644 index 000000000000..34d5254bdf05 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/discoverySolutionListSample.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { HelpRP } from "@azure/arm-selfhelp"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Solutions Discovery is the initial point of entry within Help API, which helps you identify the relevant solutions for your Azure issue.

You can discover solutions using resourceUri OR resourceUri + problemClassificationId.

We will do our best in returning relevant diagnostics for your Azure issue.

Get the problemClassificationId(s) using this [reference](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP).

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API. + * + * @summary Solutions Discovery is the initial point of entry within Help API, which helps you identify the relevant solutions for your Azure issue.

You can discover solutions using resourceUri OR resourceUri + problemClassificationId.

We will do our best in returning relevant diagnostics for your Azure issue.

Get the problemClassificationId(s) using this [reference](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP).

Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via ‘additionalParameters’ as an input to Diagnostics API. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/ListDiscoverySolutionsForKeyVaultResource.json + */ +async function listDiscoverySolutionsForAKeyVaultResource() { + const scope = + "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const resArray = new Array(); + for await (let item of client.discoverySolution.list(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listDiscoverySolutionsForAKeyVaultResource(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/operationsListSample.ts b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/operationsListSample.ts new file mode 100644 index 000000000000..41b98266f6d8 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/src/operationsListSample.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { HelpRP } from "@azure/arm-selfhelp"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Returns list of operations. + * + * @summary Returns list of operations. + * x-ms-original-file: specification/help/resource-manager/Microsoft.Help/preview/2023-01-01-preview/examples/ListOperations.json + */ +async function listAllOperations() { + const credential = new DefaultAzureCredential(); + const client = new HelpRP(credential); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllOperations(); +} + +main().catch(console.error); diff --git a/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/tsconfig.json b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/tsconfig.json new file mode 100644 index 000000000000..e26ce2a6d8f7 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/samples/v1-beta/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "alwaysStrict": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": [ + "src/**.ts" + ] +} diff --git a/sdk/selfhelp/arm-selfhelp/src/helpRP.ts b/sdk/selfhelp/arm-selfhelp/src/helpRP.ts new file mode 100644 index 000000000000..4245bf4826f9 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/helpRP.ts @@ -0,0 +1,144 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; +import * as coreAuth from "@azure/core-auth"; +import { + OperationsImpl, + DiagnosticsImpl, + DiscoverySolutionImpl +} from "./operations"; +import { + Operations, + Diagnostics, + DiscoverySolution +} from "./operationsInterfaces"; +import { HelpRPOptionalParams } from "./models"; + +export class HelpRP extends coreClient.ServiceClient { + $host: string; + apiVersion: string; + + /** + * Initializes a new instance of the HelpRP class. + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param options The parameter options + */ + constructor( + credentials: coreAuth.TokenCredential, + options?: HelpRPOptionalParams + ) { + if (credentials === undefined) { + throw new Error("'credentials' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + const defaults: HelpRPOptionalParams = { + requestContentType: "application/json; charset=utf-8", + credential: credentials + }; + + const packageDetails = `azsdk-js-arm-selfhelp/1.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` + : `${packageDetails}`; + + const optionsWithDefaults = { + ...defaults, + ...options, + userAgentOptions: { + userAgentPrefix + }, + endpoint: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" + }; + super(optionsWithDefaults); + + let bearerTokenAuthenticationPolicyFound: boolean = false; + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + } + if ( + !options || + !options.pipeline || + options.pipeline.getOrderedPolicies().length == 0 || + !bearerTokenAuthenticationPolicyFound + ) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: credentials, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + + // Assigning values to Constant parameters + this.$host = options.$host || "https://management.azure.com"; + this.apiVersion = options.apiVersion || "2023-01-01-preview"; + this.operations = new OperationsImpl(this); + this.diagnostics = new DiagnosticsImpl(this); + this.discoverySolution = new DiscoverySolutionImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); + } + + operations: Operations; + diagnostics: Diagnostics; + discoverySolution: DiscoverySolution; +} diff --git a/sdk/selfhelp/arm-selfhelp/src/index.ts b/sdk/selfhelp/arm-selfhelp/src/index.ts new file mode 100644 index 000000000000..8b1ae2428849 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +/// +export { getContinuationToken } from "./pagingHelper"; +export * from "./models"; +export { HelpRP } from "./helpRP"; +export * from "./operationsInterfaces"; diff --git a/sdk/selfhelp/arm-selfhelp/src/lroImpl.ts b/sdk/selfhelp/arm-selfhelp/src/lroImpl.ts new file mode 100644 index 000000000000..dd803cd5e28c --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/lroImpl.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { AbortSignalLike } from "@azure/abort-controller"; +import { LongRunningOperation, LroResponse } from "@azure/core-lro"; + +export function createLroSpec(inputs: { + sendOperationFn: (args: any, spec: any) => Promise>; + args: Record; + spec: { + readonly requestBody?: unknown; + readonly path?: string; + readonly httpMethod: string; + } & Record; +}): LongRunningOperation { + const { args, spec, sendOperationFn } = inputs; + return { + requestMethod: spec.httpMethod, + requestPath: spec.path!, + sendInitialRequest: () => sendOperationFn(args, spec), + sendPollRequest: ( + path: string, + options?: { abortSignal?: AbortSignalLike } + ) => { + const { requestBody, ...restSpec } = spec; + return sendOperationFn(args, { + ...restSpec, + httpMethod: "GET", + path, + abortSignal: options?.abortSignal + }); + } + }; +} diff --git a/sdk/selfhelp/arm-selfhelp/src/models/index.ts b/sdk/selfhelp/arm-selfhelp/src/models/index.ts new file mode 100644 index 000000000000..2a79122d6198 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/models/index.ts @@ -0,0 +1,485 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; + +/** 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 { + /** + * List of operations supported by the resource provider + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly value?: Operation[]; + /** + * URL to get the next set of operation list results (if there are any). + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly nextLink?: string; +} + +/** 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" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + 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" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly origin?: Origin; + /** + * Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly actionType?: ActionType; +} + +/** Localized display information for this particular operation. */ +export interface OperationDisplay { + /** + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provider?: string; + /** + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly resource?: string; + /** + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly operation?: string; + /** + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly description?: string; +} + +/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). */ +export interface ErrorResponse { + /** The error object. */ + error?: ErrorDetail; +} + +/** The error detail. */ +export interface ErrorDetail { + /** + * The error code. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly code?: string; + /** + * The error message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; + /** + * The error target. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly target?: string; + /** + * The error details. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly details?: ErrorDetail[]; + /** + * The error additional info. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** + * The additional info type. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * The additional info. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly info?: Record; +} + +/** The check availability request body. */ +export interface CheckNameAvailabilityRequest { + /** The name of the resource for which availability needs to be checked. */ + name?: string; + /** The resource type. */ + type?: string; +} + +/** Response for whether the requested resource name is available or not. */ +export interface CheckNameAvailabilityResponse { + /** Returns true or false depending on the availability of the name */ + nameAvailable?: boolean; + /** Reason for why value is not available. This field is returned if nameAvailable is false. */ + reason?: string; + /** Gets an error message explaining the 'reason' value with more details. This field is returned iif nameAvailable is false. */ + message?: string; +} + +/** Solution Invocation with additional params needed for invocation. */ +export interface DiagnosticInvocation { + /** Solution Id to invoke. */ + solutionId?: string; + /** Additional parameters required to invoke the solutionId. */ + additionalParameters?: { [propertyName: string]: string }; +} + +/** Properties returned with in an insight. */ +export interface Diagnostic { + /** Solution Id */ + solutionId?: string; + /** Denotes the status of the diagnostic resource. */ + status?: Status; + /** The problems (if any) detected by this insight. */ + insights?: Insight[]; + /** Error definition. */ + error?: ErrorModel; +} + +/** Detailed insights(s) obtained via the invocation of an insight diagnostic troubleshooter. */ +export interface Insight { + /** Article id. */ + id?: string; + /** This insight's title. */ + title?: string; + /** Detailed result content. */ + results?: string; + /** Importance level of the insight. */ + importanceLevel?: ImportanceLevel; +} + +/** Error definition. */ +export interface ErrorModel { + /** + * Service specific error code which serves as the substatus for the HTTP error code. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly code?: string; + /** + * Service specific error type which serves as additional context for the error herein. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * Description of the error. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; + /** An array of additional nested error response info objects, as described by this contract. */ + details?: ErrorModel[]; +} + +/** 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} + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The name of the resource + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly systemData?: 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; +} + +/** Discovery response. */ +export interface DiscoveryResponse { + /** The list of solution metadata. */ + value?: SolutionMetadataResource[]; + /** The link used to get the next page of solution metadata. */ + nextLink?: 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 {} + +/** Diagnostic resource */ +export interface DiagnosticResource extends ProxyResource { + /** Global parameters that can be passed to all solutionIds. */ + globalParameters?: { [propertyName: string]: string }; + /** SolutionIds that are needed to be invoked. */ + insights?: DiagnosticInvocation[]; + /** + * Diagnostic Request Accepted time. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly acceptedAt?: string; + /** + * Status of diagnostic provisioning. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: ProvisioningState; + /** + * Array of Diagnostics. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly diagnostics?: Diagnostic[]; +} + +/** Solution Metadata resource */ +export interface SolutionMetadataResource extends ProxyResource { + /** Solution Id. */ + solutionId?: string; + /** Solution Type. */ + solutionType?: string; + /** A detailed description of solution. */ + description?: string; + /** Required parameters for invoking this particular solution. */ + requiredParameterSets?: string[][]; +} + +/** Known values of {@link Origin} that the service accepts. */ +export enum KnownOrigin { + /** User */ + User = "user", + /** System */ + System = "system", + /** UserSystem */ + UserSystem = "user,system" +} + +/** + * Defines values for Origin. \ + * {@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** \ + * **system** \ + * **user,system** + */ +export type Origin = string; + +/** Known values of {@link ActionType} that the service accepts. */ +export enum KnownActionType { + /** Internal */ + Internal = "Internal" +} + +/** + * Defines values for ActionType. \ + * {@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** + */ +export type ActionType = string; + +/** Known values of {@link ProvisioningState} that the service accepts. */ +export enum KnownProvisioningState { + /** All Diagnostics in the Batch succeeded. */ + Succeeded = "Succeeded", + /** Some Diagnostics are still running or failed. */ + PartialComplete = "PartialComplete", + /** All Diagnostics failed to run. */ + Failed = "Failed", + /** When Diagnostic request gets canceled. */ + Canceled = "Canceled" +} + +/** + * Defines values for ProvisioningState. \ + * {@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**: All Diagnostics in the Batch succeeded. \ + * **PartialComplete**: Some Diagnostics are still running or failed. \ + * **Failed**: All Diagnostics failed to run. \ + * **Canceled**: When Diagnostic request gets canceled. + */ +export type ProvisioningState = string; + +/** Known values of {@link Status} that the service accepts. */ +export enum KnownStatus { + /** Diagnostic creation failed. */ + Failed = "Failed", + /** Request is missing required inputs to run. */ + MissingInputs = "MissingInputs", + /** Diagnostic is still running. */ + Running = "Running", + /** Diagnostic creation succeeded. */ + Succeeded = "Succeeded", + /** Diagnostic was timed out. */ + Timeout = "Timeout" +} + +/** + * Defines values for Status. \ + * {@link KnownStatus} can be used interchangeably with Status, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Failed**: Diagnostic creation failed. \ + * **MissingInputs**: Request is missing required inputs to run. \ + * **Running**: Diagnostic is still running. \ + * **Succeeded**: Diagnostic creation succeeded. \ + * **Timeout**: Diagnostic was timed out. + */ +export type Status = string; + +/** Known values of {@link ImportanceLevel} that the service accepts. */ +export enum KnownImportanceLevel { + /** A critical insight has been found after running the diagnostic. */ + Critical = "Critical", + /** A warning insight has been found after running the diagnostic. */ + Warning = "Warning", + /** An information insight has been found after running the diagnostic. */ + Information = "Information" +} + +/** + * Defines values for ImportanceLevel. \ + * {@link KnownImportanceLevel} can be used interchangeably with ImportanceLevel, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Critical**: A critical insight has been found after running the diagnostic. \ + * **Warning**: A warning insight has been found after running the diagnostic. \ + * **Information**: An information insight has been found after running the diagnostic. + */ +export type ImportanceLevel = string; + +/** Known values of {@link CreatedByType} that the service accepts. */ +export enum KnownCreatedByType { + /** User */ + User = "User", + /** Application */ + Application = "Application", + /** ManagedIdentity */ + ManagedIdentity = "ManagedIdentity", + /** Key */ + Key = "Key" +} + +/** + * Defines values for CreatedByType. \ + * {@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** \ + * **Application** \ + * **ManagedIdentity** \ + * **Key** + */ +export type CreatedByType = string; + +/** Optional parameters. */ +export interface OperationsListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type OperationsListResponse = OperationListResult; + +/** Optional parameters. */ +export interface OperationsListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type OperationsListNextResponse = OperationListResult; + +/** Optional parameters. */ +export interface DiagnosticsCheckNameAvailabilityOptionalParams + extends coreClient.OperationOptions { + /** The required parameters for availability check. */ + checkNameAvailabilityRequest?: CheckNameAvailabilityRequest; +} + +/** Contains response data for the checkNameAvailability operation. */ +export type DiagnosticsCheckNameAvailabilityResponse = CheckNameAvailabilityResponse; + +/** Optional parameters. */ +export interface DiagnosticsCreateOptionalParams + extends coreClient.OperationOptions { + /** The required request body for this insightResource invocation. */ + diagnosticResourceRequest?: DiagnosticResource; + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the create operation. */ +export type DiagnosticsCreateResponse = DiagnosticResource; + +/** Optional parameters. */ +export interface DiagnosticsGetOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type DiagnosticsGetResponse = DiagnosticResource; + +/** Optional parameters. */ +export interface DiscoverySolutionListOptionalParams + extends coreClient.OperationOptions { + /** Can be used to filter solutionIds by 'ProblemClassificationId'. The filter supports only 'and' and 'eq' operators. Example: $filter=ProblemClassificationId eq '1ddda5b4-cf6c-4d4f-91ad-bc38ab0e811e' and ProblemClassificationId eq '0a9673c2-7af6-4e19-90d3-4ee2461076d9'. */ + filter?: string; + /** Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. */ + skiptoken?: string; +} + +/** Contains response data for the list operation. */ +export type DiscoverySolutionListResponse = DiscoveryResponse; + +/** Optional parameters. */ +export interface DiscoverySolutionListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type DiscoverySolutionListNextResponse = DiscoveryResponse; + +/** Optional parameters. */ +export interface HelpRPOptionalParams extends coreClient.ServiceClientOptions { + /** server parameter */ + $host?: string; + /** Api Version */ + apiVersion?: string; + /** Overrides client endpoint. */ + endpoint?: string; +} diff --git a/sdk/selfhelp/arm-selfhelp/src/models/mappers.ts b/sdk/selfhelp/arm-selfhelp/src/models/mappers.ts new file mode 100644 index 000000000000..5a15ea26542d --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/models/mappers.ts @@ -0,0 +1,619 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; + +export const OperationListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationListResult", + modelProperties: { + value: { + serializedName: "value", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Operation" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const Operation: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Operation", + modelProperties: { + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + isDataAction: { + serializedName: "isDataAction", + readOnly: true, + type: { + name: "Boolean" + } + }, + display: { + serializedName: "display", + type: { + name: "Composite", + className: "OperationDisplay" + } + }, + origin: { + serializedName: "origin", + readOnly: true, + type: { + name: "String" + } + }, + actionType: { + serializedName: "actionType", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const OperationDisplay: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationDisplay", + modelProperties: { + provider: { + serializedName: "provider", + readOnly: true, + type: { + name: "String" + } + }, + resource: { + serializedName: "resource", + readOnly: true, + type: { + name: "String" + } + }, + operation: { + serializedName: "operation", + readOnly: true, + type: { + name: "String" + } + }, + description: { + serializedName: "description", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const ErrorResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ErrorDetail" + } + } + } + } +}; + +export const ErrorDetail: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorDetail", + modelProperties: { + code: { + serializedName: "code", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String" + } + }, + target: { + serializedName: "target", + readOnly: true, + type: { + name: "String" + } + }, + details: { + serializedName: "details", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorDetail" + } + } + } + }, + additionalInfo: { + serializedName: "additionalInfo", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorAdditionalInfo" + } + } + } + } + } + } +}; + +export const ErrorAdditionalInfo: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorAdditionalInfo", + modelProperties: { + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + info: { + serializedName: "info", + readOnly: true, + type: { + name: "Dictionary", + value: { type: { name: "any" } } + } + } + } + } +}; + +export const CheckNameAvailabilityRequest: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CheckNameAvailabilityRequest", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + }, + type: { + serializedName: "type", + type: { + name: "String" + } + } + } + } +}; + +export const CheckNameAvailabilityResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CheckNameAvailabilityResponse", + modelProperties: { + nameAvailable: { + serializedName: "nameAvailable", + type: { + name: "Boolean" + } + }, + reason: { + serializedName: "reason", + type: { + name: "String" + } + }, + message: { + serializedName: "message", + type: { + name: "String" + } + } + } + } +}; + +export const DiagnosticInvocation: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "DiagnosticInvocation", + modelProperties: { + solutionId: { + serializedName: "solutionId", + type: { + name: "String" + } + }, + additionalParameters: { + serializedName: "additionalParameters", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + } + } + } +}; + +export const Diagnostic: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Diagnostic", + modelProperties: { + solutionId: { + serializedName: "solutionId", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + insights: { + serializedName: "insights", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Insight" + } + } + } + }, + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ErrorModel" + } + } + } + } +}; + +export const Insight: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Insight", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + title: { + serializedName: "title", + type: { + name: "String" + } + }, + results: { + serializedName: "results", + type: { + name: "String" + } + }, + importanceLevel: { + serializedName: "importanceLevel", + type: { + name: "String" + } + } + } + } +}; + +export const ErrorModel: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorModel", + modelProperties: { + code: { + serializedName: "code", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String" + } + }, + details: { + serializedName: "details", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorModel" + } + } + } + } + } + } +}; + +export const Resource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Resource", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + systemData: { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData" + } + } + } + } +}; + +export const SystemData: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "SystemData", + modelProperties: { + createdBy: { + serializedName: "createdBy", + type: { + name: "String" + } + }, + createdByType: { + serializedName: "createdByType", + type: { + name: "String" + } + }, + createdAt: { + serializedName: "createdAt", + type: { + name: "DateTime" + } + }, + lastModifiedBy: { + serializedName: "lastModifiedBy", + type: { + name: "String" + } + }, + lastModifiedByType: { + serializedName: "lastModifiedByType", + type: { + name: "String" + } + }, + lastModifiedAt: { + serializedName: "lastModifiedAt", + type: { + name: "DateTime" + } + } + } + } +}; + +export const DiscoveryResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "DiscoveryResponse", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "SolutionMetadataResource" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const ProxyResource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ProxyResource", + modelProperties: { + ...Resource.type.modelProperties + } + } +}; + +export const DiagnosticResource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "DiagnosticResource", + modelProperties: { + ...ProxyResource.type.modelProperties, + globalParameters: { + serializedName: "properties.globalParameters", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + }, + insights: { + serializedName: "properties.insights", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "DiagnosticInvocation" + } + } + } + }, + acceptedAt: { + serializedName: "properties.acceptedAt", + readOnly: true, + type: { + name: "String" + } + }, + provisioningState: { + serializedName: "properties.provisioningState", + readOnly: true, + type: { + name: "String" + } + }, + diagnostics: { + serializedName: "properties.diagnostics", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Diagnostic" + } + } + } + } + } + } +}; + +export const SolutionMetadataResource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "SolutionMetadataResource", + modelProperties: { + ...ProxyResource.type.modelProperties, + solutionId: { + serializedName: "properties.solutionId", + type: { + name: "String" + } + }, + solutionType: { + serializedName: "properties.solutionType", + type: { + name: "String" + } + }, + description: { + serializedName: "properties.description", + type: { + name: "String" + } + }, + requiredParameterSets: { + serializedName: "properties.requiredParameterSets", + type: { + name: "Sequence", + element: { + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + } + } + } + } + } +}; diff --git a/sdk/selfhelp/arm-selfhelp/src/models/parameters.ts b/sdk/selfhelp/arm-selfhelp/src/models/parameters.ts new file mode 100644 index 000000000000..74af997ea983 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/models/parameters.ts @@ -0,0 +1,136 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + OperationParameter, + OperationURLParameter, + OperationQueryParameter +} from "@azure/core-client"; +import { + CheckNameAvailabilityRequest as CheckNameAvailabilityRequestMapper, + DiagnosticResource as DiagnosticResourceMapper +} from "../models/mappers"; + +export const accept: OperationParameter = { + parameterPath: "accept", + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Accept", + type: { + name: "String" + } + } +}; + +export const $host: OperationURLParameter = { + parameterPath: "$host", + mapper: { + serializedName: "$host", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const apiVersion: OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "2023-01-01-preview", + isConstant: true, + serializedName: "api-version", + type: { + name: "String" + } + } +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", + mapper: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String" + } + } +}; + +export const checkNameAvailabilityRequest: OperationParameter = { + parameterPath: ["options", "checkNameAvailabilityRequest"], + mapper: CheckNameAvailabilityRequestMapper +}; + +export const scope: OperationURLParameter = { + parameterPath: "scope", + mapper: { + serializedName: "scope", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const diagnosticResourceRequest: OperationParameter = { + parameterPath: ["options", "diagnosticResourceRequest"], + mapper: DiagnosticResourceMapper +}; + +export const diagnosticsResourceName: OperationURLParameter = { + parameterPath: "diagnosticsResourceName", + mapper: { + constraints: { + Pattern: new RegExp("^[A-Za-z0-9-+@()_]+$"), + MaxLength: 100, + MinLength: 1 + }, + serializedName: "diagnosticsResourceName", + required: true, + type: { + name: "String" + } + } +}; + +export const filter: OperationQueryParameter = { + parameterPath: ["options", "filter"], + mapper: { + serializedName: "$filter", + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const skiptoken: OperationQueryParameter = { + parameterPath: ["options", "skiptoken"], + mapper: { + serializedName: "$skiptoken", + type: { + name: "String" + } + } +}; diff --git a/sdk/selfhelp/arm-selfhelp/src/operations/diagnostics.ts b/sdk/selfhelp/arm-selfhelp/src/operations/diagnostics.ts new file mode 100644 index 000000000000..030eaee79c88 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/operations/diagnostics.ts @@ -0,0 +1,249 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { Diagnostics } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { HelpRP } from "../helpRP"; +import { + SimplePollerLike, + OperationState, + createHttpPoller +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; +import { + DiagnosticsCheckNameAvailabilityOptionalParams, + DiagnosticsCheckNameAvailabilityResponse, + DiagnosticsCreateOptionalParams, + DiagnosticsCreateResponse, + DiagnosticsGetOptionalParams, + DiagnosticsGetResponse +} from "../models"; + +/** Class containing Diagnostics operations. */ +export class DiagnosticsImpl implements Diagnostics { + private readonly client: HelpRP; + + /** + * Initialize a new instance of the class Diagnostics class. + * @param client Reference to the service client + */ + constructor(client: HelpRP) { + this.client = client; + } + + /** + * This API is used to check the uniqueness of a resource name used for a diagnostic check. + * @param scope This is an extension resource provider and only resource level extension is supported + * at the moment. + * @param options The options parameters. + */ + checkNameAvailability( + scope: string, + options?: DiagnosticsCheckNameAvailabilityOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { scope, options }, + checkNameAvailabilityOperationSpec + ); + } + + /** + * Diagnostics tells you precisely the root cause of the issue and how to address it. You can get + * diagnostics once you discover and identify the relevant solution for your Azure issue.

You + * can create diagnostics using the ‘solutionId’ from Solution Discovery API response and + * ‘additionalParameters’

Note: ‘requiredParameterSets’ from Solutions Discovery API + * response must be passed via ‘additionalParameters’ as an input to Diagnostics API + * @param scope This is an extension resource provider and only resource level extension is supported + * at the moment. + * @param diagnosticsResourceName Unique resource name for insight resources + * @param options The options parameters. + */ + async beginCreate( + scope: string, + diagnosticsResourceName: string, + options?: DiagnosticsCreateOptionalParams + ): Promise< + SimplePollerLike< + OperationState, + DiagnosticsCreateResponse + > + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperationFn = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ) => { + let currentRawResponse: + | coreClient.FullOperationResponse + | undefined = undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback + } + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON() + } + }; + }; + + const lro = createLroSpec({ + sendOperationFn, + args: { scope, diagnosticsResourceName, options }, + spec: createOperationSpec + }); + const poller = await createHttpPoller< + DiagnosticsCreateResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: "azure-async-operation" + }); + await poller.poll(); + return poller; + } + + /** + * Diagnostics tells you precisely the root cause of the issue and how to address it. You can get + * diagnostics once you discover and identify the relevant solution for your Azure issue.

You + * can create diagnostics using the ‘solutionId’ from Solution Discovery API response and + * ‘additionalParameters’

Note: ‘requiredParameterSets’ from Solutions Discovery API + * response must be passed via ‘additionalParameters’ as an input to Diagnostics API + * @param scope This is an extension resource provider and only resource level extension is supported + * at the moment. + * @param diagnosticsResourceName Unique resource name for insight resources + * @param options The options parameters. + */ + async beginCreateAndWait( + scope: string, + diagnosticsResourceName: string, + options?: DiagnosticsCreateOptionalParams + ): Promise { + const poller = await this.beginCreate( + scope, + diagnosticsResourceName, + options + ); + return poller.pollUntilDone(); + } + + /** + * Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. + * @param scope This is an extension resource provider and only resource level extension is supported + * at the moment. + * @param diagnosticsResourceName Unique resource name for insight resources + * @param options The options parameters. + */ + get( + scope: string, + diagnosticsResourceName: string, + options?: DiagnosticsGetOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { scope, diagnosticsResourceName, options }, + getOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const checkNameAvailabilityOperationSpec: coreClient.OperationSpec = { + path: "/{scope}/providers/Microsoft.Help/checkNameAvailability", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.CheckNameAvailabilityResponse + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: Parameters.checkNameAvailabilityRequest, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.scope], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const createOperationSpec: coreClient.OperationSpec = { + path: + "/{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}", + httpMethod: "PUT", + responses: { + 200: { + bodyMapper: Mappers.DiagnosticResource + }, + 201: { + bodyMapper: Mappers.DiagnosticResource + }, + 202: { + bodyMapper: Mappers.DiagnosticResource + }, + 204: { + bodyMapper: Mappers.DiagnosticResource + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: Parameters.diagnosticResourceRequest, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.scope, + Parameters.diagnosticsResourceName + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const getOperationSpec: coreClient.OperationSpec = { + path: + "/{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.DiagnosticResource + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.scope, + Parameters.diagnosticsResourceName + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/selfhelp/arm-selfhelp/src/operations/discoverySolution.ts b/sdk/selfhelp/arm-selfhelp/src/operations/discoverySolution.ts new file mode 100644 index 000000000000..d11a848d2cdc --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/operations/discoverySolution.ts @@ -0,0 +1,179 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { DiscoverySolution } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { HelpRP } from "../helpRP"; +import { + SolutionMetadataResource, + DiscoverySolutionListNextOptionalParams, + DiscoverySolutionListOptionalParams, + DiscoverySolutionListResponse, + DiscoverySolutionListNextResponse +} from "../models"; + +/// +/** Class containing DiscoverySolution operations. */ +export class DiscoverySolutionImpl implements DiscoverySolution { + private readonly client: HelpRP; + + /** + * Initialize a new instance of the class DiscoverySolution class. + * @param client Reference to the service client + */ + constructor(client: HelpRP) { + this.client = client; + } + + /** + * Solutions Discovery is the initial point of entry within Help API, which helps you identify the + * relevant solutions for your Azure issue.

You can discover solutions using resourceUri OR + * resourceUri + problemClassificationId.

We will do our best in returning relevant + * diagnostics for your Azure issue.

Get the problemClassificationId(s) using this + * [reference](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP).

+ * Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via + * ‘additionalParameters’ as an input to Diagnostics API. + * @param scope This is an extension resource provider and only resource level extension is supported + * at the moment. + * @param options The options parameters. + */ + public list( + scope: string, + options?: DiscoverySolutionListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(scope, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(scope, options, settings); + } + }; + } + + private async *listPagingPage( + scope: string, + options?: DiscoverySolutionListOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: DiscoverySolutionListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(scope, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listNext(scope, continuationToken, options); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listPagingAll( + scope: string, + options?: DiscoverySolutionListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(scope, options)) { + yield* page; + } + } + + /** + * Solutions Discovery is the initial point of entry within Help API, which helps you identify the + * relevant solutions for your Azure issue.

You can discover solutions using resourceUri OR + * resourceUri + problemClassificationId.

We will do our best in returning relevant + * diagnostics for your Azure issue.

Get the problemClassificationId(s) using this + * [reference](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP).

+ * Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via + * ‘additionalParameters’ as an input to Diagnostics API. + * @param scope This is an extension resource provider and only resource level extension is supported + * at the moment. + * @param options The options parameters. + */ + private _list( + scope: string, + options?: DiscoverySolutionListOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { scope, options }, + listOperationSpec + ); + } + + /** + * ListNext + * @param scope This is an extension resource provider and only resource level extension is supported + * at the moment. + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + scope: string, + nextLink: string, + options?: DiscoverySolutionListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { scope, nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreClient.OperationSpec = { + path: "/{scope}/providers/Microsoft.Help/discoverySolutions", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.DiscoveryResponse + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [ + Parameters.apiVersion, + Parameters.filter, + Parameters.skiptoken + ], + urlParameters: [Parameters.$host, Parameters.scope], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.DiscoveryResponse + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + urlParameters: [Parameters.$host, Parameters.nextLink, Parameters.scope], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/selfhelp/arm-selfhelp/src/operations/index.ts b/sdk/selfhelp/arm-selfhelp/src/operations/index.ts new file mode 100644 index 000000000000..4ee86d82b8ef --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/operations/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export * from "./operations"; +export * from "./diagnostics"; +export * from "./discoverySolution"; diff --git a/sdk/selfhelp/arm-selfhelp/src/operations/operations.ts b/sdk/selfhelp/arm-selfhelp/src/operations/operations.ts new file mode 100644 index 000000000000..0bb34b7e54bc --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/operations/operations.ts @@ -0,0 +1,149 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { Operations } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { HelpRP } from "../helpRP"; +import { + Operation, + OperationsListNextOptionalParams, + OperationsListOptionalParams, + OperationsListResponse, + OperationsListNextResponse +} from "../models"; + +/// +/** Class containing Operations operations. */ +export class OperationsImpl implements Operations { + private readonly client: HelpRP; + + /** + * Initialize a new instance of the class Operations class. + * @param client Reference to the service client + */ + constructor(client: HelpRP) { + this.client = client; + } + + /** + * Returns list of operations. + * @param options The options parameters. + */ + public list( + options?: OperationsListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); + } + }; + } + + private async *listPagingPage( + options?: OperationsListOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: OperationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listNext(continuationToken, options); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listPagingAll( + options?: OperationsListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } + } + + /** + * Returns list of operations. + * @param options The options parameters. + */ + private _list( + options?: OperationsListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + + /** + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + nextLink: string, + options?: OperationsListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Help/operations", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/diagnostics.ts b/sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/diagnostics.ts new file mode 100644 index 000000000000..52eb32c7b1a2 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/diagnostics.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { SimplePollerLike, OperationState } from "@azure/core-lro"; +import { + DiagnosticsCheckNameAvailabilityOptionalParams, + DiagnosticsCheckNameAvailabilityResponse, + DiagnosticsCreateOptionalParams, + DiagnosticsCreateResponse, + DiagnosticsGetOptionalParams, + DiagnosticsGetResponse +} from "../models"; + +/** Interface representing a Diagnostics. */ +export interface Diagnostics { + /** + * This API is used to check the uniqueness of a resource name used for a diagnostic check. + * @param scope This is an extension resource provider and only resource level extension is supported + * at the moment. + * @param options The options parameters. + */ + checkNameAvailability( + scope: string, + options?: DiagnosticsCheckNameAvailabilityOptionalParams + ): Promise; + /** + * Diagnostics tells you precisely the root cause of the issue and how to address it. You can get + * diagnostics once you discover and identify the relevant solution for your Azure issue.

You + * can create diagnostics using the ‘solutionId’ from Solution Discovery API response and + * ‘additionalParameters’

Note: ‘requiredParameterSets’ from Solutions Discovery API + * response must be passed via ‘additionalParameters’ as an input to Diagnostics API + * @param scope This is an extension resource provider and only resource level extension is supported + * at the moment. + * @param diagnosticsResourceName Unique resource name for insight resources + * @param options The options parameters. + */ + beginCreate( + scope: string, + diagnosticsResourceName: string, + options?: DiagnosticsCreateOptionalParams + ): Promise< + SimplePollerLike< + OperationState, + DiagnosticsCreateResponse + > + >; + /** + * Diagnostics tells you precisely the root cause of the issue and how to address it. You can get + * diagnostics once you discover and identify the relevant solution for your Azure issue.

You + * can create diagnostics using the ‘solutionId’ from Solution Discovery API response and + * ‘additionalParameters’

Note: ‘requiredParameterSets’ from Solutions Discovery API + * response must be passed via ‘additionalParameters’ as an input to Diagnostics API + * @param scope This is an extension resource provider and only resource level extension is supported + * at the moment. + * @param diagnosticsResourceName Unique resource name for insight resources + * @param options The options parameters. + */ + beginCreateAndWait( + scope: string, + diagnosticsResourceName: string, + options?: DiagnosticsCreateOptionalParams + ): Promise; + /** + * Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. + * @param scope This is an extension resource provider and only resource level extension is supported + * at the moment. + * @param diagnosticsResourceName Unique resource name for insight resources + * @param options The options parameters. + */ + get( + scope: string, + diagnosticsResourceName: string, + options?: DiagnosticsGetOptionalParams + ): Promise; +} diff --git a/sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/discoverySolution.ts b/sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/discoverySolution.ts new file mode 100644 index 000000000000..c21be941bec7 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/discoverySolution.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { + SolutionMetadataResource, + DiscoverySolutionListOptionalParams +} from "../models"; + +/// +/** Interface representing a DiscoverySolution. */ +export interface DiscoverySolution { + /** + * Solutions Discovery is the initial point of entry within Help API, which helps you identify the + * relevant solutions for your Azure issue.

You can discover solutions using resourceUri OR + * resourceUri + problemClassificationId.

We will do our best in returning relevant + * diagnostics for your Azure issue.

Get the problemClassificationId(s) using this + * [reference](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP).

+ * Note: ‘requiredParameterSets’ from Solutions Discovery API response must be passed via + * ‘additionalParameters’ as an input to Diagnostics API. + * @param scope This is an extension resource provider and only resource level extension is supported + * at the moment. + * @param options The options parameters. + */ + list( + scope: string, + options?: DiscoverySolutionListOptionalParams + ): PagedAsyncIterableIterator; +} diff --git a/sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/index.ts b/sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/index.ts new file mode 100644 index 000000000000..4ee86d82b8ef --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export * from "./operations"; +export * from "./diagnostics"; +export * from "./discoverySolution"; diff --git a/sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/operations.ts b/sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/operations.ts new file mode 100644 index 000000000000..0c50b09b459e --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/operationsInterfaces/operations.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Operation, OperationsListOptionalParams } from "../models"; + +/// +/** Interface representing a Operations. */ +export interface Operations { + /** + * Returns list of operations. + * @param options The options parameters. + */ + list( + options?: OperationsListOptionalParams + ): PagedAsyncIterableIterator; +} diff --git a/sdk/selfhelp/arm-selfhelp/src/pagingHelper.ts b/sdk/selfhelp/arm-selfhelp/src/pagingHelper.ts new file mode 100644 index 000000000000..269a2b9814b5 --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/selfhelp/arm-selfhelp/test/selfhelp_operations_test.spec.ts b/sdk/selfhelp/arm-selfhelp/test/selfhelp_operations_test.spec.ts new file mode 100644 index 000000000000..d15bf611887e --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/test/selfhelp_operations_test.spec.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + env, + Recorder, + RecorderStartOptions, + delay, + isPlaybackMode, +} from "@azure-tools/test-recorder"; +import { createTestCredential } from "@azure-tools/test-credential"; +import { assert } from "chai"; +import { Context } from "mocha"; +import { HelpRP } from "../src/helpRP"; + +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables +}; + +export const testPollingOptions = { + updateIntervalInMs: isPlaybackMode() ? 0 : undefined, +}; + +describe("help test", () => { + let recorder: Recorder; + let subscriptionId: string; + let client: HelpRP; + let location: string; + let resourceGroup: string; + let resourcename: string; + let scope: string; + + beforeEach(async function (this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); + subscriptionId = env.SUBSCRIPTION_ID || ''; + // This is an example of how the environment variables are used + const credential = createTestCredential(); + client = new HelpRP(credential, recorder.configureClientOptions({})); + location = "eastus"; + resourceGroup = "czwjstest"; + resourcename = "resourcetest"; + scope = "subscriptions/" + subscriptionId; + }); + + afterEach(async function () { + await recorder.stop(); + }); + + it("selfhelp checkname test", async function () { + const res = await client.diagnostics.checkNameAvailability( + scope, + { + checkNameAvailabilityRequest: { + name: "sampleName", + type: "Microsoft.Help/diagnostics" + } + }); + }); + +}) diff --git a/sdk/selfhelp/arm-selfhelp/tsconfig.json b/sdk/selfhelp/arm-selfhelp/tsconfig.json new file mode 100644 index 000000000000..43c53468dfed --- /dev/null +++ b/sdk/selfhelp/arm-selfhelp/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "module": "es6", + "moduleResolution": "node", + "strict": true, + "target": "es6", + "sourceMap": true, + "declarationMap": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "lib": [ + "es6", + "dom" + ], + "declaration": true, + "outDir": "./dist-esm", + "importHelpers": true, + "paths": { + "@azure/arm-selfhelp": [ + "./src/index" + ] + } + }, + "include": [ + "./src/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/selfhelp/ci.mgmt.yml b/sdk/selfhelp/ci.mgmt.yml new file mode 100644 index 000000000000..95c48914c3cd --- /dev/null +++ b/sdk/selfhelp/ci.mgmt.yml @@ -0,0 +1,38 @@ +# 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/selfhelp/arm-selfhelp + - sdk/selfhelp/ci.mgmt.yml + +pr: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/selfhelp/arm-selfhelp + - sdk/selfhelp/ci.mgmt.yml + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: selfhelp + Artifacts: + - name: azure-arm-selfhelp + safeName: azurearmselfhelp + \ No newline at end of file