eco-helpers 2.0.15 → 2.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +109 -3
- data/eco-helpers.gemspec +11 -5
- data/lib/eco-helpers.rb +2 -0
- data/lib/eco/api/common/base_loader.rb +14 -0
- data/lib/eco/api/common/loaders/parser.rb +1 -0
- data/lib/eco/api/common/people/default_parsers/date_parser.rb +11 -1
- data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +1 -1
- data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +11 -11
- data/lib/eco/api/common/people/entries.rb +1 -0
- data/lib/eco/api/common/people/entry_factory.rb +74 -23
- data/lib/eco/api/common/people/person_entry.rb +5 -2
- data/lib/eco/api/common/people/supervisor_helpers.rb +27 -0
- data/lib/eco/api/common/session.rb +1 -0
- data/lib/eco/api/common/session/base_session.rb +2 -0
- data/lib/eco/api/common/session/file_manager.rb +2 -2
- data/lib/eco/api/common/session/helpers.rb +30 -0
- data/lib/eco/api/common/session/helpers/prompt_user.rb +34 -0
- data/lib/eco/api/common/session/mailer.rb +0 -1
- data/lib/eco/api/common/session/s3_uploader.rb +0 -1
- data/lib/eco/api/common/session/sftp.rb +0 -1
- data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +1 -1
- data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +7 -4
- data/lib/eco/api/common/version_patches/exception.rb +11 -4
- data/lib/eco/api/microcases.rb +3 -1
- data/lib/eco/api/microcases/append_usergroups.rb +0 -1
- data/lib/eco/api/microcases/people_cache.rb +2 -2
- data/lib/eco/api/microcases/people_load.rb +2 -2
- data/lib/eco/api/microcases/people_refresh.rb +2 -2
- data/lib/eco/api/microcases/people_search.rb +6 -6
- data/lib/eco/api/microcases/preserve_default_tag.rb +23 -0
- data/lib/eco/api/microcases/preserve_filter_tags.rb +28 -0
- data/lib/eco/api/microcases/preserve_policy_groups.rb +30 -0
- data/lib/eco/api/microcases/set_account.rb +0 -1
- data/lib/eco/api/microcases/with_each.rb +67 -6
- data/lib/eco/api/microcases/with_each_present.rb +4 -2
- data/lib/eco/api/microcases/with_each_starter.rb +4 -2
- data/lib/eco/api/organization.rb +1 -0
- data/lib/eco/api/organization/people.rb +98 -22
- data/lib/eco/api/organization/people_similarity.rb +272 -0
- data/lib/eco/api/organization/person_schemas.rb +5 -1
- data/lib/eco/api/organization/policy_groups.rb +5 -1
- data/lib/eco/api/organization/presets_factory.rb +40 -80
- data/lib/eco/api/organization/presets_integrity.json +6 -0
- data/lib/eco/api/organization/presets_values.json +5 -4
- data/lib/eco/api/organization/tag_tree.rb +33 -0
- data/lib/eco/api/policies/default_policies/99_user_access_policy.rb +0 -30
- data/lib/eco/api/session.rb +10 -24
- data/lib/eco/api/session/batch.rb +25 -7
- data/lib/eco/api/session/config.rb +16 -15
- data/lib/eco/api/session/config/api.rb +4 -0
- data/lib/eco/api/session/config/apis.rb +80 -0
- data/lib/eco/api/session/config/files.rb +7 -0
- data/lib/eco/api/session/config/people.rb +3 -19
- data/lib/eco/api/usecases/default_cases.rb +4 -1
- data/lib/eco/api/usecases/default_cases/abstract_policygroup_abilities_case.rb +161 -0
- data/lib/eco/api/usecases/default_cases/analyse_people_case.rb +223 -0
- data/lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb +37 -0
- data/lib/eco/api/usecases/default_cases/codes_to_tags_case.rb +2 -3
- data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +11 -1
- data/lib/eco/api/usecases/default_cases/restore_db_case.rb +1 -2
- data/lib/eco/api/usecases/default_cases/supers_cyclic_identify_case.rb +72 -0
- data/lib/eco/api/usecases/default_cases/supers_hierarchy_case.rb +1 -1
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +132 -29
- data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +61 -36
- data/lib/eco/api/usecases/ooze_samples/ooze_update_case.rb +3 -2
- data/lib/eco/cli.rb +0 -10
- data/lib/eco/cli/config/default/options.rb +48 -17
- data/lib/eco/cli/config/default/people.rb +18 -24
- data/lib/eco/cli/config/default/people_filters.rb +3 -3
- data/lib/eco/cli/config/default/usecases.rb +105 -28
- data/lib/eco/cli/config/default/workflow.rb +21 -12
- data/lib/eco/cli/config/help.rb +1 -0
- data/lib/eco/cli/config/options_set.rb +106 -13
- data/lib/eco/cli/config/use_cases.rb +33 -33
- data/lib/eco/cli/scripting/args_helpers.rb +30 -3
- data/lib/eco/csv.rb +4 -2
- data/lib/eco/csv/table.rb +121 -21
- data/lib/eco/data.rb +1 -0
- data/lib/eco/data/crypto/encryption.rb +3 -3
- data/lib/eco/data/files/directory.rb +28 -20
- data/lib/eco/data/files/helpers.rb +6 -4
- data/lib/eco/data/fuzzy_match.rb +201 -0
- data/lib/eco/data/fuzzy_match/array_helpers.rb +75 -0
- data/lib/eco/data/fuzzy_match/chars_position_score.rb +38 -0
- data/lib/eco/data/fuzzy_match/ngrams_score.rb +82 -0
- data/lib/eco/data/fuzzy_match/pairing.rb +95 -0
- data/lib/eco/data/fuzzy_match/result.rb +87 -0
- data/lib/eco/data/fuzzy_match/results.rb +77 -0
- data/lib/eco/data/fuzzy_match/score.rb +49 -0
- data/lib/eco/data/fuzzy_match/stop_words.rb +35 -0
- data/lib/eco/data/fuzzy_match/string_helpers.rb +82 -0
- data/lib/eco/version.rb +1 -1
- metadata +168 -11
- data/lib/eco/api/microcases/refresh_abilities.rb +0 -19
- data/lib/eco/api/organization/presets_reference.json +0 -59
- data/lib/eco/api/usecases/default_cases/refresh_abilities_case.rb +0 -30
|
@@ -124,8 +124,9 @@ class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::Common::Loader
|
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
def prompt_to_confirm!
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
prompt_user("Do you want to proceed (y/N)?", default: "Y") do |response|
|
|
128
|
+
exit(1) unless response.upcase.start_with?("Y")
|
|
129
|
+
end
|
|
129
130
|
end
|
|
130
131
|
|
|
131
132
|
end
|
data/lib/eco/cli.rb
CHANGED
|
@@ -23,16 +23,6 @@ module Eco
|
|
|
23
23
|
def run(session:)
|
|
24
24
|
io = Eco::API::UseCases::BaseIO.new(session: session, options: options)
|
|
25
25
|
session.workflow(io: io).run(io: io)
|
|
26
|
-
#session.workflow(io: io) do |wf, io|
|
|
27
|
-
# io = wf.run(:options, io: io)
|
|
28
|
-
# io = wf.run(:load, io: io)
|
|
29
|
-
# io = wf.run(:usecases, io: io)
|
|
30
|
-
# io = wf.run(:launch_jobs, io: io)
|
|
31
|
-
# io = wf.run(:post_launch, io: io)
|
|
32
|
-
# io = wf.run(:report, io: io)
|
|
33
|
-
# io = wf.run(:end, io: io)
|
|
34
|
-
# io = wf.run(:close, io: io)
|
|
35
|
-
#end
|
|
36
26
|
end
|
|
37
27
|
|
|
38
28
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
ASSETS.cli.config do |cnf|
|
|
2
2
|
cnf.options_set do |options_set, options|
|
|
3
|
-
options_set.add("--help", "
|
|
3
|
+
options_set.add("--help", "Offers a HELP") do |options, sesssion|
|
|
4
4
|
conf = ASSETS.cli.config
|
|
5
5
|
puts conf.people_filters.help if hpf = SCR.get_arg("-filters")
|
|
6
6
|
puts conf.input_filters.help if hif = SCR.get_arg("-input-filters")
|
|
@@ -11,12 +11,20 @@ ASSETS.cli.config do |cnf|
|
|
|
11
11
|
" -filters to display available filters on people",
|
|
12
12
|
" -input-filters to display available filters on input data",
|
|
13
13
|
" -options to dislpay available options",
|
|
14
|
-
" -usecases to display available usecases"
|
|
14
|
+
" -usecases to display available usecases",
|
|
15
|
+
"",
|
|
16
|
+
"You may specify the usecase to know its specific options by: -usecase_name --help -options"
|
|
15
17
|
].join("\n") unless hpf || hif || ho || huc
|
|
16
18
|
exit
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
desc = "
|
|
21
|
+
desc = "Redirect Standard Ouput to file"
|
|
22
|
+
options_set.add("-stdout", desc) do |options, session|
|
|
23
|
+
file = SCR.get_arg("-stdout", with_param: true) || "output.txt"
|
|
24
|
+
STDOUT.reopen(file, "w+")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
desc = "Fix the current session to work with this schema"
|
|
20
28
|
options_set.add("-schema-id", desc) do |options, session|
|
|
21
29
|
sch_name = SCR.get_arg("-schema-id", with_param: true)
|
|
22
30
|
sch_id = session.schemas.to_id(sch_name)
|
|
@@ -33,67 +41,90 @@ ASSETS.cli.config do |cnf|
|
|
|
33
41
|
session.schema = sch_id
|
|
34
42
|
end
|
|
35
43
|
|
|
36
|
-
desc
|
|
44
|
+
desc = "Used to be used to specify the input file when using -get-partial. "
|
|
45
|
+
desc += "It can also be useful to obtain `-get-partial` of people base on `:export` use cases (i.e. -people-to-csv)"
|
|
37
46
|
options_set.add("-entries-from", desc) do |options, session|
|
|
38
47
|
options.deep_merge!(input: {entries_from: true})
|
|
39
48
|
end
|
|
40
49
|
|
|
41
|
-
desc
|
|
50
|
+
desc = "Used to only get the people from the input file. It will also include their current and new supervisors."
|
|
51
|
+
options_set.add("-get-partial", desc) do |options, session|
|
|
52
|
+
options.deep_merge!(people: {
|
|
53
|
+
get: {from: :remote, type: :partial}
|
|
54
|
+
})
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
desc = "Do not load any people for this run."
|
|
58
|
+
options_set.add("-no-people", desc) do |options, session|
|
|
59
|
+
options.deep_merge!(people: {get: false})
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
desc = "Locally cache all the people manager by retrieving from the server"
|
|
42
63
|
options_set.add("-get-people", desc) do |options, session|
|
|
43
64
|
options.deep_merge!(people: {
|
|
44
65
|
get: {from: :remote, type: :full}
|
|
45
66
|
})
|
|
46
67
|
end
|
|
47
68
|
|
|
48
|
-
|
|
69
|
+
desc = "Used to specify the cache file of people to be used. "
|
|
70
|
+
desc += "It is useful to use as people reference those stored in cached file diffrent to the last one."
|
|
71
|
+
options_set.add("-people-from-backup", desc) do |options, session|
|
|
72
|
+
file = SCR.get_file("-people-from-backup", required: true, should_exist: true)
|
|
73
|
+
options.deep_merge!(people: {
|
|
74
|
+
get: {from: :local, type: :file, file: file}
|
|
75
|
+
})
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
desc = "Runs in dry-run (no requests sent to server)"
|
|
79
|
+
options_set.add(["-dry-run", "-simulate"], desc) do |options, session|
|
|
49
80
|
options[:dry_run] = true
|
|
50
81
|
options[:simulate] = true
|
|
51
82
|
session.config.dry_run!
|
|
52
83
|
end
|
|
53
84
|
|
|
54
|
-
desc = "
|
|
85
|
+
desc = "Ignores threshold limitations on requests for this session (skip batch belt)"
|
|
55
86
|
options_set.add("-skip-batch-policy", desc) do |options|
|
|
56
87
|
options.deep_merge!(skip: {batch_policy: true})
|
|
57
88
|
end
|
|
58
89
|
|
|
59
|
-
desc = "
|
|
90
|
+
desc = "Will not run the api policies defined for the enviro"
|
|
60
91
|
options_set.add("-skip-api-policies", desc) do |options|
|
|
61
92
|
options.deep_merge!(skip: {api_policies: true})
|
|
62
93
|
end
|
|
63
94
|
|
|
64
|
-
options_set.add("-feed-only-stats", "
|
|
95
|
+
options_set.add("-feed-only-stats", "Shows only stats when giving feedback") do |options|
|
|
65
96
|
options.deep_merge!(feedback: {only_stats: true})
|
|
66
97
|
end
|
|
67
98
|
|
|
68
|
-
desc = "
|
|
99
|
+
desc = "Deprecated: used to be used to avoid reloading people after launch"
|
|
69
100
|
options[:end_get] = true
|
|
70
101
|
options_set.add("-no-get", desc) do |options|
|
|
71
102
|
options[:end_get] = false
|
|
72
103
|
end
|
|
73
104
|
|
|
74
|
-
desc = "
|
|
105
|
+
desc = "Force search mode to 'strict' when pairing input entries with existing people."
|
|
75
106
|
desc += " Besides id and external_id it will not try to find by email unless external_id is not specified"
|
|
76
107
|
options_set.add("-search-strict", desc) do |options|
|
|
77
108
|
options.deep_merge!(search: {strict: true})
|
|
78
109
|
end
|
|
79
110
|
|
|
80
|
-
desc = "
|
|
111
|
+
desc = "Search mode that will try to find people using email when id and external_id have failed"
|
|
81
112
|
desc += " This option could identify existing people by their email addresses"
|
|
82
113
|
desc += " (it should not be used in orgs where multiple people usually have the same email address)"
|
|
83
114
|
options_set.add("-search-soft", desc) do |options|
|
|
84
115
|
options.deep_merge!(search: {soft: true, strict: false})
|
|
85
116
|
end
|
|
86
117
|
|
|
87
|
-
desc = "
|
|
118
|
+
desc = "Silence notifications on account creation or invites"
|
|
88
119
|
options_set.add(["-no-invites", "-exclude-invites"], desc) do |options|
|
|
89
120
|
options.merge!(send_invites: false)
|
|
90
121
|
end
|
|
91
|
-
desc = "
|
|
122
|
+
desc = "People with account will be reinvited if they haven't accepted the invitation"
|
|
92
123
|
options_set.add("-send-invites", desc) do |options|
|
|
93
124
|
options.merge!(send_invites: true)
|
|
94
125
|
end
|
|
95
126
|
|
|
96
|
-
options_set.add("-exclude-core", "
|
|
127
|
+
options_set.add("-exclude-core", "Core input data is not used on the update") do |options|
|
|
97
128
|
options.deep_merge!(exclude: {core: true})
|
|
98
129
|
end
|
|
99
130
|
options_set.add("-exclude-filter-tags", "filter_tags is not set with the input data") do |options|
|
|
@@ -112,11 +143,11 @@ ASSETS.cli.config do |cnf|
|
|
|
112
143
|
options.deep_merge!(exclude: {name: true})
|
|
113
144
|
end
|
|
114
145
|
|
|
115
|
-
options_set.add("-exclude-details", "
|
|
146
|
+
options_set.add("-exclude-details", "Details are not set with the input data") do |options|
|
|
116
147
|
options.deep_merge!(exclude: {details: true})
|
|
117
148
|
end
|
|
118
149
|
|
|
119
|
-
options_set.add("-exclude-account", "
|
|
150
|
+
options_set.add("-exclude-account", "Account is not set with the input data") do |options|
|
|
120
151
|
options.deep_merge!(exclude: {account: true})
|
|
121
152
|
end
|
|
122
153
|
options_set.add("-exclude-policy-groups", "policy_group_ids is not set with the input data") do |options|
|
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
ASSETS.cli.config do |cnf|
|
|
2
2
|
cnf.people do |input, session, options|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
people
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
options.deep_merge!(people: {
|
|
14
|
-
get: {from: :local, type: :backup}
|
|
15
|
-
})
|
|
16
|
-
people = JSON.parse(File.read(file))
|
|
17
|
-
people = Eco::API::Organization::People.new(people)
|
|
18
|
-
elsif SCR.get_arg("-get-partial")
|
|
19
|
-
unless input && input.is_a?(Enumerable)
|
|
3
|
+
get = options.dig(:people, :get) || {}
|
|
4
|
+
case
|
|
5
|
+
when get == false
|
|
6
|
+
Eco::API::Organization::People.new([])
|
|
7
|
+
when (get[:from] == :remote) && get[:type] == :full
|
|
8
|
+
# -get-people
|
|
9
|
+
session.micro.people_cache
|
|
10
|
+
when (get[:from] == :remote) && get[:type] == :partial
|
|
11
|
+
# -get-partial
|
|
12
|
+
unless (input && input.is_a?(Enumerable))
|
|
20
13
|
raise "To use -get-partial (partial updates), you need to use -entries-from"
|
|
21
14
|
end
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
people =
|
|
15
|
+
session.micro.people_search(input, options: options)
|
|
16
|
+
when (get[:from] == :local) && get[:type] == :file
|
|
17
|
+
# -people-from-backup
|
|
18
|
+
session.micro.people_load(get[:file], modifier: :file)
|
|
19
|
+
#people = JSON.parse(File.read(get[:file]))
|
|
20
|
+
#Eco::API::Organization::People.new(people)
|
|
27
21
|
else
|
|
28
22
|
options.deep_merge!(people: {
|
|
29
23
|
get: {from: :local, type: :full}
|
|
@@ -33,9 +27,9 @@ ASSETS.cli.config do |cnf|
|
|
|
33
27
|
options.deep_merge!(people: {
|
|
34
28
|
get: {from: :remote, type: :full}
|
|
35
29
|
})
|
|
36
|
-
people = session.micro.people_cache
|
|
30
|
+
people = session.micro.people_cache
|
|
37
31
|
end
|
|
32
|
+
people
|
|
38
33
|
end
|
|
39
|
-
people
|
|
40
34
|
end
|
|
41
35
|
end
|
|
@@ -52,7 +52,7 @@ ASSETS.cli.config do |cnf|
|
|
|
52
52
|
|
|
53
53
|
desc = "only those that have ALL the specified tags separated by '|'"
|
|
54
54
|
filters.add("-filter-tags-all", desc) do |people, session, options|
|
|
55
|
-
tags = SCR.get_arg("-filter-tags-all", with_param: true).upcase.split("|")
|
|
55
|
+
tags = SCR.get_arg("-filter-tags-all", with_param: true).upcase.split("|").compact
|
|
56
56
|
options.deep_merge!(input: {filter: {filter_tags: {any: tags}}})
|
|
57
57
|
people.filter_tags_all(tags).tap do |filtered|
|
|
58
58
|
msg = "Filtered #{filtered.count} people (out of #{people.count}) with 'all' filter_tags #{tags}"
|
|
@@ -62,7 +62,7 @@ ASSETS.cli.config do |cnf|
|
|
|
62
62
|
|
|
63
63
|
desc = "only those that have ANY the specified tags separated by '|'"
|
|
64
64
|
filters.add("-filter-tags-any", desc) do |people, session, options|
|
|
65
|
-
tags = SCR.get_arg("-filter-tags-any", with_param: true).upcase.split("|")
|
|
65
|
+
tags = SCR.get_arg("-filter-tags-any", with_param: true).upcase.split("|").compact
|
|
66
66
|
options.deep_merge!(input: {filter: {filter_tags_any: tags}})
|
|
67
67
|
people.filter_tags_any(tags).tap do |filtered|
|
|
68
68
|
msg = "Filtered #{filtered.count} people (out of #{people.count}) with 'any' filter_tags #{tags}"
|
|
@@ -72,7 +72,7 @@ ASSETS.cli.config do |cnf|
|
|
|
72
72
|
|
|
73
73
|
desc = "only those that have ANY tag in the specified subtrees separated by '|'"
|
|
74
74
|
filters.add("-filter-tags-tree", desc) do |people, session, options|
|
|
75
|
-
top_tags = SCR.get_arg("-filter-tags-tree", with_param: true).upcase.split("|")
|
|
75
|
+
top_tags = SCR.get_arg("-filter-tags-tree", with_param: true).upcase.split("|").compact
|
|
76
76
|
tags = top_tags.each_with_object([]) do |top, tags|
|
|
77
77
|
tags.concat(session.tagtree.node(top).tags)
|
|
78
78
|
end.uniq
|
|
@@ -1,33 +1,103 @@
|
|
|
1
1
|
ASSETS.cli.config do |cnf|
|
|
2
2
|
cnf.usecases do |cases|
|
|
3
3
|
|
|
4
|
-
desc = "Draws the Supervisors hiearchy in a file
|
|
4
|
+
desc = "Draws the Supervisors hiearchy in a file"
|
|
5
5
|
cases.add("-supers-hierarchy", :export, desc, case_name: "supers-hierarchy") do |people, session, options|
|
|
6
|
-
file
|
|
6
|
+
options.deep_merge!(output: {file: "supers_hierarchy.txt"}) unless options.dig(:output, :file)
|
|
7
|
+
end.add_option("-to", "Specify the output file") do |options|
|
|
8
|
+
file = SCR.get_file("-to", required: true, should_exist: false)
|
|
7
9
|
options.deep_merge!(output: {file: file})
|
|
8
10
|
end
|
|
9
11
|
|
|
12
|
+
desc = "Draws the Cyclic Supervisors when identified"
|
|
13
|
+
cases.add("-identify-cyclic-supers", :export, desc, case_name: "identify-cyclic-supers") do |people, session, options|
|
|
14
|
+
options.deep_merge!(output: {file: "cyclic_supers.txt"}) unless options.dig(:output, :file)
|
|
15
|
+
end.add_option("-to", "Specify the output file") do |options|
|
|
16
|
+
file = SCR.get_file("-to", required: true, should_exist: false)
|
|
17
|
+
options.deep_merge!(output: {file: file})
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
desc = "Abstracts the Abilities that each Usergroup should probably have"
|
|
21
|
+
cases.add("-abstract-policygroup-abilities", :export, desc, case_name: "abstract-policygroup-abilities") do |people, session, options|
|
|
22
|
+
options.deep_merge!(output: {file: "suggested_usergroup_abilities.txt"}) unless options.dig(:output, :file)
|
|
23
|
+
end.add_option("-to", "Specify the output file") do |options|
|
|
24
|
+
file = SCR.get_file("-to", required: true, should_exist: false)
|
|
25
|
+
options.deep_merge!(output: {file: file})
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
desc = "Provides a set of tools to analyse a set of people (i.e. detect duplicates)"
|
|
29
|
+
cases.add("-analyse-people", :export, desc, case_name: "analyse-people") do |people, session, options|
|
|
30
|
+
options.deep_merge!(output: {file: "people_analysis.txt"}) unless options.dig(:output, :file)
|
|
31
|
+
#unless options.dig(:usecase, :analyse_people, :use_field)
|
|
32
|
+
# options.deep_merge!(usecase: {analyse_people: {use_field: :name}})
|
|
33
|
+
#end
|
|
34
|
+
end.add_option("-to", "Specify the output file.") do |options|
|
|
35
|
+
file = SCR.get_file("-to", required: true, should_exist: false)
|
|
36
|
+
options.deep_merge!(output: {file: file})
|
|
37
|
+
end.add_option("-identify-duplicates", "Generates a list of people with possible duplicates.") do |options|
|
|
38
|
+
options.deep_merge!(usecase: {analyse_people: {identify_duplicates: true}})
|
|
39
|
+
end.add_option("-use-field", "Works with -identify-duplicates. Sets field to be used in the comparison.") do |options|
|
|
40
|
+
expression = SCR.get_arg("-use-field", with_param: true)
|
|
41
|
+
options.deep_merge!(usecase: {analyse_people: {use_field: expression}})
|
|
42
|
+
end.add_option("-facet-field", "Works with -identify-duplicates. Adds an additional layer of comparison.") do |options|
|
|
43
|
+
expression = SCR.get_arg("-facet-field", with_param: true)
|
|
44
|
+
options.deep_merge!(usecase: {analyse_people: {facet_field: expression}})
|
|
45
|
+
end.add_option("-only-screening", "Works with -identify-duplicates. Skips the rearrangement stage.") do |options|
|
|
46
|
+
options.deep_merge!(usecase: {analyse_people: {only_screening: true}})
|
|
47
|
+
end.add_option("-ignore-matching-words", "Works with -identify-duplicates. Re-adjust scores ignoring matching words.") do |options|
|
|
48
|
+
options.deep_merge!(usecase: {analyse_people: {ignore_matching_words: true}})
|
|
49
|
+
end.add_option("-unique-words", "Works with -identify-duplicates. Re-adjust the comparing strings to do not have repeated words.") do |options|
|
|
50
|
+
options.deep_merge!(usecase: {analyse_people: {unique_words: true}})
|
|
51
|
+
end.add_option("-identify-unnamed", "Identifies all people with no names.") do |options|
|
|
52
|
+
options.deep_merge!(usecase: {analyse_people: {identify_unnamed: true}})
|
|
53
|
+
end.add_option("-backup-people-results", "Generates a json file with all the people involved in the final results of the analysis.") do |options|
|
|
54
|
+
file = SCR.get_file("-backup-people-results", required: true, should_exist: false)
|
|
55
|
+
options.deep_merge!(usecase: {analyse_people: {backup_people: File.expand_path(file)}})
|
|
56
|
+
end.add_option("-to-csv", "Genarates a CSV file with all people of the final results.") do |options|
|
|
57
|
+
file = SCR.get_file("-to-csv", required: true, should_exist: false) || "Results.csv"
|
|
58
|
+
options.deep_merge!(usecase: {analyse_people: {csv_file: File.expand_path(file)}})
|
|
59
|
+
end
|
|
60
|
+
|
|
10
61
|
desc = "It exports to a CSV the (filtered) people"
|
|
11
62
|
cases.add("-people-to-csv", :export, desc) do |people, session, options|
|
|
12
63
|
file = SCR.get_file("-people-to-csv", required: true, should_exist: false)
|
|
13
64
|
options.deep_merge!(export: {file: {name: file, format: :csv}})
|
|
14
|
-
|
|
15
|
-
options.
|
|
16
|
-
case_name = SCR.get_arg("-detailed")? "to-csv-detailed" : "to-csv"
|
|
65
|
+
|
|
66
|
+
case_name = options.dig(:export, :options, :detailed) ? "to-csv-detailed" : "to-csv"
|
|
17
67
|
session.usecases.case(case_name)
|
|
68
|
+
end.add_option("-nice-header", "Outputs more descriptive standard headers") do |options|
|
|
69
|
+
options.deep_merge!(export: {options: {nice_header: true}})
|
|
70
|
+
end.add_option("-internal-names", "It is the most raw export. Useful to see all the data when name mappings override/overlap") do |options|
|
|
71
|
+
options.deep_merge!(export: {options: {internal_names: true}})
|
|
72
|
+
end.add_option("-detailed", "Includes much more information to the file (i.e. permissions_merged abilities, preferences)") do |options|
|
|
73
|
+
options.deep_merge!(export: {options: {detailed: true}})
|
|
74
|
+
end.add_option("-permissions-custom", "Used with -detailed. Adds the permissions_custom abilities") do |options|
|
|
75
|
+
options.deep_merge!(export: {options: {permissions_custom: true}})
|
|
76
|
+
end.add_option("-split-schemas", "It will generate 1 file per each schema") do |options|
|
|
77
|
+
options.deep_merge!(export: {options: {split_schemas: true}})
|
|
18
78
|
end
|
|
19
79
|
|
|
20
80
|
desc = "Adds a column 'ecoPortalTag' to the input CSV with the tags that the location codes map to"
|
|
21
|
-
cases.add("-codes-to-tags-from", :other, desc, case_name: "codes-to-tags-from")
|
|
81
|
+
cases.add("-codes-to-tags-from", :other, desc, case_name: "codes-to-tags-from")
|
|
82
|
+
.add_option("-codes-to-tags-from", "Specify the input 'csv' file") do |options|
|
|
22
83
|
file = SCR.get_file("-codes-to-tags-from", required: true, should_exist: true)
|
|
23
84
|
options.deep_merge!(other: {file: {name: file, format: :csv}})
|
|
24
|
-
|
|
85
|
+
end.add_option("-column", "Specify the input column header with the codes") do |options|
|
|
25
86
|
col_codes = SCR.get_arg("-column", with_param: true)
|
|
26
87
|
options.deep_merge!(other: {file: {codes_column: col_codes}})
|
|
27
88
|
end
|
|
28
89
|
|
|
29
|
-
desc
|
|
90
|
+
desc = "Cleans from filter_tags those tags that are not present in the tagtree (as per tagtree.json file)."
|
|
91
|
+
desc += " It will preserve standard register tags of most common registers (i.e. EVENT, RISK)."
|
|
92
|
+
cases.add("-clean-unknown-tags", :transform, desc, case_name: "clean-unknown-tags")
|
|
93
|
+
|
|
94
|
+
desc = "Removes the landing page or sets it to -page-id"
|
|
30
95
|
cases.add("-reset-landing-page", :transform, desc, case_name: "reset-landing-page")
|
|
96
|
+
.add_option("-page-id", "Target landing page to set to the users") do |options|
|
|
97
|
+
SCR.get_arg("-page-id", with_param: true).tap do |new_id|
|
|
98
|
+
options.deep_merge!({page_id: new_id})
|
|
99
|
+
end
|
|
100
|
+
end
|
|
31
101
|
|
|
32
102
|
desc = "Sets as external_id the email of the person"
|
|
33
103
|
cases.add("-email-as-id", :transform, desc, case_name: "email-as-id")
|
|
@@ -42,23 +112,29 @@ ASSETS.cli.config do |cnf|
|
|
|
42
112
|
|
|
43
113
|
desc = "Sets the supervisor_id"
|
|
44
114
|
cases.add("-set-supervisor-from", :sync, desc, case_name: "set-supervisor")
|
|
115
|
+
|
|
45
116
|
desc = "Sets to -new-super the supervisor_id of the -old-super's subordinates"
|
|
46
117
|
cases.add("-switch-supervisor", :transform, desc, case_name: "switch-supervisor") do |people, session, options|
|
|
47
|
-
unless
|
|
118
|
+
unless options[:super]&.key?(:old)
|
|
48
119
|
msg = "You must specify an -old-super to target whose supervisor is changing"
|
|
49
120
|
session.logger.error(msg)
|
|
50
121
|
exit(1)
|
|
51
122
|
end
|
|
52
|
-
|
|
53
|
-
options.deep_merge!(super: {old: old_id})
|
|
54
|
-
|
|
55
|
-
unless new_id = SCR.get_arg("-new-super", with_param: true)
|
|
123
|
+
unless options[:super]&.key?(:new)
|
|
56
124
|
msg = "You must specify the -new-super id. To reset to nil the supervisor, please, specify nil."
|
|
57
125
|
session.logger.error(msg)
|
|
58
126
|
exit(1)
|
|
59
127
|
end
|
|
60
|
-
|
|
61
|
-
|
|
128
|
+
end.add_option("-old-super", "The supervisor id to be replaced on the subordinates") do |options|
|
|
129
|
+
if old_id = SCR.get_arg("-old-super", with_param: true)
|
|
130
|
+
old_id = old_id == "nil"? nil : old_id
|
|
131
|
+
options.deep_merge!(super: {old: old_id})
|
|
132
|
+
end
|
|
133
|
+
end.add_option("-new-super", "The new supervisor id") do |options|
|
|
134
|
+
if new_id = SCR.get_arg("-new-super", with_param: true)
|
|
135
|
+
new_id = new_id == "nil"? nil : new_id
|
|
136
|
+
options.deep_merge!(super: {new: new_id})
|
|
137
|
+
end
|
|
62
138
|
end
|
|
63
139
|
|
|
64
140
|
desc = "Usage '-org-data-convert backup.json -restore-db-from'."
|
|
@@ -71,15 +147,15 @@ ASSETS.cli.config do |cnf|
|
|
|
71
147
|
session.logger.info("Source DB: loaded #{input.length} entries.")
|
|
72
148
|
end
|
|
73
149
|
|
|
74
|
-
|
|
75
|
-
options.merge!(source_enviro: source_enviro)
|
|
76
|
-
else
|
|
150
|
+
unless options[:source_enviro]
|
|
77
151
|
session.logger.error("You need to specify a -source-enviro for the conversion to work out")
|
|
78
152
|
exit(1)
|
|
79
153
|
end
|
|
80
154
|
|
|
81
|
-
|
|
82
|
-
|
|
155
|
+
end.add_option("-source-enviro", "The defined -source-enviro API configuration that the backup file was generated from") do |options|
|
|
156
|
+
options.merge!(source_enviro: SCR.get_arg("-source-enviro", with_param: true))
|
|
157
|
+
end.add_option("-ignore-missing-policy-groups", "Prevents the script to crash when backup file has missing usergroups in the org") do |options|
|
|
158
|
+
options.deep_merge!(ignore: {missing: {policy_groups: true}})
|
|
83
159
|
end
|
|
84
160
|
|
|
85
161
|
desc = "Restores the people manager by using a backup.json file"
|
|
@@ -89,13 +165,15 @@ ASSETS.cli.config do |cnf|
|
|
|
89
165
|
input = Eco::API::Organization::People.new(JSON.parse(File.read(file)))
|
|
90
166
|
session.logger.info("Source DB: loaded #{input.length} entries.")
|
|
91
167
|
end
|
|
92
|
-
|
|
93
|
-
options.deep_merge!(include: {delete: true})
|
|
94
|
-
|
|
168
|
+
end.add_option("-include-delete", "If it should DELETE people that do not exist in the backup file") do |options|
|
|
169
|
+
options.deep_merge!(include: {delete: true})
|
|
170
|
+
end.add_option("-include-create", "If it should CREATE people that do not exist in the people manager") do |options|
|
|
171
|
+
options.deep_merge!(include: {create: true})
|
|
95
172
|
end
|
|
96
173
|
|
|
97
174
|
desc = "Re-sends invites to all filtered users that have not accepted the invite as yet"
|
|
98
175
|
cases.add("-reinvite", :transform, desc, case_name: "reinvite")
|
|
176
|
+
|
|
99
177
|
desc = "Re-sends invites to target users that have not accepted the invite as yet"
|
|
100
178
|
cases.add("-reinvite-from", :sync, desc, case_name: "reinvite")
|
|
101
179
|
|
|
@@ -118,8 +196,6 @@ ASSETS.cli.config do |cnf|
|
|
|
118
196
|
|
|
119
197
|
desc = "It just adds everybody to an update job without doing any change. If the org has policies, it will refresh"
|
|
120
198
|
cases.add("-refresh", :transform, desc, case_name: "refresh")
|
|
121
|
-
desc = "Remaps the abilities of every user based on their usergroups mappings thereof in the org api configuration"
|
|
122
|
-
cases.add("-refresh-abilities", :transform, desc, case_name: "refresh-abilities")
|
|
123
199
|
|
|
124
200
|
desc = "Updates details and core (including supervisor) to target people"
|
|
125
201
|
cases.add("-update-details-from", :sync, desc, case_name: "update-details")
|
|
@@ -129,9 +205,10 @@ ASSETS.cli.config do |cnf|
|
|
|
129
205
|
desc = "Updates the people specified in the input data"
|
|
130
206
|
cases.add("-update-from", :sync, desc, case_name: "update")
|
|
131
207
|
|
|
132
|
-
desc = "Does an actual transfer of
|
|
133
|
-
cases.add("-transfer-account-from", :sync, desc, case_name: "transfer-account")
|
|
134
|
-
|
|
208
|
+
desc = "Does an actual transfer of USER from id|external_id account to 'destination-id' person"
|
|
209
|
+
cases.add("-transfer-account-from", :sync, desc, case_name: "transfer-account")
|
|
210
|
+
.add_option("-include-email", "Specifies if the email should also be moved. Otherwise it only moves the account") do |options|
|
|
211
|
+
options.deep_merge!(include: {email: true})
|
|
135
212
|
end
|
|
136
213
|
|
|
137
214
|
desc = "Tries to find the input entries and update them. It creates them if not found"
|