UNPKG

@azure/arm-monitor

Version:
364 lines 13.7 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 } from "tslib"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; /// <reference lib="esnext.asynciterable" /> /** Class containing AutoscaleSettings operations. */ export class AutoscaleSettingsImpl { /** * Initialize a new instance of the class AutoscaleSettings class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Lists the autoscale settings for 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 || []); let continuationToken = result.nextLink; while (continuationToken) { result = yield __await(this._listByResourceGroupNext(resourceGroupName, continuationToken, options)); continuationToken = result.nextLink; yield yield __await(result.value || []); } }); } listByResourceGroupPagingAll(resourceGroupName, options) { return __asyncGenerator(this, arguments, function* listByResourceGroupPagingAll_1() { var e_1, _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_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; } } }); } /** * Lists the autoscale settings for a subscription * @param options The options parameters. */ listBySubscription(options) { const iter = this.listBySubscriptionPagingAll(options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: () => { return this.listBySubscriptionPagingPage(options); } }; } listBySubscriptionPagingPage(options) { return __asyncGenerator(this, arguments, function* listBySubscriptionPagingPage_1() { let result = yield __await(this._listBySubscription(options)); yield yield __await(result.value || []); let continuationToken = result.nextLink; while (continuationToken) { result = yield __await(this._listBySubscriptionNext(continuationToken, options)); continuationToken = result.nextLink; yield yield __await(result.value || []); } }); } listBySubscriptionPagingAll(options) { return __asyncGenerator(this, arguments, function* listBySubscriptionPagingAll_1() { var e_2, _a; try { for (var _b = __asyncValues(this.listBySubscriptionPagingPage(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; } } }); } /** * Lists the autoscale settings for 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); } /** * Creates or updates an autoscale setting. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param autoscaleSettingName The autoscale setting name. * @param parameters Parameters supplied to the operation. * @param options The options parameters. */ createOrUpdate(resourceGroupName, autoscaleSettingName, parameters, options) { return this.client.sendOperationRequest({ resourceGroupName, autoscaleSettingName, parameters, options }, createOrUpdateOperationSpec); } /** * Deletes and autoscale setting * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param autoscaleSettingName The autoscale setting name. * @param options The options parameters. */ delete(resourceGroupName, autoscaleSettingName, options) { return this.client.sendOperationRequest({ resourceGroupName, autoscaleSettingName, options }, deleteOperationSpec); } /** * Gets an autoscale setting * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param autoscaleSettingName The autoscale setting name. * @param options The options parameters. */ get(resourceGroupName, autoscaleSettingName, options) { return this.client.sendOperationRequest({ resourceGroupName, autoscaleSettingName, options }, getOperationSpec); } /** * Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param autoscaleSettingName The autoscale setting name. * @param autoscaleSettingResource Parameters supplied to the operation. * @param options The options parameters. */ update(resourceGroupName, autoscaleSettingName, autoscaleSettingResource, options) { return this.client.sendOperationRequest({ resourceGroupName, autoscaleSettingName, autoscaleSettingResource, options }, updateOperationSpec); } /** * Lists the autoscale settings for a subscription * @param options The options parameters. */ _listBySubscription(options) { return this.client.sendOperationRequest({ options }, listBySubscriptionOperationSpec); } /** * ListByResourceGroupNext * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param nextLink The nextLink from the previous successful call to the ListByResourceGroup method. * @param options The options parameters. */ _listByResourceGroupNext(resourceGroupName, nextLink, options) { return this.client.sendOperationRequest({ resourceGroupName, nextLink, options }, listByResourceGroupNextOperationSpec); } /** * ListBySubscriptionNext * @param nextLink The nextLink from the previous successful call to the ListBySubscription method. * @param options The options parameters. */ _listBySubscriptionNext(nextLink, options) { return this.client.sendOperationRequest({ nextLink, options }, listBySubscriptionNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listByResourceGroupOperationSpec = { path: "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.AutoscaleSettingResourceCollection }, default: { bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId ], headerParameters: [Parameters.accept], serializer }; const createOrUpdateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.AutoscaleSettingResource }, 201: { bodyMapper: Mappers.AutoscaleSettingResource }, default: { bodyMapper: Mappers.ErrorResponse } }, requestBody: Parameters.parameters, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.autoscaleSettingName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", httpMethod: "DELETE", responses: { 200: {}, 204: {}, default: { bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.autoscaleSettingName ], headerParameters: [Parameters.accept], serializer }; const getOperationSpec = { path: "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.AutoscaleSettingResource }, default: { bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.autoscaleSettingName ], headerParameters: [Parameters.accept], serializer }; const updateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.AutoscaleSettingResource }, default: { bodyMapper: Mappers.ErrorResponse } }, requestBody: Parameters.autoscaleSettingResource, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.autoscaleSettingName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const listBySubscriptionOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.AutoscaleSettingResourceCollection }, default: { bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer }; const listByResourceGroupNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.AutoscaleSettingResourceCollection }, default: { bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, Parameters.subscriptionId, Parameters.nextLink ], headerParameters: [Parameters.accept], serializer }; const listBySubscriptionNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.AutoscaleSettingResourceCollection }, default: { bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.nextLink ], headerParameters: [Parameters.accept], serializer }; //# sourceMappingURL=autoscaleSettings.js.map