platform-api 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -4
- data/lib/platform-api/client.rb +16 -2
- data/lib/platform-api/version.rb +1 -1
- data/platform-api.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55cb2a8539f3f2c2125ca1d37f11c004b5c6acd7
|
4
|
+
data.tar.gz: c24292d90bb59ed473f42349e0bea60ab10cb0d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5f4f716094a9e9622e2e5e286633961dc029629852df9b207aa950d3eae73594e61654d7af0192d0516db2f9d74a94ee64e9b8712a4fd67c483d48d57e8378a
|
7
|
+
data.tar.gz: 9db71e470f1c78921d7609f132d448885d2a3cb1d7228a56161207ce376fd41c30f07804f42030fc802326db2709b2da826a6e6ab5b36d80365fc175d7272eb5
|
data/README.md
CHANGED
@@ -60,15 +60,29 @@ 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
|
64
|
-
|
65
|
-
|
63
|
+
it. The first thing you need is a client setup with an OAuth token. You can
|
64
|
+
create an OAuth token using the `heroku-oauth` toolbelt plugin:
|
65
|
+
|
66
|
+
```bash
|
67
|
+
$ heroku plugins:install git@github.com:heroku/heroku-oauth.git
|
68
|
+
$ heroku authorizations:create -d "Platform API example token"
|
69
|
+
Created OAuth authorization.
|
70
|
+
ID: 2f01aac0-e9d3-4773-af4e-3e510aa006ca
|
71
|
+
Description: Platform API example token
|
72
|
+
Scope: global
|
73
|
+
Token: e7dd6ad7-3c6a-411e-a2be-c9fe52ac7ed2
|
74
|
+
```
|
75
|
+
|
76
|
+
Use the `Token` value when instantiating a client:
|
66
77
|
|
67
78
|
```ruby
|
68
79
|
require 'platform-api'
|
69
|
-
heroku = PlatformAPI.
|
80
|
+
heroku = PlatformAPI.connect_oauth('e7dd6ad7-3c6a-411e-a2be-c9fe52ac7ed2')
|
70
81
|
```
|
71
82
|
|
83
|
+
The [OAuth article]()https://devcenter.heroku.com/articles/oauth has more information about OAuth tokens, including how to
|
84
|
+
create tokens with specific scopes.
|
85
|
+
|
72
86
|
Now let's create an app:
|
73
87
|
|
74
88
|
```ruby
|
data/lib/platform-api/client.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
module PlatformAPI
|
2
|
-
# Get a client configured with the specified token.
|
3
|
-
def self.
|
2
|
+
# Get a client configured with the specified OAuth token.
|
3
|
+
def self.connect_oauth(oauth_token)
|
4
|
+
url = "https://api.heroku.com"
|
5
|
+
default_headers = {'Accept' => 'application/vnd.heroku+json; version=3'}
|
6
|
+
cache = Moneta.new(:File, dir: "#{Dir.home}/.heroku/platform-api")
|
7
|
+
options = {default_headers: default_headers, cache: cache}
|
8
|
+
schema_json = File.read("#{File.dirname(__FILE__)}/schema.json")
|
9
|
+
schema = Heroics::Schema.new(MultiJson.decode(schema_json))
|
10
|
+
Heroics.oauth_client_from_schema(oauth_token, schema, url, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Get a client configured with the specified API token.
|
14
|
+
#
|
15
|
+
# Always prefer `connect_oauth` unless there's a very good reason you must
|
16
|
+
# use a non-OAuth API token.
|
17
|
+
def self.connect(token)
|
4
18
|
url = "https://:#{token}@api.heroku.com"
|
5
19
|
default_headers = {'Accept' => 'application/vnd.heroku+json; version=3'}
|
6
20
|
cache = Moneta.new(:File, dir: "#{Dir.home}/.heroku/platform-api")
|
data/lib/platform-api/version.rb
CHANGED
data/platform-api.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: platform-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jkakar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.0.
|
47
|
+
version: 0.0.5
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.0.
|
54
|
+
version: 0.0.5
|
55
55
|
description: Ruby HTTP client for the Heroku API.
|
56
56
|
email:
|
57
57
|
- jkakar@kakar.ca
|