TamaEx.Memory (TamaEx v0.1.18)

View Source

Client for interacting with Memory API endpoints.

Summary

Functions

Creates a new entity for a class.

Retrieves an entity for a class by ID or identifier.

Functions

create_entity(client, class, attrs)

Creates a new entity for a class.

Parameters

  • client - The HTTP client
  • class - The Class struct containing the class_id
  • attrs - Map containing entity parameters (identifier, record, validate_record)

Examples

iex> attrs = %{"identifier" => "entity1", "record" => %{}}
iex> {:ok, validated_params} = TamaEx.Memory.Entity.Params.validate(attrs)
iex> validated_params["identifier"]
"entity1"

iex> {:error, changeset} = TamaEx.Memory.Entity.Params.validate(%{})
iex> changeset.valid?
false

get_entity(client, class, id_or_identifier)

Retrieves an entity for a class by ID or identifier.

Parameters

  • client - The HTTP client
  • class - The Class struct containing the class_id
  • id_or_identifier - Entity ID or identifier

update_entity(client, class, id, attrs, options \\ [])

Updates an entity for a class.

Parameters

  • client - The HTTP client
  • class - The Class struct containing the class_id
  • id - Entity ID or identifier to update
  • attrs - Map containing entity parameters (record is required, identifier and validate_record are optional)

Examples

iex> attrs = %{"record" => %{"name" => "Updated Name"}}
iex> {:ok, validated_params} = TamaEx.Memory.Entity.Params.validate_update(attrs)
iex> validated_params["record"]
%{"name" => "Updated Name"}