diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index e4342d3948bb..e9cdce4dcc27 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -17,6 +17,7 @@ dependencies: '@rush-temp/arm-network': file:projects/arm-network.tgz '@rush-temp/arm-policy': file:projects/arm-policy.tgz '@rush-temp/arm-resources': file:projects/arm-resources.tgz + '@rush-temp/arm-resources-subscriptions': file:projects/arm-resources-subscriptions.tgz '@rush-temp/arm-sql': file:projects/arm-sql.tgz '@rush-temp/arm-storage': file:projects/arm-storage.tgz '@rush-temp/arm-webpubsub': file:projects/arm-webpubsub.tgz @@ -8764,6 +8765,26 @@ packages: integrity: sha512-1cDd7l+RfNr7rAJxGMqLHW/zYV/F5tRFsA1R6RplSOTGg8yo1foORk8QvIa+oumecW/uYGC/jePfHrx55atGMQ== tarball: file:projects/arm-policy.tgz version: 0.0.0 + file:projects/arm-resources-subscriptions.tgz: + dependencies: + '@microsoft/api-extractor': 7.7.11 + '@rollup/plugin-commonjs': 11.0.2_rollup@1.32.1 + '@rollup/plugin-json': 4.1.0_rollup@1.32.1 + '@rollup/plugin-multi-entry': 3.0.1_rollup@1.32.1 + '@rollup/plugin-node-resolve': 8.4.0_rollup@1.32.1 + mkdirp: 1.0.4 + rollup: 1.32.1 + rollup-plugin-node-resolve: 3.4.0 + rollup-plugin-sourcemaps: 0.4.2_rollup@1.32.1 + tslib: 2.3.1 + typescript: 4.2.4 + uglify-js: 3.14.1 + dev: false + name: '@rush-temp/arm-resources-subscriptions' + resolution: + integrity: sha512-6GWFjnVvh/TZyCDi+Fj6ShcBGzmKQ8mvChj7v+n68IPy8QUwXlB08EvQ5zo/7+jii9EwFGCBOQok/5+BISRnJg== + tarball: file:projects/arm-resources-subscriptions.tgz + version: 0.0.0 file:projects/arm-resources.tgz: dependencies: '@microsoft/api-extractor': 7.7.11 @@ -12621,6 +12642,7 @@ specifiers: '@rush-temp/arm-network': file:./projects/arm-network.tgz '@rush-temp/arm-policy': file:./projects/arm-policy.tgz '@rush-temp/arm-resources': file:./projects/arm-resources.tgz + '@rush-temp/arm-resources-subscriptions': file:./projects/arm-resources-subscriptions.tgz '@rush-temp/arm-sql': file:./projects/arm-sql.tgz '@rush-temp/arm-storage': file:./projects/arm-storage.tgz '@rush-temp/arm-webpubsub': file:./projects/arm-webpubsub.tgz diff --git a/eng/ignore-links.txt b/eng/ignore-links.txt index 0306124efee6..76cbcb30cd11 100644 --- a/eng/ignore-links.txt +++ b/eng/ignore-links.txt @@ -8,3 +8,5 @@ https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/storage-blob-cha https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/storage-blob-changefeed/samples/typescript https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/storage-blob-changefeed/test/ https://github.com/Azure/azure-digital-twins/blob/private-preview/Documentation/how-to-manage-routes.md +https://docs.microsoft.com/javascript/api/@azure/arm-resources-subscriptions +https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/resources-subscriptions/arm-resources-subscriptions diff --git a/rush.json b/rush.json index 45f8d146f912..36e35ab09f18 100644 --- a/rush.json +++ b/rush.json @@ -880,6 +880,11 @@ "packageName": "@azure/arm-appservice", "projectFolder": "sdk/appservice/arm-appservice", "versionPolicyName": "management" + }, + { + "packageName": "@azure/arm-resources-subscriptions", + "projectFolder": "sdk/resources-subscriptions/arm-resources-subscriptions", + "versionPolicyName": "management" } ] -} +} \ No newline at end of file diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/CHANGELOG.md b/sdk/resources-subscriptions/arm-resources-subscriptions/CHANGELOG.md new file mode 100644 index 000000000000..f04562219eca --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/CHANGELOG.md @@ -0,0 +1,15 @@ +## 1.0.0-beta.1 (2021-08-24) + +This is the first preview for the new version of the `@azure/arm-resources-subscriptions` package that follows the new [guidelines for TypeScript SDKs](https://azure.github.io/azure-sdk/typescript_introduction.html) for Azure services. + +While this package remains auto generated, the SDK generator itself has undergone changes to comply with the above guidelines in order to generate packages that are idiomatic to the JavaScript/TypeScript ecosystem and consistent with other packages for Azure services. For more on this, please see [State of the Azure SDK 2021](https://devblogs.microsoft.com/azure-sdk/state-of-the-azure-sdk-2021/). + +Please note that this version has breaking changes, all of which were made after careful consideration during the authoring of the guidelines and user studies. + +**Noteworthy changes and features** + +- Authentication: The packages `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` are no longer supported. Use package [@azure/identity](https://www.npmjs.com/package/@azure/identity) instead. Select a credential from Azure Identity examples based on the authentication method of your choice. +- Callbacks: Method overloads that used callbacks have been removed and the use of promises is encouraged instead. +- List operations now return an iterable result that follows the `PagedAsyncIterableIterator` interface as opposed to the previous model where you had to make a new request using the link to the next page. +- Long running operations i.e. the Lro related object returned by methods whose names started with `begin`, now uses `pollUntilDone` to check whether the request is finished, instead of `pollUntilFinished`. To get the final result, use the corresponding method that will have the suffix `AndWait`. +- The SDK only supports ECMAScript 2015 (ES6) and beyond, all projects that referenced this SDK should be upgraded to use ES6. diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/LICENSE b/sdk/resources-subscriptions/arm-resources-subscriptions/LICENSE new file mode 100644 index 000000000000..ccb63b166732 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/README.md b/sdk/resources-subscriptions/arm-resources-subscriptions/README.md new file mode 100644 index 000000000000..89103439803b --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/README.md @@ -0,0 +1,94 @@ +# Azure Subscription client library for JavaScript + +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure Subscription client. + +All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. + +[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/resources-subscriptions/arm-resources-subscriptions) | +[Package (NPM)](https://www.npmjs.com/package/@azure/arm-resources-subscriptions) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-resources-subscriptions) | +[Samples](https://github.com/Azure-Samples/azure-samples-js-management) + +## Getting started + +### Currently supported environments + +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge and Firefox. + +### Prerequisites + +- An [Azure subscription][azure_sub]. + +### Install the `@azure/arm-resources-subscriptions` package + +Install the Azure Subscription client library for JavaScript with `npm`: + +```bash +npm install @azure/arm-resources-subscriptions +``` + +### Create and authenticate a `SubscriptionClient` + +To create a client object to access the Azure Subscription API, you will need the `endpoint` of your Azure Subscription resource and a `credential`. The Azure Subscription client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure Subscription resource in the [Azure Portal][azure_portal]. + +#### Using an Azure Active Directory Credential + +You can authenticate with Azure Active Directory using the [Azure Identity library][azure_identity]. To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: + +```bash +npm install @azure/identity +``` + +You will also need to **register a new AAD application and grant access to Azure Subscription** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`. + +For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). + +```javascript +const { SubscriptionClient } = require("@azure/arm-resources-subscriptions"); +const { DefaultAzureCredential } = require("@azure/identity"); +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const client = new SubscriptionClient(new DefaultAzureCredential(), subscriptionId); +``` + +## Key concepts + +### SubscriptionClient + +`SubscriptionClient` is the primary interface for developers using the Azure Subscription client library. Explore the methods on this client object to understand the different features of the Azure Subscription service that you can access. + +## Troubleshooting + +### Logging + +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: + +```javascript +import { setLogLevel } from "@azure/logger"; +setLogLevel("info"); +``` + +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). + +## Next steps + +Please take a look at the [samples](https://github.com/Azure-Samples/azure-samples-js-management) directory for detailed examples on how to use this library. + +## Contributing + +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code. + +## Related projects + +- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fresources-subscriptions%2Farm-resources-subscriptions%2FREADME.png) + +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_sub]: https://azure.microsoft.com/free/ +[azure_sub]: https://azure.microsoft.com/free/ +[azure_portal]: https://portal.azure.com +[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity +[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/_meta.json b/sdk/resources-subscriptions/arm-resources-subscriptions/_meta.json new file mode 100644 index 000000000000..4d2584b86789 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/_meta.json @@ -0,0 +1,7 @@ +{ + "commit": "0efd11ad640cce266563ed3e533557d45ab74bc8", + "readme": "specification/resources/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 --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/resources/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.10.20210820.1", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "use": "@autorest/typescript@6.0.0-alpha.10.20210820.1" +} \ No newline at end of file diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/api-extractor.json b/sdk/resources-subscriptions/arm-resources-subscriptions/api-extractor.json new file mode 100644 index 000000000000..f1352d0683c1 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/api-extractor.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "./dist-esm/index.d.ts", + "docModel": { "enabled": true }, + "apiReport": { "enabled": true, "reportFolder": "./review" }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/arm-resources-subscriptions.d.ts" + }, + "messages": { + "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "extractorMessageReporting": { + "ae-missing-release-tag": { "logLevel": "none" }, + "ae-unresolved-link": { "logLevel": "none" } + } + } +} diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/package.json b/sdk/resources-subscriptions/arm-resources-subscriptions/package.json new file mode 100644 index 000000000000..3baf314a62d5 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/package.json @@ -0,0 +1,87 @@ +{ + "name": "@azure/arm-resources-subscriptions", + "sdk-type": "mgmt", + "author": "Microsoft Corporation", + "description": "A generated SDK for SubscriptionClient.", + "version": "1.0.0-beta.1", + "engines": { "node": ">=12.0.0" }, + "dependencies": { + "@azure/core-paging": "^1.1.1", + "@azure/core-client": "^1.0.0", + "@azure/core-auth": "^1.3.0", + "@azure/core-rest-pipeline": "^1.1.0", + "tslib": "^2.2.0" + }, + "keywords": ["node", "azure", "typescript", "browser", "isomorphic"], + "license": "MIT", + "main": "./dist/index.js", + "module": "./dist-esm/index.js", + "types": "./types/arm-resources-subscriptions.d.ts", + "devDependencies": { + "@microsoft/api-extractor": "7.7.11", + "@rollup/plugin-commonjs": "11.0.2", + "@rollup/plugin-json": "^4.0.0", + "@rollup/plugin-multi-entry": "^3.0.0", + "@rollup/plugin-node-resolve": "^8.0.0", + "mkdirp": "^1.0.4", + "rollup": "^1.16.3", + "rollup-plugin-sourcemaps": "^0.4.2", + "rollup-plugin-node-resolve": "^3.4.0", + "typescript": "~4.2.0", + "uglify-js": "^3.4.9" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/resources-subscriptions/arm-resources-subscriptions", + "repository": { + "type": "git", + "url": "https://github.com/Azure/azure-sdk-for-js.git" + }, + "bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, + "files": [ + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map", + "dist-esm/**/*.js", + "dist-esm/**/*.js.map", + "dist-esm/**/*.d.ts", + "dist-esm/**/*.d.ts.map", + "src/**/*.ts", + "README.md", + "LICENSE", + "rollup.config.js", + "tsconfig.json", + "review/*", + "CHANGELOG.md", + "types/*" + ], + "scripts": { + "build": "tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", + "prepack": "npm run build", + "pack": "npm pack 2>&1", + "extract-api": "api-extractor run --local", + "lint": "echo skipped", + "audit": "echo skipped", + "clean": "echo skipped", + "build:node": "echo skipped", + "build:browser": "echo skipped", + "build:test": "echo skipped", + "build:samples": "echo skipped.", + "check-format": "echo skipped", + "execute:samples": "echo skipped", + "format": "echo skipped", + "test": "echo skipped", + "prebuild": "echo skipped", + "test:node": "echo skipped", + "test:browser": "echo skipped", + "unit-test": "echo skipped", + "unit-test:node": "echo skipped", + "unit-test:browser": "echo skipped", + "integration-test:browser": "echo skipped", + "integration-test:node": "echo skipped", + "integration-test": "echo skipped", + "docs": "echo skipped" + }, + "sideEffects": false, + "autoPublish": true +} diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/review/arm-resources-subscriptions.api.md b/sdk/resources-subscriptions/arm-resources-subscriptions/review/arm-resources-subscriptions.api.md new file mode 100644 index 000000000000..c55252234512 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/review/arm-resources-subscriptions.api.md @@ -0,0 +1,291 @@ +## API Report File for "@azure/arm-resources-subscriptions" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import * as coreAuth from '@azure/core-auth'; +import * as coreClient from '@azure/core-client'; +import { PagedAsyncIterableIterator } from '@azure/core-paging'; + +// @public +export interface CheckResourceNameResult { + name?: string; + status?: ResourceNameStatus; + type?: string; +} + +// @public +export interface CloudError { + error?: ErrorResponse; +} + +// @public +export interface ErrorAdditionalInfo { + readonly info?: Record; + readonly type?: string; +} + +// @public +export interface ErrorResponse { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorResponse[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export enum KnownRegionCategory { + // (undocumented) + Extended = "Extended", + // (undocumented) + Other = "Other", + // (undocumented) + Recommended = "Recommended" +} + +// @public +export enum KnownRegionType { + // (undocumented) + Logical = "Logical", + // (undocumented) + Physical = "Physical" +} + +// @public +export enum KnownResourceNameStatus { + // (undocumented) + Allowed = "Allowed", + // (undocumented) + Reserved = "Reserved" +} + +// @public +export interface Location { + readonly displayName?: string; + readonly id?: string; + metadata?: LocationMetadata; + readonly name?: string; + readonly regionalDisplayName?: string; + readonly subscriptionId?: string; + readonly type?: LocationType; +} + +// @public +export interface LocationListResult { + value?: Location[]; +} + +// @public +export interface LocationMetadata { + readonly geographyGroup?: string; + readonly homeLocation?: string; + readonly latitude?: string; + readonly longitude?: string; + pairedRegion?: PairedRegion[]; + readonly physicalLocation?: string; + readonly regionCategory?: RegionCategory; + readonly regionType?: RegionType; +} + +// @public +export type LocationType = "Region" | "EdgeZone"; + +// @public +export interface ManagedByTenant { + readonly tenantId?: string; +} + +// @public +export interface Operation { + display?: OperationDisplay; + name?: string; +} + +// @public +export interface OperationDisplay { + description?: string; + operation?: string; + provider?: string; + resource?: string; +} + +// @public +export interface OperationListResult { + nextLink?: string; + value?: Operation[]; +} + +// @public +export interface PairedRegion { + readonly id?: string; + readonly name?: string; + readonly subscriptionId?: string; +} + +// @public +export type RegionCategory = string; + +// @public +export type RegionType = string; + +// @public +export interface ResourceName { + name: string; + type: string; +} + +// @public +export type ResourceNameStatus = string; + +// @public +export type SpendingLimit = "On" | "Off" | "CurrentPeriodOff"; + +// @public +export interface Subscription { + authorizationSource?: string; + readonly displayName?: string; + readonly id?: string; + managedByTenants?: ManagedByTenant[]; + readonly state?: SubscriptionState; + readonly subscriptionId?: string; + subscriptionPolicies?: SubscriptionPolicies; + tags?: { + [propertyName: string]: string; + }; + readonly tenantId?: string; +} + +// @public (undocumented) +export class SubscriptionClient extends SubscriptionClientContext { + constructor(credentials: coreAuth.TokenCredential, options?: SubscriptionClientOptionalParams); + checkResourceName(options?: SubscriptionClientCheckResourceNameOptionalParams): Promise; + // (undocumented) + subscriptions: Subscriptions; + // (undocumented) + tenants: Tenants; +} + +// @public +export interface SubscriptionClientCheckResourceNameOptionalParams extends coreClient.OperationOptions { + resourceNameDefinition?: ResourceName; +} + +// @public +export type SubscriptionClientCheckResourceNameResponse = CheckResourceNameResult; + +// @public (undocumented) +export class SubscriptionClientContext extends coreClient.ServiceClient { + // (undocumented) + $host: string; + constructor(credentials: coreAuth.TokenCredential, options?: SubscriptionClientOptionalParams); + // (undocumented) + apiVersion: string; +} + +// @public +export interface SubscriptionClientOptionalParams extends coreClient.ServiceClientOptions { + $host?: string; + apiVersion?: string; + endpoint?: string; +} + +// @public +export interface SubscriptionListResult { + nextLink: string; + value?: Subscription[]; +} + +// @public +export interface SubscriptionPolicies { + readonly locationPlacementId?: string; + readonly quotaId?: string; + readonly spendingLimit?: SpendingLimit; +} + +// @public +export interface Subscriptions { + get(subscriptionId: string, options?: SubscriptionsGetOptionalParams): Promise; + list(options?: SubscriptionsListOptionalParams): PagedAsyncIterableIterator; + listLocations(subscriptionId: string, options?: SubscriptionsListLocationsOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface SubscriptionsGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionsGetResponse = Subscription; + +// @public +export interface SubscriptionsListLocationsOptionalParams extends coreClient.OperationOptions { + includeExtendedLocations?: boolean; +} + +// @public +export type SubscriptionsListLocationsResponse = LocationListResult; + +// @public +export interface SubscriptionsListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionsListNextResponse = SubscriptionListResult; + +// @public +export interface SubscriptionsListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionsListResponse = SubscriptionListResult; + +// @public +export type SubscriptionState = "Enabled" | "Warned" | "PastDue" | "Disabled" | "Deleted"; + +// @public +export type TenantCategory = "Home" | "ProjectedBy" | "ManagedBy"; + +// @public +export interface TenantIdDescription { + readonly country?: string; + readonly countryCode?: string; + readonly defaultDomain?: string; + readonly displayName?: string; + readonly domains?: string[]; + readonly id?: string; + readonly tenantBrandingLogoUrl?: string; + readonly tenantCategory?: TenantCategory; + readonly tenantId?: string; + readonly tenantType?: string; +} + +// @public +export interface TenantListResult { + nextLink: string; + value?: TenantIdDescription[]; +} + +// @public +export interface Tenants { + list(options?: TenantsListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface TenantsListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type TenantsListNextResponse = TenantListResult; + +// @public +export interface TenantsListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type TenantsListResponse = TenantListResult; + + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/rollup.config.js b/sdk/resources-subscriptions/arm-resources-subscriptions/rollup.config.js new file mode 100644 index 000000000000..9be1955eb7f1 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/rollup.config.js @@ -0,0 +1,188 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import nodeResolve from "@rollup/plugin-node-resolve"; +import cjs from "@rollup/plugin-commonjs"; +import sourcemaps from "rollup-plugin-sourcemaps"; +import multiEntry from "@rollup/plugin-multi-entry"; +import json from "@rollup/plugin-json"; + +import nodeBuiltins from "builtin-modules"; + +/** + * Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api. + * + * NOTE: this manual configuration is only needed because OpenTelemetry uses an + * __exportStar downleveled helper function to declare its exports which confuses + * rollup's automatic discovery mechanism. + * + * @returns an object reference that can be `...`'d into your cjs() configuration. + */ +export function openTelemetryCommonJs() { + const namedExports = {}; + + for (const key of [ + "@opentelemetry/api", + "@azure/core-tracing/node_modules/@opentelemetry/api" + ]) { + namedExports[key] = [ + "SpanKind", + "TraceFlags", + "getSpan", + "setSpan", + "SpanStatusCode", + "getSpanContext", + "setSpanContext" + ]; + } + + const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"]; + + for (const version of releasedOpenTelemetryVersions) { + namedExports[ + // working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path. + `../../../common/temp/node_modules/.pnpm/@opentelemetry/api@${version}/node_modules/@opentelemetry/api/build/src/index.js` + ] = [ + "SpanKind", + "TraceFlags", + "getSpan", + "setSpan", + "StatusCode", + "CanonicalCode", + "getSpanContext", + "setSpanContext" + ]; + } + + return namedExports; +} + +// #region Warning Handler + +/** + * A function that can determine whether a rollupwarning should be ignored. If + * the function returns `true`, then the warning will not be displayed. + */ + +function ignoreNiseSinonEvalWarnings(warning) { + return ( + warning.code === "EVAL" && + warning.id && + (warning.id.includes("node_modules/nise") || + warning.id.includes("node_modules/sinon")) === true + ); +} + +function ignoreChaiCircularDependencyWarnings(warning) { + return ( + warning.code === "CIRCULAR_DEPENDENCY" && + warning.importer && warning.importer.includes("node_modules/chai") === true + ); +} + +const warningInhibitors = [ + ignoreChaiCircularDependencyWarnings, + ignoreNiseSinonEvalWarnings +]; + +/** + * Construct a warning handler for the shared rollup configuration + * that ignores certain warnings that are not relevant to testing. + */ +function makeOnWarnForTesting() { + return (warning, warn) => { + // If every inhibitor returns false (i.e. no inhibitors), then show the warning + if (warningInhibitors.every((inhib) => !inhib(warning))) { + warn(warning); + } + }; +} + +// #endregion + +function makeBrowserTestConfig() { + const config = { + input: { + include: ["dist-esm/test/**/*.spec.js"], + exclude: ["dist-esm/test/**/node/**"] + }, + output: { + file: `dist-test/index.browser.js`, + format: "umd", + sourcemap: true + }, + preserveSymlinks: false, + plugins: [ + multiEntry({ exports: false }), + nodeResolve({ + mainFields: ["module", "browser"] + }), + cjs({ + namedExports: { + // Chai's strange internal architecture makes it impossible to statically + // analyze its exports. + chai: [ + "version", + "use", + "util", + "config", + "expect", + "should", + "assert" + ], + ...openTelemetryCommonJs() + } + }), + json(), + sourcemaps() + //viz({ filename: "dist-test/browser-stats.html", sourcemap: true }) + ], + onwarn: makeOnWarnForTesting(), + // Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, + // rollup started respecting the "sideEffects" field in package.json. Since + // our package.json sets "sideEffects=false", this also applies to test + // code, which causes all tests to be removed by tree-shaking. + treeshake: false + }; + + return config; +} + +const defaultConfigurationOptions = { + disableBrowserBundle: false +}; + +export function makeConfig(pkg, options) { + options = { + ...defaultConfigurationOptions, + ...(options || {}) + }; + + const baseConfig = { + // Use the package's module field if it has one + input: pkg["module"] || "dist-esm/src/index.js", + external: [ + ...nodeBuiltins, + ...Object.keys(pkg.dependencies), + ...Object.keys(pkg.devDependencies) + ], + output: { file: "dist/index.js", format: "cjs", sourcemap: true }, + preserveSymlinks: false, + plugins: [sourcemaps(), nodeResolve(), cjs()] + }; + + const config = [baseConfig]; + + if (!options.disableBrowserBundle) { + config.push(makeBrowserTestConfig()); + } + + return config; +} + +export default makeConfig(require("./package.json")); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/index.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/index.ts new file mode 100644 index 000000000000..5dc972cbaeef --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +/// +export * from "./models"; +export { SubscriptionClient } from "./subscriptionClient"; +export { SubscriptionClientContext } from "./subscriptionClientContext"; +export * from "./operationsInterfaces"; diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/index.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/index.ts new file mode 100644 index 000000000000..c4fe0bbc0be8 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/index.ts @@ -0,0 +1,470 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; + +/** Location list operation response. */ +export interface LocationListResult { + /** An array of locations. */ + value?: Location[]; +} + +/** Location information. */ +export interface Location { + /** + * The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The subscription ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly subscriptionId?: string; + /** + * The location name. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * The location type. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: LocationType; + /** + * The display name of the location. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly displayName?: string; + /** + * The display name of the location and its region. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly regionalDisplayName?: string; + /** Metadata of the location, such as lat/long, paired region, and others. */ + metadata?: LocationMetadata; +} + +/** Location metadata information */ +export interface LocationMetadata { + /** + * The type of the region. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly regionType?: RegionType; + /** + * The category of the region. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly regionCategory?: RegionCategory; + /** + * The geography group of the location. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly geographyGroup?: string; + /** + * The longitude of the location. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly longitude?: string; + /** + * The latitude of the location. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly latitude?: string; + /** + * The physical location of the Azure location. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly physicalLocation?: string; + /** The regions paired to this region. */ + pairedRegion?: PairedRegion[]; + /** + * The home location of an edge zone. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly homeLocation?: string; +} + +/** Information regarding paired region. */ +export interface PairedRegion { + /** + * The name of the paired region. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The subscription ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly subscriptionId?: string; +} + +/** An error response for a resource management request. */ +export interface CloudError { + /** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.) */ + error?: ErrorResponse; +} + +/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.) */ +export interface ErrorResponse { + /** + * The error code. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly code?: string; + /** + * The error message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; + /** + * The error target. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly target?: string; + /** + * The error details. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly details?: ErrorResponse[]; + /** + * The error additional info. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** + * The additional info type. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * The additional info. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly info?: Record; +} + +/** Subscription information. */ +export interface Subscription { + /** + * The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The subscription ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly subscriptionId?: string; + /** + * The subscription display name. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly displayName?: string; + /** + * The subscription tenant ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly tenantId?: string; + /** + * The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly state?: SubscriptionState; + /** The subscription policies. */ + subscriptionPolicies?: SubscriptionPolicies; + /** The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. */ + authorizationSource?: string; + /** An array containing the tenants managing the subscription. */ + managedByTenants?: ManagedByTenant[]; + /** The tags attached to the subscription. */ + tags?: { [propertyName: string]: string }; +} + +/** Subscription policies. */ +export interface SubscriptionPolicies { + /** + * The subscription location placement ID. The ID indicates which regions are visible for a subscription. For example, a subscription with a location placement Id of Public_2014-09-01 has access to Azure public regions. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly locationPlacementId?: string; + /** + * The subscription quota ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly quotaId?: string; + /** + * The subscription spending limit. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly spendingLimit?: SpendingLimit; +} + +/** Information about a tenant managing the subscription. */ +export interface ManagedByTenant { + /** + * The tenant ID of the managing tenant. This is a GUID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly tenantId?: string; +} + +/** Subscription list operation response. */ +export interface SubscriptionListResult { + /** An array of subscriptions. */ + value?: Subscription[]; + /** The URL to get the next set of results. */ + nextLink: string; +} + +/** Tenant Ids information. */ +export interface TenantListResult { + /** An array of tenants. */ + value?: TenantIdDescription[]; + /** The URL to use for getting the next set of results. */ + nextLink: string; +} + +/** Tenant Id information. */ +export interface TenantIdDescription { + /** + * The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The tenant ID. For example, 00000000-0000-0000-0000-000000000000. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly tenantId?: string; + /** + * Category of the tenant. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly tenantCategory?: TenantCategory; + /** + * Country/region name of the address for the tenant. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly country?: string; + /** + * Country/region abbreviation for the tenant. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly countryCode?: string; + /** + * The display name of the tenant. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly displayName?: string; + /** + * The list of domains for the tenant. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly domains?: string[]; + /** + * The default domain for the tenant. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly defaultDomain?: string; + /** + * The tenant type. Only available for 'Home' tenant category. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly tenantType?: string; + /** + * The tenant's branding logo URL. Only available for 'Home' tenant category. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly tenantBrandingLogoUrl?: string; +} + +/** Name and Type of the Resource */ +export interface ResourceName { + /** Name of the resource */ + name: string; + /** The type of the resource */ + type: string; +} + +/** Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word */ +export interface CheckResourceNameResult { + /** Name of Resource */ + name?: string; + /** Type of Resource */ + type?: string; + /** Is the resource name Allowed or Reserved */ + status?: ResourceNameStatus; +} + +/** Microsoft.Resources operation */ +export interface Operation { + /** Operation name: {provider}/{resource}/{operation} */ + name?: string; + /** The object that represents the operation. */ + display?: OperationDisplay; +} + +/** The object that represents the operation. */ +export interface OperationDisplay { + /** Service provider: Microsoft.Resources */ + provider?: string; + /** Resource on which the operation is performed: Profile, endpoint, etc. */ + resource?: string; + /** Operation type: Read, write, delete, etc. */ + operation?: string; + /** Description of the operation. */ + description?: string; +} + +/** Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. */ +export interface OperationListResult { + /** List of Microsoft.Resources operations. */ + value?: Operation[]; + /** URL to get the next set of operation list results if there are any. */ + nextLink?: string; +} + +/** Known values of {@link RegionType} that the service accepts. */ +export enum KnownRegionType { + Physical = "Physical", + Logical = "Logical" +} + +/** + * Defines values for RegionType. \ + * {@link KnownRegionType} can be used interchangeably with RegionType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Physical** \ + * **Logical** + */ +export type RegionType = string; + +/** Known values of {@link RegionCategory} that the service accepts. */ +export enum KnownRegionCategory { + Recommended = "Recommended", + Extended = "Extended", + Other = "Other" +} + +/** + * Defines values for RegionCategory. \ + * {@link KnownRegionCategory} can be used interchangeably with RegionCategory, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Recommended** \ + * **Extended** \ + * **Other** + */ +export type RegionCategory = string; + +/** Known values of {@link ResourceNameStatus} that the service accepts. */ +export enum KnownResourceNameStatus { + Allowed = "Allowed", + Reserved = "Reserved" +} + +/** + * Defines values for ResourceNameStatus. \ + * {@link KnownResourceNameStatus} can be used interchangeably with ResourceNameStatus, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Allowed** \ + * **Reserved** + */ +export type ResourceNameStatus = string; +/** Defines values for LocationType. */ +export type LocationType = "Region" | "EdgeZone"; +/** Defines values for SubscriptionState. */ +export type SubscriptionState = + | "Enabled" + | "Warned" + | "PastDue" + | "Disabled" + | "Deleted"; +/** Defines values for SpendingLimit. */ +export type SpendingLimit = "On" | "Off" | "CurrentPeriodOff"; +/** Defines values for TenantCategory. */ +export type TenantCategory = "Home" | "ProjectedBy" | "ManagedBy"; + +/** Optional parameters. */ +export interface SubscriptionsListLocationsOptionalParams + extends coreClient.OperationOptions { + /** Whether to include extended locations. */ + includeExtendedLocations?: boolean; +} + +/** Contains response data for the listLocations operation. */ +export type SubscriptionsListLocationsResponse = LocationListResult; + +/** Optional parameters. */ +export interface SubscriptionsGetOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type SubscriptionsGetResponse = Subscription; + +/** Optional parameters. */ +export interface SubscriptionsListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type SubscriptionsListResponse = SubscriptionListResult; + +/** Optional parameters. */ +export interface SubscriptionsListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type SubscriptionsListNextResponse = SubscriptionListResult; + +/** Optional parameters. */ +export interface TenantsListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type TenantsListResponse = TenantListResult; + +/** Optional parameters. */ +export interface TenantsListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type TenantsListNextResponse = TenantListResult; + +/** Optional parameters. */ +export interface SubscriptionClientCheckResourceNameOptionalParams + extends coreClient.OperationOptions { + /** Resource object with values for resource name and resource type */ + resourceNameDefinition?: ResourceName; +} + +/** Contains response data for the checkResourceName operation. */ +export type SubscriptionClientCheckResourceNameResponse = CheckResourceNameResult; + +/** Optional parameters. */ +export interface SubscriptionClientOptionalParams + extends coreClient.ServiceClientOptions { + /** server parameter */ + $host?: string; + /** Api Version */ + apiVersion?: string; + /** Overrides client endpoint. */ + endpoint?: string; +} diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/mappers.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/mappers.ts new file mode 100644 index 000000000000..3bc2da2a3652 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/mappers.ts @@ -0,0 +1,682 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; + +export const LocationListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "LocationListResult", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Location" + } + } + } + } + } + } +}; + +export const Location: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Location", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "Enum", + allowedValues: ["Region", "EdgeZone"] + } + }, + displayName: { + serializedName: "displayName", + readOnly: true, + type: { + name: "String" + } + }, + regionalDisplayName: { + serializedName: "regionalDisplayName", + readOnly: true, + type: { + name: "String" + } + }, + metadata: { + serializedName: "metadata", + type: { + name: "Composite", + className: "LocationMetadata" + } + } + } + } +}; + +export const LocationMetadata: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "LocationMetadata", + modelProperties: { + regionType: { + serializedName: "regionType", + readOnly: true, + type: { + name: "String" + } + }, + regionCategory: { + serializedName: "regionCategory", + readOnly: true, + type: { + name: "String" + } + }, + geographyGroup: { + serializedName: "geographyGroup", + readOnly: true, + type: { + name: "String" + } + }, + longitude: { + serializedName: "longitude", + readOnly: true, + type: { + name: "String" + } + }, + latitude: { + serializedName: "latitude", + readOnly: true, + type: { + name: "String" + } + }, + physicalLocation: { + serializedName: "physicalLocation", + readOnly: true, + type: { + name: "String" + } + }, + pairedRegion: { + serializedName: "pairedRegion", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PairedRegion" + } + } + } + }, + homeLocation: { + serializedName: "homeLocation", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const PairedRegion: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "PairedRegion", + modelProperties: { + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const CloudError: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CloudError", + modelProperties: { + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ErrorResponse" + } + } + } + } +}; + +export const ErrorResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + code: { + serializedName: "code", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String" + } + }, + target: { + serializedName: "target", + readOnly: true, + type: { + name: "String" + } + }, + details: { + serializedName: "details", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorResponse" + } + } + } + }, + additionalInfo: { + serializedName: "additionalInfo", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorAdditionalInfo" + } + } + } + } + } + } +}; + +export const ErrorAdditionalInfo: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorAdditionalInfo", + modelProperties: { + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + info: { + serializedName: "info", + readOnly: true, + type: { + name: "Dictionary", + value: { type: { name: "any" } } + } + } + } + } +}; + +export const Subscription: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Subscription", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + readOnly: true, + type: { + name: "String" + } + }, + displayName: { + serializedName: "displayName", + readOnly: true, + type: { + name: "String" + } + }, + tenantId: { + serializedName: "tenantId", + readOnly: true, + type: { + name: "String" + } + }, + state: { + serializedName: "state", + readOnly: true, + type: { + name: "Enum", + allowedValues: ["Enabled", "Warned", "PastDue", "Disabled", "Deleted"] + } + }, + subscriptionPolicies: { + serializedName: "subscriptionPolicies", + type: { + name: "Composite", + className: "SubscriptionPolicies" + } + }, + authorizationSource: { + serializedName: "authorizationSource", + type: { + name: "String" + } + }, + managedByTenants: { + serializedName: "managedByTenants", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ManagedByTenant" + } + } + } + }, + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + } + } + } +}; + +export const SubscriptionPolicies: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "SubscriptionPolicies", + modelProperties: { + locationPlacementId: { + serializedName: "locationPlacementId", + readOnly: true, + type: { + name: "String" + } + }, + quotaId: { + serializedName: "quotaId", + readOnly: true, + type: { + name: "String" + } + }, + spendingLimit: { + serializedName: "spendingLimit", + readOnly: true, + type: { + name: "Enum", + allowedValues: ["On", "Off", "CurrentPeriodOff"] + } + } + } + } +}; + +export const ManagedByTenant: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedByTenant", + modelProperties: { + tenantId: { + serializedName: "tenantId", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const SubscriptionListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "SubscriptionListResult", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Subscription" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + } + } + } +}; + +export const TenantListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "TenantListResult", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "TenantIdDescription" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + } + } + } +}; + +export const TenantIdDescription: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "TenantIdDescription", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + tenantId: { + serializedName: "tenantId", + readOnly: true, + type: { + name: "String" + } + }, + tenantCategory: { + serializedName: "tenantCategory", + readOnly: true, + type: { + name: "Enum", + allowedValues: ["Home", "ProjectedBy", "ManagedBy"] + } + }, + country: { + serializedName: "country", + readOnly: true, + type: { + name: "String" + } + }, + countryCode: { + serializedName: "countryCode", + readOnly: true, + type: { + name: "String" + } + }, + displayName: { + serializedName: "displayName", + readOnly: true, + type: { + name: "String" + } + }, + domains: { + serializedName: "domains", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + defaultDomain: { + serializedName: "defaultDomain", + readOnly: true, + type: { + name: "String" + } + }, + tenantType: { + serializedName: "tenantType", + readOnly: true, + type: { + name: "String" + } + }, + tenantBrandingLogoUrl: { + serializedName: "tenantBrandingLogoUrl", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const ResourceName: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceName", + modelProperties: { + name: { + serializedName: "name", + required: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + required: true, + type: { + name: "String" + } + } + } + } +}; + +export const CheckResourceNameResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CheckResourceNameResult", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + }, + type: { + serializedName: "type", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + } + } + } +}; + +export const Operation: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Operation", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + }, + display: { + serializedName: "display", + type: { + name: "Composite", + className: "OperationDisplay" + } + } + } + } +}; + +export const OperationDisplay: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationDisplay", + modelProperties: { + provider: { + serializedName: "provider", + type: { + name: "String" + } + }, + resource: { + serializedName: "resource", + type: { + name: "String" + } + }, + operation: { + serializedName: "operation", + type: { + name: "String" + } + }, + description: { + serializedName: "description", + type: { + name: "String" + } + } + } + } +}; + +export const OperationListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationListResult", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Operation" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/parameters.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/parameters.ts new file mode 100644 index 000000000000..6ae1bccccf87 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/parameters.ts @@ -0,0 +1,100 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + OperationParameter, + OperationURLParameter, + OperationQueryParameter +} from "@azure/core-client"; +import { ResourceName as ResourceNameMapper } from "../models/mappers"; + +export const accept: OperationParameter = { + parameterPath: "accept", + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Accept", + type: { + name: "String" + } + } +}; + +export const $host: OperationURLParameter = { + parameterPath: "$host", + mapper: { + serializedName: "$host", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const subscriptionId: OperationURLParameter = { + parameterPath: "subscriptionId", + mapper: { + serializedName: "subscriptionId", + required: true, + type: { + name: "String" + } + } +}; + +export const apiVersion: OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "2021-01-01", + isConstant: true, + serializedName: "api-version", + type: { + name: "String" + } + } +}; + +export const includeExtendedLocations: OperationQueryParameter = { + parameterPath: ["options", "includeExtendedLocations"], + mapper: { + serializedName: "includeExtendedLocations", + type: { + name: "Boolean" + } + } +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", + mapper: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String" + } + } +}; + +export const resourceNameDefinition: OperationParameter = { + parameterPath: ["options", "resourceNameDefinition"], + mapper: ResourceNameMapper +}; diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/index.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/index.ts new file mode 100644 index 000000000000..6c722ac4853c --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export * from "./subscriptions"; +export * from "./tenants"; diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/subscriptions.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/subscriptions.ts new file mode 100644 index 000000000000..3a1ce8bd44ad --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/subscriptions.ts @@ -0,0 +1,250 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import "@azure/core-paging"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Subscriptions } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { SubscriptionClientContext } from "../subscriptionClientContext"; +import { + Location, + SubscriptionsListLocationsOptionalParams, + Subscription, + SubscriptionsListNextOptionalParams, + SubscriptionsListOptionalParams, + SubscriptionsListLocationsResponse, + SubscriptionsGetOptionalParams, + SubscriptionsGetResponse, + SubscriptionsListResponse, + SubscriptionsListNextResponse +} from "../models"; + +/// +/** Class containing Subscriptions operations. */ +export class SubscriptionsImpl implements Subscriptions { + private readonly client: SubscriptionClientContext; + + /** + * Initialize a new instance of the class Subscriptions class. + * @param client Reference to the service client + */ + constructor(client: SubscriptionClientContext) { + this.client = client; + } + + /** + * This operation provides all the locations that are available for resource providers; however, each + * resource provider may support a subset of this list. + * @param subscriptionId The ID of the target subscription. + * @param options The options parameters. + */ + public listLocations( + subscriptionId: string, + options?: SubscriptionsListLocationsOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listLocationsPagingAll(subscriptionId, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listLocationsPagingPage(subscriptionId, options); + } + }; + } + + private async *listLocationsPagingPage( + subscriptionId: string, + options?: SubscriptionsListLocationsOptionalParams + ): AsyncIterableIterator { + let result = await this._listLocations(subscriptionId, options); + yield result.value || []; + } + + private async *listLocationsPagingAll( + subscriptionId: string, + options?: SubscriptionsListLocationsOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listLocationsPagingPage( + subscriptionId, + options + )) { + yield* page; + } + } + + /** + * Gets all subscriptions for a tenant. + * @param options The options parameters. + */ + public list( + options?: SubscriptionsListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listPagingPage(options); + } + }; + } + + private async *listPagingPage( + options?: SubscriptionsListOptionalParams + ): AsyncIterableIterator { + let result = await this._list(options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listNext(continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listPagingAll( + options?: SubscriptionsListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } + } + + /** + * This operation provides all the locations that are available for resource providers; however, each + * resource provider may support a subset of this list. + * @param subscriptionId The ID of the target subscription. + * @param options The options parameters. + */ + private _listLocations( + subscriptionId: string, + options?: SubscriptionsListLocationsOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { subscriptionId, options }, + listLocationsOperationSpec + ); + } + + /** + * Gets details about a specified subscription. + * @param subscriptionId The ID of the target subscription. + * @param options The options parameters. + */ + get( + subscriptionId: string, + options?: SubscriptionsGetOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { subscriptionId, options }, + getOperationSpec + ); + } + + /** + * Gets all subscriptions for a tenant. + * @param options The options parameters. + */ + private _list( + options?: SubscriptionsListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + + /** + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + nextLink: string, + options?: SubscriptionsListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listLocationsOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/locations", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.LocationListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + queryParameters: [Parameters.apiVersion, Parameters.includeExtendedLocations], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], + serializer +}; +const getOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.Subscription + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], + serializer +}; +const listOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.SubscriptionListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.SubscriptionListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/tenants.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/tenants.ts new file mode 100644 index 000000000000..9f36744a7328 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/tenants.ts @@ -0,0 +1,138 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import "@azure/core-paging"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Tenants } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { SubscriptionClientContext } from "../subscriptionClientContext"; +import { + TenantIdDescription, + TenantsListNextOptionalParams, + TenantsListOptionalParams, + TenantsListResponse, + TenantsListNextResponse +} from "../models"; + +/// +/** Class containing Tenants operations. */ +export class TenantsImpl implements Tenants { + private readonly client: SubscriptionClientContext; + + /** + * Initialize a new instance of the class Tenants class. + * @param client Reference to the service client + */ + constructor(client: SubscriptionClientContext) { + this.client = client; + } + + /** + * Gets the tenants for your account. + * @param options The options parameters. + */ + public list( + options?: TenantsListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listPagingPage(options); + } + }; + } + + private async *listPagingPage( + options?: TenantsListOptionalParams + ): AsyncIterableIterator { + let result = await this._list(options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listNext(continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listPagingAll( + options?: TenantsListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } + } + + /** + * Gets the tenants for your account. + * @param options The options parameters. + */ + private _list( + options?: TenantsListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + + /** + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + nextLink: string, + options?: TenantsListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreClient.OperationSpec = { + path: "/tenants", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.TenantListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.TenantListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/operationsInterfaces/index.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operationsInterfaces/index.ts new file mode 100644 index 000000000000..6c722ac4853c --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operationsInterfaces/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export * from "./subscriptions"; +export * from "./tenants"; diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/operationsInterfaces/subscriptions.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operationsInterfaces/subscriptions.ts new file mode 100644 index 000000000000..6db2b8363730 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operationsInterfaces/subscriptions.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import "@azure/core-paging"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { + Location, + SubscriptionsListLocationsOptionalParams, + Subscription, + SubscriptionsListOptionalParams, + SubscriptionsGetOptionalParams, + SubscriptionsGetResponse +} from "../models"; + +/// +/** Interface representing a Subscriptions. */ +export interface Subscriptions { + /** + * This operation provides all the locations that are available for resource providers; however, each + * resource provider may support a subset of this list. + * @param subscriptionId The ID of the target subscription. + * @param options The options parameters. + */ + listLocations( + subscriptionId: string, + options?: SubscriptionsListLocationsOptionalParams + ): PagedAsyncIterableIterator; + /** + * Gets all subscriptions for a tenant. + * @param options The options parameters. + */ + list( + options?: SubscriptionsListOptionalParams + ): PagedAsyncIterableIterator; + /** + * Gets details about a specified subscription. + * @param subscriptionId The ID of the target subscription. + * @param options The options parameters. + */ + get( + subscriptionId: string, + options?: SubscriptionsGetOptionalParams + ): Promise; +} diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/operationsInterfaces/tenants.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operationsInterfaces/tenants.ts new file mode 100644 index 000000000000..db9550258085 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operationsInterfaces/tenants.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import "@azure/core-paging"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { TenantIdDescription, TenantsListOptionalParams } from "../models"; + +/// +/** Interface representing a Tenants. */ +export interface Tenants { + /** + * Gets the tenants for your account. + * @param options The options parameters. + */ + list( + options?: TenantsListOptionalParams + ): PagedAsyncIterableIterator; +} diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClient.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClient.ts new file mode 100644 index 000000000000..7fa6d5d86ed3 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClient.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; +import * as coreAuth from "@azure/core-auth"; +import { SubscriptionsImpl, TenantsImpl } from "./operations"; +import { Subscriptions, Tenants } from "./operationsInterfaces"; +import * as Parameters from "./models/parameters"; +import * as Mappers from "./models/mappers"; +import { SubscriptionClientContext } from "./subscriptionClientContext"; +import { + SubscriptionClientOptionalParams, + SubscriptionClientCheckResourceNameOptionalParams, + SubscriptionClientCheckResourceNameResponse +} from "./models"; + +export class SubscriptionClient extends SubscriptionClientContext { + /** + * Initializes a new instance of the SubscriptionClient class. + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param options The parameter options + */ + constructor( + credentials: coreAuth.TokenCredential, + options?: SubscriptionClientOptionalParams + ) { + super(credentials, options); + this.subscriptions = new SubscriptionsImpl(this); + this.tenants = new TenantsImpl(this); + } + + /** + * A resource name is valid if it is not a reserved word, does not contains a reserved word and does + * not start with a reserved word + * @param options The options parameters. + */ + checkResourceName( + options?: SubscriptionClientCheckResourceNameOptionalParams + ): Promise { + return this.sendOperationRequest( + { options }, + checkResourceNameOperationSpec + ); + } + + subscriptions: Subscriptions; + tenants: Tenants; +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const checkResourceNameOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Resources/checkResourceName", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.CheckResourceNameResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + requestBody: Parameters.resourceNameDefinition, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClientContext.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClientContext.ts new file mode 100644 index 000000000000..7bc06470b4bd --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClientContext.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; +import * as coreAuth from "@azure/core-auth"; +import { SubscriptionClientOptionalParams } from "./models"; + +export class SubscriptionClientContext extends coreClient.ServiceClient { + $host: string; + apiVersion: string; + + /** + * Initializes a new instance of the SubscriptionClientContext class. + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param options The parameter options + */ + constructor( + credentials: coreAuth.TokenCredential, + options?: SubscriptionClientOptionalParams + ) { + if (credentials === undefined) { + throw new Error("'credentials' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + const defaults: SubscriptionClientOptionalParams = { + requestContentType: "application/json; charset=utf-8", + credential: credentials + }; + + const packageDetails = `azsdk-js-arm-resources-subscriptions/1.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` + : `${packageDetails}`; + + if (!options.credentialScopes) { + options.credentialScopes = ["https://management.azure.com/.default"]; + } + const optionsWithDefaults = { + ...defaults, + ...options, + userAgentOptions: { + userAgentPrefix + }, + baseUri: options.endpoint || "https://management.azure.com" + }; + super(optionsWithDefaults); + + // Assigning values to Constant parameters + this.$host = options.$host || "https://management.azure.com"; + this.apiVersion = options.apiVersion || "2021-01-01"; + } +} diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/tsconfig.json b/sdk/resources-subscriptions/arm-resources-subscriptions/tsconfig.json new file mode 100644 index 000000000000..603440b3a359 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "es6", + "moduleResolution": "node", + "strict": true, + "target": "es6", + "sourceMap": true, + "declarationMap": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "lib": ["es6", "dom"], + "declaration": true, + "outDir": "./dist-esm", + "importHelpers": true + }, + "include": ["./src/**/*.ts"], + "exclude": ["node_modules"] +} diff --git a/sdk/resources-subscriptions/ci.yml b/sdk/resources-subscriptions/ci.yml new file mode 100644 index 000000000000..fc4b617b6bf1 --- /dev/null +++ b/sdk/resources-subscriptions/ci.yml @@ -0,0 +1,29 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - release/* + - hotfix/* + paths: + include: + - sdk/resources-subscriptions/ + +pr: + branches: + include: + - main + - release/* + - hotfix/* + paths: + include: + - sdk/resources-subscriptions/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: resources-subscriptions + Artifacts: + - name: azure-arm-resources-subscriptions + safeName: azurearmresourcessubscriptions + \ No newline at end of file