WeaviateEx.Types.Tenant (WeaviateEx v0.7.4)
View SourceTenant struct with typed activity status.
Represents a tenant in a multi-tenant collection with full type safety for activity status values.
Activity Status Types
:active- Tenant is active (alias for hot):inactive- Tenant is inactive (alias for cold):hot- Tenant data is in memory, ready for queries:cold- Tenant is temporarily deactivated:frozen- Tenant data is persisted but not in memory:offloaded- Tenant data moved to cold storage:offloading- Tenant is being offloaded to cold storage (transitional):onloading- Tenant is being loaded from cold storage (transitional)
Examples
tenant = Tenant.new("customer_123")
tenant = Tenant.new("customer_456", activity_status: :cold)
# Convert to API format
api_map = Tenant.to_map(tenant)
# => %{"name" => "customer_456", "activityStatus" => "COLD"}
# Parse from API response
tenant = Tenant.from_map(%{"name" => "customer_789", "activityStatus" => "FROZEN"})
# => %Tenant{name: "customer_789", activity_status: :frozen}
Summary
Functions
Checks if the tenant is active (hot or active status).
Creates a Tenant from a map (e.g., from API response).
Checks if the tenant is inactive.
Creates a new Tenant struct.
Sets the activity status of a tenant.
Converts the tenant to a map for the Weaviate API.
Checks if a status is valid.
Returns the list of valid activity statuses.
Validates the activity status.
Types
@type activity_status() ::
:active
| :inactive
| :hot
| :cold
| :frozen
| :offloaded
| :offloading
| :onloading
@type t() :: %WeaviateEx.Types.Tenant{ activity_status: activity_status(), name: String.t() }
Functions
Checks if the tenant is active (hot or active status).
Examples
Tenant.active?(Tenant.new("t1", activity_status: :hot))
# => true
Tenant.active?(Tenant.new("t1", activity_status: :cold))
# => false
Creates a Tenant from a map (e.g., from API response).
Examples
Tenant.from_map(%{"name" => "customer_123", "activityStatus" => "FROZEN"})
# => %Tenant{name: "customer_123", activity_status: :frozen}
Tenant.from_map(%{"name" => "customer_456"})
# => %Tenant{name: "customer_456", activity_status: :active}
Checks if the tenant is inactive.
Examples
Tenant.inactive?(Tenant.new("t1", activity_status: :cold))
# => true
Creates a new Tenant struct.
Options
:activity_status- Initial activity status (default::active)
Examples
tenant = Tenant.new("customer_123")
tenant = Tenant.new("customer_456", activity_status: :cold)
@spec set_status(t(), activity_status()) :: t()
Sets the activity status of a tenant.
Examples
tenant = Tenant.new("customer_123")
tenant = Tenant.set_status(tenant, :cold)
Converts the tenant to a map for the Weaviate API.
Examples
tenant = Tenant.new("customer_123", activity_status: :cold)
Tenant.to_map(tenant)
# => %{"name" => "customer_123", "activityStatus" => "COLD"}
Checks if a status is valid.
Examples
Tenant.valid_status?(:hot)
# => true
Tenant.valid_status?(:invalid)
# => false
@spec valid_statuses() :: [activity_status()]
Returns the list of valid activity statuses.
Examples
Tenant.valid_statuses()
# => [:active, :inactive, :hot, :cold, :frozen, :offloaded]
Validates the activity status.
Raises ArgumentError if the status is invalid.
Examples
Tenant.validate_status!(:hot)
# => :ok
Tenant.validate_status!(:invalid)
# ** (ArgumentError) Invalid activity_status: :invalid. Must be one of [:active, :inactive, :hot, :cold, :frozen, :offloaded]