Service to manage Cloud SQL instances. v1
Package
@google-cloud/sql
Constructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of SqlInstancesServiceClient.
Parameters |
Name |
Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof fallback
: loaded instance of google-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 SqlInstancesServiceClient({fallback: true}, gax); ```
|
Properties
apiEndpoint
get apiEndpoint(): string;
The DNS address for this API service.
apiEndpoint
static get apiEndpoint(): string;
The DNS address for this API service - same as servicePath.
auth
descriptors
descriptors: Descriptors;
innerApiCalls
innerApiCalls: {
[name: string]: Function;
};
locationsClient
locationsClient: LocationsClient;
port
static get port(): number;
The port for this API service.
scopes
static get scopes(): string[];
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
static get servicePath(): string;
The DNS address for this API service.
sqlInstancesServiceStub
sqlInstancesServiceStub?: Promise<{
[name: string]: Function;
}>;
universeDomain
get universeDomain(): string;
warn
warn: (code: string, message: string, warnType?: string) => void;
Methods
acquireSsrsLease(request, options)
acquireSsrsLease(request?: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest, options?: CallOptions): Promise<[
protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse,
(protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest | undefined),
{} | undefined
]>;
Acquire a lease for the setup of SQL Server Reporting Services (SSRS).
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.
*/
/**
* Required. Cloud SQL instance ID. This doesn't include the project ID. It's
* composed of lowercase letters, numbers, and hyphens, and it must start with
* a letter. The total length must be 98 characters or less (Example:
* instance-id).
*/
// const instance = 'abc123'
/**
* Required. Project ID of the project that contains the instance (Example:
* project-id).
*/
// const project = 'my-project'
/**
* Required. The request body.
*/
// const body = {}
// Imports the Sql library
const {SqlInstancesServiceClient} = require('@google-cloud/sql').v1;
// Instantiates a client
const sqlClient = new SqlInstancesServiceClient();
async function callAcquireSsrsLease() {
// Construct request
const request = {
instance,
project,
body,
};
// Run request
const response = await sqlClient.acquireSsrsLease(request);
console.log(response);
}
callAcquireSsrsLease();
acquireSsrsLease(request, options, callback)
acquireSsrsLease(request: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest, options: CallOptions, callback: Callback<protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
acquireSsrsLease(request, callback)
acquireSsrsLease(request: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest, callback: Callback<protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
addServerCa(request, options)
addServerCa(request?: protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest, options?: CallOptions): Promise<[
protos.google.cloud.sql.v1.IOperation,
protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest | undefined,
{} | undefined
]>;
Adds a new trusted Certificate Authority (CA) version for the specified instance. Required to prepare for a certificate rotation. If a CA version was previously added but never used in a certificate rotation, this operation replaces that version. There cannot be more than one CA version waiting to be rotated in.
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 library
const {SqlInstancesServiceClient} = require('@google-cloud/sql').v1;
// Instantiates a client
const sqlClient = new SqlInstancesServiceClient();
async function callAddServerCa() {
// Construct request
const request = {
};
// Run request
const response = await sqlClient.addServerCa(request);
console.log(response);
}
callAddServerCa();
addServerCa(request, options, callback)
addServerCa(request: protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest, options: CallOptions, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
addServerCa(request, callback)
addServerCa(request: protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
clone(request, options)
clone(request?: protos.google.cloud.sql.v1.ISqlInstancesCloneRequest, options?: CallOptions): Promise<[
protos.google.cloud.sql.v1.IOperation,
protos.google.cloud.sql.v1.ISqlInstancesCloneRequest | undefined,
{} | undefined
]>;
Creates a Cloud SQL instance as a clone of the source instance. Using this operation might cause your instance to restart.
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 ID of the Cloud SQL instance to be cloned (source). This does not
* include the project ID.
*/
// const instance = 'abc123'
/**
* Project ID of the source as well as the clone Cloud SQL instance.
*/
// const project = 'my-project'
/**
*/
// const body = {}
// Imports the Sql library
const {SqlInstancesServiceClient} = require('@google-cloud/sql').v1;
// Instantiates a client
const sqlClient = new SqlInstancesServiceClient();
async function callClone() {
// Construct request
const request = {
};
// Run request
const response = await sqlClient.clone(request);
console.log(response);
}
callClone();
clone(request, options, callback)
clone(request: protos.google.cloud.sql.v1.ISqlInstancesCloneRequest, options: CallOptions, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesCloneRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
clone(request, callback)
clone(request: protos.google.cloud.sql.v1.ISqlInstancesCloneRequest, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesCloneRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
close()
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Returns |
Type |
Description |
Promise<void> |
{Promise} A promise that resolves when the client is closed.
|
createEphemeral(request, options)
createEphemeral(request?: protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest, options?: CallOptions): Promise<[
protos.google.cloud.sql.v1.ISslCert,
(protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest | undefined),
{} | undefined
]>;
Generates a short-lived X509 certificate containing the provided public key and signed by a private key specific to the target instance. Users may use the certificate to authenticate as themselves when connecting to the database.
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 Cloud SQL project.
*/
// const project = 'my-project'
/**
*/
// const body = {}
// Imports the Sql library
const {SqlInstancesServiceClient} = require('@google-cloud/sql').v1;
// Instantiates a client
const sqlClient = new SqlInstancesServiceClient();
async function callCreateEphemeral() {
// Construct request
const request = {
};
// Run request
const response = await sqlClient.createEphemeral(request);
console.log(response);
}
callCreateEphemeral();
createEphemeral(request, options, callback)
createEphemeral(request: protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest, options: CallOptions, callback: Callback<protos.google.cloud.sql.v1.ISslCert, protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
createEphemeral(request, callback)
createEphemeral(request: protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest, callback: Callback<protos.google.cloud.sql.v1.ISslCert, protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
delete(request, options)
delete(request?: protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest, options?: CallOptions): Promise<[
protos.google.cloud.sql.v1.IOperation,
protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest | undefined,
{} | undefined
]>;
Deletes a Cloud SQL instance.
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 to be deleted.
*/
// const project = 'my-project'
// Imports the Sql library
const {SqlInstancesServiceClient} = require('@google-cloud/sql').v1;
// Instantiates a client
const sqlClient = new SqlInstancesServiceClient();
async function callDelete() {
// Construct request
const request = {
};
// Run request
const response = await sqlClient.delete(request);
console.log(response);
}
callDelete();
delete(request, options, callback)
delete(request: protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest, options: CallOptions, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
delete(request, callback)
delete(request: protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
demote(request, options)
demote(request?: protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest, options?: CallOptions): Promise<[
protos.google.cloud.sql.v1.IOperation,
protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest | undefined,
{} | undefined
]>;
Demotes an existing standalone instance to be a Cloud SQL read replica for an external database server.
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.
*/
/**
* Required. Cloud SQL instance name.
*/
// const instance = 'abc123'
/**
* Required. ID of the project that contains the instance.
*/
// const project = 'my-project'
/**
* Required. The request body.
*/
// const body = {}
// Imports the Sql library
const {SqlInstancesServiceClient} = require('@google-cloud/sql').v1;
// Instantiates a client
const sqlClient = new SqlInstancesServiceClient();
async function callDemote() {
// Construct request
const request = {
instance,
project,
body,
};
// Run request
const response = await sqlClient.demote(request);
console.log(response);
}
callDemote();
demote(request, options, callback)
demote(request: protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest, options: CallOptions, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
demote(request, callback)
demote(request: protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
demoteMaster(request, options)
demoteMaster(request?: protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest, options?: CallOptions): Promise<[
protos.google.cloud.sql.v1.IOperation,
protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest | undefined,
{} | undefined
]>;
Demotes the stand-alone instance to be a Cloud SQL read replica for an external database server.
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 name.
*/
// const instance = 'abc123'
/**
* ID of the project that contains the instance.
*/
// const project = 'my-project'
/**
*/
// const body = {}
// Imports the Sql library
const {SqlInstancesServiceClient} = require('@google-cloud/sql').v1;
// Instantiates a client
const sqlClient = new SqlInstancesServiceClient();
async function callDemoteMaster() {
// Construct request
const request = {
};
// Run request
const response = await sqlClient.demoteMaster(request);
console.log(response);
}
callDemoteMaster();
demoteMaster(request, options, callback)
demoteMaster(request: protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest, options: CallOptions, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
demoteMaster(request, callback)
demoteMaster(request: protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
export(request, options)
export(request?: protos.google.cloud.sql.v1.ISqlInstancesExportRequest, options?: CallOptions): Promise<[
protos.google.cloud.sql.v1.IOperation,
protos.google.cloud.sql.v1.ISqlInstancesExportRequest | undefined,
{} | undefined
]>;
Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL dump or CSV file.
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 to be exported.
*/
// const project = 'my-project'
/**
*/
// const body = {}
// Imports the Sql library
const {SqlInstancesServiceClient} = require('@google-cloud/sql').v1;
// Instantiates a client
const sqlClient = new SqlInstancesServiceClient();
async function callExport() {
// Construct request
const request = {
};
// Run request
const response = await sqlClient.export(request);
console.log(response);
}
callExport();
export(request, options, callback)
export(request: protos.google.cloud.sql.v1.ISqlInstancesExportRequest, options: CallOptions, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesExportRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
export(request, callback)
export(request: protos.google.cloud.sql.v1.ISqlInstancesExportRequest, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesExportRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
failover(request, options)
failover(request?: protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest, options?: CallOptions): Promise<[
protos.google.cloud.sql.v1.IOperation,
protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest | undefined,
{} | undefined
]>;
Initiates a manual failover of a high availability (HA) primary instance to a standby instance, which becomes the primary instance. Users are then rerouted to the new primary. For more information, see the [Overview of high availability](https://cloud.google.com/sql/docs/mysql/high-availability) page in the Cloud SQL documentation. If using Legacy HA (MySQL only), this causes the instance to failover to its failover replica instance.
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'
/**
* ID of the project that contains the read replica.
*/
// const project = 'my-project'
/**
*/
// const body = {}
// Imports the Sql library
const {SqlInstancesServiceClient} = require('@google-cloud/sql').v1;
// Instantiates a client
const sqlClient = new SqlInstancesServiceClient();
async function callFailover() {
// Construct request
const request = {
};
// Run request
const response = await sqlClient.failover(request);
console.log(response);
}
callFailover();
failover(request, options, callback)
failover(request: protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest, options: CallOptions, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
failover(request, callback)
failover(request: protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest, callback: Callback<protos.google.cloud.sql.v1.IOperation, protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
get(request, options)
get(request?: protos.google.cloud.sql.v1.ISqlInstancesGetRequest, options?: CallOptions): Promise<[
protos.google.cloud.sql.v1.IDatabaseInstance,
protos.google.cloud.sql.v1.ISqlInstancesGetRequest | undefined,
{} | undefined
]>;
Retrieves a resource containing information about a Cloud SQL instance.
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'
// Imports the Sql library
const {SqlInstancesServiceClient} = require('@google-cloud/sql').v1;
// Instantiates a client
const sqlClient = new SqlInstancesServiceClient();
async function callGet() {
// Construct request
const request = {
};
// Run request
const response = await sqlClient.get(request);
console.log(response);
}
callGet();
get(request, options, callback)
get(request: protos.google.cloud.sql.v1.ISqlInstancesGetRequest, options: CallOptions, callback: Callback<protos.google.cloud.sql.v1.IDatabaseInstance, protos.google.cloud.sql.v1.ISqlInstancesGetRequest | null | undefined, {} | null | undefined>): void;
Returns |
Type |
Description |
void |
|
get(request, callback)
get(request: protos.google.cloud.