wfexs_backend.pushers#

Submodules#

Package Contents#

Classes#

DraftEntry

AbstractExportPlugin

Abstract class to model stateful export plugins

AbstractDraftedExportPlugin

Abstract class to model drafted stateful export plugins

API#

exception wfexs_backend.pushers.ExportPluginException#

Bases: Exception

class wfexs_backend.pushers.DraftEntry#

Bases: typing.NamedTuple

draft_id: str = None#
pid: str = None#
metadata: Mapping[str, Any] | None = None#
raw_metadata: Mapping[str, Any] | None = None#
class wfexs_backend.pushers.AbstractExportPlugin(refdir: pathlib.Path, setup_block: SecurityContextConfig | None = None, default_licences: Sequence[LicenceDescription] = [], default_orcids: Sequence[ResolvedORCID] = [], default_preferred_id: str | None = None)#

Bases: abc.ABC

Abstract class to model stateful export plugins

Initialization

PLUGIN_NAME: ClassVar[SymbolicName] = 'cast(...)'#
ENABLED: ClassVar[bool] = True#
abstractmethod push(items: Sequence[AnyContent], preferred_id: str | None = None, title: str | None = None, description: str | None = None, licences: Sequence[LicenceDescription] = [], resolved_orcids: Sequence[ResolvedORCID] = [], metadata: Mapping[str, Any] | None = None, community_specific_metadata: Mapping[str, Any] | None = None) Sequence[URIWithMetadata]#

This is the method to be implemented by the stateful pusher

abstractmethod get_pid_metadata(pid: str) Mapping[str, Any] | None#

This method is used to obtained the metadata associated to a PID, in case the destination allows it.

get_pid_draftentry(pid: str) DraftEntry | None#

This method is used to obtained the metadata associated to a PID, in case the destination allows it.

abstractmethod book_pid(preferred_id: str | None = None, initially_required_metadata: Mapping[str, Any] | None = None, initially_required_community_specific_metadata: Mapping[str, Any] | None = None, title: str | None = None, description: str | None = None, licences: Sequence[LicenceDescription] = [], resolved_orcids: Sequence[ResolvedORCID] = []) DraftEntry | None#

This method is used to book a new PID, in case the destination allows it.

We can even “suggest” either a new or existing PID.

It can return both the internal PID as the future, official one. It also returns the associated internal metadata.

When it returns None, it means either the destination does not allow booking pids, either temporary or permanently

property _customized_book_pid_error_string: str#

This method can be overridden to provide more context

abstractmethod discard_booked_pid(pid_or_draft: str | DraftEntry) bool#

This method is used to release a previously booked PID, which has not been published.

When it returns False, it means that the provided id did exist, but it was not a draft

classmethod PluginName() wfexs_backend.common.SymbolicName#
class wfexs_backend.pushers.AbstractDraftedExportPlugin(refdir: pathlib.Path, setup_block: SecurityContextConfig | None = None, default_licences: Sequence[LicenceDescription] = [], default_orcids: Sequence[ResolvedORCID] = [], default_preferred_id: str | None = None)#

Bases: wfexs_backend.pushers.AbstractExportPlugin

Abstract class to model drafted stateful export plugins

Initialization

abstractmethod upload_file_to_draft(draft_entry: wfexs_backend.pushers.DraftEntry, filename: str | IO[bytes], remote_filename: str | None, content_size: int | None = None) Mapping[str, Any]#

It takes as input the draft record representation, a local filename and optionally the remote filename to use

upload_file_to_draft_by_id(record_id: str, filename: str | IO[bytes], remote_filename: str | None) Mapping[str, Any]#
abstractmethod update_record_metadata(draft_entry: wfexs_backend.pushers.DraftEntry, metadata: Mapping[str, Any] | None = None, community_specific_metadata: Mapping[str, Any] | None = None, title: str | None = None, description: str | None = None, licences: Sequence[LicenceDescription] = [], resolved_orcids: Sequence[ResolvedORCID] = []) Mapping[str, Any]#

This method updates the (draft or not) record metadata, both the general one, and the specific of the community. This one could not make sense for some providers.

update_record_metadata_by_id(record_id: str, metadata: Mapping[str, Any] | None = None, community_specific_metadata: Mapping[str, Any] | None = None, title: str | None = None, description: str | None = None, licences: Sequence[LicenceDescription] = [], resolved_orcids: Sequence[ResolvedORCID] = []) Mapping[str, Any]#

This method updates the (draft or not) record metadata, both the general one, and the specific of the community. This one could not make sense for some providers.

abstractmethod publish_draft_record(draft_entry: wfexs_backend.pushers.DraftEntry) Mapping[str, Any]#

This method publishes a draft record, so its public id is permanent

publish_draft_record_by_id(record_id: str) Mapping[str, Any]#

This method publishes a draft record, so its public id is permanent