eco-helpers 2.0.16 → 2.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +125 -6
- data/eco-helpers.gemspec +10 -5
- data/lib/eco-helpers.rb +2 -0
- data/lib/eco/api/common/base_loader.rb +18 -0
- data/lib/eco/api/common/loaders/parser.rb +1 -0
- data/lib/eco/api/common/people/default_parsers.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/default_parsers/xls_parser.rb +53 -0
- data/lib/eco/api/common/people/entries.rb +1 -0
- data/lib/eco/api/common/people/entry_factory.rb +88 -23
- data/lib/eco/api/common/people/person_entry.rb +5 -2
- data/lib/eco/api/common/people/person_parser.rb +1 -1
- 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/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 +22 -83
- 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 +20 -28
- data/lib/eco/api/session/batch.rb +25 -7
- data/lib/eco/api/session/config.rb +0 -10
- data/lib/eco/api/session/config/apis.rb +80 -14
- data/lib/eco/api/session/config/people.rb +1 -17
- data/lib/eco/api/usecases.rb +2 -2
- data/lib/eco/api/usecases/base_case.rb +2 -2
- data/lib/eco/api/usecases/base_io.rb +17 -4
- data/lib/eco/api/usecases/default_cases.rb +2 -1
- data/lib/eco/api/usecases/default_cases/abstract_policygroup_abilities_case.rb +4 -4
- 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 +1 -1
- 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/config/default/input.rb +61 -8
- 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 +97 -32
- data/lib/eco/cli/config/default/workflow.rb +22 -13
- 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 +32 -5
- 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/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 +147 -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
@@ -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 or folder 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,45 +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
|
|
10
|
-
desc = "Draws the Cyclic Supervisors when identified
|
12
|
+
desc = "Draws the Cyclic Supervisors when identified"
|
11
13
|
cases.add("-identify-cyclic-supers", :export, desc, case_name: "identify-cyclic-supers") do |people, session, options|
|
12
|
-
file
|
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)
|
13
17
|
options.deep_merge!(output: {file: file})
|
14
18
|
end
|
15
19
|
|
16
|
-
desc = "Abstracts the Abilities that each Usergroup should probably have
|
20
|
+
desc = "Abstracts the Abilities that each Usergroup should probably have"
|
17
21
|
cases.add("-abstract-policygroup-abilities", :export, desc, case_name: "abstract-policygroup-abilities") do |people, session, options|
|
18
|
-
file
|
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)
|
19
25
|
options.deep_merge!(output: {file: file})
|
20
26
|
end
|
21
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
|
+
|
22
61
|
desc = "It exports to a CSV the (filtered) people"
|
23
62
|
cases.add("-people-to-csv", :export, desc) do |people, session, options|
|
24
63
|
file = SCR.get_file("-people-to-csv", required: true, should_exist: false)
|
25
64
|
options.deep_merge!(export: {file: {name: file, format: :csv}})
|
26
|
-
|
27
|
-
options.
|
28
|
-
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"
|
29
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}})
|
30
78
|
end
|
31
79
|
|
32
80
|
desc = "Adds a column 'ecoPortalTag' to the input CSV with the tags that the location codes map to"
|
33
|
-
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|
|
34
83
|
file = SCR.get_file("-codes-to-tags-from", required: true, should_exist: true)
|
35
84
|
options.deep_merge!(other: {file: {name: file, format: :csv}})
|
36
|
-
|
85
|
+
end.add_option("-column", "Specify the input column header with the codes") do |options|
|
37
86
|
col_codes = SCR.get_arg("-column", with_param: true)
|
38
87
|
options.deep_merge!(other: {file: {codes_column: col_codes}})
|
39
88
|
end
|
40
89
|
|
41
|
-
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"
|
42
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
|
43
101
|
|
44
102
|
desc = "Sets as external_id the email of the person"
|
45
103
|
cases.add("-email-as-id", :transform, desc, case_name: "email-as-id")
|
@@ -54,23 +112,29 @@ ASSETS.cli.config do |cnf|
|
|
54
112
|
|
55
113
|
desc = "Sets the supervisor_id"
|
56
114
|
cases.add("-set-supervisor-from", :sync, desc, case_name: "set-supervisor")
|
115
|
+
|
57
116
|
desc = "Sets to -new-super the supervisor_id of the -old-super's subordinates"
|
58
117
|
cases.add("-switch-supervisor", :transform, desc, case_name: "switch-supervisor") do |people, session, options|
|
59
|
-
unless
|
118
|
+
unless options[:super]&.key?(:old)
|
60
119
|
msg = "You must specify an -old-super to target whose supervisor is changing"
|
61
120
|
session.logger.error(msg)
|
62
121
|
exit(1)
|
63
122
|
end
|
64
|
-
|
65
|
-
options.deep_merge!(super: {old: old_id})
|
66
|
-
|
67
|
-
unless new_id = SCR.get_arg("-new-super", with_param: true)
|
123
|
+
unless options[:super]&.key?(:new)
|
68
124
|
msg = "You must specify the -new-super id. To reset to nil the supervisor, please, specify nil."
|
69
125
|
session.logger.error(msg)
|
70
126
|
exit(1)
|
71
127
|
end
|
72
|
-
|
73
|
-
|
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
|
74
138
|
end
|
75
139
|
|
76
140
|
desc = "Usage '-org-data-convert backup.json -restore-db-from'."
|
@@ -83,15 +147,15 @@ ASSETS.cli.config do |cnf|
|
|
83
147
|
session.logger.info("Source DB: loaded #{input.length} entries.")
|
84
148
|
end
|
85
149
|
|
86
|
-
|
87
|
-
options.merge!(source_enviro: source_enviro)
|
88
|
-
else
|
150
|
+
unless options[:source_enviro]
|
89
151
|
session.logger.error("You need to specify a -source-enviro for the conversion to work out")
|
90
152
|
exit(1)
|
91
153
|
end
|
92
154
|
|
93
|
-
|
94
|
-
|
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}})
|
95
159
|
end
|
96
160
|
|
97
161
|
desc = "Restores the people manager by using a backup.json file"
|
@@ -101,13 +165,15 @@ ASSETS.cli.config do |cnf|
|
|
101
165
|
input = Eco::API::Organization::People.new(JSON.parse(File.read(file)))
|
102
166
|
session.logger.info("Source DB: loaded #{input.length} entries.")
|
103
167
|
end
|
104
|
-
|
105
|
-
options.deep_merge!(include: {delete: true})
|
106
|
-
|
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})
|
107
172
|
end
|
108
173
|
|
109
174
|
desc = "Re-sends invites to all filtered users that have not accepted the invite as yet"
|
110
175
|
cases.add("-reinvite", :transform, desc, case_name: "reinvite")
|
176
|
+
|
111
177
|
desc = "Re-sends invites to target users that have not accepted the invite as yet"
|
112
178
|
cases.add("-reinvite-from", :sync, desc, case_name: "reinvite")
|
113
179
|
|
@@ -130,8 +196,6 @@ ASSETS.cli.config do |cnf|
|
|
130
196
|
|
131
197
|
desc = "It just adds everybody to an update job without doing any change. If the org has policies, it will refresh"
|
132
198
|
cases.add("-refresh", :transform, desc, case_name: "refresh")
|
133
|
-
desc = "Remaps the abilities of every user based on their usergroups mappings thereof in the org api configuration"
|
134
|
-
cases.add("-refresh-abilities", :transform, desc, case_name: "refresh-abilities")
|
135
199
|
|
136
200
|
desc = "Updates details and core (including supervisor) to target people"
|
137
201
|
cases.add("-update-details-from", :sync, desc, case_name: "update-details")
|
@@ -141,9 +205,10 @@ ASSETS.cli.config do |cnf|
|
|
141
205
|
desc = "Updates the people specified in the input data"
|
142
206
|
cases.add("-update-from", :sync, desc, case_name: "update")
|
143
207
|
|
144
|
-
desc = "Does an actual transfer of
|
145
|
-
cases.add("-transfer-account-from", :sync, desc, case_name: "transfer-account")
|
146
|
-
|
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})
|
147
212
|
end
|
148
213
|
|
149
214
|
desc = "Tries to find the input entries and update them. It creates them if not found"
|
@@ -6,11 +6,15 @@ ASSETS.cli.config do |config|
|
|
6
6
|
|
7
7
|
# default rescue
|
8
8
|
wf.rescue do |exception, io|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
begin
|
10
|
+
next io if rescued
|
11
|
+
rescued = true
|
12
|
+
|
13
|
+
io.session.logger.debug(exception.patch_full_message)
|
14
|
+
wf.run(:close, io: io)
|
15
|
+
rescue Exception => e
|
16
|
+
puts "Some problem in workflow.rescue: #{e}"
|
17
|
+
end
|
14
18
|
io
|
15
19
|
end
|
16
20
|
|
@@ -24,12 +28,15 @@ ASSETS.cli.config do |config|
|
|
24
28
|
cases_with_input = config.usecases.active(io: io).select do |usecase, data|
|
25
29
|
io.class.input_required?(usecase.type)
|
26
30
|
end
|
27
|
-
|
31
|
+
|
32
|
+
input_is_required = !cases_with_input.empty? || io.options.dig(:input, :entries_from)
|
33
|
+
missing_input = !io.input || io.input.empty?
|
34
|
+
next io unless missing_input && input_is_required
|
28
35
|
|
29
36
|
if io.options.dig(:input, :entries_from)
|
30
37
|
io = io.new(input: config.input.get(io: io))
|
31
38
|
else
|
32
|
-
opt_case = cases_with_input.values.first
|
39
|
+
opt_case = cases_with_input.values.first.option
|
33
40
|
io = io.new(input: config.input.get(io: io, option: opt_case))
|
34
41
|
end
|
35
42
|
io
|
@@ -46,8 +53,7 @@ ASSETS.cli.config do |config|
|
|
46
53
|
cases_with_people = config.usecases.active(io: io).select do |usecase, data|
|
47
54
|
io.class.people_required?(usecase.type)
|
48
55
|
end
|
49
|
-
|
50
|
-
next io unless !cases_with_people.empty? || get_people
|
56
|
+
next io if cases_with_people.empty? && !io.options.dig(:people, :get)
|
51
57
|
io = io.new(people: config.people(io: io))
|
52
58
|
end
|
53
59
|
|
@@ -60,7 +66,8 @@ ASSETS.cli.config do |config|
|
|
60
66
|
|
61
67
|
wf.before(:usecases) do |wf_cases, io|
|
62
68
|
# save partial entries -> should be native to session.workflow
|
63
|
-
|
69
|
+
get_people = io.options.dig(:people, :get)
|
70
|
+
partial_update = get_people && get_people.dig(:type) == :partial
|
64
71
|
if !io.options[:dry_run] && partial_update
|
65
72
|
partial_file = io.session.config.people.partial_cache
|
66
73
|
io.session.file_manager.save_json(io.people, partial_file, :timestamp)
|
@@ -91,11 +98,12 @@ ASSETS.cli.config do |config|
|
|
91
98
|
if io.session.post_launch.empty?
|
92
99
|
wf_post.skip!
|
93
100
|
else
|
94
|
-
|
101
|
+
get_people = io.options.dig(:people, :get)
|
102
|
+
partial_update = get_people && get_people.dig(:type) == :partial
|
95
103
|
if !io.options[:dry_run] && partial_update
|
96
104
|
# get target people afresh
|
97
105
|
people = io.session.micro.people_refresh(people: io.people, include_created: true)
|
98
|
-
io = io.new(people: people)
|
106
|
+
io = io.base.new(people: people)
|
99
107
|
else
|
100
108
|
wf_post.skip!
|
101
109
|
msg = "Although there are post_launch cases, they will NOT be RUN"
|
@@ -132,7 +140,8 @@ ASSETS.cli.config do |config|
|
|
132
140
|
end
|
133
141
|
|
134
142
|
wf.on(:end) do |wf_end, io|
|
135
|
-
|
143
|
+
get_people = io.options.dig(:people, :get)
|
144
|
+
partial_update = get_people && get_people.dig(:type) == :partial
|
136
145
|
unless !io.options[:end_get] || io.options[:dry_run] || partial_update
|
137
146
|
people = io.session.micro.people_cache
|
138
147
|
io = io.new(people: people)
|