Admin Client

The admin client provides methods to update schemas, transfers, index definitions and metadata templates.

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 admin client doesn’t take a Stream type parameter as the methods don’t need to stream.

object AdminClients {
  import cats.effect.IO
  import uk.gov.nationalarchives.dp.client.AdminClient
  import uk.gov.nationalarchives.dp.client.fs2.Fs2Client

  import scala.concurrent.duration.*

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

  val fs2AdminClientWithDefaults: IO[AdminClient[IO]] = Fs2Client.adminClient(preservicaUrl, secretName)
  val fs2AdminClientWithCustomCacheDuration: IO[AdminClient[IO]] =
    Fs2Client.adminClient(preservicaUrl, secretName, 30.minutes)
  val fs2AdminClientWithCustomSecretsManagerEndpoint: IO[AdminClient[IO]] =
    Fs2Client.adminClient(preservicaUrl, secretName, ssmEndpointUri = "https://private.ssm.endpoint")
  val fs2AdminClientWithCustomProxy: IO[AdminClient[IO]] =
    Fs2Client.adminClient(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.

addOrUpdateIndexDefinitions

  • Generate query parameters based on the arguments
  • Delete the existing schema document if present
  • Add the new schema document

addOrUpdateMetadataTemplates

  • Generate query parameters based on the arguments
  • Delete the existing schema document if present
  • Add the new schema document

addOrUpdateSchemas

  • Generate query parameters based on the arguments
  • Delete the existing schema document if present
  • Add the new schema document

addOrUpdateTransforms

  • Generate query parameters based on the arguments
  • Delete the existing schema document if present
  • Add the new schema document