Instances: insert

Requires authorization

Creates a new Cloud SQL instance.

Request

HTTP request

POST https://www.googleapis.com/sql/v1beta4/projects/project/instances

Parameters

Parameter name Value Description
Path parameters
project string Project ID of the project to which the newly created Cloud SQL instances should belong.

Authorization

This request requires authorization with at least one of the following scopes (read more about authentication and authorization).

Scope
https://www.googleapis.com/auth/sqlservice.admin
https://www.googleapis.com/auth/cloud-platform

Request body

In the request body, supply an instance resource with the following properties:

Property name Value Description Notes
Required Properties
name string Name of the Cloud SQL instance. This does not include the project ID.
settings nested object The user settings.
settings.tier string The tier or machine type for this instance, for example db-n1-standard-1. For MySQL instances, this field determines whether the instance is Second Generation (recommended) or First Generation. For more information, see pricing. writable
Optional Properties
databaseVersion string The database engine type and version. The databaseVersion field can not be changed after instance creation. MySQL Second Generation instances: MYSQL_5_7 (default) or MYSQL_5_6. PostgreSQL instances: POSTGRES_9_6 MySQL First Generation instances: MYSQL_5_6 (default) or MYSQL_5_5 writable
failoverReplica object The name and status of the failover replica. This property is applicable only to Second Generation instances. writable
failoverReplica.name string The name of the failover replica. If specified at instance creation, a failover replica is created for the instance. The name doesn't include the project ID. This property is applicable only to Second Generation instances. writable
masterInstanceName string The name of the instance which will act as master in the replication setup. writable
onPremisesConfiguration nested object Configuration specific to on-premises instances. writable
region string The geographical region. Defaults to us-central or us-central1 depending on the instance type (First Generation or Second Generation/PostgreSQL). For a complete list of valid values, see Instance Locations. The region cannot be changed after instance creation. writable
replicaConfiguration nested object Configuration specific to failover replicas and read replicas. writable
replicaConfiguration.failoverTarget boolean Specifies if the replica is the failover target. If the field is set to true the replica will be designated as a failover replica. In case the master instance fails, the replica instance will be promoted as the new master instance.

Only one replica can be specified as failover target, and the replica has to be in different zone with the master instance.

writable
replicaConfiguration.mysqlReplicaConfiguration nested object MySQL specific configuration when replicating from a MySQL on-premises master. Replication configuration information such as the username, password, certificates, and keys are not stored in the instance metadata. The configuration information is used only to set up the replication connection and is stored by MySQL in a file named master.info in the data directory. writable
replicaConfiguration.mysqlReplicaConfiguration.caCertificate string PEM representation of the trusted CA's x509 certificate. writable
replicaConfiguration.mysqlReplicaConfiguration.clientCertificate string PEM representation of the slave's x509 certificate. writable
replicaConfiguration.mysqlReplicaConfiguration.clientKey string PEM representation of the slave's private key. The corresponsing public key is encoded in the client's certificate. writable
replicaConfiguration.mysqlReplicaConfiguration.connectRetryInterval integer Seconds to wait between connect retries. MySQL's default is 60 seconds. writable
replicaConfiguration.mysqlReplicaConfiguration.dumpFilePath string Path to a SQL dump file in Google Cloud Storage from which the slave instance is to be created. The URI is in the form gs://bucketName/fileName. Compressed gzip files (.gz) are also supported. Dumps should have the binlog co-ordinates from which replication should begin. This can be accomplished by setting --master-data to 1 when using mysqldump. writable
replicaConfiguration.mysqlReplicaConfiguration.masterHeartbeatPeriod long Interval in milliseconds between replication heartbeats. writable
replicaConfiguration.mysqlReplicaConfiguration.password string The password for the replication connection. writable
replicaConfiguration.mysqlReplicaConfiguration.sslCipher string A list of permissible ciphers to use for SSL encryption. writable
replicaConfiguration.mysqlReplicaConfiguration.username string The username for the replication connection. writable
replicaConfiguration.mysqlReplicaConfiguration.verifyServerCertificate boolean Whether or not to check the master's Common Name value in the certificate that it sends during the SSL handshake. writable
settings.activationPolicy string The activation policy specifies when the instance is activated; it is applicable only when the instance state is RUNNABLE. Valid values:
ALWAYS: The instance is on, and remains so even in the absence of connection requests.
NEVER: The instance is off; it is not activated, even if a connection request arrives.
ON_DEMAND: First Generation instances only. The instance responds to incoming requests, and turns itself off when not in use. Instances with PER_USE pricing turn off after 15 minutes of inactivity. Instances with PER_PACKAGE pricing turn off after 12 hours of inactivity.
writable
settings.authorizedGaeApplications[] list The App Engine app IDs that can access this instance. This property is only applicable to First Generation instances. writable
settings.backupConfiguration nested object The daily backup configuration for the instance. writable
settings.backupConfiguration.binaryLogEnabled boolean Whether binary log is enabled. If backup configuration is disabled, binary log must be disabled as well. writable
settings.backupConfiguration.enabled boolean Whether this configuration is enabled. writable
settings.backupConfiguration.startTime string Start time for the daily backup configuration in UTC timezone in the 24 hour format - HH:MM. writable
settings.crashSafeReplicationEnabled boolean Configuration specific to read replica instances. Indicates whether database flags for crash-safe replication are enabled. This property is only applicable to First Generation instances. writable
settings.dataDiskSizeGb long The size of data disk, in GB. The data disk size minimum is 10GB. Applies only to Second Generation instances. writable
settings.dataDiskType string The type of data disk: PD_SSD (default) or PD_HDD. Applies only to Second Generation instances. writable
settings.databaseFlags[] list The database flags passed to the instance at startup. writable
settings.ipConfiguration nested object The settings for IP Management. This allows to enable or disable the instance IP and manage which external networks can connect to the instance. The IPv4 address cannot be disabled for Second Generation instances. writable
settings.ipConfiguration.authorizedNetworks[] list The list of external networks that are allowed to connect to the instance using the IP. In CIDR notation, also known as 'slash' notation (e.g. 192.168.100.0/24). writable
settings.ipConfiguration.authorizedNetworks[].expirationTime datetime The time when this access control entry expires in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. writable
settings.ipConfiguration.authorizedNetworks[].name string An optional label to identify this entry. writable
settings.ipConfiguration.authorizedNetworks[].value string The whitelisted value for the access control list. For example, to grant access to a client from an external IP (IPv4 or IPv6) address or subnet, use that address or subnet here. writable
settings.ipConfiguration.ipv4Enabled boolean Whether the instance should be assigned an IP address or not. writable
settings.ipConfiguration.requireSsl boolean Whether SSL connections over IP should be enforced or not. writable
settings.locationPreference nested object The location preference settings. This allows the instance to be located as near as possible to either an App Engine app or Compute Engine zone for better performance. App Engine co-location is only applicable to First Generation instances. writable
settings.locationPreference.followGaeApplication string The App Engine application to follow, it must be in the same region as the Cloud SQL instance. writable
settings.locationPreference.zone string The preferred Compute Engine zone (e.g. us-centra1-a, us-central1-b, etc.). writable
settings.maintenanceWindow nested object The maintenance window for this instance. This specifies when the instance may be restarted for maintenance purposes. Applies only to Second Generation instances. writable
settings.maintenanceWindow.day integer day of week (1-7), starting on Monday. writable
settings.maintenanceWindow.hour integer hour of day - 0 to 23. writable
settings.maintenanceWindow.updateTrack string Maintenance timing setting: canary (Earlier) or stable (Later).
Learn more.
writable
settings.pricingPlan string The pricing plan for this instance. This can be either PER_USE or PACKAGE. Only PER_USE is supported for Second Generation instances. writable
settings.replicationType string The type of replication this instance uses. This can be either ASYNCHRONOUS or SYNCHRONOUS. writable
settings.storageAutoResize boolean Configuration to increase storage size automatically. The default value is true. Applies only to Second Generation instances. writable
settings.storageAutoResizeLimit long The maximum size to which storage capacity can be automatically increased. The default value is 0, which specifies that there is no limit. Applies only to Second Generation instances. writable
settings.userLabels object User-provided labels, represented as a dictionary where each label is a single key value pair. writable
settings.userLabels.(key) string An individual label entry, composed of a key and a value. writable

Response

If successful, this method returns an operation resource in the response body. Note that only the fields that are relevant to the insert operation will be populated.

{
  "kind": "sql#operation",
  "selfLink": string,
  "targetProject": string,
  "targetId": string,
  "targetLink": string,
  "targetLink": string,
  "name": string,
  "operationType": string,
  "status": string,
  "user": string,
  "insertTime": datetime,
  "startTime": datetime,
  "endTime": datetime,
  "error": {
    "kind": "sql#operationErrors",
    "errors": [
      {
        "kind": "sql#operationError",
        "code": string,
        "message": string
      }
    ]
  },
  "importContext": {
    "kind": "sql#importContext",
    "fileType": string,
    "uri": string,
    "database": string,
    "importUser": string,
    "csvImportOptions": {
      "table": string,
      "columns": [
        string
      ]
    }
  },
  "exportContext": {
    "kind": "sql#exportContext",
    "fileType": string,
    "uri": string,
    "databases": [
      string
    ],
    "sqlExportOptions": {
      "tables": [
        string
      ],
      "schemaOnly": boolean
    },
    "csvExportOptions": {
      "selectQuery": string
    }
  }
}
Property name Value Description Notes
kind string This is always sql#operation.
targetProject string The project ID of the target instance related to this operation.
targetId string Name of the database instance related to this operation.
name string An identifier that uniquely identifies the operation. You can use this identifier to retrieve the Operations resource that has information about the operation.
operationType string The type of the operation. Valid values are CREATE, DELETE, UPDATE, RESTART, IMPORT, EXPORT, BACKUP_VOLUME, RESTORE_VOLUME, CREATE_USER, DELETE_USER, CREATE_DATABASE, DELETE_DATABASE .
status string The status of an operation. Valid values are PENDING, RUNNING, DONE, UNKNOWN.
user string The email address of the user who initiated this operation.
insertTime datetime The time this operation was enqueued in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.
startTime datetime The time this operation actually started in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.
endTime datetime The time this operation finished in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.
error nested object If errors occurred during processing of this operation, this field will be populated.
error.errors[] list The list of errors encountered while processing this operation.
error.errors[].kind string This is always sql#operationError.
error.errors[].code string Identifies the specific error that occurred.
error.errors[].message string Additional information about the error encountered.
importContext nested object The context for import operation, if applicable.
importContext.kind string This is always sql#importContext.
importContext.fileType string The file type for the specified uri.
SQL: The file contains SQL statements.
CSV: The file contains CSV data.
importContext.uri string A path to the file in Google Cloud Storage from which the import is made. The URI is in the form gs://bucketName/fileName. Compressed gzip files (.gz) are supported when fileType is SQL.
importContext.database string The database (for example, guestbook) to which the import is made. If fileType is SQL and no database is specified, it is assumed that the database is specified in the file to be imported. If fileType is CSV, it must be specified.
importContext.csvImportOptions object Options for importing data as CSV.
importContext.csvImportOptions.table string The table to which CSV data is imported.
importContext.csvImportOptions.columns[] list The columns to which CSV data is imported. If not specified, all columns of the database table are loaded with CSV data.
exportContext nested object The context for export operation, if applicable.
exportContext.kind string This is always sql#exportContext.
exportContext.fileType string The file type for the specified uri.
SQL: The file contains SQL statements.
CSV: The file contains CSV data.
exportContext.uri string The path to the file in Google Cloud Storage where the export will be stored. The URI is in the form gs://bucketName/fileName. If the file already exists, the requests succeeds, but the operation fails. If fileType is SQL and the filename ends with .gz, the contents are compressed.
exportContext.databases[] list Databases (for example, guestbook) from which the export is made. If fileType is SQL and no database is specified, all databases are exported. If fileType is CSV, you can optionally specify at most one database to export. If csvExportOptions.selectQuery also specifies the database, this field will be ignored.
exportContext.sqlExportOptions object Options for exporting data as SQL statements.
exportContext.sqlExportOptions.tables[] list Tables to export, or that were exported, from the specified database. If you specify tables, specify one and only one database.
exportContext.csvExportOptions object Options for exporting data as CSV.
exportContext.csvExportOptions.selectQuery string The select query used to extract the data.
error.kind string This is always sql#operationErrors.
exportContext.sqlExportOptions.schemaOnly boolean Export only schemas.
importContext.importUser string The PostgreSQL user for this import operation. Defaults to cloudsqlsuperuser. Used only for PostgreSQL instances.

Send feedback about...

Cloud SQL for MySQL