From 1ad02bb31d43af30413dde161d2c70d833db1a47 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 1 May 2019 02:34:21 +0000 Subject: [PATCH 1/3] Generated from 3ea346203a975bd90cc76d3a94f454a3ba693936 Update readme.md Changes in readme file --- .../arm-subscriptions/LICENSE.txt | 21 + sdk/subscription/arm-subscriptions/README.md | 96 +++ .../arm-subscriptions/lib/models/index.ts | 623 ++++++++++++++++++ .../arm-subscriptions/lib/models/mappers.ts | 546 +++++++++++++++ .../lib/models/operationsMappers.ts | 17 + .../lib/models/parameters.ts | 97 +++ .../lib/models/subscriptionFactoryMappers.ts | 18 + .../subscriptionOperationOperationsMappers.ts | 16 + .../lib/models/subscriptionsMappers.ts | 19 + .../lib/models/tenantsMappers.ts | 16 + .../arm-subscriptions/lib/operations/index.ts | 15 + .../lib/operations/operations.ts | 74 +++ .../lib/operations/subscriptionFactory.ts | 99 +++ .../subscriptionOperationOperations.ts | 88 +++ .../lib/operations/subscriptions.ts | 227 +++++++ .../lib/operations/tenants.ts | 123 ++++ .../lib/subscriptionClient.ts | 49 ++ .../lib/subscriptionClientContext.ts | 54 ++ .../arm-subscriptions/package.json | 56 ++ .../arm-subscriptions/rollup.config.js | 37 ++ .../arm-subscriptions/tsconfig.json | 19 + 21 files changed, 2310 insertions(+) create mode 100644 sdk/subscription/arm-subscriptions/LICENSE.txt create mode 100644 sdk/subscription/arm-subscriptions/README.md create mode 100644 sdk/subscription/arm-subscriptions/lib/models/index.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/models/mappers.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/models/operationsMappers.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/models/parameters.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/models/subscriptionFactoryMappers.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/models/subscriptionOperationOperationsMappers.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/models/subscriptionsMappers.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/models/tenantsMappers.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/operations/index.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/operations/operations.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/operations/subscriptionFactory.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/operations/subscriptionOperationOperations.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/operations/subscriptions.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/operations/tenants.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts create mode 100644 sdk/subscription/arm-subscriptions/lib/subscriptionClientContext.ts create mode 100644 sdk/subscription/arm-subscriptions/package.json create mode 100644 sdk/subscription/arm-subscriptions/rollup.config.js create mode 100644 sdk/subscription/arm-subscriptions/tsconfig.json diff --git a/sdk/subscription/arm-subscriptions/LICENSE.txt b/sdk/subscription/arm-subscriptions/LICENSE.txt new file mode 100644 index 000000000000..8f3d856145c5 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019 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/subscription/arm-subscriptions/README.md b/sdk/subscription/arm-subscriptions/README.md new file mode 100644 index 000000000000..a351fd9169fe --- /dev/null +++ b/sdk/subscription/arm-subscriptions/README.md @@ -0,0 +1,96 @@ +## Azure SubscriptionClient SDK for JavaScript + +This package contains an isomorphic SDK for SubscriptionClient. + +### Currently supported environments + +- Node.js version 6.x.x or higher +- Browser JavaScript + +### How to Install + +```bash +npm install @azure/arm-subscriptions +``` + +### How to use + +#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. + +##### Install @azure/ms-rest-nodeauth + +```bash +npm install @azure/ms-rest-nodeauth +``` + +##### Sample code + +```typescript +import * as msRest from "@azure/ms-rest-js"; +import * as msRestAzure from "@azure/ms-rest-azure-js"; +import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; +import { SubscriptionClient, SubscriptionModels, SubscriptionMappers } from "@azure/arm-subscriptions"; +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +msRestNodeAuth.interactiveLogin().then((creds) => { + const client = new SubscriptionClient(creds, subscriptionId); + client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.error(err); +}); +``` + +#### browser - Authentication, client creation and list operations as an example written in JavaScript. + +##### Install @azure/ms-rest-browserauth + +```bash +npm install @azure/ms-rest-browserauth +``` + +##### Sample code + +See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. + +- index.html +```html + + + + @azure/arm-subscriptions sample + + + + + + + + +``` + +## Related projects + +- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) diff --git a/sdk/subscription/arm-subscriptions/lib/models/index.ts b/sdk/subscription/arm-subscriptions/lib/models/index.ts new file mode 100644 index 000000000000..7e223e9ea16d --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/models/index.ts @@ -0,0 +1,623 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * 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 }; + + +/** + * @interface + * An interface representing SubscriptionCreationResult. + * The created subscription object. + * + */ +export interface SubscriptionCreationResult { + /** + * @member {string} [subscriptionLink] The link to the new subscription. + */ + subscriptionLink?: string; +} + +/** + * @interface + * An interface representing AdPrincipal. + * Active Directory Principal for subscription creation delegated permission + * + */ +export interface AdPrincipal { + /** + * @member {string} objectId Object id of the Principal + */ + objectId: string; +} + +/** + * @interface + * An interface representing SubscriptionCreationParameters. + * Subscription Creation Parameters required to create a new Azure + * subscription. + * + */ +export interface SubscriptionCreationParameters { + /** + * @member {string} [displayName] The display name of the subscription. + */ + displayName?: string; + /** + * @member {string} [billingProfileId] The ARM id of the billing profile. + */ + billingProfileId?: string; + /** + * @member {string} [skuId] The commerce id of the sku. + */ + skuId?: string; + /** + * @member {string} [costCenter] optional customer cost center + */ + costCenter?: string; + /** + * @member {AdPrincipal} [owner] rbac owner of the subscription + */ + owner?: AdPrincipal; + /** + * @member {{ [propertyName: string]: any }} [additionalParameters] + * Additional, untyped parameters to support custom subscription creation + * scenarios. + */ + additionalParameters?: { [propertyName: string]: any }; +} + +/** + * @interface + * An interface representing ErrorResponse. + * Describes the format of Error response. + * + */ +export interface ErrorResponse { + /** + * @member {string} [code] Error code + */ + code?: string; + /** + * @member {string} [message] Error message indicating why the operation + * failed. + */ + message?: string; +} + +/** + * @interface + * An interface representing SubscriptionOperation. + * status of the subscription POST operation. + * + */ +export interface SubscriptionOperation { + /** + * @member {string} [id] The operation Id. + * **NOTE: This property will not be serialized. It can only be populated by + * the server.** + */ + readonly id?: string; + /** + * @member {string} [status] Status of the pending subscription + */ + status?: string; + /** + * @member {string} [statusDetail] Status Detail of the pending subscription + */ + statusDetail?: string; +} + +/** + * @interface + * An interface representing SubscriptionOperationListResult. + * A list of pending subscription operations. + * + */ +export interface SubscriptionOperationListResult { + /** + * @member {SubscriptionOperation[]} [value] A list of pending + * SubscriptionOperations + */ + value?: SubscriptionOperation[]; +} + +/** + * @interface + * An interface representing OperationDisplay. + * The object that represents the operation. + * + */ +export interface OperationDisplay { + /** + * @member {string} [provider] Service provider: Microsoft.Subscription + */ + provider?: string; + /** + * @member {string} [resource] Resource on which the operation is performed: + * Profile, endpoint, etc. + */ + resource?: string; + /** + * @member {string} [operation] Operation type: Read, write, delete, etc. + */ + operation?: string; +} + +/** + * @interface + * An interface representing Operation. + * REST API operation + * + */ +export interface Operation { + /** + * @member {string} [name] Operation name: {provider}/{resource}/{operation} + */ + name?: string; + /** + * @member {OperationDisplay} [display] The object that represents the + * operation. + */ + display?: OperationDisplay; +} + +/** + * @interface + * An interface representing OperationListResult. + * Result of the request to list operations. It contains a list of operations + * and a URL link to get the next set of results. + * + */ +export interface OperationListResult { + /** + * @member {Operation[]} [value] List of operations. + */ + value?: Operation[]; + /** + * @member {string} [nextLink] URL to get the next set of operation list + * results if there are any. + */ + nextLink?: string; +} + +/** + * @interface + * An interface representing Location. + * Location information. + * + */ +export interface Location { + /** + * @member {string} [id] 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; + /** + * @member {string} [subscriptionId] The subscription ID. + * **NOTE: This property will not be serialized. It can only be populated by + * the server.** + */ + readonly subscriptionId?: string; + /** + * @member {string} [name] The location name. + * **NOTE: This property will not be serialized. It can only be populated by + * the server.** + */ + readonly name?: string; + /** + * @member {string} [displayName] The display name of the location. + * **NOTE: This property will not be serialized. It can only be populated by + * the server.** + */ + readonly displayName?: string; + /** + * @member {string} [latitude] The latitude of the location. + * **NOTE: This property will not be serialized. It can only be populated by + * the server.** + */ + readonly latitude?: string; + /** + * @member {string} [longitude] The longitude of the location. + * **NOTE: This property will not be serialized. It can only be populated by + * the server.** + */ + readonly longitude?: string; +} + +/** + * @interface + * An interface representing SubscriptionPolicies. + * Subscription policies. + * + */ +export interface SubscriptionPolicies { + /** + * @member {string} [locationPlacementId] 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; + /** + * @member {string} [quotaId] The subscription quota ID. + * **NOTE: This property will not be serialized. It can only be populated by + * the server.** + */ + readonly quotaId?: string; + /** + * @member {SpendingLimit} [spendingLimit] 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; +} + +/** + * @interface + * An interface representing Subscription. + * Subscription information. + * + */ +export interface Subscription { + /** + * @member {string} [id] 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; + /** + * @member {string} [subscriptionId] The subscription ID. + * **NOTE: This property will not be serialized. It can only be populated by + * the server.** + */ + readonly subscriptionId?: string; + /** + * @member {string} [displayName] The subscription display name. + * **NOTE: This property will not be serialized. It can only be populated by + * the server.** + */ + readonly displayName?: string; + /** + * @member {SubscriptionState} [state] 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; + /** + * @member {SubscriptionPolicies} [subscriptionPolicies] The subscription + * policies. + */ + subscriptionPolicies?: SubscriptionPolicies; + /** + * @member {string} [authorizationSource] 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; +} + +/** + * @interface + * An interface representing TenantIdDescription. + * Tenant Id information. + * + */ +export interface TenantIdDescription { + /** + * @member {string} [id] 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; + /** + * @member {string} [tenantId] 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; +} + +/** + * @interface + * An interface representing SubscriptionClientOptions. + * @extends AzureServiceClientOptions + */ +export interface SubscriptionClientOptions extends AzureServiceClientOptions { + /** + * @member {string} [baseUri] + */ + baseUri?: string; +} + +/** + * @interface + * An interface representing SubscriptionOperationGetHeaders. + * Defines headers for Get operation. + * + */ +export interface SubscriptionOperationGetHeaders { + /** + * @member {string} [location] The URL where the status of the asynchronous + * operation can be checked. + */ + location: string; + /** + * @member {number} [retryAfter] The amount of delay to use while the status + * of the operation is checked. The value is expressed in seconds. + */ + retryAfter: number; +} + +/** + * @interface + * An interface representing SubscriptionFactoryCreateSubscriptionHeaders. + * Defines headers for CreateSubscription operation. + * + */ +export interface SubscriptionFactoryCreateSubscriptionHeaders { + /** + * @member {string} [location] GET this URL to retrieve the status of the + * asynchronous operation. + */ + location: string; + /** + * @member {number} [retryAfter] The amount of delay to use while the status + * of the operation is checked. The value is expressed in seconds. + */ + retryAfter: number; +} + + +/** + * @interface + * An interface representing the LocationListResult. + * Location list operation response. + * + * @extends Array + */ +export interface LocationListResult extends Array { +} + +/** + * @interface + * An interface representing the SubscriptionListResult. + * Subscription list operation response. + * + * @extends Array + */ +export interface SubscriptionListResult extends Array { + /** + * @member {string} nextLink The URL to get the next set of results. + */ + nextLink: string; +} + +/** + * @interface + * An interface representing the TenantListResult. + * Tenant Ids information. + * + * @extends Array + */ +export interface TenantListResult extends Array { + /** + * @member {string} nextLink The URL to use for getting the next set of + * results. + */ + nextLink: string; +} + +/** + * 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'; + +/** + * Contains response data for the list operation. + */ +export type OperationsListResponse = OperationListResult & { + /** + * 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: OperationListResult; + }; +}; + +/** + * Contains response data for the get operation. + */ +export type SubscriptionOperationGetResponse = SubscriptionCreationResult & SubscriptionOperationGetHeaders & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: SubscriptionOperationGetHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: SubscriptionCreationResult; + }; +}; + +/** + * Contains response data for the createSubscription operation. + */ +export type SubscriptionFactoryCreateSubscriptionResponse = SubscriptionCreationResult & SubscriptionFactoryCreateSubscriptionHeaders & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The parsed HTTP response headers. + */ + parsedHeaders: SubscriptionFactoryCreateSubscriptionHeaders; + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: SubscriptionCreationResult; + }; +}; + +/** + * 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; + }; +}; diff --git a/sdk/subscription/arm-subscriptions/lib/models/mappers.ts b/sdk/subscription/arm-subscriptions/lib/models/mappers.ts new file mode 100644 index 000000000000..78b826f0f5ea --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/models/mappers.ts @@ -0,0 +1,546 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * 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 SubscriptionCreationResult: msRest.CompositeMapper = { + serializedName: "SubscriptionCreationResult", + type: { + name: "Composite", + className: "SubscriptionCreationResult", + modelProperties: { + subscriptionLink: { + serializedName: "subscriptionLink", + type: { + name: "String" + } + } + } + } +}; + +export const AdPrincipal: msRest.CompositeMapper = { + serializedName: "AdPrincipal", + type: { + name: "Composite", + className: "AdPrincipal", + modelProperties: { + objectId: { + required: true, + serializedName: "objectId", + type: { + name: "String" + } + } + } + } +}; + +export const SubscriptionCreationParameters: msRest.CompositeMapper = { + serializedName: "SubscriptionCreationParameters", + type: { + name: "Composite", + className: "SubscriptionCreationParameters", + modelProperties: { + displayName: { + serializedName: "displayName", + type: { + name: "String" + } + }, + billingProfileId: { + serializedName: "billingProfileId", + type: { + name: "String" + } + }, + skuId: { + serializedName: "skuId", + type: { + name: "String" + } + }, + costCenter: { + serializedName: "costCenter", + type: { + name: "String" + } + }, + owner: { + serializedName: "owner", + type: { + name: "Composite", + className: "AdPrincipal" + } + }, + additionalParameters: { + serializedName: "additionalParameters", + type: { + name: "Dictionary", + value: { + type: { + name: "Object" + } + } + } + } + } + } +}; + +export const ErrorResponse: msRest.CompositeMapper = { + serializedName: "ErrorResponse", + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + code: { + serializedName: "code", + type: { + name: "String" + } + }, + message: { + serializedName: "message", + type: { + name: "String" + } + } + } + } +}; + +export const SubscriptionOperation: msRest.CompositeMapper = { + serializedName: "SubscriptionOperation", + type: { + name: "Composite", + className: "SubscriptionOperation", + modelProperties: { + id: { + readOnly: true, + serializedName: "id", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + statusDetail: { + serializedName: "statusDetail", + type: { + name: "String" + } + } + } + } +}; + +export const SubscriptionOperationListResult: msRest.CompositeMapper = { + serializedName: "SubscriptionOperationListResult", + type: { + name: "Composite", + className: "SubscriptionOperationListResult", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "SubscriptionOperation" + } + } + } + } + } + } +}; + +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" + } + } + } + } +}; + +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 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" + } + }, + displayName: { + readOnly: true, + serializedName: "displayName", + type: { + name: "String" + } + }, + latitude: { + readOnly: true, + serializedName: "latitude", + type: { + name: "String" + } + }, + longitude: { + readOnly: true, + serializedName: "longitude", + type: { + name: "String" + } + } + } + } +}; + +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 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" + } + }, + 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" + } + } + } + } +}; + +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" + } + } + } + } +}; + +export const SubscriptionOperationGetHeaders: msRest.CompositeMapper = { + serializedName: "subscriptionoperation-get-headers", + type: { + name: "Composite", + className: "SubscriptionOperationGetHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String" + } + }, + retryAfter: { + serializedName: "retry-after", + type: { + name: "Number" + } + } + } + } +}; + +export const SubscriptionFactoryCreateSubscriptionHeaders: msRest.CompositeMapper = { + serializedName: "subscriptionfactory-createsubscription-headers", + type: { + name: "Composite", + className: "SubscriptionFactoryCreateSubscriptionHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String" + } + }, + retryAfter: { + serializedName: "retry-after", + type: { + name: "Number" + } + } + } + } +}; + +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/subscription/arm-subscriptions/lib/models/operationsMappers.ts b/sdk/subscription/arm-subscriptions/lib/models/operationsMappers.ts new file mode 100644 index 000000000000..715467ec9522 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/models/operationsMappers.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +export { + OperationListResult, + Operation, + OperationDisplay, + ErrorResponse +} from "../models/mappers"; + diff --git a/sdk/subscription/arm-subscriptions/lib/models/parameters.ts b/sdk/subscription/arm-subscriptions/lib/models/parameters.ts new file mode 100644 index 000000000000..7073528267dc --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/models/parameters.ts @@ -0,0 +1,97 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * 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 apiVersion0: msRest.OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + required: true, + isConstant: true, + serializedName: "api-version", + defaultValue: '2018-11-01-preview', + type: { + name: "String" + } + } +}; +export const apiVersion1: msRest.OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + required: true, + isConstant: true, + serializedName: "api-version", + defaultValue: '2016-06-01', + type: { + name: "String" + } + } +}; +export const billingAccountName: msRest.OperationURLParameter = { + parameterPath: "billingAccountName", + mapper: { + required: true, + serializedName: "billingAccountName", + type: { + name: "String" + } + } +}; +export const invoiceSectionName: msRest.OperationURLParameter = { + parameterPath: "invoiceSectionName", + mapper: { + required: true, + serializedName: "invoiceSectionName", + type: { + name: "String" + } + } +}; +export const nextPageLink: msRest.OperationURLParameter = { + parameterPath: "nextPageLink", + mapper: { + required: true, + serializedName: "nextLink", + type: { + name: "String" + } + }, + skipEncoding: true +}; +export const operationId: msRest.OperationURLParameter = { + parameterPath: "operationId", + mapper: { + required: true, + serializedName: "operationId", + type: { + name: "String" + } + } +}; +export const subscriptionId: msRest.OperationURLParameter = { + parameterPath: "subscriptionId", + mapper: { + required: true, + serializedName: "subscriptionId", + type: { + name: "String" + } + } +}; diff --git a/sdk/subscription/arm-subscriptions/lib/models/subscriptionFactoryMappers.ts b/sdk/subscription/arm-subscriptions/lib/models/subscriptionFactoryMappers.ts new file mode 100644 index 000000000000..fe92eb1483fb --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/models/subscriptionFactoryMappers.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +export { + SubscriptionCreationParameters, + AdPrincipal, + SubscriptionCreationResult, + SubscriptionFactoryCreateSubscriptionHeaders, + ErrorResponse +} from "../models/mappers"; + diff --git a/sdk/subscription/arm-subscriptions/lib/models/subscriptionOperationOperationsMappers.ts b/sdk/subscription/arm-subscriptions/lib/models/subscriptionOperationOperationsMappers.ts new file mode 100644 index 000000000000..c5247037b3ea --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/models/subscriptionOperationOperationsMappers.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +export { + SubscriptionCreationResult, + SubscriptionOperationGetHeaders, + CloudError +} from "../models/mappers"; + diff --git a/sdk/subscription/arm-subscriptions/lib/models/subscriptionsMappers.ts b/sdk/subscription/arm-subscriptions/lib/models/subscriptionsMappers.ts new file mode 100644 index 000000000000..8630883ef598 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/models/subscriptionsMappers.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +export { + LocationListResult, + Location, + CloudError, + Subscription, + SubscriptionPolicies, + SubscriptionListResult +} from "../models/mappers"; + diff --git a/sdk/subscription/arm-subscriptions/lib/models/tenantsMappers.ts b/sdk/subscription/arm-subscriptions/lib/models/tenantsMappers.ts new file mode 100644 index 000000000000..cc13f90c8b50 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/models/tenantsMappers.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +export { + TenantListResult, + TenantIdDescription, + CloudError +} from "../models/mappers"; + diff --git a/sdk/subscription/arm-subscriptions/lib/operations/index.ts b/sdk/subscription/arm-subscriptions/lib/operations/index.ts new file mode 100644 index 000000000000..613df35a62ca --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/operations/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +export * from "./operations"; +export * from "./subscriptionOperationOperations"; +export * from "./subscriptionFactory"; +export * from "./subscriptions"; +export * from "./tenants"; diff --git a/sdk/subscription/arm-subscriptions/lib/operations/operations.ts b/sdk/subscription/arm-subscriptions/lib/operations/operations.ts new file mode 100644 index 000000000000..923fecd89ed7 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/operations/operations.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * 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/operationsMappers"; +import * as Parameters from "../models/parameters"; +import { SubscriptionClientContext } from "../subscriptionClientContext"; + +/** Class representing a Operations. */ +export class Operations { + private readonly client: SubscriptionClientContext; + + /** + * Create a Operations. + * @param {SubscriptionClientContext} client Reference to the service client. + */ + constructor(client: SubscriptionClientContext) { + this.client = client; + } + + /** + * Lists all of the available Microsoft.Subscription API operations. + * @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; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const listOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "providers/Microsoft.Subscription/operations", + queryParameters: [ + Parameters.apiVersion0 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/subscription/arm-subscriptions/lib/operations/subscriptionFactory.ts b/sdk/subscription/arm-subscriptions/lib/operations/subscriptionFactory.ts new file mode 100644 index 000000000000..e2855b6049b6 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/operations/subscriptionFactory.ts @@ -0,0 +1,99 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * 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 msRestAzure from "@azure/ms-rest-azure-js"; +import * as Models from "../models"; +import * as Mappers from "../models/subscriptionFactoryMappers"; +import * as Parameters from "../models/parameters"; +import { SubscriptionClientContext } from "../subscriptionClientContext"; + +/** Class representing a SubscriptionFactory. */ +export class SubscriptionFactory { + private readonly client: SubscriptionClientContext; + + /** + * Create a SubscriptionFactory. + * @param {SubscriptionClientContext} client Reference to the service client. + */ + constructor(client: SubscriptionClientContext) { + this.client = client; + } + + /** + * Creates an Azure subscription + * @param billingAccountName The name of the commerce root billing account. + * @param invoiceSectionName The name of the invoice section. + * @param body The subscription creation parameters. + * @param [options] The optional parameters + * @returns Promise + */ + createSubscription(billingAccountName: string, invoiceSectionName: string, body: Models.SubscriptionCreationParameters, options?: msRest.RequestOptionsBase): Promise { + return this.beginCreateSubscription(billingAccountName,invoiceSectionName,body,options) + .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; + } + + /** + * Creates an Azure subscription + * @param billingAccountName The name of the commerce root billing account. + * @param invoiceSectionName The name of the invoice section. + * @param body The subscription creation parameters. + * @param [options] The optional parameters + * @returns Promise + */ + beginCreateSubscription(billingAccountName: string, invoiceSectionName: string, body: Models.SubscriptionCreationParameters, options?: msRest.RequestOptionsBase): Promise { + return this.client.sendLRORequest( + { + billingAccountName, + invoiceSectionName, + body, + options + }, + beginCreateSubscriptionOperationSpec, + options); + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const beginCreateSubscriptionOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Subscription/createSubscription", + urlParameters: [ + Parameters.billingAccountName, + Parameters.invoiceSectionName + ], + queryParameters: [ + Parameters.apiVersion0 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + requestBody: { + parameterPath: "body", + mapper: { + ...Mappers.SubscriptionCreationParameters, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.SubscriptionCreationResult, + headersMapper: Mappers.SubscriptionFactoryCreateSubscriptionHeaders + }, + 202: { + headersMapper: Mappers.SubscriptionFactoryCreateSubscriptionHeaders + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/subscription/arm-subscriptions/lib/operations/subscriptionOperationOperations.ts b/sdk/subscription/arm-subscriptions/lib/operations/subscriptionOperationOperations.ts new file mode 100644 index 000000000000..912b225c3289 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/operations/subscriptionOperationOperations.ts @@ -0,0 +1,88 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * 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/subscriptionOperationOperationsMappers"; +import * as Parameters from "../models/parameters"; +import { SubscriptionClientContext } from "../subscriptionClientContext"; + +/** Class representing a SubscriptionOperationOperations. */ +export class SubscriptionOperationOperations { + private readonly client: SubscriptionClientContext; + + /** + * Create a SubscriptionOperationOperations. + * @param {SubscriptionClientContext} client Reference to the service client. + */ + constructor(client: SubscriptionClientContext) { + this.client = client; + } + + /** + * Get the status of the pending Microsoft.Subscription API operations. + * @param operationId The operation ID, which can be found from the Location field in the generate + * recommendation response header. + * @param [options] The optional parameters + * @returns Promise + */ + get(operationId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param operationId The operation ID, which can be found from the Location field in the generate + * recommendation response header. + * @param callback The callback + */ + get(operationId: string, callback: msRest.ServiceCallback): void; + /** + * @param operationId The operation ID, which can be found from the Location field in the generate + * recommendation response header. + * @param options The optional parameters + * @param callback The callback + */ + get(operationId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + get(operationId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + operationId, + options + }, + getOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "providers/Microsoft.Subscription/subscriptionOperations/{operationId}", + urlParameters: [ + Parameters.operationId + ], + queryParameters: [ + Parameters.apiVersion0 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.SubscriptionCreationResult, + headersMapper: Mappers.SubscriptionOperationGetHeaders + }, + 202: { + headersMapper: Mappers.SubscriptionOperationGetHeaders + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; diff --git a/sdk/subscription/arm-subscriptions/lib/operations/subscriptions.ts b/sdk/subscription/arm-subscriptions/lib/operations/subscriptions.ts new file mode 100644 index 000000000000..3e978cba8f83 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/operations/subscriptions.ts @@ -0,0 +1,227 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * 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?: msRest.RequestOptionsBase): 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: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + listLocations(subscriptionId: string, options?: msRest.RequestOptionsBase | 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.apiVersion1 + ], + 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.apiVersion1 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.Subscription + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const listOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions", + queryParameters: [ + Parameters.apiVersion1 + ], + 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 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.SubscriptionListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; diff --git a/sdk/subscription/arm-subscriptions/lib/operations/tenants.ts b/sdk/subscription/arm-subscriptions/lib/operations/tenants.ts new file mode 100644 index 000000000000..cd4102be9ebf --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/operations/tenants.ts @@ -0,0 +1,123 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * 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.apiVersion1 + ], + 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 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.TenantListResult + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; diff --git a/sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts b/sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts new file mode 100644 index 000000000000..bace1a9fc285 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * 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/mappers"; +import * as operations from "./operations"; +import { SubscriptionClientContext } from "./subscriptionClientContext"; + + +class SubscriptionClient extends SubscriptionClientContext { + // Operation groups + operations: operations.Operations; + subscriptionOperation: operations.SubscriptionOperationOperations; + subscriptionFactory: operations.SubscriptionFactory; + 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. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials, options?: Models.SubscriptionClientOptions) { + super(credentials, options); + this.operations = new operations.Operations(this); + this.subscriptionOperation = new operations.SubscriptionOperationOperations(this); + this.subscriptionFactory = new operations.SubscriptionFactory(this); + this.subscriptions = new operations.Subscriptions(this); + this.tenants = new operations.Tenants(this); + } +} + +// Operation Specifications + +export { + SubscriptionClient, + SubscriptionClientContext, + Models as SubscriptionModels, + Mappers as SubscriptionMappers +}; +export * from "./operations"; diff --git a/sdk/subscription/arm-subscriptions/lib/subscriptionClientContext.ts b/sdk/subscription/arm-subscriptions/lib/subscriptionClientContext.ts new file mode 100644 index 000000000000..f1f805ba1d10 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/subscriptionClientContext.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * 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"; + +const packageName = "@azure/arm-subscriptions"; +const packageVersion = "1.0.0"; + +export class SubscriptionClientContext extends msRestAzure.AzureServiceClient { + credentials: msRest.ServiceClientCredentials; + + /** + * Initializes a new instance of the SubscriptionClient class. + * @param credentials Credentials needed for the client to connect to Azure. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials, 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.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/subscription/arm-subscriptions/package.json b/sdk/subscription/arm-subscriptions/package.json new file mode 100644 index 000000000000..a24605c49e4d --- /dev/null +++ b/sdk/subscription/arm-subscriptions/package.json @@ -0,0 +1,56 @@ +{ + "name": "@azure/arm-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": "^1.2.0", + "@azure/ms-rest-js": "^1.2.0", + "tslib": "^1.9.3" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/arm-subscriptions.js", + "module": "./esm/subscriptionClient.js", + "types": "./esm/subscriptionClient.d.ts", + "devDependencies": { + "typescript": "^3.1.1", + "rollup": "^0.66.2", + "rollup-plugin-node-resolve": "^3.4.0", + "rollup-plugin-sourcemaps": "^0.4.2", + "uglify-js": "^3.4.9" + }, + "homepage": "https://github.com/azure/azure-sdk-for-js", + "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", + "lib/**/*.ts", + "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-subscriptions.js.map'\" -o ./dist/arm-subscriptions.min.js ./dist/arm-subscriptions.js", + "prepack": "npm install && npm run build" + }, + "sideEffects": false +} diff --git a/sdk/subscription/arm-subscriptions/rollup.config.js b/sdk/subscription/arm-subscriptions/rollup.config.js new file mode 100644 index 000000000000..f4ae2d19454d --- /dev/null +++ b/sdk/subscription/arm-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-subscriptions.js", + format: "umd", + name: "Azure.ArmSubscriptions", + sourcemap: true, + globals: { + "@azure/ms-rest-js": "msRest", + "@azure/ms-rest-azure-js": "msRestAzure" + }, + banner: `/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */` + }, + plugins: [ + nodeResolve({ module: true }), + sourcemaps() + ] +}; + +export default config; diff --git a/sdk/subscription/arm-subscriptions/tsconfig.json b/sdk/subscription/arm-subscriptions/tsconfig.json new file mode 100644 index 000000000000..51ea90961ce5 --- /dev/null +++ b/sdk/subscription/arm-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"], + "declaration": true, + "outDir": "./esm", + "importHelpers": true + }, + "include": ["./lib/**/*.ts"], + "exclude": ["node_modules"] +} From 0a7f71828b48479151dc05db74176eaa50cb0fc5 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 1 May 2019 17:34:56 +0000 Subject: [PATCH 2/3] Generated from a8018695679044c15d4c26c32c24b6b77f3085b4 Update readme.md updated default package --- sdk/subscription/arm-subscriptions/README.md | 10 +- .../arm-subscriptions/lib/models/index.ts | 226 ++--------------- .../arm-subscriptions/lib/models/mappers.ts | 237 ++---------------- .../lib/models/parameters.ts | 32 +-- .../lib/models/subscriptionsMappers.ts | 4 + .../arm-subscriptions/lib/operations/index.ts | 3 - .../lib/operations/subscriptions.ts | 105 ++++++++ .../lib/subscriptionClient.ts | 11 +- .../lib/subscriptionClientContext.ts | 8 +- 9 files changed, 163 insertions(+), 473 deletions(-) diff --git a/sdk/subscription/arm-subscriptions/README.md b/sdk/subscription/arm-subscriptions/README.md index a351fd9169fe..51b91325cdda 100644 --- a/sdk/subscription/arm-subscriptions/README.md +++ b/sdk/subscription/arm-subscriptions/README.md @@ -15,7 +15,7 @@ npm install @azure/arm-subscriptions ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +#### nodejs - Authentication, client creation and listLocations subscriptions as an example written in TypeScript. ##### Install @azure/ms-rest-nodeauth @@ -34,7 +34,8 @@ const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; msRestNodeAuth.interactiveLogin().then((creds) => { const client = new SubscriptionClient(creds, subscriptionId); - client.operations.list().then((result) => { + const subscriptionId = "testsubscriptionId"; + client.subscriptions.listLocations(subscriptionId).then((result) => { console.log("The result is:"); console.log(result); }); @@ -43,7 +44,7 @@ msRestNodeAuth.interactiveLogin().then((creds) => { }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. +#### browser - Authentication, client creation and listLocations subscriptions as an example written in JavaScript. ##### Install @azure/ms-rest-browserauth @@ -77,7 +78,8 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to authManager.login(); } const client = new Azure.ArmSubscriptions.SubscriptionClient(res.creds, subscriptionId); - client.operations.list().then((result) => { + const subscriptionId = "testsubscriptionId"; + client.subscriptions.listLocations(subscriptionId).then((result) => { console.log("The result is:"); console.log(result); }).catch((err) => { diff --git a/sdk/subscription/arm-subscriptions/lib/models/index.ts b/sdk/subscription/arm-subscriptions/lib/models/index.ts index 7e223e9ea16d..75550f091200 100644 --- a/sdk/subscription/arm-subscriptions/lib/models/index.ts +++ b/sdk/subscription/arm-subscriptions/lib/models/index.ts @@ -14,68 +14,6 @@ import * as msRest from "@azure/ms-rest-js"; export { BaseResource, CloudError }; -/** - * @interface - * An interface representing SubscriptionCreationResult. - * The created subscription object. - * - */ -export interface SubscriptionCreationResult { - /** - * @member {string} [subscriptionLink] The link to the new subscription. - */ - subscriptionLink?: string; -} - -/** - * @interface - * An interface representing AdPrincipal. - * Active Directory Principal for subscription creation delegated permission - * - */ -export interface AdPrincipal { - /** - * @member {string} objectId Object id of the Principal - */ - objectId: string; -} - -/** - * @interface - * An interface representing SubscriptionCreationParameters. - * Subscription Creation Parameters required to create a new Azure - * subscription. - * - */ -export interface SubscriptionCreationParameters { - /** - * @member {string} [displayName] The display name of the subscription. - */ - displayName?: string; - /** - * @member {string} [billingProfileId] The ARM id of the billing profile. - */ - billingProfileId?: string; - /** - * @member {string} [skuId] The commerce id of the sku. - */ - skuId?: string; - /** - * @member {string} [costCenter] optional customer cost center - */ - costCenter?: string; - /** - * @member {AdPrincipal} [owner] rbac owner of the subscription - */ - owner?: AdPrincipal; - /** - * @member {{ [propertyName: string]: any }} [additionalParameters] - * Additional, untyped parameters to support custom subscription creation - * scenarios. - */ - additionalParameters?: { [propertyName: string]: any }; -} - /** * @interface * An interface representing ErrorResponse. @@ -96,98 +34,45 @@ export interface ErrorResponse { /** * @interface - * An interface representing SubscriptionOperation. - * status of the subscription POST operation. + * An interface representing CanceledSubscriptionId. + * Canceled Subscription Id * */ -export interface SubscriptionOperation { +export interface CanceledSubscriptionId { /** - * @member {string} [id] The operation Id. + * @member {string} [value] Canceled Subscription Id * **NOTE: This property will not be serialized. It can only be populated by * the server.** */ - readonly id?: string; - /** - * @member {string} [status] Status of the pending subscription - */ - status?: string; - /** - * @member {string} [statusDetail] Status Detail of the pending subscription - */ - statusDetail?: string; + readonly value?: string; } /** * @interface - * An interface representing SubscriptionOperationListResult. - * A list of pending subscription operations. + * An interface representing RenamedSubscriptionId. + * Renamed Subscription Id * */ -export interface SubscriptionOperationListResult { +export interface RenamedSubscriptionId { /** - * @member {SubscriptionOperation[]} [value] A list of pending - * SubscriptionOperations - */ - value?: SubscriptionOperation[]; -} - -/** - * @interface - * An interface representing OperationDisplay. - * The object that represents the operation. - * - */ -export interface OperationDisplay { - /** - * @member {string} [provider] Service provider: Microsoft.Subscription - */ - provider?: string; - /** - * @member {string} [resource] Resource on which the operation is performed: - * Profile, endpoint, etc. - */ - resource?: string; - /** - * @member {string} [operation] Operation type: Read, write, delete, etc. - */ - operation?: string; -} - -/** - * @interface - * An interface representing Operation. - * REST API operation - * - */ -export interface Operation { - /** - * @member {string} [name] Operation name: {provider}/{resource}/{operation} - */ - name?: string; - /** - * @member {OperationDisplay} [display] The object that represents the - * operation. + * @member {string} [value] Renamed Subscription Id + * **NOTE: This property will not be serialized. It can only be populated by + * the server.** */ - display?: OperationDisplay; + readonly value?: string; } /** * @interface - * An interface representing OperationListResult. - * Result of the request to list operations. It contains a list of operations - * and a URL link to get the next set of results. + * An interface representing SubscriptionName. + * New name of the subscription. * */ -export interface OperationListResult { - /** - * @member {Operation[]} [value] List of operations. - */ - value?: Operation[]; +export interface SubscriptionName { /** - * @member {string} [nextLink] URL to get the next set of operation list - * results if there are any. + * @member {string} [subscriptionName] New subscription name */ - nextLink?: string; + subscriptionName?: string; } /** @@ -349,44 +234,6 @@ export interface SubscriptionClientOptions extends AzureServiceClientOptions { baseUri?: string; } -/** - * @interface - * An interface representing SubscriptionOperationGetHeaders. - * Defines headers for Get operation. - * - */ -export interface SubscriptionOperationGetHeaders { - /** - * @member {string} [location] The URL where the status of the asynchronous - * operation can be checked. - */ - location: string; - /** - * @member {number} [retryAfter] The amount of delay to use while the status - * of the operation is checked. The value is expressed in seconds. - */ - retryAfter: number; -} - -/** - * @interface - * An interface representing SubscriptionFactoryCreateSubscriptionHeaders. - * Defines headers for CreateSubscription operation. - * - */ -export interface SubscriptionFactoryCreateSubscriptionHeaders { - /** - * @member {string} [location] GET this URL to retrieve the status of the - * asynchronous operation. - */ - location: string; - /** - * @member {number} [retryAfter] The amount of delay to use while the status - * of the operation is checked. The value is expressed in seconds. - */ - retryAfter: number; -} - /** * @interface @@ -444,36 +291,13 @@ export type SubscriptionState = 'Enabled' | 'Warned' | 'PastDue' | 'Disabled' | export type SpendingLimit = 'On' | 'Off' | 'CurrentPeriodOff'; /** - * Contains response data for the list operation. - */ -export type OperationsListResponse = OperationListResult & { - /** - * 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: OperationListResult; - }; -}; - -/** - * Contains response data for the get operation. + * Contains response data for the cancel operation. */ -export type SubscriptionOperationGetResponse = SubscriptionCreationResult & SubscriptionOperationGetHeaders & { +export type SubscriptionsCancelResponse = CanceledSubscriptionId & { /** * The underlying HTTP response. */ _response: msRest.HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: SubscriptionOperationGetHeaders; /** * The response body as text (string format) */ @@ -481,22 +305,18 @@ export type SubscriptionOperationGetResponse = SubscriptionCreationResult & Subs /** * The response body as parsed JSON or XML */ - parsedBody: SubscriptionCreationResult; + parsedBody: CanceledSubscriptionId; }; }; /** - * Contains response data for the createSubscription operation. + * Contains response data for the rename operation. */ -export type SubscriptionFactoryCreateSubscriptionResponse = SubscriptionCreationResult & SubscriptionFactoryCreateSubscriptionHeaders & { +export type SubscriptionsRenameResponse = RenamedSubscriptionId & { /** * The underlying HTTP response. */ _response: msRest.HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: SubscriptionFactoryCreateSubscriptionHeaders; /** * The response body as text (string format) */ @@ -504,7 +324,7 @@ export type SubscriptionFactoryCreateSubscriptionResponse = SubscriptionCreation /** * The response body as parsed JSON or XML */ - parsedBody: SubscriptionCreationResult; + parsedBody: RenamedSubscriptionId; }; }; diff --git a/sdk/subscription/arm-subscriptions/lib/models/mappers.ts b/sdk/subscription/arm-subscriptions/lib/models/mappers.ts index 78b826f0f5ea..a8b43dd02e1e 100644 --- a/sdk/subscription/arm-subscriptions/lib/models/mappers.ts +++ b/sdk/subscription/arm-subscriptions/lib/models/mappers.ts @@ -14,91 +14,6 @@ import * as msRest from "@azure/ms-rest-js"; export const CloudError = CloudErrorMapper; export const BaseResource = BaseResourceMapper; -export const SubscriptionCreationResult: msRest.CompositeMapper = { - serializedName: "SubscriptionCreationResult", - type: { - name: "Composite", - className: "SubscriptionCreationResult", - modelProperties: { - subscriptionLink: { - serializedName: "subscriptionLink", - type: { - name: "String" - } - } - } - } -}; - -export const AdPrincipal: msRest.CompositeMapper = { - serializedName: "AdPrincipal", - type: { - name: "Composite", - className: "AdPrincipal", - modelProperties: { - objectId: { - required: true, - serializedName: "objectId", - type: { - name: "String" - } - } - } - } -}; - -export const SubscriptionCreationParameters: msRest.CompositeMapper = { - serializedName: "SubscriptionCreationParameters", - type: { - name: "Composite", - className: "SubscriptionCreationParameters", - modelProperties: { - displayName: { - serializedName: "displayName", - type: { - name: "String" - } - }, - billingProfileId: { - serializedName: "billingProfileId", - type: { - name: "String" - } - }, - skuId: { - serializedName: "skuId", - type: { - name: "String" - } - }, - costCenter: { - serializedName: "costCenter", - type: { - name: "String" - } - }, - owner: { - serializedName: "owner", - type: { - name: "Composite", - className: "AdPrincipal" - } - }, - additionalParameters: { - serializedName: "additionalParameters", - type: { - name: "Dictionary", - value: { - type: { - name: "Object" - } - } - } - } - } - } -}; - export const ErrorResponse: msRest.CompositeMapper = { serializedName: "ErrorResponse", type: { @@ -121,27 +36,15 @@ export const ErrorResponse: msRest.CompositeMapper = { } }; -export const SubscriptionOperation: msRest.CompositeMapper = { - serializedName: "SubscriptionOperation", +export const CanceledSubscriptionId: msRest.CompositeMapper = { + serializedName: "CanceledSubscriptionId", type: { name: "Composite", - className: "SubscriptionOperation", + className: "CanceledSubscriptionId", modelProperties: { - id: { + value: { readOnly: true, - serializedName: "id", - type: { - name: "String" - } - }, - status: { - serializedName: "status", - type: { - name: "String" - } - }, - statusDetail: { - serializedName: "statusDetail", + serializedName: "value", type: { name: "String" } @@ -150,99 +53,31 @@ export const SubscriptionOperation: msRest.CompositeMapper = { } }; -export const SubscriptionOperationListResult: msRest.CompositeMapper = { - serializedName: "SubscriptionOperationListResult", +export const RenamedSubscriptionId: msRest.CompositeMapper = { + serializedName: "RenamedSubscriptionId", type: { name: "Composite", - className: "SubscriptionOperationListResult", + className: "RenamedSubscriptionId", modelProperties: { value: { + readOnly: true, serializedName: "value", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "SubscriptionOperation" - } - } - } - } - } - } -}; - -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" - } - } - } - } -}; - -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", +export const SubscriptionName: msRest.CompositeMapper = { + serializedName: "SubscriptionName", type: { name: "Composite", - className: "OperationListResult", + className: "SubscriptionName", modelProperties: { - value: { - serializedName: "value", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "Operation" - } - } - } - }, - nextLink: { - serializedName: "nextLink", + subscriptionName: { + serializedName: "subscriptionName", type: { name: "String" } @@ -421,50 +256,6 @@ export const TenantIdDescription: msRest.CompositeMapper = { } }; -export const SubscriptionOperationGetHeaders: msRest.CompositeMapper = { - serializedName: "subscriptionoperation-get-headers", - type: { - name: "Composite", - className: "SubscriptionOperationGetHeaders", - modelProperties: { - location: { - serializedName: "location", - type: { - name: "String" - } - }, - retryAfter: { - serializedName: "retry-after", - type: { - name: "Number" - } - } - } - } -}; - -export const SubscriptionFactoryCreateSubscriptionHeaders: msRest.CompositeMapper = { - serializedName: "subscriptionfactory-createsubscription-headers", - type: { - name: "Composite", - className: "SubscriptionFactoryCreateSubscriptionHeaders", - modelProperties: { - location: { - serializedName: "location", - type: { - name: "String" - } - }, - retryAfter: { - serializedName: "retry-after", - type: { - name: "Number" - } - } - } - } -}; - export const LocationListResult: msRest.CompositeMapper = { serializedName: "LocationListResult", type: { diff --git a/sdk/subscription/arm-subscriptions/lib/models/parameters.ts b/sdk/subscription/arm-subscriptions/lib/models/parameters.ts index 7073528267dc..827bf5839416 100644 --- a/sdk/subscription/arm-subscriptions/lib/models/parameters.ts +++ b/sdk/subscription/arm-subscriptions/lib/models/parameters.ts @@ -26,7 +26,7 @@ export const apiVersion0: msRest.OperationQueryParameter = { required: true, isConstant: true, serializedName: "api-version", - defaultValue: '2018-11-01-preview', + defaultValue: '2019-03-01-preview', type: { name: "String" } @@ -44,26 +44,6 @@ export const apiVersion1: msRest.OperationQueryParameter = { } } }; -export const billingAccountName: msRest.OperationURLParameter = { - parameterPath: "billingAccountName", - mapper: { - required: true, - serializedName: "billingAccountName", - type: { - name: "String" - } - } -}; -export const invoiceSectionName: msRest.OperationURLParameter = { - parameterPath: "invoiceSectionName", - mapper: { - required: true, - serializedName: "invoiceSectionName", - type: { - name: "String" - } - } -}; export const nextPageLink: msRest.OperationURLParameter = { parameterPath: "nextPageLink", mapper: { @@ -75,16 +55,6 @@ export const nextPageLink: msRest.OperationURLParameter = { }, skipEncoding: true }; -export const operationId: msRest.OperationURLParameter = { - parameterPath: "operationId", - mapper: { - required: true, - serializedName: "operationId", - type: { - name: "String" - } - } -}; export const subscriptionId: msRest.OperationURLParameter = { parameterPath: "subscriptionId", mapper: { diff --git a/sdk/subscription/arm-subscriptions/lib/models/subscriptionsMappers.ts b/sdk/subscription/arm-subscriptions/lib/models/subscriptionsMappers.ts index 8630883ef598..e35ce65f6067 100644 --- a/sdk/subscription/arm-subscriptions/lib/models/subscriptionsMappers.ts +++ b/sdk/subscription/arm-subscriptions/lib/models/subscriptionsMappers.ts @@ -9,6 +9,10 @@ */ export { + CanceledSubscriptionId, + ErrorResponse, + SubscriptionName, + RenamedSubscriptionId, LocationListResult, Location, CloudError, diff --git a/sdk/subscription/arm-subscriptions/lib/operations/index.ts b/sdk/subscription/arm-subscriptions/lib/operations/index.ts index 613df35a62ca..c5eec912d9ba 100644 --- a/sdk/subscription/arm-subscriptions/lib/operations/index.ts +++ b/sdk/subscription/arm-subscriptions/lib/operations/index.ts @@ -8,8 +8,5 @@ * regenerated. */ -export * from "./operations"; -export * from "./subscriptionOperationOperations"; -export * from "./subscriptionFactory"; export * from "./subscriptions"; export * from "./tenants"; diff --git a/sdk/subscription/arm-subscriptions/lib/operations/subscriptions.ts b/sdk/subscription/arm-subscriptions/lib/operations/subscriptions.ts index 3e978cba8f83..a38cf19a2a1b 100644 --- a/sdk/subscription/arm-subscriptions/lib/operations/subscriptions.ts +++ b/sdk/subscription/arm-subscriptions/lib/operations/subscriptions.ts @@ -26,6 +26,58 @@ export class Subscriptions { this.client = client; } + /** + * Cancels the subscription + * @param [options] The optional parameters + * @returns Promise + */ + cancel(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + cancel(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + cancel(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + cancel(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + cancelOperationSpec, + callback) as Promise; + } + + /** + * Renames the subscription + * @param body Subscription Name + * @param [options] The optional parameters + * @returns Promise + */ + rename(body: Models.SubscriptionName, options?: msRest.RequestOptionsBase): Promise; + /** + * @param body Subscription Name + * @param callback The callback + */ + rename(body: Models.SubscriptionName, callback: msRest.ServiceCallback): void; + /** + * @param body Subscription Name + * @param options The optional parameters + * @param callback The callback + */ + rename(body: Models.SubscriptionName, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + rename(body: Models.SubscriptionName, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + body, + options + }, + renameOperationSpec, + callback) as Promise; + } + /** * This operation provides all the locations that are available for resource providers; however, * each resource provider may support a subset of this list. @@ -139,6 +191,59 @@ export class Subscriptions { // Operation Specifications const serializer = new msRest.Serializer(Mappers); +const cancelOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion0 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.CanceledSubscriptionId + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const renameOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename", + urlParameters: [ + Parameters.subscriptionId + ], + queryParameters: [ + Parameters.apiVersion0 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + requestBody: { + parameterPath: "body", + mapper: { + ...Mappers.SubscriptionName, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.RenamedSubscriptionId + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + const listLocationsOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "subscriptions/{subscriptionId}/locations", diff --git a/sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts b/sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts index bace1a9fc285..b5bf9512ffcd 100644 --- a/sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts +++ b/sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts @@ -17,22 +17,17 @@ import { SubscriptionClientContext } from "./subscriptionClientContext"; class SubscriptionClient extends SubscriptionClientContext { // Operation groups - operations: operations.Operations; - subscriptionOperation: operations.SubscriptionOperationOperations; - subscriptionFactory: operations.SubscriptionFactory; 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. + * @param subscriptionId Subscription Id. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.SubscriptionClientOptions) { - super(credentials, options); - this.operations = new operations.Operations(this); - this.subscriptionOperation = new operations.SubscriptionOperationOperations(this); - this.subscriptionFactory = new operations.SubscriptionFactory(this); + constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.SubscriptionClientOptions) { + super(credentials, subscriptionId, options); this.subscriptions = new operations.Subscriptions(this); this.tenants = new operations.Tenants(this); } diff --git a/sdk/subscription/arm-subscriptions/lib/subscriptionClientContext.ts b/sdk/subscription/arm-subscriptions/lib/subscriptionClientContext.ts index f1f805ba1d10..2bf2bcfe616a 100644 --- a/sdk/subscription/arm-subscriptions/lib/subscriptionClientContext.ts +++ b/sdk/subscription/arm-subscriptions/lib/subscriptionClientContext.ts @@ -17,16 +17,21 @@ const packageVersion = "1.0.0"; export class SubscriptionClientContext extends msRestAzure.AzureServiceClient { credentials: msRest.ServiceClientCredentials; + subscriptionId: string; /** * Initializes a new instance of the SubscriptionClient class. * @param credentials Credentials needed for the client to connect to Azure. + * @param subscriptionId Subscription Id. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.SubscriptionClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.SubscriptionClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } + if (subscriptionId == undefined) { + throw new Error('\'subscriptionId\' cannot be null.'); + } if (!options) { options = {}; @@ -43,6 +48,7 @@ export class SubscriptionClientContext extends msRestAzure.AzureServiceClient { this.baseUri = options.baseUri || this.baseUri || "https://management.azure.com"; this.requestContentType = "application/json; charset=utf-8"; this.credentials = credentials; + this.subscriptionId = subscriptionId; if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { this.acceptLanguage = options.acceptLanguage; From a17ca71a3b6b259b5928446e58a322b1d64db704 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 2 May 2019 00:09:22 +0000 Subject: [PATCH 3/3] Generated from bfdb50d64a52ff3f322a068a5145df3f0d1789b0 Added operations swagger --- sdk/subscription/arm-subscriptions/README.md | 10 +-- .../arm-subscriptions/lib/models/index.ts | 78 ++++++++++++++++++ .../arm-subscriptions/lib/models/mappers.ts | 79 +++++++++++++++++++ .../arm-subscriptions/lib/operations/index.ts | 1 + .../lib/subscriptionClient.ts | 2 + 5 files changed, 164 insertions(+), 6 deletions(-) diff --git a/sdk/subscription/arm-subscriptions/README.md b/sdk/subscription/arm-subscriptions/README.md index 51b91325cdda..a351fd9169fe 100644 --- a/sdk/subscription/arm-subscriptions/README.md +++ b/sdk/subscription/arm-subscriptions/README.md @@ -15,7 +15,7 @@ npm install @azure/arm-subscriptions ### How to use -#### nodejs - Authentication, client creation and listLocations subscriptions as an example written in TypeScript. +#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. ##### Install @azure/ms-rest-nodeauth @@ -34,8 +34,7 @@ const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; msRestNodeAuth.interactiveLogin().then((creds) => { const client = new SubscriptionClient(creds, subscriptionId); - const subscriptionId = "testsubscriptionId"; - client.subscriptions.listLocations(subscriptionId).then((result) => { + client.operations.list().then((result) => { console.log("The result is:"); console.log(result); }); @@ -44,7 +43,7 @@ msRestNodeAuth.interactiveLogin().then((creds) => { }); ``` -#### browser - Authentication, client creation and listLocations subscriptions as an example written in JavaScript. +#### browser - Authentication, client creation and list operations as an example written in JavaScript. ##### Install @azure/ms-rest-browserauth @@ -78,8 +77,7 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to authManager.login(); } const client = new Azure.ArmSubscriptions.SubscriptionClient(res.creds, subscriptionId); - const subscriptionId = "testsubscriptionId"; - client.subscriptions.listLocations(subscriptionId).then((result) => { + client.operations.list().then((result) => { console.log("The result is:"); console.log(result); }).catch((err) => { diff --git a/sdk/subscription/arm-subscriptions/lib/models/index.ts b/sdk/subscription/arm-subscriptions/lib/models/index.ts index 75550f091200..50d9fda1f8ef 100644 --- a/sdk/subscription/arm-subscriptions/lib/models/index.ts +++ b/sdk/subscription/arm-subscriptions/lib/models/index.ts @@ -75,6 +75,65 @@ export interface SubscriptionName { subscriptionName?: string; } +/** + * @interface + * An interface representing OperationDisplay. + * The object that represents the operation. + * + */ +export interface OperationDisplay { + /** + * @member {string} [provider] Service provider: Microsoft.Subscription + */ + provider?: string; + /** + * @member {string} [resource] Resource on which the operation is performed: + * Profile, endpoint, etc. + */ + resource?: string; + /** + * @member {string} [operation] Operation type: Read, write, delete, etc. + */ + operation?: string; +} + +/** + * @interface + * An interface representing Operation. + * REST API operation + * + */ +export interface Operation { + /** + * @member {string} [name] Operation name: {provider}/{resource}/{operation} + */ + name?: string; + /** + * @member {OperationDisplay} [display] The object that represents the + * operation. + */ + display?: OperationDisplay; +} + +/** + * @interface + * An interface representing OperationListResult. + * Result of the request to list operations. It contains a list of operations + * and a URL link to get the next set of results. + * + */ +export interface OperationListResult { + /** + * @member {Operation[]} [value] List of operations. + */ + value?: Operation[]; + /** + * @member {string} [nextLink] URL to get the next set of operation list + * results if there are any. + */ + nextLink?: string; +} + /** * @interface * An interface representing Location. @@ -290,6 +349,25 @@ export type SubscriptionState = 'Enabled' | 'Warned' | 'PastDue' | 'Disabled' | */ export type SpendingLimit = 'On' | 'Off' | 'CurrentPeriodOff'; +/** + * Contains response data for the list operation. + */ +export type OperationsListResponse = OperationListResult & { + /** + * 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: OperationListResult; + }; +}; + /** * Contains response data for the cancel operation. */ diff --git a/sdk/subscription/arm-subscriptions/lib/models/mappers.ts b/sdk/subscription/arm-subscriptions/lib/models/mappers.ts index a8b43dd02e1e..1195e02b88d0 100644 --- a/sdk/subscription/arm-subscriptions/lib/models/mappers.ts +++ b/sdk/subscription/arm-subscriptions/lib/models/mappers.ts @@ -86,6 +86,85 @@ export const SubscriptionName: msRest.CompositeMapper = { } }; +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" + } + } + } + } +}; + +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 Location: msRest.CompositeMapper = { serializedName: "Location", type: { diff --git a/sdk/subscription/arm-subscriptions/lib/operations/index.ts b/sdk/subscription/arm-subscriptions/lib/operations/index.ts index c5eec912d9ba..3e6732554b87 100644 --- a/sdk/subscription/arm-subscriptions/lib/operations/index.ts +++ b/sdk/subscription/arm-subscriptions/lib/operations/index.ts @@ -8,5 +8,6 @@ * regenerated. */ +export * from "./operations"; export * from "./subscriptions"; export * from "./tenants"; diff --git a/sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts b/sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts index b5bf9512ffcd..f440b5aa75b5 100644 --- a/sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts +++ b/sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts @@ -17,6 +17,7 @@ import { SubscriptionClientContext } from "./subscriptionClientContext"; class SubscriptionClient extends SubscriptionClientContext { // Operation groups + operations: operations.Operations; subscriptions: operations.Subscriptions; tenants: operations.Tenants; @@ -28,6 +29,7 @@ class SubscriptionClient extends SubscriptionClientContext { */ constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.SubscriptionClientOptions) { super(credentials, subscriptionId, options); + this.operations = new operations.Operations(this); this.subscriptions = new operations.Subscriptions(this); this.tenants = new operations.Tenants(this); }