Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/deposit_update.py
Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | def process_post( | ||||
request, | request, | ||||
headers: Dict, | headers: Dict, | ||||
collection_name: str, | collection_name: str, | ||||
deposit_id: Optional[int] = None, | deposit_id: Optional[int] = None, | ||||
) -> Tuple[int, str, Dict]: | ) -> Tuple[int, str, Dict]: | ||||
"""Add new metadata/archive to existing deposit. | """Add new metadata/archive to existing deposit. | ||||
source: | source: | ||||
- http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html#protocoloperations_addingcontent_metadata # noqa | - http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html#protocoloperations_addingcontent_metadata | ||||
- http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html#protocoloperations_addingcontent_multipart # noqa | - http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html#protocoloperations_addingcontent_multipart | ||||
This also deals with an empty post corner case to finalize a | This also deals with an empty post corner case to finalize a | ||||
deposit. | deposit. | ||||
Returns: | Returns: | ||||
In optimal case for a multipart and atom-entry update, a | In optimal case for a multipart and atom-entry update, a | ||||
201 Created response. The body response will hold a | 201 Created response. The body response will hold a | ||||
deposit. And the response headers will contain an entry | deposit. And the response headers will contain an entry | ||||
'Location' with the EM-IRI. | 'Location' with the EM-IRI. | ||||
For the empty post case, this returns a 200. | For the empty post case, this returns a 200. | ||||
""" | """ # noqa | ||||
assert deposit_id is not None | assert deposit_id is not None | ||||
if request.content_type.startswith("multipart/"): | if request.content_type.startswith("multipart/"): | ||||
return ( | data = self._multipart_upload( | ||||
status.HTTP_201_CREATED, | |||||
EM_IRI, | |||||
self._multipart_upload( | |||||
request, headers, collection_name, deposit_id=deposit_id | request, headers, collection_name, deposit_id=deposit_id | ||||
), | |||||
) | ) | ||||
return (status.HTTP_201_CREATED, EM_IRI, data) | |||||
# check for final empty post | # check for final empty post | ||||
# source: http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html | # source: http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html | ||||
# #continueddeposit_complete | # #continueddeposit_complete | ||||
if headers["content-length"] == 0 and headers["in-progress"] is False: | if headers["content-length"] == 0 and headers["in-progress"] is False: | ||||
data = self._empty_post(request, headers, collection_name, deposit_id) | data = self._empty_post(request, headers, collection_name, deposit_id) | ||||
return (status.HTTP_200_OK, EDIT_SE_IRI, data) | return (status.HTTP_200_OK, EDIT_SE_IRI, data) | ||||
ardumont: rohhh come on!? ¯\_(ツ)_/¯
| |||||
Not Done Inline ActionsI prefer the explicit parentheses tbh, they make it more obvious the function returns a tuple imo vlorentz: I prefer the explicit parentheses tbh, they make it more obvious the function returns a tuple… | |||||
Done Inline Actionsack, adressing the non coverage part in another diff btw ("again")... ardumont: ack, adressing the non coverage part in another diff btw ("again")...
D4052 | |||||
return ( | data = self._atom_entry( | ||||
status.HTTP_201_CREATED, | request, headers, collection_name, deposit_id=deposit_id | ||||
EM_IRI, | |||||
self._atom_entry(request, headers, collection_name, deposit_id=deposit_id), | |||||
) | ) | ||||
return (status.HTTP_201_CREATED, EM_IRI, data) | |||||
def process_delete(self, req, collection_name: str, deposit_id: int) -> Dict: | def process_delete(self, req, collection_name: str, deposit_id: int) -> Dict: | ||||
"""Delete the container (deposit). | """Delete the container (deposit). | ||||
source: http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html#protocoloperations_deleteconteiner # noqa | source: http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html#protocoloperations_deleteconteiner # noqa | ||||
""" | """ | ||||
return self._delete_deposit(collection_name, deposit_id) | return self._delete_deposit(collection_name, deposit_id) |
rohhh come on!? ¯\_(ツ)_/¯