CreateExportProcess endpoint
https://redmine.teklia.com/issues/7497
Requires #1858 (closed), #1863 (closed), arkindex/workers/export#7 (closed), arkindex/workers/export#8 (closed)
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
errorstate, 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
createdorrunningon the corpus. - No export can be started if one has been created less than
EXPORT_TTL_SECONDSago and isdone.
You may want to move the code from
arkindex.documents.serializers.exportto a method onCorpusExportso 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_textfor this field. -
-
format: Enum, required.You can define a new
arkindex.process.models.ExportFormatenum which for now will only havepdfandpagexml. We will add more options later depending on which workers are available. You can add a comment onArkindexFeatureto remind developers to update bothArkindexFeatureandExportFormatfor 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_idis 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_nameshould 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_idwasNone. - Create a new Export process on the corpus, with the authenticated user as its creator and
element_idset if one was specified. - If
selectionis enabled, then newProcessElementinstances 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 theconfigurationand an extraexport_idparameter 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.