Class: JDC::Cli::Command::Admin

Inherits:
Base show all
Defined in:
lib/cli/commands/admin.rb

Constant Summary

Constants inherited from Base

Base::MANIFEST

Instance Attribute Summary

Attributes inherited from Base

#no_prompt, #prompt_ok

Instance Method Summary collapse

Methods inherited from Base

#auth_token, #client, #client_info, #find_in_hash, #find_symbol, #frameworks_info, #initialize, #load_manifest, #load_manifest_structure, #manifest, #manifest_file, #merge_manifest, #merge_parent, #resolve_in, #resolve_lexically, #resolve_manifest, #resolve_symbol, #runtimes_info, #target_base, #target_url

Constructor Details

This class inherits a constructor from JDC::Cli::Command::Base

Instance Method Details

#delete_user(user_email) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/cli/commands/admin.rb', line 24

def delete_user(user_email)
  # Check to make sure all apps and services are deleted before deleting the user
  # implicit proxying

  client.proxy_for(user_email)
  @options[:proxy] = user_email
  apps = client.apps

  if (apps && !apps.empty?)
    unless no_prompt
      proceed = ask(
        "\nDeployed applications and associated services will be DELETED, continue?",
        :default => false
      )
      err "Aborted" unless proceed
    end
    cmd = Apps.new(@options.merge({ :force => true }))
    apps.each { |app| cmd.delete(app[:name]) }
  end

  services = client.services
  if (services && !services.empty?)
    cmd = Services.new(@options)
    services.each { |s| cmd.delete_service(s[:name])}
  end

  display 'Deleting User: ', false
  client.proxy = nil
  client.delete_user(user_email)
  display 'OK'.green
end

#list_usersObject Also known as: users



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cli/commands/admin.rb', line 5

def list_users
  users = client.users
  users.sort! {|a, b| a[:email] <=> b[:email] }
  return display JSON.pretty_generate(users || []) if @options[:json]

  display "\n"
  return display "No Users" if users.nil? || users.empty?

  users_table = table do |t|
    t.headings = 'Email', 'Admin', 'Apps'
    users.each do |user|
      t << [user[:email], user[:admin], user[:apps].map {|x| x[:name]}.join(', ')]
    end
  end
  display users_table
end