Creates a new User within a collection specified by CollectionId. Takes UserId as a parameter, which is a user provided ID which should be unique within the collection. The provided UserId will alias the system generated UUID to make the UserId more user friendly.
Uses a ClientToken, an idempotency token that ensures a call to CreateUser completes only once. If the value is not supplied, the AWS SDK generates an idempotency token for the requests. This prevents retries after a network error results from making multiple CreateUser calls.
Parameters:
-
collection_id
(CollectionId)
–
The ID of an existing collection to which the new UserID needs to be created.
-
user_id
(UserId)
–
ID for the UserID to be created. This ID needs to be unique within the collection.
-
client_request_token
(Optional[ClientRequestToken], default:
None
)
–
Idempotent token used to identify the request to CreateUser. If you use the same token with multiple CreateUser requests, the same response is returned. Use ClientRequestToken to prevent the same request from being processed more than once.
Raises:
-
AccessDeniedException
–
You are not authorized to perform the action.
-
ConflictException
–
A User with the same Id already exists within the collection, or the update or deletion of the User caused an inconsistent state. **
-
IdempotentParameterMismatchException
–
A ClientRequestToken input parameter was reused with an operation, but at least one of the other input parameters is different from the previous call to the operation.
-
InternalServerError
–
Amazon Rekognition experienced a service issue. Try your call again.
-
InvalidParameterException
–
Input parameter violated a constraint. Validate your parameter before calling the API operation again.
-
ProvisionedThroughputExceededException
–
The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.
-
ResourceNotFoundException
–
The resource specified in the request cannot be found.
-
ServiceQuotaExceededException
–
The size of the collection exceeds the allowed limit. For more information, see Guidelines and quotas in Amazon Rekognition in the Amazon Rekognition Developer Guide.
-
ThrottlingException
–
Amazon Rekognition is temporarily unable to process the request. Try your call again.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
CreateUser
Creates a new User within a collection specified by CollectionId.
>>> client.create_user(collection_id='MyCollection', user_id='DemoUser')
Source code in docs_src/capo_rekognition/_services/rekognition.py
| def create_user(
self,
collection_id: "capo_rekognition.types.collection_id.CollectionId",
user_id: "capo_rekognition.types.user_id.UserId",
*,
config_overrides: Optional[RekognitionClientConfig] = None,
client_request_token: Optional[
"capo_rekognition.types.client_request_token.ClientRequestToken"
] = None,
) -> "capo_rekognition.types.create_user_response.CreateUserResponse":
"""<p>Creates a new User within a collection specified by <code>CollectionId</code>. Takes <code>UserId</code> as a parameter, which is a user provided ID which should be unique within the collection. The provided <code>UserId</code> will alias the system generated UUID to make the <code>UserId</code> more user friendly. </p> <p>Uses a <code>ClientToken</code>, an idempotency token that ensures a call to <code>CreateUser</code> completes only once. If the value is not supplied, the AWS SDK generates an idempotency token for the requests. This prevents retries after a network error results from making multiple <code>CreateUser</code> calls. </p>
Args:
collection_id: <p>The ID of an existing collection to which the new UserID needs to be created.</p>
user_id: <p>ID for the UserID to be created. This ID needs to be unique within the collection.</p>
client_request_token: <p>Idempotent token used to identify the request to <code>CreateUser</code>. If you use the same token with multiple <code>CreateUser</code> requests, the same response is returned. Use ClientRequestToken to prevent the same request from being processed more than once.</p>
Raises:
capo_rekognition.errors.access_denied_exception.AccessDeniedException: <p>You are not authorized to perform the action.</p>
capo_rekognition.errors.conflict_exception.ConflictException: <p> A User with the same Id already exists within the collection, or the update or deletion of the User caused an inconsistent state. ** </p>
capo_rekognition.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>A <code>ClientRequestToken</code> input parameter was reused with an operation, but at least one of the other input parameters is different from the previous call to the operation.</p>
capo_rekognition.errors.internal_server_error.InternalServerError: <p>Amazon Rekognition experienced a service issue. Try your call again.</p>
capo_rekognition.errors.invalid_parameter_exception.InvalidParameterException: <p>Input parameter violated a constraint. Validate your parameter before calling the API operation again.</p>
capo_rekognition.errors.provisioned_throughput_exceeded_exception.ProvisionedThroughputExceededException: <p>The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.</p>
capo_rekognition.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource specified in the request cannot be found.</p>
capo_rekognition.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p></p> <p>The size of the collection exceeds the allowed limit. For more information, see Guidelines and quotas in Amazon Rekognition in the Amazon Rekognition Developer Guide. </p>
capo_rekognition.errors.throttling_exception.ThrottlingException: <p>Amazon Rekognition is temporarily unable to process the request. Try your call again.</p>
capo_rekognition.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
CreateUser
Creates a new User within a collection specified by CollectionId.
>>> client.create_user(collection_id='MyCollection', user_id='DemoUser')
"""
def _handler(
req: "OperationRequest[capo_rekognition.types.create_user_request.CreateUserRequest]",
) -> OperationResponse[
"capo_rekognition.types.create_user_response.CreateUserResponse"
]:
import capo_rekognition._operations.rekognition_service.create_user
output, http_response = (
capo_rekognition._operations.rekognition_service.create_user.create_user(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateUser")
)
input_: capo_rekognition.types.create_user_request.CreateUserRequest = {
"collection_id": collection_id,
"user_id": user_id,
}
if client_request_token is None:
client_request_token = str(uuid.uuid4())
input_["client_request_token"] = client_request_token
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|