Class: Nodester::Client
- Inherits:
-
Object
- Object
- Nodester::Client
- Includes:
- HTTParty
- Defined in:
- lib/nodester/client.rb
Overview
The client to access the API.
Constant Summary collapse
- PLATFORM_URI =
The uri used to access the nodester.com platform for account management and status purposes.
'http://nodester.com'
Instance Method Summary collapse
-
#app(appname) ⇒ HTTParty::Response
Returns the properties of an app.
-
#appdomains ⇒ HTTParty::Response
Returns a list of all app domains for all apps of the current user.
-
#apps ⇒ HTTParty::Response
Returns a list of all apps.
-
#create_app(appname, start) ⇒ HTTParty::Response
Creates a new app.
-
#create_appdomain(appname, domain) ⇒ HTTParty::Response
Creates a new domain entry for an app.
-
#delete_app(appname) ⇒ HTTParty::Response
Deletes an app.
-
#delete_appdomain(appname, domain) ⇒ HTTParty::Response
Deletes a domain entry from an app.
-
#delete_env(appname, key) ⇒ HTTParty::Response
Deletes a key from the app’s environment.
-
#env(appname, key) ⇒ HTTParty::Response
Returns the value of a key in the app’s environment.
-
#initialize(u, p) ⇒ Client
constructor
Inititalizer for the client class.
-
#platform_coupon_request(email) ⇒ HTTParty::Response
Creates a coupon request against nodester.com for early access.
-
#platform_create_user(coupon, user, password, email, rsakey) ⇒ HTTParty::Response
Creates a new user by redeeming a coupon.
-
#platform_delete_user ⇒ HTTParty::Response
Deletes the current user.
-
#platform_status ⇒ HTTParty::Response
Retrieves the nodester.com platform status.
-
#start_stop_app(appname, running = true) ⇒ HTTParty::Response
Starts or stops an app.
-
#update_app(appname, opts = {}) ⇒ HTTParty::Response
Updates properties of an app.
-
#update_env(appname, key, value) ⇒ HTTParty::Response
Creates or updates a value for a key in the app’s environment.
-
#update_npm(appname, action, package) ⇒ HTTParty::Response
Manages the NPM package manager associated with an app.
-
#update_user(opts = {}) ⇒ HTTParty::Response
Updates the settings for the current user.
Constructor Details
#initialize(u, p) ⇒ Client
Inititalizer for the client class.
39 40 41 |
# File 'lib/nodester/client.rb', line 39 def initialize(u, p ) @auth = {:username => u, :password => p} end |
Instance Method Details
#app(appname) ⇒ HTTParty::Response
Returns the properties of an app.
175 176 177 178 |
# File 'lib/nodester/client.rb', line 175 def app(appname) ={:body => {},:basic_auth => @auth} handle_result self.class.get("/app/#{appname}", ) end |
#appdomains ⇒ HTTParty::Response
Returns a list of all app domains for all apps of the current user.
257 258 259 260 |
# File 'lib/nodester/client.rb', line 257 def appdomains() ={:basic_auth => @auth} handle_result self.class.get('/appdomains', ) end |
#apps ⇒ HTTParty::Response
The result contains the following entries (check nodester.com for up to date information):
-
‘name’ : ‘testxyz1’
-
‘port’ : 12344
-
‘gitrepo’ : ‘[email protected]:/node/git/mwawrusch/blah.git’
-
‘running’ : false
-
‘pid’ : “unknown” | some pid
-
‘gitrepo’ : ‘[email protected]:/node/git/mwawrusch/2914-2295037e88fed947a9b3b994171c5a9e.git“, ”running“=>false, ”pid“=>”unknown“}
Returns a list of all apps.
190 191 192 193 |
# File 'lib/nodester/client.rb', line 190 def apps() ={:basic_auth => @auth} handle_result self.class.get('/apps', ) end |
#create_app(appname, start) ⇒ HTTParty::Response
The result contains the following entries (check nodester.com for up to date information):
-
‘status’ : “success” | “failure”
-
‘message’ : “some text” ==> Only if failure
-
‘port’ : 12345
-
‘gitrepo’ : ‘[email protected]:/node/git/mwawrusch/blah.git’
-
‘start’ : “the value of start, for example servre.js”
-
‘running’ : true | false
-
‘pid’ : “unknown” | some pid
Creates a new app.
138 139 140 141 |
# File 'lib/nodester/client.rb', line 138 def create_app(appname,start) ={:body => {:appname=>appname,:start=>start}, :basic_auth => @auth} handle_result self.class.post('/app', ) end |
#create_appdomain(appname, domain) ⇒ HTTParty::Response
Check out the notester.com site for up to date information how to set your a record to route the domain to the actual servers.
Creates a new domain entry for an app.
241 242 243 244 |
# File 'lib/nodester/client.rb', line 241 def create_appdomain(appname,domain) ={:body => {:appname => appname,:domain=>domain},:basic_auth => @auth} handle_result self.class.post('/appdomains', ) end |
#delete_app(appname) ⇒ HTTParty::Response
Deletes an app.
167 168 169 170 |
# File 'lib/nodester/client.rb', line 167 def delete_app(appname) ={:body => {:appname => appname}, :basic_auth => @auth} handle_result self.class.delete('/app', ) end |
#delete_appdomain(appname, domain) ⇒ HTTParty::Response
Deletes a domain entry from an app.
250 251 252 253 |
# File 'lib/nodester/client.rb', line 250 def delete_appdomain(appname,domain) ={:body => {:appname => appname,:domain=>domain},:basic_auth => @auth} handle_result self.class.delete('/appdomains', ) end |
#delete_env(appname, key) ⇒ HTTParty::Response
Deletes a key from the app’s environment.
210 211 212 213 |
# File 'lib/nodester/client.rb', line 210 def delete_env(appname,key) ={:body => {:appname => appname,:key=>key},:basic_auth => @auth} handle_result self.class.delete('/env', ) end |
#env(appname, key) ⇒ HTTParty::Response
Returns the value of a key in the app’s environment.
219 220 221 222 |
# File 'lib/nodester/client.rb', line 219 def env(appname,key) ={:body => {:appname => appname,:key=>key},:basic_auth => @auth} handle_result self.class.get('/env', ) end |
#platform_coupon_request(email) ⇒ HTTParty::Response
Flow is as follows: You post this and receive a coupon per email. The result contains the following entries (check nodester.com for up to date information):
-
‘status’ : “success - you are now in queue to receive an invite on our next batch!” | “failure”
Creates a coupon request against nodester.com for early access.
74 75 76 77 |
# File 'lib/nodester/client.rb', line 74 def platform_coupon_request(email) ={ :body => {:email => email}, :base_uri => PLATFORM_URI} handle_result self.class.post('/coupon', ) end |
#platform_create_user(coupon, user, password, email, rsakey) ⇒ HTTParty::Response
Creates a new user by redeeming a coupon.
99 100 101 102 |
# File 'lib/nodester/client.rb', line 99 def platform_create_user(coupon,user,password,email,rsakey) ={ :body => {:coupon => coupon,:user =>user,:password=>password,:email=>email,:rsakey=>rsakey}, :base_uri => PLATFORM_URI} handle_result self.class.post('/user', ) end |
#platform_delete_user ⇒ HTTParty::Response
Deletes the current user.
119 120 121 122 |
# File 'lib/nodester/client.rb', line 119 def platform_delete_user() ={:basic_auth => @auth} handle_result self.class.delete('/user', ) end |
#platform_status ⇒ HTTParty::Response
The result contains the following entries (check nodester.com for up to date information):
-
‘status’ : “up”
-
‘appshosted’ : 599
-
‘appsrunning’ : 988
Retrieves the nodester.com platform status
85 86 87 88 |
# File 'lib/nodester/client.rb', line 85 def platform_status() = {:base_uri => PLATFORM_URI} handle_result self.class.get('/status', ) end |
#start_stop_app(appname, running = true) ⇒ HTTParty::Response
Starts or stops an app.
158 159 160 161 162 |
# File 'lib/nodester/client.rb', line 158 def start_stop_app(appname,running = true) ={:body=> {:appname => appname, :running=>running}, :basic_auth => @auth} handle_result self.class.put('/app', ) end |
#update_app(appname, opts = {}) ⇒ HTTParty::Response
Updates properties of an app.
147 148 149 150 151 152 |
# File 'lib/nodester/client.rb', line 147 def update_app(appname,opts = {}) opts.merge!({:appname => appname}) ={:body=> opts, :basic_auth => @auth} handle_result self.class.put('/app', ) end |
#update_env(appname, key, value) ⇒ HTTParty::Response
Creates or updates a value for a key in the app’s environment.
201 202 203 204 |
# File 'lib/nodester/client.rb', line 201 def update_env(appname,key,value) ={:body => {:appname => appname,:key=>key,:value=>value},:basic_auth => @auth} handle_result self.class.put('/env', ) end |
#update_npm(appname, action, package) ⇒ HTTParty::Response
Manages the NPM package manager associated with an app.
230 231 232 233 |
# File 'lib/nodester/client.rb', line 230 def update_npm(appname,action,package) ={:body => {:appname => appname,:action => action,:package=>package},:basic_auth => @auth} handle_result self.class.post('/npm', ) end |
#update_user(opts = {}) ⇒ HTTParty::Response
Updates the settings for the current user.
112 113 114 115 |
# File 'lib/nodester/client.rb', line 112 def update_user(opts={}) ={:body => opts,:basic_auth => @auth} handle_result self.class.put('/user', ) end |