Class: Ogre::UserDelete
- Includes:
- Thor::Actions
- Defined in:
- lib/ogre/user-delete.rb
Overview
This is used to delete a user from enterprise chef
Instance Method Summary collapse
-
#user_delete ⇒ Object
Delete user from enterprise chef.
Methods inherited from Base
Instance Method Details
#user_delete ⇒ Object
Delete user from enterprise chef
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ogre/user-delete.rb', line 13 def user_delete # prompt user # rubocop:disable LineLength exit unless [:force] || HighLine.agree("Deleting '#{username}' is permanent. Do you want to proceed? (y/n)") # rubocop:enable LineLength # disassociate from all orgs orgs = chef_rest.get("users/#{username}/organizations") org_names = orgs.map { |o| o['organization']['name'] } org_names.each do |org| puts chef_rest.delete("organizations/#{org}/users/#{username}") end # delete user chef_rest.delete("users/#{username}") puts "'#{username}' has been deleted." rescue Net::HTTPServerException => e # user not found -- i will allow it if e.response.code == '404' puts "'#{username}' not found." else raise e end end |