Class: Zillabyte::API::Apps
- Defined in:
- lib/zillabyte/api/apps.rb
Instance Method Summary collapse
- #create_cycle(id, options = {}) ⇒ Object
- #cycles_poll(id, options = {}) ⇒ Object
-
#get(id, options = {}) ⇒ Object
GET /apps/id.
-
#list(options = {}) ⇒ Object
GET /apps.
- #list_cycles(id, options = {}) ⇒ Object
-
#push_directory(dir, session = nil, options = {}) ⇒ Object
POST /apps.
- #run_forever(id, options = {}) ⇒ Object
Methods inherited from Flows
#create_delete, #create_kill, #delete, get_rich_meta_info_from_script, #poll_delete, #poll_kill, #pull_to_directory
Methods inherited from Base
Constructor Details
This class inherits a constructor from Zillabyte::API::Base
Instance Method Details
#create_cycle(id, options = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/zillabyte/api/apps.rb', line 57 def create_cycle(id, ={}) res = @api.request( :expects => 200, :method => :post, :path => "/apps/#{id}/cycles", :body => .to_json ) res.body end |
#cycles_poll(id, options = {}) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/zillabyte/api/apps.rb', line 77 def cycles_poll(id, ={}) res = @api.request( :expects => 200, :method => :get, :path => "/apps/#{id}/cycles/cycles_poll", :body => .to_json ) res.body end |
#get(id, options = {}) ⇒ Object
GET /apps/id
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/zillabyte/api/apps.rb', line 28 def get(id, = {}) = { # TODO }.merge() res = @api.request( :expects => 200, :method => :get, :path => "/apps/#{id}", :body => .to_json ) res.body end |
#list(options = {}) ⇒ Object
GET /apps
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/zillabyte/api/apps.rb', line 9 def list( = {}) = { # TODO }.merge() res = @api.request( :expects => 200, :method => :get, :path => "/apps", :body => .to_json ) res.body end |
#list_cycles(id, options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/zillabyte/api/apps.rb', line 46 def list_cycles(id, ={}) res = @api.request( :expects => 200, :method => :get, :path => "/apps/#{id}/cycles", :body => .to_json ) res.body end |
#push_directory(dir, session = nil, options = {}) ⇒ Object
POST /apps
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/zillabyte/api/apps.rb', line 90 def push_directory(dir, session = nil, = {}) type = [:output_type] # Get the meta info [:local_flag] = 1 hash = Zillabyte::API::Flows.(dir, session, ) if hash["flow_type"] == "component" session.error("To push up a component please use git. The \"zillabyte push\" command is only supported for apps.") if session end if hash.nil? session.error("unable to extract app meta information", type) if session end if hash["error"] session.error(hash["error_message"], type) if session end # Tar up everything... hash['ignore_files'] ||= [] hash['ignore_files'] << "info_to_ruby.in" hash['ignore_files'] << "vEnv" top_dir = hash['top_dir'] || "." ignore_files = hash['ignore_files'] || [] session.display("packaging directory... ", false) if session && type.nil? tar = Zillabyte::Common::Tar.tar(top_dir, ignore_files) session.display("done") if session && type.nil? hash.delete('pwd') = { :name => hash['name'], :meta => hash, # :tar => Base64.encode64(tar.read) }.merge() session.display("uploading #{tar.size} bytes... ", false) if session && type.nil? res = @api.request( :expects => 200, :method => :post, :path => "/apps", :body => .to_json ) if(res.body['uri']) uri = URI(res.body['uri']) try_again = 1 while(try_again) Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| request = Net::HTTP::Put.new(uri.request_uri) request.body_stream = tar request['Content-Length'] = request.body_stream.size request['Content-Type'] = '' response = http.request(request) if response.code.to_i >= 300 try_again = 1 break end try_again = nil end end res.body.delete('uri') end session.display("done")if session && type.nil? res.body end |
#run_forever(id, options = {}) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/zillabyte/api/apps.rb', line 67 def run_forever(id, ={}) res = @api.request( :expects => 200, :method => :post, :path => "/apps/#{id}/cycles/run_forever", :body => .to_json ) res.body end |