Workflow Client

The workflow client provides a method to start a workflow in Preservica

Creating a client

The client takes mandatory arguments for the url of the Preservica service and the secret name of the secrets manager secret storing the API credentials.

There is a caching layer which caches the secret value and the API token on disk. The duration of the cache defaults to 15 minutes but can be configured here.

It is also possible to configure the secrets manager endpoint. This can be used for testing or if using private endpoints in a VPC.

These examples use both the FS2 client and the ZIO client

The workflow client doesn’t take a Stream type parameter as the search method doesn’t need to stream.

object WorkflowClients {
  import cats.effect.IO
  import uk.gov.nationalarchives.dp.client.WorkflowClient
  import uk.gov.nationalarchives.dp.client.fs2.Fs2Client

  import scala.concurrent.duration.*

  val preservicaUrl = "https://test.preservica.com"
  val secretName = "nameOfSecretsManagerSecretContainingAPICredentials"

  val fs2WorkflowClientWithDefaults: IO[WorkflowClient[IO]] = Fs2Client.workflowClient(preservicaUrl, secretName)
  val fs2WorkflowClientWithCustomCacheDuration: IO[WorkflowClient[IO]] =
    Fs2Client.workflowClient(preservicaUrl, secretName, 30.minutes)
  val fs2WorkflowClientWithCustomSecretsManagerEndpoint: IO[WorkflowClient[IO]] =
    Fs2Client.workflowClient(preservicaUrl, secretName, ssmEndpointUri = "https://private.ssm.endpoint")
  val fs2WorkflowClientWithCustomProxy: IO[WorkflowClient[IO]] =
    Fs2Client.workflowClient(preservicaUrl, secretName, potentialProxyUrl = Option(URI.create("http://proxy.url")))
}

Method descriptions

These are descriptions of the steps taken by each method. All methods get an authentication token first, either from the API or the cache.

startWorkflow

  • Generates the start workflow input XML from the arguments.
  • Sends this input XML to the start workflow endpoint of the API.