Module: StackFu::ProvidersCredentials

Included in:
Commands::ConfigCommand
Defined in:
lib/stackfu/helpers/providers_credentials.rb

Instance Method Summary collapse

Instance Method Details

#add_slicehost_credentials(user) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/stackfu/helpers/providers_credentials.rb', line 47

def add_slicehost_credentials(user)
  while true
    puts ""
    puts "Enter your Slicehost API password (or type 'help' for more information or 'abort' to abort): "

    token = ask("")
  
    unless ['help', 'abort'].include? token.downcase
      user.settings.slicehost_token = token
      if user.save
        puts ""
        puts "Slicehost credentials saved."
      else
        puts "Error: #{user.errors.full_messages.to_s}"
      end
      return true
    end

    if token.downcase == 'abort'
      puts ""
      puts "Aborted adding server."
      return false
    else
      puts ""
      puts "== Slicehost StackFu integration ==".foreground(:green).bright
      puts ""
      puts "In order to allow StackFu to integrate itself with Slicehost, you need to enabled your API Access and provide us your API Password."
      puts ""
      puts "This can be easily done by visiting your '#{"Account > API Access".foreground(:cyan)}' area in Slicehost manager."
      puts ""
      puts "If you need further information, visit #{"http://stackfu.com/faq/slicehost-api-integration".underline} for a complete walkthrough of this process."
    end
  end
end

#add_webbynode_credentials(user) ⇒ Object



3
4
5
6
7
8
9
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
37
38
39
40
41
42
43
44
45
# File 'lib/stackfu/helpers/providers_credentials.rb', line 3

def add_webbynode_credentials(user)
  while true
    puts ""
    puts "Enter your Webbynode API credentials below (or type 'help' for more information or 'abort' to abort)"

     = ask("Webbynode Login:")
  
    unless .try(:downcase) == "abort" or .try(:downcase) == "help"
      token = ask("Webbynode Token:")
    end
  
    credentials = [ || "", token || ""].map(&:downcase)
  
    if credentials.include?('help')
      puts ""
      puts "== Webbynode StackFu integration ==".foreground(:green).bright
      puts ""
      puts "In order to allow StackFu to integrate itself with Webbynode, you need to provide the email address you use to login into Webbynode Manager and your API token."
      puts ""
      puts "This can be easily done by visiting your '#{"Account".foreground(:cyan)}' area in Webbynode Manager. On the box where your summary is presented, copy the 'API Token:' field content."
      puts ""
      puts "If you need further information, visit #{"http://stackfu.com/faq/webbynode-api-integration".underline} for a complete walkthrough of this process."

    elsif credentials.include?('abort')
    
      puts "Aborted adding server."
      return false

    else
      user.settings. = 
      user.settings.webbynode_token = token
    
      if user.save
        puts ""
        puts "Webbynode credentials saved."
      else
        puts "Error: #{user.errors.full_messages.to_s}"
      end
    
      return true          
    end
  end
end