nodester 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/README.md +25 -10
- data/lib/nodester/client.rb +120 -50
- data/lib/nodester/version.rb +2 -1
- metadata +2 -2
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,7 @@ WARNING: First version and my first published gem - need to work on docs and spe
|
|
3
3
|
|
4
4
|
## Nodester
|
5
5
|
|
6
|
-
An API wrapper for the nodester API (http://nodester.com). The initial version uses a straight approach, an ActiveResource like interface might be added if there is enough interest.
|
6
|
+
An API wrapper for the nodester API (<http://nodester.com>). The initial version uses a straight approach, an ActiveResource like interface might be added if there is enough interest.
|
7
7
|
|
8
8
|
[](http://travis-ci.org/scottyapp/nodester)
|
9
9
|
|
@@ -14,13 +14,17 @@ Include this in your gemfile
|
|
14
14
|
gem 'nodester'
|
15
15
|
|
16
16
|
## Use
|
17
|
+
A more detailed description can be found at <http://rubydoc.info/gems/nodester>.
|
17
18
|
|
18
|
-
|
19
|
-
client.create_app 'myappname','server.js'
|
20
|
-
...
|
19
|
+
###Some Sample Code
|
21
20
|
|
22
|
-
|
23
|
-
|
21
|
+
client = Nodester::Client.new("username","password")
|
22
|
+
client.create_app 'myappname','server.js'
|
23
|
+
...
|
24
|
+
|
25
|
+
### Note
|
26
|
+
There are a couple of methods, notably the platform_create_request and platform_status methods that
|
27
|
+
operate against <http://nodester.com> and not <http://api.nodester.com>, those do not require a userid/password. Just choose dummy/dummy or something similar.
|
24
28
|
|
25
29
|
All results are hashes, with strings (not symbols) as keys.
|
26
30
|
|
@@ -34,14 +38,25 @@ In case of an error either a ResponseError or a StandardError is raised.
|
|
34
38
|
|
35
39
|
Thanks to
|
36
40
|
|
37
|
-
* Aaron Russel (https://github.com/aaronrussell) whose cloudapp api helped a lot (some spec code is taken verbatim)
|
38
|
-
* John Nunemaker (https://github.com/jnunemaker) for httparty and all his other contributions.
|
41
|
+
* Aaron Russel (<https://github.com/aaronrussell>) whose cloudapp api helped a lot (some spec code is taken verbatim)
|
42
|
+
* John Nunemaker (<https://github.com/jnunemaker>) for httparty and all his other contributions.
|
39
43
|
|
40
44
|
## Trivia
|
41
45
|
|
42
46
|
This gem was created to the tunes of Natalia Kills and Nicki Minaj.
|
43
47
|
|
44
|
-
##
|
48
|
+
## Release Notes
|
49
|
+
|
50
|
+
### 0.0.3
|
51
|
+
* Updated docs
|
52
|
+
|
53
|
+
### 0.0.2
|
54
|
+
* Bug fix for NPM
|
55
|
+
|
56
|
+
### 0.0.1
|
57
|
+
* First version
|
58
|
+
|
59
|
+
## Contributing to Nodester
|
45
60
|
|
46
61
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
47
62
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
@@ -53,6 +68,6 @@ This gem was created to the tunes of Natalia Kills and Nicki Minaj.
|
|
53
68
|
|
54
69
|
== Copyright
|
55
70
|
|
56
|
-
Copyright (c) 2011 Martin Wawrusch
|
71
|
+
Copyright (c) 2011 Martin Wawrusch. See LICENSE for
|
57
72
|
further details.
|
58
73
|
|
data/lib/nodester/client.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
|
3
|
+
# @author Martin Wawrusch
|
4
|
+
#
|
5
|
+
# An API wrapper for the http://nodester.com API
|
6
|
+
# @see Client Client documentation for examples how to use the API.
|
3
7
|
module Nodester
|
4
|
-
#
|
8
|
+
# The client to access the API.
|
5
9
|
# @example Request a nodester.com coupon
|
6
10
|
# client = Nodester::Client.new("","")
|
7
11
|
# client.platform_coupon_request('arthur@dent.com')
|
@@ -24,16 +28,25 @@ module Nodester
|
|
24
28
|
include HTTParty
|
25
29
|
base_uri 'http://api.nodester.com'
|
26
30
|
|
31
|
+
# The uri used to access the nodester.com platform for account management
|
32
|
+
# and status purposes.
|
27
33
|
PLATFORM_URI = 'http://nodester.com'
|
28
34
|
|
35
|
+
# Inititalizer for the client class.
|
36
|
+
# @param [String] u the user name of your nodester.com account.
|
37
|
+
# @param [String] p the password of your nodester.com account.
|
38
|
+
# @return [Client] a new instance of the client.
|
29
39
|
def initialize(u, p )
|
30
40
|
@auth = {:username => u, :password => p}
|
31
41
|
end
|
32
42
|
|
33
|
-
|
34
|
-
# Examines a bad response and raises an
|
43
|
+
private
|
44
|
+
# Examines a bad response and raises an appropriate exception
|
35
45
|
#
|
36
|
-
# @param [HTTParty::Response] response
|
46
|
+
# @param [HTTParty::Response] the response as returned by the web request.
|
47
|
+
# @raise [ResponseError] raised in case of a web service related error.
|
48
|
+
# @raise [StandardError] raised in case of an error that is not web service related.
|
49
|
+
# @return [HTTParty::Response] the response as returned by the web request.
|
37
50
|
def self.bad_response(response)
|
38
51
|
if response.class == HTTParty::Response
|
39
52
|
raise ResponseError, response
|
@@ -41,33 +54,48 @@ module Nodester
|
|
41
54
|
raise StandardError, "Unkown error"
|
42
55
|
end
|
43
56
|
|
44
|
-
|
45
|
-
|
57
|
+
# Examines a response and either returns the response or
|
58
|
+
# raise an exception.
|
59
|
+
# @param [HTTParty::Response] the response as returned by the web request.
|
60
|
+
# @raise [ResponseError] raised in case of a web service related error.
|
61
|
+
# @raise [StandardError] raised in case of an error that is not web service related.
|
62
|
+
# @return [HTTParty::Response] the response as returned by the web request.
|
63
|
+
def handle_result(response)
|
64
|
+
response.ok? ? response : bad_response(response)
|
46
65
|
end
|
47
66
|
|
48
|
-
|
49
|
-
#
|
50
|
-
#
|
51
|
-
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
# email (required) : "x@y.com"
|
56
|
-
# Returns:
|
57
|
-
# status : "success - you are now in queue to receive an invite on our next batch!"
|
67
|
+
public
|
68
|
+
# Creates a coupon request against http://nodester.com for early access.
|
69
|
+
# @param (String) email the email where the coupon should be sent to.
|
70
|
+
# @return [HTTParty::Response] A response.
|
71
|
+
# @note Flow is as follows: You post this and receive a coupon per email.
|
72
|
+
# The result contains the following entries (check http://nodester.com for up to date information):
|
73
|
+
# * 'status' : "success - you are now in queue to receive an invite on our next batch!" | "failure"
|
58
74
|
def platform_coupon_request(email)
|
59
75
|
options={ :body => {:email => email}, :base_uri => PLATFORM_URI}
|
60
76
|
handle_result self.class.post('/coupon', options)
|
61
77
|
end
|
62
78
|
|
63
|
-
#
|
64
|
-
#
|
79
|
+
# Retrieves the http://nodester.com platform status
|
80
|
+
# @return [HTTParty::Response] A response
|
81
|
+
# @note The result contains the following entries (check http://nodester.com for up to date information):
|
82
|
+
# * 'status' : "up"
|
83
|
+
# * 'appshosted' : 599
|
84
|
+
# * 'appsrunning' : 988
|
65
85
|
def platform_status()
|
66
86
|
options = {:base_uri => PLATFORM_URI}
|
67
87
|
handle_result self.class.get('/status', options)
|
68
88
|
end
|
69
89
|
|
70
|
-
# Creates a new user
|
90
|
+
# Creates a new user by redeeming a coupon.
|
91
|
+
# @see Client#platform_coupon_request platform_coupon_request for details on how to obtain a coupon.
|
92
|
+
#
|
93
|
+
# @param (String) coupon the coupon received from nodester.
|
94
|
+
# @param (String) user the user name of the new user.
|
95
|
+
# @param (String) password the password of the new user.
|
96
|
+
# @param (String) email the email of the new user.
|
97
|
+
# @param (String) rsakey the rsa key of the new user.
|
98
|
+
# @return [HTTParty::Response] A response.
|
71
99
|
def platform_create_user(coupon,user,password,email,rsakey)
|
72
100
|
options={ :body => {:coupon => coupon,:user =>user,:password=>password,:email=>email,:rsakey=>rsakey}, :base_uri => PLATFORM_URI}
|
73
101
|
handle_result self.class.post('/user', options)
|
@@ -77,13 +105,17 @@ module Nodester
|
|
77
105
|
# API specific functions
|
78
106
|
# ------------------------------------
|
79
107
|
|
80
|
-
# Updates the current user.
|
108
|
+
# Updates the settings for the current user.
|
109
|
+
# @option opts [String] :password the password to update.
|
110
|
+
# @option opts [String] :rsakey the rsa key to update.
|
111
|
+
# @return [HTTParty::Response] A response.
|
81
112
|
def update_user(opts={})
|
82
113
|
options={:body => opts,:basic_auth => @auth}
|
83
114
|
handle_result self.class.put('/user', options)
|
84
115
|
end
|
85
116
|
|
86
117
|
# Deletes the current user.
|
118
|
+
# @return [HTTParty::Response] A response.
|
87
119
|
def platform_delete_user()
|
88
120
|
options={:basic_auth => @auth}
|
89
121
|
handle_result self.class.delete('/user', options)
|
@@ -91,76 +123,99 @@ module Nodester
|
|
91
123
|
|
92
124
|
|
93
125
|
|
94
|
-
# Creates a new app
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
# status : "success" | "failure"
|
100
|
-
# message : "some text" ==> Only if failure
|
101
|
-
# port : 12345
|
102
|
-
# gitrepo : 'git@nodester.com:/node/git/mwawrusch/blah.git'
|
103
|
-
# start : "the value of start, for example servre.js"
|
104
|
-
# running : true | false
|
105
|
-
# pid : "unknown" | some pid
|
126
|
+
# Creates a new app.
|
127
|
+
# @param (String) appname the name of the app.
|
128
|
+
# @param (String) start the file that contains the node.js startup code. (server.js)
|
129
|
+
# @return [HTTParty::Response] A response.
|
130
|
+
# @note The result contains the following entries (check http://nodester.com for up to date information):
|
131
|
+
# * 'status' : "success" | "failure"
|
132
|
+
# * 'message' : "some text" ==> Only if failure
|
133
|
+
# * 'port' : 12345
|
134
|
+
# * 'gitrepo' : 'git@nodester.com:/node/git/mwawrusch/blah.git'
|
135
|
+
# * 'start' : "the value of start, for example servre.js"
|
136
|
+
# * 'running' : true | false
|
137
|
+
# * 'pid' : "unknown" | some pid
|
106
138
|
def create_app(appname,start)
|
107
139
|
options={:body => {:appname=>appname,:start=>start}, :basic_auth => @auth}
|
108
140
|
handle_result self.class.post('/app', options)
|
109
141
|
end
|
110
142
|
|
111
|
-
|
143
|
+
# Updates properties of an app.
|
144
|
+
# @param (String) appname the name of the app.
|
145
|
+
# @option opts [String] :start the startup file that contains the node.js startup code.
|
146
|
+
# @return [HTTParty::Response] A response.
|
112
147
|
def update_app(appname,opts = {})
|
113
148
|
opts.merge!({:appname => appname})
|
114
149
|
|
115
150
|
options={:body=> opts, :basic_auth => @auth}
|
116
151
|
handle_result self.class.put('/app', options)
|
117
152
|
end
|
118
|
-
|
153
|
+
|
154
|
+
# Starts or stops an app.
|
155
|
+
# @param (String) appname the name of the app.
|
156
|
+
# @param (Boolean) running true to start the app; false to stop the app.
|
157
|
+
# @return [HTTParty::Response] A response.
|
119
158
|
def start_stop_app(appname,running = true)
|
120
159
|
|
121
160
|
options={:body=> {:appname => appname, :running=>start}, :basic_auth => @auth}
|
122
161
|
handle_result self.class.put('/app', options)
|
123
162
|
end
|
124
163
|
|
125
|
-
|
164
|
+
# Deletes an app.
|
165
|
+
# @param (String) appname the name of the app.
|
166
|
+
# @return [HTTParty::Response] A response.
|
126
167
|
def delete_app(appname)
|
127
168
|
options={:body => {:appname => appname}, :basic_auth => @auth}
|
128
169
|
handle_result self.class.delete('/app', options)
|
129
170
|
end
|
130
171
|
|
172
|
+
# Returns the properties of an app.
|
173
|
+
# @param (String) appname the name of the app.
|
174
|
+
# @return [HTTParty::Response] A response.
|
131
175
|
def app(appname)
|
132
176
|
options={:body => {},:basic_auth => @auth}
|
133
177
|
handle_result self.class.get("/app/#{appname}", options)
|
134
178
|
end
|
135
179
|
|
136
|
-
#
|
137
|
-
#
|
180
|
+
# Returns a list of all apps.
|
181
|
+
# @return [HTTParty::Response] A response.
|
138
182
|
# An array containing a list of apps, if any.
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
# gitrepo : 'git@nodester.com:/node/git/mwawrusch/2914-2295037e88fed947a9b3b994171c5a9e.git", "running"=>false, "pid"=>"unknown"}
|
183
|
+
# @note The result contains the following entries (check http://nodester.com for up to date information):
|
184
|
+
# * 'name' : 'testxyz1'
|
185
|
+
# * 'port' : 12344
|
186
|
+
# * 'gitrepo' : 'git@nodester.com:/node/git/mwawrusch/blah.git'
|
187
|
+
# * 'running' : false
|
188
|
+
# * 'pid' : "unknown" | some pid
|
189
|
+
# * 'gitrepo' : 'git@nodester.com:/node/git/mwawrusch/2914-2295037e88fed947a9b3b994171c5a9e.git", "running"=>false, "pid"=>"unknown"}
|
147
190
|
def apps()
|
148
191
|
options={:basic_auth => @auth}
|
149
192
|
handle_result self.class.get('/apps', options)
|
150
193
|
end
|
151
194
|
|
152
195
|
|
153
|
-
|
196
|
+
# Creates or updates a value for a key in the app's environment.
|
197
|
+
# @param (String) appname the name of the app.
|
198
|
+
# @param (String) key the key (name) of the evironment variable.
|
199
|
+
# @param (String) value the value of the environment variable.
|
200
|
+
# @return [HTTParty::Response] A response.
|
154
201
|
def update_env(appname,key,value)
|
155
202
|
options={:body => {:appname => appname,:key=>key,:value=>value},:basic_auth => @auth}
|
156
203
|
handle_result self.class.put('/env', options)
|
157
204
|
end
|
158
205
|
|
206
|
+
# Deletes a key from the app's environment.
|
207
|
+
# @param (String) appname the name of the app.
|
208
|
+
# @param (String) key the key (name) of the evironment variable.
|
209
|
+
# @return [HTTParty::Response] A response.
|
159
210
|
def delete_env(appname,key)
|
160
211
|
options={:body => {:appname => appname,:key=>key},:basic_auth => @auth}
|
161
212
|
handle_result self.class.delete('/env', options)
|
162
213
|
end
|
163
214
|
|
215
|
+
# Returns the value of a key in the app's environment.
|
216
|
+
# @param (String) appname the name of the app.
|
217
|
+
# @param (String) key the key (name) of the evironment variable.
|
218
|
+
# @return [HTTParty::Response] A response.
|
164
219
|
def env(appname,key)
|
165
220
|
options={:body => {:appname => appname,:key=>key},:basic_auth => @auth}
|
166
221
|
handle_result self.class.get('/env', options)
|
@@ -168,29 +223,44 @@ module Nodester
|
|
168
223
|
|
169
224
|
# curl -X POST -u "mwawrusch:mw09543089" -d "appname=myappname&action=install&package=express" http://api.nodester.com/npm
|
170
225
|
|
226
|
+
# Manages the NPM package manager associated with an app.
|
227
|
+
# @param (String) appname the name of the app.
|
228
|
+
# @param (String) action the action to perform. Can be install|upgrade|uninstall. Check official documentation
|
229
|
+
# for more info.
|
230
|
+
# @param (String) package the name of the package that should be worked with.
|
231
|
+
# @return [HTTParty::Response] A response.
|
171
232
|
def update_npm(appname,action,package)
|
172
233
|
options={:body => {:appname => appname,:action => action,:package=>package},:basic_auth => @auth}
|
173
234
|
handle_result self.class.post('/npm', options)
|
174
235
|
end
|
175
236
|
|
176
|
-
|
237
|
+
# Creates a new domain entry for an app.
|
238
|
+
# @note Check out the http://notester.com site for up to date information how to set your
|
239
|
+
# a record to route the domain to the actual servers.
|
240
|
+
# @param (String) appname the name of the app.
|
241
|
+
# @param (String) domain the domain to be associated with the app.
|
242
|
+
# @return [HTTParty::Response] A response.
|
177
243
|
def create_appdomain(appname,domain)
|
178
244
|
options={:body => {:appname => appname,:domain=>domain},:basic_auth => @auth}
|
179
245
|
handle_result self.class.post('/appdomains', options)
|
180
246
|
end
|
181
247
|
|
248
|
+
# Deletes a domain entry from an app.
|
249
|
+
# @param (String) appname the name of the app.
|
250
|
+
# @param (String) domain the domain to be disassociated from the app.
|
251
|
+
# @return [HTTParty::Response] A response.
|
182
252
|
def delete_appdomain(appname,domain)
|
183
253
|
options={:body => {:appname => appname,:domain=>domain},:basic_auth => @auth}
|
184
254
|
handle_result self.class.delete('/appdomains', options)
|
185
255
|
end
|
186
256
|
|
257
|
+
# Returns a list of all app domains for all apps of the current user.
|
258
|
+
# @return [HTTParty::Response] A response.
|
187
259
|
def appdomains()
|
188
260
|
options={:basic_auth => @auth}
|
189
261
|
handle_result self.class.get('/appdomains', options)
|
190
262
|
end
|
191
|
-
|
192
|
-
|
193
|
-
end
|
194
263
|
|
264
|
+
end
|
195
265
|
end
|
196
266
|
|
data/lib/nodester/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: nodester
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Martin Wawrusch
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-30 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|