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..50d9fda1f8ef --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/models/index.ts @@ -0,0 +1,521 @@ +/* + * 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 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 CanceledSubscriptionId. + * Canceled Subscription Id + * + */ +export interface CanceledSubscriptionId { + /** + * @member {string} [value] Canceled Subscription Id + * **NOTE: This property will not be serialized. It can only be populated by + * the server.** + */ + readonly value?: string; +} + +/** + * @interface + * An interface representing RenamedSubscriptionId. + * Renamed Subscription Id + * + */ +export interface RenamedSubscriptionId { + /** + * @member {string} [value] Renamed Subscription Id + * **NOTE: This property will not be serialized. It can only be populated by + * the server.** + */ + readonly value?: string; +} + +/** + * @interface + * An interface representing SubscriptionName. + * New name of the subscription. + * + */ +export interface SubscriptionName { + /** + * @member {string} [subscriptionName] New subscription name + */ + 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. + * 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 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 cancel operation. + */ +export type SubscriptionsCancelResponse = CanceledSubscriptionId & { + /** + * 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: CanceledSubscriptionId; + }; +}; + +/** + * Contains response data for the rename operation. + */ +export type SubscriptionsRenameResponse = RenamedSubscriptionId & { + /** + * 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: RenamedSubscriptionId; + }; +}; + +/** + * 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..1195e02b88d0 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/models/mappers.ts @@ -0,0 +1,416 @@ +/* + * 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 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 CanceledSubscriptionId: msRest.CompositeMapper = { + serializedName: "CanceledSubscriptionId", + type: { + name: "Composite", + className: "CanceledSubscriptionId", + modelProperties: { + value: { + readOnly: true, + serializedName: "value", + type: { + name: "String" + } + } + } + } +}; + +export const RenamedSubscriptionId: msRest.CompositeMapper = { + serializedName: "RenamedSubscriptionId", + type: { + name: "Composite", + className: "RenamedSubscriptionId", + modelProperties: { + value: { + readOnly: true, + serializedName: "value", + type: { + name: "String" + } + } + } + } +}; + +export const SubscriptionName: msRest.CompositeMapper = { + serializedName: "SubscriptionName", + type: { + name: "Composite", + className: "SubscriptionName", + modelProperties: { + subscriptionName: { + serializedName: "subscriptionName", + type: { + name: "String" + } + } + } + } +}; + +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 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..827bf5839416 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/models/parameters.ts @@ -0,0 +1,67 @@ +/* + * 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: '2019-03-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 nextPageLink: msRest.OperationURLParameter = { + parameterPath: "nextPageLink", + mapper: { + required: true, + serializedName: "nextLink", + type: { + name: "String" + } + }, + skipEncoding: true +}; +export const subscriptionId: msRest.OperationURLParameter = { + parameterPath: "subscriptionId", + mapper: { + required: true, + serializedName: "subscriptionId", + type: { + name: "String" + } + } +}; diff --git a/sdk/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..e35ce65f6067 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/models/subscriptionsMappers.ts @@ -0,0 +1,23 @@ +/* + * 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 { + CanceledSubscriptionId, + ErrorResponse, + SubscriptionName, + RenamedSubscriptionId, + 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..3e6732554b87 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/operations/index.ts @@ -0,0 +1,13 @@ +/* + * 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 "./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..a38cf19a2a1b --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/operations/subscriptions.ts @@ -0,0 +1,332 @@ +/* + * 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; + } + + /** + * 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. + * @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 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", + 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..f440b5aa75b5 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/subscriptionClient.ts @@ -0,0 +1,46 @@ +/* + * 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; + 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, 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); + } +} + +// 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..2bf2bcfe616a --- /dev/null +++ b/sdk/subscription/arm-subscriptions/lib/subscriptionClientContext.ts @@ -0,0 +1,60 @@ +/* + * 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; + 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, 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 = {}; + } + 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; + this.subscriptionId = subscriptionId; + + 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"] +}