UNPKG

@azure/arm-compute

Version:
477 lines 20 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 { 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"; import { createHttpPoller, } from "@azure/core-lro"; import { createLroSpec } from "../lroImpl.js"; /// <reference lib="esnext.asynciterable" /> /** Class containing GalleryInVMAccessControlProfiles operations. */ export class GalleryInVMAccessControlProfilesImpl { client; /** * Initialize a new instance of the class GalleryInVMAccessControlProfiles class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * List gallery inVMAccessControlProfiles in a gallery. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param options The options parameters. */ listByGallery(resourceGroupName, galleryName, options) { const iter = this.listByGalleryPagingAll(resourceGroupName, galleryName, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings) => { if (settings?.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listByGalleryPagingPage(resourceGroupName, galleryName, options, settings); }, }; } async *listByGalleryPagingPage(resourceGroupName, galleryName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByGallery(resourceGroupName, galleryName, options); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByGalleryNext(resourceGroupName, galleryName, continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listByGalleryPagingAll(resourceGroupName, galleryName, options) { for await (const page of this.listByGalleryPagingPage(resourceGroupName, galleryName, options)) { yield* page; } } /** * List gallery inVMAccessControlProfiles in a gallery. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param options The options parameters. */ _listByGallery(resourceGroupName, galleryName, options) { return this.client.sendOperationRequest({ resourceGroupName, galleryName, options }, listByGalleryOperationSpec); } /** * Retrieves information about a gallery inVMAccessControlProfile. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param inVMAccessControlProfileName The name of the gallery inVMAccessControlProfile to be * retrieved. * @param options The options parameters. */ get(resourceGroupName, galleryName, inVMAccessControlProfileName, options) { return this.client.sendOperationRequest({ resourceGroupName, galleryName, inVMAccessControlProfileName, options }, getOperationSpec); } /** * Create or update a gallery inVMAccessControlProfile. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param inVMAccessControlProfileName The name of the gallery inVMAccessControlProfile to be * retrieved. * @param galleryInVMAccessControlProfile Parameters supplied to the create or update gallery * inVMAccessControlProfile operation. * @param options The options parameters. */ async beginCreateOrUpdate(resourceGroupName, galleryName, inVMAccessControlProfileName, galleryInVMAccessControlProfile, options) { const directSendOperation = async (args, spec) => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = async (args, spec) => { let currentRawResponse = undefined; const providedCallback = args.options?.onResponse; const callback = (rawResponse, flatResponse) => { currentRawResponse = rawResponse; providedCallback?.(rawResponse, flatResponse); }; const updatedArgs = { ...args, options: { ...args.options, onResponse: callback, }, }; const flatResponse = await directSendOperation(updatedArgs, spec); return { flatResponse, rawResponse: { statusCode: currentRawResponse.status, body: currentRawResponse.parsedBody, headers: currentRawResponse.headers.toJSON(), }, }; }; const lro = createLroSpec({ sendOperationFn, args: { resourceGroupName, galleryName, inVMAccessControlProfileName, galleryInVMAccessControlProfile, options, }, spec: createOrUpdateOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Create or update a gallery inVMAccessControlProfile. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param inVMAccessControlProfileName The name of the gallery inVMAccessControlProfile to be * retrieved. * @param galleryInVMAccessControlProfile Parameters supplied to the create or update gallery * inVMAccessControlProfile operation. * @param options The options parameters. */ async beginCreateOrUpdateAndWait(resourceGroupName, galleryName, inVMAccessControlProfileName, galleryInVMAccessControlProfile, options) { const poller = await this.beginCreateOrUpdate(resourceGroupName, galleryName, inVMAccessControlProfileName, galleryInVMAccessControlProfile, options); return poller.pollUntilDone(); } /** * Update a gallery inVMAccessControlProfile. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param inVMAccessControlProfileName The name of the gallery inVMAccessControlProfile to be * retrieved. * @param galleryInVMAccessControlProfile Parameters supplied to the update gallery * inVMAccessControlProfile operation. * @param options The options parameters. */ async beginUpdate(resourceGroupName, galleryName, inVMAccessControlProfileName, galleryInVMAccessControlProfile, options) { const directSendOperation = async (args, spec) => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = async (args, spec) => { let currentRawResponse = undefined; const providedCallback = args.options?.onResponse; const callback = (rawResponse, flatResponse) => { currentRawResponse = rawResponse; providedCallback?.(rawResponse, flatResponse); }; const updatedArgs = { ...args, options: { ...args.options, onResponse: callback, }, }; const flatResponse = await directSendOperation(updatedArgs, spec); return { flatResponse, rawResponse: { statusCode: currentRawResponse.status, body: currentRawResponse.parsedBody, headers: currentRawResponse.headers.toJSON(), }, }; }; const lro = createLroSpec({ sendOperationFn, args: { resourceGroupName, galleryName, inVMAccessControlProfileName, galleryInVMAccessControlProfile, options, }, spec: updateOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Update a gallery inVMAccessControlProfile. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param inVMAccessControlProfileName The name of the gallery inVMAccessControlProfile to be * retrieved. * @param galleryInVMAccessControlProfile Parameters supplied to the update gallery * inVMAccessControlProfile operation. * @param options The options parameters. */ async beginUpdateAndWait(resourceGroupName, galleryName, inVMAccessControlProfileName, galleryInVMAccessControlProfile, options) { const poller = await this.beginUpdate(resourceGroupName, galleryName, inVMAccessControlProfileName, galleryInVMAccessControlProfile, options); return poller.pollUntilDone(); } /** * Delete a gallery inVMAccessControlProfile. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param inVMAccessControlProfileName The name of the gallery inVMAccessControlProfile to be * retrieved. * @param options The options parameters. */ async beginDelete(resourceGroupName, galleryName, inVMAccessControlProfileName, options) { const directSendOperation = async (args, spec) => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = async (args, spec) => { let currentRawResponse = undefined; const providedCallback = args.options?.onResponse; const callback = (rawResponse, flatResponse) => { currentRawResponse = rawResponse; providedCallback?.(rawResponse, flatResponse); }; const updatedArgs = { ...args, options: { ...args.options, onResponse: callback, }, }; const flatResponse = await directSendOperation(updatedArgs, spec); return { flatResponse, rawResponse: { statusCode: currentRawResponse.status, body: currentRawResponse.parsedBody, headers: currentRawResponse.headers.toJSON(), }, }; }; const lro = createLroSpec({ sendOperationFn, args: { resourceGroupName, galleryName, inVMAccessControlProfileName, options, }, spec: deleteOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Delete a gallery inVMAccessControlProfile. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param inVMAccessControlProfileName The name of the gallery inVMAccessControlProfile to be * retrieved. * @param options The options parameters. */ async beginDeleteAndWait(resourceGroupName, galleryName, inVMAccessControlProfileName, options) { const poller = await this.beginDelete(resourceGroupName, galleryName, inVMAccessControlProfileName, options); return poller.pollUntilDone(); } /** * ListByGalleryNext * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param nextLink The nextLink from the previous successful call to the ListByGallery method. * @param options The options parameters. */ _listByGalleryNext(resourceGroupName, galleryName, nextLink, options) { return this.client.sendOperationRequest({ resourceGroupName, galleryName, nextLink, options }, listByGalleryNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listByGalleryOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GalleryInVMAccessControlProfileList, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, ], headerParameters: [Parameters.accept], serializer, }; const getOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles/{inVMAccessControlProfileName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GalleryInVMAccessControlProfile, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.inVMAccessControlProfileName, ], headerParameters: [Parameters.accept], serializer, }; const createOrUpdateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles/{inVMAccessControlProfileName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.GalleryInVMAccessControlProfile, }, 201: { bodyMapper: Mappers.GalleryInVMAccessControlProfile, }, 202: { bodyMapper: Mappers.GalleryInVMAccessControlProfile, }, 204: { bodyMapper: Mappers.GalleryInVMAccessControlProfile, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.galleryInVMAccessControlProfile, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.inVMAccessControlProfileName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const updateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles/{inVMAccessControlProfileName}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.GalleryInVMAccessControlProfile, headersMapper: Mappers.GalleryInVMAccessControlProfilesUpdateHeaders, }, 201: { bodyMapper: Mappers.GalleryInVMAccessControlProfile, headersMapper: Mappers.GalleryInVMAccessControlProfilesUpdateHeaders, }, 202: { bodyMapper: Mappers.GalleryInVMAccessControlProfile, headersMapper: Mappers.GalleryInVMAccessControlProfilesUpdateHeaders, }, 204: { bodyMapper: Mappers.GalleryInVMAccessControlProfile, headersMapper: Mappers.GalleryInVMAccessControlProfilesUpdateHeaders, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.galleryInVMAccessControlProfile1, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.inVMAccessControlProfileName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles/{inVMAccessControlProfileName}", httpMethod: "DELETE", responses: { 200: { headersMapper: Mappers.GalleryInVMAccessControlProfilesDeleteHeaders, }, 201: { headersMapper: Mappers.GalleryInVMAccessControlProfilesDeleteHeaders, }, 202: { headersMapper: Mappers.GalleryInVMAccessControlProfilesDeleteHeaders, }, 204: { headersMapper: Mappers.GalleryInVMAccessControlProfilesDeleteHeaders, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.inVMAccessControlProfileName, ], headerParameters: [Parameters.accept], serializer, }; const listByGalleryNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GalleryInVMAccessControlProfileList, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=galleryInVMAccessControlProfiles.js.map