Skip to main content

instances

Creates, updates, deletes, gets or lists a instances resource.

Overview

Nameinstances
TypeResource
Idgoogle.sqladmin.instances

Fields

NameDatatypeDescription
namestringName of the Cloud SQL instance. This does not include the project ID.
availableMaintenanceVersionsarrayOutput only. List all maintenance versions applicable on the instance
backendTypestringThe backend type. SECOND_GEN: Cloud SQL database instance. EXTERNAL: A database server that is not managed by Google. This property is read-only; use the tier property in the settings object to determine the database type.
connectionNamestringConnection name of the Cloud SQL instance used in connection strings.
createTimestringOutput only. The time when the instance was created in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.
currentDiskSizestringThe current disk usage of the instance in bytes. This property has been deprecated. Use the "cloudsql.googleapis.com/database/disk/bytes_used" metric in Cloud Monitoring API instead. Please see this announcement for details.
databaseInstalledVersionstringOutput only. Stores the current database version running on the instance including minor version such as MYSQL_8_0_18.
databaseVersionstringThe database engine type and version. The databaseVersion field cannot be changed after instance creation.
diskEncryptionConfigurationobjectDisk encryption configuration for an instance.
diskEncryptionStatusobjectDisk encryption status for an instance.
dnsNamestringOutput only. The dns name of the instance.
etagstringThis field is deprecated and will be removed from a future version of the API. Use the settings.settingsVersion field instead.
failoverReplicaobjectThe name and status of the failover replica.
gceZonestringThe Compute Engine zone that the instance is currently serving from. This value could be different from the zone that was specified when the instance was created if the instance has failed over to its secondary zone. WARNING: Changing this might restart the instance.
geminiConfigobjectGemini instance configuration.
instanceTypestringThe instance type.
ipAddressesarrayThe assigned IP addresses for the instance.
ipv6AddressstringThe IPv6 address assigned to the instance. (Deprecated) This property was applicable only to First Generation instances.
kindstringThis is always sql#instance.
maintenanceVersionstringThe current software version on the instance.
masterInstanceNamestringThe name of the instance which will act as primary in the replication setup.
maxDiskSizestringThe maximum disk size of the instance in bytes.
onPremisesConfigurationobjectOn-premises instance configuration.
outOfDiskReportobjectThis message wraps up the information written by out-of-disk detection job.
primaryDnsNamestringOutput only. DEPRECATED: please use write_endpoint instead.
projectstringThe project ID of the project containing the Cloud SQL instance. The Google apps domain is prefixed if applicable.
pscServiceAttachmentLinkstringOutput only. The link to service attachment of PSC instance.
regionstringThe geographical region of the Cloud SQL instance. It can be one of the regions where Cloud SQL operates: For example, asia-east1, europe-west1, and us-central1. The default value is us-central1.
replicaConfigurationobjectRead-replica configuration for connecting to the primary instance.
replicaNamesarrayThe replicas of the instance.
replicationClusterobjectA primary instance and disaster recovery (DR) replica pair. A DR replica is a cross-region replica that you designate for failover in the event that the primary instance experiences regional failure. Only applicable to MySQL.
rootPasswordstringInitial root password. Use only on creation. You must set root passwords before you can connect to PostgreSQL instances.
satisfiesPzibooleanOutput only. This status indicates whether the instance satisfies PZI. The status is reserved for future use.
satisfiesPzsbooleanThis status indicates whether the instance satisfies PZS. The status is reserved for future use.
scheduledMaintenanceobjectAny scheduled maintenance for this instance.
secondaryGceZonestringThe Compute Engine zone that the failover instance is currently serving from for a regional instance. This value could be different from the zone that was specified when the instance was created if the instance has failed over to its secondary/failover zone.
selfLinkstringThe URI of this resource.
serverCaCertobjectSslCerts Resource
serviceAccountEmailAddressstringThe service account email address assigned to the instance.\This property is read-only.
settingsobjectDatabase instance settings.
sqlNetworkArchitecturestring
statestringThe current serving state of the Cloud SQL instance.
suspensionReasonarrayIf the instance state is SUSPENDED, the reason for the suspension.
switchTransactionLogsToCloudStorageEnabledbooleanInput only. Whether Cloud SQL is enabled to switch storing point-in-time recovery log files from a data disk to Cloud Storage.
upgradableDatabaseVersionsarrayOutput only. All database versions that are available for upgrade.
writeEndpointstringOutput only. The dns name of the primary instance in a replication group.

Methods

NameAccessible byRequired ParamsDescription
getSELECTinstance, projectRetrieves a resource containing information about a Cloud SQL instance.
listSELECTprojectLists instances under a given project.
insertINSERTprojectCreates a new Cloud SQL instance.
deleteDELETEinstance, projectDeletes a Cloud SQL instance.
patchUPDATEinstance, projectPartially updates settings of a Cloud SQL instance by merging the request with the current configuration. This method supports patch semantics.
updateREPLACEinstance, projectUpdates settings of a Cloud SQL instance. Using this operation might cause your instance to restart.
acquire_ssrs_leaseEXECinstance, projectAcquire a lease for the setup of SQL Server Reporting Services (SSRS).
cloneEXECinstance, projectCreates a Cloud SQL instance as a clone of the source instance. Using this operation might cause your instance to restart.
demoteEXECinstance, projectDemotes an existing standalone instance to be a Cloud SQL read replica for an external database server.
demote_masterEXECinstance, projectDemotes the stand-alone instance to be a Cloud SQL read replica for an external database server.
exportEXECinstance, projectExports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL dump or CSV file.
failoverEXECinstance, projectInitiates 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 page in the Cloud SQL documentation. If using Legacy HA (MySQL only), this causes the instance to failover to its failover replica instance.
importEXECinstance, projectImports data into a Cloud SQL instance from a SQL dump or CSV file in Cloud Storage.
list_server_certificatesEXECinstance, projectLists all versions of server certificates and certificate authorities (CAs) for the specified instance. There can be up to three sets of certs listed: the certificate that is currently in use, a future that has been added but not yet used to sign a certificate, and a certificate that has been rotated out.
perform_disk_shrinkEXECinstance, projectPerform Disk Shrink on primary instance.
promote_replicaEXECinstance, projectPromotes the read replica instance to be an independent Cloud SQL primary instance. Using this operation might cause your instance to restart.
reencryptEXECinstance, projectReencrypt CMEK instance with latest key version.
release_ssrs_leaseEXECinstance, projectRelease a lease for the setup of SQL Server Reporting Services (SSRS).
reschedule_maintenanceEXECinstance, projectReschedules the maintenance on the given instance.
reset_replica_sizeEXECinstance, projectReset Replica Size to primary instance disk size.
reset_ssl_configEXECinstance, projectDeletes all client certificates and generates a new server SSL certificate for the instance.
restartEXECinstance, projectRestarts a Cloud SQL instance.
restore_backupEXECinstance, projectRestores a backup of a Cloud SQL instance. Using this operation might cause your instance to restart.
rotate_server_caEXECinstance, projectRotates the server certificate to one signed by the Certificate Authority (CA) version previously added with the addServerCA method. For instances that have enabled Certificate Authority Service (CAS) based server CA, please use RotateServerCertificate to rotate the server certificate.
rotate_server_certificateEXECinstance, projectRotates the server certificate version to one previously added with the addServerCertificate method. For instances not using Certificate Authority Service (CAS) server CA, please use RotateServerCa instead.
start_external_syncEXECinstance, projectStart External primary instance migration.
start_replicaEXECinstance, projectStarts the replication in the read replica instance.
stop_replicaEXECinstance, projectStops the replication in the read replica instance.
switchoverEXECinstance, projectSwitches over from the primary instance to the designated DR replica instance.
truncate_logEXECinstance, projectTruncate MySQL general and slow query log tables MySQL only.
verify_external_sync_settingsEXECinstance, projectVerify External primary instance external sync settings.

SELECT examples

Lists instances under a given project.

SELECT
name,
availableMaintenanceVersions,
backendType,
connectionName,
createTime,
currentDiskSize,
databaseInstalledVersion,
databaseVersion,
diskEncryptionConfiguration,
diskEncryptionStatus,
dnsName,
etag,
failoverReplica,
gceZone,
geminiConfig,
instanceType,
ipAddresses,
ipv6Address,
kind,
maintenanceVersion,
masterInstanceName,
maxDiskSize,
onPremisesConfiguration,
outOfDiskReport,
primaryDnsName,
project,
pscServiceAttachmentLink,
region,
replicaConfiguration,
replicaNames,
replicationCluster,
rootPassword,
satisfiesPzi,
satisfiesPzs,
scheduledMaintenance,
secondaryGceZone,
selfLink,
serverCaCert,
serviceAccountEmailAddress,
settings,
sqlNetworkArchitecture,
state,
suspensionReason,
switchTransactionLogsToCloudStorageEnabled,
upgradableDatabaseVersions,
writeEndpoint
FROM google.sqladmin.instances
WHERE project = '{{ project }}';

INSERT example

Use the following StackQL query and manifest file to create a new instances resource.

/*+ create */
INSERT INTO google.sqladmin.instances (
project,
state,
databaseVersion,
settings,
etag,
failoverReplica,
masterInstanceName,
replicaNames,
maxDiskSize,
currentDiskSize,
ipAddresses,
serverCaCert,
instanceType,
project,
ipv6Address,
serviceAccountEmailAddress,
onPremisesConfiguration,
replicaConfiguration,
backendType,
suspensionReason,
connectionName,
name,
region,
gceZone,
secondaryGceZone,
diskEncryptionConfiguration,
diskEncryptionStatus,
rootPassword,
scheduledMaintenance,
satisfiesPzs,
outOfDiskReport,
maintenanceVersion,
sqlNetworkArchitecture,
replicationCluster,
geminiConfig,
switchTransactionLogsToCloudStorageEnabled
)
SELECT
'{{ project }}',
'{{ state }}',
'{{ databaseVersion }}',
'{{ settings }}',
'{{ etag }}',
'{{ failoverReplica }}',
'{{ masterInstanceName }}',
'{{ replicaNames }}',
'{{ maxDiskSize }}',
'{{ currentDiskSize }}',
'{{ ipAddresses }}',
'{{ serverCaCert }}',
'{{ instanceType }}',
'{{ project }}',
'{{ ipv6Address }}',
'{{ serviceAccountEmailAddress }}',
'{{ onPremisesConfiguration }}',
'{{ replicaConfiguration }}',
'{{ backendType }}',
'{{ suspensionReason }}',
'{{ connectionName }}',
'{{ name }}',
'{{ region }}',
'{{ gceZone }}',
'{{ secondaryGceZone }}',
'{{ diskEncryptionConfiguration }}',
'{{ diskEncryptionStatus }}',
'{{ rootPassword }}',
'{{ scheduledMaintenance }}',
{{ satisfiesPzs }},
'{{ outOfDiskReport }}',
'{{ maintenanceVersion }}',
'{{ sqlNetworkArchitecture }}',
'{{ replicationCluster }}',
'{{ geminiConfig }}',
{{ switchTransactionLogsToCloudStorageEnabled }}
;

UPDATE example

Updates a instances resource.

/*+ update */
UPDATE google.sqladmin.instances
SET
state = '{{ state }}',
databaseVersion = '{{ databaseVersion }}',
settings = '{{ settings }}',
etag = '{{ etag }}',
failoverReplica = '{{ failoverReplica }}',
masterInstanceName = '{{ masterInstanceName }}',
replicaNames = '{{ replicaNames }}',
maxDiskSize = '{{ maxDiskSize }}',
currentDiskSize = '{{ currentDiskSize }}',
ipAddresses = '{{ ipAddresses }}',
serverCaCert = '{{ serverCaCert }}',
instanceType = '{{ instanceType }}',
project = '{{ project }}',
ipv6Address = '{{ ipv6Address }}',
serviceAccountEmailAddress = '{{ serviceAccountEmailAddress }}',
onPremisesConfiguration = '{{ onPremisesConfiguration }}',
replicaConfiguration = '{{ replicaConfiguration }}',
backendType = '{{ backendType }}',
suspensionReason = '{{ suspensionReason }}',
connectionName = '{{ connectionName }}',
name = '{{ name }}',
region = '{{ region }}',
gceZone = '{{ gceZone }}',
secondaryGceZone = '{{ secondaryGceZone }}',
diskEncryptionConfiguration = '{{ diskEncryptionConfiguration }}',
diskEncryptionStatus = '{{ diskEncryptionStatus }}',
rootPassword = '{{ rootPassword }}',
scheduledMaintenance = '{{ scheduledMaintenance }}',
satisfiesPzs = true|false,
outOfDiskReport = '{{ outOfDiskReport }}',
maintenanceVersion = '{{ maintenanceVersion }}',
sqlNetworkArchitecture = '{{ sqlNetworkArchitecture }}',
replicationCluster = '{{ replicationCluster }}',
geminiConfig = '{{ geminiConfig }}',
switchTransactionLogsToCloudStorageEnabled = true|false
WHERE
instance = '{{ instance }}'
AND project = '{{ project }}';

REPLACE example

Replaces all fields in the specified instances resource.

/*+ update */
REPLACE google.sqladmin.instances
SET
state = '{{ state }}',
databaseVersion = '{{ databaseVersion }}',
settings = '{{ settings }}',
etag = '{{ etag }}',
failoverReplica = '{{ failoverReplica }}',
masterInstanceName = '{{ masterInstanceName }}',
replicaNames = '{{ replicaNames }}',
maxDiskSize = '{{ maxDiskSize }}',
currentDiskSize = '{{ currentDiskSize }}',
ipAddresses = '{{ ipAddresses }}',
serverCaCert = '{{ serverCaCert }}',
instanceType = '{{ instanceType }}',
project = '{{ project }}',
ipv6Address = '{{ ipv6Address }}',
serviceAccountEmailAddress = '{{ serviceAccountEmailAddress }}',
onPremisesConfiguration = '{{ onPremisesConfiguration }}',
replicaConfiguration = '{{ replicaConfiguration }}',
backendType = '{{ backendType }}',
suspensionReason = '{{ suspensionReason }}',
connectionName = '{{ connectionName }}',
name = '{{ name }}',
region = '{{ region }}',
gceZone = '{{ gceZone }}',
secondaryGceZone = '{{ secondaryGceZone }}',
diskEncryptionConfiguration = '{{ diskEncryptionConfiguration }}',
diskEncryptionStatus = '{{ diskEncryptionStatus }}',
rootPassword = '{{ rootPassword }}',
scheduledMaintenance = '{{ scheduledMaintenance }}',
satisfiesPzs = true|false,
outOfDiskReport = '{{ outOfDiskReport }}',
maintenanceVersion = '{{ maintenanceVersion }}',
sqlNetworkArchitecture = '{{ sqlNetworkArchitecture }}',
replicationCluster = '{{ replicationCluster }}',
geminiConfig = '{{ geminiConfig }}',
switchTransactionLogsToCloudStorageEnabled = true|false
WHERE
instance = '{{ instance }}'
AND project = '{{ project }}';

DELETE example

Deletes the specified instances resource.

/*+ delete */
DELETE FROM google.sqladmin.instances
WHERE instance = '{{ instance }}'
AND project = '{{ project }}';