Skip to content

associate_instance_event_window

associate_instance_event_window(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional[Boolean] = None,
    instance_event_window_id: Optional[InstanceEventWindowId] = None,
    association_target: Optional[InstanceEventWindowAssociationRequest] = None,
) -> AssociateInstanceEventWindowResult

Associates one or more targets with an event window. Only one type of target (instance IDs, Dedicated Host IDs, or tags) can be specified with an event window.

For more information, see Define event windows for scheduled events in the Amazon EC2 User Guide.

Parameters:

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • instance_event_window_id (Optional[InstanceEventWindowId], default: None ) –

    The ID of the event window.

  • association_target (Optional[InstanceEventWindowAssociationRequest], default: None ) –

    One or more targets associated with the specified event window.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def associate_instance_event_window(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    instance_event_window_id: Optional[
        "capo_ec2.types.instance_event_window_id.InstanceEventWindowId"
    ] = None,
    association_target: Optional[
        "capo_ec2.types.instance_event_window_association_request.InstanceEventWindowAssociationRequest"
    ] = None,
) -> "capo_ec2.types.associate_instance_event_window_result.AssociateInstanceEventWindowResult":
    """<p>Associates one or more targets with an event window. Only one type of target (instance IDs, Dedicated Host IDs, or tags) can be specified with an event window.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/event-windows.html">Define event windows for scheduled events</a> in the <i>Amazon EC2 User Guide</i>.</p>

    Args:
        dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        instance_event_window_id: <p>The ID of the event window.</p>
        association_target: <p>One or more targets associated with the specified event window.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.associate_instance_event_window_request.AssociateInstanceEventWindowRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.associate_instance_event_window_result.AssociateInstanceEventWindowResult"
    ]:
        import capo_ec2._operations.amazon_ec2.associate_instance_event_window

        output, http_response = (
            capo_ec2._operations.amazon_ec2.associate_instance_event_window.associate_instance_event_window(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AssociateInstanceEventWindow")
    )
    input_: capo_ec2.types.associate_instance_event_window_request.AssociateInstanceEventWindowRequest = {}
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if instance_event_window_id is not None:
        input_["instance_event_window_id"] = instance_event_window_id
    if association_target is not None:
        input_["association_target"] = association_target

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output