Lightning.SetupUtils (Lightning v2.13.5)

View Source

SetupUtils encapsulates logic for setting up initial data for various sites.

Summary

Functions

Creates initial data and returns the created records.

In some (mostly remote-controlled) deployments, it's necessary to create a user, and apiToken, and multiple credentials (owned by the user) so that later openfn deploy calls can make use of these artifacts.

Functions

confirm_users(users)

create_dhis2_project(project_users)

create_openhie_project(project_users)

create_starter_project(name, project_users, with_workflow \\ false)

create_users(opts)

setup_demo(opts \\ [create_super: false])

@spec setup_demo(nil | maybe_improper_list() | map()) :: %{
  jobs: [...],
  projects: [atom() | %{:id => any(), optional(any()) => any()}, ...],
  users: [atom() | %{:id => any(), optional(any()) => any()}, ...],
  workflows: [atom() | %{:id => any(), optional(any()) => any()}, ...],
  workorders: [atom() | %{:id => any(), optional(any()) => any()}, ...]
}

Creates initial data and returns the created records.

setup_user(user, token \\ nil, credentials \\ nil)

@spec setup_user(map(), String.t() | nil, [map()] | nil) :: :ok | {:error, any()}

In some (mostly remote-controlled) deployments, it's necessary to create a user, and apiToken, and multiple credentials (owned by the user) so that later openfn deploy calls can make use of these artifacts.

When run before openfn deploy, this function makes it possible to set up an entire lightning instance with a working project (including secrets) without using the web UI.

Examples

iex> setup_user(%{email: "td@openfn.org", first_name: "taylor", last_name: "downs", password: "shh12345!"}, "secretToken", [%{name: "openmrs", schema: "raw", body: %{"a" => "secret"}}, %{ name: "dhis2", schema: "raw", body: %{"b" => "safe"}}]) :ok

tear_down(opts \\ [destroy_super: false])