updateMaintenanceWindowTarget method

Future<UpdateMaintenanceWindowTargetResult> updateMaintenanceWindowTarget({
  1. required String windowId,
  2. required String windowTargetId,
  3. String? description,
  4. String? name,
  5. String? ownerInformation,
  6. bool? replace,
  7. List<Target>? targets,
})

Modifies the target of an existing maintenance window. You can change the following:

  • Name
  • Description
  • Owner
  • IDs for an ID target
  • Tags for a Tag target
  • From any supported tag type to another. The three supported tag types are ID target, Tag target, and resource group. For more information, see Target.

May throw DoesNotExistException. May throw InternalServerError.

Parameter windowId : The maintenance window ID with which to modify the target.

Parameter windowTargetId : The target ID to modify.

Parameter description : An optional description for the update.

Parameter name : A name for the update.

Parameter ownerInformation : User-provided value that will be included in any CloudWatch events raised while running tasks for these targets in this maintenance window.

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

Parameter targets : The targets to add or replace.

Implementation

Future<UpdateMaintenanceWindowTargetResult> updateMaintenanceWindowTarget({
  required String windowId,
  required String windowTargetId,
  String? description,
  String? name,
  String? ownerInformation,
  bool? replace,
  List<Target>? targets,
}) async {
  ArgumentError.checkNotNull(windowId, 'windowId');
  _s.validateStringLength(
    'windowId',
    windowId,
    20,
    20,
    isRequired: true,
  );
  ArgumentError.checkNotNull(windowTargetId, 'windowTargetId');
  _s.validateStringLength(
    'windowTargetId',
    windowTargetId,
    36,
    36,
    isRequired: true,
  );
  _s.validateStringLength(
    'description',
    description,
    1,
    128,
  );
  _s.validateStringLength(
    'name',
    name,
    3,
    128,
  );
  _s.validateStringLength(
    'ownerInformation',
    ownerInformation,
    1,
    128,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonSSM.UpdateMaintenanceWindowTarget'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'WindowId': windowId,
      'WindowTargetId': windowTargetId,
      if (description != null) 'Description': description,
      if (name != null) 'Name': name,
      if (ownerInformation != null) 'OwnerInformation': ownerInformation,
      if (replace != null) 'Replace': replace,
      if (targets != null) 'Targets': targets,
    },
  );

  return UpdateMaintenanceWindowTargetResult.fromJson(jsonResponse.body);
}