eco-helpers 1.4.0 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +150 -2
- data/LICENSE +21 -0
- data/eco-helpers.gemspec +11 -10
- data/lib/eco/api.rb +3 -0
- data/lib/eco/api/common.rb +5 -1
- data/lib/eco/api/common/base_loader.rb +54 -0
- data/lib/eco/api/common/class_auto_loader.rb +109 -0
- data/lib/eco/api/common/class_helpers.rb +33 -0
- data/lib/eco/api/common/class_hierarchy.rb +1 -1
- data/lib/eco/api/common/class_meta_basics.rb +16 -0
- data/lib/eco/api/common/loaders.rb +13 -0
- data/lib/eco/api/common/loaders/error_handler.rb +41 -0
- data/lib/eco/api/common/loaders/parser.rb +127 -0
- data/lib/eco/api/common/loaders/policy.rb +25 -0
- data/lib/eco/api/common/loaders/use_case.rb +40 -0
- data/lib/eco/api/common/people/default_parsers.rb +5 -10
- data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +13 -23
- data/lib/eco/api/common/people/default_parsers/csv_parser.rb +20 -35
- data/lib/eco/api/common/people/default_parsers/date_parser.rb +15 -26
- data/lib/eco/api/common/people/default_parsers/freemium_parser.rb +20 -0
- data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +26 -0
- data/lib/eco/api/common/people/default_parsers/multi_parser.rb +15 -27
- data/lib/eco/api/common/people/default_parsers/numeric_parser.rb +14 -19
- data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +31 -0
- data/lib/eco/api/common/people/default_parsers/send_invites_parser.rb +15 -24
- data/lib/eco/api/common/people/entries.rb +54 -24
- data/lib/eco/api/common/people/entry_factory.rb +18 -15
- data/lib/eco/api/common/people/person_attribute_parser.rb +29 -12
- data/lib/eco/api/common/people/person_entry.rb +308 -216
- data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +5 -2
- data/lib/eco/api/common/people/person_parser.rb +52 -19
- data/lib/eco/api/common/session/base_session.rb +3 -6
- data/lib/eco/api/common/session/environment.rb +2 -23
- data/lib/eco/api/common/session/logger.rb +4 -0
- data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +2 -0
- data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +9 -1
- data/lib/eco/api/common/version_patches/exception.rb +24 -2
- data/lib/eco/api/custom.rb +13 -0
- data/lib/eco/api/custom/error_handler.rb +20 -0
- data/lib/eco/api/custom/namespace.rb +7 -0
- data/lib/eco/api/custom/parser.rb +50 -0
- data/lib/eco/api/custom/policy.rb +28 -0
- data/lib/eco/api/custom/use_case.rb +16 -0
- data/lib/eco/api/error.rb +1 -0
- data/lib/eco/api/error/handlers.rb +10 -3
- data/lib/eco/api/microcases.rb +35 -0
- data/lib/eco/api/microcases/account_excluded.rb +24 -0
- data/lib/eco/api/microcases/append_usergroups.rb +19 -0
- data/lib/eco/api/microcases/core_excluded.rb +20 -0
- data/lib/eco/api/microcases/fix_default_group.rb +34 -0
- data/lib/eco/api/microcases/fix_filter_tags.rb +42 -0
- data/lib/eco/api/microcases/people_cache.rb +17 -0
- data/lib/eco/api/microcases/people_load.rb +59 -0
- data/lib/eco/api/microcases/people_refresh.rb +31 -0
- data/lib/eco/api/microcases/people_search.rb +65 -0
- data/lib/eco/api/microcases/refresh_abilities.rb +19 -0
- data/lib/eco/api/microcases/refresh_default_tag.rb +27 -0
- data/lib/eco/api/microcases/s3upload_targets.rb +39 -0
- data/lib/eco/api/microcases/set_account.rb +20 -0
- data/lib/eco/api/microcases/set_core.rb +18 -0
- data/lib/eco/api/microcases/set_core_with_supervisor.rb +23 -0
- data/lib/eco/api/microcases/set_supervisor.rb +30 -0
- data/lib/eco/api/microcases/strict_search.rb +19 -0
- data/lib/eco/api/microcases/with_each.rb +27 -0
- data/lib/eco/api/microcases/with_each_leaver.rb +24 -0
- data/lib/eco/api/microcases/with_each_present.rb +30 -0
- data/lib/eco/api/microcases/with_each_starter.rb +30 -0
- data/lib/eco/api/microcases/with_each_subordinate.rb +34 -0
- data/lib/eco/api/microcases/with_supervisor.rb +36 -0
- data/lib/eco/api/organization/people.rb +72 -35
- data/lib/eco/api/organization/presets_factory.rb +13 -4
- data/lib/eco/api/organization/presets_reference.json +9 -1
- data/lib/eco/api/organization/presets_values.json +4 -1
- data/lib/eco/api/policies.rb +11 -7
- data/lib/eco/api/session.rb +62 -29
- data/lib/eco/api/session/batch.rb +2 -45
- data/lib/eco/api/session/batch/base_policy.rb +7 -6
- data/lib/eco/api/session/batch/errors.rb +28 -4
- data/lib/eco/api/session/batch/feedback.rb +7 -1
- data/lib/eco/api/session/batch/job.rb +40 -23
- data/lib/eco/api/session/batch/jobs.rb +9 -4
- data/lib/eco/api/session/batch/jobs_groups.rb +1 -1
- data/lib/eco/api/session/batch/request_stats.rb +91 -58
- data/lib/eco/api/session/batch/status.rb +35 -31
- data/lib/eco/api/session/config.rb +106 -44
- data/lib/eco/api/session/config/api.rb +132 -7
- data/lib/eco/api/session/config/apis.rb +24 -25
- data/lib/eco/api/session/config/logger.rb +2 -2
- data/lib/eco/api/session/config/post_launch.rb +1 -1
- data/lib/eco/api/session/config/workflow.rb +8 -7
- data/lib/eco/api/usecases.rb +47 -33
- data/lib/eco/api/usecases/backup/append_usergroups_case.rb +36 -0
- data/lib/eco/api/usecases/backup/create_case.rb +104 -0
- data/lib/eco/api/usecases/backup/create_details_case.rb +31 -0
- data/lib/eco/api/usecases/backup/create_details_with_supervisor_case.rb +48 -0
- data/lib/eco/api/usecases/backup/hris_case.rb +124 -0
- data/lib/eco/api/usecases/backup/set_default_tag_case.rb +49 -0
- data/lib/eco/api/usecases/backup/set_supervisor_case.rb +41 -0
- data/lib/eco/api/usecases/backup/transfer_account_case.rb +90 -0
- data/lib/eco/api/usecases/backup/update_case.rb +112 -0
- data/lib/eco/api/usecases/backup/update_details_case.rb +64 -0
- data/lib/eco/api/usecases/backup/upsert_case.rb +114 -0
- data/lib/eco/api/usecases/base_case.rb +2 -0
- data/lib/eco/api/usecases/base_io.rb +3 -3
- data/lib/eco/api/usecases/default_cases.rb +23 -53
- data/lib/eco/api/usecases/default_cases/append_usergroups_case.rb +10 -31
- data/lib/eco/api/usecases/default_cases/change_email_case.rb +23 -47
- data/lib/eco/api/usecases/default_cases/codes_to_tags_case.rb +56 -43
- data/lib/eco/api/usecases/default_cases/create_case.rb +15 -101
- data/lib/eco/api/usecases/default_cases/create_details_case.rb +11 -26
- data/lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb +12 -43
- data/lib/eco/api/usecases/default_cases/delete_sync_case.rb +11 -0
- data/lib/eco/api/usecases/default_cases/delete_trans_case.rb +14 -0
- data/lib/eco/api/usecases/default_cases/email_as_id_case.rb +10 -21
- data/lib/eco/api/usecases/default_cases/hris_case.rb +23 -120
- data/lib/eco/api/usecases/default_cases/new_email_case.rb +10 -23
- data/lib/eco/api/usecases/default_cases/new_id_case.rb +11 -25
- data/lib/eco/api/usecases/default_cases/new_id_case0.rb +14 -0
- data/lib/eco/api/usecases/default_cases/org_data_convert_case.rb +83 -0
- data/lib/eco/api/usecases/default_cases/refresh_abilities_case.rb +30 -0
- data/lib/eco/api/usecases/default_cases/refresh_case.rb +7 -20
- data/lib/eco/api/usecases/default_cases/reinvite_sync_case.rb +11 -0
- data/lib/eco/api/usecases/default_cases/reinvite_trans_case.rb +17 -0
- data/lib/eco/api/usecases/default_cases/remove_account_sync_case.rb +11 -0
- data/lib/eco/api/usecases/default_cases/remove_account_trans_case.rb +17 -0
- data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +9 -19
- data/lib/eco/api/usecases/default_cases/restore_db_case.rb +92 -0
- data/lib/eco/api/usecases/default_cases/set_default_tag_case.rb +32 -40
- data/lib/eco/api/usecases/default_cases/set_supervisor_case.rb +15 -33
- data/lib/eco/api/usecases/default_cases/switch_supervisor_case.rb +66 -57
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +36 -44
- data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +40 -55
- data/lib/eco/api/usecases/default_cases/transfer_account_case.rb +264 -84
- data/lib/eco/api/usecases/default_cases/update_case.rb +15 -109
- data/lib/eco/api/usecases/default_cases/update_details_case.rb +14 -61
- data/lib/eco/api/usecases/default_cases/upsert_case.rb +16 -111
- data/lib/eco/api/usecases/use_case_io.rb +9 -9
- data/lib/eco/cli/config.rb +10 -2
- data/lib/eco/cli/config/default.rb +2 -1
- data/lib/eco/cli/config/default/input_filters.rb +58 -0
- data/lib/eco/cli/config/default/options.rb +60 -25
- data/lib/eco/cli/config/default/people.rb +4 -4
- data/lib/eco/cli/config/default/people_filters.rb +108 -0
- data/lib/eco/cli/config/default/usecases.rb +69 -32
- data/lib/eco/cli/config/default/workflow.rb +37 -27
- data/lib/eco/cli/config/filters.rb +50 -0
- data/lib/eco/cli/config/filters/input_filters.rb +29 -0
- data/lib/eco/cli/config/filters/people_filters.rb +29 -0
- data/lib/eco/cli/config/help.rb +49 -0
- data/lib/eco/cli/config/options_set.rb +17 -1
- data/lib/eco/cli/config/use_cases.rb +79 -53
- data/lib/eco/cli/scripting.rb +10 -2
- data/lib/eco/cli/scripting/args_helpers.rb +25 -15
- data/lib/eco/cli/scripting/argument.rb +1 -0
- data/lib/eco/cli/scripting/arguments.rb +1 -1
- data/lib/eco/csv.rb +8 -3
- data/lib/eco/csv/table.rb +1 -1
- data/lib/eco/data/crypto/encryption.rb +3 -0
- data/lib/eco/data/files/helpers.rb +6 -1
- data/lib/eco/language/match.rb +19 -9
- data/lib/eco/language/match_modifier.rb +13 -5
- data/lib/eco/language/models/collection.rb +77 -56
- data/lib/eco/language/models/parser_serializer.rb +39 -15
- data/lib/eco/version.rb +1 -1
- metadata +149 -63
- data/lib/eco/api/session/task.rb +0 -175
- data/lib/eco/api/usecases/default_case.rb +0 -19
- data/lib/eco/api/usecases/default_cases/delete_case.rb +0 -32
- data/lib/eco/api/usecases/default_cases/recover_db_case.rb +0 -98
- data/lib/eco/api/usecases/default_cases/refresh_presets_case.rb +0 -26
- data/lib/eco/api/usecases/default_cases/reinvite_case.rb +0 -41
- data/lib/eco/api/usecases/default_cases/remove_account_case.rb +0 -38
- data/lib/eco/cli/config/default/filters.rb +0 -70
- data/lib/eco/cli/config/people_filters.rb +0 -38
@@ -1,12 +1,28 @@
|
|
1
1
|
ASSETS.cli.config do |cnf|
|
2
2
|
cnf.options_set do |options_set, options|
|
3
|
-
|
4
|
-
|
3
|
+
options_set.add("--help", "offers a help") do |options, sesssion|
|
4
|
+
conf = ASSETS.cli.config
|
5
|
+
puts conf.people_filters.help if hpf = SCR.get_arg("-filters")
|
6
|
+
puts conf.input_filters.help if hif = SCR.get_arg("-input-filters")
|
7
|
+
puts conf.options_set.help if ho = SCR.get_arg("-options")
|
8
|
+
puts conf.usecases.help if huc = SCR.get_arg("-usecases")
|
9
|
+
puts [
|
10
|
+
"Please specify one of the below:",
|
11
|
+
" -filters to display available filters on people",
|
12
|
+
" -input-filters to display available filters on input data",
|
13
|
+
" -options to dislpay available options",
|
14
|
+
" -usecases to display available usecases"
|
15
|
+
].join("\n") unless hpf || hif || ho || huc
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
|
19
|
+
desc = "fix the current session to work with this schema"
|
20
|
+
options_set.add("-schema-id", desc) do |options, session|
|
5
21
|
sch_name = SCR.get_arg("-schema-id", with_param: true)
|
6
22
|
sch_id = session.schemas.to_id(sch_name)
|
7
23
|
|
8
24
|
unless sch_id
|
9
|
-
msg = "You need to specify a schema id or name. '#{
|
25
|
+
msg = "You need to specify a correct schema id or name. '#{sch_name}' does not exist"
|
10
26
|
session.logger.error(msg)
|
11
27
|
exit(1)
|
12
28
|
end
|
@@ -17,84 +33,103 @@ ASSETS.cli.config do |cnf|
|
|
17
33
|
session.schema = sch_id
|
18
34
|
end
|
19
35
|
|
20
|
-
|
36
|
+
desc = "deprecated: used to be used to specify the input file when using -get-partial"
|
37
|
+
options_set.add("-entries-from", desc) do |options, session|
|
21
38
|
options.deep_merge!(input: {entries_from: true})
|
22
39
|
end
|
23
40
|
|
24
|
-
|
41
|
+
desc = "locally cache all the people manager by retrieving from the server"
|
42
|
+
options_set.add("-get-people", desc) do |options, session|
|
25
43
|
options.deep_merge!(people: {
|
26
44
|
get: {from: :remote, type: :full}
|
27
45
|
})
|
28
46
|
end
|
29
47
|
|
30
|
-
options_set.add(["-dry-run", "-simulate"]) do |options, session|
|
48
|
+
options_set.add(["-dry-run", "-simulate"], "runs in dry-run (no requests sent to server)") do |options, session|
|
31
49
|
options[:dry_run] = true
|
32
50
|
options[:simulate] = true
|
33
51
|
session.config.dry_run!
|
34
52
|
end
|
35
53
|
|
36
|
-
|
54
|
+
desc = "ignores threshold limitations on requests for this session (skip batch belt)"
|
55
|
+
options_set.add("-skip-batch-policy", desc) do |options|
|
37
56
|
options.deep_merge!(skip: {batch_policy: true})
|
38
57
|
end
|
39
58
|
|
40
|
-
|
59
|
+
desc = "will not run the api policies defined for the enviro"
|
60
|
+
options_set.add("-skip-api-policies", desc) do |options|
|
41
61
|
options.deep_merge!(skip: {api_policies: true})
|
42
62
|
end
|
43
63
|
|
44
|
-
options_set.add("-feed-only-stats") do |options|
|
64
|
+
options_set.add("-feed-only-stats", "shows only stats when giving feedback") do |options|
|
45
65
|
options.deep_merge!(feedback: {only_stats: true})
|
46
66
|
end
|
47
67
|
|
68
|
+
desc = "deprecated: used to be used to avoid reloading people after launch"
|
48
69
|
options[:end_get] = true
|
49
|
-
options_set.add("-no-get") do |options|
|
70
|
+
options_set.add("-no-get", desc) do |options|
|
50
71
|
options[:end_get] = false
|
51
72
|
end
|
52
73
|
|
53
|
-
|
74
|
+
desc = "force search mode to 'strict' when pairing input entries with existing people."
|
75
|
+
desc += " Besides id and external_id it will not try to find by email unless external_id is not specified"
|
76
|
+
options_set.add("-search-strict", desc) do |options|
|
54
77
|
options.deep_merge!(search: {strict: true})
|
55
78
|
end
|
56
|
-
|
57
|
-
|
79
|
+
|
80
|
+
desc = "search mode that will try to find people using email when id and external_id have failed"
|
81
|
+
desc += " This option could identify existing people by their email addresses"
|
82
|
+
desc += " (it should not be used in orgs where multiple people usually have the same email address)"
|
83
|
+
options_set.add("-search-soft", desc) do |options|
|
84
|
+
options.deep_merge!(search: {soft: true, strict: false})
|
58
85
|
end
|
59
86
|
|
60
|
-
|
87
|
+
desc = "silence notifications on account creation or invites"
|
88
|
+
options_set.add(["-no-invites", "-exclude-invites"], desc) do |options|
|
61
89
|
options.merge!(send_invites: false)
|
62
90
|
end
|
63
|
-
|
91
|
+
desc = "people with account will be reinvited if they haven't accepted the invitation"
|
92
|
+
options_set.add("-send-invites", desc) do |options|
|
64
93
|
options.merge!(send_invites: true)
|
65
94
|
end
|
66
95
|
|
67
|
-
options_set.add("-exclude-core") do |options|
|
96
|
+
options_set.add("-exclude-core", "core input data is not used on the update") do |options|
|
68
97
|
options.deep_merge!(exclude: {core: true})
|
69
98
|
end
|
70
|
-
options_set.add("-exclude-filter-tags") do |options|
|
99
|
+
options_set.add("-exclude-filter-tags", "filter_tags is not set with the input data") do |options|
|
71
100
|
options.deep_merge!(exclude: {filter_tags: true})
|
72
101
|
end
|
73
|
-
options_set.add("-exclude-external-id") do |options|
|
102
|
+
options_set.add("-exclude-external-id", "external_id is not set with the input data") do |options|
|
74
103
|
options.deep_merge!(exclude: {external_id: true})
|
75
104
|
end
|
76
|
-
options_set.add("-exclude-supervisor") do |options|
|
105
|
+
options_set.add("-exclude-supervisor", "supervisor_id is not set with the input data") do |options|
|
77
106
|
options.deep_merge!(exclude: {supervisor: true})
|
78
107
|
end
|
79
|
-
options_set.add("-exclude-email") do |options|
|
108
|
+
options_set.add("-exclude-email", "email is not set with the input data") do |options|
|
80
109
|
options.deep_merge!(exclude: {email: true})
|
81
110
|
end
|
82
|
-
options_set.add("-exclude-name") do |options|
|
111
|
+
options_set.add("-exclude-name", "name is not set with the input data") do |options|
|
83
112
|
options.deep_merge!(exclude: {name: true})
|
84
113
|
end
|
85
114
|
|
86
|
-
options_set.add("-exclude-details") do |options|
|
115
|
+
options_set.add("-exclude-details", "details are not set with the input data") do |options|
|
87
116
|
options.deep_merge!(exclude: {details: true})
|
88
117
|
end
|
89
118
|
|
90
|
-
options_set.add("-exclude-account") do |options|
|
119
|
+
options_set.add("-exclude-account", "account is not set with the input data") do |options|
|
91
120
|
options.deep_merge!(exclude: {account: true})
|
92
121
|
end
|
93
|
-
options_set.add("-exclude-policy-groups") do |options|
|
122
|
+
options_set.add("-exclude-policy-groups", "policy_group_ids is not set with the input data") do |options|
|
94
123
|
options.deep_merge!(exclude: {policy_groups: true})
|
95
124
|
end
|
96
|
-
options_set.add("-
|
125
|
+
options_set.add("-default-tag", "default_tag is not set with the input data") do |options|
|
126
|
+
options.deep_merge!(exclude: {default_tag: true})
|
127
|
+
end
|
128
|
+
options_set.add("-exclude-abilities", "permissions_custom is not set with the input data") do |options|
|
97
129
|
options.deep_merge!(exclude: {abilities: true})
|
98
130
|
end
|
131
|
+
options_set.add("-exclude-login-providers", "login_provider_ids is not set with the input data") do |options|
|
132
|
+
options.deep_merge!(exclude: {login_providers: true})
|
133
|
+
end
|
99
134
|
end
|
100
135
|
end
|
@@ -5,7 +5,7 @@ ASSETS.cli.config do |cnf|
|
|
5
5
|
options.deep_merge!(people: {
|
6
6
|
get: {from: :remote, type: :full}
|
7
7
|
})
|
8
|
-
people = session.
|
8
|
+
people = session.micro.people_cache
|
9
9
|
elsif SCR.get_arg("-no-people")
|
10
10
|
people = Eco::API::Organization::People.new([])
|
11
11
|
elsif SCR.get_arg("-people-from-backup")
|
@@ -23,17 +23,17 @@ ASSETS.cli.config do |cnf|
|
|
23
23
|
get: {from: :remote, type: :partial}
|
24
24
|
})
|
25
25
|
|
26
|
-
people = session.
|
26
|
+
people = session.micro.people_search(input, options: options)
|
27
27
|
else
|
28
28
|
options.deep_merge!(people: {
|
29
29
|
get: {from: :local, type: :full}
|
30
30
|
})
|
31
|
-
people = session.
|
31
|
+
people = session.micro.people_load(modifier: [:newest, :save])
|
32
32
|
if people.empty?
|
33
33
|
options.deep_merge!(people: {
|
34
34
|
get: {from: :remote, type: :full}
|
35
35
|
})
|
36
|
-
people = session.
|
36
|
+
people = session.micro.people_cache if people.empty?
|
37
37
|
end
|
38
38
|
end
|
39
39
|
people
|
@@ -0,0 +1,108 @@
|
|
1
|
+
ASSETS.cli.config do |cnf|
|
2
|
+
cnf.people_filters do |filters|
|
3
|
+
|
4
|
+
filters.add("-only-users", "only those with account") do |people, session, options|
|
5
|
+
options.deep_merge!(people: {filter: {account: true}})
|
6
|
+
people.users
|
7
|
+
end
|
8
|
+
|
9
|
+
filters.add("-no-account", "only those with no account") do |people, session, options|
|
10
|
+
options.deep_merge!(people: {filter: {account: false}})
|
11
|
+
people.account_present(false)
|
12
|
+
end
|
13
|
+
|
14
|
+
filters.add("-with-details", "only those with details") do |people, session, options|
|
15
|
+
options.deep_merge!(people: {filter: {details: true}})
|
16
|
+
people.details_present
|
17
|
+
end
|
18
|
+
|
19
|
+
filters.add("-no-id", "only those with no external_id") do |people, session, options|
|
20
|
+
options.deep_merge!(people: {filter: {external_id: nil}})
|
21
|
+
people.external_id_present(false)
|
22
|
+
end
|
23
|
+
|
24
|
+
filters.add("-supervisors", "only those that have subordinates") do |people, session, options|
|
25
|
+
options.deep_merge!(people: {filter: {subordinates: true}})
|
26
|
+
people.newFrom people.to_a.select {|person| person.subordinates > 0}
|
27
|
+
end
|
28
|
+
|
29
|
+
filters.add("-supervisor-id", "only those with certain supervisor") do |people, session, options|
|
30
|
+
id = SCR.get_arg("-supervisor-id", with_param: true)
|
31
|
+
options.deep_merge!(people: {filter: {supervisor_id: id}})
|
32
|
+
unless sup = session.micro.with_supervisor(id, people, strict: true)
|
33
|
+
status = session.batch.search([{"id" => id}])
|
34
|
+
sup = status.people.first
|
35
|
+
end
|
36
|
+
unless sup
|
37
|
+
session.logger.error("Supervisor with id '#{id}' does not exist")
|
38
|
+
exit(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
people.supervisor_id(sup.id)
|
42
|
+
end
|
43
|
+
|
44
|
+
filters.add("-no-default-tag", "only those users with no default tag") do |people, session, options|
|
45
|
+
options.deep_merge!(people: {filter: {account: {default_tag: nil}}})
|
46
|
+
people.users.select do |person|
|
47
|
+
!person.account.default_tag
|
48
|
+
end.yield_self do |filtered|
|
49
|
+
people.newFrom filtered
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
desc = "only those that have ALL the specified tags separated by '|'"
|
54
|
+
filters.add("-filter-tags-all", desc) do |people, session, options|
|
55
|
+
tags = SCR.get_arg("-filter-tags-all", with_param: true).upcase.split("|")
|
56
|
+
options.deep_merge!(input: {filter: {filter_tags: {any: tags}}})
|
57
|
+
people.filter_tags_all(tags).tap do |filtered|
|
58
|
+
msg = "Filtered #{filtered.count} people (out of #{people.count}) with 'all' filter_tags #{tags}"
|
59
|
+
session.logger.info(msg)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc = "only those that have ANY the specified tags separated by '|'"
|
64
|
+
filters.add("-filter-tags-any", desc) do |people, session, options|
|
65
|
+
tags = SCR.get_arg("-filter-tags-any", with_param: true).upcase.split("|")
|
66
|
+
options.deep_merge!(input: {filter: {filter_tags_any: tags}})
|
67
|
+
people.filter_tags_any(tags).tap do |filtered|
|
68
|
+
msg = "Filtered #{filtered.count} people (out of #{people.count}) with 'any' filter_tags #{tags}"
|
69
|
+
session.logger.info(msg)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
desc = "only those that have ANY tag in the specified subtrees separated by '|'"
|
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("|")
|
76
|
+
tags = top_tags.each_with_object([]) do |top, tags|
|
77
|
+
tags.concat(session.tagtree.node(top).tags)
|
78
|
+
end.uniq
|
79
|
+
options.deep_merge!(input: {filter: {filter_tags: {tree: top_tags, any: tags}}})
|
80
|
+
people.filter_tags_any(tags).tap do |filtered|
|
81
|
+
msg = "Filtered #{filtered.count} people (out of #{people.count}) with 'any' filter_tags in subtrees #{top_tags}"
|
82
|
+
session.logger.info(msg)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
filters.add("-schema-id", "only those with the specified schema id or name") do |people, session, options|
|
87
|
+
sch_name = SCR.get_arg("-schema-id", with_param: true)
|
88
|
+
sch_id = session.schemas.to_id(sch_name)
|
89
|
+
|
90
|
+
unless sch_id
|
91
|
+
msg = "You need to specify a correct schema id or name. '#{sch_name}' does not exist"
|
92
|
+
session.logger.error(msg)
|
93
|
+
exit(1)
|
94
|
+
end
|
95
|
+
|
96
|
+
options.deep_merge!(people: {filter: {details: {schema_id: sch_id}}})
|
97
|
+
session.logger.info("Filtering people entries with schema #{session.schemas.to_name(sch_id)}")
|
98
|
+
|
99
|
+
people.select do |person|
|
100
|
+
person.details && (person.details.schema_id == sch_id)
|
101
|
+
end.yield_self do |filtered|
|
102
|
+
session.logger.info("Filtered #{filtered.count} people out of #{people.count} total")
|
103
|
+
people.newFrom filtered
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
ASSETS.cli.config do |cnf|
|
2
2
|
cnf.usecases do |cases|
|
3
3
|
|
4
|
-
|
4
|
+
desc = "It exports to a CSV the (filtered) people"
|
5
|
+
cases.add("-people-to-csv", :export, desc) do |people, session, options|
|
5
6
|
file = SCR.get_file("-people-to-csv", required: true, should_exist: false)
|
6
7
|
options.deep_merge!(export: {file: {name: file, format: :csv}})
|
7
8
|
options.deep_merge!(export: {options: {nice_header: true}}) if SCR.get_arg("-nice-header")
|
@@ -10,7 +11,8 @@ ASSETS.cli.config do |cnf|
|
|
10
11
|
session.usecases.case(case_name)
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
+
desc = "Adds a column 'ecoPortalTag' to the input CSV with the tags that the location codes map to"
|
15
|
+
cases.add("-codes-to-tags-from", :other, desc, case_name: "codes-to-tags-from") do |session, options|
|
14
16
|
file = SCR.get_file("-codes-to-tags-from", required: true, should_exist: true)
|
15
17
|
options.deep_merge!(other: {file: {name: file, format: :csv}})
|
16
18
|
|
@@ -18,16 +20,24 @@ ASSETS.cli.config do |cnf|
|
|
18
20
|
options.deep_merge!(other: {file: {codes_column: col_codes}})
|
19
21
|
end
|
20
22
|
|
21
|
-
|
22
|
-
cases.add("-
|
23
|
-
|
24
|
-
|
25
|
-
cases.add("-
|
26
|
-
|
27
|
-
|
28
|
-
cases.add("-
|
29
|
-
|
30
|
-
|
23
|
+
desc = "Removes the landing page"
|
24
|
+
cases.add("-reset-landing-page", :transform, desc, case_name: "reset-landing-page")
|
25
|
+
|
26
|
+
desc = "Sets as external_id the email of the person"
|
27
|
+
cases.add("-email-as-id", :transform, desc, case_name: "email-as-id")
|
28
|
+
|
29
|
+
desc = "Sets the external_id to the one given in the input CSV"
|
30
|
+
cases.add("-new-id-from", :sync, desc, case_name: "new-id")
|
31
|
+
|
32
|
+
desc = "Sets the email of people. It won't succeed if email taken by any other user in eP"
|
33
|
+
cases.add("-new-email-from", :sync, desc, case_name: "new-email")
|
34
|
+
desc = "Forces a change of email in the same org. It won't succeed if email taken by an org member user"
|
35
|
+
cases.add("-change-email-from", :sync, desc, case_name: "change-email")
|
36
|
+
|
37
|
+
desc = "Sets the supervisor_id"
|
38
|
+
cases.add("-set-supervisor-from", :sync, desc, case_name: "set-supervisor")
|
39
|
+
desc = "Sets to -new-super the supervisor_id of the -old-super's subordinates"
|
40
|
+
cases.add("-switch-supervisor", :transform, desc, case_name: "switch-supervisor") do |people, session, options|
|
31
41
|
unless old_id = SCR.get_arg("-old-super", with_param: true)
|
32
42
|
msg = "You must specify an -old-super to target whose supervisor is changing"
|
33
43
|
session.logger.error(msg)
|
@@ -45,15 +55,10 @@ ASSETS.cli.config do |cnf|
|
|
45
55
|
options.deep_merge!(super: {new: new_id})
|
46
56
|
end
|
47
57
|
|
48
|
-
|
49
|
-
cases.add("-
|
50
|
-
cases.add("-reinvite", :transform, case_name: "reinvite")
|
51
|
-
cases.add("-reinvite-from", :sync, case_name: "reinvite")
|
52
|
-
cases.add("-set-default-tag", :transform, case_name: "set-default-tag")
|
53
|
-
|
54
|
-
cases.add("-recover-db-from", :sync, case_name: "recover-db") do |input, people, session, options|
|
58
|
+
desc = "Restores the people manager by using a backup.json file"
|
59
|
+
cases.add("-restore-db-from", :sync, desc, case_name: "restore-db") do |input, people, session, options|
|
55
60
|
unless input && input.is_a?(Eco::API::Organization::People)
|
56
|
-
file = SCR.get_file("-
|
61
|
+
file = SCR.get_file("-restore-db-from", required: true)
|
57
62
|
input = Eco::API::Organization::People.new(JSON.parse(File.read(file)))
|
58
63
|
session.logger.info("Source DB: loaded #{input.length} entries.")
|
59
64
|
end
|
@@ -62,17 +67,49 @@ ASSETS.cli.config do |cnf|
|
|
62
67
|
options.deep_merge!(include: {create: true}) if SCR.get_arg("-include-create")
|
63
68
|
end
|
64
69
|
|
65
|
-
|
66
|
-
cases.add("-
|
67
|
-
|
68
|
-
cases.add("-
|
69
|
-
|
70
|
-
|
71
|
-
cases.add("-
|
72
|
-
|
73
|
-
cases.add("-delete", :
|
74
|
-
|
75
|
-
cases.add("-
|
76
|
-
|
70
|
+
desc = "Re-sends invites to all filtered users that have not accepted the invite as yet"
|
71
|
+
cases.add("-reinvite", :transform, desc, case_name: "reinvite")
|
72
|
+
desc = "Re-sends invites to target users that have not accepted the invite as yet"
|
73
|
+
cases.add("-reinvite-from", :sync, desc, case_name: "reinvite")
|
74
|
+
|
75
|
+
desc = "Deletes everybody that has been filtered from the people manager"
|
76
|
+
cases.add("-delete", :transform, desc, case_name: "delete")
|
77
|
+
desc = "Deletes the people specified in the input data"
|
78
|
+
cases.add("-delete-from", :sync, desc, case_name: "delete")
|
79
|
+
desc = "Removes the account of everybody that has been filtered from the people manager"
|
80
|
+
cases.add("-remove-account", :transform, desc, case_name: "remove-account")
|
81
|
+
desc = "Removes the people specified in the input data"
|
82
|
+
cases.add("-remove-account-from", :sync, desc, case_name: "remove-account")
|
83
|
+
|
84
|
+
desc = "Re-freshes the default_tag of users"
|
85
|
+
cases.add("-set-default-tag", :transform, desc, case_name: "set-default-tag")
|
86
|
+
|
87
|
+
desc = "Creates people with with details and account"
|
88
|
+
cases.add("-create-from", :sync, desc, case_name: "create")
|
89
|
+
desc = "Creates people with only details"
|
90
|
+
cases.add("-create-details-from", :sync, desc, case_name: "create-details")
|
91
|
+
|
92
|
+
desc = "It just adds everybody to an update job without doing any change. If the org has policies, it will refresh"
|
93
|
+
cases.add("-refresh", :transform, desc, case_name: "refresh")
|
94
|
+
desc = "Remaps the abilities of every user based on their usergroups mappings thereof in the org api configuration"
|
95
|
+
cases.add("-refresh-abilities", :transform, desc, case_name: "refresh-abilities")
|
96
|
+
|
97
|
+
desc = "Updates details and core (including supervisor) to target people"
|
98
|
+
cases.add("-update-details-from", :sync, desc, case_name: "update-details")
|
99
|
+
|
100
|
+
desc = "Appends the policy_group_ids column to the people with account specified in the input data"
|
101
|
+
cases.add("-append-usergroups-from", :sync, desc, case_name: "append-usergroups")
|
102
|
+
desc = "Updates the people specified in the input data"
|
103
|
+
cases.add("-update-from", :sync, desc, case_name: "update")
|
104
|
+
|
105
|
+
desc = "Does an actual transfer of user from id|external_id account to 'destination-id' person"
|
106
|
+
cases.add("-transfer-account-from", :sync, desc, case_name: "transfer-account") do |input, people, session, options|
|
107
|
+
options.deep_merge!(include: {email: SCR.get_arg("-include-email")})
|
108
|
+
end
|
109
|
+
|
110
|
+
desc = "Tries to find the input entries and update them. It creates them if not found"
|
111
|
+
cases.add("-upsert-from", :sync, desc, case_name: "upsert")
|
112
|
+
desc = "It does like -upsert-from and additionally removes account and supervisor of those in people that are not in the entries (leavers)"
|
113
|
+
cases.add("-hris-from", :sync, desc, case_name: "hris")
|
77
114
|
end
|
78
115
|
end
|
@@ -4,7 +4,7 @@ ASSETS.cli.config do |config|
|
|
4
4
|
io = nil
|
5
5
|
# default rescue
|
6
6
|
wf.rescue do |exception, io|
|
7
|
-
io.session.logger.
|
7
|
+
io.session.logger.debug(exception.patch_full_message)
|
8
8
|
wf.run(:close, io: io)
|
9
9
|
io
|
10
10
|
end
|
@@ -14,38 +14,42 @@ ASSETS.cli.config do |config|
|
|
14
14
|
end
|
15
15
|
|
16
16
|
wf.for(:load) do |wf_load|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
wf_load.for(:input) do |wf_input|
|
18
|
+
wf_input.on(:get) do |wf_input_get, io|
|
19
|
+
cases_with_input = config.usecases.active(io: io).select do |usecase, data|
|
20
|
+
io.class.input_required?(usecase.type)
|
21
|
+
end
|
22
|
+
next io unless (!io.input || io.input.empty?) && !cases_with_input.empty?
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
if io.options.dig(:input, :entries_from)
|
25
|
+
io = io.new(input: config.input.get(io: io))
|
26
|
+
else
|
27
|
+
opt_case = cases_with_input.values.first[:option]
|
28
|
+
io = io.new(input: config.input.get(io: io, option: opt_case))
|
29
|
+
end
|
30
|
+
io
|
24
31
|
end
|
25
32
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
io = io.new(input: config.input.get(io: io))
|
30
|
-
else
|
31
|
-
opt_case = cases_with_input.values.first[:option]
|
32
|
-
io = io.new(input: config.input.get(io: io, option: opt_case))
|
33
|
+
wf_input.on(:filter) do |wf_input_filter, io|
|
34
|
+
next io unless io.input && !io.input.empty?
|
35
|
+
io = io.new(input: config.input_filters.process(io: io))
|
33
36
|
end
|
34
|
-
io
|
35
37
|
end
|
36
38
|
|
37
|
-
wf_load.
|
38
|
-
|
39
|
-
|
39
|
+
wf_load.for(:people) do |wf_people|
|
40
|
+
wf_people.on(:get) do |wf_people_get, io|
|
41
|
+
cases_with_people = config.usecases.active(io: io).select do |usecase, data|
|
42
|
+
io.class.people_required?(usecase.type)
|
43
|
+
end
|
44
|
+
get_people = io.options.dig(:people, :get, :from) == :remote
|
45
|
+
next io unless !cases_with_people.empty? || get_people
|
46
|
+
io = io.new(people: config.people(io: io))
|
40
47
|
end
|
41
|
-
get_people = io.options.dig(:people, :get, :from) == :remote
|
42
|
-
next io unless !cases_with_people.empty? || get_people
|
43
|
-
io = io.new(people: config.people(io: io))
|
44
|
-
end
|
45
48
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
+
wf_people.on(:filter) do |wf_people_filter, io|
|
50
|
+
next io unless io.people && !io.people.empty?
|
51
|
+
io = io.new(people: config.people_filters.process(io: io))
|
52
|
+
end
|
49
53
|
end
|
50
54
|
end
|
51
55
|
|
@@ -85,7 +89,7 @@ ASSETS.cli.config do |config|
|
|
85
89
|
partial_update = io.options.dig(:people, :get, :type) == :partial
|
86
90
|
if !io.options[:dry_run] && partial_update
|
87
91
|
# get target people afresh
|
88
|
-
people = io.session.
|
92
|
+
people = io.session.micro.people_refresh(people: io.people, include_created: true)
|
89
93
|
io = io.new(people: people)
|
90
94
|
else
|
91
95
|
wf_post.skip!
|
@@ -116,10 +120,16 @@ ASSETS.cli.config do |config|
|
|
116
120
|
end
|
117
121
|
end
|
118
122
|
|
123
|
+
wf.on(:report) do |wf_report, io|
|
124
|
+
#config.reports.active(io: io)
|
125
|
+
#io.session.reports
|
126
|
+
io
|
127
|
+
end
|
128
|
+
|
119
129
|
wf.on(:end) do |wf_end, io|
|
120
130
|
partial_update = io.options.dig(:people, :get, :type) == :partial
|
121
131
|
unless !io.options[:end_get] || io.options[:dry_run] || partial_update
|
122
|
-
people = io.session.
|
132
|
+
people = io.session.micro.people_cache
|
123
133
|
io = io.new(people: people)
|
124
134
|
end
|
125
135
|
io
|