Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/urls.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 | ||||
"""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 COL_IRI, CONT_FILE_IRI, EDIT_SE_IRI, EM_IRI, SD_IRI, STATE_IRI | from ..config import COL_IRI, CONT_FILE_IRI, EDIT_SE_IRI, EM_IRI, SD_IRI, STATE_IRI | ||||
from .deposit import APIPostDeposit | from .collection import CollectionAPI | ||||
from .deposit_content import APIContent | from .content import ContentAPI | ||||
from .deposit_status import APIStatus | from .edit import EditAPI | ||||
from .deposit_update import APIUpdateArchive, APIUpdateMetadata | from .edit_media import EditMediaAPI | ||||
from .service_document import APIServiceDocument | from .service_document import ServiceDocumentAPI | ||||
from .state import StateAPI | |||||
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/", APIServiceDocument.as_view(), name=SD_IRI), | url(r"^servicedocument/", ServiceDocumentAPI.as_view(), name=SD_IRI), | ||||
# Col IRI - Collection IRI | # Col-IRI - Collection IRI | ||||
# -> POST | # -> POST | ||||
url(r"^(?P<collection_name>[^/]+)/$", APIPostDeposit.as_view(), name=COL_IRI), | url(r"^(?P<collection_name>[^/]+)/$", CollectionAPI.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/$", | ||||
APIUpdateArchive.as_view(), | EditMediaAPI.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/$", | ||||
APIUpdateMetadata.as_view(), | EditAPI.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/$", | ||||
APIStatus.as_view(), | StateAPI.as_view(), | ||||
name=STATE_IRI, | name=STATE_IRI, | ||||
), | ), | ||||
# Cont/File IRI | # Cont-IRI | ||||
# -> GET | # -> GET | ||||
url( | url( | ||||
r"^(?P<collection_name>[^/]+)/(?P<deposit_id>[^/]+)/content/$", | r"^(?P<collection_name>[^/]+)/(?P<deposit_id>[^/]+)/content/$", | ||||
APIContent.as_view(), | ContentAPI.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 | ||||
] | ] |