UNPKG

@azure/arm-resources

Version:
416 lines 15.4 kB
"use strict"; /* * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ProvidersImpl = void 0; const tslib_1 = require("tslib"); const pagingHelper_js_1 = require("../pagingHelper.js"); const coreClient = tslib_1.__importStar(require("@azure/core-client")); const Mappers = tslib_1.__importStar(require("../models/mappers.js")); const Parameters = tslib_1.__importStar(require("../models/parameters.js")); /// <reference lib="esnext.asynciterable" /> /** Class containing Providers operations. */ class ProvidersImpl { /** * Initialize a new instance of the class Providers class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Gets all resource providers for a subscription. * @param options The options parameters. */ list(options) { const iter = this.listPagingAll(options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings) => { if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listPagingPage(options, settings); }, }; } listPagingPage(options, settings) { return tslib_1.__asyncGenerator(this, arguments, function* listPagingPage_1() { let result; let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken; if (!continuationToken) { result = yield tslib_1.__await(this._list(options)); let page = result.value || []; continuationToken = result.nextLink; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield yield tslib_1.__await(page); } while (continuationToken) { result = yield tslib_1.__await(this._listNext(continuationToken, options)); continuationToken = result.nextLink; let page = result.value || []; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield yield tslib_1.__await(page); } }); } listPagingAll(options) { return tslib_1.__asyncGenerator(this, arguments, function* listPagingAll_1() { var _a, e_1, _b, _c; try { for (var _d = true, _e = tslib_1.__asyncValues(this.listPagingPage(options)), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a; _d = true) { _c = _f.value; _d = false; const page = _c; yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(page))); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e)); } finally { if (e_1) throw e_1.error; } } }); } /** * Gets all resource providers for the tenant. * @param options The options parameters. */ listAtTenantScope(options) { const iter = this.listAtTenantScopePagingAll(options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings) => { if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listAtTenantScopePagingPage(options, settings); }, }; } listAtTenantScopePagingPage(options, settings) { return tslib_1.__asyncGenerator(this, arguments, function* listAtTenantScopePagingPage_1() { let result; let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken; if (!continuationToken) { result = yield tslib_1.__await(this._listAtTenantScope(options)); let page = result.value || []; continuationToken = result.nextLink; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield yield tslib_1.__await(page); } while (continuationToken) { result = yield tslib_1.__await(this._listAtTenantScopeNext(continuationToken, options)); continuationToken = result.nextLink; let page = result.value || []; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield yield tslib_1.__await(page); } }); } listAtTenantScopePagingAll(options) { return tslib_1.__asyncGenerator(this, arguments, function* listAtTenantScopePagingAll_1() { var _a, e_2, _b, _c; try { for (var _d = true, _e = tslib_1.__asyncValues(this.listAtTenantScopePagingPage(options)), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a; _d = true) { _c = _f.value; _d = false; const page = _c; yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(page))); } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e)); } finally { if (e_2) throw e_2.error; } } }); } /** * Unregisters a subscription from a resource provider. * @param resourceProviderNamespace The namespace of the resource provider to unregister. * @param options The options parameters. */ unregister(resourceProviderNamespace, options) { return this.client.sendOperationRequest({ resourceProviderNamespace, options }, unregisterOperationSpec); } /** * Registers a management group with a resource provider. Use this operation to register a resource * provider with resource types that can be deployed at the management group scope. It does not * recursively register subscriptions within the management group. Instead, you must register * subscriptions individually. * @param resourceProviderNamespace The namespace of the resource provider to register. * @param groupId The management group ID. * @param options The options parameters. */ registerAtManagementGroupScope(resourceProviderNamespace, groupId, options) { return this.client.sendOperationRequest({ resourceProviderNamespace, groupId, options }, registerAtManagementGroupScopeOperationSpec); } /** * Get the provider permissions. * @param resourceProviderNamespace The namespace of the resource provider. * @param options The options parameters. */ providerPermissions(resourceProviderNamespace, options) { return this.client.sendOperationRequest({ resourceProviderNamespace, options }, providerPermissionsOperationSpec); } /** * Registers a subscription with a resource provider. * @param resourceProviderNamespace The namespace of the resource provider to register. * @param options The options parameters. */ register(resourceProviderNamespace, options) { return this.client.sendOperationRequest({ resourceProviderNamespace, options }, registerOperationSpec); } /** * Gets all resource providers for a subscription. * @param options The options parameters. */ _list(options) { return this.client.sendOperationRequest({ options }, listOperationSpec); } /** * Gets all resource providers for the tenant. * @param options The options parameters. */ _listAtTenantScope(options) { return this.client.sendOperationRequest({ options }, listAtTenantScopeOperationSpec); } /** * Gets the specified resource provider. * @param resourceProviderNamespace The namespace of the resource provider. * @param options The options parameters. */ get(resourceProviderNamespace, options) { return this.client.sendOperationRequest({ resourceProviderNamespace, options }, getOperationSpec); } /** * Gets the specified resource provider at the tenant level. * @param resourceProviderNamespace The namespace of the resource provider. * @param options The options parameters. */ getAtTenantScope(resourceProviderNamespace, options) { return this.client.sendOperationRequest({ resourceProviderNamespace, options }, getAtTenantScopeOperationSpec); } /** * ListNext * @param nextLink The nextLink from the previous successful call to the List method. * @param options The options parameters. */ _listNext(nextLink, options) { return this.client.sendOperationRequest({ nextLink, options }, listNextOperationSpec); } /** * ListAtTenantScopeNext * @param nextLink The nextLink from the previous successful call to the ListAtTenantScope method. * @param options The options parameters. */ _listAtTenantScopeNext(nextLink, options) { return this.client.sendOperationRequest({ nextLink, options }, listAtTenantScopeNextOperationSpec); } } exports.ProvidersImpl = ProvidersImpl; // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const unregisterOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister", httpMethod: "POST", responses: { 200: { bodyMapper: Mappers.Provider, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceProviderNamespace, ], headerParameters: [Parameters.accept], serializer, }; const registerAtManagementGroupScopeOperationSpec = { path: "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register", httpMethod: "POST", responses: { 200: {}, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.groupId, Parameters.resourceProviderNamespace, ], headerParameters: [Parameters.accept], serializer, }; const providerPermissionsOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ProviderPermissionListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceProviderNamespace, ], headerParameters: [Parameters.accept], serializer, }; const registerOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register", httpMethod: "POST", responses: { 200: { bodyMapper: Mappers.Provider, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.properties, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceProviderNamespace, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const listOperationSpec = { path: "/subscriptions/{subscriptionId}/providers", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ProviderListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion, Parameters.expand], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer, }; const listAtTenantScopeOperationSpec = { path: "/providers", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ProviderListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion, Parameters.expand], urlParameters: [Parameters.$host], headerParameters: [Parameters.accept], serializer, }; const getOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.Provider, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion, Parameters.expand], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceProviderNamespace, ], headerParameters: [Parameters.accept], serializer, }; const getAtTenantScopeOperationSpec = { path: "/providers/{resourceProviderNamespace}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.Provider, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion, Parameters.expand], urlParameters: [Parameters.$host, Parameters.resourceProviderNamespace], headerParameters: [Parameters.accept], serializer, }; const listNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ProviderListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, ], headerParameters: [Parameters.accept], serializer, }; const listAtTenantScopeNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ProviderListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=providers.js.map