REST Resource: operations

Resource: Operation

An Operation resource. For successful operations that return an Operation resource, only the fields relevant to the operation are populated in the resource.

JSON representation
{
  "kind": string,
  "targetLink": string,
  "status": enum (SqlOperationStatus),
  "user": string,
  "insertTime": string,
  "startTime": string,
  "endTime": string,
  "error": {
    object (OperationErrors)
  },
  "operationType": enum (SqlOperationType),
  "importContext": {
    object (ImportContext)
  },
  "exportContext": {
    object (ExportContext)
  },
  "backupContext": {
    object (BackupContext)
  },
  "name": string,
  "targetId": string,
  "selfLink": string,
  "targetProject": string
  "subOperationType": {
    object (SqlSubOperationType)
  }
}
Fields
kind

string

This is always sql#operation.

status

enum (SqlOperationStatus)

The status of an operation.

user

string

The email address of the user who initiated this operation.

insertTime

string (Timestamp format)

The time this operation was enqueued in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

startTime

string (Timestamp format)

The time this operation actually started in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

endTime

string (Timestamp format)

The time this operation finished in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

error

object (OperationErrors)

If errors occurred during processing of this operation, this field will be populated.

operationType

enum (SqlOperationType)

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

importContext

object (ImportContext)

The context for import operation, if applicable.

exportContext

object (ExportContext)

The context for export operation, if applicable.

backupContext

object (BackupContext)

The context for backup operation, if applicable.

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.

targetId

string

Name of the resource on which this operation is executed.

targetProject

string

The project ID of the target instance related to this operation.

subOperationType

object (SqlSubOperationType)

Optional. The sub operation based on the operation type.

SqlOperationStatus

The status of an operation.

Enums
SQL_OPERATION_STATUS_UNSPECIFIEDThe state of the operation is unknown.
PENDINGThe operation has been queued, but has not started yet.
RUNNINGThe operation is running.
DONEThe operation completed.

OperationErrors

Database instance operation errors list wrapper.

JSON representation
{
  "kind": string,
  "errors": [
    {
      object (OperationError)
    }
  ]
}
Fields
kind

string

This is always sql#operationErrors.

errors[]

object (OperationError)

The list of errors encountered while processing this operation.

SqlOperationType

The type of Cloud SQL operation.

Enums
SQL_OPERATION_TYPE_UNSPECIFIEDUnknown operation type.
IMPORTImports data into a Cloud SQL instance.
EXPORTExports data from a Cloud SQL instance to a Cloud Storage bucket.
CREATECreates a new Cloud SQL instance.
UPDATEUpdates the settings of a Cloud SQL instance.
DELETEDeletes a Cloud SQL instance.
RESTARTRestarts the Cloud SQL instance.
BACKUP
SNAPSHOT
BACKUP_VOLUMEPerforms instance backup.
DELETE_VOLUMEDeletes an instance backup.
RESTORE_VOLUMERestores an instance backup.
INJECT_USER
CLONEClones a Cloud SQL instance.
STOP_REPLICAStops replication on a Cloud SQL read replica instance.
START_REPLICAStarts replication on a Cloud SQL read replica instance.
PROMOTE_REPLICAPromotes a Cloud SQL replica instance.
CREATE_REPLICACreates a Cloud SQL replica instance.
CREATE_USERCreates a new user in a Cloud SQL instance.
DELETE_USERDeletes a user from a Cloud SQL instance.
UPDATE_USERUpdates an existing user in a Cloud SQL instance.
CREATE_DATABASECreates a database in the Cloud SQL instance.
DELETE_DATABASEDeletes a database in the Cloud SQL instance.
UPDATE_DATABASEUpdates a database in the Cloud SQL instance.
FAILOVERPerforms failover of an HA-enabled Cloud SQL failover replica.
DELETE_BACKUPDeletes the backup taken by a backup run.
RECREATE_REPLICA
TRUNCATE_LOGTruncates a general or slow log table in MySQL.
DEMOTE_MASTERDemotes the stand-alone instance to be a Cloud SQL read replica for an external database server.
MAINTENANCEIndicates that the instance is currently in maintenance. Maintenance typically causes the instance to be unavailable for 1-3 minutes.
ENABLE_PRIVATE_IP

This field is deprecated, and will be removed in future version of API.

DEFER_MAINTENANCE
CREATE_CLONE

Creates clone instance.

RESCHEDULE_MAINTENANCEReschedule maintenance to another time.
START_EXTERNAL_SYNCStarts external sync of a Cloud SQL EM replica to an external primary instance.
LOG_CLEANUPRecovers logs from an instance's old data disk.
AUTO_RESTARTPerforms auto-restart of an HA-enabled Cloud SQL database for auto recovery.
SWITCHOVERSwitches the roles of the primary and replica pair. The target instance should be the replica.
UPDATE_BACKUPUpdate a backup.
RECONFIGURE_OLD_PRIMARYReconfigures old primary after a promote replica operation. Effect of a promote operation to the old primary is executed in this operation, asynchronously from the promote replica operation executed to the replica.
CLUSTER_MAINTENANCEIndicates that the instance, its read replicas, and its cascading replicas are in maintenance. Maintenance typically gets initiated on groups of replicas first, followed by the primary instance. For each instance, maintenance typically causes the instance to be unavailable for 1-3 minutes.
SELF_SERVICE_MAINTENANCEIndicates that the instance (and any of its replicas) are currently in maintenance. This is initiated as a self-service request by using SSM. Maintenance typically causes the instance to be unavailable for 1-3 minutes.
SWITCHOVER_TO_REPLICASwitches a primary instance to a replica. This operation runs as part of a switchover operation to the original primary instance.
REPAIR_READ_POOLRepairs entire read pool or specified read pool nodes in the read pool.
CREATE_READ_POOLCreates a Cloud SQL read pool instance.

ImportContext

Database instance import context.

JSON representation
{
  "uri": string,
  "database": string,
  "kind": string,
  "fileType": enum (SqlFileType),
  "csvImportOptions": {
    "table": string,
    "columns": [
      string
    ],
    "escapeCharacter": string,
    "quoteCharacter": string,
    "fieldsTerminatedBy": string,
    "linesTerminatedBy": string
  },
  "importUser": string,
  "bakImportOptions": {
    "encryptionOptions": {
      "certPath": string,
      "pvkPath": string,
      "pvkPassword": string
    },
    "striped": boolean
  }
  "sqlImportOptions": {
    "threads": integer,
    "parallel": boolean
}
Fields
uri

string

Path to the import file in Cloud Storage, in the form gs://bucketName/fileName. Compressed gzip files (.gz) are supported when fileType is SQL. The instance must have write permissions to the bucket and read access to the file.

database

string

The target database for the import. If fileType is SQL, this field is required only if the import file does not specify a database, and is overridden by any database specification in the import file. If fileType is CSV, one database must be specified.

kind

string

This is always sql#importContext.

fileType

enum (SqlFileType)

The file type for the specified uri. * SQL: The file contains SQL statements. * CSV: The file contains CSV data. * BAK: The file contains backup data for a SQL Server instance.

csvImportOptions

object

Options for importing data as CSV.

csvImportOptions.table

string

The table to which CSV data is imported.

csvImportOptions.columns[]

string

The columns to which CSV data is imported. If not specified, all columns of the database table are loaded with CSV data.

csvImportOptions.escapeCharacter

string

Specifies the character that should appear before a data character that needs to be escaped.

csvImportOptions.quoteCharacter

string

Specifies the quoting character to be used when a data value is quoted.

csvImportOptions.fieldsTerminatedBy

string

Specifies the character that separates columns within each row (line) of the file.

csvImportOptions.linesTerminatedBy

string

This is used to separate lines. If a line does not contain all fields, the rest of the columns are set to their default values.

importUser

string

The PostgreSQL user for this import operation. PostgreSQL instances only.

bakImportOptions

object

Import parameters specific to SQL Server .BAK files

bakImportOptions.encryptionOptions

object

bakImportOptions.encryptionOptions.certPath

string

Path to the Certificate (.cer) in Cloud Storage, in the form gs://bucketName/fileName. The instance must have write permissions to the bucket and read access to the file.

bakImportOptions.encryptionOptions.pvkPath

string

Path to the Certificate Private Key (.pvk) in Cloud Storage, in the form gs://bucketName/fileName. The instance must have write permissions to the bucket and read access to the file.

bakImportOptions.encryptionOptions.pvkPassword

string

Password that encrypts the private key

bakImportOptions.striped

boolean

Whether or not the backup set being restored is striped. Applies only to Cloud SQL for SQL Server.

sqlImportOptions

object

Optional. Options for importing data from SQL statements.

sqlImportOptions.threads

integer

Optional. The number of threads to use for parallel import.

sqlImportOptions.parallel

boolean

Optional. Whether or not the import should be parallel.

SqlFileType

Enums
SQL_FILE_TYPE_UNSPECIFIEDUnknown file type.
SQLFile containing SQL statements.
CSVFile in CSV format.
BAK

ExportContext

Database instance export context.

JSON representation
{
  "uri": string,
  "databases": [
    string
  ],
  "kind": string,
  "sqlExportOptions": {
    "tables": [
      string
    ],
    "schemaOnly": boolean,
    "mysqlExportOptions": {
      "masterData": integer
    },
    "threads": integer,
    "parallel": boolean
  },
  "csvExportOptions": {
    "selectQuery": string,
    "escapeCharacter": string,
    "quoteCharacter": string,
    "fieldsTerminatedBy": string,
    "linesTerminatedBy": string
  },
  "fileType": enum (SqlFileType),
  "offload": boolean,
  "bakExportOptions": {
    "striped": boolean,
    "stripeCount": integer
  }
}
Fields
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 request succeeds, but the operation fails. If fileType is SQL and the filename ends with .gz, the contents are compressed.

databases[]

string

Databases to be exported.
MySQL instances: If fileType is SQL and no database is specified, all databases are exported, except for the mysql system database. If fileType is CSV, you can specify one database, either by using this property or by using the csvExportOptions.selectQuery property, which takes precedence over this property.
PostgreSQL instances: You must specify one database to be exported. If fileType is CSV, this database must match the one specified in the csvExportOptions.selectQuery property.
SQL Server instances: You must specify one database to be exported, and the fileType must be BAK.

kind

string

This is always sql#exportContext.

sqlExportOptions

object

Options for exporting data as SQL statements.

sqlExportOptions.tables[]

string

Tables to export, or that were exported, from the specified database. If you specify tables, specify one and only one database. For PostgreSQL instances, you can specify only one table.

sqlExportOptions.schemaOnly

boolean

Export only schemas.

sqlExportOptions.mysqlExportOptions

object

sqlExportOptions.mysqlExportOptions.masterData

integer

Option to include SQL statement required to set up replication. If set to 1, the dump file includes a CHANGE MASTER TO statement with the binary log coordinates, and --set-gtid-purged is set to ON. If set to 2, the CHANGE MASTER TO statement is written as a SQL comment and has no effect. If set to any value other than 1, --set-gtid-purged is set to OFF.

sqlExportOptions.threads

integer

Optional. The number of threads to use for parallel export.

sqlExportOptions.parallel

boolean

Optional. Whether or not the export should be parallel.

csvExportOptions

object

Options for exporting data as CSV. MySQL and PostgreSQL instances only.

csvExportOptions.selectQuery

string

The select query used to extract the data.

csvExportOptions.escapeCharacter

string

Specifies the character that should appear before a data character that needs to be escaped.

csvExportOptions.quoteCharacter

string

Specifies the quoting character to be used when a data value is quoted.

csvExportOptions.fieldsTerminatedBy

string

Specifies the character that separates columns within each row (line) of the file.

csvExportOptions.linesTerminatedBy

string

This is used to separate lines. If a line does not contain all fields, the rest of the columns are set to their default values.

fileType

enum (SqlFileType)

The file type for the specified uri.

offload

boolean

Option for export offload.

bakExportOptions

object

Options for exporting data as BAK files.

bakExportOptions.striped

boolean

Whether or not the export should be striped.

bakExportOptions.stripeCount

integer

Option for specifying how many stripes to use for the export. If blank, and the value of the striped field is true, the number of stripes is automatically chosen.

BackupContext

Backup context.

JSON representation
{
  "backupId": string,
  "kind": string
}
Fields
backupId

string (int64 format)

The identifier of the backup.

kind

string

This is always sql#backupContext.

name

string

The name of the backup. Format: projects/{project}/backups/{backup}

SqlSubOperationType

The sub operation type based on the operation type.

JSON representation
{

  // Union field sub_operation_details can be only one of the following:
  "maintenanceType": enum (SqlMaintenanceType)
  // End of list of possible types for union field sub_operation_details.
}
Fields
Union field sub_operation_details. Sub operation details corresponding to the operation type. sub_operation_details can be only one of the following:
maintenanceType

enum (SqlMaintenanceType)

The type of maintenance to be performed on the instance.

SqlMaintenanceType

The type of maintenance to be performed on the instance.

Enums
SQL_MAINTENANCE_TYPE_UNSPECIFIEDMaintenance type is unspecified.
INSTANCE_MAINTENANCEIndicates that a standalone instance is undergoing maintenance. The instance can be either a primary instance or a replica.
REPLICA_INCLUDED_MAINTENANCEIndicates that the primary instance and all of its replicas, including cascading replicas, are undergoing maintenance. Maintenance is performed on groups of replicas first, followed by the primary instance.
INSTANCE_SELF_SERVICE_MAINTENANCEIndicates that the standalone instance is undergoing maintenance, initiated by self-service. The instance can be either a primary instance or a replica.
REPLICA_INCLUDED_SELF_SERVICE_MAINTENANCEIndicates that the primary instance and all of its replicas are undergoing maintenance, initiated by self-service. Maintenance is performed on groups of replicas first, followed by the primary instance.

Methods

cancel

Cancels an instance operation that has been performed on an instance.

get

Retrieves an instance operation that has been performed on an instance.

list

Lists all instance operations that have been performed on the given Cloud SQL instance in the reverse chronological order of the start time.