class

PlaceOS::Model::Tenant

Inherits PlaceOS::Model::Timestamps < PlaceOS::Model::Scope < PlaceOS::Model::Associations < PlaceOS::Model::ModelWithAutoKey < Neuroplastic < PgORM::Base < PgORM::Validators < PgORM::Table < PgORM::Persistence < PgORM::Associations < ActiveModel::Callbacks < ActiveModel::Validation < ActiveModel::Model < DB::Mappable < DB::Serializable < YAML::Serializable < JSON::Serializable < Reference < Object

Constants

CALLBACKS = { before_save: [:set_delegated, :"encrypt!"] of Nil, after_save: [] of Nil, before_create: [do self.created_at = self.updated_at = Time.utc end] of Nil, after_create: [] of Nil, before_update: [do self.updated_at = Time.utc end] of Nil, after_update: [] of Nil, before_destroy: [:destroy_attendees, :destroy_guests, :destroy_event_metadata] of Nil, after_destroy: [] of Nil, }
Log = ::Log.for(self)
PRIMARY_KEY_TYPES = {:id => (Int64 | Nil)} of Nil => Nil

macro level key => type

PRIMARY_KEYS = [{:id}]
VALID_PLATFORMS = ["office365", "google"]

Constructors

from_json(string_or_io : String | IO, trusted : Bool = false) : self
from_json(string_or_io : String | IO, root : String, trusted : Bool = false) : self

Deserializes the given JSON in string_or_io into an instance of self, assuming the JSON consists of an JSON object with key root, and whose value is the value to deserialize. Will not deserialise from fields with mass_assign: false

class User < ActiveModel::Model
  attribute name : String
  attribute google_id : UUID, mass_assign: false
end

User.from_json(%({"main": {"name": "Jason", "google_id": "f6f70bfb-c882-446d-8758-7ce47db39620"}}), root: "main") # => #<User:0x103131b20 @name="Jason">
from_trusted_json(string_or_io : String | IO, root : String) : self
from_trusted_json(string_or_io : String | IO) : self

Serialize from a trusted JSON source

from_trusted_yaml(string_or_io : String | IO) : self

Serialize from a trusted YAML source

from_yaml(string_or_io : String | IO, trusted : Bool = false) : self
new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
Source
new(pull : JSON::PullParser)
Source
new(rs : DB::ResultSet)
new(parent_id : Int64 | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, name : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, domain : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, email_domain : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, platform : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, credentials : String | ActiveModel::Model::None = ::ActiveModel::Model::None.new, booking_limits : JSON::Any | ActiveModel::Model::None = ::ActiveModel::Model::None.new, outlook_config : PlaceOS::Model::Tenant::OutlookConfig | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, delegated : Bool | ActiveModel::Model::None = ::ActiveModel::Model::None.new, service_account : String | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, secret_expiry : Time | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, early_checkin : Int64 | ActiveModel::Model::None = ::ActiveModel::Model::None.new, id : Int64 | Nil | ActiveModel::Model::None = ::ActiveModel::Model::None.new, created_at : Time | ActiveModel::Model::None = ::ActiveModel::Model::None.new, updated_at : Time | ActiveModel::Model::None = ::ActiveModel::Model::None.new)
new(params : HTTP::Params | Hash(String, String) | Tuple(String, String))

Initialize PlaceOS::Model::Tenant from HTTP::Params.

Class methods

attributes

Returns all attribute keys.

changes(id : Int64 | Nil | Nil = nil) : ChangeFeed

Changefeed at row (if id passed) or whole table level. Returns a ChangeFeed instance which can be used to invoke async callbacks via on or use blocking Iterator via each method.

elastic
from_rs(__temp_1814 : DB::ResultSet)
on_error(err : Exception | IO::Error)
primary_key

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

Source
table_name

Instance methods

after_create

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

after_destroy

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

after_initialize(trusted : Bool)
after_save

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

after_update

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

apply_defaults

Generate code to apply default values

as_json
Source
assign_attributes(parent_id : Int64 | Nil | Missing = Missing, name : String | Nil | Missing = Missing, domain : String | Missing = Missing, email_domain : String | Nil | Missing = Missing, platform : String | Missing = Missing, credentials : String | Missing = Missing, booking_limits : JSON::Any | Missing = Missing, outlook_config : PlaceOS::Model::Tenant::OutlookConfig | Nil | Missing = Missing, delegated : Bool | Missing = Missing, service_account : String | Nil | Missing = Missing, secret_expiry : Time | Nil | Missing = Missing, early_checkin : Int64 | Missing = Missing, id : Int64 | Nil | Missing = Missing, created_at : Time | Missing = Missing, updated_at : Time | Missing = Missing)

Assign to multiple attributes.

assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))

Assign to multiple attributes via HTTP::Params.

assign_attributes(model : PlaceOS::Model::Tenant)

Assign to multiple attributes from a model object

assign_attributes_from_json(json, root : String)
assign_attributes_from_json(json)
assign_attributes_from_trusted_json(json, root : String)
assign_attributes_from_trusted_json(json)

Assign each field from JSON if field exists in JSON and has changed in model

assign_attributes_from_trusted_yaml(yaml)
assign_attributes_from_yaml(yaml)

Uses the YAML parser as JSON is valid YAML

attendees
Source
attributes

Returns a Hash of all attribute values

attributes_tuple

Returns a NamedTuple of all attribute values.

before_create

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

before_destroy

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

before_save

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

before_update

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

booking_limits

booking_limits getter

booking_limits=(value : JSON::Any)

booking_limits setter

booking_limits?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

booking_limits_assigned?
booking_limits_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

booking_limits_changed?
booking_limits_default

booking_limits's default value

Source
booking_limits_present?
booking_limits_removed?
booking_limits_was
booking_limits_will_change!

Include booking_limits in the set of changed attributes, whether it has changed or not.

changed?

Check if any attributes have changed.

changed_attributes

Returns a Hash with all changed attributes.

changed_json(io : IO) : Nil

Serialize the set of changed attributes to JSON.

changed_json

Serialize the set of changed attributes to JSON.

changed_persist_attributes
changed_yaml(io : IO) : Nil

Serialize the set of changed attributes to YAML.

changed_yaml

Serialize the set of changed attributes to YAML.

clear_changes_information

Reset changes for all attributes.

created_at

created_at getter

created_at=(value : Time)

created_at setter

created_at?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

created_at_assigned?
created_at_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

created_at_changed?
created_at_default

created_at's default value

created_at_present?
created_at_removed?
created_at_was
created_at_will_change!

Include created_at in the set of changed attributes, whether it has changed or not.

credentials

credentials getter

credentials=(value : String)

credentials setter

credentials?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

credentials_assigned?
credentials_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

credentials_changed?
credentials_default

credentials's default value

Source
credentials_present?
credentials_removed?
credentials_was
credentials_will_change!

Include credentials in the set of changed attributes, whether it has changed or not.

decrypt_for(user) : String

Decrypts (if user has correct privilege) and returns the credentials string

Source
decrypt_for!(user)
Source
delegated

delegated getter

delegated=(value : Bool)

delegated setter

delegated?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

delegated_assigned?
delegated_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

delegated_changed?
delegated_default

delegated's default value

Source
delegated_present?
delegated_removed?
delegated_was
delegated_will_change!

Include delegated in the set of changed attributes, whether it has changed or not.

destroy_attendees
destroy_event_metadata
destroy_guests
domain

domain getter

domain=(value : String)

domain setter

domain?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

domain_assigned?
domain_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

domain_changed?
domain_default

domain's default value

Source
domain_present?
domain_removed?
domain_was
domain_will_change!

Include domain in the set of changed attributes, whether it has changed or not.

early_checkin

early_checkin getter

early_checkin=(value : Int64)

early_checkin setter

early_checkin?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

early_checkin_assigned?
early_checkin_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

early_checkin_changed?
early_checkin_default

early_checkin's default value

Source
early_checkin_present?
early_checkin_removed?
early_checkin_was
early_checkin_will_change!

Include early_checkin in the set of changed attributes, whether it has changed or not.

email_domain

email_domain getter

email_domain=(value : String | Nil)

email_domain setter

email_domain_assigned?
email_domain_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

email_domain_changed?
email_domain_default

email_domain's default value

Source
email_domain_present?
email_domain_removed?
email_domain_was
email_domain_will_change!

Include email_domain in the set of changed attributes, whether it has changed or not.

encrypt!

Encrypt in place

Source
event_metadata
Source
guests
Source
id

id getter

id=(value : Int64 | Nil)

id setter

id?
id_assigned?
id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

id_changed?
id_default

id's default value

id_present?
id_removed?
id_was
id_will_change!

Include id in the set of changed attributes, whether it has changed or not.

invoke_props

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

is_encrypted?

Determine if attributes are encrypted

Source
name

name getter

name=(value : String | Nil)

name setter

name_assigned?
name_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

name_changed?
name_default

name's default value

Source
name_present?
name_removed?
name_was
name_will_change!

Include name in the set of changed attributes, whether it has changed or not.

outlook_config

outlook_config getter

outlook_config=(value : PlaceOS::Model::Tenant::OutlookConfig | Nil)

outlook_config setter

outlook_config_assigned?
outlook_config_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

outlook_config_changed?
outlook_config_default

outlook_config's default value

Source
outlook_config_present?
outlook_config_removed?
outlook_config_was
outlook_config_will_change!

Include outlook_config in the set of changed attributes, whether it has changed or not.

parent
Source
parent_id

parent_id getter

parent_id=(value : Int64 | Nil)

Setters parent_id setter

parent_id_assigned?
parent_id_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

parent_id_changed?
parent_id_default

parent_id's default value

Source
parent_id_present?

TODO:: resolve for belongs_to Tenant, foreign_key: "parent_id", association_name: "parent"

parent_id_removed?
parent_id_was
parent_id_will_change!

Include parent_id in the set of changed attributes, whether it has changed or not.

persistent_attributes

Returns a Hash of all attributes that can be persisted.

place_calendar_client(bearer_token : String, expires : Int64 | Nil)
Source
place_calendar_client
Source
platform

platform getter

platform=(value : String)

platform setter

platform?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

platform_assigned?
platform_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

platform_changed?
platform_default

platform's default value

Source
platform_present?
platform_removed?
platform_was
platform_will_change!

Include platform in the set of changed attributes, whether it has changed or not.

primary_key

Base class for all models which have auto-generated bigint as pk and doesn't require string based auto generated pk

Source
primary_key_hash
restore_attributes

Reset each attribute to their previous values and clears all changes.

secret_expiry

secret_expiry getter

secret_expiry=(value : Time | Nil)

secret_expiry setter

secret_expiry_assigned?
secret_expiry_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

secret_expiry_changed?
secret_expiry_default

secret_expiry's default value

Source
secret_expiry_present?
secret_expiry_removed?
secret_expiry_was
secret_expiry_will_change!

Include secret_expiry in the set of changed attributes, whether it has changed or not.

service_account

service_account getter

service_account=(value : String | Nil)

service_account setter

service_account_assigned?
service_account_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

service_account_changed?
service_account_default

service_account's default value

Source
service_account_present?
service_account_removed?
service_account_was
service_account_will_change!

Include service_account in the set of changed attributes, whether it has changed or not.

set_delegated

ensure delegated column has been defined

Source
table_name
updated_at

updated_at getter

updated_at=(value : Time)

updated_at setter

updated_at?

NOTE: use getter / getter! (not property / property!) so that the setter defined later in __create_initializer__ is the only setter on the field. Crystal's overload resolution silently fails to replace a property-defined setter with one of identical signature for generic types (e.g. Set(String)?, Array(String)?, String | Array(String)), although it does work for non-generic ones like String?. Defining the setter only once via __create_initializer__ ensures change tracking, sanitization, and custom setter blocks run uniformly across all types.

updated_at_assigned?
updated_at_change

Returns a Tuple of the previous and the current value of an instance variable if it has changed

updated_at_changed?
updated_at_default

updated_at's default value

updated_at_present?
updated_at_removed?
updated_at_was
updated_at_will_change!

Include updated_at in the set of changed attributes, whether it has changed or not.

using_service_account?
Source
valid_json?(value : String)
Source
validate_nilability

Validate that all non-nillable fields have values.

which_account(user_email : String, resources = [] of String) : String

distribute load as much as possible when using service accounts

Source

Macros

scope(name, &block)

Nested types