updateMaintenanceWindowTask method

Future<UpdateMaintenanceWindowTaskResult> updateMaintenanceWindowTask({
  1. required String windowId,
  2. required String windowTaskId,
  3. String? description,
  4. LoggingInfo? loggingInfo,
  5. String? maxConcurrency,
  6. String? maxErrors,
  7. String? name,
  8. int? priority,
  9. bool? replace,
  10. String? serviceRoleArn,
  11. List<Target>? targets,
  12. String? taskArn,
  13. MaintenanceWindowTaskInvocationParameters? taskInvocationParameters,
  14. Map<String, MaintenanceWindowTaskParameterValueExpression>? taskParameters,
})

Modifies a task assigned to a maintenance window. You can't change the task type, but you can change the following values:

  • TaskARN. For example, you can change a RUN_COMMAND task from AWS-RunPowerShellScript to AWS-RunShellScript.
  • ServiceRoleArn
  • TaskInvocationParameters
  • Priority
  • MaxConcurrency
  • MaxErrors
If the value for a parameter in UpdateMaintenanceWindowTask is null, then the corresponding field is not modified. If you set Replace to true, then all fields required by the RegisterTaskWithMaintenanceWindow action are required for this request. Optional fields that aren't specified are set to null.

May throw DoesNotExistException. May throw InternalServerError.

Parameter windowId : The maintenance window ID that contains the task to modify.

Parameter windowTaskId : The task ID to modify.

Parameter description : The new task description to specify.

Parameter loggingInfo : The new logging location in Amazon S3 to specify.

Parameter maxConcurrency : The new MaxConcurrency value you want to specify. MaxConcurrency is the number of targets that are allowed to run this task in parallel.

Parameter maxErrors : The new MaxErrors value to specify. MaxErrors is the maximum number of errors that are allowed before the task stops being scheduled.

Parameter name : The new task name to specify.

Parameter priority : The new task priority to specify. The lower the number, the higher the priority. Tasks that have the same priority are scheduled in parallel.

Parameter replace : If True, then all fields that are required by the RegisterTaskWithMaintenanceWindow action are also required for this API request. Optional fields that are not specified are set to null.

Parameter serviceRoleArn : The ARN of the IAM service role for Systems Manager to assume when running a maintenance window task. If you do not specify a service role ARN, Systems Manager uses your account's service-linked role. If no service-linked role for Systems Manager exists in your account, it is created when you run RegisterTaskWithMaintenanceWindow.

For more information, see the following topics in the in the AWS Systems Manager User Guide:

Parameter targets : The targets (either instances or tags) to modify. Instances are specified using Key=instanceids,Values=instanceID_1,instanceID_2. Tags are specified using Key=tag_name,Values=tag_value.

Parameter taskArn : The task ARN to modify.

Parameter taskInvocationParameters : The parameters that the task should use during execution. Populate only the fields that match the task type. All other fields should be empty.

Parameter taskParameters : The parameters to modify. The map has the following format:

Key: string, between 1 and 255 characters

Value: an array of strings, each string is between 1 and 255 characters

Implementation

Future<UpdateMaintenanceWindowTaskResult> updateMaintenanceWindowTask({
  required String windowId,
  required String windowTaskId,
  String? description,
  LoggingInfo? loggingInfo,
  String? maxConcurrency,
  String? maxErrors,
  String? name,
  int? priority,
  bool? replace,
  String? serviceRoleArn,
  List<Target>? targets,
  String? taskArn,
  MaintenanceWindowTaskInvocationParameters? taskInvocationParameters,
  Map<String, MaintenanceWindowTaskParameterValueExpression>? taskParameters,
}) async {
  ArgumentError.checkNotNull(windowId, 'windowId');
  _s.validateStringLength(
    'windowId',
    windowId,
    20,
    20,
    isRequired: true,
  );
  ArgumentError.checkNotNull(windowTaskId, 'windowTaskId');
  _s.validateStringLength(
    'windowTaskId',
    windowTaskId,
    36,
    36,
    isRequired: true,
  );
  _s.validateStringLength(
    'description',
    description,
    1,
    128,
  );
  _s.validateStringLength(
    'maxConcurrency',
    maxConcurrency,
    1,
    7,
  );
  _s.validateStringLength(
    'maxErrors',
    maxErrors,
    1,
    7,
  );
  _s.validateStringLength(
    'name',
    name,
    3,
    128,
  );
  _s.validateNumRange(
    'priority',
    priority,
    0,
    1152921504606846976,
  );
  _s.validateStringLength(
    'taskArn',
    taskArn,
    1,
    1600,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonSSM.UpdateMaintenanceWindowTask'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'WindowId': windowId,
      'WindowTaskId': windowTaskId,
      if (description != null) 'Description': description,
      if (loggingInfo != null) 'LoggingInfo': loggingInfo,
      if (maxConcurrency != null) 'MaxConcurrency': maxConcurrency,
      if (maxErrors != null) 'MaxErrors': maxErrors,
      if (name != null) 'Name': name,
      if (priority != null) 'Priority': priority,
      if (replace != null) 'Replace': replace,
      if (serviceRoleArn != null) 'ServiceRoleArn': serviceRoleArn,
      if (targets != null) 'Targets': targets,
      if (taskArn != null) 'TaskArn': taskArn,
      if (taskInvocationParameters != null)
        'TaskInvocationParameters': taskInvocationParameters,
      if (taskParameters != null) 'TaskParameters': taskParameters,
    },
  );

  return UpdateMaintenanceWindowTaskResult.fromJson(jsonResponse.body);
}