swh.deposit.api.common module

class swh.deposit.api.common.SWHAPIView(**kwargs)[source]

Bases: rest_framework.views.APIView

Mixin intended as a based API view to enforce the basic authentication check

authentication_classes: Sequence[Type[rest_framework.authentication.BaseAuthentication]] = (<class 'rest_framework.authentication.BasicAuthentication'>,)
permission_classes: Sequence[Type[rest_framework.permissions.BasePermission]] = (<class 'rest_framework.permissions.IsAuthenticated'>,)
class swh.deposit.api.common.SWHBaseDeposit(**config)[source]

Bases: swh.deposit.config.SWHDefaultConfig, swh.deposit.api.common.SWHAPIView

Base deposit request class sharing multiple common behaviors.

additional_checks(request, headers, collection_name, deposit_id=None)[source]

Permit the child class to enrich additional checks.

Returns

dict with ‘error’ detailing the problem.

checks(request, collection_name, deposit_id=None)[source]
restrict_access(request, deposit=None)[source]
get(request, *args, **kwargs)[source]
post(request, *args, **kwargs)[source]
put(request, *args, **kwargs)[source]
delete(request, *args, **kwargs)[source]
class swh.deposit.api.common.SWHGetDepositAPI(**config)[source]

Bases: swh.deposit.api.common.SWHBaseDeposit

Mixin for class to support GET method.

get(request, collection_name, deposit_id, format=None)[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

abstract process_get(request, collection_name, deposit_id)[source]

Routine to deal with the deposit’s get processing.

Returns

Tuple status, stream of content, content-type

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

Bases: swh.deposit.api.common.SWHBaseDeposit

Mixin for class to support DELETE method.

post(request, collection_name, deposit_id=None, format=None)[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

abstract process_post(request, headers, collection_name, deposit_id=None)[source]

Routine to deal with the deposit’s processing.

Returns

Tuple of: - response status code (200, 201, etc…) - key iri (EM_IRI, EDIT_SE_IRI, etc…) - dictionary of the processing result

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

Bases: swh.deposit.api.common.SWHBaseDeposit

Mixin for class to support PUT method.

put(request, collection_name, deposit_id, format=None)[source]

Endpoint to update deposit resources.

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

abstract process_put(request, headers, collection_name, deposit_id)[source]

Routine to deal with updating a deposit in some way.

Returns

dictionary of the processing result

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

Bases: swh.deposit.api.common.SWHBaseDeposit

Mixin for class to support DELETE method.

delete(request, collection_name, deposit_id)[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

abstract process_delete(request, collection_name, deposit_id)[source]

Routine to delete a resource.

This is mostly not allowed except for the EM_IRI (cf. .api.deposit_update.SWHUpdateArchiveDeposit)