Class v1.DisksClient (4.3.0)

The Disks API. v1

Package

@google-cloud/compute

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?:ClientOptions,gaxInstance?:typeofgax|typeofgax.fallback);

Construct an instance of DisksClient.

Parameters
NameDescription
optsClientOptions
gaxInstancetypeofgax | typeoffallback

: loaded instance ofgoogle-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new DisksClient({fallback: true}, gax); ```

Properties

apiEndpoint

getapiEndpoint():string;

The DNS address for this API service.

apiEndpoint

staticgetapiEndpoint():string;

The DNS address for this API service - same as servicePath.

auth

auth:gax.GoogleAuth;

descriptors

descriptors:Descriptors;

disksStub

disksStub?:Promise<{[name:string]:Function;}>;

innerApiCalls

innerApiCalls:{[name:string]:Function;};

port

staticgetport():number;

The port for this API service.

scopes

staticgetscopes():string[];

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

staticgetservicePath():string;

The DNS address for this API service.

universeDomain

getuniverseDomain():string;

warn

warn:(code:string,message:string,warnType?:string)=>void;

Methods

addResourcePolicies(request, options)

addResourcePolicies(request?:protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest,options?:CallOptions):Promise<[LROperation<protos.google.cloud.compute.v1.IOperation,null>,protos.google.cloud.compute.v1.IOperation|undefined,{}|undefined]>;

Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation.

Parameters
NameDescription
requestIAddResourcePoliciesDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[LROperation<protos.google.cloud.compute.v1.IOperation, null>,protos.google.cloud.compute.v1.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Please see thedocumentation for more details and examples. This method is considered to be in beta. This means while stable it is still a work-in-progress and under active development, and might get backwards-incompatible changes at any time..promise() is not supported yet.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  The disk name for this request.   */// const disk = 'abc123'/**   *  The body resource for this request   */// const disksAddResourcePoliciesRequestResource = {}/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).   */// const requestId = 'abc123'/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallAddResourcePolicies(){// Construct requestconstrequest={disk,disksAddResourcePoliciesRequestResource,project,zone,};// Run requestconstresponse=awaitcomputeClient.addResourcePolicies(request);console.log(response);}callAddResourcePolicies();

addResourcePolicies(request, options, callback)

addResourcePolicies(request:protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIAddResourcePoliciesDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

addResourcePolicies(request, callback)

addResourcePolicies(request:protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIAddResourcePoliciesDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IAddResourcePoliciesDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

aggregatedListAsync(request, options)

aggregatedListAsync(request?:protos.google.cloud.compute.v1.IAggregatedListDisksRequest,options?:CallOptions):AsyncIterable<[string,protos.google.cloud.compute.v1.IDisksScopedList]>;

Retrieves an aggregated list of persistent disks. To prevent failure, Google recommends that you set thereturnPartialSuccess parameter totrue.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
requestIAggregatedListDisksRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
AsyncIterable<[string,protos.google.cloud.compute.v1.IDisksScopedList]>

{Object} An iterable Object that allowsasync iteration. When you iterate the returned iterable, each element will be an object representing as tuple [string,DisksScopedList]. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see thedocumentation for more details and examples.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//***Afilterexpressionthatfiltersresourceslistedintheresponse.MostComputeresourcessupporttwotypesoffilterexpressions:expressionsthatsupportregularexpressionsandexpressionsthatfollowAPIimprovementproposalAIP-160.Thesetwotypesoffilterexpressionscannotbemixedinonerequest.IfyouwanttouseAIP-160,yourexpressionmustspecifythefieldname,anoperator,andthevaluethatyouwanttouseforfiltering.Thevaluemustbeastring,anumber,oraboolean.Theoperatormustbeeither`=`,`!=`,`>`,`<`,><=`, `="">=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name!=example-instance`. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use:
 labels.owner:*
You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example:
(scheduling.automaticRestart=true)(cpuPlatform="Intel Skylake")
By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example:
(cpuPlatform="Intel Skylake")OR(cpuPlatform="Intel Broadwell")AND(scheduling.automaticRestart=true)
If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. You cannot combine constraints on multiple fields using regular expressions.

/ // const filter = 'abc123' /*

  • Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included./// const includeAllScopes = true/*
  • The maximum number of results per page that should be returned. If the number of available results is larger thanmaxResults, Compute Engine returns anextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are0 to500, inclusive. (Default:500)/// const maxResults = 1234/*
  • Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp usingorderBy="creationTimestamp desc". This sorts results based on thecreationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting byname orcreationTimestamp desc is supported./// const orderBy = 'abc123'/*
  • Specifies a page token to use. SetpageToken to thenextPageToken returned by a previous list request to get the next page of results./// const pageToken = 'abc123'/*
  • Project ID for this request./// const project = 'my-project'/*
  • Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. For example, when partial success behavior is enabled, aggregatedList for a single zone scope either returns all resources in the zone or no resources, with an error code./// const returnPartialSuccess = true/*
  • The Shared VPC service project id or service project number for which aggregated list request is invoked for subnetworks list-usable api.*/// const serviceProjectNumber = 1234

    // Imports the Compute libraryconst {DisksClient} = require('@google-cloud/compute').v1;

    // Instantiates a clientconst computeClient = new DisksClient();

    async function callAggregatedList() {// Construct requestconst request = {project,};

    // Run requestconst iterable = computeClient.aggregatedListAsync(request);for await (const [key, value] of iterable) { console.log(response);}}

    callAggregatedList();

bulkInsert(request, options)

bulkInsert(request?:protos.google.cloud.compute.v1.IBulkInsertDiskRequest,options?:CallOptions):Promise<[LROperation<protos.google.cloud.compute.v1.IOperation,null>,protos.google.cloud.compute.v1.IOperation|undefined,{}|undefined]>;

Bulk create a set of disks.

Parameters
NameDescription
requestIBulkInsertDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[LROperation<protos.google.cloud.compute.v1.IOperation, null>,protos.google.cloud.compute.v1.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Please see thedocumentation for more details and examples. This method is considered to be in beta. This means while stable it is still a work-in-progress and under active development, and might get backwards-incompatible changes at any time..promise() is not supported yet.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  The body resource for this request   */// const bulkInsertDiskResourceResource = {}/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).   */// const requestId = 'abc123'/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallBulkInsert(){// Construct requestconstrequest={bulkInsertDiskResourceResource,project,zone,};// Run requestconstresponse=awaitcomputeClient.bulkInsert(request);console.log(response);}callBulkInsert();

bulkInsert(request, options, callback)

bulkInsert(request:protos.google.cloud.compute.v1.IBulkInsertDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IBulkInsertDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIBulkInsertDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IBulkInsertDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

bulkInsert(request, callback)

bulkInsert(request:protos.google.cloud.compute.v1.IBulkInsertDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IBulkInsertDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIBulkInsertDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IBulkInsertDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

close()

close():Promise<void>;

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns
TypeDescription
Promise<void>

{Promise} A promise that resolves when the client is closed.

createSnapshot(request, options)

createSnapshot(request?:protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest,options?:CallOptions):Promise<[LROperation<protos.google.cloud.compute.v1.IOperation,null>,protos.google.cloud.compute.v1.IOperation|undefined,{}|undefined]>;

Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project.

Parameters
NameDescription
requestICreateSnapshotDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[LROperation<protos.google.cloud.compute.v1.IOperation, null>,protos.google.cloud.compute.v1.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Please see thedocumentation for more details and examples. This method is considered to be in beta. This means while stable it is still a work-in-progress and under active development, and might get backwards-incompatible changes at any time..promise() is not supported yet.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  Name of the persistent disk to snapshot.   */// const disk = 'abc123'/**   *  Input Only  Whether to attempt an application consistent snapshot by informing the OS to prepare for the snapshot process.   */// const guestFlush = true/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).   */// const requestId = 'abc123'/**   *  The body resource for this request   */// const snapshotResource = {}/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallCreateSnapshot(){// Construct requestconstrequest={disk,project,snapshotResource,zone,};// Run requestconstresponse=awaitcomputeClient.createSnapshot(request);console.log(response);}callCreateSnapshot();

createSnapshot(request, options, callback)

createSnapshot(request:protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestICreateSnapshotDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createSnapshot(request, callback)

createSnapshot(request:protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestICreateSnapshotDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.ICreateSnapshotDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

delete(request, options)

delete(request?:protos.google.cloud.compute.v1.IDeleteDiskRequest,options?:CallOptions):Promise<[LROperation<protos.google.cloud.compute.v1.IOperation,null>,protos.google.cloud.compute.v1.IOperation|undefined,{}|undefined]>;

Deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots.

Parameters
NameDescription
requestIDeleteDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[LROperation<protos.google.cloud.compute.v1.IOperation, null>,protos.google.cloud.compute.v1.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Please see thedocumentation for more details and examples. This method is considered to be in beta. This means while stable it is still a work-in-progress and under active development, and might get backwards-incompatible changes at any time..promise() is not supported yet.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  Name of the persistent disk to delete.   */// const disk = 'abc123'/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).   */// const requestId = 'abc123'/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallDelete(){// Construct requestconstrequest={disk,project,zone,};// Run requestconstresponse=awaitcomputeClient.delete(request);console.log(response);}callDelete();

delete(request, options, callback)

delete(request:protos.google.cloud.compute.v1.IDeleteDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IDeleteDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIDeleteDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IDeleteDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

delete(request, callback)

delete(request:protos.google.cloud.compute.v1.IDeleteDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IDeleteDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIDeleteDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IDeleteDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

get(request, options)

get(request?:protos.google.cloud.compute.v1.IGetDiskRequest,options?:CallOptions):Promise<[protos.google.cloud.compute.v1.IDisk,protos.google.cloud.compute.v1.IGetDiskRequest|undefined,{}|undefined]>;

Returns the specified persistent disk.

Parameters
NameDescription
requestIGetDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.compute.v1.IDisk,protos.google.cloud.compute.v1.IGetDiskRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see thedocumentation for more details and examples.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  Name of the persistent disk to return.   */// const disk = 'abc123'/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallGet(){// Construct requestconstrequest={disk,project,zone,};// Run requestconstresponse=awaitcomputeClient.get(request);console.log(response);}callGet();

get(request, options, callback)

get(request:protos.google.cloud.compute.v1.IGetDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IDisk,protos.google.cloud.compute.v1.IGetDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIGetDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IDisk,protos.google.cloud.compute.v1.IGetDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

get(request, callback)

get(request:protos.google.cloud.compute.v1.IGetDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IDisk,protos.google.cloud.compute.v1.IGetDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIGetDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IDisk,protos.google.cloud.compute.v1.IGetDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getIamPolicy(request, options)

getIamPolicy(request?:protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest,options?:CallOptions):Promise<[protos.google.cloud.compute.v1.IPolicy,protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest|undefined,{}|undefined]>;

Gets the access control policy for a resource. May be empty if no such policy or resource exists.

Parameters
NameDescription
requestIGetIamPolicyDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.compute.v1.IPolicy,protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representingPolicy. Please see thedocumentation for more details and examples.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  Requested IAM Policy version.   */// const optionsRequestedPolicyVersion = 1234/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  Name or id of the resource for this request.   */// const resource = 'abc123'/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallGetIamPolicy(){// Construct requestconstrequest={project,resource,zone,};// Run requestconstresponse=awaitcomputeClient.getIamPolicy(request);console.log(response);}callGetIamPolicy();

getIamPolicy(request, options, callback)

getIamPolicy(request:protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IPolicy,protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIGetIamPolicyDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IPolicy,protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getIamPolicy(request, callback)

getIamPolicy(request:protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IPolicy,protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIGetIamPolicyDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IPolicy,protos.google.cloud.compute.v1.IGetIamPolicyDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getProjectId()

getProjectId():Promise<string>;
Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback:Callback<string,undefined,undefined>):void;
Parameter
NameDescription
callbackCallback<string, undefined, undefined>
Returns
TypeDescription
void

initialize()

initialize():Promise<{[name:string]:Function;}>;

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns
TypeDescription
Promise<{ [name: string]:Function; }>

{Promise} A promise that resolves to an authenticated service stub.

insert(request, options)

insert(request?:protos.google.cloud.compute.v1.IInsertDiskRequest,options?:CallOptions):Promise<[LROperation<protos.google.cloud.compute.v1.IOperation,null>,protos.google.cloud.compute.v1.IOperation|undefined,{}|undefined]>;

Creates a persistent disk in the specified project using the data in the request. You can create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500 GB data disk by omitting all properties. You can also create a disk that is larger than the default size by specifying the sizeGb property.

Parameters
NameDescription
requestIInsertDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[LROperation<protos.google.cloud.compute.v1.IOperation, null>,protos.google.cloud.compute.v1.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Please see thedocumentation for more details and examples. This method is considered to be in beta. This means while stable it is still a work-in-progress and under active development, and might get backwards-incompatible changes at any time..promise() is not supported yet.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  The body resource for this request   */// const diskResource = {}/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).   */// const requestId = 'abc123'/**   *  Source image to restore onto a disk. This field is optional.   */// const sourceImage = 'abc123'/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallInsert(){// Construct requestconstrequest={diskResource,project,zone,};// Run requestconstresponse=awaitcomputeClient.insert(request);console.log(response);}callInsert();

insert(request, options, callback)

insert(request:protos.google.cloud.compute.v1.IInsertDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IInsertDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIInsertDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IInsertDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

insert(request, callback)

insert(request:protos.google.cloud.compute.v1.IInsertDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IInsertDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIInsertDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IInsertDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

list(request, options)

list(request?:protos.google.cloud.compute.v1.IListDisksRequest,options?:CallOptions):Promise<[protos.google.cloud.compute.v1.IDisk[],protos.google.cloud.compute.v1.IListDisksRequest|null,protos.google.cloud.compute.v1.IDiskList]>;

Retrieves a list of persistent disks contained within the specified zone.

Parameters
NameDescription
requestIListDisksRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.compute.v1.IDisk[],protos.google.cloud.compute.v1.IListDisksRequest | null,protos.google.cloud.compute.v1.IDiskList ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend usinglistAsync() method described below for async iteration which you can stop as needed. Please see thedocumentation for more details and examples.

list(request, options, callback)

list(request:protos.google.cloud.compute.v1.IListDisksRequest,options:CallOptions,callback:PaginationCallback<protos.google.cloud.compute.v1.IListDisksRequest,protos.google.cloud.compute.v1.IDiskList|null|undefined,protos.google.cloud.compute.v1.IDisk>):void;
Parameters
NameDescription
requestIListDisksRequest
optionsCallOptions
callbackPaginationCallback<protos.google.cloud.compute.v1.IListDisksRequest,protos.google.cloud.compute.v1.IDiskList | null | undefined,protos.google.cloud.compute.v1.IDisk>
Returns
TypeDescription
void

list(request, callback)

list(request:protos.google.cloud.compute.v1.IListDisksRequest,callback:PaginationCallback<protos.google.cloud.compute.v1.IListDisksRequest,protos.google.cloud.compute.v1.IDiskList|null|undefined,protos.google.cloud.compute.v1.IDisk>):void;
Parameters
NameDescription
requestIListDisksRequest
callbackPaginationCallback<protos.google.cloud.compute.v1.IListDisksRequest,protos.google.cloud.compute.v1.IDiskList | null | undefined,protos.google.cloud.compute.v1.IDisk>
Returns
TypeDescription
void

listAsync(request, options)

listAsync(request?:protos.google.cloud.compute.v1.IListDisksRequest,options?:CallOptions):AsyncIterable<protos.google.cloud.compute.v1.IDisk>;

Equivalent tolist, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
requestIListDisksRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.compute.v1.IDisk>

{Object} An iterable Object that allowsasync iteration. When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see thedocumentation for more details and examples.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//***Afilterexpressionthatfiltersresourceslistedintheresponse.MostComputeresourcessupporttwotypesoffilterexpressions:expressionsthatsupportregularexpressionsandexpressionsthatfollowAPIimprovementproposalAIP-160.Thesetwotypesoffilterexpressionscannotbemixedinonerequest.IfyouwanttouseAIP-160,yourexpressionmustspecifythefieldname,anoperator,andthevaluethatyouwanttouseforfiltering.Thevaluemustbeastring,anumber,oraboolean.Theoperatormustbeeither`=`,`!=`,`>`,`<`,><=`, `="">=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name!=example-instance`. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use:
 labels.owner:*
You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example:
(scheduling.automaticRestart=true)(cpuPlatform="Intel Skylake")
By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example:
(cpuPlatform="Intel Skylake")OR(cpuPlatform="Intel Broadwell")AND(scheduling.automaticRestart=true)
If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. You cannot combine constraints on multiple fields using regular expressions.

/ // const filter = 'abc123' /*

  • The maximum number of results per page that should be returned. If the number of available results is larger thanmaxResults, Compute Engine returns anextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are0 to500, inclusive. (Default:500)/// const maxResults = 1234/*
  • Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp usingorderBy="creationTimestamp desc". This sorts results based on thecreationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting byname orcreationTimestamp desc is supported./// const orderBy = 'abc123'/*
  • Specifies a page token to use. SetpageToken to thenextPageToken returned by a previous list request to get the next page of results./// const pageToken = 'abc123'/*
  • Project ID for this request./// const project = 'my-project'/*
  • Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. For example, when partial success behavior is enabled, aggregatedList for a single zone scope either returns all resources in the zone or no resources, with an error code./// const returnPartialSuccess = true/*
  • The name of the zone for this request.*/// const zone = 'abc123'

    // Imports the Compute libraryconst {DisksClient} = require('@google-cloud/compute').v1;

    // Instantiates a clientconst computeClient = new DisksClient();

    async function callList() {// Construct requestconst request = {project,zone,};

    // Run requestconst iterable = computeClient.listAsync(request);for await (const response of iterable) { console.log(response);}}

    callList();

listStream(request, options)

listStream(request?:protos.google.cloud.compute.v1.IListDisksRequest,options?:CallOptions):Transform;

Equivalent tomethod.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
requestIListDisksRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend usinglistAsync() method described below for async iteration which you can stop as needed. Please see thedocumentation for more details and examples.

removeResourcePolicies(request, options)

removeResourcePolicies(request?:protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest,options?:CallOptions):Promise<[LROperation<protos.google.cloud.compute.v1.IOperation,null>,protos.google.cloud.compute.v1.IOperation|undefined,{}|undefined]>;

Removes resource policies from a disk.

Parameters
NameDescription
requestIRemoveResourcePoliciesDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[LROperation<protos.google.cloud.compute.v1.IOperation, null>,protos.google.cloud.compute.v1.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Please see thedocumentation for more details and examples. This method is considered to be in beta. This means while stable it is still a work-in-progress and under active development, and might get backwards-incompatible changes at any time..promise() is not supported yet.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  The disk name for this request.   */// const disk = 'abc123'/**   *  The body resource for this request   */// const disksRemoveResourcePoliciesRequestResource = {}/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).   */// const requestId = 'abc123'/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallRemoveResourcePolicies(){// Construct requestconstrequest={disk,disksRemoveResourcePoliciesRequestResource,project,zone,};// Run requestconstresponse=awaitcomputeClient.removeResourcePolicies(request);console.log(response);}callRemoveResourcePolicies();

removeResourcePolicies(request, options, callback)

removeResourcePolicies(request:protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIRemoveResourcePoliciesDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

removeResourcePolicies(request, callback)

removeResourcePolicies(request:protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIRemoveResourcePoliciesDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IRemoveResourcePoliciesDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

resize(request, options)

resize(request?:protos.google.cloud.compute.v1.IResizeDiskRequest,options?:CallOptions):Promise<[LROperation<protos.google.cloud.compute.v1.IOperation,null>,protos.google.cloud.compute.v1.IOperation|undefined,{}|undefined]>;

Resizes the specified persistent disk. You can only increase the size of the disk.

Parameters
NameDescription
requestIResizeDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[LROperation<protos.google.cloud.compute.v1.IOperation, null>,protos.google.cloud.compute.v1.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Please see thedocumentation for more details and examples. This method is considered to be in beta. This means while stable it is still a work-in-progress and under active development, and might get backwards-incompatible changes at any time..promise() is not supported yet.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  The name of the persistent disk.   */// const disk = 'abc123'/**   *  The body resource for this request   */// const disksResizeRequestResource = {}/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).   */// const requestId = 'abc123'/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallResize(){// Construct requestconstrequest={disk,disksResizeRequestResource,project,zone,};// Run requestconstresponse=awaitcomputeClient.resize(request);console.log(response);}callResize();

resize(request, options, callback)

resize(request:protos.google.cloud.compute.v1.IResizeDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IResizeDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIResizeDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IResizeDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

resize(request, callback)

resize(request:protos.google.cloud.compute.v1.IResizeDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IResizeDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIResizeDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IResizeDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

setIamPolicy(request, options)

setIamPolicy(request?:protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest,options?:CallOptions):Promise<[protos.google.cloud.compute.v1.IPolicy,protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest|undefined,{}|undefined]>;

Sets the access control policy on the specified resource. Replaces any existing policy.

Parameters
NameDescription
requestISetIamPolicyDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.compute.v1.IPolicy,protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representingPolicy. Please see thedocumentation for more details and examples.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  Project ID for this request.   */// const project = 'my-project'/**   *  Name or id of the resource for this request.   */// const resource = 'abc123'/**   *  The name of the zone for this request.   */// const zone = 'abc123'/**   *  The body resource for this request   */// const zoneSetPolicyRequestResource = {}// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallSetIamPolicy(){// Construct requestconstrequest={project,resource,zone,zoneSetPolicyRequestResource,};// Run requestconstresponse=awaitcomputeClient.setIamPolicy(request);console.log(response);}callSetIamPolicy();

setIamPolicy(request, options, callback)

setIamPolicy(request:protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IPolicy,protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestISetIamPolicyDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IPolicy,protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

setIamPolicy(request, callback)

setIamPolicy(request:protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IPolicy,protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestISetIamPolicyDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IPolicy,protos.google.cloud.compute.v1.ISetIamPolicyDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

setLabels(request, options)

setLabels(request?:protos.google.cloud.compute.v1.ISetLabelsDiskRequest,options?:CallOptions):Promise<[LROperation<protos.google.cloud.compute.v1.IOperation,null>,protos.google.cloud.compute.v1.IOperation|undefined,{}|undefined]>;

Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation.

Parameters
NameDescription
requestISetLabelsDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[LROperation<protos.google.cloud.compute.v1.IOperation, null>,protos.google.cloud.compute.v1.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Please see thedocumentation for more details and examples. This method is considered to be in beta. This means while stable it is still a work-in-progress and under active development, and might get backwards-incompatible changes at any time..promise() is not supported yet.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  Project ID for this request.   */// const project = 'my-project'/**   *  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).   */// const requestId = 'abc123'/**   *  Name or id of the resource for this request.   */// const resource = 'abc123'/**   *  The name of the zone for this request.   */// const zone = 'abc123'/**   *  The body resource for this request   */// const zoneSetLabelsRequestResource = {}// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallSetLabels(){// Construct requestconstrequest={project,resource,zone,zoneSetLabelsRequestResource,};// Run requestconstresponse=awaitcomputeClient.setLabels(request);console.log(response);}callSetLabels();

setLabels(request, options, callback)

setLabels(request:protos.google.cloud.compute.v1.ISetLabelsDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.ISetLabelsDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestISetLabelsDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.ISetLabelsDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

setLabels(request, callback)

setLabels(request:protos.google.cloud.compute.v1.ISetLabelsDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.ISetLabelsDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestISetLabelsDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.ISetLabelsDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

startAsyncReplication(request, options)

startAsyncReplication(request?:protos.google.cloud.compute.v1.IStartAsyncReplicationDiskRequest,options?:CallOptions):Promise<[LROperation<protos.google.cloud.compute.v1.IOperation,null>,protos.google.cloud.compute.v1.IOperation|undefined,{}|undefined]>;

Starts asynchronous replication. Must be invoked on the primary disk.

Parameters
NameDescription
requestIStartAsyncReplicationDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[LROperation<protos.google.cloud.compute.v1.IOperation, null>,protos.google.cloud.compute.v1.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Please see thedocumentation for more details and examples. This method is considered to be in beta. This means while stable it is still a work-in-progress and under active development, and might get backwards-incompatible changes at any time..promise() is not supported yet.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  The name of the persistent disk.   */// const disk = 'abc123'/**   *  The body resource for this request   */// const disksStartAsyncReplicationRequestResource = {}/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).   */// const requestId = 'abc123'/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallStartAsyncReplication(){// Construct requestconstrequest={disk,disksStartAsyncReplicationRequestResource,project,zone,};// Run requestconstresponse=awaitcomputeClient.startAsyncReplication(request);console.log(response);}callStartAsyncReplication();

startAsyncReplication(request, options, callback)

startAsyncReplication(request:protos.google.cloud.compute.v1.IStartAsyncReplicationDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IStartAsyncReplicationDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIStartAsyncReplicationDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IStartAsyncReplicationDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

startAsyncReplication(request, callback)

startAsyncReplication(request:protos.google.cloud.compute.v1.IStartAsyncReplicationDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IStartAsyncReplicationDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIStartAsyncReplicationDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IStartAsyncReplicationDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

stopAsyncReplication(request, options)

stopAsyncReplication(request?:protos.google.cloud.compute.v1.IStopAsyncReplicationDiskRequest,options?:CallOptions):Promise<[LROperation<protos.google.cloud.compute.v1.IOperation,null>,protos.google.cloud.compute.v1.IOperation|undefined,{}|undefined]>;

Stops asynchronous replication. Can be invoked either on the primary or on the secondary disk.

Parameters
NameDescription
requestIStopAsyncReplicationDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[LROperation<protos.google.cloud.compute.v1.IOperation, null>,protos.google.cloud.compute.v1.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Please see thedocumentation for more details and examples. This method is considered to be in beta. This means while stable it is still a work-in-progress and under active development, and might get backwards-incompatible changes at any time..promise() is not supported yet.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  The name of the persistent disk.   */// const disk = 'abc123'/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).   */// const requestId = 'abc123'/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallStopAsyncReplication(){// Construct requestconstrequest={disk,project,zone,};// Run requestconstresponse=awaitcomputeClient.stopAsyncReplication(request);console.log(response);}callStopAsyncReplication();

stopAsyncReplication(request, options, callback)

stopAsyncReplication(request:protos.google.cloud.compute.v1.IStopAsyncReplicationDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IStopAsyncReplicationDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIStopAsyncReplicationDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IStopAsyncReplicationDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

stopAsyncReplication(request, callback)

stopAsyncReplication(request:protos.google.cloud.compute.v1.IStopAsyncReplicationDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IStopAsyncReplicationDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIStopAsyncReplicationDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IStopAsyncReplicationDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

stopGroupAsyncReplication(request, options)

stopGroupAsyncReplication(request?:protos.google.cloud.compute.v1.IStopGroupAsyncReplicationDiskRequest,options?:CallOptions):Promise<[LROperation<protos.google.cloud.compute.v1.IOperation,null>,protos.google.cloud.compute.v1.IOperation|undefined,{}|undefined]>;

Stops asynchronous replication for a consistency group of disks. Can be invoked either in the primary or secondary scope.

Parameters
NameDescription
requestIStopGroupAsyncReplicationDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[LROperation<protos.google.cloud.compute.v1.IOperation, null>,protos.google.cloud.compute.v1.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Please see thedocumentation for more details and examples. This method is considered to be in beta. This means while stable it is still a work-in-progress and under active development, and might get backwards-incompatible changes at any time..promise() is not supported yet.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  The body resource for this request   */// const disksStopGroupAsyncReplicationResourceResource = {}/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).   */// const requestId = 'abc123'/**   *  The name of the zone for this request. This must be the zone of the primary or secondary disks in the consistency group.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallStopGroupAsyncReplication(){// Construct requestconstrequest={disksStopGroupAsyncReplicationResourceResource,project,zone,};// Run requestconstresponse=awaitcomputeClient.stopGroupAsyncReplication(request);console.log(response);}callStopGroupAsyncReplication();

stopGroupAsyncReplication(request, options, callback)

stopGroupAsyncReplication(request:protos.google.cloud.compute.v1.IStopGroupAsyncReplicationDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IStopGroupAsyncReplicationDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIStopGroupAsyncReplicationDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IStopGroupAsyncReplicationDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

stopGroupAsyncReplication(request, callback)

stopGroupAsyncReplication(request:protos.google.cloud.compute.v1.IStopGroupAsyncReplicationDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IStopGroupAsyncReplicationDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIStopGroupAsyncReplicationDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IStopGroupAsyncReplicationDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

testIamPermissions(request, options)

testIamPermissions(request?:protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest,options?:CallOptions):Promise<[protos.google.cloud.compute.v1.ITestPermissionsResponse,protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest|undefined,{}|undefined]>;

Returns permissions that a caller has on the specified resource.

Parameters
NameDescription
requestITestIamPermissionsDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.compute.v1.ITestPermissionsResponse,protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representingTestPermissionsResponse. Please see thedocumentation for more details and examples.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  Project ID for this request.   */// const project = 'my-project'/**   *  Name or id of the resource for this request.   */// const resource = 'abc123'/**   *  The body resource for this request   */// const testPermissionsRequestResource = {}/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallTestIamPermissions(){// Construct requestconstrequest={project,resource,testPermissionsRequestResource,zone,};// Run requestconstresponse=awaitcomputeClient.testIamPermissions(request);console.log(response);}callTestIamPermissions();

testIamPermissions(request, options, callback)

testIamPermissions(request:protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.ITestPermissionsResponse,protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestITestIamPermissionsDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.ITestPermissionsResponse,protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

testIamPermissions(request, callback)

testIamPermissions(request:protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest,callback:Callback<protos.google.cloud.compute.v1.ITestPermissionsResponse,protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestITestIamPermissionsDiskRequest
callbackCallback<protos.google.cloud.compute.v1.ITestPermissionsResponse,protos.google.cloud.compute.v1.ITestIamPermissionsDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

update(request, options)

update(request?:protos.google.cloud.compute.v1.IUpdateDiskRequest,options?:CallOptions):Promise<[LROperation<protos.google.cloud.compute.v1.IOperation,null>,protos.google.cloud.compute.v1.IOperation|undefined,{}|undefined]>;

Updates the specified disk with the data included in the request. The update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license.

Parameters
NameDescription
requestIUpdateDiskRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[LROperation<protos.google.cloud.compute.v1.IOperation, null>,protos.google.cloud.compute.v1.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Please see thedocumentation for more details and examples. This method is considered to be in beta. This means while stable it is still a work-in-progress and under active development, and might get backwards-incompatible changes at any time..promise() is not supported yet.

Example
/**   * This snippet has been automatically generated and should be regarded as a code template only.   * It will require modifications to work.   * It may require correct/in-range values for request initialization.   * TODO(developer): Uncomment these variables before running the sample.   *//**   *  The disk name for this request.   */// const disk = 'abc123'/**   *  The body resource for this request   */// const diskResource = {}/**   */// const paths = 'abc123'/**   *  Project ID for this request.   */// const project = 'my-project'/**   *  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).   */// const requestId = 'abc123'/**   *  update_mask indicates fields to be updated as part of this request.   */// const updateMask = 'abc123'/**   *  The name of the zone for this request.   */// const zone = 'abc123'// Imports the Compute libraryconst{DisksClient}=require('@google-cloud/compute').v1;// Instantiates a clientconstcomputeClient=newDisksClient();asyncfunctioncallUpdate(){// Construct requestconstrequest={disk,diskResource,project,zone,};// Run requestconstresponse=awaitcomputeClient.update(request);console.log(response);}callUpdate();

update(request, options, callback)

update(request:protos.google.cloud.compute.v1.IUpdateDiskRequest,options:CallOptions,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IUpdateDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIUpdateDiskRequest
optionsCallOptions
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IUpdateDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

update(request, callback)

update(request:protos.google.cloud.compute.v1.IUpdateDiskRequest,callback:Callback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IUpdateDiskRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestIUpdateDiskRequest
callbackCallback<protos.google.cloud.compute.v1.IOperation,protos.google.cloud.compute.v1.IUpdateDiskRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-03 UTC.