heroku-api 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +8 -6
- data/README.md +30 -30
- data/changelog.txt +8 -0
- data/heroku-api.gemspec +1 -1
- data/lib/heroku/api.rb +31 -5
- data/lib/heroku/api/collaborators.rb +1 -1
- data/lib/heroku/api/config_vars.rb +1 -1
- data/lib/heroku/api/mock.rb +3 -3
- data/lib/heroku/api/mock/addons.rb +12 -12
- data/lib/heroku/api/mock/apps.rb +8 -8
- data/lib/heroku/api/mock/collaborators.rb +3 -3
- data/lib/heroku/api/mock/config_vars.rb +3 -3
- data/lib/heroku/api/mock/domains.rb +2 -2
- data/lib/heroku/api/mock/features.rb +7 -7
- data/lib/heroku/api/mock/keys.rb +1 -1
- data/lib/heroku/api/mock/processes.rb +9 -9
- data/lib/heroku/api/mock/releases.rb +3 -3
- data/lib/heroku/api/mock/stacks.rb +3 -3
- data/lib/heroku/api/version.rb +1 -1
- data/test/test_addons.rb +1 -1
- data/test/test_collaborators.rb +1 -1
- data/test/test_features.rb +2 -2
- data/test/test_user.rb +1 -1
- metadata +11 -11
data/.travis.yml
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
rvm:
|
4
|
-
- 1.8.7
|
5
|
-
- 1.9.2
|
6
|
-
- 1.9.3
|
1
|
+
language: ruby
|
7
2
|
|
8
3
|
notifications:
|
9
4
|
email: false
|
@@ -12,3 +7,10 @@ notifications:
|
|
12
7
|
on_failure: always
|
13
8
|
urls:
|
14
9
|
- http://dx-helper.herokuapp.com/travis
|
10
|
+
|
11
|
+
rvm:
|
12
|
+
- 1.8.7
|
13
|
+
- 1.9.2
|
14
|
+
- 1.9.3
|
15
|
+
|
16
|
+
script: bundle exec rake
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ For additional details about any of the commands, see the [API docs](http://api-
|
|
29
29
|
|
30
30
|
### Add-ons
|
31
31
|
|
32
|
-
heroku.
|
32
|
+
heroku.delete_addon('app', 'addon') # remove 'addon' add-on from an 'app' app
|
33
33
|
heroku.get_addons # see a listing of all available add-ons
|
34
34
|
heroku.get_addons('app') # see listing of installed add-ons for 'app' app
|
35
35
|
heroku.post_addon('app', 'addon') # add 'addon' add-on to 'app' app
|
@@ -47,60 +47,60 @@ For additional details about any of the commands, see the [API docs](http://api-
|
|
47
47
|
|
48
48
|
### Collaborators
|
49
49
|
|
50
|
-
delete_collaborator('app', 'email@example.com') # remove 'email@example.com' collaborator from 'app' app
|
51
|
-
get_collaborators('app') # list collaborators for 'app' app
|
52
|
-
post_collaborator('app', 'email@example.com') # add 'email@example.com' collaborator to 'app' app
|
50
|
+
heroku.delete_collaborator('app', 'email@example.com') # remove 'email@example.com' collaborator from 'app' app
|
51
|
+
heroku.get_collaborators('app') # list collaborators for 'app' app
|
52
|
+
heroku.post_collaborator('app', 'email@example.com') # add 'email@example.com' collaborator to 'app' app
|
53
53
|
|
54
54
|
### Config Variables
|
55
55
|
|
56
|
-
delete_config_var('app', 'KEY') # remove 'KEY' key from 'app' app
|
57
|
-
get_config_vars('app') # get list of config vars for 'app' app
|
58
|
-
put_config_vars('app', 'KEY' => 'value') # set 'KEY' key to 'value' for 'app' app
|
56
|
+
heroku.delete_config_var('app', 'KEY') # remove 'KEY' key from 'app' app
|
57
|
+
heroku.get_config_vars('app') # get list of config vars for 'app' app
|
58
|
+
heroku.put_config_vars('app', 'KEY' => 'value') # set 'KEY' key to 'value' for 'app' app
|
59
59
|
|
60
60
|
### Domains
|
61
61
|
|
62
|
-
delete_domain('app', 'example.com') # remove the 'example.com' domain from the 'app' app
|
63
|
-
get_domains('app') # list configured domains for the 'app' app
|
64
|
-
post_domains('app', 'example.com') # add 'example.com' domain to the 'app' app
|
62
|
+
heroku.delete_domain('app', 'example.com') # remove the 'example.com' domain from the 'app' app
|
63
|
+
heroku.get_domains('app') # list configured domains for the 'app' app
|
64
|
+
heroku.post_domains('app', 'example.com') # add 'example.com' domain to the 'app' app
|
65
65
|
|
66
66
|
### Keys
|
67
67
|
|
68
|
-
delete_key('user@hostname.local') # remove the 'user@hostname.local' key
|
69
|
-
delete_keys # remove all keys
|
70
|
-
get_keys # list configured keys
|
71
|
-
post_key('key data') # add key defined by 'key data'
|
68
|
+
heroku.delete_key('user@hostname.local') # remove the 'user@hostname.local' key
|
69
|
+
heroku.delete_keys # remove all keys
|
70
|
+
heroku.get_keys # list configured keys
|
71
|
+
heroku.post_key('key data') # add key defined by 'key data'
|
72
72
|
|
73
73
|
### Logs
|
74
74
|
|
75
|
-
get_logs('app') # return logs information for 'app' app
|
75
|
+
heroku.get_logs('app') # return logs information for 'app' app
|
76
76
|
|
77
77
|
### Processes
|
78
78
|
|
79
|
-
get_ps('app') # list current processes for 'app' app
|
80
|
-
post_ps('app', 'command') # run 'command' command in context of 'app' app
|
81
|
-
post_ps_restart('app') # restart all processes for 'app' app
|
82
|
-
post_ps_scale('app', 'type', 'quantity') # scale 'type' type processes to 'quantity' for 'app' app
|
83
|
-
post_ps_stop('app', 'ps' => 'web.1') # stop 'web.1' process for 'app' app
|
84
|
-
post_ps_stop('app', 'type' => 'web') # stop all 'web' processes for 'app' app
|
85
|
-
put_dynos('app', 'dynos') # set number of dynos for bamboo app 'app' to 'dynos'
|
86
|
-
put_workers('app', 'workers') # set number of workers for bamboo app 'app' to 'workers'
|
79
|
+
heroku.get_ps('app') # list current processes for 'app' app
|
80
|
+
heroku.post_ps('app', 'command') # run 'command' command in context of 'app' app
|
81
|
+
heroku.post_ps_restart('app') # restart all processes for 'app' app
|
82
|
+
heroku.post_ps_scale('app', 'type', 'quantity') # scale 'type' type processes to 'quantity' for 'app' app
|
83
|
+
heroku.post_ps_stop('app', 'ps' => 'web.1') # stop 'web.1' process for 'app' app
|
84
|
+
heroku.post_ps_stop('app', 'type' => 'web') # stop all 'web' processes for 'app' app
|
85
|
+
heroku.put_dynos('app', 'dynos') # set number of dynos for bamboo app 'app' to 'dynos'
|
86
|
+
heroku.put_workers('app', 'workers') # set number of workers for bamboo app 'app' to 'workers'
|
87
87
|
|
88
|
-
post_ps_restart('app', 'ps' => 'web.1') # restart 'web.1' process for 'app' app
|
88
|
+
heroku.post_ps_restart('app', 'ps' => 'web.1') # restart 'web.1' process for 'app' app
|
89
89
|
|
90
90
|
### Releases
|
91
91
|
|
92
|
-
get_releases('app') # list of releases for 'app' app
|
93
|
-
get_release('app', 'v#') # get details of 'v#' release for 'app' app
|
94
|
-
post_release('app', 'v#') # rollback 'app' app to 'v#' release
|
92
|
+
heroku.get_releases('app') # list of releases for 'app' app
|
93
|
+
heroku.get_release('app', 'v#') # get details of 'v#' release for 'app' app
|
94
|
+
heroku.post_release('app', 'v#') # rollback 'app' app to 'v#' release
|
95
95
|
|
96
96
|
### Stacks
|
97
97
|
|
98
|
-
get_stack('app') # list available stacks
|
99
|
-
put_stack('app', 'stack') # migrate 'app' app to 'stack' stack
|
98
|
+
heroku.get_stack('app') # list available stacks
|
99
|
+
heroku.put_stack('app', 'stack') # migrate 'app' app to 'stack' stack
|
100
100
|
|
101
101
|
### User
|
102
102
|
|
103
|
-
get_user # list user info
|
103
|
+
heroku.get_user # list user info
|
104
104
|
|
105
105
|
Mock
|
106
106
|
----
|
data/changelog.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
0.2.7 07/05/2012
|
2
|
+
================
|
3
|
+
|
4
|
+
doc fixes (fixes delete_addon and improves consistency)
|
5
|
+
post_collaborator returns 201 when users does not yet exist
|
6
|
+
use json (instead of okjson) when available
|
7
|
+
update excon dependency
|
8
|
+
|
1
9
|
0.2.6 06/21/2012
|
2
10
|
================
|
3
11
|
|
data/heroku-api.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
-
s.add_runtime_dependency 'excon', '~>0.14.
|
19
|
+
s.add_runtime_dependency 'excon', '~>0.14.3'
|
20
20
|
|
21
21
|
s.add_development_dependency 'minitest'
|
22
22
|
s.add_development_dependency 'rake'
|
data/lib/heroku/api.rb
CHANGED
@@ -9,8 +9,6 @@ unless $LOAD_PATH.include?(__LIB_DIR__)
|
|
9
9
|
$LOAD_PATH.unshift(__LIB_DIR__)
|
10
10
|
end
|
11
11
|
|
12
|
-
require "heroku/api/vendor/okjson"
|
13
|
-
|
14
12
|
require "heroku/api/errors"
|
15
13
|
require "heroku/api/mock"
|
16
14
|
require "heroku/api/version"
|
@@ -34,6 +32,36 @@ srand
|
|
34
32
|
module Heroku
|
35
33
|
class API
|
36
34
|
|
35
|
+
begin
|
36
|
+
|
37
|
+
require('json')
|
38
|
+
|
39
|
+
def self.json_decode(json)
|
40
|
+
JSON.parse(json)
|
41
|
+
rescue
|
42
|
+
json
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.json_encode(object)
|
46
|
+
JSON.dump(object)
|
47
|
+
end
|
48
|
+
|
49
|
+
rescue LoadError
|
50
|
+
|
51
|
+
require('heroku/api/vendor/okjson')
|
52
|
+
|
53
|
+
def self.json_decode(json)
|
54
|
+
Heroku::API::OkJson.decode(json)
|
55
|
+
rescue
|
56
|
+
json
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.json_encode(object)
|
60
|
+
Heroku::API::OkJson.encode(object)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
37
65
|
def initialize(options={})
|
38
66
|
@api_key = options.delete(:api_key) || ENV['HEROKU_API_KEY']
|
39
67
|
user_pass = ":#{@api_key}"
|
@@ -81,9 +109,7 @@ module Heroku
|
|
81
109
|
response.body = Zlib::GzipReader.new(StringIO.new(response.body)).read
|
82
110
|
end
|
83
111
|
begin
|
84
|
-
response.body = Heroku::API
|
85
|
-
rescue
|
86
|
-
# leave non-JSON body as is
|
112
|
+
response.body = Heroku::API.json_decode(response.body)
|
87
113
|
end
|
88
114
|
end
|
89
115
|
|
data/lib/heroku/api/mock.rb
CHANGED
@@ -72,7 +72,7 @@ module Heroku
|
|
72
72
|
def self.get_mock_addon(mock_data, addon)
|
73
73
|
@addons ||= begin
|
74
74
|
data = File.read("#{File.dirname(__FILE__)}/mock/cache/get_addons.json")
|
75
|
-
Heroku::API
|
75
|
+
Heroku::API.json_decode(data)
|
76
76
|
end
|
77
77
|
@addons.detect {|addon_data| addon_data['name'] == addon}
|
78
78
|
end
|
@@ -106,7 +106,7 @@ module Heroku
|
|
106
106
|
def self.get_mock_feature(mock_data, feature)
|
107
107
|
@features ||= begin
|
108
108
|
data = File.read("#{File.dirname(__FILE__)}/mock/cache/get_features.json")
|
109
|
-
Heroku::API
|
109
|
+
Heroku::API.json_decode(data)
|
110
110
|
end
|
111
111
|
@features.detect {|feature_data| feature_data['name'] == feature}
|
112
112
|
end
|
@@ -139,7 +139,7 @@ module Heroku
|
|
139
139
|
|
140
140
|
parsed = params.dup
|
141
141
|
begin # try to JSON decode
|
142
|
-
parsed[:body] &&= Heroku::API
|
142
|
+
parsed[:body] &&= Heroku::API.json_decode(parsed[:body])
|
143
143
|
rescue # else leave as is
|
144
144
|
end
|
145
145
|
|
@@ -14,7 +14,7 @@ module Heroku
|
|
14
14
|
# addon is currently installed
|
15
15
|
remove_mock_app_addon(mock_data, app, addon)
|
16
16
|
{
|
17
|
-
:body => Heroku::API
|
17
|
+
:body => Heroku::API.json_encode({
|
18
18
|
"message" => nil,
|
19
19
|
"price" => get_mock_addon_price(mock_data, addon),
|
20
20
|
"status" => 'Uninstalled'
|
@@ -24,14 +24,14 @@ module Heroku
|
|
24
24
|
else
|
25
25
|
# addon is not currently installed
|
26
26
|
{
|
27
|
-
:body => Heroku::API
|
27
|
+
:body => Heroku::API.json_encode({'error' => "The add-on #{addon} is not installed for this app. Did you mean:\n\t#{addon_names.join("\n\t")}"}),
|
28
28
|
:status => 422
|
29
29
|
}
|
30
30
|
end
|
31
31
|
else
|
32
32
|
# addon does not exist
|
33
33
|
{
|
34
|
-
:body => Heroku::API
|
34
|
+
:body => Heroku::API.json_encode({'error' => "Could not find add-on #{addon}. Did you mean:\n\t#{addon_names.join("\n\t")}"}),
|
35
35
|
:status => 422
|
36
36
|
}
|
37
37
|
end
|
@@ -53,7 +53,7 @@ module Heroku
|
|
53
53
|
app, _ = request_params[:captures][:path]
|
54
54
|
with_mock_app(mock_data, app) do
|
55
55
|
{
|
56
|
-
:body => Heroku::API
|
56
|
+
:body => Heroku::API.json_encode(mock_data[:addons][app].map {|addon| addon['configured'] = true; addon}),
|
57
57
|
:status => 200
|
58
58
|
}
|
59
59
|
end
|
@@ -72,7 +72,7 @@ module Heroku
|
|
72
72
|
# addon is not currently installed
|
73
73
|
add_mock_app_addon(mock_data, app, addon)
|
74
74
|
{
|
75
|
-
:body => Heroku::API
|
75
|
+
:body => Heroku::API.json_encode({
|
76
76
|
"message" => nil,
|
77
77
|
"price" => get_mock_addon_price(mock_data, addon),
|
78
78
|
"status" => 'Installed'
|
@@ -82,21 +82,21 @@ module Heroku
|
|
82
82
|
else
|
83
83
|
# addon is currently installed
|
84
84
|
{
|
85
|
-
:body => Heroku::API
|
85
|
+
:body => Heroku::API.json_encode({'error' => "Add-on already installed."}),
|
86
86
|
:status => 422
|
87
87
|
}
|
88
88
|
end
|
89
89
|
else
|
90
90
|
# addon of same type exists
|
91
91
|
{
|
92
|
-
:body => Heroku::API
|
92
|
+
:body => Heroku::API.json_encode({'error' => "#{app_addon_type_data['name']} add-on already added.\nTo upgrade, use addons:upgrade instead.\n"}),
|
93
93
|
:status => 422
|
94
94
|
}
|
95
95
|
end
|
96
96
|
else
|
97
97
|
# addon does not exist
|
98
98
|
{
|
99
|
-
:body => Heroku::API
|
99
|
+
:body => Heroku::API.json_encode({'error' => "Add-on not found."}),
|
100
100
|
:status => 404
|
101
101
|
}
|
102
102
|
end
|
@@ -117,7 +117,7 @@ module Heroku
|
|
117
117
|
mock_data[:addons][app].delete(app_addon_data)
|
118
118
|
add_mock_app_addon(mock_data, app, addon)
|
119
119
|
{
|
120
|
-
:body => Heroku::API
|
120
|
+
:body => Heroku::API.json_encode({
|
121
121
|
"message" => 'Plan upgraded',
|
122
122
|
"price" => get_mock_addon_price(mock_data, addon),
|
123
123
|
"status" => 'Updated'
|
@@ -127,21 +127,21 @@ module Heroku
|
|
127
127
|
else
|
128
128
|
# addon is currently installed
|
129
129
|
{
|
130
|
-
:body => Heroku::API
|
130
|
+
:body => Heroku::API.json_encode({'error' => "Add-on already installed."}),
|
131
131
|
:status => 422
|
132
132
|
}
|
133
133
|
end
|
134
134
|
else
|
135
135
|
# addon of same type not installed
|
136
136
|
{
|
137
|
-
:body => Heroku::API
|
137
|
+
:body => Heroku::API.json_encode({'error' => "Can't upgrade, no #{addon.split(':').join(' ')} add-on has been added.\nTo add, use addons:add instead.\n"}),
|
138
138
|
:status => 422
|
139
139
|
}
|
140
140
|
end
|
141
141
|
else
|
142
142
|
# addon does not exist
|
143
143
|
{
|
144
|
-
:body => Heroku::API
|
144
|
+
:body => Heroku::API.json_encode({'error' => "Add-on not found."}),
|
145
145
|
:status => 404
|
146
146
|
}
|
147
147
|
end
|
data/lib/heroku/api/mock/apps.rb
CHANGED
@@ -15,7 +15,7 @@ module Heroku
|
|
15
15
|
mock_data[:ps].delete(app)
|
16
16
|
mock_data[:releases].delete(app)
|
17
17
|
{
|
18
|
-
:body => Heroku::API
|
18
|
+
:body => Heroku::API.json_encode({}),
|
19
19
|
:status => 200
|
20
20
|
}
|
21
21
|
end
|
@@ -25,7 +25,7 @@ module Heroku
|
|
25
25
|
Excon.stub(:expects => 200, :method => :get, :path => '/apps') do |params|
|
26
26
|
request_params, mock_data = parse_stub_params(params)
|
27
27
|
{
|
28
|
-
:body => Heroku::API
|
28
|
+
:body => Heroku::API.json_encode(mock_data[:apps]),
|
29
29
|
:status => 200
|
30
30
|
}
|
31
31
|
end
|
@@ -36,7 +36,7 @@ module Heroku
|
|
36
36
|
app, _ = request_params[:captures][:path]
|
37
37
|
with_mock_app(mock_data, app) do |app_data|
|
38
38
|
{
|
39
|
-
:body => Heroku::API
|
39
|
+
:body => Heroku::API.json_encode(app_data),
|
40
40
|
:status => 200
|
41
41
|
}
|
42
42
|
end
|
@@ -49,7 +49,7 @@ module Heroku
|
|
49
49
|
|
50
50
|
if get_mock_app(mock_data, app)
|
51
51
|
{
|
52
|
-
:body => Heroku::API
|
52
|
+
:body => Heroku::API.json_encode('error' => 'Name is already taken'),
|
53
53
|
:status => 422
|
54
54
|
}
|
55
55
|
else
|
@@ -112,7 +112,7 @@ module Heroku
|
|
112
112
|
end
|
113
113
|
|
114
114
|
{
|
115
|
-
:body => Heroku::API
|
115
|
+
:body => Heroku::API.json_encode(app_data),
|
116
116
|
:status => 202
|
117
117
|
}
|
118
118
|
end
|
@@ -157,12 +157,12 @@ module Heroku
|
|
157
157
|
end
|
158
158
|
if email && !collaborator
|
159
159
|
{
|
160
|
-
:body => Heroku::API
|
160
|
+
:body => Heroku::API.json_encode('error' => 'Only existing collaborators can receive ownership for an app'),
|
161
161
|
:status => 422
|
162
162
|
}
|
163
163
|
else
|
164
164
|
{
|
165
|
-
:body => Heroku::API
|
165
|
+
:body => Heroku::API.json_encode('name' => app_data['name']),
|
166
166
|
:status => 200
|
167
167
|
}
|
168
168
|
end
|
@@ -176,7 +176,7 @@ module Heroku
|
|
176
176
|
|
177
177
|
with_mock_app(mock_data, app) do |app_data|
|
178
178
|
{
|
179
|
-
:body => Heroku::API
|
179
|
+
:body => Heroku::API.json_encode({}),
|
180
180
|
:status => 201
|
181
181
|
}
|
182
182
|
end
|
@@ -25,14 +25,14 @@ module Heroku
|
|
25
25
|
app, _ = request_params[:captures][:path]
|
26
26
|
with_mock_app(mock_data, app) do
|
27
27
|
{
|
28
|
-
:body => Heroku::API
|
28
|
+
:body => Heroku::API.json_encode(mock_data[:collaborators][app]),
|
29
29
|
:status => 200
|
30
30
|
}
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
# stub POST /apps/:app/collaborators
|
35
|
-
Excon.stub(:expects => 200, :method => :post, :path => %r{^/apps/([^/]+)/collaborators}) do |params|
|
35
|
+
Excon.stub(:expects => [200, 201], :method => :post, :path => %r{^/apps/([^/]+)/collaborators}) do |params|
|
36
36
|
request_params, mock_data = parse_stub_params(params)
|
37
37
|
app, _ = request_params[:captures][:path]
|
38
38
|
email = request_params[:query]['collaborator[email]']
|
@@ -40,7 +40,7 @@ module Heroku
|
|
40
40
|
mock_data[:collaborators][app] |= [{'access' => 'edit', 'email' => email, 'name' => nil}]
|
41
41
|
{
|
42
42
|
:body => "#{email} added as a collaborator on #{app}.",
|
43
|
-
:status =>
|
43
|
+
:status => 201
|
44
44
|
}
|
45
45
|
# Existing user response
|
46
46
|
#{
|
@@ -10,7 +10,7 @@ module Heroku
|
|
10
10
|
mock_data[:config_vars][app].delete(key)
|
11
11
|
add_mock_release(mock_data, app, {'descr' => "Config remove #{key}"})
|
12
12
|
{
|
13
|
-
:body => Heroku::API
|
13
|
+
:body => Heroku::API.json_encode(mock_data[:config_vars][app]),
|
14
14
|
:status => 200
|
15
15
|
}
|
16
16
|
end
|
@@ -22,7 +22,7 @@ module Heroku
|
|
22
22
|
app, _ = request_params[:captures][:path]
|
23
23
|
with_mock_app(mock_data, app) do
|
24
24
|
{
|
25
|
-
:body => Heroku::API
|
25
|
+
:body => Heroku::API.json_encode(mock_data[:config_vars][app]),
|
26
26
|
:status => 200
|
27
27
|
}
|
28
28
|
end
|
@@ -37,7 +37,7 @@ module Heroku
|
|
37
37
|
mock_data[:config_vars][app].merge!(new_config_vars)
|
38
38
|
add_mock_release(mock_data, app, {'descr' => "Config add #{new_config_vars.keys.join(', ')}"})
|
39
39
|
{
|
40
|
-
:body => Heroku::API
|
40
|
+
:body => Heroku::API.json_encode(mock_data[:config_vars][app]),
|
41
41
|
:status => 200
|
42
42
|
}
|
43
43
|
end
|
@@ -42,7 +42,7 @@ module Heroku
|
|
42
42
|
app, _ = request_params[:captures][:path]
|
43
43
|
with_mock_app(mock_data, app) do |app_data|
|
44
44
|
{
|
45
|
-
:body => Heroku::API
|
45
|
+
:body => Heroku::API.json_encode(mock_data[:domains][app]),
|
46
46
|
:status => 200
|
47
47
|
}
|
48
48
|
end
|
@@ -66,7 +66,7 @@ module Heroku
|
|
66
66
|
}
|
67
67
|
end
|
68
68
|
{
|
69
|
-
:body => Heroku::API
|
69
|
+
:body => Heroku::API.json_encode('domain' => domain),
|
70
70
|
:status => 201
|
71
71
|
}
|
72
72
|
end
|
@@ -16,20 +16,20 @@ module Heroku
|
|
16
16
|
when 'app'
|
17
17
|
mock_data[:features][:app][app].delete(feature_data)
|
18
18
|
{
|
19
|
-
:body => Heroku::API
|
19
|
+
:body => Heroku::API.json_encode(feature_data.merge('enabled' => false)),
|
20
20
|
:status => 200
|
21
21
|
}
|
22
22
|
when 'user'
|
23
23
|
mock_data[:features][:user].delete(feature_data.merge('enabled' => false))
|
24
24
|
{
|
25
|
-
:body => Heroku::API
|
25
|
+
:body => Heroku::API.json_encode(feature_data),
|
26
26
|
:status => 200
|
27
27
|
}
|
28
28
|
end
|
29
29
|
else
|
30
30
|
# feature does not exist
|
31
31
|
{
|
32
|
-
:body => Heroku::API
|
32
|
+
:body => Heroku::API.json_encode({'error' => "Feature not found."}),
|
33
33
|
:status => 404
|
34
34
|
}
|
35
35
|
end
|
@@ -56,13 +56,13 @@ module Heroku
|
|
56
56
|
feature, _ = request_params[:captures][:path]
|
57
57
|
if feature_data = get_mock_feature(mock_data, feature)
|
58
58
|
{
|
59
|
-
:body => Heroku::API
|
59
|
+
:body => Heroku::API.json_encode(feature_data),
|
60
60
|
:status => 200
|
61
61
|
}
|
62
62
|
else
|
63
63
|
# feature does not exist
|
64
64
|
{
|
65
|
-
:body => Heroku::API
|
65
|
+
:body => Heroku::API.json_encode({'error' => "Feature not found."}),
|
66
66
|
:status => 404
|
67
67
|
}
|
68
68
|
end
|
@@ -82,7 +82,7 @@ module Heroku
|
|
82
82
|
when 'app'
|
83
83
|
mock_data[:features][:app][app] << feature_data
|
84
84
|
{
|
85
|
-
:body => Heroku::API
|
85
|
+
:body => Heroku::API.json_encode(feature_data),
|
86
86
|
:status => 200
|
87
87
|
}
|
88
88
|
when 'user'
|
@@ -95,7 +95,7 @@ module Heroku
|
|
95
95
|
else
|
96
96
|
# feature does not exist
|
97
97
|
{
|
98
|
-
:body => Heroku::API
|
98
|
+
:body => Heroku::API.json_encode({'error' => "Feature not found."}),
|
99
99
|
:status => 404
|
100
100
|
}
|
101
101
|
end
|
data/lib/heroku/api/mock/keys.rb
CHANGED
@@ -26,7 +26,7 @@ module Heroku
|
|
26
26
|
Excon.stub(:expects => 200, :method => :get, :path => %r{^/user/keys}) do |params|
|
27
27
|
request_params, mock_data = parse_stub_params(params)
|
28
28
|
{
|
29
|
-
:body => Heroku::API
|
29
|
+
:body => Heroku::API.json_encode(mock_data[:keys]),
|
30
30
|
:status => 200
|
31
31
|
}
|
32
32
|
end
|
@@ -8,7 +8,7 @@ module Heroku
|
|
8
8
|
app, _ = request_params[:captures][:path]
|
9
9
|
with_mock_app(mock_data, app) do |app_data|
|
10
10
|
{
|
11
|
-
:body => Heroku::API
|
11
|
+
:body => Heroku::API.json_encode(get_mock_processes(mock_data, app)),
|
12
12
|
:status => 200
|
13
13
|
}
|
14
14
|
end
|
@@ -43,7 +43,7 @@ module Heroku
|
|
43
43
|
}
|
44
44
|
mock_data[:ps][app] << data
|
45
45
|
{
|
46
|
-
:body => Heroku::API
|
46
|
+
:body => Heroku::API.json_encode(data),
|
47
47
|
:status => 200,
|
48
48
|
}
|
49
49
|
end
|
@@ -117,13 +117,13 @@ module Heroku
|
|
117
117
|
}
|
118
118
|
else
|
119
119
|
{
|
120
|
-
:body => Heroku::API
|
120
|
+
:body => Heroku::API.json_encode('error' => "No such type as #{type}") ,
|
121
121
|
:status => 422
|
122
122
|
}
|
123
123
|
end
|
124
124
|
else
|
125
125
|
{
|
126
|
-
:body => Heroku::API
|
126
|
+
:body => Heroku::API.json_encode('error' => "That feature is not available on this app's stack"),
|
127
127
|
:status => 422
|
128
128
|
}
|
129
129
|
end
|
@@ -139,7 +139,7 @@ module Heroku
|
|
139
139
|
type = request_params[:query].has_key?('type') && request_params[:query]['type']
|
140
140
|
if !ps && !type
|
141
141
|
{
|
142
|
-
:body => Heroku::API
|
142
|
+
:body => Heroku::API.json_encode({'error' => 'Missing process argument'}),
|
143
143
|
:status => 422
|
144
144
|
}
|
145
145
|
else
|
@@ -160,12 +160,12 @@ module Heroku
|
|
160
160
|
unless app_data['stack'] == 'cedar'
|
161
161
|
app_data['dynos'] = dynos
|
162
162
|
{
|
163
|
-
:body => Heroku::API
|
163
|
+
:body => Heroku::API.json_encode({'name' => app, 'dynos' => dynos}),
|
164
164
|
:status => 200
|
165
165
|
}
|
166
166
|
else
|
167
167
|
{
|
168
|
-
:body => Heroku::API
|
168
|
+
:body => Heroku::API.json_encode({'error' => "For Cedar apps, use `heroku scale web=#{dynos}`"}),
|
169
169
|
:status => 422
|
170
170
|
}
|
171
171
|
end
|
@@ -181,12 +181,12 @@ module Heroku
|
|
181
181
|
unless app_data['stack'] == 'cedar'
|
182
182
|
app_data['workers'] = workers
|
183
183
|
{
|
184
|
-
:body => Heroku::API
|
184
|
+
:body => Heroku::API.json_encode({'name' => app, 'workers' => workers}),
|
185
185
|
:status => 200
|
186
186
|
}
|
187
187
|
else
|
188
188
|
{
|
189
|
-
:body => Heroku::API
|
189
|
+
:body => Heroku::API.json_encode({'error' => "For Cedar apps, use `heroku scale worker=#{workers}`"}),
|
190
190
|
:status => 422
|
191
191
|
}
|
192
192
|
end
|
@@ -8,7 +8,7 @@ module Heroku
|
|
8
8
|
app, _ = request_params[:captures][:path]
|
9
9
|
with_mock_app(mock_data, app) do |app_data|
|
10
10
|
{
|
11
|
-
:body => Heroku::API
|
11
|
+
:body => Heroku::API.json_encode(mock_data[:releases][app]),
|
12
12
|
:status => 200
|
13
13
|
}
|
14
14
|
end
|
@@ -22,7 +22,7 @@ module Heroku
|
|
22
22
|
releases = mock_data[:releases][app]
|
23
23
|
if release_data = (release_name == 'current' && releases.last) || releases.detect {|release| release['name'] == release_name}
|
24
24
|
{
|
25
|
-
:body => Heroku::API
|
25
|
+
:body => Heroku::API.json_encode(release_data),
|
26
26
|
:status => 200
|
27
27
|
}
|
28
28
|
else
|
@@ -51,7 +51,7 @@ module Heroku
|
|
51
51
|
}
|
52
52
|
else
|
53
53
|
{
|
54
|
-
:body => Heroku::API
|
54
|
+
:body => Heroku::API.json_encode({'error' => 'Cannot rollback to a release that had a different set of addons installed'}),
|
55
55
|
:status => 422
|
56
56
|
}
|
57
57
|
end
|
@@ -37,7 +37,7 @@ module Heroku
|
|
37
37
|
stack_data = Marshal::load(Marshal.dump(STACKS))
|
38
38
|
stack_data.detect {|stack| stack['name'] == app_data['stack']}['current'] = true
|
39
39
|
{
|
40
|
-
:body => Heroku::API
|
40
|
+
:body => Heroku::API.json_encode(stack_data),
|
41
41
|
:status => 200
|
42
42
|
}
|
43
43
|
end
|
@@ -65,13 +65,13 @@ BODY
|
|
65
65
|
}
|
66
66
|
else
|
67
67
|
{
|
68
|
-
:body => Heroku::API
|
68
|
+
:body => Heroku::API.json_encode('error' => 'Stack not found'),
|
69
69
|
:status => 404
|
70
70
|
}
|
71
71
|
end
|
72
72
|
else
|
73
73
|
{
|
74
|
-
:body => Heroku::API
|
74
|
+
:body => Heroku::API.json_encode('error' => 'Stack migration to/from Cedar is not available. Create a new app with --stack cedar instead.'),
|
75
75
|
:status => 422
|
76
76
|
}
|
77
77
|
end
|
data/lib/heroku/api/version.rb
CHANGED
data/test/test_addons.rb
CHANGED
@@ -43,7 +43,7 @@ class TestAddons < MiniTest::Unit::TestCase
|
|
43
43
|
data = File.read("#{File.dirname(__FILE__)}/../lib/heroku/api/mock/cache/get_addons.json")
|
44
44
|
|
45
45
|
assert_equal(200, response.status)
|
46
|
-
assert_equal(Heroku::API
|
46
|
+
assert_equal(Heroku::API.json_decode(data), response.body)
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_get_addons_with_app
|
data/test/test_collaborators.rb
CHANGED
@@ -54,7 +54,7 @@ class TestCollaborators < MiniTest::Unit::TestCase
|
|
54
54
|
email_address = 'wesley@heroku.com'
|
55
55
|
response = heroku.post_collaborator(app_data['name'], email_address)
|
56
56
|
|
57
|
-
assert_equal(
|
57
|
+
assert_equal(201, response.status)
|
58
58
|
assert_equal(
|
59
59
|
"#{email_address} added as a collaborator on #{app_data['name']}.",
|
60
60
|
response.body
|
data/test/test_features.rb
CHANGED
@@ -5,7 +5,7 @@ class TestFeatures < MiniTest::Unit::TestCase
|
|
5
5
|
def setup
|
6
6
|
@feature_data ||= begin
|
7
7
|
data = File.read("#{File.dirname(__FILE__)}/../lib/heroku/api/mock/cache/get_features.json")
|
8
|
-
features_data = Heroku::API
|
8
|
+
features_data = Heroku::API.json_decode(data)
|
9
9
|
features_data.detect {|feature| feature['name'] == 'user_env_compile'}
|
10
10
|
end
|
11
11
|
end
|
@@ -40,7 +40,7 @@ class TestFeatures < MiniTest::Unit::TestCase
|
|
40
40
|
data = File.read("#{File.dirname(__FILE__)}/../lib/heroku/api/mock/cache/get_features.json")
|
41
41
|
|
42
42
|
assert_equal(200, response.status)
|
43
|
-
assert_equal(Heroku::API
|
43
|
+
assert_equal(Heroku::API.json_decode(data), response.body)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
data/test/test_user.rb
CHANGED
@@ -7,7 +7,7 @@ class TestUser < MiniTest::Unit::TestCase
|
|
7
7
|
data = File.read("#{File.dirname(__FILE__)}/../lib/heroku/api/mock/cache/get_user.json")
|
8
8
|
|
9
9
|
assert_equal(200, response.status)
|
10
|
-
assert_equal(Heroku::API
|
10
|
+
assert_equal(Heroku::API.json_decode(data), response.body)
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: excon
|
16
|
-
requirement: &
|
16
|
+
requirement: &70181884166000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.14.
|
21
|
+
version: 0.14.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70181884166000
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: minitest
|
27
|
-
requirement: &
|
27
|
+
requirement: &70181884165300 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70181884165300
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70181884164420 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70181884164420
|
47
47
|
description: Ruby Client for the Heroku API
|
48
48
|
email:
|
49
49
|
- wesley@heroku.com
|
@@ -121,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
segments:
|
123
123
|
- 0
|
124
|
-
hash:
|
124
|
+
hash: 3317431445359256884
|
125
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
126
|
none: false
|
127
127
|
requirements:
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
version: '0'
|
131
131
|
segments:
|
132
132
|
- 0
|
133
|
-
hash:
|
133
|
+
hash: 3317431445359256884
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project:
|
136
136
|
rubygems_version: 1.8.15
|