Skip to content

update_maintenance_window

update_maintenance_window(
    window_id: MaintenanceWindowId,
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    name: Optional[MaintenanceWindowName] = None,
    description: Optional[MaintenanceWindowDescription] = None,
    start_date: Optional[MaintenanceWindowStringDateTime] = None,
    end_date: Optional[MaintenanceWindowStringDateTime] = None,
    schedule: Optional[MaintenanceWindowSchedule] = None,
    schedule_timezone: Optional[MaintenanceWindowTimezone] = None,
    schedule_offset: Optional[MaintenanceWindowOffset] = None,
    duration: Optional[MaintenanceWindowDurationHours] = None,
    cutoff: Optional[MaintenanceWindowCutoff] = None,
    allow_unassociated_targets: Optional[
        MaintenanceWindowAllowUnassociatedTargets
    ] = None,
    enabled: Optional[MaintenanceWindowEnabled] = None,
    replace: Optional[Boolean] = None,
) -> UpdateMaintenanceWindowResult

Updates an existing maintenance window. Only specified parameters are modified.

The value you specify for Duration determines the specific end time for the maintenance window based on the time it begins. No maintenance window tasks are permitted to start after the resulting endtime minus the number of hours you specify for Cutoff. For example, if the maintenance window starts at 3 PM, the duration is three hours, and the value you specify for Cutoff is one hour, no maintenance window tasks can start after 5 PM.

Parameters:

  • window_id (MaintenanceWindowId) –

    The ID of the maintenance window to update.

  • name (Optional[MaintenanceWindowName], default: None ) –

    The name of the maintenance window.

  • description (Optional[MaintenanceWindowDescription], default: None ) –

    An optional description for the update request.

  • start_date (Optional[MaintenanceWindowStringDateTime], default: None ) –

    The date and time, in ISO-8601 Extended format, for when you want the maintenance window to become active. StartDate allows you to delay activation of the maintenance window until the specified future date.

    When using a rate schedule, if you provide a start date that occurs in the past, the current date and time are used as the start date.

  • end_date (Optional[MaintenanceWindowStringDateTime], default: None ) –

    The date and time, in ISO-8601 Extended format, for when you want the maintenance window to become inactive. EndDate allows you to set a date and time in the future when the maintenance window will no longer run.

  • schedule (Optional[MaintenanceWindowSchedule], default: None ) –

    The schedule of the maintenance window in the form of a cron or rate expression.

  • schedule_timezone (Optional[MaintenanceWindowTimezone], default: None ) –

    The time zone that the scheduled maintenance window executions are based on, in Internet Assigned Numbers Authority (IANA) format. For example: "America/Los_Angeles", "UTC", or "Asia/Seoul". For more information, see the Time Zone Database on the IANA website.

  • schedule_offset (Optional[MaintenanceWindowOffset], default: None ) –

    The number of days to wait after the date and time specified by a cron expression before running the maintenance window.

    For example, the following cron expression schedules a maintenance window to run the third Tuesday of every month at 11:30 PM.

    cron(30 23 ? * TUE#3 *)

    If the schedule offset is 2, the maintenance window won't run until two days later.

  • duration (Optional[MaintenanceWindowDurationHours], default: None ) –

    The duration of the maintenance window in hours.

  • cutoff (Optional[MaintenanceWindowCutoff], default: None ) –

    The number of hours before the end of the maintenance window that Amazon Web Services Systems Manager stops scheduling new tasks for execution.

  • allow_unassociated_targets (Optional[MaintenanceWindowAllowUnassociatedTargets], default: None ) –

    Whether targets must be registered with the maintenance window before tasks can be defined for those targets.

  • enabled (Optional[MaintenanceWindowEnabled], default: None ) –

    Whether the maintenance window is enabled.

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

    If True, then all fields that are required by the CreateMaintenanceWindow operation are also required for this API request. Optional fields that aren't specified are set to null.

Raises:

  • DoesNotExistException –

    Error returned when the ID specified for a resource, such as a maintenance window or patch baseline, doesn't exist.

    For information about resource quotas in Amazon Web Services Systems Manager, see Systems Manager service quotas in the Amazon Web Services General Reference.

  • InternalServerError –

    An error occurred on the server side.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_ssm/_services/ssm.py
def update_maintenance_window(
    self,
    window_id: "capo_ssm.types.maintenance_window_id.MaintenanceWindowId",
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    name: Optional[
        "capo_ssm.types.maintenance_window_name.MaintenanceWindowName"
    ] = None,
    description: Optional[
        "capo_ssm.types.maintenance_window_description.MaintenanceWindowDescription"
    ] = None,
    start_date: Optional[
        "capo_ssm.types.maintenance_window_string_date_time.MaintenanceWindowStringDateTime"
    ] = None,
    end_date: Optional[
        "capo_ssm.types.maintenance_window_string_date_time.MaintenanceWindowStringDateTime"
    ] = None,
    schedule: Optional[
        "capo_ssm.types.maintenance_window_schedule.MaintenanceWindowSchedule"
    ] = None,
    schedule_timezone: Optional[
        "capo_ssm.types.maintenance_window_timezone.MaintenanceWindowTimezone"
    ] = None,
    schedule_offset: Optional[
        "capo_ssm.types.maintenance_window_offset.MaintenanceWindowOffset"
    ] = None,
    duration: Optional[
        "capo_ssm.types.maintenance_window_duration_hours.MaintenanceWindowDurationHours"
    ] = None,
    cutoff: Optional[
        "capo_ssm.types.maintenance_window_cutoff.MaintenanceWindowCutoff"
    ] = None,
    allow_unassociated_targets: Optional[
        "capo_ssm.types.maintenance_window_allow_unassociated_targets.MaintenanceWindowAllowUnassociatedTargets"
    ] = None,
    enabled: Optional[
        "capo_ssm.types.maintenance_window_enabled.MaintenanceWindowEnabled"
    ] = None,
    replace: Optional["capo_ssm.types.boolean.Boolean"] = None,
) -> (
    "capo_ssm.types.update_maintenance_window_result.UpdateMaintenanceWindowResult"
):
    """<p>Updates an existing maintenance window. Only specified parameters are modified.</p> <note> <p>The value you specify for <code>Duration</code> determines the specific end time for the maintenance window based on the time it begins. No maintenance window tasks are permitted to start after the resulting endtime minus the number of hours you specify for <code>Cutoff</code>. For example, if the maintenance window starts at 3 PM, the duration is three hours, and the value you specify for <code>Cutoff</code> is one hour, no maintenance window tasks can start after 5 PM.</p> </note>

    Args:
        window_id: <p>The ID of the maintenance window to update.</p>
        name: <p>The name of the maintenance window.</p>
        description: <p>An optional description for the update request.</p>
        start_date: <p>The date and time, in ISO-8601 Extended format, for when you want the maintenance window to become active. <code>StartDate</code> allows you to delay activation of the maintenance window until the specified future date.</p> <note> <p>When using a rate schedule, if you provide a start date that occurs in the past, the current date and time are used as the start date. </p> </note>
        end_date: <p>The date and time, in ISO-8601 Extended format, for when you want the maintenance window to become inactive. <code>EndDate</code> allows you to set a date and time in the future when the maintenance window will no longer run.</p>
        schedule: <p>The schedule of the maintenance window in the form of a cron or rate expression.</p>
        schedule_timezone: <p>The time zone that the scheduled maintenance window executions are based on, in Internet Assigned Numbers Authority (IANA) format. For example: "America/Los_Angeles", "UTC", or "Asia/Seoul". For more information, see the <a href="https://www.iana.org/time-zones">Time Zone Database</a> on the IANA website.</p>
        schedule_offset: <p>The number of days to wait after the date and time specified by a cron expression before running the maintenance window.</p> <p>For example, the following cron expression schedules a maintenance window to run the third Tuesday of every month at 11:30 PM.</p> <p> <code>cron(30 23 ? * TUE#3 *)</code> </p> <p>If the schedule offset is <code>2</code>, the maintenance window won't run until two days later.</p>
        duration: <p>The duration of the maintenance window in hours.</p>
        cutoff: <p>The number of hours before the end of the maintenance window that Amazon Web Services Systems Manager stops scheduling new tasks for execution.</p>
        allow_unassociated_targets: <p>Whether targets must be registered with the maintenance window before tasks can be defined for those targets.</p>
        enabled: <p>Whether the maintenance window is enabled.</p>
        replace: <p>If <code>True</code>, then all fields that are required by the <a>CreateMaintenanceWindow</a> operation are also required for this API request. Optional fields that aren't specified are set to null. </p>

    Raises:
        capo_ssm.errors.does_not_exist_exception.DoesNotExistException: <p>Error returned when the ID specified for a resource, such as a maintenance window or patch baseline, doesn't exist.</p> <p>For information about resource quotas in Amazon Web Services Systems Manager, see <a href="https://docs.aws.amazon.com/general/latest/gr/ssm.html#limits_ssm">Systems Manager service quotas</a> in the <i>Amazon Web Services General Reference</i>.</p>
        capo_ssm.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_ssm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ssm.types.update_maintenance_window_request.UpdateMaintenanceWindowRequest]",
    ) -> OperationResponse[
        "capo_ssm.types.update_maintenance_window_result.UpdateMaintenanceWindowResult"
    ]:
        import capo_ssm._operations.amazon_ssm.update_maintenance_window

        output, http_response = (
            capo_ssm._operations.amazon_ssm.update_maintenance_window.update_maintenance_window(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_ssm.types.update_maintenance_window_request.UpdateMaintenanceWindowRequest",
    ) -> dict[str, Any]:
        import capo_ssm.types.update_maintenance_window_request

        return capo_ssm.types.update_maintenance_window_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_ssm.types.update_maintenance_window_result.UpdateMaintenanceWindowResult",
    ) -> dict[str, Any]:
        import capo_ssm.types.update_maintenance_window_result

        return capo_ssm.types.update_maintenance_window_result.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "UpdateMaintenanceWindow",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_ssm.types.update_maintenance_window_request.UpdateMaintenanceWindowRequest = {
        "window_id": window_id
    }
    if name is not None:
        input_["name"] = name
    if description is not None:
        input_["description"] = description
    if start_date is not None:
        input_["start_date"] = start_date
    if end_date is not None:
        input_["end_date"] = end_date
    if schedule is not None:
        input_["schedule"] = schedule
    if schedule_timezone is not None:
        input_["schedule_timezone"] = schedule_timezone
    if schedule_offset is not None:
        input_["schedule_offset"] = schedule_offset
    if duration is not None:
        input_["duration"] = duration
    if cutoff is not None:
        input_["cutoff"] = cutoff
    if allow_unassociated_targets is not None:
        input_["allow_unassociated_targets"] = allow_unassociated_targets
    if enabled is not None:
        input_["enabled"] = enabled
    if replace is not None:
        input_["replace"] = replace

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