swh.deposit.api.private package

Submodules

swh.deposit.api.private.deposit_check module

class swh.deposit.api.private.deposit_check.SWHChecksDeposit(**config)[source]

Bases: swh.deposit.api.common.SWHGetDepositAPI, swh.deposit.api.common.SWHPrivateAPIView, swh.deposit.api.private.DepositReadMixin

Dedicated class to read a deposit’s raw archives content.

Only GET is supported.

_check_deposit_archives(deposit)[source]

Given a deposit, check each deposit request of type archive.

Parameters:deposit to check archives for (The) –
Returns
tuple (status, error_detail): True, None if all archives are ok, (False, <detailed-error>) otherwise.
_check_archive(archive_request)[source]

Check that a deposit associated archive is ok: - readable - supported archive format - valid content: the archive does not contain a single archive file

If any of those checks are not ok, return the corresponding failing check.

Parameters:archive_path (DepositRequest) – Archive to check
Returns:(True, None) if archive is check compliant, (False, <detail-error>) otherwise.
_check_metadata(metadata)[source]

Check to execute on all metadata for mandatory field presence.

Parameters:metadata (dict) – Metadata dictionary to check for mandatory fields
Returns:
True, None if metadata are
ok (False, <detailed-error>) otherwise.
Return type:tuple (status, error_detail)
process_get(req, collection_name, deposit_id)[source]
Build a unique tarball from the multiple received and stream that
content to the client.
Parameters:
  • req (Request) –
  • collection_name (str) – Collection owning the deposit
  • deposit_id (id) – Deposit concerned by the reading
Returns:

Tuple status, stream of content, content-type

__abstractmethods__ = frozenset()
__module__ = 'swh.deposit.api.private.deposit_check'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 111
_abc_registry = <_weakrefset.WeakSet object>

swh.deposit.api.private.deposit_list module

class swh.deposit.api.private.deposit_list.DefaultPagination[source]

Bases: rest_framework.pagination.PageNumberPagination

page_size = 100
page_size_query_param = 'page_size'
__module__ = 'swh.deposit.api.private.deposit_list'
class swh.deposit.api.private.deposit_list.StatusDetailField(*args, **kwargs)[source]

Bases: rest_framework.fields._UnvalidatedField

status_detail field is a dict, we want a simple message instead. So, we reuse the convert_status_detail from deposit_status endpoint to that effect.

to_representation(value)[source]

Transform the outgoing native value into primitive data.

__module__ = 'swh.deposit.api.private.deposit_list'
class swh.deposit.api.private.deposit_list.DepositSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]

Bases: rest_framework.serializers.ModelSerializer

class Meta[source]

Bases: object

model

alias of swh.deposit.models.Deposit

fields = '__all__'
__dict__ = mappingproxy({'__weakref__': <attribute '__weakref__' of 'Meta' objects>, '__doc__': None, '__module__': 'swh.deposit.api.private.deposit_list', 'fields': '__all__', 'model': <class 'swh.deposit.models.Deposit'>, '__dict__': <attribute '__dict__' of 'Meta' objects>})
__module__ = 'swh.deposit.api.private.deposit_list'
__weakref__

list of weak references to the object (if defined)

__module__ = 'swh.deposit.api.private.deposit_list'
_declared_fields = {'status_detail': StatusDetailField()}
class swh.deposit.api.private.deposit_list.DepositList(**kwargs)[source]

Bases: rest_framework.generics.ListAPIView, swh.deposit.api.common.SWHPrivateAPIView

Deposit request class to list the deposit’s status per page.

HTTP verbs supported: GET

queryset
serializer_class

alias of DepositSerializer

pagination_class

alias of DefaultPagination

__module__ = 'swh.deposit.api.private.deposit_list'

swh.deposit.api.private.deposit_read module

swh.deposit.api.private.deposit_read.aggregate_tarballs(extraction_dir, archive_paths)[source]
Aggregate multiple tarballs into one and returns this new archive’s
path.
Parameters:
  • extraction_dir (path) – Path to use for the tarballs computation
  • archive_paths ([str]) – Deposit’s archive paths
Returns:

Tuple (directory to clean up, archive path (aggregated or not))

class swh.deposit.api.private.deposit_read.SWHDepositReadArchives[source]

Bases: swh.deposit.api.common.SWHGetDepositAPI, swh.deposit.api.common.SWHPrivateAPIView, swh.deposit.api.private.DepositReadMixin

Dedicated class to read a deposit’s raw archives content.

Only GET is supported.

ADDITIONAL_CONFIG = {'extraction_dir': ('str', '/tmp/swh-deposit/archive/')}
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

process_get(req, collection_name, deposit_id)[source]
Build a unique tarball from the multiple received and stream that
content to the client.
Parameters:
  • req (Request) –
  • collection_name (str) – Collection owning the deposit
  • deposit_id (id) – Deposit concerned by the reading
Returns:

Tuple status, stream of content, content-type

__abstractmethods__ = frozenset()
__module__ = 'swh.deposit.api.private.deposit_read'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 111
_abc_registry = <_weakrefset.WeakSet object>
class swh.deposit.api.private.deposit_read.SWHDepositReadMetadata[source]

Bases: swh.deposit.api.common.SWHGetDepositAPI, swh.deposit.api.common.SWHPrivateAPIView, swh.deposit.api.private.DepositReadMixin

Class in charge of aggregating metadata on a deposit.

ADDITIONAL_CONFIG = {'provider': ('dict', {'metadata': {}, 'provider_type': 'deposit_client'}), 'tool': ('dict', {'name': 'swh-deposit', 'configuration': {'sword_version': '2'}, 'version': '0.0.1'})}
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

_normalize_dates(deposit, metadata)[source]
Normalize the date to use as a tuple of author date, committer date
from the incoming metadata.
Parameters:
  • deposit (Deposit) – Deposit model representation
  • metadata (Dict) – Metadata dict representation
Returns:

Tuple of author date, committer date. Those dates are swh normalized.

metadata_read(deposit)[source]
Read and aggregate multiple data on deposit into one unified data
dictionary.
Parameters:deposit (Deposit) – Deposit concerned by the data aggregation.
Returns:Dictionary of data representing the deposit to inject in swh.
process_get(req, collection_name, deposit_id)[source]

Routine to deal with the deposit’s get processing.

Returns:Tuple status, stream of content, content-type
__abstractmethods__ = frozenset()
__module__ = 'swh.deposit.api.private.deposit_read'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 111
_abc_registry = <_weakrefset.WeakSet object>

swh.deposit.api.private.deposit_update_status module

class swh.deposit.api.private.deposit_update_status.SWHUpdateStatusDeposit(**config)[source]

Bases: swh.deposit.api.common.SWHPutDepositAPI, swh.deposit.api.common.SWHPrivateAPIView

Deposit request class to update the deposit’s status.

HTTP verbs supported: PUT

parser_classes = (<class 'rest_framework.parsers.JSONParser'>,)
additional_checks(req, headers, collection_name, deposit_id=None)[source]

Enrich existing checks to the default ones.

New checks: - Ensure the status is provided - Ensure it exists

restrict_access(req, deposit=None)[source]

Remove restriction modification to ‘partial’ deposit. Update is possible regardless of the existing status.

process_put(req, headers, collection_name, deposit_id)[source]

Update the deposit’s status

Returns:204 No content
__abstractmethods__ = frozenset()
__module__ = 'swh.deposit.api.private.deposit_update_status'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 111
_abc_registry = <_weakrefset.WeakSet object>

swh.deposit.api.private.urls module

Module contents

class swh.deposit.api.private.DepositReadMixin[source]

Bases: object

Deposit Read mixin

_deposit_requests(deposit, request_type)[source]

Given a deposit, yields its associated deposit_request

Parameters:
  • deposit (Deposit) – Deposit to list requests for
  • request_type (str) – ‘archive’ or ‘metadata’
Yields:

deposit requests of type request_type associated to the deposit

_metadata_get(deposit)[source]

Given a deposit, aggregate all metadata requests.

Parameters:
  • deposit (Deposit) – The deposit instance to extract
  • from. (metadata) –
Returns:

metadata dict from the deposit.

__dict__ = mappingproxy({'__weakref__': <attribute '__weakref__' of 'DepositReadMixin' objects>, '__doc__': 'Deposit Read mixin\n\n ', '__module__': 'swh.deposit.api.private', '_deposit_requests': <function DepositReadMixin._deposit_requests>, '_metadata_get': <function DepositReadMixin._metadata_get>, '__dict__': <attribute '__dict__' of 'DepositReadMixin' objects>})
__module__ = 'swh.deposit.api.private'
__weakref__

list of weak references to the object (if defined)