ExPlain.Tenants (ExPlain v0.3.0)

Copy Markdown View Source

Operations for managing tenants in Plain.

Summary

Functions

Adds a customer to one or more tenants.

Fetches a tenant by its Plain ID. Returns {:ok, nil} if not found.

Returns a paginated list of tenants.

Removes a customer from one or more tenants.

Searches tenants by name or external ID.

Sets the exact list of tenants a customer belongs to, replacing any existing memberships.

Updates the tier associated with a tenant.

Creates or updates a tenant.

Functions

add_customer(client, input)

@spec add_customer(ExPlain.Client.t(), map()) ::
  {:ok, :added} | {:error, ExPlain.Error.t()}

Adds a customer to one or more tenants.

The input map must include :customer_identifier and :tenant_identifiers.

get_by_id(client, tenant_id)

@spec get_by_id(ExPlain.Client.t(), String.t()) ::
  {:ok, ExPlain.Tenants.Tenant.t() | nil} | {:error, ExPlain.Error.t()}

Fetches a tenant by its Plain ID. Returns {:ok, nil} if not found.

list(client, opts \\ [])

@spec list(
  ExPlain.Client.t(),
  keyword()
) ::
  {:ok, %{nodes: [ExPlain.Tenants.Tenant.t()], page_info: ExPlain.PageInfo.t()}}
  | {:error, ExPlain.Error.t()}

Returns a paginated list of tenants.

remove_customer(client, input)

@spec remove_customer(ExPlain.Client.t(), map()) ::
  {:ok, :removed} | {:error, ExPlain.Error.t()}

Removes a customer from one or more tenants.

The input map must include :customer_identifier and :tenant_identifiers.

search(client, search_query, opts \\ [])

@spec search(ExPlain.Client.t(), map(), keyword()) ::
  {:ok, %{nodes: [ExPlain.Tenants.Tenant.t()], page_info: ExPlain.PageInfo.t()}}
  | {:error, ExPlain.Error.t()}

Searches tenants by name or external ID.

The search_query map must include :name or :external_id.

set_customer_tenants(client, input)

@spec set_customer_tenants(ExPlain.Client.t(), map()) ::
  {:ok, :set} | {:error, ExPlain.Error.t()}

Sets the exact list of tenants a customer belongs to, replacing any existing memberships.

The input map must include :customer_identifier and :tenant_identifiers.

update_tier(client, input)

@spec update_tier(ExPlain.Client.t(), map()) ::
  {:ok, map()} | {:error, ExPlain.Error.t()}

Updates the tier associated with a tenant.

The input map must include :tenant_identifier and :tier_identifier.

upsert(client, input)

@spec upsert(ExPlain.Client.t(), map()) ::
  {:ok, ExPlain.Tenants.Tenant.t()} | {:error, ExPlain.Error.t()}

Creates or updates a tenant.

The input map must include :external_id and :name.