/* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for * license information. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ import * as msRest from "@azure/ms-rest-js"; import * as msRestAzure from "@azure/ms-rest-azure-js"; import * as Models from "../models"; import * as Mappers from "../models/snapshotsMappers"; import * as Parameters from "../models/parameters"; import { ComputeManagementClientContext } from "../computeManagementClientContext"; /** Class representing a Snapshots. */ export class Snapshots { private readonly client: ComputeManagementClientContext; /** * Create a Snapshots. * @param {ComputeManagementClientContext} client Reference to the service client. */ constructor(client: ComputeManagementClientContext) { this.client = client; } /** * Creates or updates a snapshot. * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param snapshot Snapshot object supplied in the body of the Put disk operation. * @param [options] The optional parameters * @returns Promise */ createOrUpdate(resourceGroupName: string, snapshotName: string, snapshot: Models.Snapshot, options?: msRest.RequestOptionsBase): Promise { return this.beginCreateOrUpdate(resourceGroupName,snapshotName,snapshot,options) .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; } /** * Updates (patches) a snapshot. * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param snapshot Snapshot object supplied in the body of the Patch snapshot operation. * @param [options] The optional parameters * @returns Promise */ update(resourceGroupName: string, snapshotName: string, snapshot: Models.SnapshotUpdate, options?: msRest.RequestOptionsBase): Promise { return this.beginUpdate(resourceGroupName,snapshotName,snapshot,options) .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; } /** * Gets information about a snapshot. * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param [options] The optional parameters * @returns Promise */ get(resourceGroupName: string, snapshotName: string, options?: msRest.RequestOptionsBase): Promise; /** * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param callback The callback */ get(resourceGroupName: string, snapshotName: string, callback: msRest.ServiceCallback): void; /** * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param options The optional parameters * @param callback The callback */ get(resourceGroupName: string, snapshotName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; get(resourceGroupName: string, snapshotName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { resourceGroupName, snapshotName, options }, getOperationSpec, callback) as Promise; } /** * Deletes a snapshot. * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param [options] The optional parameters * @returns Promise */ deleteMethod(resourceGroupName: string, snapshotName: string, options?: msRest.RequestOptionsBase): Promise { return this.beginDeleteMethod(resourceGroupName,snapshotName,options) .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; } /** * Lists snapshots under a resource group. * @param resourceGroupName The name of the resource group. * @param [options] The optional parameters * @returns Promise */ listByResourceGroup(resourceGroupName: string, options?: msRest.RequestOptionsBase): Promise; /** * @param resourceGroupName The name of the resource group. * @param callback The callback */ listByResourceGroup(resourceGroupName: string, callback: msRest.ServiceCallback): void; /** * @param resourceGroupName The name of the resource group. * @param options The optional parameters * @param callback The callback */ listByResourceGroup(resourceGroupName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; listByResourceGroup(resourceGroupName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { resourceGroupName, options }, listByResourceGroupOperationSpec, callback) as Promise; } /** * Lists snapshots under a subscription. * @param [options] The optional parameters * @returns Promise */ list(options?: msRest.RequestOptionsBase): Promise; /** * @param callback The callback */ list(callback: msRest.ServiceCallback): void; /** * @param options The optional parameters * @param callback The callback */ list(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; list(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { options }, listOperationSpec, callback) as Promise; } /** * Grants access to a snapshot. * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param grantAccessData Access data object supplied in the body of the get snapshot access * operation. * @param [options] The optional parameters * @returns Promise */ grantAccess(resourceGroupName: string, snapshotName: string, grantAccessData: Models.GrantAccessData, options?: msRest.RequestOptionsBase): Promise { return this.beginGrantAccess(resourceGroupName,snapshotName,grantAccessData,options) .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; } /** * Revokes access to a snapshot. * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param [options] The optional parameters * @returns Promise */ revokeAccess(resourceGroupName: string, snapshotName: string, options?: msRest.RequestOptionsBase): Promise { return this.beginRevokeAccess(resourceGroupName,snapshotName,options) .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; } /** * Creates or updates a snapshot. * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param snapshot Snapshot object supplied in the body of the Put disk operation. * @param [options] The optional parameters * @returns Promise */ beginCreateOrUpdate(resourceGroupName: string, snapshotName: string, snapshot: Models.Snapshot, options?: msRest.RequestOptionsBase): Promise { return this.client.sendLRORequest( { resourceGroupName, snapshotName, snapshot, options }, beginCreateOrUpdateOperationSpec, options); } /** * Updates (patches) a snapshot. * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param snapshot Snapshot object supplied in the body of the Patch snapshot operation. * @param [options] The optional parameters * @returns Promise */ beginUpdate(resourceGroupName: string, snapshotName: string, snapshot: Models.SnapshotUpdate, options?: msRest.RequestOptionsBase): Promise { return this.client.sendLRORequest( { resourceGroupName, snapshotName, snapshot, options }, beginUpdateOperationSpec, options); } /** * Deletes a snapshot. * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param [options] The optional parameters * @returns Promise */ beginDeleteMethod(resourceGroupName: string, snapshotName: string, options?: msRest.RequestOptionsBase): Promise { return this.client.sendLRORequest( { resourceGroupName, snapshotName, options }, beginDeleteMethodOperationSpec, options); } /** * Grants access to a snapshot. * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param grantAccessData Access data object supplied in the body of the get snapshot access * operation. * @param [options] The optional parameters * @returns Promise */ beginGrantAccess(resourceGroupName: string, snapshotName: string, grantAccessData: Models.GrantAccessData, options?: msRest.RequestOptionsBase): Promise { return this.client.sendLRORequest( { resourceGroupName, snapshotName, grantAccessData, options }, beginGrantAccessOperationSpec, options); } /** * Revokes access to a snapshot. * @param resourceGroupName The name of the resource group. * @param snapshotName The name of the snapshot that is being created. The name can't be changed * after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * max name length is 80 characters. * @param [options] The optional parameters * @returns Promise */ beginRevokeAccess(resourceGroupName: string, snapshotName: string, options?: msRest.RequestOptionsBase): Promise { return this.client.sendLRORequest( { resourceGroupName, snapshotName, options }, beginRevokeAccessOperationSpec, options); } /** * Lists snapshots under a resource group. * @param nextPageLink The NextLink from the previous successful call to List operation. * @param [options] The optional parameters * @returns Promise */ listByResourceGroupNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; /** * @param nextPageLink The NextLink from the previous successful call to List operation. * @param callback The callback */ listByResourceGroupNext(nextPageLink: string, callback: msRest.ServiceCallback): void; /** * @param nextPageLink The NextLink from the previous successful call to List operation. * @param options The optional parameters * @param callback The callback */ listByResourceGroupNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; listByResourceGroupNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { nextPageLink, options }, listByResourceGroupNextOperationSpec, callback) as Promise; } /** * Lists snapshots under a subscription. * @param nextPageLink The NextLink from the previous successful call to List operation. * @param [options] The optional parameters * @returns Promise */ listNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; /** * @param nextPageLink The NextLink from the previous successful call to List operation. * @param callback The callback */ listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; /** * @param nextPageLink The NextLink from the previous successful call to List operation. * @param options The optional parameters * @param callback The callback */ listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { nextPageLink, options }, listNextOperationSpec, callback) as Promise; } } // Operation Specifications const serializer = new msRest.Serializer(Mappers); const getOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.snapshotName ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.Snapshot }, default: { bodyMapper: Mappers.CloudError } }, serializer }; const listByResourceGroupOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.SnapshotList }, default: { bodyMapper: Mappers.CloudError } }, serializer }; const listOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots", urlParameters: [ Parameters.subscriptionId ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.SnapshotList }, default: { bodyMapper: Mappers.CloudError } }, serializer }; const beginCreateOrUpdateOperationSpec: msRest.OperationSpec = { httpMethod: "PUT", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.snapshotName ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: "snapshot", mapper: { ...Mappers.Snapshot, required: true } }, responses: { 200: { bodyMapper: Mappers.Snapshot }, 202: { bodyMapper: Mappers.Snapshot }, default: { bodyMapper: Mappers.CloudError } }, serializer }; const beginUpdateOperationSpec: msRest.OperationSpec = { httpMethod: "PATCH", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.snapshotName ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: "snapshot", mapper: { ...Mappers.SnapshotUpdate, required: true } }, responses: { 200: { bodyMapper: Mappers.Snapshot }, 202: { bodyMapper: Mappers.Snapshot }, default: { bodyMapper: Mappers.CloudError } }, serializer }; const beginDeleteMethodOperationSpec: msRest.OperationSpec = { httpMethod: "DELETE", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.snapshotName ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.OperationStatusResponse }, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError } }, serializer }; const beginGrantAccessOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.snapshotName ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: "grantAccessData", mapper: { ...Mappers.GrantAccessData, required: true } }, responses: { 200: { bodyMapper: Mappers.AccessUri }, 202: {}, default: { bodyMapper: Mappers.CloudError } }, serializer }; const beginRevokeAccessOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.snapshotName ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.OperationStatusResponse }, 202: {}, default: { bodyMapper: Mappers.CloudError } }, serializer }; const listByResourceGroupNextOperationSpec: msRest.OperationSpec = { httpMethod: "GET", baseUrl: "https://management.azure.com", path: "{nextLink}", urlParameters: [ Parameters.nextPageLink ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.SnapshotList }, default: { bodyMapper: Mappers.CloudError } }, serializer }; const listNextOperationSpec: msRest.OperationSpec = { httpMethod: "GET", baseUrl: "https://management.azure.com", path: "{nextLink}", urlParameters: [ Parameters.nextPageLink ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.SnapshotList }, default: { bodyMapper: Mappers.CloudError } }, serializer };