createBackup method

Future<CreateBackupResponse> createBackup({
  1. required String serverName,
  2. String? description,
  3. List<Tag>? tags,
})

Creates an application-level backup of a server. While the server is in the BACKING_UP state, the server cannot be changed, and no additional backup can be created.

Backups can be created for servers in RUNNING, HEALTHY, and UNHEALTHY states. By default, you can create a maximum of 50 manual backups.

This operation is asynchronous.

A LimitExceededException is thrown when the maximum number of manual backups is reached. An InvalidStateException is thrown when the server is not in any of the following states: RUNNING, HEALTHY, or UNHEALTHY. A ResourceNotFoundException is thrown when the server is not found. A ValidationException is thrown when parameters of the request are not valid.

May throw InvalidStateException. May throw LimitExceededException. May throw ResourceNotFoundException. May throw ValidationException.

Parameter serverName : The name of the server that you want to back up.

Parameter description : A user-defined description of the backup.

Parameter tags : A map that contains tag keys and tag values to attach to an AWS OpsWorks-CM server backup.

  • The key cannot be empty.
  • The key can be a maximum of 127 characters, and can contain only Unicode letters, numbers, or separators, or the following special characters: + - = . _ : /
  • The value can be a maximum 255 characters, and contain only Unicode letters, numbers, or separators, or the following special characters: + - = . _ : /
  • Leading and trailing white spaces are trimmed from both the key and value.
  • A maximum of 50 user-applied tags is allowed for tag-supported AWS OpsWorks-CM resources.

Implementation

Future<CreateBackupResponse> createBackup({
  required String serverName,
  String? description,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(serverName, 'serverName');
  _s.validateStringLength(
    'serverName',
    serverName,
    1,
    40,
    isRequired: true,
  );
  _s.validateStringLength(
    'description',
    description,
    0,
    10000,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'OpsWorksCM_V2016_11_01.CreateBackup'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ServerName': serverName,
      if (description != null) 'Description': description,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateBackupResponse.fromJson(jsonResponse.body);
}