Process Monitor Client
The process monitor client provides a method to get monitors and a method to get messages 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 process monitor client doesn’t take a Stream
type parameter as the getMonitors
method doesn’t need to stream.
object ProcessMonitorClients {
import cats.effect.IO
import uk.gov.nationalarchives.dp.client.ProcessMonitorClient
import uk.gov.nationalarchives.dp.client.fs2.Fs2Client
import scala.concurrent.duration.*
val preservicaUrl = "https://test.preservica.com"
val secretName = "nameOfSecretsManagerSecretContainingAPICredentials"
val fs2ProcessMonitorClientWithDefaults: IO[ProcessMonitorClient[IO]] =
Fs2Client.processMonitorClient(preservicaUrl, secretName)
val fs2ProcessMonitorClientWithCustomCacheDuration: IO[ProcessMonitorClient[IO]] =
Fs2Client.processMonitorClient(preservicaUrl, secretName, 30.minutes)
val fs2ProcessMonitorClientWithCustomSecretsManagerEndpoint: IO[ProcessMonitorClient[IO]] =
Fs2Client.processMonitorClient(preservicaUrl, secretName, ssmEndpointUri = "https://private.ssm.endpoint")
val fs2ProcessMonitorClientWithCustomProxy: IO[ProcessMonitorClient[IO]] = Fs2Client.processMonitorClient(
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.
getMonitors
- Generates the monitors input query from the arguments.
- Sends this query in order to call the
monitors
endpoint of the API and get information on a particular monitor.
getMessages
- Generates the generate input query from the arguments.
- Sends this query in order to call the
messages
endpoint of the API and get information on a particular message/messages.