From 504f2e768edbff7cc1c18e2357819b3b7dd817ec Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 23 Aug 2021 06:29:02 +0000 Subject: [PATCH] CodeGen from PR 15671 in Azure/azure-rest-api-specs update-typescript.md-for-resources (#15671) * update-typescript.md-for-resources * update --- .../arm-resources-subscriptions/LICENSE.txt | 21 + .../arm-resources-subscriptions/README.md | 110 +++ .../arm-resources-subscriptions/package.json | 59 ++ .../rollup.config.js | 37 + .../src/models/index.ts | 649 ++++++++++++++++ .../src/models/mappers.ts | 707 ++++++++++++++++++ .../src/models/parameters.ts | 64 ++ .../src/models/subscriptionsMappers.ts | 21 + .../src/models/tenantsMappers.ts | 15 + .../src/operations/index.ts | 11 + .../src/operations/subscriptions.ts | 230 ++++++ .../src/operations/tenants.ts | 125 ++++ .../src/subscriptionClient.ts | 102 +++ .../src/subscriptionClientContext.ts | 61 ++ .../arm-resources-subscriptions/tsconfig.json | 19 + 15 files changed, 2231 insertions(+) create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/LICENSE.txt create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/README.md create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/package.json create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/rollup.config.js create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/src/models/index.ts create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/src/models/mappers.ts create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/src/models/parameters.ts create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/src/models/subscriptionsMappers.ts create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/src/models/tenantsMappers.ts create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/index.ts create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/subscriptions.ts create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/tenants.ts create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClient.ts create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClientContext.ts create mode 100644 sdk/resources-subscriptions/arm-resources-subscriptions/tsconfig.json diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/LICENSE.txt b/sdk/resources-subscriptions/arm-resources-subscriptions/LICENSE.txt new file mode 100644 index 000000000000..2d3163745319 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/LICENSE.txt @@ -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. 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..b2efa619c187 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/README.md @@ -0,0 +1,110 @@ +## Azure SubscriptionClient SDK for JavaScript + +This package contains an isomorphic SDK (runs both in node.js and in browsers) for SubscriptionClient. + +### Currently supported environments + +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge and Firefox. + +### Prerequisites + +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-resources-subscriptions` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: +```bash +npm install --save @azure/arm-resources-subscriptions @azure/identity +``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + +### How to use + +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. + +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. +#### nodejs - Authentication, client creation, and listLocations subscriptions as an example written in JavaScript. + +##### Sample code + +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { SubscriptionClient } = require("@azure/arm-resources-subscriptions"); +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new SubscriptionClient(creds, subscriptionId); +const subscriptionId = "testsubscriptionId"; +const includeExtendedLocations = true; +client.subscriptions.listLocations(subscriptionId, includeExtendedLocations).then((result) => { + console.log("The result is:"); + console.log(result); +}).catch((err) => { + console.log("An error occurred:"); + console.error(err); +}); +``` + +#### browser - Authentication, client creation, and listLocations subscriptions as an example written in JavaScript. + +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. + +##### Sample code + +- index.html + +```html + + + + @azure/arm-resources-subscriptions sample + + + + + + + +``` + +## 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/sdk/resources-subscriptions/arm-resources-subscriptions/README.png) 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..2982a1abec53 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/package.json @@ -0,0 +1,59 @@ +{ + "name": "@azure/arm-resources-subscriptions", + "author": "Microsoft Corporation", + "description": "SubscriptionClient Library with typescript type definitions for node.js and browser.", + "version": "1.0.0", + "dependencies": { + "@azure/ms-rest-azure-js": "^2.1.0", + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", + "tslib": "^1.10.0" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/arm-resources-subscriptions.js", + "module": "./esm/subscriptionClient.js", + "types": "./esm/subscriptionClient.d.ts", + "devDependencies": { + "typescript": "^3.6.0", + "rollup": "^1.18.0", + "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-sourcemaps": "^0.4.2", + "uglify-js": "^3.6.0" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/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", + "esm/**/*.js", + "esm/**/*.js.map", + "esm/**/*.d.ts", + "esm/**/*.d.ts.map", + "src/**/*.ts", + "README.md", + "rollup.config.js", + "tsconfig.json" + ], + "scripts": { + "build": "tsc && rollup -c rollup.config.js && npm run minify", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/arm-resources-subscriptions.js.map'\" -o ./dist/arm-resources-subscriptions.min.js ./dist/arm-resources-subscriptions.js", + "prepack": "npm install && npm run build" + }, + "sideEffects": false, + "autoPublish": true +} 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..45312e4ebf92 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/rollup.config.js @@ -0,0 +1,37 @@ +import rollup from "rollup"; +import nodeResolve from "rollup-plugin-node-resolve"; +import sourcemaps from "rollup-plugin-sourcemaps"; + +/** + * @type {rollup.RollupFileOptions} + */ +const config = { + input: "./esm/subscriptionClient.js", + external: [ + "@azure/ms-rest-js", + "@azure/ms-rest-azure-js" + ], + output: { + file: "./dist/arm-resources-subscriptions.js", + format: "umd", + name: "Azure.ArmResourcesSubscriptions", + sourcemap: true, + globals: { + "@azure/ms-rest-js": "msRest", + "@azure/ms-rest-azure-js": "msRestAzure" + }, + banner: `/* + * 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. + */` + }, + plugins: [ + nodeResolve({ mainFields: ['module', 'main'] }), + sourcemaps() + ] +}; + +export default config; 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..ab78bfcd8e82 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/index.ts @@ -0,0 +1,649 @@ +/* + * 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 { BaseResource, CloudError, AzureServiceClientOptions } from "@azure/ms-rest-azure-js"; +import * as msRest from "@azure/ms-rest-js"; + +export { BaseResource, CloudError }; + +/** + * 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; +} + +/** + * Location metadata information + */ +export interface LocationMetadata { + /** + * The type of the region. Possible values include: 'Physical', 'Logical' + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly regionType?: RegionType; + /** + * The category of the region. Possible values include: 'Recommended', 'Extended', 'Other' + * **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; +} + +/** + * 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. Possible values include: 'Region', 'EdgeZone' + * **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; +} + +/** + * 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. Possible values include: 'On', 'Off', 'CurrentPeriodOff' + * **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 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. + * Possible values include: 'Enabled', 'Warned', 'PastDue', 'Disabled', '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 }; +} + +/** + * 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. Possible values include: 'Home', 'ProjectedBy', 'ManagedBy' + * **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. Possible values include: 'Allowed', 'Reserved' + */ + status?: ResourceNameStatus; +} + +/** + * 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?: any; +} + +/** + * Common error response for all Azure Resource Manager APIs to return error details for failed + * operations. (This also follows the OData error response format.) + * @summary Error Response + */ +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 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; +} + +/** + * Microsoft.Resources operation + */ +export interface Operation { + /** + * Operation name: {provider}/{resource}/{operation} + */ + name?: string; + /** + * The object that represents the operation. + */ + display?: OperationDisplay; +} + +/** + * 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; +} + +/** + * Optional Parameters. + */ +export interface SubscriptionsListLocationsOptionalParams extends msRest.RequestOptionsBase { + /** + * Whether to include extended locations. + */ + includeExtendedLocations?: boolean; +} + +/** + * Optional Parameters. + */ +export interface SubscriptionClientCheckResourceNameOptionalParams extends msRest.RequestOptionsBase { + /** + * Resource object with values for resource name and resource type + */ + resourceNameDefinition?: ResourceName; +} + +/** + * An interface representing SubscriptionClientOptions. + */ +export interface SubscriptionClientOptions extends AzureServiceClientOptions { + baseUri?: string; +} + +/** + * @interface + * Location list operation response. + * @extends Array + */ +export interface LocationListResult extends Array { +} + +/** + * @interface + * Subscription list operation response. + * @extends Array + */ +export interface SubscriptionListResult extends Array { + /** + * The URL to get the next set of results. + */ + nextLink: string; +} + +/** + * @interface + * Tenant Ids information. + * @extends Array + */ +export interface TenantListResult extends Array { + /** + * The URL to use for getting the next set of results. + */ + nextLink: string; +} + +/** + * Defines values for RegionType. + * Possible values include: 'Physical', 'Logical' + * @readonly + * @enum {string} + */ +export type RegionType = 'Physical' | 'Logical'; + +/** + * Defines values for RegionCategory. + * Possible values include: 'Recommended', 'Extended', 'Other' + * @readonly + * @enum {string} + */ +export type RegionCategory = 'Recommended' | 'Extended' | 'Other'; + +/** + * Defines values for LocationType. + * Possible values include: 'Region', 'EdgeZone' + * @readonly + * @enum {string} + */ +export type LocationType = 'Region' | 'EdgeZone'; + +/** + * Defines values for SubscriptionState. + * Possible values include: 'Enabled', 'Warned', 'PastDue', 'Disabled', 'Deleted' + * @readonly + * @enum {string} + */ +export type SubscriptionState = 'Enabled' | 'Warned' | 'PastDue' | 'Disabled' | 'Deleted'; + +/** + * Defines values for SpendingLimit. + * Possible values include: 'On', 'Off', 'CurrentPeriodOff' + * @readonly + * @enum {string} + */ +export type SpendingLimit = 'On' | 'Off' | 'CurrentPeriodOff'; + +/** + * Defines values for TenantCategory. + * Possible values include: 'Home', 'ProjectedBy', 'ManagedBy' + * @readonly + * @enum {string} + */ +export type TenantCategory = 'Home' | 'ProjectedBy' | 'ManagedBy'; + +/** + * Defines values for ResourceNameStatus. + * Possible values include: 'Allowed', 'Reserved' + * @readonly + * @enum {string} + */ +export type ResourceNameStatus = 'Allowed' | 'Reserved'; + +/** + * Contains response data for the listLocations operation. + */ +export type SubscriptionsListLocationsResponse = LocationListResult & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: LocationListResult; + }; +}; + +/** + * Contains response data for the get operation. + */ +export type SubscriptionsGetResponse = Subscription & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: Subscription; + }; +}; + +/** + * Contains response data for the list operation. + */ +export type SubscriptionsListResponse = SubscriptionListResult & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: SubscriptionListResult; + }; +}; + +/** + * Contains response data for the listNext operation. + */ +export type SubscriptionsListNextResponse = SubscriptionListResult & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: SubscriptionListResult; + }; +}; + +/** + * Contains response data for the list operation. + */ +export type TenantsListResponse = TenantListResult & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: TenantListResult; + }; +}; + +/** + * Contains response data for the listNext operation. + */ +export type TenantsListNextResponse = TenantListResult & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: TenantListResult; + }; +}; + +/** + * Contains response data for the checkResourceName operation. + */ +export type CheckResourceNameResponse = CheckResourceNameResult & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: CheckResourceNameResult; + }; +}; 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..22e2fdf336f2 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/mappers.ts @@ -0,0 +1,707 @@ +/* + * 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 { CloudErrorMapper, BaseResourceMapper } from "@azure/ms-rest-azure-js"; +import * as msRest from "@azure/ms-rest-js"; + +export const CloudError = CloudErrorMapper; +export const BaseResource = BaseResourceMapper; + +export const PairedRegion: msRest.CompositeMapper = { + serializedName: "PairedRegion", + type: { + name: "Composite", + className: "PairedRegion", + modelProperties: { + name: { + readOnly: true, + serializedName: "name", + type: { + name: "String" + } + }, + id: { + readOnly: true, + serializedName: "id", + type: { + name: "String" + } + }, + subscriptionId: { + readOnly: true, + serializedName: "subscriptionId", + type: { + name: "String" + } + } + } + } +}; + +export const LocationMetadata: msRest.CompositeMapper = { + serializedName: "LocationMetadata", + type: { + name: "Composite", + className: "LocationMetadata", + modelProperties: { + regionType: { + readOnly: true, + serializedName: "regionType", + type: { + name: "String" + } + }, + regionCategory: { + readOnly: true, + serializedName: "regionCategory", + type: { + name: "String" + } + }, + geographyGroup: { + readOnly: true, + serializedName: "geographyGroup", + type: { + name: "String" + } + }, + longitude: { + readOnly: true, + serializedName: "longitude", + type: { + name: "String" + } + }, + latitude: { + readOnly: true, + serializedName: "latitude", + type: { + name: "String" + } + }, + physicalLocation: { + readOnly: true, + serializedName: "physicalLocation", + type: { + name: "String" + } + }, + pairedRegion: { + serializedName: "pairedRegion", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "PairedRegion" + } + } + } + }, + homeLocation: { + readOnly: true, + serializedName: "homeLocation", + type: { + name: "String" + } + } + } + } +}; + +export const Location: msRest.CompositeMapper = { + serializedName: "Location", + type: { + name: "Composite", + className: "Location", + modelProperties: { + id: { + readOnly: true, + serializedName: "id", + type: { + name: "String" + } + }, + subscriptionId: { + readOnly: true, + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + name: { + readOnly: true, + serializedName: "name", + type: { + name: "String" + } + }, + type: { + readOnly: true, + serializedName: "type", + type: { + name: "Enum", + allowedValues: [ + "Region", + "EdgeZone" + ] + } + }, + displayName: { + readOnly: true, + serializedName: "displayName", + type: { + name: "String" + } + }, + regionalDisplayName: { + readOnly: true, + serializedName: "regionalDisplayName", + type: { + name: "String" + } + }, + metadata: { + serializedName: "metadata", + type: { + name: "Composite", + className: "LocationMetadata" + } + } + } + } +}; + +export const SubscriptionPolicies: msRest.CompositeMapper = { + serializedName: "SubscriptionPolicies", + type: { + name: "Composite", + className: "SubscriptionPolicies", + modelProperties: { + locationPlacementId: { + readOnly: true, + serializedName: "locationPlacementId", + type: { + name: "String" + } + }, + quotaId: { + readOnly: true, + serializedName: "quotaId", + type: { + name: "String" + } + }, + spendingLimit: { + readOnly: true, + serializedName: "spendingLimit", + type: { + name: "Enum", + allowedValues: [ + "On", + "Off", + "CurrentPeriodOff" + ] + } + } + } + } +}; + +export const ManagedByTenant: msRest.CompositeMapper = { + serializedName: "ManagedByTenant", + type: { + name: "Composite", + className: "ManagedByTenant", + modelProperties: { + tenantId: { + readOnly: true, + serializedName: "tenantId", + type: { + name: "String" + } + } + } + } +}; + +export const Subscription: msRest.CompositeMapper = { + serializedName: "Subscription", + type: { + name: "Composite", + className: "Subscription", + modelProperties: { + id: { + readOnly: true, + serializedName: "id", + type: { + name: "String" + } + }, + subscriptionId: { + readOnly: true, + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + displayName: { + readOnly: true, + serializedName: "displayName", + type: { + name: "String" + } + }, + tenantId: { + readOnly: true, + serializedName: "tenantId", + type: { + name: "String" + } + }, + state: { + readOnly: true, + serializedName: "state", + 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 TenantIdDescription: msRest.CompositeMapper = { + serializedName: "TenantIdDescription", + type: { + name: "Composite", + className: "TenantIdDescription", + modelProperties: { + id: { + readOnly: true, + serializedName: "id", + type: { + name: "String" + } + }, + tenantId: { + readOnly: true, + serializedName: "tenantId", + type: { + name: "String" + } + }, + tenantCategory: { + readOnly: true, + serializedName: "tenantCategory", + type: { + name: "Enum", + allowedValues: [ + "Home", + "ProjectedBy", + "ManagedBy" + ] + } + }, + country: { + readOnly: true, + serializedName: "country", + type: { + name: "String" + } + }, + countryCode: { + readOnly: true, + serializedName: "countryCode", + type: { + name: "String" + } + }, + displayName: { + readOnly: true, + serializedName: "displayName", + type: { + name: "String" + } + }, + domains: { + readOnly: true, + serializedName: "domains", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + }, + defaultDomain: { + readOnly: true, + serializedName: "defaultDomain", + type: { + name: "String" + } + }, + tenantType: { + readOnly: true, + serializedName: "tenantType", + type: { + name: "String" + } + }, + tenantBrandingLogoUrl: { + readOnly: true, + serializedName: "tenantBrandingLogoUrl", + type: { + name: "String" + } + } + } + } +}; + +export const ResourceName: msRest.CompositeMapper = { + serializedName: "ResourceName", + type: { + name: "Composite", + className: "ResourceName", + modelProperties: { + name: { + required: true, + serializedName: "name", + type: { + name: "String" + } + }, + type: { + required: true, + serializedName: "type", + type: { + name: "String" + } + } + } + } +}; + +export const CheckResourceNameResult: msRest.CompositeMapper = { + serializedName: "CheckResourceNameResult", + 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 ErrorAdditionalInfo: msRest.CompositeMapper = { + serializedName: "ErrorAdditionalInfo", + type: { + name: "Composite", + className: "ErrorAdditionalInfo", + modelProperties: { + type: { + readOnly: true, + serializedName: "type", + type: { + name: "String" + } + }, + info: { + readOnly: true, + serializedName: "info", + type: { + name: "Object" + } + } + } + } +}; + +export const ErrorResponse: msRest.CompositeMapper = { + serializedName: "ErrorResponse", + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + code: { + readOnly: true, + serializedName: "code", + type: { + name: "String" + } + }, + message: { + readOnly: true, + serializedName: "message", + type: { + name: "String" + } + }, + target: { + readOnly: true, + serializedName: "target", + type: { + name: "String" + } + }, + details: { + readOnly: true, + serializedName: "details", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorResponse" + } + } + } + }, + additionalInfo: { + readOnly: true, + serializedName: "additionalInfo", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorAdditionalInfo" + } + } + } + } + } + } +}; + +export const OperationDisplay: msRest.CompositeMapper = { + serializedName: "Operation_display", + 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 Operation: msRest.CompositeMapper = { + serializedName: "Operation", + type: { + name: "Composite", + className: "Operation", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + }, + display: { + serializedName: "display", + type: { + name: "Composite", + className: "OperationDisplay" + } + } + } + } +}; + +export const OperationListResult: msRest.CompositeMapper = { + serializedName: "OperationListResult", + type: { + name: "Composite", + className: "OperationListResult", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Operation" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const LocationListResult: msRest.CompositeMapper = { + serializedName: "LocationListResult", + type: { + name: "Composite", + className: "LocationListResult", + modelProperties: { + value: { + serializedName: "", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Location" + } + } + } + } + } + } +}; + +export const SubscriptionListResult: msRest.CompositeMapper = { + serializedName: "SubscriptionListResult", + type: { + name: "Composite", + className: "SubscriptionListResult", + modelProperties: { + value: { + serializedName: "", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Subscription" + } + } + } + }, + nextLink: { + required: true, + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const TenantListResult: msRest.CompositeMapper = { + serializedName: "TenantListResult", + type: { + name: "Composite", + className: "TenantListResult", + modelProperties: { + value: { + serializedName: "", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "TenantIdDescription" + } + } + } + }, + nextLink: { + required: true, + 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..631abcbf7806 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/parameters.ts @@ -0,0 +1,64 @@ +/* + * 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 msRest from "@azure/ms-rest-js"; + +export const acceptLanguage: msRest.OperationParameter = { + parameterPath: "acceptLanguage", + mapper: { + serializedName: "accept-language", + defaultValue: 'en-US', + type: { + name: "String" + } + } +}; +export const apiVersion: msRest.OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + required: true, + serializedName: "api-version", + type: { + name: "String" + } + } +}; +export const includeExtendedLocations: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "includeExtendedLocations" + ], + mapper: { + serializedName: "includeExtendedLocations", + type: { + name: "Boolean" + } + } +}; +export const nextPageLink: msRest.OperationURLParameter = { + parameterPath: "nextPageLink", + mapper: { + required: true, + serializedName: "nextLink", + type: { + name: "String" + } + }, + skipEncoding: true +}; +export const subscriptionId: msRest.OperationURLParameter = { + parameterPath: "subscriptionId", + mapper: { + required: true, + serializedName: "subscriptionId", + type: { + name: "String" + } + } +}; diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/subscriptionsMappers.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/subscriptionsMappers.ts new file mode 100644 index 000000000000..b53e14ee5fca --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/subscriptionsMappers.ts @@ -0,0 +1,21 @@ +/* + * 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 { + CloudError, + ErrorAdditionalInfo, + ErrorResponse, + Location, + LocationListResult, + LocationMetadata, + ManagedByTenant, + PairedRegion, + Subscription, + SubscriptionListResult, + SubscriptionPolicies +} from "../models/mappers"; diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/tenantsMappers.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/tenantsMappers.ts new file mode 100644 index 000000000000..0a4b51d4ef72 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/models/tenantsMappers.ts @@ -0,0 +1,15 @@ +/* + * 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 { + CloudError, + ErrorAdditionalInfo, + ErrorResponse, + TenantIdDescription, + TenantListResult +} from "../models/mappers"; 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..e0c4dea8c122 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +export * from "./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..2ee97c85518d --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/subscriptions.ts @@ -0,0 +1,230 @@ +/* + * 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 msRest from "@azure/ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/subscriptionsMappers"; +import * as Parameters from "../models/parameters"; +import { SubscriptionClientContext } from "../subscriptionClientContext"; + +/** Class representing a Subscriptions. */ +export class Subscriptions { + private readonly client: SubscriptionClientContext; + + /** + * Create a Subscriptions. + * @param {SubscriptionClientContext} 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. + * @summary Gets all available geo-locations. + * @param subscriptionId The ID of the target subscription. + * @param [options] The optional parameters + * @returns Promise + */ + listLocations(subscriptionId: string, options?: Models.SubscriptionsListLocationsOptionalParams): Promise; + /** + * @param subscriptionId The ID of the target subscription. + * @param callback The callback + */ + listLocations(subscriptionId: string, callback: msRest.ServiceCallback): void; + /** + * @param subscriptionId The ID of the target subscription. + * @param options The optional parameters + * @param callback The callback + */ + listLocations(subscriptionId: string, options: Models.SubscriptionsListLocationsOptionalParams, callback: msRest.ServiceCallback): void; + listLocations(subscriptionId: string, options?: Models.SubscriptionsListLocationsOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + subscriptionId, + options + }, + listLocationsOperationSpec, + callback) as Promise; + } + + /** + * Gets details about a specified subscription. + * @param subscriptionId The ID of the target subscription. + * @param [options] The optional parameters + * @returns Promise + */ + get(subscriptionId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param subscriptionId The ID of the target subscription. + * @param callback The callback + */ + get(subscriptionId: string, callback: msRest.ServiceCallback): void; + /** + * @param subscriptionId The ID of the target subscription. + * @param options The optional parameters + * @param callback The callback + */ + get(subscriptionId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + get(subscriptionId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + subscriptionId, + options + }, + getOperationSpec, + callback) as Promise; + } + + /** + * Gets all subscriptions for a tenant. + * @param [options] The optional parameters + * @returns Promise + */ + list(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + list(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + list(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + list(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + listOperationSpec, + callback) as Promise; + } + + /** + * Gets all subscriptions for a tenant. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listNextOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const listLocationsOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/locations", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion, + Parameters.includeExtendedLocations + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.LocationListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const getOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.Subscription + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const listOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions", + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.SubscriptionListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const listNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.SubscriptionListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + 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..231f15893210 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/operations/tenants.ts @@ -0,0 +1,125 @@ +/* + * 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 msRest from "@azure/ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/tenantsMappers"; +import * as Parameters from "../models/parameters"; +import { SubscriptionClientContext } from "../subscriptionClientContext"; + +/** Class representing a Tenants. */ +export class Tenants { + private readonly client: SubscriptionClientContext; + + /** + * Create a Tenants. + * @param {SubscriptionClientContext} client Reference to the service client. + */ + constructor(client: SubscriptionClientContext) { + this.client = client; + } + + /** + * Gets the tenants for your account. + * @param [options] The optional parameters + * @returns Promise + */ + list(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + list(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + list(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + list(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + listOperationSpec, + callback) as Promise; + } + + /** + * Gets the tenants for your account. + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + nextPageLink, + options + }, + listNextOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const listOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "tenants", + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.TenantListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const listNextOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + baseUrl: "https://management.azure.com", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.TenantListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; 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..ebc05881cb2b --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClient.ts @@ -0,0 +1,102 @@ +/* + * 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 msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; +import * as Models from "./models"; +import * as Mappers from "./models/mappers"; +import * as Parameters from "./models/parameters"; +import * as operations from "./operations"; +import { SubscriptionClientContext } from "./subscriptionClientContext"; + + +class SubscriptionClient extends SubscriptionClientContext { + // Operation groups + subscriptions: operations.Subscriptions; + tenants: operations.Tenants; + + /** + * Initializes a new instance of the SubscriptionClient class. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, options?: Models.SubscriptionClientOptions) { + super(credentials, options); + this.subscriptions = new operations.Subscriptions(this); + this.tenants = new operations.Tenants(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 + * @summary Checks resource name validity + * @param [options] The optional parameters + * @returns Promise + */ + checkResourceName(options?: Models.SubscriptionClientCheckResourceNameOptionalParams): Promise; + /** + * @param callback The callback + */ + checkResourceName(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + checkResourceName(options: Models.SubscriptionClientCheckResourceNameOptionalParams, callback: msRest.ServiceCallback): void; + checkResourceName(options?: Models.SubscriptionClientCheckResourceNameOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + options + }, + checkResourceNameOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const checkResourceNameOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "providers/Microsoft.Resources/checkResourceName", + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + requestBody: { + parameterPath: [ + "options", + "resourceNameDefinition" + ], + mapper: Mappers.ResourceName + }, + responses: { + 200: { + bodyMapper: Mappers.CheckResourceNameResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +export { + SubscriptionClient, + SubscriptionClientContext, + Models as SubscriptionModels, + Mappers as SubscriptionMappers +}; +export * from "./operations"; 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..5d97a73e1017 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClientContext.ts @@ -0,0 +1,61 @@ +/* + * 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 Models from "./models"; +import * as msRest from "@azure/ms-rest-js"; +import * as msRestAzure from "@azure/ms-rest-azure-js"; +import { TokenCredential } from "@azure/core-auth"; + +const packageName = "@azure/arm-resources-subscriptions"; +const packageVersion = "1.0.0"; + +export class SubscriptionClientContext extends msRestAzure.AzureServiceClient { + credentials: msRest.ServiceClientCredentials | TokenCredential; + apiVersion?: string; + + /** + * Initializes a new instance of the SubscriptionClient class. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, options?: Models.SubscriptionClientOptions) { + if (credentials == undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + + if (!options) { + options = {}; + } + if (!options.userAgent) { + const defaultUserAgent = msRestAzure.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(credentials, options); + + this.apiVersion = '2021-01-01'; + this.acceptLanguage = 'en-US'; + this.longRunningOperationRetryTimeout = 30; + this.baseUri = options.baseUri || this.baseUri || "https://management.azure.com"; + this.requestContentType = "application/json; charset=utf-8"; + this.credentials = credentials; + + if (options.acceptLanguage !== null && options.acceptLanguage !== undefined) { + this.acceptLanguage = options.acceptLanguage; + } + if (options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { + this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; + } + } +} 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..422b584abd5e --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "es6", + "moduleResolution": "node", + "strict": true, + "target": "es5", + "sourceMap": true, + "declarationMap": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "lib": ["es6", "dom"], + "declaration": true, + "outDir": "./esm", + "importHelpers": true + }, + "include": ["./src/**/*.ts"], + "exclude": ["node_modules"] +}