Class: Eco::API::Session::Config
- Inherits:
-
Hash
- Object
- Hash
- Eco::API::Session::Config
show all
- 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/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
Defined Under Namespace
Classes: Api, Apis, BaseConfig, Files, Logger, Mailer, People, PostLaunch, S3Storage, SFTP, Workflow
Instance Attribute Summary collapse
Config instance pure methods
collapse
Additional resources
collapse
Organization related shortcuts
collapse
People shortcuts
collapse
Session workflow and batch job launces
collapse
Instance Method Summary
collapse
Methods inherited from Hash
#deep_merge, #deep_merge!
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
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
Set the active api by name
106
107
108
109
|
# File 'lib/eco/api/session/config.rb', line 106
def active_api(name)
apis.active_name = name
self
end
|
#active_enviro ⇒ Object
112
113
114
|
# File 'lib/eco/api/session/config.rb', line 112
def active_enviro
apis.active_root_name
end
|
Returns this configuration.
98
99
100
101
|
# File 'lib/eco/api/session/config.rb', line 98
def add_api(name, **kargs)
apis.add(name, **kargs)
self
end
|
#api(logger = ::Logger.new(IO::NULL), version: nil) ⇒ Object
117
118
119
|
# File 'lib/eco/api/session/config.rb', line 117
def api(logger = ::Logger.new(IO::NULL), version: nil)
apis.api(logger, version: version)
end
|
87
88
89
|
# File 'lib/eco/api/session/config.rb', line 87
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.
92
93
94
|
# File 'lib/eco/api/session/config.rb', line 92
def apis?
apis.apis?
end
|
337
338
339
340
341
342
343
344
345
|
# File 'lib/eco/api/session/config.rb', line 337
def batch_policies
@batch_policies = self["batch_policies"] ||= Eco::API::Session::Batch::Policies.new("batch_policy")
if block_given?
yield(@batch_policies)
self
else
@batch_policies
end
end
|
#clone(name) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/eco/api/session/config.rb', line 15
def clone(name)
keys.each_with_object(self.class.new(name)) do |key, cnf|
begin
cnf[key] = self[key].clone(config: cnf)
rescue ArgumentError
cnf[key] = self[key].clone
end
end
end
|
#default_schema=(name) ⇒ Object
Set the default schema this api
org configuration should work on.
285
286
287
|
# File 'lib/eco/api/session/config.rb', line 285
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.
260
261
262
|
# File 'lib/eco/api/session/config.rb', line 260
def default_usergroup=(value)
people.default_usergroup = value
end
|
#discarded_people_file=(value) ⇒ Object
Specify the file that holds the csv
with people to be excluded from API
updates.
265
266
267
|
# File 'lib/eco/api/session/config.rb', line 265
def discarded_people_file=(value)
people.discarded_file = value
end
|
#dry_run! ⇒ Object
Deprecated. old helper to fix the dry-run mode
Note:
this is now done via options[:dry_run]
, parsed as an option
138
139
140
|
# File 'lib/eco/api/session/config.rb', line 138
def dry_run!
self["dry-run"] = true
end
|
#dry_run? ⇒ Boolean
Deprecated. old helper to check if we are in dry-run mode
Note:
this is now done via options[:dry_run]
, which is parsed as an option
144
145
146
|
# File 'lib/eco/api/session/config.rb', line 144
def dry_run?
self["dry-run"]
end
|
348
349
350
351
352
353
354
355
356
|
# File 'lib/eco/api/session/config.rb', line 348
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_timestamp_pattern=(pattern) ⇒ Object
177
178
179
|
# File 'lib/eco/api/session/config.rb', line 177
def file_timestamp_pattern=(pattern)
files.timestamp_pattern = pattern
end
|
152
153
154
|
# File 'lib/eco/api/session/config.rb', line 152
def files
self["files"] ||= Eco::API::Session::Config::Files.new(config: self)
end
|
#location_codes ⇒ Object
205
206
207
|
# File 'lib/eco/api/session/config.rb', line 205
def location_codes
org["location_codes"]
end
|
#location_codes=(file) ⇒ Object
201
202
203
|
# File 'lib/eco/api/session/config.rb', line 201
def location_codes=(file)
org["location_codes"] = file
end
|
#locations_mapper ⇒ Object
209
210
211
212
213
|
# File 'lib/eco/api/session/config.rb', line 209
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
74
75
76
|
# File 'lib/eco/api/session/config.rb', line 74
def log_connection=(value)
logger.log_connection = value
end
|
#log_console_level=(value) ⇒ Object
58
59
60
|
# File 'lib/eco/api/session/config.rb', line 58
def log_console_level=(value)
logger.console_level= value
end
|
#log_file=(file) ⇒ Object
66
67
68
|
# File 'lib/eco/api/session/config.rb', line 66
def log_file=(file)
logger.file = file
end
|
#log_file_level=(value) ⇒ Object
62
63
64
|
# File 'lib/eco/api/session/config.rb', line 62
def log_file_level=(value)
logger.file_level = value
end
|
54
55
56
|
# File 'lib/eco/api/session/config.rb', line 54
def logger
self["logger"] ||= Eco::API::Session::Config::Logger.new(config: self)
end
|
244
245
246
247
248
|
# File 'lib/eco/api/session/config.rb', line 244
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
|
46
47
48
|
# File 'lib/eco/api/session/config.rb', line 46
def mailer
self["mailer"] ||= Eco::API::Session::Config::Mailer.new(config: self)
end
|
#org ⇒ Object
197
198
199
|
# File 'lib/eco/api/session/config.rb', line 197
def org
self["org"]
end
|
255
256
257
|
# File 'lib/eco/api/session/config.rb', line 255
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.
270
271
272
|
# File 'lib/eco/api/session/config.rb', line 270
def people_cache=(file)
people.cache = file
end
|
#person_fields_mapper=(file) ⇒ Object
Specify the .json
file name with the mappings [DataInputColumnName
, internal-name
].
280
281
282
|
# File 'lib/eco/api/session/config.rb', line 280
def person_fields_mapper=(file)
people.fields_mapper = file
end
|
Returns parser/serializer for the defined format
.
302
303
304
|
# File 'lib/eco/api/session/config.rb', line 302
def person_parser(format: :csv, &block)
people.parser(format: format, &block)
end
|
326
327
328
329
330
331
332
333
334
|
# File 'lib/eco/api/session/config.rb', line 326
def policies
@policies = self["policies"] ||= Eco::API::Policies.new
if block_given?
yield(@policies)
self
else
@policies
end
end
|
230
231
232
233
234
|
# File 'lib/eco/api/session/config.rb', line 230
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
|
321
322
323
|
# File 'lib/eco/api/session/config.rb', line 321
def post_launch
self["post_launch"] ||= Eco::API::Session::Config::PostLaunch.new(config: self)
end
|
#presets_custom=(file) ⇒ Object
Specify the file with the account custom abilities presets
290
291
292
|
# File 'lib/eco/api/session/config.rb', line 290
def presets_custom=(file)
people.presets_custom = file
end
|
#presets_map=(file) ⇒ Object
Specify the file with the usergroup to custom presets mapping
295
296
297
|
# File 'lib/eco/api/session/config.rb', line 295
def presets_map=(file)
people.presets_map = file
end
|
#reopen {|_self| ... } ⇒ Object
25
26
27
|
# File 'lib/eco/api/session/config.rb', line 25
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.
275
276
277
|
# File 'lib/eco/api/session/config.rb', line 275
def requests_backup_folder=(folder)
people.requests_folder = folder
end
|
#require(file = nil, match: nil) ⇒ Object
185
186
187
188
189
190
191
192
193
|
# File 'lib/eco/api/session/config.rb', line 185
def require(file = nil, match: nil)
if match
file_manager.dir.dir_files(pattern: match).each do |file|
require_relative File.expand_path(file)
end
else
require_relative "#{File.expand_path(file_manager.dir.file(file))}"
end
end
|
#run_mode=(mode) ⇒ Object
Sets the mode
of the active api
124
125
126
|
# File 'lib/eco/api/session/config.rb', line 124
def run_mode=(mode)
apis.active_api.mode = mode
end
|
#run_mode_local? ⇒ Boolean
128
129
130
|
# File 'lib/eco/api/session/config.rb', line 128
def run_mode_local?
apis.active_api.local?
end
|
#run_mode_remote? ⇒ Boolean
132
133
134
|
# File 'lib/eco/api/session/config.rb', line 132
def run_mode_remote?
apis.active_api.remote?
end
|
Helper to upload files and folders to S3
.
#schemas ⇒ Object
Returns pEco::API::Organization::PersonSchemas.
237
238
239
240
241
|
# File 'lib/eco/api/session/config.rb', line 237
def schemas
return @schemas if instance_variable_defined?(:@schemas)
schs = api&.person_schemas.to_a
@schemas = Eco::API::Organization::PersonSchemas.new(schs)
end
|
Returns the session
linked to this config
.
82
83
84
|
# File 'lib/eco/api/session/config.rb', line 82
def session
@session ||= Eco::API::Session.new(self)
end
|
Helper to manage SFTP
files and folders.
34
35
36
|
# File 'lib/eco/api/session/config.rb', line 34
def sftp
self["sftp"] ||= Eco::API::Session::Config::SFTP.new(config: self)
end
|
220
221
222
223
224
225
226
227
|
# File 'lib/eco/api/session/config.rb', line 220
def tagtree(enviro: nil)
return @tagtree if instance_variable_defined?(:@tagtree) && @tagtree.enviro == enviro
if tree_file = org["tagtree"]
tree = []
tree = file_manager.load_json(tree_file) unless !tree_file
@tagtree = Eco::API::Organization::TagTree.new(tree, enviro: enviro)
end
end
|
#tagtree=(file) ⇒ Object
215
216
217
|
# File 'lib/eco/api/session/config.rb', line 215
def tagtree=(file)
org["tagtree"] = file
end
|
#timestamp_console=(value) ⇒ Object
70
71
72
|
# File 'lib/eco/api/session/config.rb', line 70
def timestamp_console=(value)
logger.timestamp_console = value
end
|
310
311
312
313
314
315
316
317
318
|
# File 'lib/eco/api/session/config.rb', line 310
def usecases
@usecases = self["usecases"] ||= Eco::API::UseCases.new
if block_given?
yield(@usecases)
self
else
@usecases
end
end
|
359
360
361
362
363
364
|
# File 'lib/eco/api/session/config.rb', line 359
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/eco/api/session/config.rb', line 161
def working_directory(mode: nil)
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
157
158
159
|
# File 'lib/eco/api/session/config.rb', line 157
def working_directory=(path)
files.working_directory = path
end
|