Sigra.EnterpriseConnections (Sigra v1.1.0)

Copy Markdown View Source

Organization-scoped enterprise connection lifecycle management.

This module owns the persisted truth for enterprise SSO setup. Host apps provide the schemas and repo; Sigra owns the lifecycle and validation rules.

Summary

Types

config()

@type config() :: %{
  :repo => module(),
  :schemas => %{enterprise_connection: module()},
  optional(:http_client) => function()
}

Functions

activate_connection(config, scope, attrs_or_connection \\ %{})

@spec activate_connection(config(), map(), map()) ::
  {:ok, struct()}
  | {:error, Ecto.Changeset.t()}
  | {:error, :validation_failed}
  | {:error, :forbidden}

change_connection(config, scope, attrs \\ %{})

@spec change_connection(config(), map(), map()) :: Ecto.Changeset.t()

disable_connection(config, scope, connection \\ nil)

@spec disable_connection(config(), map(), map()) ::
  {:ok, struct()} | {:error, :not_found} | {:error, :forbidden}

get_connection(config, scope)

@spec get_connection(config(), map()) :: struct() | nil

save_connection(config, scope, attrs)

@spec save_connection(config(), map(), map()) ::
  {:ok, struct()} | {:error, Ecto.Changeset.t()}

validate_connection(config, scope, attrs \\ %{})

@spec validate_connection(config(), map(), map()) ::
  {:ok, struct()}
  | {:error, Ecto.Changeset.t()}
  | {:error, :validation_failed, struct()}