UNPKG

@azure/arm-compute

Version:
489 lines 21.3 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. 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 GalleryApplicationVersions operations. */ export class GalleryApplicationVersionsImpl { client; /** * Initialize a new instance of the class GalleryApplicationVersions class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * List gallery Application Versions in a gallery Application Definition. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param galleryApplicationName The name of the gallery Application Definition to be retrieved. * @param options The options parameters. */ listByGalleryApplication(resourceGroupName, galleryName, galleryApplicationName, options) { const iter = this.listByGalleryApplicationPagingAll(resourceGroupName, galleryName, galleryApplicationName, 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.listByGalleryApplicationPagingPage(resourceGroupName, galleryName, galleryApplicationName, options, settings); }, }; } async *listByGalleryApplicationPagingPage(resourceGroupName, galleryName, galleryApplicationName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByGalleryApplication(resourceGroupName, galleryName, galleryApplicationName, options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByGalleryApplicationNext(resourceGroupName, galleryName, galleryApplicationName, continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listByGalleryApplicationPagingAll(resourceGroupName, galleryName, galleryApplicationName, options) { for await (const page of this.listByGalleryApplicationPagingPage(resourceGroupName, galleryName, galleryApplicationName, options)) { yield* page; } } /** * List gallery Application Versions in a gallery Application Definition. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param galleryApplicationName The name of the gallery Application Definition to be retrieved. * @param options The options parameters. */ _listByGalleryApplication(resourceGroupName, galleryName, galleryApplicationName, options) { return this.client.sendOperationRequest({ resourceGroupName, galleryName, galleryApplicationName, options }, listByGalleryApplicationOperationSpec); } /** * Retrieves information about a gallery Application Version. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param galleryApplicationName The name of the gallery Application Definition to be retrieved. * @param galleryApplicationVersionName The name of the gallery Application Version to be retrieved. * @param options The options parameters. */ get(resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, options) { return this.client.sendOperationRequest({ resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, options, }, getOperationSpec); } /** * Create or update a gallery Application Version. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param galleryApplicationName The name of the gallery Application Definition to be retrieved. * @param galleryApplicationVersionName The name of the gallery Application Version to be retrieved. * @param galleryApplicationVersion Parameters supplied to the create or update gallery Application * Version operation. * @param options The options parameters. */ async beginCreateOrUpdate(resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, galleryApplicationVersion, 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, galleryApplicationName, galleryApplicationVersionName, galleryApplicationVersion, 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 Application Version. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param galleryApplicationName The name of the gallery Application Definition to be retrieved. * @param galleryApplicationVersionName The name of the gallery Application Version to be retrieved. * @param galleryApplicationVersion Parameters supplied to the create or update gallery Application * Version operation. * @param options The options parameters. */ async beginCreateOrUpdateAndWait(resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, galleryApplicationVersion, options) { const poller = await this.beginCreateOrUpdate(resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, galleryApplicationVersion, options); return poller.pollUntilDone(); } /** * Update a gallery Application Version. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param galleryApplicationName The name of the gallery Application Definition to be retrieved. * @param galleryApplicationVersionName The name of the gallery Application Version to be retrieved. * @param galleryApplicationVersion Parameters supplied to the update gallery Application Version * operation. * @param options The options parameters. */ async beginUpdate(resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, galleryApplicationVersion, 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, galleryApplicationName, galleryApplicationVersionName, galleryApplicationVersion, options, }, spec: updateOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Update a gallery Application Version. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param galleryApplicationName The name of the gallery Application Definition to be retrieved. * @param galleryApplicationVersionName The name of the gallery Application Version to be retrieved. * @param galleryApplicationVersion Parameters supplied to the update gallery Application Version * operation. * @param options The options parameters. */ async beginUpdateAndWait(resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, galleryApplicationVersion, options) { const poller = await this.beginUpdate(resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, galleryApplicationVersion, options); return poller.pollUntilDone(); } /** * Delete a gallery Application Version. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param galleryApplicationName The name of the gallery Application Definition to be retrieved. * @param galleryApplicationVersionName The name of the gallery Application Version to be retrieved. * @param options The options parameters. */ async beginDelete(resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, 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, galleryApplicationName, galleryApplicationVersionName, options, }, spec: deleteOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Delete a gallery Application Version. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param galleryApplicationName The name of the gallery Application Definition to be retrieved. * @param galleryApplicationVersionName The name of the gallery Application Version to be retrieved. * @param options The options parameters. */ async beginDeleteAndWait(resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, options) { const poller = await this.beginDelete(resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, options); return poller.pollUntilDone(); } /** * ListByGalleryApplicationNext * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param galleryApplicationName The name of the gallery Application Definition to be retrieved. * @param nextLink The nextLink from the previous successful call to the ListByGalleryApplication * method. * @param options The options parameters. */ _listByGalleryApplicationNext(resourceGroupName, galleryName, galleryApplicationName, nextLink, options) { return this.client.sendOperationRequest({ resourceGroupName, galleryName, galleryApplicationName, nextLink, options, }, listByGalleryApplicationNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listByGalleryApplicationOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GalleryApplicationVersionList, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.galleryApplicationName, ], headerParameters: [Parameters.accept], serializer, }; const getOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GalleryApplicationVersion, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion3, Parameters.expand12], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.galleryApplicationName, Parameters.galleryApplicationVersionName, ], headerParameters: [Parameters.accept], serializer, }; const createOrUpdateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.GalleryApplicationVersion, }, 201: { bodyMapper: Mappers.GalleryApplicationVersion, }, 202: { bodyMapper: Mappers.GalleryApplicationVersion, }, 204: { bodyMapper: Mappers.GalleryApplicationVersion, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.galleryApplicationVersion, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.galleryApplicationName, Parameters.galleryApplicationVersionName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const updateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.GalleryApplicationVersion, headersMapper: Mappers.GalleryApplicationVersionsUpdateHeaders, }, 201: { bodyMapper: Mappers.GalleryApplicationVersion, headersMapper: Mappers.GalleryApplicationVersionsUpdateHeaders, }, 202: { bodyMapper: Mappers.GalleryApplicationVersion, headersMapper: Mappers.GalleryApplicationVersionsUpdateHeaders, }, 204: { bodyMapper: Mappers.GalleryApplicationVersion, headersMapper: Mappers.GalleryApplicationVersionsUpdateHeaders, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.galleryApplicationVersion1, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.galleryApplicationName, Parameters.galleryApplicationVersionName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", httpMethod: "DELETE", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.galleryApplicationName, Parameters.galleryApplicationVersionName, ], headerParameters: [Parameters.accept], serializer, }; const listByGalleryApplicationNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GalleryApplicationVersionList, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.galleryApplicationName, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=galleryApplicationVersions.js.map