Experiment with addons

Addons allow to execute external programs in some context inside
docspell. Currently it is possible to run them after processing files.
Addons are provided by URLs to zip files.
This commit is contained in:
eikek
2022-04-22 14:07:28 +02:00
parent e04a76faa4
commit 7fdd78ad06
166 changed files with 8181 additions and 115 deletions

View File

@ -122,8 +122,45 @@ paths:
schema:
$ref: "#/components/schemas/BasicResult"
/addon/config:
get:
operationId: "v1-addon-config-get"
tags: [ Addons ]
summary: What is supported running addons
description: |
Return what this joex supports when executing addons.
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/AddonSupport"
components:
schemas:
AddonSupport:
description: |
How this joex supports executing addons.
required:
- nodeId
- runners
properties:
nodeId:
type: string
format: ident
runners:
type: array
items:
type: string
format: addon-runner-type
enum:
- nix-flake
- docker
- trivial
JobAndLog:
description: |
Some more details about the job.

View File

@ -10,7 +10,7 @@ import cats.effect._
import cats.implicits._
import docspell.common.{Ident, LenientUri}
import docspell.joexapi.model.BasicResult
import docspell.joexapi.model.{AddonSupport, BasicResult}
import org.http4s.blaze.client.BlazeClientBuilder
import org.http4s.circe.CirceEntityDecoder
@ -25,6 +25,7 @@ trait JoexClient[F[_]] {
def cancelJob(base: LenientUri, job: Ident): F[BasicResult]
def getAddonSupport(base: LenientUri): F[AddonSupport]
}
object JoexClient {
@ -33,6 +34,13 @@ object JoexClient {
new JoexClient[F] with CirceEntityDecoder {
private[this] val logger = docspell.logging.getLogger[F]
def getAddonSupport(base: LenientUri): F[AddonSupport] = {
val getUrl = base / "api" / "v1" / "addon" / "config"
val req = Request[F](Method.GET, uri(getUrl))
logger.debug(s"Getting addon support") *>
client.expect[AddonSupport](req)
}
def notifyJoex(base: LenientUri): F[BasicResult] = {
val notifyUrl = base / "api" / "v1" / "notify"
val req = Request[F](Method.POST, uri(notifyUrl))