create method

Future<Operation> create(
  1. Backup request,
  2. String parent, {
  3. String? backupId,
  4. String? encryptionConfig_encryptionType,
  5. String? encryptionConfig_kmsKeyName,
  6. List<String>? encryptionConfig_kmsKeyNames,
  7. String? $fields,
})

Starts creating a new Cloud Spanner Backup.

The returned backup long-running operation will have a name of the format projects//instances//backups//operations/ and can be used to track creation of the backup. The metadata field type is CreateBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the creation and delete the backup. There can be only one pending backup creation per database. Backup creation of different databases can run concurrently.

request - The metadata request object.

Request parameters:

parent - Required. The name of the instance in which the backup will be created. This must be the same instance that contains the database the backup will be created from. The backup will be stored in the location(s) specified in the instance configuration of this instance. Values are of the form projects//instances/. Value must have pattern ^projects/\[^/\]+/instances/\[^/\]+$.

backupId - Required. The id of the backup to be created. The backup_id appended to parent forms the full backup name of the form projects//instances//backups/.

encryptionConfig_encryptionType - Required. The encryption type of the backup. Possible string values are:

  • "ENCRYPTION_TYPE_UNSPECIFIED" : Unspecified. Do not use.
  • "USE_DATABASE_ENCRYPTION" : Use the same encryption configuration as the database. This is the default option when encryption_config is empty. For example, if the database is using Customer_Managed_Encryption, the backup will be using the same Cloud KMS key as the database.
  • "GOOGLE_DEFAULT_ENCRYPTION" : Use Google default encryption.
  • "CUSTOMER_MANAGED_ENCRYPTION" : Use customer managed encryption. If specified, kms_key_name must contain a valid Cloud KMS key.

encryptionConfig_kmsKeyName - Optional. The Cloud KMS key that will be used to protect the backup. This field should be set only when encryption_type is CUSTOMER_MANAGED_ENCRYPTION. Values are of the form projects//locations//keyRings//cryptoKeys/.

encryptionConfig_kmsKeyNames - Optional. Specifies the KMS configuration for the one or more keys used to protect the backup. Values are of the form projects//locations//keyRings//cryptoKeys/. The keys referenced by kms_key_names must fully cover all regions of the backup's instance configuration. Some examples: * For single region instance configs, specify a single regional location KMS key. * For multi-regional instance configs of type GOOGLE_MANAGED, either specify a multi-regional location KMS key or multiple regional location KMS keys that cover all regions in the instance config. * For an instance config of type USER_MANAGED, please specify only regional location KMS keys to cover each region in the instance config. Multi-regional location KMS keys are not supported for USER_MANAGED instance configs.

$fields - Selector specifying which fields to include in a partial response.

Completes with a Operation.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<Operation> create(
  Backup request,
  core.String parent, {
  core.String? backupId,
  core.String? encryptionConfig_encryptionType,
  core.String? encryptionConfig_kmsKeyName,
  core.List<core.String>? encryptionConfig_kmsKeyNames,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (backupId != null) 'backupId': [backupId],
    if (encryptionConfig_encryptionType != null)
      'encryptionConfig.encryptionType': [encryptionConfig_encryptionType],
    if (encryptionConfig_kmsKeyName != null)
      'encryptionConfig.kmsKeyName': [encryptionConfig_kmsKeyName],
    if (encryptionConfig_kmsKeyNames != null)
      'encryptionConfig.kmsKeyNames': encryptionConfig_kmsKeyNames,
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v1/' + core.Uri.encodeFull('$parent') + '/backups';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return Operation.fromJson(response_ as core.Map<core.String, core.dynamic>);
}