Command-Line Interface

While the API is running, you can connect directly to its CLI (Command-Line Interface) to run low-level API commands as the system user.

Docker

If you installed Pro Custodibus via Docker, you can connect to the API CLI by running the following command from the same directory as the Pro Custodibus docker-compose.yml file:

$ docker-compose exec api bin/api remote
Erlang/OTP 26 [erts-14.2.5.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit:ns]

Interactive Elixir (1.16.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(api@77c456e774f5)1>

Native

If you installed Pro Custodibus natively, you can connect to the API CLI by running the following command as root (or as a sudoers user) on the API server:

$ /srv/procustodibus/api/ops/run/command.sh remote
[sudo] password for grace:
Erlang/OTP 26 [erts-14.2.5.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit:ns]

Interactive Elixir (1.16.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(api@colossus)1>

If you installed the API into a different directory than /srv/procustodibus/api, you will also need to specify the ROOT_DIR environment variable:

$ ROOT_DIR=/opt/pc-api /opt/pc-api/ops/run/command.sh remote

Quit

To quit the CLI, press ctrl-c to bring up a BREAK menu, and then press a to select the abort menu option:

iex(api@colossus)1>
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
       (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
a
$

Version

A safe example command you can run in the CLI is to print the API version information:

iex(api@77c456e774f5)1> Api.Utils.Version.new
%Api.Utils.Version{
  edition: "ee",
  hostname: "77c456e774f5",
  licensed: true,
  site: "prod",
  build: %Api.Utils.Version.Build{
    date: "2024-08-09T20:01:48+00:00",
    host: "build",
    user: "build",
    commit: "b008364b24c4fd7fa42a68a0a2d8fbc9b94830b7",
    tag: "1.5.0"
  }
}

List Login IDs

If you lost the login ID to a Pro Custodibus user (which is a randomly-generated string), you can find it by running the following command:

iex(api@77c456e774f5)2> Api.Ops.UserTools.list_login_ids
[
  [
    organization: "Super Arcem",
    name: "System User",
    login_id: "systemuser",
    db_id: 1,
    created: ~U[2020-01-01 00:00:00Z]
  ],
  [
    organization: "Remington Rand",
    name: "Grace Hopper",
    login_id: "Sb93efKdyaQ",
    db_id: 2,
    created: ~U[2024-04-08 02:05:48Z]
  ]
]

In the above command output, Sb93efKdyaQ is the login ID of the “Grace Hopper” user.

Reset Password Code

To generate a reset-password code for a user, run the following command, passing in their login ID (eg Sb93efKdyaQ) as the command argument:

iex(api@77c456e774f5)3> Api.Ops.UserTools.reset_password_code("Sb93efKdyaQ")
"https://procustodibus.example.com/c/password-reset/Nf16qAfejPz"

Copy and paste the generated URL into a web browser to reset the user’s password.

Create Super User

To create a new super user, run the following command:

iex(api@77c456e774f5)4> Api.Ops.UserTools.create_super_user
"https://procustodibus.example.com/c/password-reset/GWkW7v6xCWF"

Copy and paste the generated URL into a web browser to set the new super user’s password (after which the user’s login ID will be displayed).

Super users can view and access all organizations in the system.