integration

lib.integration.capitalize

Uppercase the first character of s, leaving the rest unchanged. An empty string is returned as-is.

Arguments

s (String): The string to capitalize

Example

capitalize "sonarr"
=> "Sonarr"

lib.integration.mkArrStackIntegrationScript

Build a shell script that idempotently registers an integration with an *Arr-stack app's (Sonarr/Radarr/Prowlarr-style) REST API: it checks apiEndpoint for an existing entry matching settings.implementation, and if none is found, POSTs settings to create one.

Arguments

name (String): Name of the app being integrated with, used in log messages

apiEndpoint (String): URL of the integration list/create endpoint

authApiKeyVar (String): Environment variable holding the API key for apiEndpoint

settings (AttrSet): The integration payload to POST; settings.fields is an attrset serialized to the API's field-list format, and settings.implementation identifies the integration type

apiKeyFieldName (String): Field name to inject apiKeyVar's value under in settings.fields (optional, required if apiKeyVar is set)

apiKeyVar (String): Environment variable to inject into settings.fields (optional)

Example

integration.mkArrStackIntegrationScript {
  name = "Sonarr";
  apiEndpoint = "${integration.workloadServiceUrl prowlarrWorkload}/api/v1/applications";
  authApiKeyVar = "PROWLARR_API_KEY";
  apiKeyFieldName = "apiKey";
  apiKeyVar = "SONARR_API_KEY";
  settings = {
    implementation = "Sonarr";
    fields.baseUrl = integration.workloadServiceUrl sonarrWorkload;
  };
}