Class: Eco::API::Session::Config
- Defined in:
- lib/eco/api/session/config.rb,
lib/eco/api/session/config/api.rb,
lib/eco/api/session/config/apis.rb,
lib/eco/api/session/config/sftp.rb,
lib/eco/api/session/config/files.rb,
lib/eco/api/session/config/logger.rb,
lib/eco/api/session/config/mailer.rb,
lib/eco/api/session/config/people.rb,
lib/eco/api/session/config/tagtree.rb,
lib/eco/api/session/config/workflow.rb,
lib/eco/api/session/config/s3_storage.rb,
lib/eco/api/session/config/base_config.rb,
lib/eco/api/session/config/post_launch.rb,
lib/eco/api/session/config/apis/one_off.rb,
lib/eco/api/session/config/apis/service_up.rb,
lib/eco/api/session/config/apis/enviro_spaces.rb,
lib/eco/api/session/config/apis/space_helpers.rb
Defined Under Namespace
Classes: Api, ApiDefChain, Apis, BaseConfig, Files, Logger, Mailer, People, PostLaunch, S3Storage, SFTP, TagTree, Workflow
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Config instance pure methods collapse
Additional resources collapse
-
#mailer ⇒ Eco::API::Session::Config::Mailer
Helper to send emails.
-
#s3storage ⇒ Eco::API::Session::Config::S3Storage
Helper to upload files and folders to
S3
. -
#sftp ⇒ Eco::API::Session::Config::SFTP
Helper to manage
SFTP
files and folders. -
#tagtree_config ⇒ Eco::API::Session::Config::TagTree
Helper scope reporting structures.
Logger collapse
- #log_connection=(value) ⇒ Object
- #log_console_level=(value) ⇒ Object
- #log_file=(file) ⇒ Object
- #log_file_level=(value) ⇒ Object
- #logger ⇒ Eco::API::Session::Config::Logger
- #timestamp_console=(value) ⇒ Object
Session and API collapse
-
#active_api(name, space: nil) ⇒ Eco::API::Session::Config
Set the active api by
name
. - #active_enviro ⇒ Object
- #active_enviro_space ⇒ Object
-
#add_api(name, **kargs) ⇒ Eco::API::Session::Config
This configuration.
-
#api(logger = ::Logger.new(IO::NULL), version: nil) ⇒ Eco::API::Session::Config::Api
The currently active api.
- #apis ⇒ Eco::API::Session::Config::Apis
-
#apis? ⇒ Boolean
true
if there is any api configuration defined,false
otherwise. -
#dry_run! ⇒ Object
deprecated
Deprecated.
old helper to fix the dry-run mode
-
#dry_run? ⇒ Boolean
deprecated
Deprecated.
old helper to check if we are in dry-run mode
-
#run_mode=(mode) ⇒ Object
Sets the
mode
of the active api. - #run_mode_local? ⇒ Boolean
- #run_mode_remote? ⇒ Boolean
-
#session ⇒ Eco::API::Session
The
session
linked to thisconfig
.
Files collapse
- #file_manager ⇒ Object
- #file_timestamp_pattern=(pattern) ⇒ Object
- #files ⇒ Eco::API::Session::Config::Files
- #require(file = nil, match: nil) ⇒ Object
- #working_directory(mode: nil) ⇒ Object
-
#working_directory=(path) ⇒ Object
Defines in the base folder from where files are expected to be found when relative paths are used.
Organization related shortcuts collapse
-
#live_tree(id: nil, **kargs, &block) ⇒ Eco::API::Organization::TagTree
It obtains the first of the live tagtree in the org.
-
#live_trees(**kargs, &block) ⇒ Array<Eco::API::Organization::TagTree>
Retrieves all the location structures of the organisation.
- #location_codes ⇒ Object
- #location_codes=(file) ⇒ Object
- #locations_mapper ⇒ Object
- #login_providers ⇒ Eco::API::Organization::LoginProviders
-
#node_classifications(active: true) ⇒ Eco::API::Organization::NodeClassifications
The location node classifications of the organization.
- #org ⇒ Object
- #policy_groups ⇒ Eco::API::Organization::PolicyGroups
-
#schemas ⇒ Object
PEco::API::Organization::PersonSchemas.
-
#tagtree(include_archived: false, recache: false, raise_on_missing: true) ⇒ Eco::API::Organization::TagTree
It uses the
tagtree.json
file and in its absence, ifgraphql
enabled, the largestlife_tagtree
. - #tagtree=(file) ⇒ Object
- #tagtree_id=(value) ⇒ Object
People shortcuts collapse
-
#default_login_method=(name) ⇒ Object
Set the default login method that users should acquire.
-
#default_schema=(name) ⇒ Object
Set the default schema this
api
org configuration should work on. -
#default_usergroup=(value) ⇒ Object
Define the default usergroup that should be given to people with no usergroups.
-
#discarded_people_file=(value) ⇒ Object
Specify the file that holds the
csv
with people to be excluded fromAPI
updates. - #people ⇒ Eco::API::Session::Config::People
-
#people_cache=(file) ⇒ Object
Set the base folder/name.ext name of the fieles where people will be cached.
-
#person_fields_mapper=(file) ⇒ Object
Specify the
.json
file name with the mappings [DataInputColumnName
,internal-name
]. -
#person_parser(format: :csv, &block) ⇒ Eco::API::Common::People::PersonParser
Parser/serializer for the defined
format
. -
#requests_backup_folder=(folder) ⇒ Object
Set the base folder name where requests launched to the server will be saved for future reference.
Session workflow and batch job launces collapse
- #batch_policies(&block) ⇒ Eco::API::Session::Batch::Policies
-
#delay_between_job_groups(seconds = nil) ⇒ nil, Interger
Seconds between job groups.
-
#delay_between_jobs(seconds = nil) ⇒ nil, Interger
Seconds between jobs.
- #error_handlers ⇒ Eco::API::Error::Handlers
- #policies ⇒ Eco::API::Policies
- #post_launch ⇒ Eco::API::Session::Config::PostLaunch
- #usecases ⇒ Eco::API::UseCases
- #workflow ⇒ Eco::API::Session::Config::Workflow
Instance Method Summary collapse
-
#initialize(name = :default) ⇒ Config
constructor
A new instance of Config.
Methods inherited from Hash
Constructor Details
#initialize(name = :default) ⇒ Config
Returns a new instance of Config.
7 8 9 10 11 |
# File 'lib/eco/api/session/config.rb', line 7 def initialize(name = :default) super(nil) @name = name self["org"] = {} end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/eco/api/session/config.rb', line 5 def name @name end |
Instance Method Details
#active_api(name, space: nil) ⇒ Eco::API::Session::Config
Set the active api by name
123 124 125 126 |
# File 'lib/eco/api/session/config.rb', line 123 def active_api(name, space: nil) apis.set_active_name(name, space: space) self end |
#active_enviro ⇒ Object
129 130 131 |
# File 'lib/eco/api/session/config.rb', line 129 def active_enviro apis.active_root_name end |
#active_enviro_space ⇒ Object
134 135 136 |
# File 'lib/eco/api/session/config.rb', line 134 def active_enviro_space apis.active_space end |
#add_api(name, **kargs) ⇒ Eco::API::Session::Config
Returns this configuration.
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/eco/api/session/config.rb', line 109 def add_api(name, **kargs) apis.add(name, **kargs) if block_given? params = kargs.merge({space: :sub_other}) yield(ApiDefChain.new(self, name, params)) end ApiDefChain.new(self, name, {space: :other}) end |
#api(logger = ::Logger.new(IO::NULL), version: nil) ⇒ Eco::API::Session::Config::Api
Returns the currently active api.
140 141 142 |
# File 'lib/eco/api/session/config.rb', line 140 def api(logger = ::Logger.new(IO::NULL), version: nil) apis.api(logger, version: version) end |
#apis ⇒ Eco::API::Session::Config::Apis
91 92 93 |
# File 'lib/eco/api/session/config.rb', line 91 def apis self["apis"] ||= Eco::API::Session::Config::Apis.new(config: self) end |
#apis? ⇒ Boolean
Returns true
if there is any api configuration defined, false
otherwise.
96 97 98 |
# File 'lib/eco/api/session/config.rb', line 96 def apis? apis.apis? end |
#batch_policies(&block) ⇒ Eco::API::Session::Batch::Policies
396 397 398 399 400 401 402 403 404 |
# File 'lib/eco/api/session/config.rb', line 396 def batch_policies(&block) @batch_policies = self["batch_policies"] ||= Eco::API::Session::Batch::Policies.new("batch_policy") if block_given? @batch_policies.evaluate(@batch_policies, &block) self else @batch_policies end end |
#clone(name) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/eco/api/session/config.rb', line 15 def clone(name) keys.each_with_object(self.class.new(name)) do |key, cnf| cnf[key] = self[key].clone(config: cnf) rescue ArgumentError cnf[key] = self[key].clone end end |
#default_login_method=(name) ⇒ Object
Set the default login method that users should acquire.
353 354 355 |
# File 'lib/eco/api/session/config.rb', line 353 def default_login_method=(name) people.default_login_method = name end |
#default_schema=(name) ⇒ Object
Set the default schema this api
org configuration should work on.
348 349 350 |
# File 'lib/eco/api/session/config.rb', line 348 def default_schema=(name) people.default_schema = name end |
#default_usergroup=(value) ⇒ Object
Define the default usergroup that should be given to people with no usergroups.
323 324 325 |
# File 'lib/eco/api/session/config.rb', line 323 def default_usergroup=(value) people.default_usergroup = value end |
#delay_between_job_groups(seconds = nil) ⇒ nil, Interger
Returns seconds between job groups.
432 433 434 435 |
# File 'lib/eco/api/session/config.rb', line 432 def delay_between_job_groups(seconds = nil) self["delay_between_job_groups"] = seconds if seconds self["delay_between_job_groups"] end |
#delay_between_jobs(seconds = nil) ⇒ nil, Interger
Returns seconds between jobs.
426 427 428 429 |
# File 'lib/eco/api/session/config.rb', line 426 def delay_between_jobs(seconds = nil) self["delay_between_jobs"] = seconds if seconds self["delay_between_jobs"] end |
#discarded_people_file=(value) ⇒ Object
Specify the file that holds the csv
with people to be excluded from API
updates.
328 329 330 |
# File 'lib/eco/api/session/config.rb', line 328 def discarded_people_file=(value) people.discarded_file = value end |
#dry_run! ⇒ Object
old helper to fix the dry-run mode
this is now done via options[:dry_run]
, parsed as an option
161 162 163 |
# File 'lib/eco/api/session/config.rb', line 161 def dry_run! self["dry-run"] = true end |
#dry_run? ⇒ Boolean
old helper to check if we are in dry-run mode
this is now done via options[:dry_run]
, which is parsed as an option
167 168 169 |
# File 'lib/eco/api/session/config.rb', line 167 def dry_run? self["dry-run"] end |
#error_handlers ⇒ Eco::API::Error::Handlers
407 408 409 410 411 412 413 414 415 |
# File 'lib/eco/api/session/config.rb', line 407 def error_handlers @error_handlers = self["error_handlers"] ||= Eco::API::Error::Handlers.new if block_given? yield(@error_handlers) self else @error_handlers end end |
#file_manager ⇒ Object
206 207 208 |
# File 'lib/eco/api/session/config.rb', line 206 def file_manager Eco::API::Common::Session::FileManager.new(self) end |
#file_timestamp_pattern=(pattern) ⇒ Object
202 203 204 |
# File 'lib/eco/api/session/config.rb', line 202 def (pattern) files. = pattern end |
#files ⇒ Eco::API::Session::Config::Files
175 176 177 |
# File 'lib/eco/api/session/config.rb', line 175 def files self["files"] ||= Eco::API::Session::Config::Files.new(config: self) end |
#live_tree(id: nil, **kargs, &block) ⇒ Eco::API::Organization::TagTree
it requires graphql connection configuration parameters
It obtains the first of the live tagtree in the org
281 282 283 |
# File 'lib/eco/api/session/config.rb', line 281 def live_tree(id: nil, **kargs, &block) tagtree_config.live_tree(id: id, **kargs, &block) end |
#live_trees(**kargs, &block) ⇒ Array<Eco::API::Organization::TagTree>
Retrieves all the location structures of the organisation
288 289 290 |
# File 'lib/eco/api/session/config.rb', line 288 def live_trees(**kargs, &block) tagtree_config.live_trees(**kargs, &block) end |
#location_codes ⇒ Object
235 236 237 |
# File 'lib/eco/api/session/config.rb', line 235 def location_codes org["location_codes"] end |
#location_codes=(file) ⇒ Object
231 232 233 |
# File 'lib/eco/api/session/config.rb', line 231 def location_codes=(file) org["location_codes"] = file end |
#locations_mapper ⇒ Object
239 240 241 242 243 |
# File 'lib/eco/api/session/config.rb', line 239 def locations_mapper return @locations_mapper if instance_variable_defined?(:@locations_mapper) file = file_manager.newest(location_codes) @locations_mapper = Eco::Data::Mapper.new(file_manager.load_json(file), internal: :first) end |
#log_connection=(value) ⇒ Object
78 79 80 |
# File 'lib/eco/api/session/config.rb', line 78 def log_connection=(value) logger.log_connection = value end |
#log_console_level=(value) ⇒ Object
62 63 64 |
# File 'lib/eco/api/session/config.rb', line 62 def log_console_level=(value) logger.console_level= value end |
#log_file=(file) ⇒ Object
70 71 72 |
# File 'lib/eco/api/session/config.rb', line 70 def log_file=(file) logger.file = file end |
#log_file_level=(value) ⇒ Object
66 67 68 |
# File 'lib/eco/api/session/config.rb', line 66 def log_file_level=(value) logger.file_level = value end |
#logger ⇒ Eco::API::Session::Config::Logger
58 59 60 |
# File 'lib/eco/api/session/config.rb', line 58 def logger self["logger"] ||= Eco::API::Session::Config::Logger.new(config: self) end |
#login_providers ⇒ Eco::API::Organization::LoginProviders
307 308 309 310 311 |
# File 'lib/eco/api/session/config.rb', line 307 def login_providers return @login_providers if instance_variable_defined?(:@login_providers) provs = api&.login_providers.to_a @login_providers = Eco::API::Organization::LoginProviders.new(provs) end |
#mailer ⇒ Eco::API::Session::Config::Mailer
Helper to send emails.
44 45 46 |
# File 'lib/eco/api/session/config.rb', line 44 def mailer self["mailer"] ||= Eco::API::Session::Config::Mailer.new(config: self) end |
#node_classifications(active: true) ⇒ Eco::API::Organization::NodeClassifications
The location node classifications of the organization
255 256 257 |
# File 'lib/eco/api/session/config.rb', line 255 def node_classifications(active: true) tagtree_config.node_classifications(active: active) end |
#org ⇒ Object
227 228 229 |
# File 'lib/eco/api/session/config.rb', line 227 def org self["org"] end |
#people ⇒ Eco::API::Session::Config::People
318 319 320 |
# File 'lib/eco/api/session/config.rb', line 318 def people self["people"] ||= Eco::API::Session::Config::People.new(config: self) end |
#people_cache=(file) ⇒ Object
Set the base folder/name.ext name of the fieles where people will be cached.
333 334 335 |
# File 'lib/eco/api/session/config.rb', line 333 def people_cache=(file) people.cache = file end |
#person_fields_mapper=(file) ⇒ Object
Specify the .json
file name with the mappings [DataInputColumnName
, internal-name
].
343 344 345 |
# File 'lib/eco/api/session/config.rb', line 343 def person_fields_mapper=(file) people.fields_mapper = file end |
#person_parser(format: :csv, &block) ⇒ Eco::API::Common::People::PersonParser
Returns parser/serializer for the defined format
.
360 361 362 |
# File 'lib/eco/api/session/config.rb', line 360 def person_parser(format: :csv, &block) people.parser(format: format, &block) end |
#policies ⇒ Eco::API::Policies
384 385 386 387 388 389 390 391 392 393 |
# File 'lib/eco/api/session/config.rb', line 384 def policies @policies = self["policies"] ||= Eco::API::Policies.new if block_given? yield(@policies) self else @policies end end |
#policy_groups ⇒ Eco::API::Organization::PolicyGroups
293 294 295 296 297 |
# File 'lib/eco/api/session/config.rb', line 293 def policy_groups return @policy_groups if instance_variable_defined?(:@policy_groups) pgs = api&.policy_groups.to_a @policy_groups = Eco::API::Organization::PolicyGroups.new(pgs) end |
#post_launch ⇒ Eco::API::Session::Config::PostLaunch
379 380 381 |
# File 'lib/eco/api/session/config.rb', line 379 def post_launch self["post_launch"] ||= Eco::API::Session::Config::PostLaunch.new(config: self) end |
#reopen {|_self| ... } ⇒ Object
23 24 25 |
# File 'lib/eco/api/session/config.rb', line 23 def reopen yield(self) end |
#requests_backup_folder=(folder) ⇒ Object
Set the base folder name where requests launched to the server will be saved for future reference.
338 339 340 |
# File 'lib/eco/api/session/config.rb', line 338 def requests_backup_folder=(folder) people.requests_folder = folder end |
#require(file = nil, match: nil) ⇒ Object
210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/eco/api/session/config.rb', line 210 def require(file = nil, match: nil) if match file_manager.dir.dir_files(pattern: match).each do |file| require_relative File.(file) end else target = File.(file_manager.dir.file(file)) require_relative target end rescue LoadError => err raise unless apis.active_api.one_off? pp err.to_s end |
#run_mode=(mode) ⇒ Object
Sets the mode
of the active api
147 148 149 |
# File 'lib/eco/api/session/config.rb', line 147 def run_mode=(mode) apis.active_api.mode = mode end |
#run_mode_local? ⇒ Boolean
151 152 153 |
# File 'lib/eco/api/session/config.rb', line 151 def run_mode_local? apis.active_api.local? end |
#run_mode_remote? ⇒ Boolean
155 156 157 |
# File 'lib/eco/api/session/config.rb', line 155 def run_mode_remote? apis.active_api.remote? end |
#s3storage ⇒ Eco::API::Session::Config::S3Storage
Helper to upload files and folders to S3
.
38 39 40 |
# File 'lib/eco/api/session/config.rb', line 38 def s3storage self["s3_storage"] ||= Eco::API::Session::Config::S3Storage.new(config: self) end |
#schemas ⇒ Object
Returns pEco::API::Organization::PersonSchemas.
300 301 302 303 304 |
# File 'lib/eco/api/session/config.rb', line 300 def schemas return @schemas if instance_variable_defined?(:@schemas) schs = api&.person_schemas.to_a @schemas = Eco::API::Organization::PersonSchemas.new(schs) end |
#session ⇒ Eco::API::Session
Returns the session
linked to this config
.
86 87 88 |
# File 'lib/eco/api/session/config.rb', line 86 def session @session ||= Eco::API::Session.new(self) end |
#sftp ⇒ Eco::API::Session::Config::SFTP
Helper to manage SFTP
files and folders.
32 33 34 |
# File 'lib/eco/api/session/config.rb', line 32 def sftp self["sftp"] ||= Eco::API::Session::Config::SFTP.new(config: self) end |
#tagtree(include_archived: false, recache: false, raise_on_missing: true) ⇒ Eco::API::Organization::TagTree
it does NOT include archived nodes by default.
- This is for legacy (most usecases don't)
It uses the tagtree.json
file and in its absence, if graphql
enabled, the largest life_tagtree
265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/eco/api/session/config.rb', line 265 def tagtree( include_archived: false, recache: false, raise_on_missing: true ) kargs = { recache: recache, include_archived: include_archived, raise_on_missing: raise_on_missing } @tagtree ||= tagtree_config.scope_tree(**kargs) end |
#tagtree=(file) ⇒ Object
245 246 247 |
# File 'lib/eco/api/session/config.rb', line 245 def tagtree=(file) tagtree_config.file = file end |
#tagtree_config ⇒ Eco::API::Session::Config::TagTree
Helper scope reporting structures.
50 51 52 |
# File 'lib/eco/api/session/config.rb', line 50 def tagtree_config org["tagtree_config"] ||= Eco::API::Session::Config::TagTree.new(config: self) end |
#tagtree_id=(value) ⇒ Object
249 250 251 |
# File 'lib/eco/api/session/config.rb', line 249 def tagtree_id=(value) tagtree_config.structure_id = value end |
#timestamp_console=(value) ⇒ Object
74 75 76 |
# File 'lib/eco/api/session/config.rb', line 74 def (value) logger. = value end |
#usecases ⇒ Eco::API::UseCases
368 369 370 371 372 373 374 375 376 |
# File 'lib/eco/api/session/config.rb', line 368 def usecases @usecases = self["usecases"] ||= Eco::API::UseCases.new if block_given? yield(@usecases) self else @usecases end end |
#workflow ⇒ Eco::API::Session::Config::Workflow
418 419 420 421 422 423 |
# File 'lib/eco/api/session/config.rb', line 418 def workflow @workflow = self["workflow"] ||= Eco::API::Session::Config::Workflow.new(config: self) @workflow.tap do |wf| yield(wf) if block_given? end end |
#working_directory(mode: nil) ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/eco/api/session/config.rb', line 184 def working_directory(mode: nil) return files.working_directory if apis.active_api&.one_off? unless mode wd = files.working_directory return wd unless wd.to_s.strip.empty? end mode ||= :active_api if mode == :active_api apis.active_root_name elsif mode == :raw_api_name apis.active_name else files.working_directory end end |
#working_directory=(path) ⇒ Object
Defines in the base folder from where files are expected to be found when relative paths are used
180 181 182 |
# File 'lib/eco/api/session/config.rb', line 180 def working_directory=(path) files.working_directory = path end |