@azure/arm-resources
Version:
A generated SDK for ResourceManagementClient.
412 lines • 14.9 kB
JavaScript
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
import { setContinuationToken } from "../pagingHelper.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
/// <reference lib="esnext.asynciterable" />
/** Class containing Providers operations. */
export 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 __asyncGenerator(this, arguments, function* listPagingPage_1() {
let result;
let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
if (!continuationToken) {
result = yield __await(this._list(options));
let page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield yield __await(page);
}
while (continuationToken) {
result = yield __await(this._listNext(continuationToken, options));
continuationToken = result.nextLink;
let page = result.value || [];
setContinuationToken(page, continuationToken);
yield yield __await(page);
}
});
}
listPagingAll(options) {
return __asyncGenerator(this, arguments, function* listPagingAll_1() {
var _a, e_1, _b, _c;
try {
for (var _d = true, _e = __asyncValues(this.listPagingPage(options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const page = _c;
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_d && !_a && (_b = _e.return)) yield __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 __asyncGenerator(this, arguments, function* listAtTenantScopePagingPage_1() {
let result;
let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
if (!continuationToken) {
result = yield __await(this._listAtTenantScope(options));
let page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield yield __await(page);
}
while (continuationToken) {
result = yield __await(this._listAtTenantScopeNext(continuationToken, options));
continuationToken = result.nextLink;
let page = result.value || [];
setContinuationToken(page, continuationToken);
yield yield __await(page);
}
});
}
listAtTenantScopePagingAll(options) {
return __asyncGenerator(this, arguments, function* listAtTenantScopePagingAll_1() {
var _a, e_2, _b, _c;
try {
for (var _d = true, _e = __asyncValues(this.listAtTenantScopePagingPage(options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const page = _c;
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (!_d && !_a && (_b = _e.return)) yield __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);
}
}
// 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