Approves a time off request. Evaluates agent time off balances and group time off allowances before approving. RuleFailureAction controls what happens when these evaluations fail. The request is rejected with CONFLICTING_TIME_OFF_REQUEST if it overlaps another time off request for the user that is APPROVED or being approved.
The time off request is processed asynchronously, so a successful call doesn't indicate the final status. Read the resulting status with GetTimeOff or from the time off state-change events.
Approving an APPROVED request succeeds without a change. Approving a REJECTED request evaluates the rules again, so it can end APPROVED or REJECTED, and repeating the call can give a different result. Check the status with GetTimeOff before you retry.
Returns ConflictException if the request is PENDING or CANCELLED. PENDING means Connect Customer is still processing the request asynchronously. Wait until GetTimeOff returns a status other than PENDING, and then retry.
When the approval succeeds, Connect Customer cancels any overtime or voluntary time off activity that overlaps the approved window.
Connect Customer doesn't check whether the principal that calls this operation supervises the user. The staffing group's approval settings also don't apply. IAM permissions are the only control. If you allow a principal to call this operation, that principal can send RuleFailureAction OVERRIDE and approve a request past failed rules. Grant permission for this operation only to principals that you trust to override time off rules.
Parameters:
-
instance_id
(InstanceIdOrArn)
–
The identifier of the Connect Customer instance. This can be the ID or the ARN of the instance. You can find the instance ID in the Amazon Resource Name (ARN) of the instance.
-
user_id
(UserIdOrArn)
–
The identifier of the user who the time off request belongs to. This can be the ID or the ARN of the user.
-
time_off_id
(TimeOffId)
–
The unique identifier of the time off request to approve. If the time off request doesn't belong to UserId, the operation returns ResourceNotFoundException.
-
description
(Optional[Description], default:
None
)
–
A description recorded with the approval. GetTimeOff doesn't return it.
-
rule_failure_action
(Optional[RuleFailureAction], default:
None
)
–
Controls what happens when a configured rule fails. REJECT, the default, records an ERROR and leaves the request REJECTED. OVERRIDE records a WARNING and approves the request, like the Override time off rules option in the Connect Customer admin website. OVERRIDE never waives CONFLICTING_TIME_OFF_REQUEST.
Raises:
Examples:
To approve a time off request past a failed rule
The following example approves a time off request with RuleFailureAction OVERRIDE, so a failed rule is recorded as a WARNING instead of rejecting the request.
>>> await client.approve_time_off(instance_id='12345678-1234-1234-1234-123456789012', user_id='87654321-4321-4321-4321-210987654321', time_off_id='abcdef12-3456-7890-abcd-ef1234567890', description='Approved with coverage from the evening shift', rule_failure_action='OVERRIDE')
Source code in docs_src/capo_connectscheduling/_services/async_connect_scheduling.py
| async def approve_time_off(
self,
instance_id: "capo_connectscheduling.types.instance_id_or_arn.InstanceIdOrArn",
user_id: "capo_connectscheduling.types.user_id_or_arn.UserIdOrArn",
time_off_id: "capo_connectscheduling.types.time_off_id.TimeOffId",
*,
config_overrides: Optional[AsyncConnectSchedulingClientConfig] = None,
description: Optional[
"capo_connectscheduling.types.description.Description"
] = None,
rule_failure_action: Optional[
"capo_connectscheduling.types.rule_failure_action.RuleFailureAction"
] = None,
) -> (
"capo_connectscheduling.types.approve_time_off_response.ApproveTimeOffResponse"
):
"""<p>Approves a time off request. Evaluates agent time off balances and group time off allowances before approving. <code>RuleFailureAction</code> controls what happens when these evaluations fail. The request is rejected with <code>CONFLICTING_TIME_OFF_REQUEST</code> if it overlaps another time off request for the user that is <code>APPROVED</code> or being approved.</p> <p>The time off request is processed asynchronously, so a successful call doesn't indicate the final status. Read the resulting status with <code>GetTimeOff</code> or from the time off state-change events.</p> <p>Approving an <code>APPROVED</code> request succeeds without a change. Approving a <code>REJECTED</code> request evaluates the rules again, so it can end <code>APPROVED</code> or <code>REJECTED</code>, and repeating the call can give a different result. Check the status with <code>GetTimeOff</code> before you retry.</p> <p>Returns <code>ConflictException</code> if the request is <code>PENDING</code> or <code>CANCELLED</code>. <code>PENDING</code> means Connect Customer is still processing the request asynchronously. Wait until <code>GetTimeOff</code> returns a status other than <code>PENDING</code>, and then retry.</p> <important> <p>When the approval succeeds, Connect Customer cancels any overtime or voluntary time off activity that overlaps the approved window.</p> </important> <note> <p>Connect Customer doesn't check whether the principal that calls this operation supervises the user. The staffing group's approval settings also don't apply. IAM permissions are the only control. If you allow a principal to call this operation, that principal can send <code>RuleFailureAction</code> <code>OVERRIDE</code> and approve a request past failed rules. Grant permission for this operation only to principals that you trust to override time off rules.</p> </note>
Args:
instance_id: <p>The identifier of the Connect Customer instance. This can be the ID or the ARN of the instance. You can <a href="https://docs.aws.amazon.com/connect/latest/adminguide/find-instance-arn.html">find the instance ID</a> in the Amazon Resource Name (ARN) of the instance.</p>
user_id: <p>The identifier of the user who the time off request belongs to. This can be the ID or the ARN of the user.</p>
time_off_id: <p>The unique identifier of the time off request to approve. If the time off request doesn't belong to <code>UserId</code>, the operation returns <code>ResourceNotFoundException</code>.</p>
description: <p>A description recorded with the approval. <code>GetTimeOff</code> doesn't return it.</p>
rule_failure_action: <p>Controls what happens when a configured rule fails. <code>REJECT</code>, the default, records an <code>ERROR</code> and leaves the request <code>REJECTED</code>. <code>OVERRIDE</code> records a <code>WARNING</code> and approves the request, like the <i>Override time off rules</i> option in the Connect Customer admin website. <code>OVERRIDE</code> never waives <code>CONFLICTING_TIME_OFF_REQUEST</code>.</p>
Raises:
capo_connectscheduling.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient permissions to perform this action.</p>
capo_connectscheduling.errors.conflict_exception.ConflictException: <p>The request could not be processed because of a conflict with the current state of the resource.</p>
capo_connectscheduling.errors.internal_server_exception.InternalServerException: <p>The request processing failed because of an error or failure with the service.</p>
capo_connectscheduling.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found.</p>
capo_connectscheduling.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
capo_connectscheduling.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an AWS service.</p>
capo_connectscheduling.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To approve a time off request past a failed rule
The following example approves a time off request with RuleFailureAction OVERRIDE, so a failed rule is recorded as a WARNING instead of rejecting the request.
>>> await client.approve_time_off(instance_id='12345678-1234-1234-1234-123456789012', user_id='87654321-4321-4321-4321-210987654321', time_off_id='abcdef12-3456-7890-abcd-ef1234567890', description='Approved with coverage from the evening shift', rule_failure_action='OVERRIDE')
"""
async def _handler(
req: "AsyncOperationRequest[capo_connectscheduling.types.approve_time_off_request.ApproveTimeOffRequest]",
) -> AsyncOperationResponse[
"capo_connectscheduling.types.approve_time_off_response.ApproveTimeOffResponse"
]:
import capo_connectscheduling._operations.amazon_connect_scheduling.approve_time_off
(
output,
http_response,
) = await capo_connectscheduling._operations.amazon_connect_scheduling.approve_time_off.async_approve_time_off(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
def _redact_input(
input_: "capo_connectscheduling.types.approve_time_off_request.ApproveTimeOffRequest",
) -> dict[str, Any]:
import capo_connectscheduling.types.approve_time_off_request
return (
capo_connectscheduling.types.approve_time_off_request.redact_sensitive(
input_
)
)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging("ApproveTimeOff", redact_input=_redact_input),
)
input_: capo_connectscheduling.types.approve_time_off_request.ApproveTimeOffRequest = {
"instance_id": instance_id,
"user_id": user_id,
"time_off_id": time_off_id,
}
if description is not None:
input_["description"] = description
if rule_failure_action is not None:
input_["rule_failure_action"] = rule_failure_action
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|