swh.deposit.api.common module#
- class swh.deposit.api.common.ParsedRequestHeaders(content_type: str, content_length: int | None, in_progress: bool, content_disposition: str | None, content_md5sum: bytes | None, packaging: str | None, slug: str | None, on_behalf_of: str | None, metadata_relevant: str | None, swhid: str | None)[source]#
Bases:
object
Method generated by attrs for class ParsedRequestHeaders.
- class swh.deposit.api.common.Receipt(deposit_id: int, deposit_date: datetime, status: str, archive: str | None)[source]#
Bases:
object
Data computed while handling the request body that will be served in the Deposit Receipt.
Method generated by attrs for class Receipt.
- swh.deposit.api.common.get_deposit_by_id(deposit_id: int, collection_name: str | None = None) Deposit [source]#
Gets an existing Deposit object if it exists, or raises DepositError. If collection is not None, also checks the deposit belongs to the collection.
- swh.deposit.api.common.get_collection_by_name(collection_name: str)[source]#
Gets an existing Deposit object if it exists, or raises DepositError.
- swh.deposit.api.common.guess_deposit_origin_url(deposit: Deposit)[source]#
Guesses an origin url for the given deposit.
- class swh.deposit.api.common.APIBase[source]#
Bases:
APIConfig
,APIView
Base deposit request class sharing multiple common behaviors.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- additional_checks(request: Request, headers: ParsedRequestHeaders, collection_name: str, deposit: Deposit | None) Dict[str, Any] [source]#
Permit the child class to enrich additional checks.
- Returns:
dict with ‘error’ detailing the problem.
- get_client(request) DepositClient [source]#
- checks(request: Request, collection_name: str, deposit: Deposit | None = None) ParsedRequestHeaders [source]#
- restrict_access(request: Request, headers: ParsedRequestHeaders, deposit: Deposit) None [source]#
Allow modifications on deposit with status ‘partial’ only, reject the rest.
- class swh.deposit.api.common.APIGet[source]#
Bases:
APIBase
Mixin for class to support GET method.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- get(request: Request, collection_name: str, deposit_id: int) HttpResponse | FileResponse [source]#
Endpoint to create/add resources to deposit.
- Returns:
200 response when no error during routine occurred 400 if the deposit does not belong to the collection 404 if the deposit or the collection does not exist
- class swh.deposit.api.common.APIPost[source]#
Bases:
APIBase
Mixin for class to support POST method.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- post(request: Request, collection_name: str, deposit_id: int | None = None) HttpResponse [source]#
Endpoint to create/add resources to deposit.
- Returns:
204 response when no error during routine occurred. 400 if the deposit does not belong to the collection 404 if the deposit or the collection does not exist
- class swh.deposit.api.common.APIPut[source]#
Bases:
APIBase
Mixin for class to support PUT method.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- class swh.deposit.api.common.APIDelete[source]#
Bases:
APIBase
Mixin for class to support DELETE method.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- delete(request: Request, collection_name: str, deposit_id: int | None = None) HttpResponse [source]#
Endpoint to delete some deposit’s resources (archives, deposit).
- Returns:
204 response when no error during routine occurred. 400 if the deposit does not belong to the collection 404 if the deposit or the collection does not exist