diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 2070f801ace2..7f71426fa505 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -9654,7 +9654,7 @@ packages: dev: false file:projects/arm-cognitiveservices.tgz: - resolution: {integrity: sha512-TVvxQMYtcXgUfUms4MqQHE5zcUpCzg4eZK2VJmqQ14/paJG2amXdO2+wo96DbIzy1ay8xA5UYZH5zaMtEWY6tQ==, tarball: file:projects/arm-cognitiveservices.tgz} + resolution: {integrity: sha512-5ft5zJVV/bD87pD20Gk+GbCy0EVtHJwVIptjnVlrK5Z/iAlNCK0uCvqYjr0DKhQHI8wp3biKOOZbfCE8xrG/Fw==, tarball: file:projects/arm-cognitiveservices.tgz} name: '@rush-temp/arm-cognitiveservices' version: 0.0.0 dependencies: @@ -9663,18 +9663,19 @@ packages: '@microsoft/api-extractor': 7.19.5 '@rollup/plugin-commonjs': 21.0.2_rollup@2.70.1 '@rollup/plugin-json': 4.1.0_rollup@2.70.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@2.70.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@2.70.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 + '@rollup/plugin-node-resolve': 13.1.3_rollup@2.70.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.70.1 - rollup-plugin-sourcemaps: 0.4.2_rollup@2.70.1 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.3 transitivePeerDependencies: + - '@types/node' - debug - encoding - supports-color diff --git a/sdk/cognitiveservices/arm-cognitiveservices/CHANGELOG.md b/sdk/cognitiveservices/arm-cognitiveservices/CHANGELOG.md index 054942469b81..d527f22c4f60 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/CHANGELOG.md +++ b/sdk/cognitiveservices/arm-cognitiveservices/CHANGELOG.md @@ -1,15 +1,23 @@ # Release History - -## 7.0.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + +## 7.1.0 (2022-03-28) + +**Features** + + - Added operation Accounts.listModels + - Added Interface AccountModelListResult + - Added Interface AccountsListModelsNextOptionalParams + - Added Interface AccountsListModelsOptionalParams + - Added Interface ModelDeprecationInfo + - Added Type Alias AccountModel + - Added Type Alias AccountsListModelsNextResponse + - Added Type Alias AccountsListModelsResponse + - Interface AccountProperties has a new optional parameter deletionDate + - Interface AccountProperties has a new optional parameter dynamicThrottlingEnabled + - Interface AccountProperties has a new optional parameter scheduledPurgeDate + - Interface DeploymentScaleSettings has a new optional parameter activeCapacity + + ## 7.0.0 (2021-12-20) The package of @azure/arm-cognitiveservices is using our next generation design principles since version 7.0.0, which contains breaking changes. diff --git a/sdk/cognitiveservices/arm-cognitiveservices/LICENSE b/sdk/cognitiveservices/arm-cognitiveservices/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/LICENSE +++ b/sdk/cognitiveservices/arm-cognitiveservices/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 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 diff --git a/sdk/cognitiveservices/arm-cognitiveservices/README.md b/sdk/cognitiveservices/arm-cognitiveservices/README.md index 5ce5baad6480..15f2d746332b 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/README.md +++ b/sdk/cognitiveservices/arm-cognitiveservices/README.md @@ -16,6 +16,8 @@ Cognitive Services Management Client - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,8 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); 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 subscriptionId = "00000000-0000-0000-0000-000000000000"; const client = new CognitiveServicesManagementClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new CognitiveServicesManagementClient(credential, subscriptionId); ``` diff --git a/sdk/cognitiveservices/arm-cognitiveservices/_meta.json b/sdk/cognitiveservices/arm-cognitiveservices/_meta.json index 5f8bb5abc3fb..df6e988fa264 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/_meta.json +++ b/sdk/cognitiveservices/arm-cognitiveservices/_meta.json @@ -1,7 +1,8 @@ { - "commit": "d967edeee8fd6af6d40bffe53cceed1bd053d7ad", + "commit": "d9e9cdfe86eb9f3098d716236b3ba407d8e6e984", "readme": "specification/cognitiveservices/resource-manager/readme.md", - "autorest_command": "autorest --version=3.1.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/cognitiveservices/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211217.1", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\cognitiveservices\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-beta.17 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211217.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.1", + "use": "@autorest/typescript@6.0.0-beta.17" } \ No newline at end of file diff --git a/sdk/cognitiveservices/arm-cognitiveservices/api-extractor.json b/sdk/cognitiveservices/arm-cognitiveservices/api-extractor.json index c93b52f9e3ef..486163c73c91 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/api-extractor.json +++ b/sdk/cognitiveservices/arm-cognitiveservices/api-extractor.json @@ -1,18 +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" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-cognitiveservices.d.ts" }, "messages": { - "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, "extractorMessageReporting": { - "ae-missing-release-tag": { "logLevel": "none" }, - "ae-unresolved-link": { "logLevel": "none" } + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } } } -} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/arm-cognitiveservices/package.json b/sdk/cognitiveservices/arm-cognitiveservices/package.json index 8e12c3e018ae..a5eb4d5c3286 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/package.json +++ b/sdk/cognitiveservices/arm-cognitiveservices/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for CognitiveServicesManagementClient.", - "version": "7.0.1", + "version": "7.1.0", "engines": { "node": ">=12.0.0" }, @@ -30,12 +30,12 @@ "devDependencies": { "@microsoft/api-extractor": "^7.18.11", "@rollup/plugin-commonjs": "^21.0.1", - "@rollup/plugin-json": "^4.0.0", - "@rollup/plugin-multi-entry": "^3.0.0", - "@rollup/plugin-node-resolve": "^8.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-multi-entry": "^4.1.0", + "@rollup/plugin-node-resolve": "^13.1.3", "mkdirp": "^1.0.4", - "rollup": "^2.0.0", - "rollup-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -98,5 +98,21 @@ "docs": "echo skipped" }, "sideEffects": false, - "autoPublish": true -} + "//metadata": { + "constantPaths": [ + { + "path": "src/cognitiveServicesManagementClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-cognitiveservices?view=azure-node-preview" + } +} \ No newline at end of file diff --git a/sdk/cognitiveservices/arm-cognitiveservices/review/arm-cognitiveservices.api.md b/sdk/cognitiveservices/arm-cognitiveservices/review/arm-cognitiveservices.api.md index 3f223a5b3e31..98a3ca0cfb09 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/review/arm-cognitiveservices.api.md +++ b/sdk/cognitiveservices/arm-cognitiveservices/review/arm-cognitiveservices.api.md @@ -29,6 +29,23 @@ export interface AccountListResult { readonly value?: Account[]; } +// @public +export type AccountModel = DeploymentModel & { + baseModel?: DeploymentModel; + maxCapacity?: number; + capabilities?: { + [propertyName: string]: string; + }; + deprecation?: ModelDeprecationInfo; + readonly systemData?: SystemData; +}; + +// @public +export interface AccountModelListResult { + nextLink?: string; + value?: AccountModel[]; +} + // @public export interface AccountProperties { // (undocumented) @@ -38,8 +55,10 @@ export interface AccountProperties { readonly capabilities?: SkuCapability[]; customSubDomainName?: string; readonly dateCreated?: string; + readonly deletionDate?: string; // (undocumented) disableLocalAuth?: boolean; + dynamicThrottlingEnabled?: boolean; encryption?: Encryption; readonly endpoint?: string; readonly endpoints?: { @@ -57,6 +76,7 @@ export interface AccountProperties { restore?: boolean; // (undocumented) restrictOutboundNetworkAccess?: boolean; + readonly scheduledPurgeDate?: string; readonly skuChangeInfo?: SkuChangeInfo; userOwnedStorage?: UserOwnedStorage[]; } @@ -73,6 +93,7 @@ export interface Accounts { list(options?: AccountsListOptionalParams): PagedAsyncIterableIterator; listByResourceGroup(resourceGroupName: string, options?: AccountsListByResourceGroupOptionalParams): PagedAsyncIterableIterator; listKeys(resourceGroupName: string, accountName: string, options?: AccountsListKeysOptionalParams): Promise; + listModels(resourceGroupName: string, accountName: string, options?: AccountsListModelsOptionalParams): PagedAsyncIterableIterator; listSkus(resourceGroupName: string, accountName: string, options?: AccountsListSkusOptionalParams): Promise; listUsages(resourceGroupName: string, accountName: string, options?: AccountsListUsagesOptionalParams): Promise; regenerateKey(resourceGroupName: string, accountName: string, keyName: KeyName, options?: AccountsRegenerateKeyOptionalParams): Promise; @@ -132,6 +153,20 @@ export interface AccountsListKeysOptionalParams extends coreClient.OperationOpti // @public export type AccountsListKeysResponse = ApiKeys; +// @public +export interface AccountsListModelsNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AccountsListModelsNextResponse = AccountModelListResult; + +// @public +export interface AccountsListModelsOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AccountsListModelsResponse = AccountModelListResult; + // @public export interface AccountsListNextOptionalParams extends coreClient.OperationOptions { } @@ -485,6 +520,7 @@ export interface Deployments { // @public export interface DeploymentScaleSettings { + readonly activeCapacity?: number; capacity?: number; scaleType?: DeploymentScaleType; } @@ -778,6 +814,12 @@ export interface MetricName { value?: string; } +// @public +export interface ModelDeprecationInfo { + fineTune?: string; + inference?: string; +} + // @public export type NetworkRuleAction = string; diff --git a/sdk/cognitiveservices/arm-cognitiveservices/rollup.config.js b/sdk/cognitiveservices/arm-cognitiveservices/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/rollup.config.js +++ b/sdk/cognitiveservices/arm-cognitiveservices/rollup.config.js @@ -14,62 +14,14 @@ import json from "@rollup/plugin-json"; import nodeBuiltins from "builtin-modules"; -/** - * Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api. - * - * NOTE: this manual configuration is only needed because OpenTelemetry uses an - * __exportStar downleveled helper function to declare its exports which confuses - * rollup's automatic discovery mechanism. - * - * @returns an object reference that can be `...`'d into your cjs() configuration. - */ -export function openTelemetryCommonJs() { - const namedExports = {}; - - for (const key of [ - "@opentelemetry/api", - "@azure/core-tracing/node_modules/@opentelemetry/api" - ]) { - namedExports[key] = [ - "SpanKind", - "TraceFlags", - "getSpan", - "setSpan", - "SpanStatusCode", - "getSpanContext", - "setSpanContext" - ]; - } - - const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"]; - - for (const version of releasedOpenTelemetryVersions) { - namedExports[ - // working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path. - `../../../common/temp/node_modules/.pnpm/@opentelemetry/api@${version}/node_modules/@opentelemetry/api/build/src/index.js` - ] = [ - "SpanKind", - "TraceFlags", - "getSpan", - "setSpan", - "StatusCode", - "CanonicalCode", - "getSpanContext", - "setSpanContext" - ]; - } - - return namedExports; -} - // #region Warning Handler /** - * A function that can determine whether a rollupwarning should be ignored. If + * 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 ignoreNiseSinonEvalWarnings(warning) { +function ignoreNiseSinonEval(warning) { return ( warning.code === "EVAL" && warning.id && @@ -78,17 +30,14 @@ function ignoreNiseSinonEvalWarnings(warning) { ); } -function ignoreChaiCircularDependencyWarnings(warning) { +function ignoreChaiCircularDependency(warning) { return ( warning.code === "CIRCULAR_DEPENDENCY" && warning.importer && warning.importer.includes("node_modules/chai") === true ); } -const warningInhibitors = [ - ignoreChaiCircularDependencyWarnings, - ignoreNiseSinonEvalWarnings -]; +const warningInhibitors = [ignoreChaiCircularDependency, ignoreNiseSinonEval]; /** * Construct a warning handler for the shared rollup configuration @@ -122,22 +71,7 @@ function makeBrowserTestConfig() { nodeResolve({ mainFields: ["module", "browser"] }), - cjs({ - namedExports: { - // Chai's strange internal architecture makes it impossible to statically - // analyze its exports. - chai: [ - "version", - "use", - "util", - "config", - "expect", - "should", - "assert" - ], - ...openTelemetryCommonJs() - } - }), + cjs(), json(), sourcemaps() //viz({ filename: "dist-test/browser-stats.html", sourcemap: true }) @@ -173,7 +107,7 @@ export function makeConfig(pkg, options) { ], output: { file: "dist/index.js", format: "cjs", sourcemap: true }, preserveSymlinks: false, - plugins: [sourcemaps(), nodeResolve(), cjs()] + plugins: [sourcemaps(), nodeResolve()] }; const config = [baseConfig]; diff --git a/sdk/cognitiveservices/arm-cognitiveservices/sample.env b/sdk/cognitiveservices/arm-cognitiveservices/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/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/cognitiveservices/arm-cognitiveservices/samples-dev/accountsCreateSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsCreateSample.ts new file mode 100644 index 000000000000..9b453d7265d4 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsCreateSample.ts @@ -0,0 +1,94 @@ +/* + * 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 { + Account, + CognitiveServicesManagementClient +} from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. + * + * @summary Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CreateAccount.json + */ +async function createAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "testCreate1"; + const account: Account = { + identity: { type: "SystemAssigned" }, + kind: "Emotion", + location: "West US", + properties: { + encryption: { + keySource: "Microsoft.KeyVault", + keyVaultProperties: { + keyName: "KeyName", + keyVaultUri: "https://pltfrmscrts-use-pc-dev.vault.azure.net/", + keyVersion: "891CF236-D241-4738-9462-D506AF493DFA" + } + }, + userOwnedStorage: [ + { + resourceId: + "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount" + } + ] + }, + sku: { name: "S0" } + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.beginCreateAndWait( + resourceGroupName, + accountName, + account + ); + console.log(result); +} + +createAccount().catch(console.error); + +/** + * This sample demonstrates how to Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. + * + * @summary Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CreateAccountMin.json + */ +async function createAccountMin() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "testCreate1"; + const account: Account = { + identity: { type: "SystemAssigned" }, + kind: "CognitiveServices", + location: "West US", + properties: {}, + sku: { name: "S0" } + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.beginCreateAndWait( + resourceGroupName, + accountName, + account + ); + console.log(result); +} + +createAccountMin().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsDeleteSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsDeleteSample.ts new file mode 100644 index 000000000000..a0d62d524583 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsDeleteSample.ts @@ -0,0 +1,36 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a Cognitive Services account from the resource group. + * + * @summary Deletes a Cognitive Services account from the resource group. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteAccount.json + */ +async function deleteAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "PropTest01"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.beginDeleteAndWait( + resourceGroupName, + accountName + ); + console.log(result); +} + +deleteAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsGetSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsGetSample.ts new file mode 100644 index 000000000000..b202aeb3f8c6 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns a Cognitive Services account specified by the parameters. + * + * @summary Returns a Cognitive Services account specified by the parameters. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetAccount.json + */ +async function getAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.get(resourceGroupName, accountName); + console.log(result); +} + +getAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListByResourceGroupSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListByResourceGroupSample.ts new file mode 100644 index 000000000000..68f70955f769 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListByResourceGroupSample.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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns all the resources of a particular type belonging to a resource group + * + * @summary Returns all the resources of a particular type belonging to a resource group + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsByResourceGroup.json + */ +async function listAccountsByResourceGroup() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.accounts.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAccountsByResourceGroup().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListKeysSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListKeysSample.ts new file mode 100644 index 000000000000..3c61febbd1a3 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListKeysSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the account keys for the specified Cognitive Services account. + * + * @summary Lists the account keys for the specified Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListKeys.json + */ +async function listKeys() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.listKeys(resourceGroupName, accountName); + console.log(result); +} + +listKeys().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListModelsSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListModelsSample.ts new file mode 100644 index 000000000000..65893bcd64fd --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListModelsSample.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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to List available Models for the requested Cognitive Services account + * + * @summary List available Models for the requested Cognitive Services account + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountModels.json + */ +async function listAccountModels() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.accounts.listModels( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAccountModels().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListSample.ts new file mode 100644 index 000000000000..80e6e10763a3 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListSample.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. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns all the resources of a particular type belonging to a subscription. + * + * @summary Returns all the resources of a particular type belonging to a subscription. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsBySubscription.json + */ +async function listAccountsBySubscription() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.accounts.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listAccountsBySubscription().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListSkusSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListSkusSample.ts new file mode 100644 index 000000000000..f9f71831b904 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListSkusSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to List available SKUs for the requested Cognitive Services account + * + * @summary List available SKUs for the requested Cognitive Services account + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListSkus.json + */ +async function listSkUs() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.listSkus(resourceGroupName, accountName); + console.log(result); +} + +listSkUs().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListUsagesSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListUsagesSample.ts new file mode 100644 index 000000000000..74ebcb3db090 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsListUsagesSample.ts @@ -0,0 +1,36 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Get usages for the requested Cognitive Services account + * + * @summary Get usages for the requested Cognitive Services account + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetUsages.json + */ +async function getUsages() { + const subscriptionId = "5a4f5c2e-6983-4ccb-bd34-2196d5b5bbd3"; + const resourceGroupName = "myResourceGroup"; + const accountName = "TestUsage02"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.listUsages( + resourceGroupName, + accountName + ); + console.log(result); +} + +getUsages().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsRegenerateKeySample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsRegenerateKeySample.ts new file mode 100644 index 000000000000..9f5b14f2d5f4 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsRegenerateKeySample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Regenerates the specified account key for the specified Cognitive Services account. + * + * @summary Regenerates the specified account key for the specified Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/RegenerateKey.json + */ +async function regenerateKeys() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const keyName = "Key2"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.regenerateKey( + resourceGroupName, + accountName, + keyName + ); + console.log(result); +} + +regenerateKeys().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsUpdateSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsUpdateSample.ts new file mode 100644 index 000000000000..d8ef2b16d3b9 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/accountsUpdateSample.ts @@ -0,0 +1,41 @@ +/* + * 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 { + Account, + CognitiveServicesManagementClient +} from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a Cognitive Services account + * + * @summary Updates a Cognitive Services account + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/UpdateAccount.json + */ +async function updateAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "bvttest"; + const accountName = "bingSearch"; + const account: Account = { location: "global", sku: { name: "S2" } }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.beginUpdateAndWait( + resourceGroupName, + accountName, + account + ); + console.log(result); +} + +updateAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/checkDomainAvailabilitySample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/checkDomainAvailabilitySample.ts new file mode 100644 index 000000000000..4a4b646dfbe6 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/checkDomainAvailabilitySample.ts @@ -0,0 +1,33 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Check whether a domain is available. + * + * @summary Check whether a domain is available. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CheckDomainAvailability.json + */ +async function checkSkuAvailability() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const subdomainName = "contosodemoapp1"; + const typeParam = "Microsoft.CognitiveServices/accounts"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.checkDomainAvailability(subdomainName, typeParam); + console.log(result); +} + +checkSkuAvailability().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/checkSkuAvailabilitySample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/checkSkuAvailabilitySample.ts new file mode 100644 index 000000000000..f9ca94f3ffe4 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/checkSkuAvailabilitySample.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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Check available SKUs. + * + * @summary Check available SKUs. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CheckSkuAvailability.json + */ +async function checkSkuAvailability() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const location = "westus"; + const skus = ["S0"]; + const kind = "Face"; + const typeParam = "Microsoft.CognitiveServices/accounts"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.checkSkuAvailability( + location, + skus, + kind, + typeParam + ); + console.log(result); +} + +checkSkuAvailability().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentPlansCreateOrUpdateSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentPlansCreateOrUpdateSample.ts new file mode 100644 index 000000000000..9b7452f19e1b --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentPlansCreateOrUpdateSample.ts @@ -0,0 +1,50 @@ +/* + * 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 { + CommitmentPlan, + CognitiveServicesManagementClient +} from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Update the state of specified commitmentPlans associated with the Cognitive Services account. + * + * @summary Update the state of specified commitmentPlans associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutCommitmentPlan.json + */ +async function putCommitmentPlan() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const commitmentPlanName = "commitmentPlanName"; + const commitmentPlan: CommitmentPlan = { + properties: { + autoRenew: true, + current: { tier: "T1" }, + hostingModel: "Web", + planType: "Speech2Text" + } + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.commitmentPlans.createOrUpdate( + resourceGroupName, + accountName, + commitmentPlanName, + commitmentPlan + ); + console.log(result); +} + +putCommitmentPlan().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentPlansDeleteSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentPlansDeleteSample.ts new file mode 100644 index 000000000000..f9f4739d57e5 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentPlansDeleteSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the specified commitmentPlan associated with the Cognitive Services account. + * + * @summary Deletes the specified commitmentPlan associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteCommitmentPlan.json + */ +async function deleteCommitmentPlan() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const commitmentPlanName = "commitmentPlanName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.commitmentPlans.beginDeleteAndWait( + resourceGroupName, + accountName, + commitmentPlanName + ); + console.log(result); +} + +deleteCommitmentPlan().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentPlansGetSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentPlansGetSample.ts new file mode 100644 index 000000000000..18a4d8fc2c84 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentPlansGetSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the specified commitmentPlans associated with the Cognitive Services account. + * + * @summary Gets the specified commitmentPlans associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetCommitmentPlan.json + */ +async function getCommitmentPlan() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const commitmentPlanName = "commitmentPlanName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.commitmentPlans.get( + resourceGroupName, + accountName, + commitmentPlanName + ); + console.log(result); +} + +getCommitmentPlan().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentPlansListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentPlansListSample.ts new file mode 100644 index 000000000000..2188fdf66778 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentPlansListSample.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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the commitmentPlans associated with the Cognitive Services account. + * + * @summary Gets the commitmentPlans associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListCommitmentPlans.json + */ +async function listCommitmentPlans() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.commitmentPlans.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listCommitmentPlans().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentTiersListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentTiersListSample.ts new file mode 100644 index 000000000000..dc1dbcf6c6a9 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/commitmentTiersListSample.ts @@ -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. +import { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to List Commitment Tiers. + * + * @summary List Commitment Tiers. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListCommitmentTiers.json + */ +async function listCommitmentTiers() { + const subscriptionId = "subscriptionId"; + const location = "location"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.commitmentTiers.list(location)) { + resArray.push(item); + } + console.log(resArray); +} + +listCommitmentTiers().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deletedAccountsGetSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deletedAccountsGetSample.ts new file mode 100644 index 000000000000..bd466262e39f --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deletedAccountsGetSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns a Cognitive Services account specified by the parameters. + * + * @summary Returns a Cognitive Services account specified by the parameters. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetDeletedAccount.json + */ +async function getAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const location = "westus"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.deletedAccounts.get( + location, + resourceGroupName, + accountName + ); + console.log(result); +} + +getAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deletedAccountsListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deletedAccountsListSample.ts new file mode 100644 index 000000000000..34b59e95fa2d --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deletedAccountsListSample.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. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns all the resources of a particular type belonging to a subscription. + * + * @summary Returns all the resources of a particular type belonging to a subscription. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsBySubscription.json + */ +async function listDeletedAccountsBySubscription() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.deletedAccounts.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDeletedAccountsBySubscription().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deletedAccountsPurgeSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deletedAccountsPurgeSample.ts new file mode 100644 index 000000000000..ab8800e53887 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deletedAccountsPurgeSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a Cognitive Services account from the resource group. + * + * @summary Deletes a Cognitive Services account from the resource group. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PurgeDeletedAccount.json + */ +async function deleteAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const location = "westus"; + const resourceGroupName = "myResourceGroup"; + const accountName = "PropTest01"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.deletedAccounts.beginPurgeAndWait( + location, + resourceGroupName, + accountName + ); + console.log(result); +} + +deleteAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deploymentsCreateOrUpdateSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deploymentsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..2ce6453d66e3 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deploymentsCreateOrUpdateSample.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + Deployment, + CognitiveServicesManagementClient +} from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Update the state of specified deployments associated with the Cognitive Services account. + * + * @summary Update the state of specified deployments associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutDeployment.json + */ +async function putDeployment() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const deploymentName = "deploymentName"; + const deployment: Deployment = { + properties: { + model: { name: "ada", format: "OpenAI", version: "1" }, + scaleSettings: { capacity: 1, scaleType: "Manual" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + accountName, + deploymentName, + deployment + ); + console.log(result); +} + +putDeployment().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deploymentsDeleteSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deploymentsDeleteSample.ts new file mode 100644 index 000000000000..0bf4493ac428 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deploymentsDeleteSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the specified deployment associated with the Cognitive Services account. + * + * @summary Deletes the specified deployment associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteDeployment.json + */ +async function deleteDeployment() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const deploymentName = "deploymentName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.deployments.beginDeleteAndWait( + resourceGroupName, + accountName, + deploymentName + ); + console.log(result); +} + +deleteDeployment().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deploymentsGetSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deploymentsGetSample.ts new file mode 100644 index 000000000000..01a174f41b1c --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deploymentsGetSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the specified deployments associated with the Cognitive Services account. + * + * @summary Gets the specified deployments associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetDeployment.json + */ +async function getDeployment() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const deploymentName = "deploymentName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.deployments.get( + resourceGroupName, + accountName, + deploymentName + ); + console.log(result); +} + +getDeployment().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deploymentsListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deploymentsListSample.ts new file mode 100644 index 000000000000..641ef11bb031 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/deploymentsListSample.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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the deployments associated with the Cognitive Services account. + * + * @summary Gets the deployments associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListDeployments.json + */ +async function listDeployments() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.deployments.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDeployments().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/operationsListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/operationsListSample.ts new file mode 100644 index 000000000000..288b46dbeeb4 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/operationsListSample.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. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the available Cognitive Services account operations. + * + * @summary Lists all the available Cognitive Services account operations. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetOperations.json + */ +async function getOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getOperations().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateEndpointConnectionsCreateOrUpdateSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateEndpointConnectionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..419300d0d867 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateEndpointConnectionsCreateOrUpdateSample.ts @@ -0,0 +1,50 @@ +/* + * 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 { + PrivateEndpointConnection, + CognitiveServicesManagementClient +} from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Update the state of specified private endpoint connection associated with the Cognitive Services account. + * + * @summary Update the state of specified private endpoint connection associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutPrivateEndpointConnection.json + */ +async function putPrivateEndpointConnection() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res7687"; + const accountName = "sto9699"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const properties: PrivateEndpointConnection = { + properties: { + privateLinkServiceConnectionState: { + description: "Auto-Approved", + status: "Approved" + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.privateEndpointConnections.beginCreateOrUpdateAndWait( + resourceGroupName, + accountName, + privateEndpointConnectionName, + properties + ); + console.log(result); +} + +putPrivateEndpointConnection().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateEndpointConnectionsDeleteSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateEndpointConnectionsDeleteSample.ts new file mode 100644 index 000000000000..640886b030f0 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateEndpointConnectionsDeleteSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the specified private endpoint connection associated with the Cognitive Services account. + * + * @summary Deletes the specified private endpoint connection associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeletePrivateEndpointConnection.json + */ +async function deletePrivateEndpointConnection() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res6977"; + const accountName = "sto2527"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.privateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + accountName, + privateEndpointConnectionName + ); + console.log(result); +} + +deletePrivateEndpointConnection().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateEndpointConnectionsGetSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateEndpointConnectionsGetSample.ts new file mode 100644 index 000000000000..9c24187d7b8b --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateEndpointConnectionsGetSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the specified private endpoint connection associated with the Cognitive Services account. + * + * @summary Gets the specified private endpoint connection associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetPrivateEndpointConnection.json + */ +async function getPrivateEndpointConnection() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res6977"; + const accountName = "sto2527"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + accountName, + privateEndpointConnectionName + ); + console.log(result); +} + +getPrivateEndpointConnection().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateEndpointConnectionsListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateEndpointConnectionsListSample.ts new file mode 100644 index 000000000000..891a022fa3b1 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateEndpointConnectionsListSample.ts @@ -0,0 +1,36 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the private endpoint connections associated with the Cognitive Services account. + * + * @summary Gets the private endpoint connections associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListPrivateEndpointConnections.json + */ +async function getPrivateEndpointConnection() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.privateEndpointConnections.list( + resourceGroupName, + accountName + ); + console.log(result); +} + +getPrivateEndpointConnection().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateLinkResourcesListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateLinkResourcesListSample.ts new file mode 100644 index 000000000000..b1303452c62f --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/privateLinkResourcesListSample.ts @@ -0,0 +1,36 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the private link resources that need to be created for a Cognitive Services account. + * + * @summary Gets the private link resources that need to be created for a Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListPrivateLinkResources.json + */ +async function listPrivateLinkResources() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.privateLinkResources.list( + resourceGroupName, + accountName + ); + console.log(result); +} + +listPrivateLinkResources().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/resourceSkusListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/resourceSkusListSample.ts new file mode 100644 index 000000000000..1cc038a286a9 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples-dev/resourceSkusListSample.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. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. + * + * @summary Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetSkus.json + */ +async function regenerateKeys() { + const subscriptionId = "f1c637e4-72ec-4f89-8d2b-0f933c036002"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.resourceSkus.list()) { + resArray.push(item); + } + console.log(resArray); +} + +regenerateKeys().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/README.md b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/README.md new file mode 100644 index 000000000000..d5d5ca8cb21b --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/README.md @@ -0,0 +1,112 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [accountsCreateSample.js][accountscreatesample] | Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CreateAccount.json | +| [accountsDeleteSample.js][accountsdeletesample] | Deletes a Cognitive Services account from the resource group. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteAccount.json | +| [accountsGetSample.js][accountsgetsample] | Returns a Cognitive Services account specified by the parameters. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetAccount.json | +| [accountsListByResourceGroupSample.js][accountslistbyresourcegroupsample] | Returns all the resources of a particular type belonging to a resource group x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsByResourceGroup.json | +| [accountsListKeysSample.js][accountslistkeyssample] | Lists the account keys for the specified Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListKeys.json | +| [accountsListModelsSample.js][accountslistmodelssample] | List available Models for the requested Cognitive Services account x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountModels.json | +| [accountsListSample.js][accountslistsample] | Returns all the resources of a particular type belonging to a subscription. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsBySubscription.json | +| [accountsListSkusSample.js][accountslistskussample] | List available SKUs for the requested Cognitive Services account x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListSkus.json | +| [accountsListUsagesSample.js][accountslistusagessample] | Get usages for the requested Cognitive Services account x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetUsages.json | +| [accountsRegenerateKeySample.js][accountsregeneratekeysample] | Regenerates the specified account key for the specified Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/RegenerateKey.json | +| [accountsUpdateSample.js][accountsupdatesample] | Updates a Cognitive Services account x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/UpdateAccount.json | +| [checkDomainAvailabilitySample.js][checkdomainavailabilitysample] | Check whether a domain is available. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CheckDomainAvailability.json | +| [checkSkuAvailabilitySample.js][checkskuavailabilitysample] | Check available SKUs. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CheckSkuAvailability.json | +| [commitmentPlansCreateOrUpdateSample.js][commitmentplanscreateorupdatesample] | Update the state of specified commitmentPlans associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutCommitmentPlan.json | +| [commitmentPlansDeleteSample.js][commitmentplansdeletesample] | Deletes the specified commitmentPlan associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteCommitmentPlan.json | +| [commitmentPlansGetSample.js][commitmentplansgetsample] | Gets the specified commitmentPlans associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetCommitmentPlan.json | +| [commitmentPlansListSample.js][commitmentplanslistsample] | Gets the commitmentPlans associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListCommitmentPlans.json | +| [commitmentTiersListSample.js][commitmenttierslistsample] | List Commitment Tiers. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListCommitmentTiers.json | +| [deletedAccountsGetSample.js][deletedaccountsgetsample] | Returns a Cognitive Services account specified by the parameters. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetDeletedAccount.json | +| [deletedAccountsListSample.js][deletedaccountslistsample] | Returns all the resources of a particular type belonging to a subscription. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsBySubscription.json | +| [deletedAccountsPurgeSample.js][deletedaccountspurgesample] | Deletes a Cognitive Services account from the resource group. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PurgeDeletedAccount.json | +| [deploymentsCreateOrUpdateSample.js][deploymentscreateorupdatesample] | Update the state of specified deployments associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutDeployment.json | +| [deploymentsDeleteSample.js][deploymentsdeletesample] | Deletes the specified deployment associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteDeployment.json | +| [deploymentsGetSample.js][deploymentsgetsample] | Gets the specified deployments associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetDeployment.json | +| [deploymentsListSample.js][deploymentslistsample] | Gets the deployments associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListDeployments.json | +| [operationsListSample.js][operationslistsample] | Lists all the available Cognitive Services account operations. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetOperations.json | +| [privateEndpointConnectionsCreateOrUpdateSample.js][privateendpointconnectionscreateorupdatesample] | Update the state of specified private endpoint connection associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutPrivateEndpointConnection.json | +| [privateEndpointConnectionsDeleteSample.js][privateendpointconnectionsdeletesample] | Deletes the specified private endpoint connection associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeletePrivateEndpointConnection.json | +| [privateEndpointConnectionsGetSample.js][privateendpointconnectionsgetsample] | Gets the specified private endpoint connection associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetPrivateEndpointConnection.json | +| [privateEndpointConnectionsListSample.js][privateendpointconnectionslistsample] | Gets the private endpoint connections associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListPrivateEndpointConnections.json | +| [privateLinkResourcesListSample.js][privatelinkresourceslistsample] | Gets the private link resources that need to be created for a Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListPrivateLinkResources.json | +| [resourceSkusListSample.js][resourceskuslistsample] | Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetSkus.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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 accountsCreateSample.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 accountsCreateSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[accountscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsCreateSample.js +[accountsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsDeleteSample.js +[accountsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsGetSample.js +[accountslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListByResourceGroupSample.js +[accountslistkeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListKeysSample.js +[accountslistmodelssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListModelsSample.js +[accountslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListSample.js +[accountslistskussample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListSkusSample.js +[accountslistusagessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListUsagesSample.js +[accountsregeneratekeysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsRegenerateKeySample.js +[accountsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsUpdateSample.js +[checkdomainavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/checkDomainAvailabilitySample.js +[checkskuavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/checkSkuAvailabilitySample.js +[commitmentplanscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansCreateOrUpdateSample.js +[commitmentplansdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansDeleteSample.js +[commitmentplansgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansGetSample.js +[commitmentplanslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansListSample.js +[commitmenttierslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentTiersListSample.js +[deletedaccountsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deletedAccountsGetSample.js +[deletedaccountslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deletedAccountsListSample.js +[deletedaccountspurgesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deletedAccountsPurgeSample.js +[deploymentscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsCreateOrUpdateSample.js +[deploymentsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsDeleteSample.js +[deploymentsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsGetSample.js +[deploymentslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsListSample.js +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/operationsListSample.js +[privateendpointconnectionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsCreateOrUpdateSample.js +[privateendpointconnectionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsDeleteSample.js +[privateendpointconnectionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsGetSample.js +[privateendpointconnectionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsListSample.js +[privatelinkresourceslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateLinkResourcesListSample.js +[resourceskuslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/resourceSkusListSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-cognitiveservices?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cognitiveservices/arm-cognitiveservices/README.md diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsCreateSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsCreateSample.js new file mode 100644 index 000000000000..c93d214336a5 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsCreateSample.js @@ -0,0 +1,77 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. + * + * @summary Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CreateAccount.json + */ +async function createAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "testCreate1"; + const account = { + identity: { type: "SystemAssigned" }, + kind: "Emotion", + location: "West US", + properties: { + encryption: { + keySource: "Microsoft.KeyVault", + keyVaultProperties: { + keyName: "KeyName", + keyVaultUri: "https://pltfrmscrts-use-pc-dev.vault.azure.net/", + keyVersion: "891CF236-D241-4738-9462-D506AF493DFA", + }, + }, + userOwnedStorage: [ + { + resourceId: + "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount", + }, + ], + }, + sku: { name: "S0" }, + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.accounts.beginCreateAndWait(resourceGroupName, accountName, account); + console.log(result); +} + +createAccount().catch(console.error); + +/** + * This sample demonstrates how to Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. + * + * @summary Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CreateAccountMin.json + */ +async function createAccountMin() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "testCreate1"; + const account = { + identity: { type: "SystemAssigned" }, + kind: "CognitiveServices", + location: "West US", + properties: {}, + sku: { name: "S0" }, + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.accounts.beginCreateAndWait(resourceGroupName, accountName, account); + console.log(result); +} + +createAccountMin().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsDeleteSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsDeleteSample.js new file mode 100644 index 000000000000..f6e3a6844445 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsDeleteSample.js @@ -0,0 +1,30 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes a Cognitive Services account from the resource group. + * + * @summary Deletes a Cognitive Services account from the resource group. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteAccount.json + */ +async function deleteAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "PropTest01"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.accounts.beginDeleteAndWait(resourceGroupName, accountName); + console.log(result); +} + +deleteAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsGetSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsGetSample.js new file mode 100644 index 000000000000..7bf695797f4a --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns a Cognitive Services account specified by the parameters. + * + * @summary Returns a Cognitive Services account specified by the parameters. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetAccount.json + */ +async function getAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.accounts.get(resourceGroupName, accountName); + console.log(result); +} + +getAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListByResourceGroupSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListByResourceGroupSample.js new file mode 100644 index 000000000000..63f0c4fb65db --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListByResourceGroupSample.js @@ -0,0 +1,32 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns all the resources of a particular type belonging to a resource group + * + * @summary Returns all the resources of a particular type belonging to a resource group + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsByResourceGroup.json + */ +async function listAccountsByResourceGroup() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.accounts.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +listAccountsByResourceGroup().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListKeysSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListKeysSample.js new file mode 100644 index 000000000000..bd50c15b66d6 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListKeysSample.js @@ -0,0 +1,30 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists the account keys for the specified Cognitive Services account. + * + * @summary Lists the account keys for the specified Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListKeys.json + */ +async function listKeys() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.accounts.listKeys(resourceGroupName, accountName); + console.log(result); +} + +listKeys().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListModelsSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListModelsSample.js new file mode 100644 index 000000000000..43efc5a7378b --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListModelsSample.js @@ -0,0 +1,33 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to List available Models for the requested Cognitive Services account + * + * @summary List available Models for the requested Cognitive Services account + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountModels.json + */ +async function listAccountModels() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.accounts.listModels(resourceGroupName, accountName)) { + resArray.push(item); + } + console.log(resArray); +} + +listAccountModels().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListSample.js new file mode 100644 index 000000000000..5ff787a4da12 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns all the resources of a particular type belonging to a subscription. + * + * @summary Returns all the resources of a particular type belonging to a subscription. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsBySubscription.json + */ +async function listAccountsBySubscription() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.accounts.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listAccountsBySubscription().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListSkusSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListSkusSample.js new file mode 100644 index 000000000000..96640375300d --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListSkusSample.js @@ -0,0 +1,30 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to List available SKUs for the requested Cognitive Services account + * + * @summary List available SKUs for the requested Cognitive Services account + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListSkus.json + */ +async function listSkUs() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.accounts.listSkus(resourceGroupName, accountName); + console.log(result); +} + +listSkUs().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListUsagesSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListUsagesSample.js new file mode 100644 index 000000000000..755a9c7e3378 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsListUsagesSample.js @@ -0,0 +1,30 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Get usages for the requested Cognitive Services account + * + * @summary Get usages for the requested Cognitive Services account + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetUsages.json + */ +async function getUsages() { + const subscriptionId = "5a4f5c2e-6983-4ccb-bd34-2196d5b5bbd3"; + const resourceGroupName = "myResourceGroup"; + const accountName = "TestUsage02"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.accounts.listUsages(resourceGroupName, accountName); + console.log(result); +} + +getUsages().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsRegenerateKeySample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsRegenerateKeySample.js new file mode 100644 index 000000000000..2c12027746b3 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsRegenerateKeySample.js @@ -0,0 +1,31 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Regenerates the specified account key for the specified Cognitive Services account. + * + * @summary Regenerates the specified account key for the specified Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/RegenerateKey.json + */ +async function regenerateKeys() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const keyName = "Key2"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.accounts.regenerateKey(resourceGroupName, accountName, keyName); + console.log(result); +} + +regenerateKeys().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsUpdateSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsUpdateSample.js new file mode 100644 index 000000000000..9bb940881bb7 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/accountsUpdateSample.js @@ -0,0 +1,31 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates a Cognitive Services account + * + * @summary Updates a Cognitive Services account + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/UpdateAccount.json + */ +async function updateAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "bvttest"; + const accountName = "bingSearch"; + const account = { location: "global", sku: { name: "S2" } }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.accounts.beginUpdateAndWait(resourceGroupName, accountName, account); + console.log(result); +} + +updateAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/checkDomainAvailabilitySample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/checkDomainAvailabilitySample.js new file mode 100644 index 000000000000..49d3f8d6b65e --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/checkDomainAvailabilitySample.js @@ -0,0 +1,30 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Check whether a domain is available. + * + * @summary Check whether a domain is available. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CheckDomainAvailability.json + */ +async function checkSkuAvailability() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const subdomainName = "contosodemoapp1"; + const typeParam = "Microsoft.CognitiveServices/accounts"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.checkDomainAvailability(subdomainName, typeParam); + console.log(result); +} + +checkSkuAvailability().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/checkSkuAvailabilitySample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/checkSkuAvailabilitySample.js new file mode 100644 index 000000000000..a4748adaf0d6 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/checkSkuAvailabilitySample.js @@ -0,0 +1,32 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Check available SKUs. + * + * @summary Check available SKUs. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CheckSkuAvailability.json + */ +async function checkSkuAvailability() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const location = "westus"; + const skus = ["S0"]; + const kind = "Face"; + const typeParam = "Microsoft.CognitiveServices/accounts"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.checkSkuAvailability(location, skus, kind, typeParam); + console.log(result); +} + +checkSkuAvailability().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansCreateOrUpdateSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansCreateOrUpdateSample.js new file mode 100644 index 000000000000..f971fa914a81 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansCreateOrUpdateSample.js @@ -0,0 +1,44 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Update the state of specified commitmentPlans associated with the Cognitive Services account. + * + * @summary Update the state of specified commitmentPlans associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutCommitmentPlan.json + */ +async function putCommitmentPlan() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const commitmentPlanName = "commitmentPlanName"; + const commitmentPlan = { + properties: { + autoRenew: true, + current: { tier: "T1" }, + hostingModel: "Web", + planType: "Speech2Text", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.commitmentPlans.createOrUpdate( + resourceGroupName, + accountName, + commitmentPlanName, + commitmentPlan + ); + console.log(result); +} + +putCommitmentPlan().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansDeleteSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansDeleteSample.js new file mode 100644 index 000000000000..c40b2e8c9f29 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansDeleteSample.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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes the specified commitmentPlan associated with the Cognitive Services account. + * + * @summary Deletes the specified commitmentPlan associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteCommitmentPlan.json + */ +async function deleteCommitmentPlan() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const commitmentPlanName = "commitmentPlanName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.commitmentPlans.beginDeleteAndWait( + resourceGroupName, + accountName, + commitmentPlanName + ); + console.log(result); +} + +deleteCommitmentPlan().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansGetSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansGetSample.js new file mode 100644 index 000000000000..ef77367e3349 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansGetSample.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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the specified commitmentPlans associated with the Cognitive Services account. + * + * @summary Gets the specified commitmentPlans associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetCommitmentPlan.json + */ +async function getCommitmentPlan() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const commitmentPlanName = "commitmentPlanName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.commitmentPlans.get( + resourceGroupName, + accountName, + commitmentPlanName + ); + console.log(result); +} + +getCommitmentPlan().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansListSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansListSample.js new file mode 100644 index 000000000000..f3a26b2258ce --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentPlansListSample.js @@ -0,0 +1,33 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the commitmentPlans associated with the Cognitive Services account. + * + * @summary Gets the commitmentPlans associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListCommitmentPlans.json + */ +async function listCommitmentPlans() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.commitmentPlans.list(resourceGroupName, accountName)) { + resArray.push(item); + } + console.log(resArray); +} + +listCommitmentPlans().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentTiersListSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentTiersListSample.js new file mode 100644 index 000000000000..86108aa468d0 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/commitmentTiersListSample.js @@ -0,0 +1,32 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to List Commitment Tiers. + * + * @summary List Commitment Tiers. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListCommitmentTiers.json + */ +async function listCommitmentTiers() { + const subscriptionId = "subscriptionId"; + const location = "location"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.commitmentTiers.list(location)) { + resArray.push(item); + } + console.log(resArray); +} + +listCommitmentTiers().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deletedAccountsGetSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deletedAccountsGetSample.js new file mode 100644 index 000000000000..4196859e84f9 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deletedAccountsGetSample.js @@ -0,0 +1,31 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns a Cognitive Services account specified by the parameters. + * + * @summary Returns a Cognitive Services account specified by the parameters. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetDeletedAccount.json + */ +async function getAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const location = "westus"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.deletedAccounts.get(location, resourceGroupName, accountName); + console.log(result); +} + +getAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deletedAccountsListSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deletedAccountsListSample.js new file mode 100644 index 000000000000..ac59d090de4c --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deletedAccountsListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns all the resources of a particular type belonging to a subscription. + * + * @summary Returns all the resources of a particular type belonging to a subscription. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsBySubscription.json + */ +async function listDeletedAccountsBySubscription() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.deletedAccounts.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDeletedAccountsBySubscription().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deletedAccountsPurgeSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deletedAccountsPurgeSample.js new file mode 100644 index 000000000000..38744bea392a --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deletedAccountsPurgeSample.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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes a Cognitive Services account from the resource group. + * + * @summary Deletes a Cognitive Services account from the resource group. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PurgeDeletedAccount.json + */ +async function deleteAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const location = "westus"; + const resourceGroupName = "myResourceGroup"; + const accountName = "PropTest01"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.deletedAccounts.beginPurgeAndWait( + location, + resourceGroupName, + accountName + ); + console.log(result); +} + +deleteAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsCreateOrUpdateSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsCreateOrUpdateSample.js new file mode 100644 index 000000000000..902f25f6520a --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsCreateOrUpdateSample.js @@ -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. +const { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Update the state of specified deployments associated with the Cognitive Services account. + * + * @summary Update the state of specified deployments associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutDeployment.json + */ +async function putDeployment() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const deploymentName = "deploymentName"; + const deployment = { + properties: { + model: { name: "ada", format: "OpenAI", version: "1" }, + scaleSettings: { capacity: 1, scaleType: "Manual" }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + accountName, + deploymentName, + deployment + ); + console.log(result); +} + +putDeployment().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsDeleteSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsDeleteSample.js new file mode 100644 index 000000000000..2b64023088c8 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsDeleteSample.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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes the specified deployment associated with the Cognitive Services account. + * + * @summary Deletes the specified deployment associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteDeployment.json + */ +async function deleteDeployment() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const deploymentName = "deploymentName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.deployments.beginDeleteAndWait( + resourceGroupName, + accountName, + deploymentName + ); + console.log(result); +} + +deleteDeployment().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsGetSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsGetSample.js new file mode 100644 index 000000000000..04c6bfec5f10 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsGetSample.js @@ -0,0 +1,31 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the specified deployments associated with the Cognitive Services account. + * + * @summary Gets the specified deployments associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetDeployment.json + */ +async function getDeployment() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const deploymentName = "deploymentName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.deployments.get(resourceGroupName, accountName, deploymentName); + console.log(result); +} + +getDeployment().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsListSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsListSample.js new file mode 100644 index 000000000000..9042b50634f5 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/deploymentsListSample.js @@ -0,0 +1,33 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the deployments associated with the Cognitive Services account. + * + * @summary Gets the deployments associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListDeployments.json + */ +async function listDeployments() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.deployments.list(resourceGroupName, accountName)) { + resArray.push(item); + } + console.log(resArray); +} + +listDeployments().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/operationsListSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/operationsListSample.js new file mode 100644 index 000000000000..7855732e3808 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/operationsListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all the available Cognitive Services account operations. + * + * @summary Lists all the available Cognitive Services account operations. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetOperations.json + */ +async function getOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getOperations().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/package.json b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/package.json new file mode 100644 index 000000000000..6fa675af31f5 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-cognitiveservices-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/cognitiveservices/arm-cognitiveservices" + }, + "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/cognitiveservices/arm-cognitiveservices", + "dependencies": { + "@azure/arm-cognitiveservices": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsCreateOrUpdateSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsCreateOrUpdateSample.js new file mode 100644 index 000000000000..e72c49d8f638 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsCreateOrUpdateSample.js @@ -0,0 +1,44 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Update the state of specified private endpoint connection associated with the Cognitive Services account. + * + * @summary Update the state of specified private endpoint connection associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutPrivateEndpointConnection.json + */ +async function putPrivateEndpointConnection() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res7687"; + const accountName = "sto9699"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const properties = { + properties: { + privateLinkServiceConnectionState: { + description: "Auto-Approved", + status: "Approved", + }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginCreateOrUpdateAndWait( + resourceGroupName, + accountName, + privateEndpointConnectionName, + properties + ); + console.log(result); +} + +putPrivateEndpointConnection().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsDeleteSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsDeleteSample.js new file mode 100644 index 000000000000..0cbdbb70bb59 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsDeleteSample.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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes the specified private endpoint connection associated with the Cognitive Services account. + * + * @summary Deletes the specified private endpoint connection associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeletePrivateEndpointConnection.json + */ +async function deletePrivateEndpointConnection() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res6977"; + const accountName = "sto2527"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + accountName, + privateEndpointConnectionName + ); + console.log(result); +} + +deletePrivateEndpointConnection().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsGetSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsGetSample.js new file mode 100644 index 000000000000..653817250f83 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsGetSample.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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the specified private endpoint connection associated with the Cognitive Services account. + * + * @summary Gets the specified private endpoint connection associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetPrivateEndpointConnection.json + */ +async function getPrivateEndpointConnection() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res6977"; + const accountName = "sto2527"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + accountName, + privateEndpointConnectionName + ); + console.log(result); +} + +getPrivateEndpointConnection().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsListSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsListSample.js new file mode 100644 index 000000000000..3a8cb0ad26e9 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateEndpointConnectionsListSample.js @@ -0,0 +1,30 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the private endpoint connections associated with the Cognitive Services account. + * + * @summary Gets the private endpoint connections associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListPrivateEndpointConnections.json + */ +async function getPrivateEndpointConnection() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.list(resourceGroupName, accountName); + console.log(result); +} + +getPrivateEndpointConnection().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateLinkResourcesListSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateLinkResourcesListSample.js new file mode 100644 index 000000000000..592e5e337659 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/privateLinkResourcesListSample.js @@ -0,0 +1,30 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the private link resources that need to be created for a Cognitive Services account. + * + * @summary Gets the private link resources that need to be created for a Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListPrivateLinkResources.json + */ +async function listPrivateLinkResources() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const result = await client.privateLinkResources.list(resourceGroupName, accountName); + console.log(result); +} + +listPrivateLinkResources().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/resourceSkusListSample.js b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/resourceSkusListSample.js new file mode 100644 index 000000000000..6c9dc20ca724 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/resourceSkusListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { CognitiveServicesManagementClient } = require("@azure/arm-cognitiveservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. + * + * @summary Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetSkus.json + */ +async function regenerateKeys() { + const subscriptionId = "f1c637e4-72ec-4f89-8d2b-0f933c036002"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.resourceSkus.list()) { + resArray.push(item); + } + console.log(resArray); +} + +regenerateKeys().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/sample.env b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/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/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/README.md b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/README.md new file mode 100644 index 000000000000..6ed7d08c4857 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/README.md @@ -0,0 +1,125 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [accountsCreateSample.ts][accountscreatesample] | Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CreateAccount.json | +| [accountsDeleteSample.ts][accountsdeletesample] | Deletes a Cognitive Services account from the resource group. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteAccount.json | +| [accountsGetSample.ts][accountsgetsample] | Returns a Cognitive Services account specified by the parameters. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetAccount.json | +| [accountsListByResourceGroupSample.ts][accountslistbyresourcegroupsample] | Returns all the resources of a particular type belonging to a resource group x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsByResourceGroup.json | +| [accountsListKeysSample.ts][accountslistkeyssample] | Lists the account keys for the specified Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListKeys.json | +| [accountsListModelsSample.ts][accountslistmodelssample] | List available Models for the requested Cognitive Services account x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountModels.json | +| [accountsListSample.ts][accountslistsample] | Returns all the resources of a particular type belonging to a subscription. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsBySubscription.json | +| [accountsListSkusSample.ts][accountslistskussample] | List available SKUs for the requested Cognitive Services account x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListSkus.json | +| [accountsListUsagesSample.ts][accountslistusagessample] | Get usages for the requested Cognitive Services account x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetUsages.json | +| [accountsRegenerateKeySample.ts][accountsregeneratekeysample] | Regenerates the specified account key for the specified Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/RegenerateKey.json | +| [accountsUpdateSample.ts][accountsupdatesample] | Updates a Cognitive Services account x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/UpdateAccount.json | +| [checkDomainAvailabilitySample.ts][checkdomainavailabilitysample] | Check whether a domain is available. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CheckDomainAvailability.json | +| [checkSkuAvailabilitySample.ts][checkskuavailabilitysample] | Check available SKUs. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CheckSkuAvailability.json | +| [commitmentPlansCreateOrUpdateSample.ts][commitmentplanscreateorupdatesample] | Update the state of specified commitmentPlans associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutCommitmentPlan.json | +| [commitmentPlansDeleteSample.ts][commitmentplansdeletesample] | Deletes the specified commitmentPlan associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteCommitmentPlan.json | +| [commitmentPlansGetSample.ts][commitmentplansgetsample] | Gets the specified commitmentPlans associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetCommitmentPlan.json | +| [commitmentPlansListSample.ts][commitmentplanslistsample] | Gets the commitmentPlans associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListCommitmentPlans.json | +| [commitmentTiersListSample.ts][commitmenttierslistsample] | List Commitment Tiers. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListCommitmentTiers.json | +| [deletedAccountsGetSample.ts][deletedaccountsgetsample] | Returns a Cognitive Services account specified by the parameters. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetDeletedAccount.json | +| [deletedAccountsListSample.ts][deletedaccountslistsample] | Returns all the resources of a particular type belonging to a subscription. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsBySubscription.json | +| [deletedAccountsPurgeSample.ts][deletedaccountspurgesample] | Deletes a Cognitive Services account from the resource group. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PurgeDeletedAccount.json | +| [deploymentsCreateOrUpdateSample.ts][deploymentscreateorupdatesample] | Update the state of specified deployments associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutDeployment.json | +| [deploymentsDeleteSample.ts][deploymentsdeletesample] | Deletes the specified deployment associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteDeployment.json | +| [deploymentsGetSample.ts][deploymentsgetsample] | Gets the specified deployments associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetDeployment.json | +| [deploymentsListSample.ts][deploymentslistsample] | Gets the deployments associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListDeployments.json | +| [operationsListSample.ts][operationslistsample] | Lists all the available Cognitive Services account operations. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetOperations.json | +| [privateEndpointConnectionsCreateOrUpdateSample.ts][privateendpointconnectionscreateorupdatesample] | Update the state of specified private endpoint connection associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutPrivateEndpointConnection.json | +| [privateEndpointConnectionsDeleteSample.ts][privateendpointconnectionsdeletesample] | Deletes the specified private endpoint connection associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeletePrivateEndpointConnection.json | +| [privateEndpointConnectionsGetSample.ts][privateendpointconnectionsgetsample] | Gets the specified private endpoint connection associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetPrivateEndpointConnection.json | +| [privateEndpointConnectionsListSample.ts][privateendpointconnectionslistsample] | Gets the private endpoint connections associated with the Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListPrivateEndpointConnections.json | +| [privateLinkResourcesListSample.ts][privatelinkresourceslistsample] | Gets the private link resources that need to be created for a Cognitive Services account. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListPrivateLinkResources.json | +| [resourceSkusListSample.ts][resourceskuslistsample] | Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetSkus.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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/accountsCreateSample.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/accountsCreateSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[accountscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsCreateSample.ts +[accountsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsDeleteSample.ts +[accountsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsGetSample.ts +[accountslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListByResourceGroupSample.ts +[accountslistkeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListKeysSample.ts +[accountslistmodelssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListModelsSample.ts +[accountslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListSample.ts +[accountslistskussample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListSkusSample.ts +[accountslistusagessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListUsagesSample.ts +[accountsregeneratekeysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsRegenerateKeySample.ts +[accountsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsUpdateSample.ts +[checkdomainavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/checkDomainAvailabilitySample.ts +[checkskuavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/checkSkuAvailabilitySample.ts +[commitmentplanscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansCreateOrUpdateSample.ts +[commitmentplansdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansDeleteSample.ts +[commitmentplansgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansGetSample.ts +[commitmentplanslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansListSample.ts +[commitmenttierslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentTiersListSample.ts +[deletedaccountsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deletedAccountsGetSample.ts +[deletedaccountslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deletedAccountsListSample.ts +[deletedaccountspurgesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deletedAccountsPurgeSample.ts +[deploymentscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsCreateOrUpdateSample.ts +[deploymentsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsDeleteSample.ts +[deploymentsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsGetSample.ts +[deploymentslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsListSample.ts +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/operationsListSample.ts +[privateendpointconnectionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsCreateOrUpdateSample.ts +[privateendpointconnectionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsDeleteSample.ts +[privateendpointconnectionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsGetSample.ts +[privateendpointconnectionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsListSample.ts +[privatelinkresourceslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateLinkResourcesListSample.ts +[resourceskuslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/resourceSkusListSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-cognitiveservices?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cognitiveservices/arm-cognitiveservices/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/package.json b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/package.json new file mode 100644 index 000000000000..9c662c1bdf9c --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-cognitiveservices-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/cognitiveservices/arm-cognitiveservices" + }, + "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/cognitiveservices/arm-cognitiveservices", + "dependencies": { + "@azure/arm-cognitiveservices": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "~4.4.0", + "rimraf": "latest" + } +} diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/sample.env b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/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/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsCreateSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsCreateSample.ts new file mode 100644 index 000000000000..9b453d7265d4 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsCreateSample.ts @@ -0,0 +1,94 @@ +/* + * 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 { + Account, + CognitiveServicesManagementClient +} from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. + * + * @summary Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CreateAccount.json + */ +async function createAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "testCreate1"; + const account: Account = { + identity: { type: "SystemAssigned" }, + kind: "Emotion", + location: "West US", + properties: { + encryption: { + keySource: "Microsoft.KeyVault", + keyVaultProperties: { + keyName: "KeyName", + keyVaultUri: "https://pltfrmscrts-use-pc-dev.vault.azure.net/", + keyVersion: "891CF236-D241-4738-9462-D506AF493DFA" + } + }, + userOwnedStorage: [ + { + resourceId: + "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount" + } + ] + }, + sku: { name: "S0" } + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.beginCreateAndWait( + resourceGroupName, + accountName, + account + ); + console.log(result); +} + +createAccount().catch(console.error); + +/** + * This sample demonstrates how to Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. + * + * @summary Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CreateAccountMin.json + */ +async function createAccountMin() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "testCreate1"; + const account: Account = { + identity: { type: "SystemAssigned" }, + kind: "CognitiveServices", + location: "West US", + properties: {}, + sku: { name: "S0" } + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.beginCreateAndWait( + resourceGroupName, + accountName, + account + ); + console.log(result); +} + +createAccountMin().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsDeleteSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsDeleteSample.ts new file mode 100644 index 000000000000..a0d62d524583 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsDeleteSample.ts @@ -0,0 +1,36 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a Cognitive Services account from the resource group. + * + * @summary Deletes a Cognitive Services account from the resource group. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteAccount.json + */ +async function deleteAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "PropTest01"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.beginDeleteAndWait( + resourceGroupName, + accountName + ); + console.log(result); +} + +deleteAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsGetSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsGetSample.ts new file mode 100644 index 000000000000..b202aeb3f8c6 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns a Cognitive Services account specified by the parameters. + * + * @summary Returns a Cognitive Services account specified by the parameters. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetAccount.json + */ +async function getAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.get(resourceGroupName, accountName); + console.log(result); +} + +getAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListByResourceGroupSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListByResourceGroupSample.ts new file mode 100644 index 000000000000..68f70955f769 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListByResourceGroupSample.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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns all the resources of a particular type belonging to a resource group + * + * @summary Returns all the resources of a particular type belonging to a resource group + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsByResourceGroup.json + */ +async function listAccountsByResourceGroup() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.accounts.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAccountsByResourceGroup().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListKeysSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListKeysSample.ts new file mode 100644 index 000000000000..3c61febbd1a3 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListKeysSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the account keys for the specified Cognitive Services account. + * + * @summary Lists the account keys for the specified Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListKeys.json + */ +async function listKeys() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.listKeys(resourceGroupName, accountName); + console.log(result); +} + +listKeys().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListModelsSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListModelsSample.ts new file mode 100644 index 000000000000..65893bcd64fd --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListModelsSample.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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to List available Models for the requested Cognitive Services account + * + * @summary List available Models for the requested Cognitive Services account + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountModels.json + */ +async function listAccountModels() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.accounts.listModels( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAccountModels().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListSample.ts new file mode 100644 index 000000000000..80e6e10763a3 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListSample.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. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns all the resources of a particular type belonging to a subscription. + * + * @summary Returns all the resources of a particular type belonging to a subscription. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsBySubscription.json + */ +async function listAccountsBySubscription() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.accounts.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listAccountsBySubscription().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListSkusSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListSkusSample.ts new file mode 100644 index 000000000000..f9f71831b904 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListSkusSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to List available SKUs for the requested Cognitive Services account + * + * @summary List available SKUs for the requested Cognitive Services account + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListSkus.json + */ +async function listSkUs() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.listSkus(resourceGroupName, accountName); + console.log(result); +} + +listSkUs().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListUsagesSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListUsagesSample.ts new file mode 100644 index 000000000000..74ebcb3db090 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsListUsagesSample.ts @@ -0,0 +1,36 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Get usages for the requested Cognitive Services account + * + * @summary Get usages for the requested Cognitive Services account + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetUsages.json + */ +async function getUsages() { + const subscriptionId = "5a4f5c2e-6983-4ccb-bd34-2196d5b5bbd3"; + const resourceGroupName = "myResourceGroup"; + const accountName = "TestUsage02"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.listUsages( + resourceGroupName, + accountName + ); + console.log(result); +} + +getUsages().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsRegenerateKeySample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsRegenerateKeySample.ts new file mode 100644 index 000000000000..9f5b14f2d5f4 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsRegenerateKeySample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Regenerates the specified account key for the specified Cognitive Services account. + * + * @summary Regenerates the specified account key for the specified Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/RegenerateKey.json + */ +async function regenerateKeys() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const keyName = "Key2"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.regenerateKey( + resourceGroupName, + accountName, + keyName + ); + console.log(result); +} + +regenerateKeys().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsUpdateSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsUpdateSample.ts new file mode 100644 index 000000000000..d8ef2b16d3b9 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/accountsUpdateSample.ts @@ -0,0 +1,41 @@ +/* + * 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 { + Account, + CognitiveServicesManagementClient +} from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a Cognitive Services account + * + * @summary Updates a Cognitive Services account + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/UpdateAccount.json + */ +async function updateAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const resourceGroupName = "bvttest"; + const accountName = "bingSearch"; + const account: Account = { location: "global", sku: { name: "S2" } }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.accounts.beginUpdateAndWait( + resourceGroupName, + accountName, + account + ); + console.log(result); +} + +updateAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/checkDomainAvailabilitySample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/checkDomainAvailabilitySample.ts new file mode 100644 index 000000000000..4a4b646dfbe6 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/checkDomainAvailabilitySample.ts @@ -0,0 +1,33 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Check whether a domain is available. + * + * @summary Check whether a domain is available. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CheckDomainAvailability.json + */ +async function checkSkuAvailability() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const subdomainName = "contosodemoapp1"; + const typeParam = "Microsoft.CognitiveServices/accounts"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.checkDomainAvailability(subdomainName, typeParam); + console.log(result); +} + +checkSkuAvailability().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/checkSkuAvailabilitySample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/checkSkuAvailabilitySample.ts new file mode 100644 index 000000000000..f9ca94f3ffe4 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/checkSkuAvailabilitySample.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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Check available SKUs. + * + * @summary Check available SKUs. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/CheckSkuAvailability.json + */ +async function checkSkuAvailability() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const location = "westus"; + const skus = ["S0"]; + const kind = "Face"; + const typeParam = "Microsoft.CognitiveServices/accounts"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.checkSkuAvailability( + location, + skus, + kind, + typeParam + ); + console.log(result); +} + +checkSkuAvailability().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansCreateOrUpdateSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansCreateOrUpdateSample.ts new file mode 100644 index 000000000000..9b7452f19e1b --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansCreateOrUpdateSample.ts @@ -0,0 +1,50 @@ +/* + * 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 { + CommitmentPlan, + CognitiveServicesManagementClient +} from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Update the state of specified commitmentPlans associated with the Cognitive Services account. + * + * @summary Update the state of specified commitmentPlans associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutCommitmentPlan.json + */ +async function putCommitmentPlan() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const commitmentPlanName = "commitmentPlanName"; + const commitmentPlan: CommitmentPlan = { + properties: { + autoRenew: true, + current: { tier: "T1" }, + hostingModel: "Web", + planType: "Speech2Text" + } + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.commitmentPlans.createOrUpdate( + resourceGroupName, + accountName, + commitmentPlanName, + commitmentPlan + ); + console.log(result); +} + +putCommitmentPlan().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansDeleteSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansDeleteSample.ts new file mode 100644 index 000000000000..f9f4739d57e5 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansDeleteSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the specified commitmentPlan associated with the Cognitive Services account. + * + * @summary Deletes the specified commitmentPlan associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteCommitmentPlan.json + */ +async function deleteCommitmentPlan() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const commitmentPlanName = "commitmentPlanName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.commitmentPlans.beginDeleteAndWait( + resourceGroupName, + accountName, + commitmentPlanName + ); + console.log(result); +} + +deleteCommitmentPlan().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansGetSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansGetSample.ts new file mode 100644 index 000000000000..18a4d8fc2c84 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansGetSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the specified commitmentPlans associated with the Cognitive Services account. + * + * @summary Gets the specified commitmentPlans associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetCommitmentPlan.json + */ +async function getCommitmentPlan() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const commitmentPlanName = "commitmentPlanName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.commitmentPlans.get( + resourceGroupName, + accountName, + commitmentPlanName + ); + console.log(result); +} + +getCommitmentPlan().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansListSample.ts new file mode 100644 index 000000000000..2188fdf66778 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentPlansListSample.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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the commitmentPlans associated with the Cognitive Services account. + * + * @summary Gets the commitmentPlans associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListCommitmentPlans.json + */ +async function listCommitmentPlans() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.commitmentPlans.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listCommitmentPlans().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentTiersListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentTiersListSample.ts new file mode 100644 index 000000000000..dc1dbcf6c6a9 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/commitmentTiersListSample.ts @@ -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. +import { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to List Commitment Tiers. + * + * @summary List Commitment Tiers. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListCommitmentTiers.json + */ +async function listCommitmentTiers() { + const subscriptionId = "subscriptionId"; + const location = "location"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.commitmentTiers.list(location)) { + resArray.push(item); + } + console.log(resArray); +} + +listCommitmentTiers().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deletedAccountsGetSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deletedAccountsGetSample.ts new file mode 100644 index 000000000000..bd466262e39f --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deletedAccountsGetSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns a Cognitive Services account specified by the parameters. + * + * @summary Returns a Cognitive Services account specified by the parameters. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetDeletedAccount.json + */ +async function getAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const location = "westus"; + const resourceGroupName = "myResourceGroup"; + const accountName = "myAccount"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.deletedAccounts.get( + location, + resourceGroupName, + accountName + ); + console.log(result); +} + +getAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deletedAccountsListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deletedAccountsListSample.ts new file mode 100644 index 000000000000..34b59e95fa2d --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deletedAccountsListSample.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. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns all the resources of a particular type belonging to a subscription. + * + * @summary Returns all the resources of a particular type belonging to a subscription. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListAccountsBySubscription.json + */ +async function listDeletedAccountsBySubscription() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.deletedAccounts.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDeletedAccountsBySubscription().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deletedAccountsPurgeSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deletedAccountsPurgeSample.ts new file mode 100644 index 000000000000..ab8800e53887 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deletedAccountsPurgeSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a Cognitive Services account from the resource group. + * + * @summary Deletes a Cognitive Services account from the resource group. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PurgeDeletedAccount.json + */ +async function deleteAccount() { + const subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const location = "westus"; + const resourceGroupName = "myResourceGroup"; + const accountName = "PropTest01"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.deletedAccounts.beginPurgeAndWait( + location, + resourceGroupName, + accountName + ); + console.log(result); +} + +deleteAccount().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsCreateOrUpdateSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..2ce6453d66e3 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsCreateOrUpdateSample.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + Deployment, + CognitiveServicesManagementClient +} from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Update the state of specified deployments associated with the Cognitive Services account. + * + * @summary Update the state of specified deployments associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutDeployment.json + */ +async function putDeployment() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const deploymentName = "deploymentName"; + const deployment: Deployment = { + properties: { + model: { name: "ada", format: "OpenAI", version: "1" }, + scaleSettings: { capacity: 1, scaleType: "Manual" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + accountName, + deploymentName, + deployment + ); + console.log(result); +} + +putDeployment().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsDeleteSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsDeleteSample.ts new file mode 100644 index 000000000000..0bf4493ac428 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsDeleteSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the specified deployment associated with the Cognitive Services account. + * + * @summary Deletes the specified deployment associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeleteDeployment.json + */ +async function deleteDeployment() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const deploymentName = "deploymentName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.deployments.beginDeleteAndWait( + resourceGroupName, + accountName, + deploymentName + ); + console.log(result); +} + +deleteDeployment().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsGetSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsGetSample.ts new file mode 100644 index 000000000000..01a174f41b1c --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsGetSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the specified deployments associated with the Cognitive Services account. + * + * @summary Gets the specified deployments associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetDeployment.json + */ +async function getDeployment() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const deploymentName = "deploymentName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.deployments.get( + resourceGroupName, + accountName, + deploymentName + ); + console.log(result); +} + +getDeployment().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsListSample.ts new file mode 100644 index 000000000000..641ef11bb031 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/deploymentsListSample.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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the deployments associated with the Cognitive Services account. + * + * @summary Gets the deployments associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListDeployments.json + */ +async function listDeployments() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourceGroupName"; + const accountName = "accountName"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.deployments.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDeployments().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/operationsListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/operationsListSample.ts new file mode 100644 index 000000000000..288b46dbeeb4 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/operationsListSample.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. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the available Cognitive Services account operations. + * + * @summary Lists all the available Cognitive Services account operations. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetOperations.json + */ +async function getOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getOperations().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsCreateOrUpdateSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..419300d0d867 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsCreateOrUpdateSample.ts @@ -0,0 +1,50 @@ +/* + * 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 { + PrivateEndpointConnection, + CognitiveServicesManagementClient +} from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Update the state of specified private endpoint connection associated with the Cognitive Services account. + * + * @summary Update the state of specified private endpoint connection associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/PutPrivateEndpointConnection.json + */ +async function putPrivateEndpointConnection() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res7687"; + const accountName = "sto9699"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const properties: PrivateEndpointConnection = { + properties: { + privateLinkServiceConnectionState: { + description: "Auto-Approved", + status: "Approved" + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.privateEndpointConnections.beginCreateOrUpdateAndWait( + resourceGroupName, + accountName, + privateEndpointConnectionName, + properties + ); + console.log(result); +} + +putPrivateEndpointConnection().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsDeleteSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsDeleteSample.ts new file mode 100644 index 000000000000..640886b030f0 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsDeleteSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the specified private endpoint connection associated with the Cognitive Services account. + * + * @summary Deletes the specified private endpoint connection associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/DeletePrivateEndpointConnection.json + */ +async function deletePrivateEndpointConnection() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res6977"; + const accountName = "sto2527"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.privateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + accountName, + privateEndpointConnectionName + ); + console.log(result); +} + +deletePrivateEndpointConnection().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsGetSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsGetSample.ts new file mode 100644 index 000000000000..9c24187d7b8b --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsGetSample.ts @@ -0,0 +1,38 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the specified private endpoint connection associated with the Cognitive Services account. + * + * @summary Gets the specified private endpoint connection associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetPrivateEndpointConnection.json + */ +async function getPrivateEndpointConnection() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res6977"; + const accountName = "sto2527"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + accountName, + privateEndpointConnectionName + ); + console.log(result); +} + +getPrivateEndpointConnection().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsListSample.ts new file mode 100644 index 000000000000..891a022fa3b1 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateEndpointConnectionsListSample.ts @@ -0,0 +1,36 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the private endpoint connections associated with the Cognitive Services account. + * + * @summary Gets the private endpoint connections associated with the Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListPrivateEndpointConnections.json + */ +async function getPrivateEndpointConnection() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.privateEndpointConnections.list( + resourceGroupName, + accountName + ); + console.log(result); +} + +getPrivateEndpointConnection().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateLinkResourcesListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateLinkResourcesListSample.ts new file mode 100644 index 000000000000..b1303452c62f --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/privateLinkResourcesListSample.ts @@ -0,0 +1,36 @@ +/* + * 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 { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the private link resources that need to be created for a Cognitive Services account. + * + * @summary Gets the private link resources that need to be created for a Cognitive Services account. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/ListPrivateLinkResources.json + */ +async function listPrivateLinkResources() { + const subscriptionId = "{subscription-id}"; + const resourceGroupName = "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const result = await client.privateLinkResources.list( + resourceGroupName, + accountName + ); + console.log(result); +} + +listPrivateLinkResources().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/resourceSkusListSample.ts b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/resourceSkusListSample.ts new file mode 100644 index 000000000000..1cc038a286a9 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/src/resourceSkusListSample.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. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { CognitiveServicesManagementClient } from "@azure/arm-cognitiveservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. + * + * @summary Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. + * x-ms-original-file: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2022-03-01/examples/GetSkus.json + */ +async function regenerateKeys() { + const subscriptionId = "f1c637e4-72ec-4f89-8d2b-0f933c036002"; + const credential = new DefaultAzureCredential(); + const client = new CognitiveServicesManagementClient( + credential, + subscriptionId + ); + const resArray = new Array(); + for await (let item of client.resourceSkus.list()) { + resArray.push(item); + } + console.log(resArray); +} + +regenerateKeys().catch(console.error); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/tsconfig.json b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/cognitiveservices/arm-cognitiveservices/samples/v7/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "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/cognitiveservices/arm-cognitiveservices/src/cognitiveServicesManagementClient.ts b/sdk/cognitiveservices/arm-cognitiveservices/src/cognitiveServicesManagementClient.ts index 58cb9ed56c03..0bba97558d37 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/src/cognitiveServicesManagementClient.ts +++ b/sdk/cognitiveservices/arm-cognitiveservices/src/cognitiveServicesManagementClient.ts @@ -72,7 +72,7 @@ export class CognitiveServicesManagementClient extends coreClient.ServiceClient credential: credentials }; - const packageDetails = `azsdk-js-arm-cognitiveservices/7.0.0`; + const packageDetails = `azsdk-js-arm-cognitiveservices/7.1.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -87,7 +87,8 @@ export class CognitiveServicesManagementClient extends coreClient.ServiceClient userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); // Parameter assignments @@ -95,7 +96,7 @@ export class CognitiveServicesManagementClient extends coreClient.ServiceClient // Assigning values to Constant parameters this.$host = options.$host || "https://management.azure.com"; - this.apiVersion = options.apiVersion || "2021-10-01"; + this.apiVersion = options.apiVersion || "2022-03-01"; this.accounts = new AccountsImpl(this); this.deletedAccounts = new DeletedAccountsImpl(this); this.resourceSkus = new ResourceSkusImpl(this); diff --git a/sdk/cognitiveservices/arm-cognitiveservices/src/models/index.ts b/sdk/cognitiveservices/arm-cognitiveservices/src/models/index.ts index a733bfd3e204..dec6c99a4c78 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/src/models/index.ts +++ b/sdk/cognitiveservices/arm-cognitiveservices/src/models/index.ts @@ -117,7 +117,7 @@ export interface AccountProperties { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly privateEndpointConnections?: PrivateEndpointConnection[]; - /** Whether or not public endpoint access is allowed for this account. Value is optional but if passed in, must be 'Enabled' or 'Disabled' */ + /** Whether or not public endpoint access is allowed for this account. */ publicNetworkAccess?: PublicNetworkAccess; /** The api properties for special APIs. */ apiProperties?: ApiProperties; @@ -131,6 +131,8 @@ export interface AccountProperties { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly callRateLimit?: CallRateLimit; + /** The flag to enable dynamic throttling. */ + dynamicThrottlingEnabled?: boolean; /** NOTE: This property will not be serialized. It can only be populated by the server. */ readonly quotaLimit?: QuotaLimit; restrictOutboundNetworkAccess?: boolean; @@ -142,6 +144,16 @@ export interface AccountProperties { */ readonly endpoints?: { [propertyName: string]: string }; restore?: boolean; + /** + * The deletion date, only available for deleted account. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly deletionDate?: string; + /** + * The scheduled purge date, only available for deleted account. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly scheduledPurgeDate?: string; } /** SkuCapability indicates the capability of a certain feature. */ @@ -485,6 +497,32 @@ export interface MetricName { localizedValue?: string; } +/** The list of cognitive services accounts operation response. */ +export interface AccountModelListResult { + /** The link used to get the next page of Model. */ + nextLink?: string; + /** Gets the list of Cognitive Services accounts Model and their properties. */ + value?: AccountModel[]; +} + +/** Properties of Cognitive Services account deployment model. */ +export interface DeploymentModel { + /** Deployment model format. */ + format?: string; + /** Deployment model name. */ + name?: string; + /** Deployment model version. */ + version?: string; +} + +/** Cognitive Services account ModelDeprecationInfo. */ +export interface ModelDeprecationInfo { + /** The datetime of deprecation of the fineTune Model. */ + fineTune?: string; + /** The datetime of deprecation of the inference Model. */ + inference?: string; +} + /** 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 { /** @@ -709,22 +747,17 @@ export interface DeploymentProperties { scaleSettings?: DeploymentScaleSettings; } -/** Properties of Cognitive Services account deployment model. */ -export interface DeploymentModel { - /** Deployment model format. */ - format?: string; - /** Deployment model name. */ - name?: string; - /** Deployment model version. */ - version?: string; -} - /** Properties of Cognitive Services account deployment model. */ export interface DeploymentScaleSettings { /** Deployment scale type. */ scaleType?: DeploymentScaleType; /** Deployment capacity. */ capacity?: number; + /** + * Deployment active capacity. This value might be different from `capacity` if customer recently updated `capacity`. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly activeCapacity?: number; } /** The list of cognitive services accounts operation response. */ @@ -798,6 +831,23 @@ export type PrivateLinkResource = Resource & { /** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */ export type ProxyResource = Resource & {}; +/** Cognitive Services account Model. */ +export type AccountModel = DeploymentModel & { + /** Base Model Identifier. */ + baseModel?: DeploymentModel; + /** The max capacity. */ + maxCapacity?: number; + /** The capabilities. */ + capabilities?: { [propertyName: string]: string }; + /** Cognitive Services account ModelDeprecationInfo. */ + deprecation?: ModelDeprecationInfo; + /** + * Metadata pertaining to creation and last modification of the resource. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly systemData?: SystemData; +}; + /** The Private Endpoint Connection resource. */ export type PrivateEndpointConnection = AzureEntityResource & { /** Resource properties. */ @@ -1263,6 +1313,13 @@ export interface AccountsListUsagesOptionalParams /** Contains response data for the listUsages operation. */ export type AccountsListUsagesResponse = UsageListResult; +/** Optional parameters. */ +export interface AccountsListModelsOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listModels operation. */ +export type AccountsListModelsResponse = AccountModelListResult; + /** Optional parameters. */ export interface AccountsListByResourceGroupNextOptionalParams extends coreClient.OperationOptions {} @@ -1277,6 +1334,13 @@ export interface AccountsListNextOptionalParams /** Contains response data for the listNext operation. */ export type AccountsListNextResponse = AccountListResult; +/** Optional parameters. */ +export interface AccountsListModelsNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listModelsNext operation. */ +export type AccountsListModelsNextResponse = AccountModelListResult; + /** Optional parameters. */ export interface DeletedAccountsGetOptionalParams extends coreClient.OperationOptions {} diff --git a/sdk/cognitiveservices/arm-cognitiveservices/src/models/mappers.ts b/sdk/cognitiveservices/arm-cognitiveservices/src/models/mappers.ts index 76015b75881b..eac00647d23c 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/src/models/mappers.ts +++ b/sdk/cognitiveservices/arm-cognitiveservices/src/models/mappers.ts @@ -291,6 +291,12 @@ export const AccountProperties: coreClient.CompositeMapper = { className: "CallRateLimit" } }, + dynamicThrottlingEnabled: { + serializedName: "dynamicThrottlingEnabled", + type: { + name: "Boolean" + } + }, quotaLimit: { serializedName: "quotaLimit", type: { @@ -334,6 +340,20 @@ export const AccountProperties: coreClient.CompositeMapper = { type: { name: "Boolean" } + }, + deletionDate: { + serializedName: "deletionDate", + readOnly: true, + type: { + name: "String" + } + }, + scheduledPurgeDate: { + serializedName: "scheduledPurgeDate", + readOnly: true, + type: { + name: "String" + } } } } @@ -1347,6 +1367,81 @@ export const MetricName: coreClient.CompositeMapper = { } }; +export const AccountModelListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AccountModelListResult", + modelProperties: { + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + }, + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "AccountModel" + } + } + } + } + } + } +}; + +export const DeploymentModel: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "DeploymentModel", + modelProperties: { + format: { + serializedName: "format", + type: { + name: "String" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + version: { + serializedName: "version", + type: { + name: "String" + } + } + } + } +}; + +export const ModelDeprecationInfo: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ModelDeprecationInfo", + modelProperties: { + fineTune: { + serializedName: "fineTune", + type: { + name: "String" + } + }, + inference: { + serializedName: "inference", + type: { + name: "String" + } + } + } + } +}; + export const OperationListResult: coreClient.CompositeMapper = { type: { name: "Composite", @@ -1901,33 +1996,6 @@ export const DeploymentProperties: coreClient.CompositeMapper = { } }; -export const DeploymentModel: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "DeploymentModel", - modelProperties: { - format: { - serializedName: "format", - type: { - name: "String" - } - }, - name: { - serializedName: "name", - type: { - name: "String" - } - }, - version: { - serializedName: "version", - type: { - name: "String" - } - } - } - } -}; - export const DeploymentScaleSettings: coreClient.CompositeMapper = { type: { name: "Composite", @@ -1944,6 +2012,13 @@ export const DeploymentScaleSettings: coreClient.CompositeMapper = { type: { name: "Number" } + }, + activeCapacity: { + serializedName: "activeCapacity", + readOnly: true, + type: { + name: "Number" + } } } } @@ -2111,6 +2186,50 @@ export const ProxyResource: coreClient.CompositeMapper = { } }; +export const AccountModel: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AccountModel", + modelProperties: { + ...DeploymentModel.type.modelProperties, + baseModel: { + serializedName: "baseModel", + type: { + name: "Composite", + className: "DeploymentModel" + } + }, + maxCapacity: { + serializedName: "maxCapacity", + type: { + name: "Number" + } + }, + capabilities: { + serializedName: "capabilities", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + }, + deprecation: { + serializedName: "deprecation", + type: { + name: "Composite", + className: "ModelDeprecationInfo" + } + }, + systemData: { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData" + } + } + } + } +}; + export const PrivateEndpointConnection: coreClient.CompositeMapper = { type: { name: "Composite", diff --git a/sdk/cognitiveservices/arm-cognitiveservices/src/models/parameters.ts b/sdk/cognitiveservices/arm-cognitiveservices/src/models/parameters.ts index 3ae70b24eb75..42ef559bb3c2 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/src/models/parameters.ts +++ b/sdk/cognitiveservices/arm-cognitiveservices/src/models/parameters.ts @@ -96,7 +96,7 @@ export const accountName: OperationURLParameter = { export const apiVersion: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - defaultValue: "2021-10-01", + defaultValue: "2022-03-01", isConstant: true, serializedName: "api-version", type: { diff --git a/sdk/cognitiveservices/arm-cognitiveservices/src/operations/accounts.ts b/sdk/cognitiveservices/arm-cognitiveservices/src/operations/accounts.ts index 77b1b5911e4e..e62d07bda639 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/src/operations/accounts.ts +++ b/sdk/cognitiveservices/arm-cognitiveservices/src/operations/accounts.ts @@ -20,6 +20,9 @@ import { AccountsListByResourceGroupOptionalParams, AccountsListNextOptionalParams, AccountsListOptionalParams, + AccountModel, + AccountsListModelsNextOptionalParams, + AccountsListModelsOptionalParams, AccountsCreateOptionalParams, AccountsCreateResponse, AccountsUpdateOptionalParams, @@ -38,8 +41,10 @@ import { AccountsListSkusResponse, AccountsListUsagesOptionalParams, AccountsListUsagesResponse, + AccountsListModelsResponse, AccountsListByResourceGroupNextResponse, - AccountsListNextResponse + AccountsListNextResponse, + AccountsListModelsNextResponse } from "../models"; /// @@ -150,6 +155,77 @@ export class AccountsImpl implements Accounts { } } + /** + * List available Models for the requested Cognitive Services account + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of Cognitive Services account. + * @param options The options parameters. + */ + public listModels( + resourceGroupName: string, + accountName: string, + options?: AccountsListModelsOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listModelsPagingAll( + resourceGroupName, + accountName, + options + ); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listModelsPagingPage( + resourceGroupName, + accountName, + options + ); + } + }; + } + + private async *listModelsPagingPage( + resourceGroupName: string, + accountName: string, + options?: AccountsListModelsOptionalParams + ): AsyncIterableIterator { + let result = await this._listModels( + resourceGroupName, + accountName, + options + ); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listModelsNext( + resourceGroupName, + accountName, + continuationToken, + options + ); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listModelsPagingAll( + resourceGroupName: string, + accountName: string, + options?: AccountsListModelsOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listModelsPagingPage( + resourceGroupName, + accountName, + options + )) { + yield* page; + } + } + /** * Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the * keys for developer to access intelligent APIs. It's also the resource type for billing. @@ -213,10 +289,12 @@ export class AccountsImpl implements Accounts { { resourceGroupName, accountName, account, options }, createOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -304,10 +382,12 @@ export class AccountsImpl implements Accounts { { resourceGroupName, accountName, account, options }, updateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -387,10 +467,12 @@ export class AccountsImpl implements Accounts { { resourceGroupName, accountName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -524,6 +606,23 @@ export class AccountsImpl implements Accounts { ); } + /** + * List available Models for the requested Cognitive Services account + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of Cognitive Services account. + * @param options The options parameters. + */ + private _listModels( + resourceGroupName: string, + accountName: string, + options?: AccountsListModelsOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, accountName, options }, + listModelsOperationSpec + ); + } + /** * ListByResourceGroupNext * @param resourceGroupName The name of the resource group. The name is case insensitive. @@ -555,6 +654,25 @@ export class AccountsImpl implements Accounts { listNextOperationSpec ); } + + /** + * ListModelsNext + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of Cognitive Services account. + * @param nextLink The nextLink from the previous successful call to the ListModels method. + * @param options The options parameters. + */ + private _listModelsNext( + resourceGroupName: string, + accountName: string, + nextLink: string, + options?: AccountsListModelsNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, accountName, nextLink, options }, + listModelsNextOperationSpec + ); + } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); @@ -801,6 +919,28 @@ const listUsagesOperationSpec: coreClient.OperationSpec = { headerParameters: [Parameters.accept], serializer }; +const listModelsOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/models", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AccountModelListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.resourceGroupName, + Parameters.accountName, + Parameters.subscriptionId + ], + headerParameters: [Parameters.accept], + serializer +}; const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", @@ -842,3 +982,25 @@ const listNextOperationSpec: coreClient.OperationSpec = { headerParameters: [Parameters.accept], serializer }; +const listModelsNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AccountModelListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.resourceGroupName, + Parameters.accountName, + Parameters.subscriptionId, + Parameters.nextLink + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/cognitiveservices/arm-cognitiveservices/src/operations/commitmentPlans.ts b/sdk/cognitiveservices/arm-cognitiveservices/src/operations/commitmentPlans.ts index a48f1544bcb6..41d07b1897a4 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/src/operations/commitmentPlans.ts +++ b/sdk/cognitiveservices/arm-cognitiveservices/src/operations/commitmentPlans.ts @@ -222,10 +222,12 @@ export class CommitmentPlansImpl implements CommitmentPlans { { resourceGroupName, accountName, commitmentPlanName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/cognitiveservices/arm-cognitiveservices/src/operations/deletedAccounts.ts b/sdk/cognitiveservices/arm-cognitiveservices/src/operations/deletedAccounts.ts index b53d7591ccdc..df6a73d6f186 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/src/operations/deletedAccounts.ts +++ b/sdk/cognitiveservices/arm-cognitiveservices/src/operations/deletedAccounts.ts @@ -156,10 +156,12 @@ export class DeletedAccountsImpl implements DeletedAccounts { { location, resourceGroupName, accountName, options }, purgeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/cognitiveservices/arm-cognitiveservices/src/operations/deployments.ts b/sdk/cognitiveservices/arm-cognitiveservices/src/operations/deployments.ts index 65043a0598fd..85c632cd220b 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/src/operations/deployments.ts +++ b/sdk/cognitiveservices/arm-cognitiveservices/src/operations/deployments.ts @@ -199,10 +199,12 @@ export class DeploymentsImpl implements Deployments { { resourceGroupName, accountName, deploymentName, deployment, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -287,10 +289,12 @@ export class DeploymentsImpl implements Deployments { { resourceGroupName, accountName, deploymentName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/cognitiveservices/arm-cognitiveservices/src/operations/privateEndpointConnections.ts b/sdk/cognitiveservices/arm-cognitiveservices/src/operations/privateEndpointConnections.ts index 460d830c4691..04c0df21aa39 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/src/operations/privateEndpointConnections.ts +++ b/sdk/cognitiveservices/arm-cognitiveservices/src/operations/privateEndpointConnections.ts @@ -151,10 +151,12 @@ export class PrivateEndpointConnectionsImpl }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -247,10 +249,12 @@ export class PrivateEndpointConnectionsImpl }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/cognitiveservices/arm-cognitiveservices/src/operationsInterfaces/accounts.ts b/sdk/cognitiveservices/arm-cognitiveservices/src/operationsInterfaces/accounts.ts index 31d34178784c..e3d3ec126c21 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/src/operationsInterfaces/accounts.ts +++ b/sdk/cognitiveservices/arm-cognitiveservices/src/operationsInterfaces/accounts.ts @@ -12,6 +12,8 @@ import { Account, AccountsListByResourceGroupOptionalParams, AccountsListOptionalParams, + AccountModel, + AccountsListModelsOptionalParams, AccountsCreateOptionalParams, AccountsCreateResponse, AccountsUpdateOptionalParams, @@ -49,6 +51,17 @@ export interface Accounts { list( options?: AccountsListOptionalParams ): PagedAsyncIterableIterator; + /** + * List available Models for the requested Cognitive Services account + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of Cognitive Services account. + * @param options The options parameters. + */ + listModels( + resourceGroupName: string, + accountName: string, + options?: AccountsListModelsOptionalParams + ): PagedAsyncIterableIterator; /** * Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the * keys for developer to access intelligent APIs. It's also the resource type for billing. diff --git a/sdk/cognitiveservices/arm-cognitiveservices/tsconfig.json b/sdk/cognitiveservices/arm-cognitiveservices/tsconfig.json index 6e3251194117..67e8e46df416 100644 --- a/sdk/cognitiveservices/arm-cognitiveservices/tsconfig.json +++ b/sdk/cognitiveservices/arm-cognitiveservices/tsconfig.json @@ -9,11 +9,25 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6", "dom"], + "lib": [ + "es6", + "dom" + ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-cognitiveservices": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.ts"], - "exclude": ["node_modules"] -} + "include": [ + "./src/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/cognitiveservices/ci.mgmt.yml b/sdk/cognitiveservices/ci.mgmt.yml index e0e0bd8e9eed..605be190bd1d 100644 --- a/sdk/cognitiveservices/ci.mgmt.yml +++ b/sdk/cognitiveservices/ci.mgmt.yml @@ -1,5 +1,5 @@ # NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. - + trigger: branches: include: @@ -9,7 +9,7 @@ trigger: paths: include: - sdk/cognitiveservices/ci.mgmt.yml - - sdk/cognitiveservices/arm-cognitiveservices/ + - sdk/cognitiveservices/arm-cognitiveservices pr: branches: include: @@ -22,12 +22,11 @@ pr: paths: include: - sdk/cognitiveservices/ci.mgmt.yml - - sdk/cognitiveservices/arm-cognitiveservices/ - + - sdk/cognitiveservices/arm-cognitiveservices extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: ServiceDirectory: cognitiveservices Artifacts: - name: azure-arm-cognitiveservices - safeName: azurearmcognitiveservices \ No newline at end of file + safeName: azurearmcognitiveservices