UNPKG

@azure/arm-monitor

Version:
310 lines 14.2 kB
/* * 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, __awaiter } from "tslib"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { LroEngine } from "@azure/core-lro"; import { LroImpl } from "../lroImpl"; /// <reference lib="esnext.asynciterable" /> /** Class containing PrivateLinkScopedResources operations. */ export class PrivateLinkScopedResourcesImpl { /** * Initialize a new instance of the class PrivateLinkScopedResources class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Gets all private endpoint connections on a private link scope. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param scopeName The name of the Azure Monitor PrivateLinkScope resource. * @param options The options parameters. */ listByPrivateLinkScope(resourceGroupName, scopeName, options) { const iter = this.listByPrivateLinkScopePagingAll(resourceGroupName, scopeName, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: () => { return this.listByPrivateLinkScopePagingPage(resourceGroupName, scopeName, options); } }; } listByPrivateLinkScopePagingPage(resourceGroupName, scopeName, options) { return __asyncGenerator(this, arguments, function* listByPrivateLinkScopePagingPage_1() { let result = yield __await(this._listByPrivateLinkScope(resourceGroupName, scopeName, options)); yield yield __await(result.value || []); let continuationToken = result.nextLink; while (continuationToken) { result = yield __await(this._listByPrivateLinkScopeNext(resourceGroupName, scopeName, continuationToken, options)); continuationToken = result.nextLink; yield yield __await(result.value || []); } }); } listByPrivateLinkScopePagingAll(resourceGroupName, scopeName, options) { return __asyncGenerator(this, arguments, function* listByPrivateLinkScopePagingAll_1() { var e_1, _a; try { for (var _b = __asyncValues(this.listByPrivateLinkScopePagingPage(resourceGroupName, scopeName, options)), _c; _c = yield __await(_b.next()), !_c.done;) { const page = _c.value; yield __await(yield* __asyncDelegator(__asyncValues(page))); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b)); } finally { if (e_1) throw e_1.error; } } }); } /** * Gets a scoped resource in a private link scope. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param scopeName The name of the Azure Monitor PrivateLinkScope resource. * @param name The name of the scoped resource object. * @param options The options parameters. */ get(resourceGroupName, scopeName, name, options) { return this.client.sendOperationRequest({ resourceGroupName, scopeName, name, options }, getOperationSpec); } /** * Approve or reject a private endpoint connection with a given name. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param scopeName The name of the Azure Monitor PrivateLinkScope resource. * @param name The name of the scoped resource object. * @param parameters A private link scoped resource * @param options The options parameters. */ beginCreateOrUpdate(resourceGroupName, scopeName, name, parameters, options) { return __awaiter(this, void 0, void 0, function* () { const directSendOperation = (args, spec) => __awaiter(this, void 0, void 0, function* () { return this.client.sendOperationRequest(args, spec); }); const sendOperation = (args, spec) => __awaiter(this, void 0, void 0, function* () { var _a; let currentRawResponse = undefined; const providedCallback = (_a = args.options) === null || _a === void 0 ? void 0 : _a.onResponse; const callback = (rawResponse, flatResponse) => { currentRawResponse = rawResponse; providedCallback === null || providedCallback === void 0 ? void 0 : providedCallback(rawResponse, flatResponse); }; const updatedArgs = Object.assign(Object.assign({}, args), { options: Object.assign(Object.assign({}, args.options), { onResponse: callback }) }); const flatResponse = yield directSendOperation(updatedArgs, spec); return { flatResponse, rawResponse: { statusCode: currentRawResponse.status, body: currentRawResponse.parsedBody, headers: currentRawResponse.headers.toJSON() } }; }); const lro = new LroImpl(sendOperation, { resourceGroupName, scopeName, name, parameters, options }, createOrUpdateOperationSpec); return new LroEngine(lro, { resumeFrom: options === null || options === void 0 ? void 0 : options.resumeFrom, intervalInMs: options === null || options === void 0 ? void 0 : options.updateIntervalInMs }); }); } /** * Approve or reject a private endpoint connection with a given name. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param scopeName The name of the Azure Monitor PrivateLinkScope resource. * @param name The name of the scoped resource object. * @param parameters A private link scoped resource * @param options The options parameters. */ beginCreateOrUpdateAndWait(resourceGroupName, scopeName, name, parameters, options) { return __awaiter(this, void 0, void 0, function* () { const poller = yield this.beginCreateOrUpdate(resourceGroupName, scopeName, name, parameters, options); return poller.pollUntilDone(); }); } /** * Deletes a private endpoint connection with a given name. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param scopeName The name of the Azure Monitor PrivateLinkScope resource. * @param name The name of the scoped resource object. * @param options The options parameters. */ beginDelete(resourceGroupName, scopeName, name, options) { return __awaiter(this, void 0, void 0, function* () { const directSendOperation = (args, spec) => __awaiter(this, void 0, void 0, function* () { return this.client.sendOperationRequest(args, spec); }); const sendOperation = (args, spec) => __awaiter(this, void 0, void 0, function* () { var _a; let currentRawResponse = undefined; const providedCallback = (_a = args.options) === null || _a === void 0 ? void 0 : _a.onResponse; const callback = (rawResponse, flatResponse) => { currentRawResponse = rawResponse; providedCallback === null || providedCallback === void 0 ? void 0 : providedCallback(rawResponse, flatResponse); }; const updatedArgs = Object.assign(Object.assign({}, args), { options: Object.assign(Object.assign({}, args.options), { onResponse: callback }) }); const flatResponse = yield directSendOperation(updatedArgs, spec); return { flatResponse, rawResponse: { statusCode: currentRawResponse.status, body: currentRawResponse.parsedBody, headers: currentRawResponse.headers.toJSON() } }; }); const lro = new LroImpl(sendOperation, { resourceGroupName, scopeName, name, options }, deleteOperationSpec); return new LroEngine(lro, { resumeFrom: options === null || options === void 0 ? void 0 : options.resumeFrom, intervalInMs: options === null || options === void 0 ? void 0 : options.updateIntervalInMs }); }); } /** * Deletes a private endpoint connection with a given name. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param scopeName The name of the Azure Monitor PrivateLinkScope resource. * @param name The name of the scoped resource object. * @param options The options parameters. */ beginDeleteAndWait(resourceGroupName, scopeName, name, options) { return __awaiter(this, void 0, void 0, function* () { const poller = yield this.beginDelete(resourceGroupName, scopeName, name, options); return poller.pollUntilDone(); }); } /** * Gets all private endpoint connections on a private link scope. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param scopeName The name of the Azure Monitor PrivateLinkScope resource. * @param options The options parameters. */ _listByPrivateLinkScope(resourceGroupName, scopeName, options) { return this.client.sendOperationRequest({ resourceGroupName, scopeName, options }, listByPrivateLinkScopeOperationSpec); } /** * ListByPrivateLinkScopeNext * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param scopeName The name of the Azure Monitor PrivateLinkScope resource. * @param nextLink The nextLink from the previous successful call to the ListByPrivateLinkScope method. * @param options The options parameters. */ _listByPrivateLinkScopeNext(resourceGroupName, scopeName, nextLink, options) { return this.client.sendOperationRequest({ resourceGroupName, scopeName, nextLink, options }, listByPrivateLinkScopeNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const getOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ScopedResource } }, queryParameters: [Parameters.apiVersion10], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.name, Parameters.scopeName ], headerParameters: [Parameters.accept], serializer }; const createOrUpdateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.ScopedResource }, 201: { bodyMapper: Mappers.ScopedResource }, 202: { bodyMapper: Mappers.ScopedResource }, 204: { bodyMapper: Mappers.ScopedResource } }, requestBody: Parameters.parameters9, queryParameters: [Parameters.apiVersion10], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.name, Parameters.scopeName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", httpMethod: "DELETE", responses: { 200: {}, 201: {}, 202: {}, 204: {} }, queryParameters: [Parameters.apiVersion10], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.name, Parameters.scopeName ], serializer }; const listByPrivateLinkScopeOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ScopedResourceListResult } }, queryParameters: [Parameters.apiVersion10], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.scopeName ], headerParameters: [Parameters.accept], serializer }; const listByPrivateLinkScopeNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ScopedResourceListResult } }, queryParameters: [Parameters.apiVersion10], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.nextLink, Parameters.scopeName ], headerParameters: [Parameters.accept], serializer }; //# sourceMappingURL=privateLinkScopedResources.js.map