Creates a collection in an AWS Region. You can add faces to the collection using the IndexFaces operation.
For example, you might create collections, one for each of your application users. A user can then index faces using the IndexFaces operation and persist results in a specific collection. Then, a user can search the collection for faces in the user-specific container.
When you create a collection, it is associated with the latest version of the face model version.
Collection names are case-sensitive.
This operation requires permissions to perform the rekognition:CreateCollection action. If you want to tag your collection, you also require permission to perform the rekognition:TagResource operation.
Parameters:
-
collection_id
(CollectionId)
–
ID for the collection that you are creating.
-
tags
(Optional[TagMap], default:
None
)
–
A set of tags (key-value pairs) that you want to attach to the collection.
Raises:
Examples:
To create a collection
This operation creates a Rekognition collection for storing image data.
>>> await client.create_collection(collection_id='myphotos')
Source code in docs_src/capo_rekognition/_services/async_rekognition.py
| async def create_collection(
self,
collection_id: "capo_rekognition.types.collection_id.CollectionId",
*,
config_overrides: Optional[AsyncRekognitionClientConfig] = None,
tags: Optional["capo_rekognition.types.tag_map.TagMap"] = None,
) -> "capo_rekognition.types.create_collection_response.CreateCollectionResponse":
"""<p>Creates a collection in an AWS Region. You can add faces to the collection using the <a>IndexFaces</a> operation. </p> <p>For example, you might create collections, one for each of your application users. A user can then index faces using the <code>IndexFaces</code> operation and persist results in a specific collection. Then, a user can search the collection for faces in the user-specific container. </p> <p>When you create a collection, it is associated with the latest version of the face model version.</p> <note> <p>Collection names are case-sensitive.</p> </note> <p>This operation requires permissions to perform the <code>rekognition:CreateCollection</code> action. If you want to tag your collection, you also require permission to perform the <code>rekognition:TagResource</code> operation.</p>
Args:
collection_id: <p>ID for the collection that you are creating.</p>
tags: <p> A set of tags (key-value pairs) that you want to attach to the collection. </p>
Raises:
capo_rekognition.errors.access_denied_exception.AccessDeniedException: <p>You are not authorized to perform the action.</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_already_exists_exception.ResourceAlreadyExistsException: <p>A resource with the specified ID already exists.</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:
To create a collection
This operation creates a Rekognition collection for storing image data.
>>> await client.create_collection(collection_id='myphotos')
"""
async def _handler(
req: "AsyncOperationRequest[capo_rekognition.types.create_collection_request.CreateCollectionRequest]",
) -> AsyncOperationResponse[
"capo_rekognition.types.create_collection_response.CreateCollectionResponse"
]:
import capo_rekognition._operations.rekognition_service.create_collection
(
output,
http_response,
) = await capo_rekognition._operations.rekognition_service.create_collection.async_create_collection(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateCollection")
)
input_: capo_rekognition.types.create_collection_request.CreateCollectionRequest = {
"collection_id": collection_id
}
if tags is not None:
input_["tags"] = tags
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|