Disconnects a connected MQTT client from Amazon Web Services IoT Core. When you disconnect a client, Amazon Web Services IoT Core closes the client's network connection and optionally cleans the session state.
Requires permission to access the DeleteConnection action.
Parameters:
-
client_id
(ClientId)
–
The unique identifier of the MQTT client to disconnect. The client ID can't start with a dollar sign ($).
MQTT client IDs must be URL encoded (percent-encoded) when they contain characters that are not valid in HTTP requests, such as spaces, forward slashes (/), and UTF-8 characters.
-
clean_session
(Optional[CleanSession], default:
None
)
–
Specifies whether to remove the client's persistent session state when disconnecting. Set to TRUE to delete all session information, including subscriptions and queued messages. Set to FALSE to preserve the session state for persistent sessions. For clean sessions this parameter will be ignored. By default, this is set to FALSE (preserves the session state).
-
prevent_will_message
(Optional[PreventWillMessage], default:
None
)
–
Controls if Amazon Web Services IoT Core publishes the client's Last Will and Testament (LWT) message upon disconnection. Set to TRUE to prevent publishing the LWT message. Set to FALSE to ensure that LWT is published. By default, this is set to FALSE (LWT message is published).
Raises:
Source code in docs_src/capo_iot_data_plane/_services/io_t_data_plane.py
| def delete_connection(
self,
client_id: "capo_iot_data_plane.types.client_id.ClientId",
*,
config_overrides: Optional[IoTDataPlaneClientConfig] = None,
clean_session: Optional[
"capo_iot_data_plane.types.clean_session.CleanSession"
] = None,
prevent_will_message: Optional[
"capo_iot_data_plane.types.prevent_will_message.PreventWillMessage"
] = None,
) -> None:
"""<p>Disconnects a connected MQTT client from Amazon Web Services IoT Core. When you disconnect a client, Amazon Web Services IoT Core closes the client's network connection and optionally cleans the session state.</p> <p>Requires permission to access the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions">DeleteConnection</a> action.</p>
Args:
client_id: <p>The unique identifier of the MQTT client to disconnect. The client ID can't start with a dollar sign ($).</p> <p>MQTT client IDs must be URL encoded (percent-encoded) when they contain characters that are not valid in HTTP requests, such as spaces, forward slashes (/), and UTF-8 characters.</p>
clean_session: <p>Specifies whether to remove the client's persistent session state when disconnecting. Set to <code>TRUE</code> to delete all session information, including subscriptions and queued messages. Set to <code>FALSE</code> to preserve the session state for <a href="https://docs.aws.amazon.com/iot/latest/developerguide/mqtt.html#mqtt-persistent-sessions">persistent sessions</a>. For clean sessions this parameter will be ignored. By default, this is set to <code>FALSE</code> (preserves the session state).</p>
prevent_will_message: <p>Controls if Amazon Web Services IoT Core publishes the client's Last Will and Testament (LWT) message upon disconnection. Set to <code>TRUE</code> to prevent publishing the LWT message. Set to <code>FALSE</code> to ensure that LWT is published. By default, this is set to <code>FALSE</code> (LWT message is published).</p>
Raises:
capo_iot_data_plane.errors.forbidden_exception.ForbiddenException: <p>The caller isn't authorized to make the request.</p>
capo_iot_data_plane.errors.internal_failure_exception.InternalFailureException: <p>An unexpected error has occurred.</p>
capo_iot_data_plane.errors.invalid_request_exception.InvalidRequestException: <p>The request is not valid.</p>
capo_iot_data_plane.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
capo_iot_data_plane.errors.throttling_exception.ThrottlingException: <p>The rate exceeds the limit.</p>
capo_iot_data_plane.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_iot_data_plane.types.delete_connection_request.DeleteConnectionRequest]",
) -> OperationResponse[None]:
import capo_iot_data_plane._operations.iot_moonraker_service.delete_connection
output, http_response = (
capo_iot_data_plane._operations.iot_moonraker_service.delete_connection.delete_connection(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("DeleteConnection")
)
input_: capo_iot_data_plane.types.delete_connection_request.DeleteConnectionRequest = {
"client_id": client_id
}
if clean_session is not None:
input_["clean_session"] = clean_session
if prevent_will_message is not None:
input_["prevent_will_message"] = prevent_will_message
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|