platform-api 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30650e1cb768ab40187de984a7758f1d4a7baf8e
4
- data.tar.gz: 9986413c179ffb63979212fb2782cc76c6cc9d1f
3
+ metadata.gz: dc573a7f60a0a23121a4884dc04541d9fc11e47a
4
+ data.tar.gz: 1ebd353900700ec76f53f2df7d97795c0bbdc9b1
5
5
  SHA512:
6
- metadata.gz: 343e26b799e139a176862bf955ee1bf1210dd87d474b41b686b229f6597c13b99cd070045b992ecc7d2623dda0e9625b33dde70463c9286170f84e6ac0899efa
7
- data.tar.gz: 3ab6ce2a3c17a5e23dd3a2a3ccc371e16d635fb34d3438daa3d10ad9a2550496aa7010fd98e0aa31c01b0ded08bff896621f2cbf80fc9fc144075b5214fea569
6
+ metadata.gz: f671726d70cc5228706cb0f997021c584ce1400491e752ce7063c4be1fcd19cee2bfc82510385f732b86d2f81f41fdf90b91158b07ee03a81c52beb703e14e0d
7
+ data.tar.gz: 3374fc2827b622e901a7c9ab1ce1035b0e0db5a7cededf4e4e570d47e28759d8ea370090058c511118614aaaca2ab65db9fd1641101bf4da21b8f29f6d243e8d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- platform-api (0.0.2)
4
+ platform-api (0.0.3)
5
5
  heroics
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -36,15 +36,15 @@ information about the support actions. For example, the [Formation](https://dev
36
36
  resource has [Info](https://devcenter.heroku.com/articles/platform-api-reference#formation-info), [List](https://devcenter.heroku.com/articles/platform-api-reference#formation-list), [Batch update](https://devcenter.heroku.com/articles/platform-api-reference#formation-batch-update), and [Update](https://devcenter.heroku.com/articles/platform-api-reference#formation-update) actions.
37
37
 
38
38
  You can easily map any resource and its related action client methods. The
39
- formation actions above are accessed as `client.formation.info`,
40
- `client.formation.list`, `client.formation.batch_update` and
41
- `client.formation.update`. When the URL for one of these actions includes
39
+ formation actions above are accessed as `heroku.formation.info`,
40
+ `heroku.formation.list`, `heroku.formation.batch_update` and
41
+ `heroku.formation.update`. When the URL for one of these actions includes
42
42
  parameters they should be passed as arguments to the method. When the request
43
43
  expects a request payload it should be passed as a Ruby Hash in the final
44
44
  argument to the method.
45
45
 
46
46
  For example, to get information about the `web` formation on the `sushi` app
47
- you'd invoke `client.formation.info('sushi', 'web')` and it would return a
47
+ you'd invoke `heroku.formation.info('sushi', 'web')` and it would return a
48
48
  Ruby object that matches the one given in the [response example](https://devcenter.heroku.com/articles/platform-api-reference#formation-info).
49
49
 
50
50
  Once you get used to these basic patterns using the client is quite easy
@@ -60,19 +60,19 @@ raises `Excon::Error` exceptions when errors occur. You can catch specific
60
60
  ### A real world example
61
61
 
62
62
  Let's go through an example of creating an app and using the API to work with
63
- it. The first thing you need is a client that's setup with your username and
64
- API token. You can find your API token by clicking the *Show API Key* on your
63
+ it. The first thing you need is a client that's setup with your API token.
64
+ You can find your API token by clicking the *Show API Key* on your
65
65
  [account page](https://dashboard.heroku.com/account).
66
66
 
67
67
  ```ruby
68
68
  require 'platform-api'
69
- client = PlatformAPI.connect('username', 'token')
69
+ heroku = PlatformAPI.connect('token')
70
70
  ```
71
71
 
72
72
  Now let's create an app:
73
73
 
74
74
  ```ruby
75
- client.app.create
75
+ heroku.app.create
76
76
  => {"id"=>22979756,
77
77
  "name"=>"floating-retreat-4255",
78
78
  "dynos"=>0,
@@ -107,7 +107,7 @@ client.app.create
107
107
  We can read the same information back with the `info` method.
108
108
 
109
109
  ```ruby
110
- client.app.info('floating-retreat-4255')
110
+ heroku.app.info('floating-retreat-4255')
111
111
  => {"id"=>22979756,
112
112
  "name"=>"floating-retreat-4255",
113
113
  "dynos"=>0,
@@ -142,7 +142,7 @@ client.app.info('floating-retreat-4255')
142
142
  Let's add a Heroku PostgreSQL database to our app now:
143
143
 
144
144
  ```ruby
145
- client.addon.create('floating-retreat-4255', {'plan' => 'heroku-postgresql:dev'})
145
+ heroku.addon.create('floating-retreat-4255', {'plan' => 'heroku-postgresql:dev'})
146
146
  => {"config_vars"=>["HEROKU_POSTGRESQL_COBALT_URL"],
147
147
  "created_at"=>"2014-03-13T00:28:55Z",
148
148
  "id"=>"79a0c826-06be-4dcd-8bb5-f2c1b1bc2beb",
@@ -157,16 +157,15 @@ client.addon.create('floating-retreat-4255', {'plan' => 'heroku-postgresql:dev'}
157
157
  Excellent! That will have added a config var which we can now see:
158
158
 
159
159
  ```ruby
160
- client.config_var.info('floating-retreat-4255')
161
- => client.config_var.info('floating-retreat-4255')
162
- {"HEROKU_POSTGRESQL_COBALT_URL"=>"postgres://<redacted>"}
160
+ heroku.config_var.info('floating-retreat-4255')
161
+ => {"HEROKU_POSTGRESQL_COBALT_URL"=>"postgres://<redacted>"}
163
162
  ```
164
163
 
165
164
  And there we go, we have the config var. Let's set an additional config var,
166
- which will also demonstrate an request that needs a payload:
165
+ which will also demonstrate how to make a request that needs a payload:
167
166
 
168
167
  ```ruby
169
- client.config_var.update('floating-retreat-4255', {'MYAPP' => 'ROCKS'})
168
+ heroku.config_var.update('floating-retreat-4255', {'MYAPP' => 'ROCKS'})
170
169
  => {"HEROKU_POSTGRESQL_COBALT_URL"=>"postgres://<redacted>",
171
170
  "MYAPP"=>"ROCKS"}
172
171
  ```
@@ -204,7 +203,7 @@ Total 489 (delta 244), reused 489 (delta 244)
204
203
  We can now use the API to see our `web` process running:
205
204
 
206
205
  ```ruby
207
- client.formation.list('floating-retreat-4255')
206
+ heroku.formation.list('floating-retreat-4255')
208
207
  => [{"command"=>"coffee index.coffee",
209
208
  "created_at"=>"2014-03-13T04:13:37Z",
210
209
  "id"=>"f682b260-8089-4e18-b792-688cc02bf923",
@@ -217,7 +216,10 @@ client.formation.list('floating-retreat-4255')
217
216
  Let's change `web` process to run on a 2X dyno:
218
217
 
219
218
  ```ruby
220
- client.formation.batch_update('floating-retreat-4255', {"updates" => [{"process" => "web", "quantity" => 1, "size" => "2X"}]})
219
+ heroku.formation.batch_update('floating-retreat-4255',
220
+ {"updates" => [{"process" => "web",
221
+ "quantity" => 1,
222
+ "size" => "2X"}]})
221
223
  => [{"command"=>"coffee index.coffee",
222
224
  "created_at"=>"2014-03-13T04:13:37Z",
223
225
  "id"=>"f682b260-8089-4e18-b792-688cc02bf923",
@@ -232,7 +234,7 @@ command. We can use the singular update action to modify a single formation
232
234
  type:
233
235
 
234
236
  ```ruby
235
- client.formation.update('floating-retreat-4255', 'web', {"size" => "1X"})
237
+ heroku.formation.update('floating-retreat-4255', 'web', {"size" => "1X"})
236
238
  => {"command"=>"coffee index.coffee",
237
239
  "created_at"=>"2014-03-13T04:13:37Z",
238
240
  "id"=>"f682b260-8089-4e18-b792-688cc02bf923",
@@ -242,8 +244,9 @@ client.formation.update('floating-retreat-4255', 'web', {"size" => "1X"})
242
244
  "updated_at"=>"2014-03-13T04:24:46Z"}
243
245
  ```
244
246
 
245
- Hopefully this has given you a taste of how the client works. If you have
246
- questions please feel free to file issues.
247
+ Hopefully this has given you a taste of how the client works and an
248
+ understanding of how resources and actions are mapped from the documentation.
249
+ If you have questions please feel free to file issues.
247
250
 
248
251
  ### Debugging
249
252
 
@@ -1,7 +1,7 @@
1
1
  module PlatformAPI
2
- # Get a client configured with the specified username and token.
3
- def self.connect(username, token)
4
- url = "https://#{username}:#{token}@api.heroku.com"
2
+ # Get a client configured with the specified token.
3
+ def self.connect( token)
4
+ url = "https://:#{token}@api.heroku.com"
5
5
  default_headers = {'Accept' => 'application/vnd.heroku+json; version=3'}
6
6
  cache = Moneta.new(:File, dir: "#{Dir.home}/.heroku/platform-api")
7
7
  options = {default_headers: default_headers, cache: cache}
@@ -1,3 +1,3 @@
1
1
  module PlatformAPI
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platform-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jkakar