Module watts_service

this module handles the services.

Description

this module handles the services. It validates the parameter coming from the plugin as as the configuration itself.

Data Types

conf_parameter()

conf_parameter() = #{name => binary(), type => binary(), default => any()}

conf_parameters()

conf_parameters() = [conf_parameter()]

connection()

connection() = #{type => local | ssh, user => undefined | string(), passwd => undefined | string(), host => undefined | string(), port => undefined | integer(), ssh_dir => undefined | string(), ssh_key_pass => undefined | string()}

info()

info() = #{id => binary(), allow_same_state => boolean(), authz => watts_service_authz:config(), cmd => binary(), connection => connection(), cred_limit => infinite | integer(), description => binary(), enabled => boolean(), parallel_runner => infinite | integer(), params => [parameter_set()], pass_access_token => boolean(), plugin_conf => map(), plugin_features => map(), plugin_timeout => infinity | integer(), plugin_version => undefined | binary(), queue => atom(), term() => term()}

limited_info()

limited_info() = #{id => binary(), description => binary(), cred_limit => infinite | integer(), pass_access_token => boolean(), enabled => boolean(), params => [], limit_reached => boolean(), cred_count => integer(), authorized => boolean(), authz_tooltip => binary()}

parameter()

parameter() = #{key => binary(), name => binary(), description => binary(), type => atom(), mandatory => boolean()}

parameter_set()

parameter_set() = [parameter()]

Function Index

add/1add a service to the ets database, used during initialization.
add_queue/2*add a queue to jobs.
allows_same_state/1wether the plugin may return the same state twice.
are_params_valid/2check if the passed request parameters are valid for the service.
convert_to_type/2*convert the valut to the given type.
exists/1return if a service with the given id exists.
filter_list_for_user/2*filter the list of services for a user, to hide them.
fulfills_paramset/2*check if the list of keys are fullfilling the given parameter set.
gen_queue_name/1*generate the name of a queue: the atom 'watts_service-ID'.
get_and_validate_parameter/1*get and validate the parameter from the plugin.
get_credential_limit/1get the credential limit for a service.
get_info/1get the info for a sepcific service id.
get_list/0get a list of all services currently configured.
get_list/1get the list of all services for a user.
get_queue/1get the queue name (an atom) for a service id.
is_allowed/2checks if a user is allowed to use the given service.
is_allowed/3*checking the service authorization rules see watts_service_authz.
is_enabled/1return if a service, given by the id, is enabled.
is_secure_plugin_or_allowed/3*check and log if a plugin supports stdin of if insecure plugins are allowed.
is_valid_key/1*return if a key is valid.
is_valid_key_char/1*ceck if the character is valid within a key.
list_skipped_parameter_and_delete_config/1*list the skipped parameter from the config and delete the raw config.
maybe_warn_default/4*print a warning if using the default value from the plugin.
maybe_warning_about_using_env/1*write a warning about not supporting environment anymore.
start_runner_queue_if_needed/1*start the runnuner queue if needed.
to_atom/1*convert the binary to an existing atom or unknown.
to_conf_type/1*convert the type to a configuration type.
to_request_type/1*convert the type to a request type.
to_valid_type/2*try to convert the type to an atom and find it in the given list.
update_conf_parameter/5*check the conversion results and update the config if all okay.
update_limits_for_user/2*update the list for the user with limits and permissions.
update_params/1update the parameter of a service by running the plugin.
update_service/2*update the config of the service in the ets.
validate_call_parameter/9*validate one parameter for a call (part of a parameter set).
validate_call_parameter_set/2*validate a single parameter set.
validate_call_parameter_set/5*validate a call parameter set and keep track of the result.
validate_call_parameter_sets/2*validate the call parameter sets.
validate_call_parameter_sets/3*validate the call parameter sets and keep track of the result Itterate through each parameter set, validating it.
validate_conf_parameter/2*validate configuration parameter.
validate_conf_parameter/3*validate the configuration parameter and keep track of the result.
validate_params_and_update_db/3*validate the parameter returned from the plugin and maybe update the ets.

Function Details

add/1

add(ServiceInfo::info()) -> {ok, binary()} | {error, invalid_config}

add a service to the ets database, used during initialization

add_queue/2 *

add_queue(Id::binary(), NumRunner::integer()) -> ok

add a queue to jobs

allows_same_state/1

allows_same_state(ServiceId::binary()) -> boolean()

wether the plugin may return the same state twice

are_params_valid/2

are_params_valid(Params::map(), ServiceId::info() | limited_info() | binary()) -> boolean()

check if the passed request parameters are valid for the service

convert_to_type/2 *

convert_to_type(Value::binary(), X2::atom()) -> {ok, binary() | atom()} | {error, bad_value}

convert the valut to the given type.

exists/1

exists(ServiceId::binary()) -> boolean()

return if a service with the given id exists

filter_list_for_user/2 *

filter_list_for_user(UserInfo::watts_userinfo:info(), ServiceList::[info()]) -> {ok, [info()]}

filter the list of services for a user, to hide them.

fulfills_paramset/2 *

fulfills_paramset(Params::[binary()], List::parameter_set()) -> boolean()

check if the list of keys are fullfilling the given parameter set

gen_queue_name/1 *

gen_queue_name(Id::binary()) -> atom()

generate the name of a queue: the atom 'watts_service-ID'. Where ID is the id of the service.

get_and_validate_parameter/1 *

get_and_validate_parameter(X1::{ok, {binary(), info()}} | any()) -> ok | {error, not_found}

get and validate the parameter from the plugin.

get_credential_limit/1

get_credential_limit(ServiceId::binary()) -> {ok, integer() | infinite}

get the credential limit for a service

get_info/1

get_info(ServiceId::binary()) -> {ok, info()} | {error, Reason::atom()}

get the info for a sepcific service id

get_list/0

get_list() -> {ok, [info()]}

get a list of all services currently configured.

get_list/1

get_list(UserInfo::watts_userinfo:userinfo()) -> {ok, [limited_info()]}

get the list of all services for a user

get_queue/1

get_queue(ServiceId::binary()) -> {ok, atom()}

get the queue name (an atom) for a service id

is_allowed/2

is_allowed(UserInfo::watts_userinfo:userinfo(), ServiceId::binary()) -> boolean()

checks if a user is allowed to use the given service

See also: is_allowed/3.

is_allowed/3 *

is_allowed(ServiceId::binary(), UserInfo::watts_userinfo:userinfo(), AuthzConf::watts_service_authz:config()) -> boolean()

checking the service authorization rules see watts_service_authz

is_enabled/1

is_enabled(ServiceId::binary()) -> boolean()

return if a service, given by the id, is enabled

is_secure_plugin_or_allowed/3 *

is_secure_plugin_or_allowed(X1::map(), X2::boolean(), Id::binary()) -> boolean()

check and log if a plugin supports stdin of if insecure plugins are allowed

is_valid_key/1 *

is_valid_key(Key::binary()) -> boolean()

return if a key is valid.

is_valid_key_char/1 *

is_valid_key_char(X1::integer()) -> boolean()

ceck if the character is valid within a key

list_skipped_parameter_and_delete_config/1 *

list_skipped_parameter_and_delete_config(Info::info()) -> info()

list the skipped parameter from the config and delete the raw config

maybe_warn_default/4 *

maybe_warn_default(X1::boolean(), Id::binary(), Name::binary(), Default::any()) -> ok

print a warning if using the default value from the plugin

maybe_warning_about_using_env/1 *

maybe_warning_about_using_env(X1::info()) -> ok

write a warning about not supporting environment anymore

start_runner_queue_if_needed/1 *

start_runner_queue_if_needed(X1::info()) -> {ok, atom()}

start the runnuner queue if needed.

to_atom/1 *

to_atom(Type::binary()) -> atom()

convert the binary to an existing atom or unknown.

to_conf_type/1 *

to_conf_type(Type::binary()) -> atom()

convert the type to a configuration type.

to_request_type/1 *

to_request_type(Type::binary()) -> atom()

convert the type to a request type.

to_valid_type/2 *

to_valid_type(Type::binary(), ValidTypes::[atom()]) -> atom()

try to convert the type to an atom and find it in the given list.

update_conf_parameter/5 *

update_conf_parameter(Name::binary(), Valid::boolean(), Default::{ok, any()} | {error, any()}, Type::atom(), Info::info()) -> {boolean(), info()}

check the conversion results and update the config if all okay.

update_limits_for_user/2 *

update_limits_for_user(UserInfo::watts_userinfo:info(), ServiceList::[info()]) -> {ok, [limited_info()]}

update the list for the user with limits and permissions

update_params/1

update_params(Id::binary()) -> ok | {error, not_found}

update the parameter of a service by running the plugin

update_service/2 *

update_service(Id::binary(), NewInfo::info()) -> ok | {error, Reason::atom()}

update the config of the service in the ets.

validate_call_parameter/9 *

validate_call_parameter(Key::binary(), X2::boolean(), X3::boolean(), Name::binary(), Desc::binary(), Type::atom(), Param::map(), Id::binary(), ParamSet::parameter_set()) -> {boolean(), parameter_set()}

validate one parameter for a call (part of a parameter set)

validate_call_parameter_set/2 *

validate_call_parameter_set(Set::parameter_set(), Info::info()) -> {boolean(), info()}

validate a single parameter set. a singe set is a list of maps, each containing the specificaiton of one parameter

validate_call_parameter_set/5 *

validate_call_parameter_set(T::parameter_set(), Info::info(), ParamSet::parameter_set(), Keys::[binary()], Result::boolean()) -> {boolean(), info()}

validate a call parameter set and keep track of the result. also update at the end the params list within the info with each new set.

validate_call_parameter_sets/2 *

validate_call_parameter_sets(Params::[parameter_set()], Info::info()) -> {boolean(), info()}

validate the call parameter sets

validate_call_parameter_sets/3 *

validate_call_parameter_sets(T::[parameter_set()], Info::info(), Result::boolean()) -> {boolean(), info()}

validate the call parameter sets and keep track of the result Itterate through each parameter set, validating it.

validate_conf_parameter/2 *

validate_conf_parameter(Params::conf_parameters(), Info::info()) -> {boolean(), info()}

validate configuration parameter

validate_conf_parameter/3 *

validate_conf_parameter(T::conf_parameters(), Info::info(), Result::boolean()) -> {boolean(), info()}

validate the configuration parameter and keep track of the result.

validate_params_and_update_db/3 *

validate_params_and_update_db(Id::binary(), Info::info(), X3::{ok, map()} | any()) -> ok | {error, not_found}

validate the parameter returned from the plugin and maybe update the ets


Generated by EDoc