UNPKG

@azure/arm-compute

Version:
458 lines 18.7 kB
"use strict"; /* * 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.GalleryApplicationsImpl = void 0; const tslib_1 = require("tslib"); const pagingHelper_js_1 = require("../pagingHelper.js"); const coreClient = tslib_1.__importStar(require("@azure/core-client")); const Mappers = tslib_1.__importStar(require("../models/mappers.js")); const Parameters = tslib_1.__importStar(require("../models/parameters.js")); const core_lro_1 = require("@azure/core-lro"); const lroImpl_js_1 = require("../lroImpl.js"); /// <reference lib="esnext.asynciterable" /> /** Class containing GalleryApplications operations. */ class GalleryApplicationsImpl { client; /** * Initialize a new instance of the class GalleryApplications class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * List gallery Application Definitions 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; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByGalleryNext(resourceGroupName, galleryName, continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield page; } } async *listByGalleryPagingAll(resourceGroupName, galleryName, options) { for await (const page of this.listByGalleryPagingPage(resourceGroupName, galleryName, options)) { yield* page; } } /** * List gallery Application Definitions 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 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. */ get(resourceGroupName, galleryName, galleryApplicationName, options) { return this.client.sendOperationRequest({ resourceGroupName, galleryName, galleryApplicationName, options }, getOperationSpec); } /** * Create or update 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 galleryApplication Parameters supplied to the create or update gallery Application operation. * @param options The options parameters. */ async beginCreateOrUpdate(resourceGroupName, galleryName, galleryApplicationName, galleryApplication, 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 = (0, lroImpl_js_1.createLroSpec)({ sendOperationFn, args: { resourceGroupName, galleryName, galleryApplicationName, galleryApplication, options, }, spec: createOrUpdateOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Create or update 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 galleryApplication Parameters supplied to the create or update gallery Application operation. * @param options The options parameters. */ async beginCreateOrUpdateAndWait(resourceGroupName, galleryName, galleryApplicationName, galleryApplication, options) { const poller = await this.beginCreateOrUpdate(resourceGroupName, galleryName, galleryApplicationName, galleryApplication, options); return poller.pollUntilDone(); } /** * Update 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 galleryApplication Parameters supplied to the update gallery Application operation. * @param options The options parameters. */ async beginUpdate(resourceGroupName, galleryName, galleryApplicationName, galleryApplication, 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 = (0, lroImpl_js_1.createLroSpec)({ sendOperationFn, args: { resourceGroupName, galleryName, galleryApplicationName, galleryApplication, options, }, spec: updateOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Update 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 galleryApplication Parameters supplied to the update gallery Application operation. * @param options The options parameters. */ async beginUpdateAndWait(resourceGroupName, galleryName, galleryApplicationName, galleryApplication, options) { const poller = await this.beginUpdate(resourceGroupName, galleryName, galleryApplicationName, galleryApplication, options); return poller.pollUntilDone(); } /** * Delete a gallery Application. * @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. */ async beginDelete(resourceGroupName, galleryName, galleryApplicationName, 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 = (0, lroImpl_js_1.createLroSpec)({ sendOperationFn, args: { resourceGroupName, galleryName, galleryApplicationName, options }, spec: deleteOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Delete a gallery Application. * @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. */ async beginDeleteAndWait(resourceGroupName, galleryName, galleryApplicationName, options) { const poller = await this.beginDelete(resourceGroupName, galleryName, galleryApplicationName, 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); } } exports.GalleryApplicationsImpl = GalleryApplicationsImpl; // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listByGalleryOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GalleryApplicationList, }, 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}/applications/{galleryApplicationName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GalleryApplication, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.galleryApplicationName, ], headerParameters: [Parameters.accept], serializer, }; const createOrUpdateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.GalleryApplication, }, 201: { bodyMapper: Mappers.GalleryApplication, }, 202: { bodyMapper: Mappers.GalleryApplication, }, 204: { bodyMapper: Mappers.GalleryApplication, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.galleryApplication, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.galleryApplicationName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const updateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.GalleryApplication, headersMapper: Mappers.GalleryApplicationsUpdateHeaders, }, 201: { bodyMapper: Mappers.GalleryApplication, headersMapper: Mappers.GalleryApplicationsUpdateHeaders, }, 202: { bodyMapper: Mappers.GalleryApplication, headersMapper: Mappers.GalleryApplicationsUpdateHeaders, }, 204: { bodyMapper: Mappers.GalleryApplication, headersMapper: Mappers.GalleryApplicationsUpdateHeaders, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.galleryApplication1, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.galleryApplicationName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", 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, ], headerParameters: [Parameters.accept], serializer, }; const listByGalleryNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GalleryApplicationList, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=galleryApplications.js.map