smart_city_registry v5.0.2 SmartCity.Registry.Organization View Source

Struct defining an organization definition and functions for reading and writing organization definitions to Redis.

const Organization = {
  "id": "",          // uuid
  "orgTitle": "",    // user friendly
  "orgName": "",     // system friendly
  "description": "",
  "logoUrl": "",
  "homepage": "",
  "dn": ""           // LDAP distinguished name
}

Link to this section Summary

Functions

Returns {:ok, organization} with the organization for the given id, or an error with the reason.

Returns the organization with the given id or raises an error.

Returns {:ok, organization} with all organization definitions in the system.

See get_all/0. Raises on errors.

Returns {:ok, organization_versions} with a history of all versions of the given organization.

See get_history/1. Raises on errors.

Writes the organization to history and sets the organization as the latest definition for the given id field of the passed in organization in Redis.

Link to this section Types

Link to this type

t()

View Source
t() :: %SmartCity.Registry.Organization{
  description: term(),
  dn: term(),
  homepage: term(),
  id: term(),
  logoUrl: term(),
  orgName: term(),
  orgTitle: term(),
  version: term()
}

Link to this section Functions

Returns {:ok, organization} with the organization for the given id, or an error with the reason.

Returns the organization with the given id or raises an error.

Link to this function

get_all()

View Source
get_all() :: {:ok, [SmartCity.Registry.Organization.t()]} | {:error, term()}

Returns {:ok, organization} with all organization definitions in the system.

See get_all/0. Raises on errors.

Link to this function

get_history(id)

View Source
get_history(id()) ::
  {:ok, [SmartCity.Registry.Organization.t()]} | {:error, term()}

Returns {:ok, organization_versions} with a history of all versions of the given organization.

See get_history/1. Raises on errors.

Returns a new SmartCity.Registry.Organization struct.

Can be created from:

  • map with string keys
  • map with atom keys
  • JSON
Link to this function

write(organization)

View Source
write(SmartCity.Organization.t()) :: {:ok, id()} | {:error, reason()}

Writes the organization to history and sets the organization as the latest definition for the given id field of the passed in organization in Redis.

Registry subscribers will be notified and have their handle_organization/1 callback triggered.

Returns an {:ok, id} tuple() where id is the organization id.

Parameters

  • organization: SmartCity.Registry.Organization struct to be written.