UNPKG

@azure/arm-compute

Version:
261 lines 10.5 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.RestorePointsImpl = void 0; const tslib_1 = require("tslib"); 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"); /** Class containing RestorePoints operations. */ class RestorePointsImpl { client; /** * Initialize a new instance of the class RestorePoints class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * The operation to get the restore point. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param restorePointCollectionName The name of the restore point collection. * @param restorePointName The name of the restore point. * @param options The options parameters. */ get(resourceGroupName, restorePointCollectionName, restorePointName, options) { return this.client.sendOperationRequest({ resourceGroupName, restorePointCollectionName, restorePointName, options, }, getOperationSpec); } /** * The operation to create the restore point. Updating properties of an existing restore point is not * allowed * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param restorePointCollectionName The name of the restore point collection. * @param restorePointName The name of the restore point. * @param parameters Parameters supplied to the Create restore point operation. * @param options The options parameters. */ async beginCreate(resourceGroupName, restorePointCollectionName, restorePointName, parameters, 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, restorePointCollectionName, restorePointName, parameters, options, }, spec: createOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * The operation to create the restore point. Updating properties of an existing restore point is not * allowed * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param restorePointCollectionName The name of the restore point collection. * @param restorePointName The name of the restore point. * @param parameters Parameters supplied to the Create restore point operation. * @param options The options parameters. */ async beginCreateAndWait(resourceGroupName, restorePointCollectionName, restorePointName, parameters, options) { const poller = await this.beginCreate(resourceGroupName, restorePointCollectionName, restorePointName, parameters, options); return poller.pollUntilDone(); } /** * The operation to delete the restore point. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param restorePointCollectionName The name of the restore point collection. * @param restorePointName The name of the restore point. * @param options The options parameters. */ async beginDelete(resourceGroupName, restorePointCollectionName, restorePointName, 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, restorePointCollectionName, restorePointName, 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; } /** * The operation to delete the restore point. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param restorePointCollectionName The name of the restore point collection. * @param restorePointName The name of the restore point. * @param options The options parameters. */ async beginDeleteAndWait(resourceGroupName, restorePointCollectionName, restorePointName, options) { const poller = await this.beginDelete(resourceGroupName, restorePointCollectionName, restorePointName, options); return poller.pollUntilDone(); } } exports.RestorePointsImpl = RestorePointsImpl; // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const getOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.RestorePoint, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion, Parameters.expand10], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.restorePointCollectionName, Parameters.restorePointName, ], headerParameters: [Parameters.accept], serializer, }; const createOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.RestorePoint, headersMapper: Mappers.RestorePointsCreateHeaders, }, 201: { bodyMapper: Mappers.RestorePoint, headersMapper: Mappers.RestorePointsCreateHeaders, }, 202: { bodyMapper: Mappers.RestorePoint, headersMapper: Mappers.RestorePointsCreateHeaders, }, 204: { bodyMapper: Mappers.RestorePoint, headersMapper: Mappers.RestorePointsCreateHeaders, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters34, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.restorePointCollectionName, Parameters.restorePointName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", httpMethod: "DELETE", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.restorePointCollectionName, Parameters.restorePointName, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=restorePoints.js.map