Class: BBGAPI::LB_Applications
- Inherits:
-
Object
- Object
- BBGAPI::LB_Applications
- Defined in:
- lib/bbgapi/lb_applications.rb
Class Method Summary collapse
- .create ⇒ Object
- .delete ⇒ Object
- .delete_confirm(name, id) ⇒ Object
- .get_app ⇒ Object
- .list ⇒ Object
- .menulist ⇒ Object
- .only_name_id ⇒ Object
- .raw ⇒ Object
- .set_app(appid = "") ⇒ Object
- .tbi ⇒ Object
Class Method Details
.create ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bbgapi/lb_applications.rb', line 35 def self.create app_name = ask("Specify a name for the new app: ") = { :body => { :name => app_name } } partial = '/api/lb_applications' api_response = BBGAPI::Client.posturl(partial,) puts "App Created!" puts "Name: #{api_response["name"]}" puts "ID: #{api_response["id"]}" puts "External IP: #{api_response["ip_v4"]}" puts "Internal IP: #{api_response["source_ip"]}" end |
.delete ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/bbgapi/lb_applications.rb', line 49 def self.delete raw_apps = self.raw choose do || .prompt = "Which App To Delete?" raw_apps.each {|app| .choices(app["name"]) {self.delete_confirm(app["name"],app["id"])} } end end |
.delete_confirm(name, id) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/bbgapi/lb_applications.rb', line 59 def self.delete_confirm(name,id) choose do || .prompt = "Are you sure you want to delete app #{name}?" .choices(:yes) { partial = "/api/lb_applications/#{id}" api_response = BBGAPI::Client.deleteurl(partial) pp api_response } .choices(:no) end end |
.get_app ⇒ Object
73 74 75 |
# File 'lib/bbgapi/lb_applications.rb', line 73 def self.get_app return @@current_app end |
.list ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bbgapi/lb_applications.rb', line 18 def self.list partial = '/api/lb_applications' api_response = BBGAPI::Client.geturl(partial,"") apps = [] api_response.each {|x| apps << {"name" => "#{x["name"]}","id" => "#{x["id"]}"} puts "\n" puts "Name: #{x["name"]}" puts "ID: #{x["id"]}" puts "Description: #{x["description"]}" puts "External IP: #{x["ip_v4"]}" puts "Internal IP: #{x["source_ip_v4"]}" puts "Created: #{x["created"]}" } puts "\n" end |
.menulist ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/bbgapi/lb_applications.rb', line 5 def self. choose do || puts "Load Balancer Applications" puts "----------------------------------------" .prompt = "Which Action?" .choices(:list) {self.list} .choices(:create) {self.create} .choices(:update) {self.tbi} .choices(:delete) {self.delete} end end |
.only_name_id ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/bbgapi/lb_applications.rb', line 87 def self.only_name_id partial = '/api/lb_applications' api_response = BBGAPI::Client.geturl(partial,"") apps = [] api_response.each {|x| apps << {"name" => "#{x["name"]}","id" => "#{x["id"]}"} } return apps end |
.raw ⇒ Object
81 82 83 84 85 |
# File 'lib/bbgapi/lb_applications.rb', line 81 def self.raw partial = '/api/lb_applications' api_response = BBGAPI::Client.geturl(partial,"") return api_response end |
.set_app(appid = "") ⇒ Object
77 78 79 |
# File 'lib/bbgapi/lb_applications.rb', line 77 def self.set_app (appid="") @@current_app = appid end |
.tbi ⇒ Object
97 98 99 |
# File 'lib/bbgapi/lb_applications.rb', line 97 def self.tbi puts "This is not yet implemented" end |