diff --git a/swh/deposit/api/common.py b/swh/deposit/api/common.py --- a/swh/deposit/api/common.py +++ b/swh/deposit/api/common.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2019 The Software Heritage developers +# Copyright (C) 2017-2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -58,7 +58,7 @@ ACCEPT_ARCHIVE_CONTENT_TYPES = ["application/zip", "application/x-tar"] -class SWHAPIView(APIView): +class AuthenticatedAPIView(APIView): """Mixin intended as a based API view to enforce the basic authentication check @@ -68,7 +68,7 @@ permission_classes: Sequence[Type[BasePermission]] = (IsAuthenticated,) -class SWHBaseDeposit(SWHDefaultConfig, SWHAPIView, metaclass=ABCMeta): +class APIBase(SWHDefaultConfig, AuthenticatedAPIView, metaclass=ABCMeta): """Base deposit request class sharing multiple common behaviors. """ @@ -797,7 +797,7 @@ return self._basic_not_allowed_method(request, "DELETE") -class SWHGetDepositAPI(SWHBaseDeposit, metaclass=ABCMeta): +class GetAPI(APIBase, metaclass=ABCMeta): """Mixin for class to support GET method. """ @@ -834,7 +834,7 @@ pass -class SWHPostDepositAPI(SWHBaseDeposit, metaclass=ABCMeta): +class SWHPostDepositAPI(APIBase, metaclass=ABCMeta): """Mixin for class to support DELETE method. """ @@ -888,7 +888,7 @@ pass -class SWHPutDepositAPI(SWHBaseDeposit, metaclass=ABCMeta): +class SWHPutDepositAPI(APIBase, metaclass=ABCMeta): """Mixin for class to support PUT method. """ @@ -926,7 +926,7 @@ pass -class SWHDeleteDepositAPI(SWHBaseDeposit, metaclass=ABCMeta): +class SWHDeleteDepositAPI(APIBase, metaclass=ABCMeta): """Mixin for class to support DELETE method. """ diff --git a/swh/deposit/api/deposit_content.py b/swh/deposit/api/deposit_content.py --- a/swh/deposit/api/deposit_content.py +++ b/swh/deposit/api/deposit_content.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 The Software Heritage developers +# Copyright (C) 2017-2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -6,13 +6,13 @@ from django.shortcuts import render from rest_framework import status -from .common import SWHBaseDeposit +from .common import APIBase from ..errors import NOT_FOUND, make_error_response from ..errors import make_error_response_from_dict from ..models import DEPOSIT_STATUS_DETAIL, Deposit, DepositRequest -class SWHDepositContent(SWHBaseDeposit): +class SWHDepositContent(APIBase): def get(self, req, collection_name, deposit_id, format=None): checks = self.checks(req, collection_name, deposit_id) if "error" in checks: diff --git a/swh/deposit/api/deposit_status.py b/swh/deposit/api/deposit_status.py --- a/swh/deposit/api/deposit_status.py +++ b/swh/deposit/api/deposit_status.py @@ -6,14 +6,14 @@ from django.shortcuts import render from rest_framework import status -from .common import SWHBaseDeposit +from .common import APIBase from .converters import convert_status_detail from ..errors import NOT_FOUND, make_error_response from ..errors import make_error_response_from_dict from ..models import DEPOSIT_STATUS_DETAIL, Deposit -class SWHDepositStatus(SWHBaseDeposit): +class SWHDepositStatus(APIBase): """Deposit status. What's known as 'State IRI' in the sword specification. diff --git a/swh/deposit/api/private/__init__.py b/swh/deposit/api/private/__init__.py --- a/swh/deposit/api/private/__init__.py +++ b/swh/deposit/api/private/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2019 The Software Heritage developers +# Copyright (C) 2017-2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -10,7 +10,7 @@ from rest_framework.permissions import AllowAny -from swh.deposit.api.common import SWHAPIView +from swh.deposit.api.common import AuthenticatedAPIView from swh.deposit.errors import make_error_dict, NOT_FOUND @@ -58,7 +58,7 @@ return utils.merge(*metadata) -class SWHPrivateAPIView(SWHDefaultConfig, SWHAPIView): +class SWHPrivateAPIView(SWHDefaultConfig, AuthenticatedAPIView): """Mixin intended as private api (so no authentication) based API view (for the private ones). diff --git a/swh/deposit/api/private/deposit_check.py b/swh/deposit/api/private/deposit_check.py --- a/swh/deposit/api/private/deposit_check.py +++ b/swh/deposit/api/private/deposit_check.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2019 The Software Heritage developers +# Copyright (C) 2017-2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -16,7 +16,7 @@ from swh.scheduler.utils import create_oneshot_task_dict from . import DepositReadMixin, SWHPrivateAPIView -from ..common import SWHGetDepositAPI +from ..common import GetAPI from ...config import DEPOSIT_STATUS_VERIFIED, DEPOSIT_STATUS_REJECTED from ...config import ARCHIVE_TYPE from ...models import Deposit @@ -55,7 +55,7 @@ ) -class SWHChecksDeposit(SWHPrivateAPIView, SWHGetDepositAPI, DepositReadMixin): +class SWHChecksDeposit(SWHPrivateAPIView, GetAPI, DepositReadMixin): """Dedicated class to read a deposit's raw archives content. Only GET is supported. diff --git a/swh/deposit/api/private/deposit_read.py b/swh/deposit/api/private/deposit_read.py --- a/swh/deposit/api/private/deposit_read.py +++ b/swh/deposit/api/private/deposit_read.py @@ -18,7 +18,7 @@ from . import DepositReadMixin, SWHPrivateAPIView from ...config import SWH_PERSON, ARCHIVE_TYPE -from ..common import SWHGetDepositAPI +from ..common import GetAPI from ...models import Deposit @@ -60,7 +60,7 @@ shutil.rmtree(dir_path) -class SWHDepositReadArchives(SWHPrivateAPIView, SWHGetDepositAPI, DepositReadMixin): +class SWHDepositReadArchives(SWHPrivateAPIView, GetAPI, DepositReadMixin): """Dedicated class to read a deposit's raw archives content. Only GET is supported. @@ -102,7 +102,7 @@ ) -class SWHDepositReadMetadata(SWHPrivateAPIView, SWHGetDepositAPI, DepositReadMixin): +class SWHDepositReadMetadata(SWHPrivateAPIView, GetAPI, DepositReadMixin): """Class in charge of aggregating metadata on a deposit. """ diff --git a/swh/deposit/api/service_document.py b/swh/deposit/api/service_document.py --- a/swh/deposit/api/service_document.py +++ b/swh/deposit/api/service_document.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2019 The Software Heritage developers +# Copyright (C) 2017-2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -6,13 +6,13 @@ from django.shortcuts import render from django.urls import reverse -from .common import SWHBaseDeposit, ACCEPT_PACKAGINGS +from .common import APIBase, ACCEPT_PACKAGINGS from .common import ACCEPT_ARCHIVE_CONTENT_TYPES from ..config import COL_IRI from ..models import DepositClient, DepositCollection -class SWHServiceDocument(SWHBaseDeposit): +class SWHServiceDocument(APIBase): def get(self, req, *args, **kwargs): client = DepositClient.objects.get(username=req.user) diff --git a/swh/deposit/parsers.py b/swh/deposit/parsers.py --- a/swh/deposit/parsers.py +++ b/swh/deposit/parsers.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2019 The Software Heritage developers +# Copyright (C) 2017-2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -65,7 +65,7 @@ # We do not actually want to parse the stream yet # because we want to keep the raw data as well # this is done later in the atom entry call - # (cf. swh.deposit.api.common.SWHBaseDeposit._atom_entry) + # (cf. swh.deposit.api.common.APIBase._atom_entry) return stream