Sha256: 353461beeef085d0adb3ed26bd3959094a09b3911dbb313fde7cd7fed84b6169

Contents?: true

Size: 806 Bytes

Versions: 6

Compression:

Stored size: 806 Bytes

Contents

module Ogre
  # Delete organization through Chef::REST object
  class OrgDelete < Ogre::Base
    include Thor::Actions

    # required
    argument :org, type: :string, desc: DESC_ORG

    class_option :force, aliases: '-f', default: false, type: :boolean, desc: DESC_FORCE

    # Organization delete
    def org_delete
      # prompt user
      exit unless options[:force] || HighLine.agree("Deleting '#{org}' is permanent. Do you want to proceed? (y/n)")

      begin
        chef_rest.delete_rest("/organizations/#{org}")
        puts "'#{org}' org has been deleted."
      rescue Net::HTTPServerException => e
        # does not exist, exit gracefully
        if e.response.code == '404'
          puts "#{org} org does not exist"
        else
          raise e
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ogre-0.1.5 lib/ogre/org-delete.rb
ogre-0.1.4 lib/ogre/org-delete.rb
ogre-0.1.3 lib/ogre/org-delete.rb
ogre-0.1.2 lib/ogre/org-delete.rb
ogre-0.1.1 lib/ogre/org-delete.rb
ogre-0.1.0 lib/ogre/org-delete.rb