Class v1.SqlDatabasesServiceClient (0.13.0)

Service to manage databases. v1

Package

@google-cloud/sql

Constructors

(constructor)(opts, gaxInstance)

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

Construct an instance of SqlDatabasesServiceClient.

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 SqlDatabasesServiceClient({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;

innerApiCalls

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

locationsClient

locationsClient:LocationsClient;

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.

sqlDatabasesServiceStub

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

universeDomain

getuniverseDomain():string;

warn

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

Methods

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.

delete(request, options)

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

Deletes a database from a Cloud SQL instance.

Parameters
NameDescription
requestISqlDatabasesDeleteRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.sql.v1.IOperation,protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest | 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 database to be deleted in the instance.   */// const database = 'abc123'/**   *  Database instance ID. This does not include the project ID.   */// const instance = 'abc123'/**   *  Project ID of the project that contains the instance.   */// const project = 'my-project'// Imports the Sql libraryconst{SqlDatabasesServiceClient}=require('@google-cloud/sql').v1;// Instantiates a clientconstsqlClient=newSqlDatabasesServiceClient();asyncfunctioncallDelete(){// Construct requestconstrequest={};// Run requestconstresponse=awaitsqlClient.delete(request);console.log(response);}callDelete();

delete(request, options, callback)

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

delete(request, callback)

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

get(request, options)

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

Retrieves a resource containing information about a database inside a Cloud SQL instance.

Parameters
NameDescription
requestISqlDatabasesGetRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.sql.v1.IDatabase,protos.google.cloud.sql.v1.ISqlDatabasesGetRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representingDatabase. 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 database in the instance.   */// const database = 'abc123'/**   *  Database instance ID. This does not include the project ID.   */// const instance = 'abc123'/**   *  Project ID of the project that contains the instance.   */// const project = 'my-project'// Imports the Sql libraryconst{SqlDatabasesServiceClient}=require('@google-cloud/sql').v1;// Instantiates a clientconstsqlClient=newSqlDatabasesServiceClient();asyncfunctioncallGet(){// Construct requestconstrequest={};// Run requestconstresponse=awaitsqlClient.get(request);console.log(response);}callGet();

get(request, options, callback)

get(request:protos.google.cloud.sql.v1.ISqlDatabasesGetRequest,options:CallOptions,callback:Callback<protos.google.cloud.sql.v1.IDatabase,protos.google.cloud.sql.v1.ISqlDatabasesGetRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestISqlDatabasesGetRequest
optionsCallOptions
callbackCallback<protos.google.cloud.sql.v1.IDatabase,protos.google.cloud.sql.v1.ISqlDatabasesGetRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

get(request, callback)

get(request:protos.google.cloud.sql.v1.ISqlDatabasesGetRequest,callback:Callback<protos.google.cloud.sql.v1.IDatabase,protos.google.cloud.sql.v1.ISqlDatabasesGetRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestISqlDatabasesGetRequest
callbackCallback<protos.google.cloud.sql.v1.IDatabase,protos.google.cloud.sql.v1.ISqlDatabasesGetRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getLocation(request, options, callback)

getLocation(request:LocationProtos.google.cloud.location.IGetLocationRequest,options?:gax.CallOptions|Callback<LocationProtos.google.cloud.location.ILocation,LocationProtos.google.cloud.location.IGetLocationRequest|null|undefined,{}|null|undefined>,callback?:Callback<LocationProtos.google.cloud.location.ILocation,LocationProtos.google.cloud.location.IGetLocationRequest|null|undefined,{}|null|undefined>):Promise<LocationProtos.google.cloud.location.ILocation>;

Gets information about a location.

Parameters
NameDescription
requestLocationProtos.google.cloud.location.IGetLocationRequest

The request object that will be sent.

optionsCallOptions |Callback<google.cloud.location.ILocation,google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>

Call options. SeeCallOptions for more details.

callbackCallback<google.cloud.location.ILocation,google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
Promise<google.cloud.location.ILocation>

{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
const[response]=awaitclient.getLocation(request);

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.sql.v1.ISqlDatabasesInsertRequest,options?:CallOptions):Promise<[protos.google.cloud.sql.v1.IOperation,protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest|undefined,{}|undefined]>;

Inserts a resource containing information about a database inside a Cloud SQL instance.

**Note:** You can't modify the default character set and collation.

Parameters
NameDescription
requestISqlDatabasesInsertRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.sql.v1.IOperation,protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest | 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.   *//**   *  Database instance ID. This does not include the project ID.   */// const instance = 'abc123'/**   *  Project ID of the project that contains the instance.   */// const project = 'my-project'/**   */// const body = {}// Imports the Sql libraryconst{SqlDatabasesServiceClient}=require('@google-cloud/sql').v1;// Instantiates a clientconstsqlClient=newSqlDatabasesServiceClient();asyncfunctioncallInsert(){// Construct requestconstrequest={};// Run requestconstresponse=awaitsqlClient.insert(request);console.log(response);}callInsert();

insert(request, options, callback)

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

insert(request, callback)

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

list(request, options)

list(request?:protos.google.cloud.sql.v1.ISqlDatabasesListRequest,options?:CallOptions):Promise<[protos.google.cloud.sql.v1.IDatabasesListResponse,protos.google.cloud.sql.v1.ISqlDatabasesListRequest|undefined,{}|undefined]>;

Lists databases in the specified Cloud SQL instance.

Parameters
NameDescription
requestISqlDatabasesListRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.sql.v1.IDatabasesListResponse,protos.google.cloud.sql.v1.ISqlDatabasesListRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representingDatabasesListResponse. 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.   *//**   *  Cloud SQL instance ID. This does not include the project ID.   */// const instance = 'abc123'/**   *  Project ID of the project that contains the instance.   */// const project = 'my-project'// Imports the Sql libraryconst{SqlDatabasesServiceClient}=require('@google-cloud/sql').v1;// Instantiates a clientconstsqlClient=newSqlDatabasesServiceClient();asyncfunctioncallList(){// Construct requestconstrequest={};// Run requestconstresponse=awaitsqlClient.list(request);console.log(response);}callList();

list(request, options, callback)

list(request:protos.google.cloud.sql.v1.ISqlDatabasesListRequest,options:CallOptions,callback:Callback<protos.google.cloud.sql.v1.IDatabasesListResponse,protos.google.cloud.sql.v1.ISqlDatabasesListRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestISqlDatabasesListRequest
optionsCallOptions
callbackCallback<protos.google.cloud.sql.v1.IDatabasesListResponse,protos.google.cloud.sql.v1.ISqlDatabasesListRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

list(request, callback)

list(request:protos.google.cloud.sql.v1.ISqlDatabasesListRequest,callback:Callback<protos.google.cloud.sql.v1.IDatabasesListResponse,protos.google.cloud.sql.v1.ISqlDatabasesListRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestISqlDatabasesListRequest
callbackCallback<protos.google.cloud.sql.v1.IDatabasesListResponse,protos.google.cloud.sql.v1.ISqlDatabasesListRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

listLocationsAsync(request, options)

listLocationsAsync(request:LocationProtos.google.cloud.location.IListLocationsRequest,options?:CallOptions):AsyncIterable<LocationProtos.google.cloud.location.ILocation>;

Lists information about the supported locations for this service. Returns an iterable object.

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

Parameters
NameDescription
requestLocationProtos.google.cloud.location.IListLocationsRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
AsyncIterable<google.cloud.location.ILocation>

{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
constiterable=client.listLocationsAsync(request);forawait(constresponseofiterable){// process response}

patch(request, options)

patch(request?:protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest,options?:CallOptions):Promise<[protos.google.cloud.sql.v1.IOperation,protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|undefined,{}|undefined]>;

Partially updates a resource containing information about a database inside a Cloud SQL instance. This method supports patch semantics.

Parameters
NameDescription
requestISqlDatabasesUpdateRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.sql.v1.IOperation,protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | 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 database to be updated in the instance.   */// const database = 'abc123'/**   *  Database instance ID. This does not include the project ID.   */// const instance = 'abc123'/**   *  Project ID of the project that contains the instance.   */// const project = 'my-project'/**   */// const body = {}// Imports the Sql libraryconst{SqlDatabasesServiceClient}=require('@google-cloud/sql').v1;// Instantiates a clientconstsqlClient=newSqlDatabasesServiceClient();asyncfunctioncallPatch(){// Construct requestconstrequest={};// Run requestconstresponse=awaitsqlClient.patch(request);console.log(response);}callPatch();

patch(request, options, callback)

patch(request:protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest,options:CallOptions,callback:Callback<protos.google.cloud.sql.v1.IOperation,protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestISqlDatabasesUpdateRequest
optionsCallOptions
callbackCallback<protos.google.cloud.sql.v1.IOperation,protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

patch(request, callback)

patch(request:protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest,callback:Callback<protos.google.cloud.sql.v1.IOperation,protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestISqlDatabasesUpdateRequest
callbackCallback<protos.google.cloud.sql.v1.IOperation,protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

update(request, options)

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

Updates a resource containing information about a database inside a Cloud SQL instance.

Parameters
NameDescription
requestISqlDatabasesUpdateRequest

The request object that will be sent.

optionsCallOptions

Call options. SeeCallOptions for more details.

Returns
TypeDescription
Promise<[protos.google.cloud.sql.v1.IOperation,protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | 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 database to be updated in the instance.   */// const database = 'abc123'/**   *  Database instance ID. This does not include the project ID.   */// const instance = 'abc123'/**   *  Project ID of the project that contains the instance.   */// const project = 'my-project'/**   */// const body = {}// Imports the Sql libraryconst{SqlDatabasesServiceClient}=require('@google-cloud/sql').v1;// Instantiates a clientconstsqlClient=newSqlDatabasesServiceClient();asyncfunctioncallUpdate(){// Construct requestconstrequest={};// Run requestconstresponse=awaitsqlClient.update(request);console.log(response);}callUpdate();

update(request, options, callback)

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

update(request, callback)

update(request:protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest,callback:Callback<protos.google.cloud.sql.v1.IOperation,protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined,{}|null|undefined>):void;
Parameters
NameDescription
requestISqlDatabasesUpdateRequest
callbackCallback<protos.google.cloud.sql.v1.IOperation,protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | 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.