UNPKG

@azure/arm-monitor

Version:
429 lines 16.8 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 ActionGroups operations. */ export class ActionGroupsImpl { /** * Initialize a new instance of the class ActionGroups class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Get a list of all action groups in a subscription. * @param options The options parameters. */ listBySubscriptionId(options) { const iter = this.listBySubscriptionIdPagingAll(options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: () => { return this.listBySubscriptionIdPagingPage(options); } }; } listBySubscriptionIdPagingPage(options) { return __asyncGenerator(this, arguments, function* listBySubscriptionIdPagingPage_1() { let result = yield __await(this._listBySubscriptionId(options)); yield yield __await(result.value || []); }); } listBySubscriptionIdPagingAll(options) { return __asyncGenerator(this, arguments, function* listBySubscriptionIdPagingAll_1() { var e_1, _a; try { for (var _b = __asyncValues(this.listBySubscriptionIdPagingPage(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; } } }); } /** * Get a list of all action groups in a resource group. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param options The options parameters. */ listByResourceGroup(resourceGroupName, options) { const iter = this.listByResourceGroupPagingAll(resourceGroupName, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: () => { return this.listByResourceGroupPagingPage(resourceGroupName, options); } }; } listByResourceGroupPagingPage(resourceGroupName, options) { return __asyncGenerator(this, arguments, function* listByResourceGroupPagingPage_1() { let result = yield __await(this._listByResourceGroup(resourceGroupName, options)); yield yield __await(result.value || []); }); } listByResourceGroupPagingAll(resourceGroupName, options) { return __asyncGenerator(this, arguments, function* listByResourceGroupPagingAll_1() { var e_2, _a; try { for (var _b = __asyncValues(this.listByResourceGroupPagingPage(resourceGroupName, options)), _c; _c = yield __await(_b.next()), !_c.done;) { const page = _c.value; yield __await(yield* __asyncDelegator(__asyncValues(page))); } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b)); } finally { if (e_2) throw e_2.error; } } }); } /** * Create a new action group or update an existing one. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param actionGroupName The name of the action group. * @param actionGroup The action group to create or use for the update. * @param options The options parameters. */ createOrUpdate(resourceGroupName, actionGroupName, actionGroup, options) { return this.client.sendOperationRequest({ resourceGroupName, actionGroupName, actionGroup, options }, createOrUpdateOperationSpec); } /** * Get an action group. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param actionGroupName The name of the action group. * @param options The options parameters. */ get(resourceGroupName, actionGroupName, options) { return this.client.sendOperationRequest({ resourceGroupName, actionGroupName, options }, getOperationSpec); } /** * Delete an action group. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param actionGroupName The name of the action group. * @param options The options parameters. */ delete(resourceGroupName, actionGroupName, options) { return this.client.sendOperationRequest({ resourceGroupName, actionGroupName, options }, deleteOperationSpec); } /** * Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param actionGroupName The name of the action group. * @param actionGroupPatch Parameters supplied to the operation. * @param options The options parameters. */ update(resourceGroupName, actionGroupName, actionGroupPatch, options) { return this.client.sendOperationRequest({ resourceGroupName, actionGroupName, actionGroupPatch, options }, updateOperationSpec); } /** * Send test notifications to a set of provided receivers * @param notificationRequest The notification request body which includes the contact details * @param options The options parameters. */ beginPostTestNotifications(notificationRequest, 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, { notificationRequest, options }, postTestNotificationsOperationSpec); return new LroEngine(lro, { resumeFrom: options === null || options === void 0 ? void 0 : options.resumeFrom, intervalInMs: options === null || options === void 0 ? void 0 : options.updateIntervalInMs, lroResourceLocationConfig: "location" }); }); } /** * Send test notifications to a set of provided receivers * @param notificationRequest The notification request body which includes the contact details * @param options The options parameters. */ beginPostTestNotificationsAndWait(notificationRequest, options) { return __awaiter(this, void 0, void 0, function* () { const poller = yield this.beginPostTestNotifications(notificationRequest, options); return poller.pollUntilDone(); }); } /** * Get the test notifications by the notification id * @param notificationId The notification id * @param options The options parameters. */ getTestNotifications(notificationId, options) { return this.client.sendOperationRequest({ notificationId, options }, getTestNotificationsOperationSpec); } /** * Get a list of all action groups in a subscription. * @param options The options parameters. */ _listBySubscriptionId(options) { return this.client.sendOperationRequest({ options }, listBySubscriptionIdOperationSpec); } /** * Get a list of all action groups in a resource group. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param options The options parameters. */ _listByResourceGroup(resourceGroupName, options) { return this.client.sendOperationRequest({ resourceGroupName, options }, listByResourceGroupOperationSpec); } /** * Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. * This operation is only supported for Email or SMS receivers. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param actionGroupName The name of the action group. * @param enableRequest The receiver to re-enable. * @param options The options parameters. */ enableReceiver(resourceGroupName, actionGroupName, enableRequest, options) { return this.client.sendOperationRequest({ resourceGroupName, actionGroupName, enableRequest, options }, enableReceiverOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const createOrUpdateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.ActionGroupResource }, 201: { bodyMapper: Mappers.ActionGroupResource }, default: { bodyMapper: Mappers.ErrorResponse } }, requestBody: Parameters.actionGroup, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.actionGroupName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const getOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ActionGroupResource }, default: { bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.actionGroupName ], headerParameters: [Parameters.accept], serializer }; const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", httpMethod: "DELETE", responses: { 200: {}, 204: {}, default: { bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.actionGroupName ], headerParameters: [Parameters.accept], serializer }; const updateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.ActionGroupResource }, default: { bodyMapper: Mappers.ErrorResponse } }, requestBody: Parameters.actionGroupPatch, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.actionGroupName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const postTestNotificationsOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications", httpMethod: "POST", responses: { 200: { bodyMapper: Mappers.TestNotificationResponse }, 201: { bodyMapper: Mappers.TestNotificationResponse }, 202: { bodyMapper: Mappers.TestNotificationResponse }, 204: { bodyMapper: Mappers.TestNotificationResponse }, default: { bodyMapper: Mappers.ErrorResponse } }, requestBody: Parameters.notificationRequest, queryParameters: [Parameters.apiVersion3], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const getTestNotificationsOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.TestNotificationDetailsResponse }, default: { bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.notificationId ], headerParameters: [Parameters.accept], serializer }; const listBySubscriptionIdOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ActionGroupList }, default: { bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion3], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer }; const listByResourceGroupOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ActionGroupList }, default: { bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId ], headerParameters: [Parameters.accept], serializer }; const enableReceiverOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe", httpMethod: "POST", responses: { 200: {}, 409: { isError: true }, default: { bodyMapper: Mappers.ErrorResponse } }, requestBody: Parameters.enableRequest, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.actionGroupName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; //# sourceMappingURL=actionGroups.js.map