@azure/arm-compute
Version:
A generated SDK for ComputeManagementClient.
112 lines • 4.3 kB
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
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";
/** Class containing GallerySharingProfile operations. */
export class GallerySharingProfileImpl {
client;
/**
* Initialize a new instance of the class GallerySharingProfile class.
* @param client Reference to the service client
*/
constructor(client) {
this.client = client;
}
/**
* Update sharing profile of 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 sharingUpdate Parameters supplied to the update gallery sharing profile.
* @param options The options parameters.
*/
async beginUpdate(resourceGroupName, galleryName, sharingUpdate, 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, sharingUpdate, options },
spec: updateOperationSpec,
});
const poller = await createHttpPoller(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs,
resourceLocationConfig: "location",
});
await poller.poll();
return poller;
}
/**
* Update sharing profile of 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 sharingUpdate Parameters supplied to the update gallery sharing profile.
* @param options The options parameters.
*/
async beginUpdateAndWait(resourceGroupName, galleryName, sharingUpdate, options) {
const poller = await this.beginUpdate(resourceGroupName, galleryName, sharingUpdate, options);
return poller.pollUntilDone();
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const updateOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.SharingUpdate,
},
201: {
bodyMapper: Mappers.SharingUpdate,
},
202: {
bodyMapper: Mappers.SharingUpdate,
},
204: {
bodyMapper: Mappers.SharingUpdate,
},
default: {
bodyMapper: Mappers.CloudError,
},
},
requestBody: Parameters.sharingUpdate,
queryParameters: [Parameters.apiVersion3],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.galleryName,
],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer,
};
//# sourceMappingURL=gallerySharingProfile.js.map