lib/eco/cli/config/default/usecases.rb in eco-helpers-1.5.1 vs lib/eco/cli/config/default/usecases.rb in eco-helpers-1.5.2

- old
+ new

@@ -1,35 +1,45 @@ ASSETS.cli.config do |cnf| cnf.usecases do |cases| - cases.add("-people-to-csv", :export) do |people, session, options| + desc = "It exports to a CSV the (filtered) people" + cases.add("-people-to-csv", :export, desc) do |people, session, options| file = SCR.get_file("-people-to-csv", required: true, should_exist: false) options.deep_merge!(export: {file: {name: file, format: :csv}}) options.deep_merge!(export: {options: {nice_header: true}}) if SCR.get_arg("-nice-header") case_name = SCR.get_arg("-detailed")? "to-csv-detailed" : "to-csv" session.usecases.case(case_name) end - cases.add("-codes-to-tags-from", :other, case_name: "codes-to-tags-from") do |session, options| + desc = "Adds a column 'ecoPortalTag' to the input CSV with the tags that the location codes map to" + cases.add("-codes-to-tags-from", :other, desc, case_name: "codes-to-tags-from") do |session, options| file = SCR.get_file("-codes-to-tags-from", required: true, should_exist: true) options.deep_merge!(other: {file: {name: file, format: :csv}}) col_codes = SCR.get_arg("-column", with_param: true) options.deep_merge!(other: {file: {codes_column: col_codes}}) end - cases.add("-reset-landing-page", :transform, case_name: "reset-landing-page") - cases.add("-email-as-id", :transform, case_name: "email-as-id") - cases.add("-new-id-from", :sync, case_name: "new-id") - # won't succeed if some other user with that email in all eP - cases.add("-new-email-from", :sync, case_name: "new-email") - # forces the change of email no matter what, - # unless some other user with that email in the same organization - cases.add("-change-email-from", :sync, case_name: "change-email") - cases.add("-set-supervisor-from", :sync, case_name: "set-supervisor") - cases.add("-switch-supervisor", :transform, case_name: "switch-supervisor") do |people, session, options| + desc = "Removes the landing page" + cases.add("-reset-landing-page", :transform, desc, case_name: "reset-landing-page") + + desc = "Sets as external_id the email of the person" + cases.add("-email-as-id", :transform, desc, case_name: "email-as-id") + + desc = "Sets the external_id to the one given in the input CSV" + cases.add("-new-id-from", :sync, desc, case_name: "new-id") + + desc = "Sets the email of people. It won't succeed if email taken by any other user in eP" + cases.add("-new-email-from", :sync, desc, case_name: "new-email") + desc = "Forces a change of email in the same org. It won't succeed if email taken by an org member user" + cases.add("-change-email-from", :sync, desc, case_name: "change-email") + + desc = "Sets the supervisor_id" + cases.add("-set-supervisor-from", :sync, desc, case_name: "set-supervisor") + desc = "Sets to -new-super the supervisor_id of the -old-super's subordinates" + cases.add("-switch-supervisor", :transform, desc, case_name: "switch-supervisor") do |people, session, options| unless old_id = SCR.get_arg("-old-super", with_param: true) msg = "You must specify an -old-super to target whose supervisor is changing" session.logger.error(msg) exit(1) end @@ -43,36 +53,63 @@ end new_id = new_id == "nil"? nil : new_id options.deep_merge!(super: {new: new_id}) end - cases.add("-create-details-from", :sync, case_name: "create-details") - cases.add("-update-details-from", :sync, case_name: "update-details") - cases.add("-reinvite", :transform, case_name: "reinvite") - cases.add("-reinvite-from", :sync, case_name: "reinvite") - cases.add("-set-default-tag", :transform, case_name: "set-default-tag") - - cases.add("-recover-db-from", :sync, case_name: "recover-db") do |input, people, session, options| + desc = "Restores the people manager by using a backup.json file" + cases.add("-restore-db-from", :sync, desc, case_name: "restore-db") do |input, people, session, options| unless input && input.is_a?(Eco::API::Organization::People) - file = SCR.get_file("-recover-db-from", required: true) + file = SCR.get_file("-restore-db-from", required: true) input = Eco::API::Organization::People.new(JSON.parse(File.read(file))) session.logger.info("Source DB: loaded #{input.length} entries.") end options.deep_merge!(include: {delete: true}) if SCR.get_arg("-include-delete") options.deep_merge!(include: {create: true}) if SCR.get_arg("-include-create") end - cases.add("-create-from", :sync, case_name: "create") - cases.add("-append-usergroups-from", :sync, case_name: "append-usergroups") - cases.add("-update-from", :sync, case_name: "update") - cases.add("-refresh", :transform, case_name: "refresh") - cases.add("-refresh-presets", :transform, case_name: "refresh-presets") - cases.add("-transfer-account-from", :sync, case_name: "transfer-account") - cases.add("-remove-account", :transform, case_name: "remove-account") - cases.add("-remove-account-from", :sync, case_name: "remove-account") - cases.add("-delete", :transform, case_name: "delete") - cases.add("-delete-from", :sync, case_name: "delete") - cases.add("-upsert-from", :sync, case_name: "upsert") - cases.add("-hris-from", :sync, case_name: "hris") + desc = "Re-sends invites to all filtered users that have not accepted the invite as yet" + cases.add("-reinvite", :transform, desc, case_name: "reinvite") + desc = "Re-sends invites to target users that have not accepted the invite as yet" + cases.add("-reinvite-from", :sync, desc, case_name: "reinvite") + + desc = "Deletes everybody that has been filtered from the people manager" + cases.add("-delete", :transform, desc, case_name: "delete") + desc = "Deletes the people specified in the input data" + cases.add("-delete-from", :sync, desc, case_name: "delete") + desc = "Removes the account of everybody that has been filtered from the people manager" + cases.add("-remove-account", :transform, desc, case_name: "remove-account") + desc = "Removes the people specified in the input data" + cases.add("-remove-account-from", :sync, desc, case_name: "remove-account") + + desc = "Re-freshes the default_tag of users" + cases.add("-set-default-tag", :transform, desc, case_name: "set-default-tag") + + desc = "Creates people with with details and account" + cases.add("-create-from", :sync, desc, case_name: "create") + desc = "Creates people with only details" + cases.add("-create-details-from", :sync, desc, case_name: "create-details") + + desc = "It just adds everybody to an update job without doing any change. If the org has policies, it will refresh" + cases.add("-refresh", :transform, desc, case_name: "refresh") + desc = "Remaps the abilities of every user based on their usergroups mappings thereof in the org api configuration" + cases.add("-refresh-abilities", :transform, desc, case_name: "refresh-abilities") + + desc = "Updates details and core (including supervisor) to target people" + cases.add("-update-details-from", :sync, desc, case_name: "update-details") + + desc = "Appends the policy_group_ids column to the people with account specified in the input data" + cases.add("-append-usergroups-from", :sync, desc, case_name: "append-usergroups") + desc = "Updates the people specified in the input data" + cases.add("-update-from", :sync, desc, case_name: "update") + + desc = "Does an actual transfer of user from id|external_id account to 'destination-id' person" + cases.add("-transfer-account-from", :sync, desc, case_name: "transfer-account") do |input, people, session, options| + options.deep_merge!(include: {email: SCR.get_arg("-include-email")}) + end + + desc = "Tries to find the input entries and update them. It creates them if not found" + cases.add("-upsert-from", :sync, desc, case_name: "upsert") + desc = "It does like -upsert-from and additionally removes account and supervisor of those in people that are not in the entries (leavers)" + cases.add("-hris-from", :sync, desc, case_name: "hris") end end