@azure/arm-compute
Version:
A generated SDK for ComputeManagementClient.
448 lines • 18.1 kB
JavaScript
// 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 GalleryApplications operations. */
export 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);
const page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield page;
}
while (continuationToken) {
result = await this._listByGalleryNext(resourceGroupName, galleryName, continuationToken, options);
continuationToken = result.nextLink;
const 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 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 = createLroSpec({
sendOperationFn,
args: {
resourceGroupName,
galleryName,
galleryApplicationName,
galleryApplication,
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 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 = createLroSpec({
sendOperationFn,
args: {
resourceGroupName,
galleryName,
galleryApplicationName,
galleryApplication,
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 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 = createLroSpec({
sendOperationFn,
args: { resourceGroupName, galleryName, galleryApplicationName, 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.
* @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);
}
}
// 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