Class: BBGAPI::Blocks_Templates
- Inherits:
-
Object
- Object
- BBGAPI::Blocks_Templates
- Defined in:
- lib/bbgapi/blocks_templates.rb
Class Method Summary collapse
Class Method Details
.blocksmenu ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/bbgapi/blocks_templates.rb', line 44 def self. choose do || .prompt = "Are you templating a VPS or a Block?" .choices(:vps) { vpslist = BBGAPI::Servers.raw choose do || .prompt = "Which VPS?" vpslist.each {|vps| .choices(vps["hostname"]) {return vps["id"]} } end } .choices(:block) { vpslist = BBGAPI::Blocks.raw choose do || .prompt = "Which Block?" vpslist.each {|vps| .choices(vps["hostname"]) {return vps["id"]} } end } end end |
.create ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/bbgapi/blocks_templates.rb', line 69 def self.create blockid = self. = { :body => { :id => blockid } } partial = '/api/block_templates' api_response = BBGAPI::Client.posturl(partial,) puts "#{api_response["text"]}" end |
.list ⇒ Object
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 |
# File 'lib/bbgapi/blocks_templates.rb', line 16 def self.list partial = '/api/block_templates' api_response = BBGAPI::Client.geturl(partial,"") srv = api_response.find_all{|item| !item["public"] } sorted = srv.sort_by {|a| a["created"]}.reverse puts "Last 10 Images:" sorted.each_with_index {|x,i| break if i == 10; puts "#{x["description"]} - #{x["id"]}" } puts "\n" pubsrv = api_response.find_all{|item| item["public"] } pubsorted = pubsrv.sort_by {|a| a["description"]} puts "Public Images (limit 10):" pubsorted.each_with_index {|x,i| break if i == 10; puts "#{x["description"]} - #{x["id"]}" } puts "\n" end |
.menulist ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/bbgapi/blocks_templates.rb', line 3 def self. choose do || puts "Block Templates" puts "----------------------------------------" .prompt = "Which Action?" .choices(:list) {self.list} .choices(:create) {self.create} .choices(:update) {self.tbi} .choices(:delete) {self.tbi} end end |
.raw ⇒ Object
81 82 83 84 85 86 |
# File 'lib/bbgapi/blocks_templates.rb', line 81 def self.raw partial = '/api/block_templates' api_response = BBGAPI::Client.geturl(partial,"") sorted = api_response.sort_by {|a| a["created"]}.reverse return sorted end |
.tbi ⇒ Object
88 89 90 |
# File 'lib/bbgapi/blocks_templates.rb', line 88 def self.tbi puts "This is not yet implemented" end |