Attaches the specified principal to the specified thing. A principal can be X.509 certificates, Amazon Cognito identities or federated identities.
Requires permission to access the AttachThingPrincipal action.
Parameters:
-
thing_name
(ThingName)
–
-
principal
(Principal)
–
The principal, which can be a certificate ARN (as returned from the CreateCertificate operation) or an Amazon Cognito ID.
-
thing_principal_type
(Optional[ThingPrincipalType], default:
None
)
–
The type of the relation you want to specify when you attach a principal to a thing.
Raises:
Source code in docs_src/capo_iot/_services/io_t.py
| def attach_thing_principal(
self,
thing_name: "capo_iot.types.thing_name.ThingName",
principal: "capo_iot.types.principal.Principal",
*,
config_overrides: Optional[IoTClientConfig] = None,
thing_principal_type: Optional[
"capo_iot.types.thing_principal_type.ThingPrincipalType"
] = None,
) -> "capo_iot.types.attach_thing_principal_response.AttachThingPrincipalResponse":
"""<p>Attaches the specified principal to the specified thing. A principal can be X.509 certificates, Amazon Cognito identities or federated identities.</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">AttachThingPrincipal</a> action.</p>
Args:
thing_name: <p>The name of the thing.</p>
principal: <p>The principal, which can be a certificate ARN (as returned from the CreateCertificate operation) or an Amazon Cognito ID.</p>
thing_principal_type: <p>The type of the relation you want to specify when you attach a principal to a thing.</p> <ul> <li> <p> <code>EXCLUSIVE_THING</code> - Attaches the specified principal to the specified thing, exclusively. The thing will be the only thing that’s attached to the principal.</p> </li> </ul> <ul> <li> <p> <code>NON_EXCLUSIVE_THING</code> - Attaches the specified principal to the specified thing. Multiple things can be attached to the principal.</p> </li> </ul>
Raises:
capo_iot.errors.internal_failure_exception.InternalFailureException: <p>An unexpected error has occurred.</p>
capo_iot.errors.invalid_request_exception.InvalidRequestException: <p>The request is not valid.</p>
capo_iot.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
capo_iot.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is temporarily unavailable.</p>
capo_iot.errors.throttling_exception.ThrottlingException: <p>The rate exceeds the limit.</p>
capo_iot.errors.unauthorized_exception.UnauthorizedException: <p>You are not authorized to perform this operation.</p>
capo_iot.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_iot.types.attach_thing_principal_request.AttachThingPrincipalRequest]",
) -> OperationResponse[
"capo_iot.types.attach_thing_principal_response.AttachThingPrincipalResponse"
]:
import capo_iot._operations.aws_iot_service.attach_thing_principal
output, http_response = (
capo_iot._operations.aws_iot_service.attach_thing_principal.attach_thing_principal(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("AttachThingPrincipal")
)
input_: capo_iot.types.attach_thing_principal_request.AttachThingPrincipalRequest = {
"thing_name": thing_name,
"principal": principal,
}
if thing_principal_type is not None:
input_["thing_principal_type"] = thing_principal_type
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|