CreateExportProcess endpoint
https://redmine.teklia.com/issues/7497
Requires #1858 (closed), #1863 (closed), arkindex/workers/export#7, arkindex/workers/export#8
A new CreateExportProcess
endpoint at /api/v1/process/export/{id}/
, where {id}
is the ID of a corpus, accepts the following parameters:
-
export_id
: UUID orNone
. Required, even if you just want to set it toNone
, so that it is explicit.-
When set to an UUID, it should be of a CorpusExport belonging to the corpus. If it is in an
error
state, return HTTP 400. -
When set to
None
, this will start an export, so this field should validate the same rules asStartExport
:- No export can be started if one is already
created
orrunning
on the corpus. - No export can be started if one has been created less than
EXPORT_TTL_SECONDS
ago and isdone
.
You may want to move the code from
arkindex.documents.serializers.export
to a method onCorpusExport
so that the same checks are done on both endpoints. - No export can be started if one is already
This behavior should be documented in the
help_text
for this field. -
-
format
: Enum, required.You can define a new
arkindex.process.models.ExportFormat
enum which for now will only havepdf
andpagexml
. We will add more options later depending on which workers are available. You can add a comment onArkindexFeature
to remind developers to update bothArkindexFeature
andExportFormat
for export feature workers! -
element_id
: UUID orNone
. Optional, defaults toNone
.- When this element does not exist or belongs to a corpus the user does not have guest access to, return HTTP 404.
- When the user has guest access to the element's corpus, but it is not the corpus from the URL, return HTTP 400.
-
selection
: Boolean. Optional, defaults toFalse
.- If this is enabled and
element_id
is set, return HTTP 400. - If this is enabled and there are no elements in the user's selection for this corpus, return HTTP 400.
- If this is enabled and
-
configuration
: Dict. Optional, defaults to{}
.This should be validated as a user configuration for the WorkerVersion that provides the ArkindexFeature that matches the specified
format
. For example, withpdf
, sending{"order_by_name": "mayhaps"}
should fail, becauseorder_by_name
should be a boolean. Pay particular attention to checking that no required parameters are missing.
When the user does not have a verified email, return HTTP 403.
When the user does not have guest access to the corpus, return a generic HTTP 404.
When the user has guest access to the corpus but not admin access, return HTTP 403 with an explicit message.
When everything is valid, this endpoint should, in a single transaction:
- Create and start a new CorpusExport on the corpus if
export_id
wasNone
. - Create a new Export process on the corpus, with the authenticated user as its creator and
element_id
set if one was specified. - If
selection
is enabled, then newProcessElement
instances should be created in bulk for all of the elements selected by the user on this corpus. - Get or create a WorkerConfiguration for the worker of the version that provides the feature selected by the
format
, containing theconfiguration
and an extraexport_id
parameter set to the ID of the specified CorpusExport. - Create a WorkerRun for the WorkerVersion providing the feature, with the selected WorkerConfiguration.
- Start the process.
- Return HTTP 201 with the same payload as a
RetrieveProcess
.