class PlaceOS::Api::Systems

Included Modules

Defined in:

placeos-rest-api/controllers/systems.cr

Constant Summary

AFTER = {} of Nil => Nil
AROUND = {} of Nil => Nil
BEFORE = {set_request_id => {nil, nil}, authorize! => {nil, [root, mqtt_user, mqtt_access]}, set_user_id => {nil, [root, mqtt_user, mqtt_access]}, can_read_guest => {[show, sys_zones], nil}, can_read => {[index, find_by_email], nil}, can_write => {[create, update, destroy, remove, update_alt, start, stop], nil}, can_read_control => {[types, functions, state, state_lookup], nil}, can_write_control => {[control, execute], nil}, check_admin => {nil, [index, show, find_by_email, control, execute, types, functions, state, state_lookup]}, check_support => {[state, state_lookup, functions], nil}, current_control_system => {[show, update, destroy, remove, start, stop, execute, types, functions, metadata], nil}, ensure_json => {[create, update, update_alt, execute], nil}, body => {[create, execute, update, update_alt], nil}} of Nil => Nil
FORCE = {} of Nil => Nil
LOCAL_AFTER = {} of Nil => Nil

function => options

LOCAL_AROUND = {} of Nil => Nil

function => options

LOCAL_BEFORE = {can_read_guest => {[show, sys_zones], nil}, can_read => {[index, find_by_email], nil}, can_write => {[create, update, destroy, remove, update_alt, start, stop], nil}, can_read_control => {[types, functions, state, state_lookup], nil}, can_write_control => {[control, execute], nil}, check_admin => {nil, [index, show, find_by_email, control, execute, types, functions, state, state_lookup]}, check_support => {[state, state_lookup, functions], nil}, current_control_system => {[show, update, destroy, remove, start, stop, execute, types, functions, metadata], nil}, ensure_json => {[create, update, update_alt, execute], nil}, body => {[create, execute, update, update_alt], nil}} of Nil => Nil

function => options

LOCAL_FORCE = {} of Nil => Nil

function => options

LOCAL_RESCUE = {} of Nil => Nil

function => options

LOCAL_ROUTES = {find_by_email => {"get", "/with_emails", nil, do emails = required_param(in) systems = (Model::ControlSystem.find_all(emails, index: :email)).to_a set_collection_headers(systems.size, Model::ControlSystem.table_name) render(json: systems) end, false}, update_alt => {"put", "/:sys_id", nil, do update end, false}, sys_zones => {"get", "/:sys_id/zones", nil, do if user_token.guest_scope? if user_token.user.roles.includes?(control_system_id) else return head(:forbidden) end end documents = if current_control_system.zones.empty? [] of Model::Zone else (Model::Zone.find_all(current_control_system.zones)).to_a end set_collection_headers(documents.size, Model::Zone.table_name) render(json: documents) end, false}, metadata => {"get", "/:sys_id/metadata", nil, do parent_id = current_control_system.id.not_nil! render(json: Model::Metadata.build_metadata(parent_id, name)) end, false}, settings => {"get", "/:sys_id/settings", nil, do render(json: Api::Settings.collated_settings(current_user, current_control_system)) end, false}, add_module => {"put", "/:sys_id/module/:module_id", nil, do if Model::Module.exists?(module_id) else head(:not_found) end module_present = (current_control_system.modules.includes?(module_id)) || (Model::ControlSystem.add_module(control_system_id, module_id)) if module_present else render(text: "Failed to add ControlSystem Module", status: :internal_server_error) end render(json: Model::ControlSystem.find!(control_system_id, runopts: {"read_mode" => "majority"})) end, false}, remove_module => {"delete", "/:sys_id/module/:module_id", nil, do if current_control_system.modules.includes?(module_id) current_control_system.remove_module(module_id) current_control_system.save! end render(json: current_control_system) end, false}, start => {"post", "/:sys_id/start", nil, do Systems.module_running_state(running: true, control_system: current_control_system) head(:ok) end, false}, stop => {"post", "/:sys_id/stop", nil, do Systems.module_running_state(running: false, control_system: current_control_system) head(:ok) end, false}, execute => {"post", "/:sys_id/:module_slug/:method", nil, do begin module_name, index = RemoteDriver.get_parts(module_slug) Log.context.set(module_name: module_name, index: index, method: method) args = Array(JSON::Any).from_json(self.body) remote_driver = RemoteDriver.new(sys_id: control_system_id, module_name: module_name, index: index, discovery: self.class.core_discovery, user_id: current_user.id) response_text, status_code = remote_driver.exec(security: driver_clearance(user_token), function: method, args: args, request_id: request_id) response.headers["Content-Type"] = "application/json" render(text: response_text, status: status_code) rescue e : RemoteDriver::Error handle_execute_error(e) end end, false}, types => {"get", "/:sys_id/types", nil, do types = (Model::Module.in_control_system(current_control_system.id.as(String))).tally_by(&.resolved_name) render(json: types) end, false}, state => {"get", "/:sys_id/:module_slug", nil, do module_name, index = RemoteDriver.get_parts(module_slug) render(json: self.class.module_state(control_system_id, module_name, index)) end, false}, state_lookup => {"get", "/:sys_id/:module_slug/:key", nil, do module_name, index = RemoteDriver.get_parts(module_slug) render(json: self.class.module_state(control_system_id, module_name, index, key)) end, false}, functions => {"get", "/:sys_id/functions/:module_slug", nil, do module_name, index = RemoteDriver.get_parts(module_slug) metadata = ::PlaceOS::Driver::Proxy::System.driver_metadata?(system_id: control_system_id, module_name: module_name, index: index) if metadata else Log.debug do "metadata not found for #{module_slug} on #{control_system_id}" end head(:not_found) end hidden_functions = if user_token.is_admin? [] of String else if user_token.is_support? metadata.security["administrator"]? || ([] of String) else (metadata.security["support"]? || ([] of String)) + (metadata.security["administrator"]? || ([] of String)) end end functions = metadata.interface.reject!(hidden_functions) response = functions.transform_values do |arguments| {arity: arguments.size, params: arguments, order: arguments.keys} end render(json: response) end, false}, control => {"get", "/control", nil, do |ws| Log.trace do "WebSocket API request" end Log.context.set(fixed_device: boolean_param("fixed_device")) Systems.session_manager.create_session(ws: ws, request_id: request_id, user: user_token) end, true}} of Nil => Nil

function => options

LOCAL_SKIP = {} of Nil => Nil

function => options

Log = ::PlaceOS::Api::Log.for(self)
NAMESPACE = ["/api/engine/v2/systems/"]

default namespace based on class

RESCUE = {Error::NoBody => {error_no_body, do |_error| message = "missing request body" Log.debug do message end return render_error(HTTP::Status::BAD_REQUEST, message) end}, JSON::SerializableError => {json_serializable_error, do |error| message = "Missing or extraneous properties in client JSON" Log.debug(exception: error) do message end if Api.production? return render_error(HTTP::Status::BAD_REQUEST, message) else return render_error(HTTP::Status::BAD_REQUEST, error.message, backtrace: error.backtrace?) end end}, JSON::ParseException => {json_parse_exception, do |error| message = "Failed to parse client JSON" Log.debug(exception: error) do message end if Api.production? return render_error(HTTP::Status::BAD_REQUEST, message) else return render_error(HTTP::Status::BAD_REQUEST, error.message, backtrace: error.backtrace?) end end}, Error::Unauthorized => {error_unauthorized, do |error| Log.debug do error.message end head(:unauthorized) end}, Error::Forbidden => {error_forbidden, do |error| Log.debug do error.message end head(:forbidden) end}, RethinkORM::Error::DocumentNotFound => {rethink_orm_error_document_not_found, do |error| Log.debug do error.message end head(:not_found) end}, RethinkORM::Error::DocumentInvalid => {rethink_orm_error_document_invalid, do |error| Log.debug do error.message end return render_error(HTTP::Status::UNPROCESSABLE_ENTITY, error.message) end}, Error::InvalidParams => {error_invalid_params, do |error| model_errors = error.params.errors.map(&.to_s) Log.debug(exception: error) do {message: "Invalid params", model_errors: model_errors} end return render_error(HTTP::Status::BAD_REQUEST, "Invalid params: #{model_errors.join(", ")}") end}} of Nil => Nil
ROUTE_RESOURCE = "systems"
ROUTES = {find_by_email => {"get", "/with_emails", nil, do emails = required_param(in) systems = (Model::ControlSystem.find_all(emails, index: :email)).to_a set_collection_headers(systems.size, Model::ControlSystem.table_name) render(json: systems) end, false}, update_alt => {"put", "/:sys_id", nil, do update end, false}, sys_zones => {"get", "/:sys_id/zones", nil, do if user_token.guest_scope? if user_token.user.roles.includes?(control_system_id) else return head(:forbidden) end end documents = if current_control_system.zones.empty? [] of Model::Zone else (Model::Zone.find_all(current_control_system.zones)).to_a end set_collection_headers(documents.size, Model::Zone.table_name) render(json: documents) end, false}, metadata => {"get", "/:sys_id/metadata", nil, do parent_id = current_control_system.id.not_nil! render(json: Model::Metadata.build_metadata(parent_id, name)) end, false}, settings => {"get", "/:sys_id/settings", nil, do render(json: Api::Settings.collated_settings(current_user, current_control_system)) end, false}, add_module => {"put", "/:sys_id/module/:module_id", nil, do if Model::Module.exists?(module_id) else head(:not_found) end module_present = (current_control_system.modules.includes?(module_id)) || (Model::ControlSystem.add_module(control_system_id, module_id)) if module_present else render(text: "Failed to add ControlSystem Module", status: :internal_server_error) end render(json: Model::ControlSystem.find!(control_system_id, runopts: {"read_mode" => "majority"})) end, false}, remove_module => {"delete", "/:sys_id/module/:module_id", nil, do if current_control_system.modules.includes?(module_id) current_control_system.remove_module(module_id) current_control_system.save! end render(json: current_control_system) end, false}, start => {"post", "/:sys_id/start", nil, do Systems.module_running_state(running: true, control_system: current_control_system) head(:ok) end, false}, stop => {"post", "/:sys_id/stop", nil, do Systems.module_running_state(running: false, control_system: current_control_system) head(:ok) end, false}, execute => {"post", "/:sys_id/:module_slug/:method", nil, do begin module_name, index = RemoteDriver.get_parts(module_slug) Log.context.set(module_name: module_name, index: index, method: method) args = Array(JSON::Any).from_json(self.body) remote_driver = RemoteDriver.new(sys_id: control_system_id, module_name: module_name, index: index, discovery: self.class.core_discovery, user_id: current_user.id) response_text, status_code = remote_driver.exec(security: driver_clearance(user_token), function: method, args: args, request_id: request_id) response.headers["Content-Type"] = "application/json" render(text: response_text, status: status_code) rescue e : RemoteDriver::Error handle_execute_error(e) end end, false}, types => {"get", "/:sys_id/types", nil, do types = (Model::Module.in_control_system(current_control_system.id.as(String))).tally_by(&.resolved_name) render(json: types) end, false}, state => {"get", "/:sys_id/:module_slug", nil, do module_name, index = RemoteDriver.get_parts(module_slug) render(json: self.class.module_state(control_system_id, module_name, index)) end, false}, state_lookup => {"get", "/:sys_id/:module_slug/:key", nil, do module_name, index = RemoteDriver.get_parts(module_slug) render(json: self.class.module_state(control_system_id, module_name, index, key)) end, false}, functions => {"get", "/:sys_id/functions/:module_slug", nil, do module_name, index = RemoteDriver.get_parts(module_slug) metadata = ::PlaceOS::Driver::Proxy::System.driver_metadata?(system_id: control_system_id, module_name: module_name, index: index) if metadata else Log.debug do "metadata not found for #{module_slug} on #{control_system_id}" end head(:not_found) end hidden_functions = if user_token.is_admin? [] of String else if user_token.is_support? metadata.security["administrator"]? || ([] of String) else (metadata.security["support"]? || ([] of String)) + (metadata.security["administrator"]? || ([] of String)) end end functions = metadata.interface.reject!(hidden_functions) response = functions.transform_values do |arguments| {arity: arguments.size, params: arguments, order: arguments.keys} end render(json: response) end, false}, control => {"get", "/control", nil, do |ws| Log.trace do "WebSocket API request" end Log.context.set(fixed_device: boolean_param("fixed_device")) Systems.session_manager.create_session(ws: ws, request_id: request_id, user: user_token) end, true}, index => {"get", "/", nil, nil, false}, show => {"get", "/:sys_id", nil, nil, false}, update => {"patch", "/:sys_id", nil, nil, false}, create => {"post", "/", nil, nil, false}, destroy => {"delete", "/:sys_id", nil, nil, false}} of Nil => Nil
SKIP = {} of Nil => Nil

Class Method Summary

Instance Method Summary

Macro Summary

Instance methods inherited from module PlaceOS::Api::Utils::CoreHelper

driver_clearance(user : Model::User | Model::UserJWT) driver_clearance

Instance methods inherited from class PlaceOS::Api::Application

body : IO body, boolean_param(key : String, default : Bool = false, allow_empty : Bool = false) : Bool boolean_param, paginate_results(elastic, query, route = base_route) paginate_results, request_id : String request_id, set_collection_headers(size : Int32, content_type : String) set_collection_headers, set_request_id set_request_id, set_user_id set_user_id

Class methods inherited from class PlaceOS::Api::Application

context(method : String, route : String, route_params : Hash(String, String) | Nil = nil, headers : Hash(String, String) | Nil = nil, body : String | Bytes | IO | Nil = nil, &) context, core_discovery : Discovery::Core core_discovery

Class methods inherited from module PlaceOS::Api::Utils::Scopes

can_scope_access?(user_token : UserJWT, scope : String, access : Access) can_scope_access?, can_scopes_access!(user_token : UserJWT, scopes : Enumerable(String), access : Access) can_scopes_access!

Instance methods inherited from module PlaceOS::Api::Utils::CurrentUser

authorize! : Model::UserJWT authorize!, check_admin check_admin, check_oauth_scope check_oauth_scope, check_support check_support, current_authority : Model::Authority | Nil current_authority, current_user : Model::User current_user, is_admin? is_admin?, is_support? is_support?, user_token : Model::UserJWT user_token

Instance methods inherited from module PlaceOS::Api::Utils::Responders

handle_execute_error(error : Driver::Proxy::RemoteDriver::Error, respond : Bool = true) handle_execute_error, render_error(status : HTTP::Status, message : String | Nil, **additional) render_error, restrict_attributes(model, only : Array(String) | Nil = nil, except : Array(String) | Nil = nil, fields : Hash | Nil = nil) : Hash restrict_attributes, save_and_respond(resource, &)
save_and_respond(resource)
save_and_respond
, save_and_status(resource) save_and_status, with_fields(model, fields) : Hash with_fields

Class Method Detail

def self.__init_routes__(router) #

Routes call the functions generated above


def self.__route_list__ #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.add_module(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.base_route #

Helper for obtaining base route


def self.context(method : String, route : String, route_params : Hash(String, String) | Nil = nil, headers : Hash(String, String) | Nil = nil, body : String | Bytes | IO | Nil = nil, &) #

[View source]
def self.control(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.core_for(module_id : String, request_id : String | Nil = nil) : Core::Client #

Create a core client for given module id


[View source]
def self.core_for(module_id : String, request_id : String | Nil = nil, & : Core::Client -> V) forall V #

Create a core client and yield it to a block


[View source]
def self.create(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.delete__api_engine_v2_systems___sys_id(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.delete__api_engine_v2_systems___sys_id_module__module_id(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.destroy(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.execute(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.find_by_email(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Helper methods for performing redirect_to calls


def self.functions(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__api_engine_v2_systems__(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__api_engine_v2_systems___sys_id(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__api_engine_v2_systems___sys_id__module_slug(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__api_engine_v2_systems___sys_id__module_slug__key(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__api_engine_v2_systems___sys_id_functions__module_slug(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__api_engine_v2_systems___sys_id_metadata(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__api_engine_v2_systems___sys_id_settings(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__api_engine_v2_systems___sys_id_types(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__api_engine_v2_systems___sys_id_zones(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__api_engine_v2_systems__control(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__api_engine_v2_systems__with_emails(context, head_request) #

Generate functions for each route


def self.index(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.locate_module(module_id : String) : URI #

Use consistent hashing to determine the location of the module


[View source]
def self.locate_module?(sys_id : String, module_name : String, index : Int32) : URI | Nil #

Determine URI for a system module


[View source]
def self.metadata(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.module_state(sys_id : String, module_name : String, index : Int32, key : String | Nil = nil) #

[View source]
def self.patch__api_engine_v2_systems___sys_id(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.post__api_engine_v2_systems__(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.post__api_engine_v2_systems___sys_id__module_slug__method(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.post__api_engine_v2_systems___sys_id_start(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.post__api_engine_v2_systems___sys_id_stop(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.put__api_engine_v2_systems___sys_id(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.put__api_engine_v2_systems___sys_id_module__module_id(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.remove_module(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.session_manager : WebSocket::Manager #

Websocket API session manager


[View source]
def self.settings(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.show(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.start(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.state(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.state_lookup(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.stop(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.sys_zones(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.types(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.update(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.update_alt(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


Instance Method Detail

def add_module #

Adds the module from the system if it doesn't already exist


[View source]
def base_route(*args, **options) #

Helper for obtaining base route


def base_route(*args, **options, &) #

Helper for obtaining base route


def complete? : Bool #

[View source]
def control(ws) #

[View source]
def control_system_id : String #

[View source]
def create #

[View source]
def current_control_system : Model::ControlSystem #

[View source]
def destroy #

[View source]
def error_forbidden(error) #

def error_invalid_params(error) #

def error_no_body(_error) #

Create functions as required for errors Skip the generating methods for existing handlers


def error_unauthorized(error) #

def execute #

Runs a function in a system module


[View source]
def find_by_email #

Finds all the systems with the specified email address


[View source]
def functions #

Lists functions available on the driver Filters higher privilege functions.


[View source]
def in : Array(String) | Nil #

[View source]
def index #

Query ControlSystem resources


[View source]
def json_parse_exception(error) #

def json_serializable_error(error) #

def key : String #

[View source]
def metadata #

Return metadata for the system


[View source]
def method : String #

[View source]
def module_id : String #

[View source]
def module_slug : String #

[View source]
def name : String | Nil #

[View source]
def remove_module #

Removes the module from the system and deletes it if not used elsewhere


[View source]
def rethink_orm_error_document_invalid(error) #

def rethink_orm_error_document_not_found(error) #

def settings #

Receive the collated settings for a system


[View source]
def show #

Renders a control system


[View source]
def start #

Start modules


[View source]
def state #

Returns the state of an associated module


[View source]
def state_lookup #

Returns the state lookup for a given key on a module


[View source]
def stop #

Stop modules


[View source]
def sys_zones #

Return all zones for this system


[View source]
def types #

Look-up a module types in a system, returning a count of each type


[View source]
def update #

Updates a control system


[View source]
def update_alt #

def version : Int32 | Nil #

[View source]

Macro Detail

macro __inherit_after_filters__ #

macro __inherit_around_filters__ #

macro __inherit_before_filters__ #

macro __inherit_force_filters__ #

macro __inherit_rescue_filters__ #

macro __inherit_routes_filters__ #

macro __inherit_skip_filters__ #

macro generate_scope_check(*scopes) #