updateServer method

Future<UpdateServerResponse> updateServer({
  1. required String serverName,
  2. int? backupRetentionCount,
  3. bool? disableAutomatedBackup,
  4. String? preferredBackupWindow,
  5. String? preferredMaintenanceWindow,
})

Updates settings for a server.

This operation is synchronous.

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

Parameter serverName : The name of the server to update.

Parameter backupRetentionCount : Sets the number of automated backups that you want to keep.

Parameter disableAutomatedBackup : Setting DisableAutomatedBackup to true disables automated or scheduled backups. Automated backups are enabled by default.

Implementation

Future<UpdateServerResponse> updateServer({
  required String serverName,
  int? backupRetentionCount,
  bool? disableAutomatedBackup,
  String? preferredBackupWindow,
  String? preferredMaintenanceWindow,
}) async {
  ArgumentError.checkNotNull(serverName, 'serverName');
  _s.validateStringLength(
    'serverName',
    serverName,
    1,
    40,
    isRequired: true,
  );
  _s.validateStringLength(
    'preferredBackupWindow',
    preferredBackupWindow,
    0,
    10000,
  );
  _s.validateStringLength(
    'preferredMaintenanceWindow',
    preferredMaintenanceWindow,
    0,
    10000,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'OpsWorksCM_V2016_11_01.UpdateServer'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ServerName': serverName,
      if (backupRetentionCount != null)
        'BackupRetentionCount': backupRetentionCount,
      if (disableAutomatedBackup != null)
        'DisableAutomatedBackup': disableAutomatedBackup,
      if (preferredBackupWindow != null)
        'PreferredBackupWindow': preferredBackupWindow,
      if (preferredMaintenanceWindow != null)
        'PreferredMaintenanceWindow': preferredMaintenanceWindow,
    },
  );

  return UpdateServerResponse.fromJson(jsonResponse.body);
}