registerTargetWithMaintenanceWindow method

Future<RegisterTargetWithMaintenanceWindowResult> registerTargetWithMaintenanceWindow({
  1. required MaintenanceWindowResourceType resourceType,
  2. required List<Target> targets,
  3. required String windowId,
  4. String? clientToken,
  5. String? description,
  6. String? name,
  7. String? ownerInformation,
})

Registers a target with a maintenance window.

May throw DoesNotExistException. May throw IdempotentParameterMismatch. May throw InternalServerError. May throw ResourceLimitExceededException.

Parameter resourceType : The type of target being registered with the maintenance window.

Parameter targets : The targets to register with the maintenance window. In other words, the managed nodes to run commands on when the maintenance window runs. You can specify targets using managed node IDs, resource group names, or tags that have been applied to managed nodes.

Example 1: Specify managed node IDs

Key=InstanceIds,Values=

Example 2: Use tag key-pairs applied to managed nodes

Key=tag:

Example 3: Use tag-keys applied to managed nodes

Key=tag-key,Values=

Example 4: Use resource group names

Key=resource-groups:Name,Values=

Example 5: Use filters for resource group types

Key=resource-groups:ResourceTypeFilters,Values=

Key=resource-groups:ResourceTypeFilters,Values=AWS::EC2::INSTANCE,AWS::EC2::VPC For more information about these examples formats, including the best use case for each one, see Examples: Register targets with a maintenance window in the Amazon Web Services Systems Manager User Guide.

Parameter windowId : The ID of the maintenance window the target should be registered with.

Parameter clientToken : User-provided idempotency token.

Parameter description : An optional description for the target.

Parameter name : An optional name for the target.

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

Implementation

Future<RegisterTargetWithMaintenanceWindowResult>
    registerTargetWithMaintenanceWindow({
  required MaintenanceWindowResourceType resourceType,
  required List<Target> targets,
  required String windowId,
  String? clientToken,
  String? description,
  String? name,
  String? ownerInformation,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonSSM.RegisterTargetWithMaintenanceWindow'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ResourceType': resourceType.value,
      'Targets': targets,
      'WindowId': windowId,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (description != null) 'Description': description,
      if (name != null) 'Name': name,
      if (ownerInformation != null) 'OwnerInformation': ownerInformation,
    },
  );

  return RegisterTargetWithMaintenanceWindowResult.fromJson(
      jsonResponse.body);
}