Class: BBGAPI::LB_Services
- Inherits:
-
Object
- Object
- BBGAPI::LB_Services
- Defined in:
- lib/bbgapi/lb_services.rb
Class Method Summary collapse
- .create ⇒ Object
- .delete ⇒ Object
- .delete_confirm(name, id) ⇒ Object
- .get_service ⇒ Object
- .haproxyinfo ⇒ Object
- .list ⇒ Object
- .menulist ⇒ Object
- .only_name_id ⇒ Object
- .raw ⇒ Object
- .recurse ⇒ Object
- .set_service(serviceid = "") ⇒ Object
- .tbi ⇒ Object
Class Method Details
.create ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/bbgapi/lb_services.rb', line 62 def self.create begin cur_app = BBGAPI::LB_Applications.get_app rescue cur_app = self.recurse end choose do || .prompt = "HTTP or HTTPS?" .choices(:http) {service_type="http"} .choices(:https) {service_type="https"} end = { :body => { :service_type => service_type } } partial = "/api/lb_applications/#{cur_app}/lb_services" api_response = BBGAPI::Client.posturl(partial,) pp api_response #puts "Name: #{api_response["name"]}" puts "\n" end |
.delete ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/bbgapi/lb_services.rb', line 87 def self.delete raw_services = self.raw choose do || .prompt = "Which Service To Delete?" raw_services.each {|service| .choices(service["name"]) {self.delete_confirm(service["name"],service["id"])} } end end |
.delete_confirm(name, id) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/bbgapi/lb_services.rb', line 97 def self.delete_confirm(name,id) begin cur_app = BBGAPI::LB_Applications.get_app rescue cur_app = self.recurse end choose do || .prompt = "Are you sure you want to delete service #{name}?" .choices(:yes) { partial = "/api/lb_applications/#{cur_app}/lb_services/#{id}" api_response = BBGAPI::Client.deleteurl(partial) pp api_response } .choices(:no) end end |
.get_service ⇒ Object
16 17 18 |
# File 'lib/bbgapi/lb_services.rb', line 16 def self.get_service return @@current_service end |
.haproxyinfo ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/bbgapi/lb_services.rb', line 144 def self. begin cur_app = BBGAPI::LB_Applications.get_app rescue cur_app = self.recurse end partial = "/api/lb_applications/#{cur_app}/lb_services" api_response = BBGAPI::Client.geturl(partial,"") haproxy = [] api_response.each {|x| haproxy << {"name" => "#{x["name"]}","status_url" => "#{x["status_url"]}","status_username" => "#{x["status_username"]}","status_password" => "#{x["status_password"]}"} } return haproxy end |
.list ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/bbgapi/lb_services.rb', line 38 def self.list begin cur_app = BBGAPI::LB_Applications.get_app rescue cur_app = self.recurse end partial = "/api/lb_applications/#{cur_app}/lb_services" api_response = BBGAPI::Client.geturl(partial,"") api_response.each {|x| puts "\n" puts "Name: #{x["name"]}" puts "ID: #{x["id"]}" puts "Description: #{x["description"]}" puts "Port: #{x["port"]}" puts "Service Type: #{x["service_type"]}" puts "Status URL: #{x["status_url"]}" puts "Status User: #{x["status_username"]}" puts "Status Pass: #{x["status_password"]}" puts "Created: #{x["created"]}" } puts "\n" end |
.menulist ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/bbgapi/lb_services.rb', line 4 def self. choose do || puts "Load Balancer Services" puts "----------------------------------------" .prompt = "Which Action?" .choices(:list) {self.list} .choices(:create) {self.tbi} .choices(:update) {self.tbi} .choices(:delete) {self.tbi} end end |
.only_name_id ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/bbgapi/lb_services.rb', line 115 def self.only_name_id begin cur_app = BBGAPI::LB_Applications.get_app rescue cur_app = self.recurse end partial = "/api/lb_applications/#{cur_app}/lb_services" api_response = BBGAPI::Client.geturl(partial,"") services = [] api_response.each {|x| services << {"name" => "#{x["name"]}","id" => "#{x["id"]}"} } return services end |
.raw ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/bbgapi/lb_services.rb', line 131 def self.raw begin cur_app = BBGAPI::LB_Applications.get_app rescue cur_app = self.recurse end partial = "/api/lb_applications/#{cur_app}/lb_services" api_response = BBGAPI::Client.geturl(partial,"") return api_response end |
.recurse ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bbgapi/lb_services.rb', line 24 def self.recurse apps = BBGAPI::LB_Applications.only_name_id choose do || .prompt = "Which Application?" apps.each {|k| .choices(k["name"]) { BBGAPI::LB_Applications.set_app(k["id"]) cur_app = k["id"] } } end return BBGAPI::LB_Applications.get_app end |
.set_service(serviceid = "") ⇒ Object
20 21 22 |
# File 'lib/bbgapi/lb_services.rb', line 20 def self.set_service (serviceid="") @@current_service = serviceid end |
.tbi ⇒ Object
160 161 162 |
# File 'lib/bbgapi/lb_services.rb', line 160 def self.tbi puts "This is not yet implemented" end |