Mock Activity Endpoint.

Arkadiusz Ryś 4dc63493ce Merge msdl/dev into cleanup %!s(int64=2) %!d(string=hai) anos
data be2e533e91 Remove unneeded requirements %!s(int64=2) %!d(string=hai) anos
docs f884dcce4c Add Lucas to authors %!s(int64=2) %!d(string=hai) anos
mocka 4dc63493ce Merge msdl/dev into cleanup %!s(int64=2) %!d(string=hai) anos
tests 9912a55430 Factor out concerns to standalone units %!s(int64=2) %!d(string=hai) anos
.dockerignore b6aeff41e9 Create boilerplate %!s(int64=2) %!d(string=hai) anos
.editorconfig b6aeff41e9 Create boilerplate %!s(int64=2) %!d(string=hai) anos
.gitignore 448b1725cf Set options to ignore generated images %!s(int64=2) %!d(string=hai) anos
.gitlab-ci.yml b6aeff41e9 Create boilerplate %!s(int64=2) %!d(string=hai) anos
Dockerfile b6aeff41e9 Create boilerplate %!s(int64=2) %!d(string=hai) anos
HISTORY.rst d304092daf Update changelog version 0.0.1 %!s(int64=2) %!d(string=hai) anos
LICENSE b6aeff41e9 Create boilerplate %!s(int64=2) %!d(string=hai) anos
README.md da519b36ab Include name field in json examples %!s(int64=2) %!d(string=hai) anos
pyproject.toml f884dcce4c Add Lucas to authors %!s(int64=2) %!d(string=hai) anos
requirements.txt be2e533e91 Remove unneeded requirements %!s(int64=2) %!d(string=hai) anos
tasks.py ee39c65b56 Create task invocation file %!s(int64=2) %!d(string=hai) anos

README.md

Mocka

Mock Activity Endpoint. Automated activity enactments must be HTTP calls where users must specify the endpoint in the FTG's Transformation, and the timeout in the PM's Activity. As an activity gets triggered it requires knowledge of the control and artefact flow. This endpoint expects this context in the form of a json body following a highly specific format.

{
    "ctrl": "<name of control port going into the activity>",
    "input": {
        "<name of artefact port going into the activity>": {
            "type": "<inline|reference>",
            "content": <the contents of the artefact going into this port in case it's inlined>,
            "name": "<the file name>",
            "encoding": "<the encoding of said artefact>"
        }
    }
}

Anything between < and > is to be filled in by the requester. Only inline type artefacts are supported at the moment.

Barring any errors, mocka will retaliate with a json response in the same gist.

{
    "ctrl": "<the name of the control port which should be taken out of the activity>",
    "output": {
        "<the name of the artefact which got generated>": {
            "type": "<inline|reference>",
            "content": <the contents of the generated artefact>,
            "name": "<the file name>",
            "encoding": "<the encoding of said artefact>"
        }
    }
}

This response can contain multiple artefacts. It can even be an error stating a timeout or broken input. The expectation is that the Workflow Enactment Engine will deal with the fallout.

NOTE: A call to store the artefact in the backend will be needed when the type of the output artefact is set to reference.

Deploying a mock activity endpoint

NOTE: Be sure to have ´libmagic´ installed. It is used to figure out the encoding of the artefacts being sent on their journey.

Drop into a shell and sing the magic incantation python3 -m mocka. This will leave you haunted with an endpoint lingering on port 7999 by default. From this point onward you're on your own and can perform any request you want.

Wishful thinking

It would be nice if this endpoint would support gradual progress updates. This would also require the Workflow Enactment Engine to do the same.