Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/collection.py
# Copyright (C) 2017-2020 The Software Heritage developers | # Copyright (C) 2017-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from typing import Any, Dict, Optional, Tuple | from typing import Any, Dict, Optional, Tuple | ||||
from rest_framework import status | from rest_framework import status | ||||
from ..config import EDIT_IRI | from ..config import EDIT_IRI | ||||
from ..parsers import ( | from ..parsers import ( | ||||
SWHAtomEntryParser, | SWHAtomEntryParser, | ||||
SWHFileUploadTarParser, | SWHFileUploadTarParser, | ||||
SWHFileUploadZipParser, | SWHFileUploadZipParser, | ||||
SWHMultiPartParser, | SWHMultiPartParser, | ||||
) | ) | ||||
from .common import ACCEPT_ARCHIVE_CONTENT_TYPES, APIPost | from .common import ACCEPT_ARCHIVE_CONTENT_TYPES, APIPost, ParsedRequestHeaders | ||||
class CollectionAPI(APIPost): | class CollectionAPI(APIPost): | ||||
"""Deposit request class defining api endpoints for sword deposit. | """Deposit request class defining api endpoints for sword deposit. | ||||
What's known as 'Col-IRI' in the sword specification. | What's known as 'Col-IRI' in the sword specification. | ||||
HTTP verbs supported: POST | HTTP verbs supported: POST | ||||
""" | """ | ||||
parser_classes = ( | parser_classes = ( | ||||
SWHMultiPartParser, | SWHMultiPartParser, | ||||
SWHFileUploadZipParser, | SWHFileUploadZipParser, | ||||
SWHFileUploadTarParser, | SWHFileUploadTarParser, | ||||
SWHAtomEntryParser, | SWHAtomEntryParser, | ||||
) | ) | ||||
def process_post( | def process_post( | ||||
self, | self, | ||||
req, | req, | ||||
headers: Dict[str, Any], | headers: ParsedRequestHeaders, | ||||
collection_name: str, | collection_name: str, | ||||
deposit_id: Optional[int] = None, | deposit_id: Optional[int] = None, | ||||
) -> Tuple[int, str, Dict[str, Any]]: | ) -> Tuple[int, str, Dict[str, Any]]: | ||||
"""Create a first deposit as: | """Create a first deposit as: | ||||
- archive deposit (1 zip) | - archive deposit (1 zip) | ||||
- multipart (1 zip + 1 atom entry) | - multipart (1 zip + 1 atom entry) | ||||
- atom entry | - atom entry | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |