NekUpload.upload.invenio_rdm_api module
- NekUpload.upload.invenio_rdm_api.cancel_review_request(url: str, token: str, request_id: str, payload: dict[str, str] | None = None) Response[source]
Cancel a user-submitted review request. Only request’s creator can cancel it
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
record_id (str) – Id of record for which review request will be cancelled
payload (str) – Contains content and format
- Returns:
Record review submission response
- Return type:
requests.Response
- Raises:
APIError – If an error occurs during the API call.
- NekUpload.upload.invenio_rdm_api.commit_file_upload(url: str, token: str, record_id: str, filename: str) Response[source]
Save uploaded file in the draft record
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
record_id (str) – Record ID for which files are uploaded to
filename (str) – Name of file to be uploaded
- Returns:
Commit response object
- Return type:
requests.Response
- Raises:
APIError – If an error occurs during the API call.
- NekUpload.upload.invenio_rdm_api.create_draft_record(url: str, token: str, metadata: dict[str, Any], custom_fields: dict[str, Any] = None, upload_file_enabled: bool = True) Response[source]
Create a record draft in an InvenioRDM instance with the specified metadata.
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
metadata (dict[str,Any], optional) – Metadata to be uploaded.
custom_fields (dict[str,Any], optional) – Custom fields for record (InvenioRDM v10 and newer). Defaults to None.
upload_file_enabled (bool, optional) – Denotes whether file upload allowed or not. Defaults to True.
- Raises:
APIError – If an error occurs during the API call.
- Returns:
Returns a request.Response obhject on success (201 status code)
- Return type:
requests.Response
- NekUpload.upload.invenio_rdm_api.create_new_record_version(url: str, token: str, record_id: str) Response[source]
Create a new draft record from a published record, thereby creating a new version
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
record_id (str) – Record ID from which new record version will be created
- Raises:
APIError – If an error occurs during the API call.
- Returns:
Returns a request.Response obhject on success (201 status code)
- Return type:
requests.Response
- NekUpload.upload.invenio_rdm_api.delete_draft(url: str, token: str, record_id: str) Response[source]
Delete a draft record
- Parameters:
- Returns:
Delete response object
- Return type:
requests.Response
- Raises:
APIError – If an error occurs during the API call.
- NekUpload.upload.invenio_rdm_api.delete_review_request(url: str, token: str, record_id: str) Response[source]
Delete review request for the specified draft
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
record_id (str) – Id of record foe which review request will be deleted
- Returns:
Record review submission response
- Return type:
requests.Response
- Raises:
APIError – If an error occurs during the API call.
ClientError – If an error occurs due to invalid message parameters
- NekUpload.upload.invenio_rdm_api.download_draft_file(url: str, token: str, record_id: str, filename: str, target_directory: str) tuple[Response, str][source]
Download a file from a draft or record. Outputs response and output file name
- Parameters:
url (str) – _description_
token (str) – _description_
record_id (str) – _description_
filename (str) – _description_
target_directory (str) – Directory where file will be stored. Filename becomes target_directory/filename
- Returns:
_description_
- Return type:
requests.Response
- NekUpload.upload.invenio_rdm_api.get_all_user_drafts_and_records(url: str, token: str) Response[source]
Get all drafts and records owned by user
- Parameters:
url (str) – _description_
token (str) – _description_
- Returns:
_description_
- Return type:
requests.Response
- NekUpload.upload.invenio_rdm_api.get_community(url: str, token: str, community_slug: str) Response[source]
Get community specified by the community slug or id
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
community_slug (str) – Community url slug or uuid
- Returns:
Get community response
- Return type:
requests.Response
- Raises:
APIError – If an error occurs during the API call.
- NekUpload.upload.invenio_rdm_api.get_community_records(url: str, community_slug: str) Response[source]
Get all drafts and records in a community
- Parameters:
url (str) – _description_
community_slug (str) – _description_
- Returns:
_description_
- Return type:
requests.Response
- NekUpload.upload.invenio_rdm_api.get_draft_record(url: str, token: str, record_id: str) Response[source]
Get draft record associated with record_id. Can also get published records (maybe).
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
record_id (str) – Id of desired record
- Returns:
Record review submission response
- Return type:
requests.Response
- Raises:
APIError – If an error occurs during the API call.
- NekUpload.upload.invenio_rdm_api.get_record(url: str, token: str, record_id: str) Response[source]
Get published record associated with record id
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
record_id (str) – Record ID of desired record
- Raises:
APIError – If API call fails
- Returns:
_description_
- Return type:
requests.Response
- NekUpload.upload.invenio_rdm_api.prepare_file_upload(url: str, token: str, record_id: str, file_name_list: list[str]) Response[source]
Creates a location in the Invenio database record to store the files. Capable of batch file preparation.
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
record_id (str) – Record ID for which files will be uploaded to
file_name_list (list[str]) – list of names of file to be uploaded
- Returns:
Response for preparing file upload (201 response code on success)
- Return type:
requests.Response
- Raises:
APIError – If an error occurs during the API call.
ClientError – If an error occurs due to invalid message parameters
- NekUpload.upload.invenio_rdm_api.publish_draft(url: str, token: str, record_id: str) Response[source]
Publish the specified draft on InvenioRDM
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
record_id (str) – Id of record to be published
- Returns:
Publish response object
- Return type:
requests.Response
- Raises:
APIError – If an error occurs during the API call.
ClientError – If an error occurs due to invalid message parameters
- NekUpload.upload.invenio_rdm_api.raise_status_error(response: Response)[source]
Raises suitable error for different status codes
- Parameters:
response (requests.Response) – Resposne object
- Raises:
ClientError – _description_
ServerError – _description_
APIError – _description_
- NekUpload.upload.invenio_rdm_api.reserve_doi_draft(url: str, token: str, record_id: str) Response[source]
Reserve a DOI for the specified draft record
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
record_id (str) – Record ID for which DOI reservation is for
- Raises:
APIError – If an error occurs during the API call.
- Returns:
Returns a request.Response obhject on success (201 status code)
- Return type:
requests.Response
- NekUpload.upload.invenio_rdm_api.submit_record_for_review(url: str, token: str, record_id: str, payload: dict[str, str] | None = None) Response[source]
Once record is submmitted to community, submit it for review to community admins
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
record_id (str) – Id of record to be submitted for review
payload (str) – Contains content and format
- Returns:
Record review submission response
- Return type:
requests.Response
- Raises:
APIError – If an error occurs during the API call.
- NekUpload.upload.invenio_rdm_api.submit_record_to_community(url: str, token: str, community_uuid: str, record_id: str) Request[source]
Submit a specified record to a specified community
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
community_uuid (str) – Community UUID
record_id (str) – Id of record to be submitted to community
- Returns:
Community submission response
- Return type:
requests.Request
- Raises:
APIError – If an error occurs during the API call.
ClientError – If an error occurs due to invalid message parameters
- NekUpload.upload.invenio_rdm_api.update_draft_record(url: str, token: str, record_id: str, metadata: dict[str, Any], custom_fields: dict[str, Any] = None, upload_file_enabled: bool = True) Response[source]
Update a record draft in InvenioRDM with the specified metadata
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
metadata (dict[str,Any], optional) – Metadata to be uploaded.
custom_fields (dict[str,Any], optional) – Custom fields for record (InvenioRDM v10 and newer). Defaults to None.
upload_file_enabled (bool, optional) – Denotes whether file upload allowed or not. Defaults to True.
- Raises:
APIError – If an error occurs during the API call.
- Returns:
Returns a request.Response obhject on success (200 status code)
- Return type:
requests.Response
- NekUpload.upload.invenio_rdm_api.upload_file(url: str, token: str, record_id: str, file_path: str) Response[source]
Upload the specified file to the specified draft record
- Parameters:
url (str) – Base url route to the invenio database
token (str) – Personal access token
record_id (str) – Record ID for which files will be uploaded to
file_path (str) – Path of file to be uploaded
- Returns:
Upload response object
- Return type:
requests.Response
- Raises:
APIError – If an error occurs during the API call.