Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/urls.py
# 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 | # 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 | ||||
"""SWH's deposit api URL Configuration | """SWH's deposit api URL Configuration | ||||
""" | """ | ||||
from django.conf.urls import url | from django.conf.urls import url | ||||
from django.shortcuts import render | from django.shortcuts import render | ||||
from ..config import EDIT_SE_IRI, EM_IRI, CONT_FILE_IRI | from ..config import EDIT_SE_IRI, EM_IRI, CONT_FILE_IRI | ||||
from ..config import SD_IRI, COL_IRI, STATE_IRI | from ..config import SD_IRI, COL_IRI, STATE_IRI | ||||
from .deposit import SWHDeposit | from .deposit import APIPostDeposit | ||||
from .deposit_status import SWHDepositStatus | from .deposit_status import APIStatus | ||||
from .deposit_update import SWHUpdateMetadataDeposit | from .deposit_update import APIUpdateMetadata | ||||
from .deposit_update import SWHUpdateArchiveDeposit | from .deposit_update import APIUpdateArchive | ||||
from .deposit_content import SWHDepositContent | from .deposit_content import APIContent | ||||
from .service_document import SWHServiceDocument | from .service_document import APIServiceDocument | ||||
def api_view(req): | def api_view(req): | ||||
return render(req, "api.html") | return render(req, "api.html") | ||||
# PUBLIC API | # PUBLIC API | ||||
urlpatterns = [ | urlpatterns = [ | ||||
# simple view on the api | # simple view on the api | ||||
url(r"^$", api_view, name="api"), | url(r"^$", api_view, name="api"), | ||||
# SD IRI - Service Document IRI | # SD IRI - Service Document IRI | ||||
# -> GET | # -> GET | ||||
url(r"^servicedocument/", SWHServiceDocument.as_view(), name=SD_IRI), | url(r"^servicedocument/", APIServiceDocument.as_view(), name=SD_IRI), | ||||
# Col IRI - Collection IRI | # Col IRI - Collection IRI | ||||
# -> POST | # -> POST | ||||
url(r"^(?P<collection_name>[^/]+)/$", SWHDeposit.as_view(), name=COL_IRI), | url(r"^(?P<collection_name>[^/]+)/$", APIPostDeposit.as_view(), name=COL_IRI), | ||||
# EM IRI - Atom Edit Media IRI (update archive IRI) | # EM IRI - Atom Edit Media IRI (update archive IRI) | ||||
# -> PUT (update-in-place existing archive) | # -> PUT (update-in-place existing archive) | ||||
# -> POST (add new archive) | # -> POST (add new archive) | ||||
url( | url( | ||||
r"^(?P<collection_name>[^/]+)/(?P<deposit_id>[^/]+)/media/$", | r"^(?P<collection_name>[^/]+)/(?P<deposit_id>[^/]+)/media/$", | ||||
SWHUpdateArchiveDeposit.as_view(), | APIUpdateArchive.as_view(), | ||||
name=EM_IRI, | name=EM_IRI, | ||||
), | ), | ||||
# Edit IRI - Atom Entry Edit IRI (update metadata IRI) | # Edit IRI - Atom Entry Edit IRI (update metadata IRI) | ||||
# SE IRI - Sword Edit IRI ;; possibly same as Edit IRI | # SE IRI - Sword Edit IRI ;; possibly same as Edit IRI | ||||
# -> PUT (update in place) | # -> PUT (update in place) | ||||
# -> POST (add new metadata) | # -> POST (add new metadata) | ||||
url( | url( | ||||
r"^(?P<collection_name>[^/]+)/(?P<deposit_id>[^/]+)/metadata/$", | r"^(?P<collection_name>[^/]+)/(?P<deposit_id>[^/]+)/metadata/$", | ||||
SWHUpdateMetadataDeposit.as_view(), | APIUpdateMetadata.as_view(), | ||||
name=EDIT_SE_IRI, | name=EDIT_SE_IRI, | ||||
), | ), | ||||
# State IRI | # State IRI | ||||
# -> GET | # -> GET | ||||
url( | url( | ||||
r"^(?P<collection_name>[^/]+)/(?P<deposit_id>[^/]+)/status/$", | r"^(?P<collection_name>[^/]+)/(?P<deposit_id>[^/]+)/status/$", | ||||
SWHDepositStatus.as_view(), | APIStatus.as_view(), | ||||
name=STATE_IRI, | name=STATE_IRI, | ||||
), | ), | ||||
# Cont/File IRI | # Cont/File IRI | ||||
# -> GET | # -> GET | ||||
url( | url( | ||||
r"^(?P<collection_name>[^/]+)/(?P<deposit_id>[^/]+)/content/$", | r"^(?P<collection_name>[^/]+)/(?P<deposit_id>[^/]+)/content/$", | ||||
SWHDepositContent.as_view(), | APIContent.as_view(), | ||||
name=CONT_FILE_IRI, | name=CONT_FILE_IRI, | ||||
), # specification is not clear about | ), # specification is not clear about | ||||
# FILE-IRI, we assume it's the same as | # FILE-IRI, we assume it's the same as | ||||
# the CONT-IRI one | # the CONT-IRI one | ||||
] | ] |