describeBackups method

Future<DescribeBackupsResponse> describeBackups({
  1. String? backupId,
  2. int? maxResults,
  3. String? nextToken,
  4. String? serverName,
})

Describes backups. The results are ordered by time, with newest backups first. If you do not specify a BackupId or ServerName, the command returns all backups.

This operation is synchronous.

A ResourceNotFoundException is thrown when the backup does not exist. A ValidationException is raised when parameters of the request are not valid.

May throw ValidationException. May throw ResourceNotFoundException. May throw InvalidNextTokenException.

Parameter backupId : Describes a single backup.

Parameter maxResults : This is not currently implemented for DescribeBackups requests.

Parameter nextToken : This is not currently implemented for DescribeBackups requests.

Parameter serverName : Returns backups for the server with the specified ServerName.

Implementation

Future<DescribeBackupsResponse> describeBackups({
  String? backupId,
  int? maxResults,
  String? nextToken,
  String? serverName,
}) async {
  _s.validateStringLength(
    'backupId',
    backupId,
    0,
    79,
  );
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    1152921504606846976,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    0,
    10000,
  );
  _s.validateStringLength(
    'serverName',
    serverName,
    1,
    40,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'OpsWorksCM_V2016_11_01.DescribeBackups'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (backupId != null) 'BackupId': backupId,
      if (maxResults != null) 'MaxResults': maxResults,
      if (nextToken != null) 'NextToken': nextToken,
      if (serverName != null) 'ServerName': serverName,
    },
  );

  return DescribeBackupsResponse.fromJson(jsonResponse.body);
}