swh.deposit.api.collection module#

class swh.deposit.api.collection.CollectionAPI[source]#

Bases: ListAPIView, APIPost

Deposit request class defining api endpoints for sword deposit.

What’s known as ‘Col-IRI’ in the sword specification.

HTTP verbs supported: GET and POST

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

parser_classes = (<class 'swh.deposit.parsers.SWHMultiPartParser'>, <class 'swh.deposit.parsers.SWHFileUploadZipParser'>, <class 'swh.deposit.parsers.SWHFileUploadTarParser'>, <class 'swh.deposit.parsers.SWHAtomEntryParser'>)#
serializer_class#

alias of DepositSerializer

pagination_class#

alias of DefaultPagination

get(request, *args, **kwargs)[source]#

List the user’s collection if the user has access to said collection.

get_queryset()[source]#

List the deposits for the authenticated user (pagination is handled by the pagination_class class attribute).

process_post(req, headers: ParsedRequestHeaders, collection_name: str, deposit: Deposit | None = None) Tuple[int, str, Receipt][source]#

Create a first deposit as: - archive deposit (1 zip) - multipart (1 zip + 1 atom entry) - atom entry

Parameters:
  • req (Request) – the request holding the information to parse and inject in db

  • collection_name (str) – the associated client

Returns:

An http response (HttpResponse) according to the situation.

If everything is ok, a 201 response (created) with a deposit receipt.

Raises:
  • - archive deposit

    • 400 (bad request) if the request is not providing an external identifier - 403 (forbidden) if the length of the archive exceeds the max size configured - 412 (precondition failed) if the length or hash provided mismatch the reality of the archive. - 415 (unsupported media type) if a wrong media type is provided

  • - multipart deposit

    • 400 (bad request) if the request is not providing an external identifier - 412 (precondition failed) if the potentially md5 hash provided mismatch the reality of the archive - 415 (unsupported media type) if a wrong media type is provided

  • - Atom entry deposit

    • 400 (bad request) if the request is not providing an external identifier - 400 (bad request) if the request’s body is empty - 415 (unsupported media type) if a wrong media type is provided