Class: Ogre::OrgShow

Inherits:
Base
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/ogre/org-show.rb

Overview

Show org through Chef::REST object

Instance Method Summary collapse

Methods inherited from Base

#chef_rest

Instance Method Details

#org_showObject

Show org details



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ogre/org-show.rb', line 10

def org_show
  # get org details
  results = chef_rest.get("/organizations/#{org}")
  puts colorize('name:') + "         #{results['name']}"
  puts colorize('description:') + "  #{results['full_name']}"
  puts colorize('guid:') + "         #{results['guid']}"

  # get admins
  admins = chef_rest.get("/organizations/#{org}/groups/admins")

  # get normal users
  users = chef_rest.get("/organizations/#{org}/groups/users")

  # output admins with a '@' prefix
  admins['users'].each do |admin|
    if admins['users'][0] == admin
      puts colorize('users') + "         @#{admin}"
    else
      puts "              @#{admin}"
    end
  end

  # output users that don't exist in the admin group
  (users['users'] - admins['users']).each do |user|
    puts "              #{user}"
  end
end