Sha256: 42061b4502d99d9b2556a9898e3506a1de41c6cfca04a46999981ad1b4294476
Contents?: true
Size: 1.14 KB
Versions: 6
Compression:
Stored size: 1.14 KB
Contents
module Ogre # This is used to delete a user from enterprise chef class UserDelete < Ogre::Base include Thor::Actions # required argument :username, type: :string # optional class_option :force, aliases: '-f', default: false, type: :boolean, desc: DESC_FORCE # Delete user from enterprise chef def user_delete # prompt user # rubocop:disable LineLength exit unless options[: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_rest("users/#{username}/organizations") org_names = orgs.map { |o| o['organization']['name'] } org_names.each do |org| puts chef_rest.delete_rest("organizations/#{org}/users/#{username}") end # delete user chef_rest.delete_rest("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 end end
Version data entries
6 entries across 6 versions & 1 rubygems