/* * 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/disksMappers"; import * as Parameters from "../models/parameters"; import { ComputeManagementClientContext } from "../computeManagementClientContext"; /** Class representing a Disks. */ export class Disks { private readonly client: ComputeManagementClientContext; /** * Create a Disks. * @param {ComputeManagementClientContext} client Reference to the service client. */ constructor(client: ComputeManagementClientContext) { this.client = client; } /** * Creates or updates a disk. * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param disk Disk object supplied in the body of the Put disk operation. * @param [options] The optional parameters * @returns Promise */ createOrUpdate(resourceGroupName: string, diskName: string, disk: Models.Disk, options?: msRest.RequestOptionsBase): Promise { return this.beginCreateOrUpdate(resourceGroupName,diskName,disk,options) .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; } /** * Updates (patches) a disk. * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param disk Disk object supplied in the body of the Patch disk operation. * @param [options] The optional parameters * @returns Promise */ update(resourceGroupName: string, diskName: string, disk: Models.DiskUpdate, options?: msRest.RequestOptionsBase): Promise { return this.beginUpdate(resourceGroupName,diskName,disk,options) .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; } /** * Gets information about a disk. * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param [options] The optional parameters * @returns Promise */ get(resourceGroupName: string, diskName: string, options?: msRest.RequestOptionsBase): Promise; /** * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param callback The callback */ get(resourceGroupName: string, diskName: string, callback: msRest.ServiceCallback): void; /** * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param options The optional parameters * @param callback The callback */ get(resourceGroupName: string, diskName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; get(resourceGroupName: string, diskName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { resourceGroupName, diskName, options }, getOperationSpec, callback) as Promise; } /** * Deletes a disk. * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param [options] The optional parameters * @returns Promise */ deleteMethod(resourceGroupName: string, diskName: string, options?: msRest.RequestOptionsBase): Promise { return this.beginDeleteMethod(resourceGroupName,diskName,options) .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; } /** * Lists all the disks 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 all the disks 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 disk. * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param grantAccessData Access data object supplied in the body of the get disk access operation. * @param [options] The optional parameters * @returns Promise */ grantAccess(resourceGroupName: string, diskName: string, grantAccessData: Models.GrantAccessData, options?: msRest.RequestOptionsBase): Promise { return this.beginGrantAccess(resourceGroupName,diskName,grantAccessData,options) .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; } /** * Revokes access to a disk. * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param [options] The optional parameters * @returns Promise */ revokeAccess(resourceGroupName: string, diskName: string, options?: msRest.RequestOptionsBase): Promise { return this.beginRevokeAccess(resourceGroupName,diskName,options) .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; } /** * Creates or updates a disk. * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param disk Disk object supplied in the body of the Put disk operation. * @param [options] The optional parameters * @returns Promise */ beginCreateOrUpdate(resourceGroupName: string, diskName: string, disk: Models.Disk, options?: msRest.RequestOptionsBase): Promise { return this.client.sendLRORequest( { resourceGroupName, diskName, disk, options }, beginCreateOrUpdateOperationSpec, options); } /** * Updates (patches) a disk. * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param disk Disk object supplied in the body of the Patch disk operation. * @param [options] The optional parameters * @returns Promise */ beginUpdate(resourceGroupName: string, diskName: string, disk: Models.DiskUpdate, options?: msRest.RequestOptionsBase): Promise { return this.client.sendLRORequest( { resourceGroupName, diskName, disk, options }, beginUpdateOperationSpec, options); } /** * Deletes a disk. * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param [options] The optional parameters * @returns Promise */ beginDeleteMethod(resourceGroupName: string, diskName: string, options?: msRest.RequestOptionsBase): Promise { return this.client.sendLRORequest( { resourceGroupName, diskName, options }, beginDeleteMethodOperationSpec, options); } /** * Grants access to a disk. * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param grantAccessData Access data object supplied in the body of the get disk access operation. * @param [options] The optional parameters * @returns Promise */ beginGrantAccess(resourceGroupName: string, diskName: string, grantAccessData: Models.GrantAccessData, options?: msRest.RequestOptionsBase): Promise { return this.client.sendLRORequest( { resourceGroupName, diskName, grantAccessData, options }, beginGrantAccessOperationSpec, options); } /** * Revokes access to a disk. * @param resourceGroupName The name of the resource group. * @param diskName The name of the managed disk that is being created. The name can't be changed * after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The * maximum name length is 80 characters. * @param [options] The optional parameters * @returns Promise */ beginRevokeAccess(resourceGroupName: string, diskName: string, options?: msRest.RequestOptionsBase): Promise { return this.client.sendLRORequest( { resourceGroupName, diskName, options }, beginRevokeAccessOperationSpec, options); } /** * Lists all the disks 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 all the disks 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/disks/{diskName}", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.diskName ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.Disk }, default: { bodyMapper: Mappers.CloudError } }, serializer }; const listByResourceGroupOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.DiskList }, default: { bodyMapper: Mappers.CloudError } }, serializer }; const listOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks", urlParameters: [ Parameters.subscriptionId ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], responses: { 200: { bodyMapper: Mappers.DiskList }, default: { bodyMapper: Mappers.CloudError } }, serializer }; const beginCreateOrUpdateOperationSpec: msRest.OperationSpec = { httpMethod: "PUT", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.diskName ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: "disk", mapper: { ...Mappers.Disk, required: true } }, responses: { 200: { bodyMapper: Mappers.Disk }, 202: { bodyMapper: Mappers.Disk }, default: { bodyMapper: Mappers.CloudError } }, serializer }; const beginUpdateOperationSpec: msRest.OperationSpec = { httpMethod: "PATCH", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.diskName ], queryParameters: [ Parameters.apiVersion1 ], headerParameters: [ Parameters.acceptLanguage ], requestBody: { parameterPath: "disk", mapper: { ...Mappers.DiskUpdate, required: true } }, responses: { 200: { bodyMapper: Mappers.Disk }, 202: { bodyMapper: Mappers.Disk }, default: { bodyMapper: Mappers.CloudError } }, serializer }; const beginDeleteMethodOperationSpec: msRest.OperationSpec = { httpMethod: "DELETE", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.diskName ], 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/disks/{diskName}/beginGetAccess", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.diskName ], 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/disks/{diskName}/endGetAccess", urlParameters: [ Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.diskName ], 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.DiskList }, 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.DiskList }, default: { bodyMapper: Mappers.CloudError } }, serializer };