swh.deposit.api.deposit module

class swh.deposit.api.deposit.SWHDeposit(**config)[source]

Bases: swh.deposit.api.common.SWHPostDepositAPI

Deposit request class defining api endpoints for sword deposit.

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

HTTP verbs supported: POST

parser_classes = (<class 'swh.deposit.parsers.SWHMultiPartParser'>, <class 'swh.deposit.parsers.SWHFileUploadZipParser'>, <class 'swh.deposit.parsers.SWHFileUploadTarParser'>, <class 'swh.deposit.parsers.SWHAtomEntryParser'>)
additional_checks(req, headers, collection_name, deposit_id=None)[source]

Permit the child class to enrich additional checks.

Returns

dict with ‘error’ detailing the problem.

process_post(req, headers, collection_name, deposit_id=None)[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.

Otherwise, depending on the upload, the following errors can be returned:

  • 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