dawn-api 0.9.0 → 0.10.1
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 +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +49 -0
- data/lib/dawn/api/authenticate.rb +16 -5
- data/lib/dawn/api/base_api.rb +27 -6
- data/lib/dawn/api/hosts.rb +14 -2
- data/lib/dawn/api/models/account.rb +43 -0
- data/lib/dawn/api/{app → models/app}/domains.rb +12 -9
- data/lib/dawn/api/{app → models/app}/drains.rb +10 -7
- data/lib/dawn/api/{app → models/app}/env.rb +3 -7
- data/lib/dawn/api/{app → models/app}/gears.rb +11 -10
- data/lib/dawn/api/models/app/releases.rb +43 -0
- data/lib/dawn/api/models/app.rb +172 -0
- data/lib/dawn/api/models/domain.rb +64 -0
- data/lib/dawn/api/{drain.rb → models/drain.rb} +20 -37
- data/lib/dawn/api/models/gear.rb +79 -0
- data/lib/dawn/api/models/key.rb +63 -0
- data/lib/dawn/api/{login.rb → models/login.rb} +2 -4
- data/lib/dawn/api/models/release.rb +52 -0
- data/lib/dawn/api/models.rb +8 -0
- data/lib/dawn/api/safe/base_api.rb +9 -0
- data/lib/dawn/api/safe/safe_extension.rb +28 -0
- data/lib/dawn/api/safe.rb +2 -0
- data/lib/dawn/api/version.rb +3 -3
- data/lib/dawn/api.rb +2 -6
- metadata +21 -12
- data/lib/dawn/api/app.rb +0 -131
- data/lib/dawn/api/domain.rb +0 -80
- data/lib/dawn/api/gear.rb +0 -101
- data/lib/dawn/api/key.rb +0 -73
@@ -13,68 +13,51 @@ module Dawn
|
|
13
13
|
@data = data
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
data_key :id
|
17
|
+
data_key :created_at
|
18
|
+
data_key :updated_at
|
19
|
+
data_key :url
|
20
|
+
data_key :app_id, "app/id"
|
19
21
|
|
20
22
|
def app
|
21
23
|
@app ||= App.find(id: app_id)
|
22
24
|
end
|
23
25
|
|
24
|
-
def id
|
25
|
-
data["id"]
|
26
|
-
end
|
27
|
-
|
28
|
-
def url
|
29
|
-
data["url"]
|
30
|
-
end
|
31
|
-
|
32
26
|
def refresh
|
33
|
-
@data =
|
34
|
-
expects: 200,
|
35
|
-
method: :get,
|
27
|
+
@data = get(
|
36
28
|
path: "/drains/#{id}",
|
37
29
|
query: options
|
38
30
|
)["drain"]
|
39
31
|
end
|
40
32
|
|
41
|
-
def
|
42
|
-
|
43
|
-
expects: 200,
|
44
|
-
method: :post,
|
45
|
-
path: "/drains/#{id}",
|
46
|
-
body: options.to_json
|
47
|
-
)
|
48
|
-
end
|
49
|
-
|
50
|
-
def destroy(options={})
|
51
|
-
request(
|
52
|
-
expects: 200,
|
53
|
-
method: :delete,
|
54
|
-
path: "/drains/#{id}",
|
55
|
-
query: options
|
56
|
-
)
|
33
|
+
def destroy(options)
|
34
|
+
Drain.destroy(options.merge(id: id))
|
57
35
|
end
|
58
36
|
|
59
37
|
def self.all(options={})
|
60
|
-
|
61
|
-
expects: 200,
|
62
|
-
method: :get,
|
38
|
+
get(
|
63
39
|
path: "/drains",
|
64
40
|
query: options
|
65
41
|
).map { |hsh| new hsh["drain"] }
|
66
42
|
end
|
67
43
|
|
68
44
|
def self.find(options={})
|
69
|
-
id = options
|
45
|
+
id = id_param(options)
|
70
46
|
|
71
|
-
new
|
72
|
-
expects: 200,
|
73
|
-
method: :get,
|
47
|
+
new get(
|
74
48
|
path: "/drains/#{id}",
|
75
49
|
query: options
|
76
50
|
)["drain"]
|
77
51
|
end
|
78
52
|
|
53
|
+
def self.destroy(options={})
|
54
|
+
id = id_param(options)
|
55
|
+
|
56
|
+
delete(
|
57
|
+
path: "/drains/#{id}",
|
58
|
+
query: options
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
79
62
|
end
|
80
63
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'dawn/api/base_api'
|
2
|
+
|
3
|
+
module Dawn
|
4
|
+
class Gear
|
5
|
+
|
6
|
+
include BaseApi
|
7
|
+
|
8
|
+
attr_reader :data
|
9
|
+
attr_writer :app
|
10
|
+
|
11
|
+
def initialize(data)
|
12
|
+
@app = nil
|
13
|
+
@data = data
|
14
|
+
end
|
15
|
+
|
16
|
+
data_key :id
|
17
|
+
data_key :created_at
|
18
|
+
data_key :updated_at
|
19
|
+
data_key :name
|
20
|
+
data_key :uptime
|
21
|
+
data_key :proctype
|
22
|
+
data_key :number
|
23
|
+
data_key :app_id, "app/id"
|
24
|
+
|
25
|
+
def app
|
26
|
+
@app ||= App.find(id: app_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
def refresh
|
30
|
+
@data = get(
|
31
|
+
path: "/gears/#{id}",
|
32
|
+
query: options
|
33
|
+
)["gear"]
|
34
|
+
end
|
35
|
+
|
36
|
+
def restart(options={})
|
37
|
+
self.class.restart(options.merge(id: id))
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy(options)
|
41
|
+
self.class.destroy(options.merge(id: id))
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.all(options={})
|
45
|
+
get(
|
46
|
+
path: "/gears",
|
47
|
+
query: options
|
48
|
+
).map { |d| new d["gear"] }
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.find(options)
|
52
|
+
id = id_param(options)
|
53
|
+
|
54
|
+
new get(
|
55
|
+
path: "/gears/#{id}",
|
56
|
+
query: options
|
57
|
+
)["gear"]
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.restart(options={})
|
61
|
+
self.class.restart(options.merge(id: id))
|
62
|
+
|
63
|
+
post(
|
64
|
+
path: "/gears/#{id}/restart",
|
65
|
+
query: options
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.destroy(options)
|
70
|
+
id = id_param(options)
|
71
|
+
|
72
|
+
delete(
|
73
|
+
path: "/gears/#{id}",
|
74
|
+
query: options
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'dawn/api/base_api'
|
2
|
+
|
3
|
+
module Dawn
|
4
|
+
class Key
|
5
|
+
|
6
|
+
include BaseApi
|
7
|
+
|
8
|
+
attr_reader :data
|
9
|
+
|
10
|
+
def initialize(data)
|
11
|
+
@data = data
|
12
|
+
end
|
13
|
+
|
14
|
+
data_key :id
|
15
|
+
data_key :created_at
|
16
|
+
data_key :updated_at
|
17
|
+
data_key :fingerprint
|
18
|
+
data_key :key
|
19
|
+
|
20
|
+
def destroy(options={})
|
21
|
+
self.class.destroy(options.merge(id: id))
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.create(options={})
|
25
|
+
options.fetch(:key)
|
26
|
+
|
27
|
+
new post(
|
28
|
+
path: '/account/keys',
|
29
|
+
body: options.to_json
|
30
|
+
)["key"]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.all(options={})
|
34
|
+
get(
|
35
|
+
path: '/account/keys',
|
36
|
+
query: options
|
37
|
+
).map { |hsh| new hsh["key"] }
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.find(options={})
|
41
|
+
id = id_param(options)
|
42
|
+
|
43
|
+
new get(
|
44
|
+
path: "/account/keys/#{id}",
|
45
|
+
query: options
|
46
|
+
)["key"]
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.destroy(options={})
|
50
|
+
id = id_param(options)
|
51
|
+
|
52
|
+
delete(
|
53
|
+
path: "/account/keys/#{id}",
|
54
|
+
query: options
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
class << self
|
59
|
+
private :new
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'dawn/api/base_api'
|
2
|
+
|
3
|
+
module Dawn
|
4
|
+
class Release
|
5
|
+
|
6
|
+
include BaseApi
|
7
|
+
|
8
|
+
attr_reader :data
|
9
|
+
attr_writer :app
|
10
|
+
|
11
|
+
def initialize(data)
|
12
|
+
@app = nil
|
13
|
+
@data = data
|
14
|
+
end
|
15
|
+
|
16
|
+
data_key :id
|
17
|
+
data_key :created_at
|
18
|
+
data_key :updated_at
|
19
|
+
data_key :image
|
20
|
+
data_key :app_id, "app/id"
|
21
|
+
|
22
|
+
def app
|
23
|
+
@app ||= App.find(id: app_id)
|
24
|
+
end
|
25
|
+
|
26
|
+
def refresh
|
27
|
+
@data = request(
|
28
|
+
expects: 200,
|
29
|
+
method: :get,
|
30
|
+
path: "/releases/#{id}",
|
31
|
+
query: options
|
32
|
+
)["release"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.all(options={})
|
36
|
+
get(
|
37
|
+
path: "/releases",
|
38
|
+
query: options
|
39
|
+
).map { |hsh| new hsh["release"] }
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.find(options={})
|
43
|
+
id = id_param(options)
|
44
|
+
|
45
|
+
new get(
|
46
|
+
path: "/releases/#{id}",
|
47
|
+
query: options
|
48
|
+
)["release"]
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'dawn/api/authenticate'
|
2
|
+
require 'dawn/api/models/account'
|
3
|
+
require 'dawn/api/models/app'
|
4
|
+
require 'dawn/api/models/domain'
|
5
|
+
require 'dawn/api/models/drain'
|
6
|
+
require 'dawn/api/models/gear'
|
7
|
+
require 'dawn/api/models/key'
|
8
|
+
require 'dawn/api/models/login'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Dawn
|
2
|
+
module SafeExtension
|
3
|
+
class SafeContext
|
4
|
+
attr_accessor :last_exception
|
5
|
+
|
6
|
+
def initialize(obj)
|
7
|
+
@obj = obj
|
8
|
+
@last_exception = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(sym, *args, &block)
|
12
|
+
if @obj.respond_to?(sym)
|
13
|
+
begin
|
14
|
+
@obj.send sym, *args, &block
|
15
|
+
rescue => ex
|
16
|
+
self.last_exception = ex
|
17
|
+
end
|
18
|
+
else
|
19
|
+
@obj.method_missing sym, *args, &block
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def safe
|
25
|
+
SafeContext.new(self)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/dawn/api/version.rb
CHANGED
@@ -2,10 +2,10 @@ module Dawn
|
|
2
2
|
module API
|
3
3
|
module Version
|
4
4
|
MAJOR = 0
|
5
|
-
MINOR =
|
6
|
-
PATCH =
|
5
|
+
MINOR = 10
|
6
|
+
PATCH = 1
|
7
7
|
BUILD = nil
|
8
|
-
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join("
|
8
|
+
STRING = [[MAJOR, MINOR, PATCH].compact.join("."), BUILD].compact.join("-").freeze
|
9
9
|
end
|
10
10
|
# backward compatibility
|
11
11
|
VERSION = Version::STRING
|
data/lib/dawn/api.rb
CHANGED
@@ -2,9 +2,5 @@ require 'json'
|
|
2
2
|
|
3
3
|
require 'dawn/api/version'
|
4
4
|
require 'dawn/api/authenticate'
|
5
|
-
require 'dawn/api/
|
6
|
-
|
7
|
-
require 'dawn/api/drain'
|
8
|
-
require 'dawn/api/gear'
|
9
|
-
require 'dawn/api/key'
|
10
|
-
require 'dawn/api/login'
|
5
|
+
require 'dawn/api/models'
|
6
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dawn-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blaž Hrastnik
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: excon
|
@@ -73,20 +73,29 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- CHANGELOG.md
|
77
|
+
- README.md
|
76
78
|
- lib/dawn/api.rb
|
77
|
-
- lib/dawn/api/app.rb
|
78
|
-
- lib/dawn/api/app/domains.rb
|
79
|
-
- lib/dawn/api/app/drains.rb
|
80
|
-
- lib/dawn/api/app/env.rb
|
81
|
-
- lib/dawn/api/app/gears.rb
|
82
79
|
- lib/dawn/api/authenticate.rb
|
83
80
|
- lib/dawn/api/base_api.rb
|
84
|
-
- lib/dawn/api/domain.rb
|
85
|
-
- lib/dawn/api/drain.rb
|
86
|
-
- lib/dawn/api/gear.rb
|
87
81
|
- lib/dawn/api/hosts.rb
|
88
|
-
- lib/dawn/api/
|
89
|
-
- lib/dawn/api/
|
82
|
+
- lib/dawn/api/models.rb
|
83
|
+
- lib/dawn/api/models/account.rb
|
84
|
+
- lib/dawn/api/models/app.rb
|
85
|
+
- lib/dawn/api/models/app/domains.rb
|
86
|
+
- lib/dawn/api/models/app/drains.rb
|
87
|
+
- lib/dawn/api/models/app/env.rb
|
88
|
+
- lib/dawn/api/models/app/gears.rb
|
89
|
+
- lib/dawn/api/models/app/releases.rb
|
90
|
+
- lib/dawn/api/models/domain.rb
|
91
|
+
- lib/dawn/api/models/drain.rb
|
92
|
+
- lib/dawn/api/models/gear.rb
|
93
|
+
- lib/dawn/api/models/key.rb
|
94
|
+
- lib/dawn/api/models/login.rb
|
95
|
+
- lib/dawn/api/models/release.rb
|
96
|
+
- lib/dawn/api/safe.rb
|
97
|
+
- lib/dawn/api/safe/base_api.rb
|
98
|
+
- lib/dawn/api/safe/safe_extension.rb
|
90
99
|
- lib/dawn/api/version.rb
|
91
100
|
homepage: https://github.com/dawn/dawn-api
|
92
101
|
licenses:
|
data/lib/dawn/api/app.rb
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
require 'dawn/api/hosts'
|
2
|
-
require 'dawn/api/base_api'
|
3
|
-
require 'dawn/api/app/env'
|
4
|
-
require 'dawn/api/app/gears'
|
5
|
-
require 'dawn/api/app/drains'
|
6
|
-
require 'dawn/api/app/domains'
|
7
|
-
|
8
|
-
module Dawn
|
9
|
-
class App
|
10
|
-
|
11
|
-
include BaseApi
|
12
|
-
|
13
|
-
attr_reader :data
|
14
|
-
attr_reader :env
|
15
|
-
|
16
|
-
def initialize(hsh)
|
17
|
-
@data = hsh
|
18
|
-
@env = Env.new(self, @data.delete("env"))
|
19
|
-
end
|
20
|
-
|
21
|
-
def name
|
22
|
-
data["name"]
|
23
|
-
end
|
24
|
-
|
25
|
-
def id
|
26
|
-
data["id"]
|
27
|
-
end
|
28
|
-
|
29
|
-
def formation
|
30
|
-
data["formation"]
|
31
|
-
end
|
32
|
-
|
33
|
-
def git
|
34
|
-
data["git"]
|
35
|
-
end
|
36
|
-
|
37
|
-
def restart(options={})
|
38
|
-
request(
|
39
|
-
expects: 200,
|
40
|
-
method: :delete,
|
41
|
-
path: "/apps/#{id}/gears",
|
42
|
-
query: options
|
43
|
-
)
|
44
|
-
end
|
45
|
-
|
46
|
-
def gears
|
47
|
-
@gears ||= Gears.new self
|
48
|
-
end
|
49
|
-
|
50
|
-
def drains
|
51
|
-
@drains ||= Drains.new self
|
52
|
-
end
|
53
|
-
|
54
|
-
def domains
|
55
|
-
@domains ||= Domains.new self
|
56
|
-
end
|
57
|
-
|
58
|
-
def logs(options={})
|
59
|
-
url = json_request(
|
60
|
-
expects: 200,
|
61
|
-
method: :get,
|
62
|
-
path: "/apps/#{id}/logs",
|
63
|
-
query: options
|
64
|
-
)["logs"]
|
65
|
-
"http://#{Dawn.log_host}#{url}"
|
66
|
-
end
|
67
|
-
|
68
|
-
def update(options={})
|
69
|
-
data.merge!(json_request(
|
70
|
-
expects: 200,
|
71
|
-
method: :patch,
|
72
|
-
path: "/apps/#{id}",
|
73
|
-
body: { name: name }.merge(options).to_json
|
74
|
-
)["app"])
|
75
|
-
end
|
76
|
-
|
77
|
-
def scale(options={})
|
78
|
-
request(
|
79
|
-
expects: 200,
|
80
|
-
method: :post,
|
81
|
-
path: "/apps/#{id}/scale",
|
82
|
-
body: options.to_json
|
83
|
-
)
|
84
|
-
end
|
85
|
-
|
86
|
-
def destroy(options={})
|
87
|
-
request(
|
88
|
-
expects: 200,
|
89
|
-
method: :delete,
|
90
|
-
path: "/apps/#{id}",
|
91
|
-
query: options
|
92
|
-
)
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.all(options={})
|
96
|
-
json_request(
|
97
|
-
expects: 200,
|
98
|
-
method: :get,
|
99
|
-
path: "/apps",
|
100
|
-
query: options
|
101
|
-
).map { |hsh| new(hsh["app"]) }
|
102
|
-
end
|
103
|
-
|
104
|
-
def self.create(options)
|
105
|
-
new json_request(
|
106
|
-
expects: 200,
|
107
|
-
method: :post,
|
108
|
-
path: '/apps',
|
109
|
-
body: options.to_json
|
110
|
-
)["app"]
|
111
|
-
end
|
112
|
-
|
113
|
-
def self.find(options)
|
114
|
-
path = options[:id] ? "/apps/#{options.delete(:id)}" : "/apps"
|
115
|
-
hsh = json_request(
|
116
|
-
expects: 200,
|
117
|
-
method: :get,
|
118
|
-
path: path,
|
119
|
-
query: options
|
120
|
-
)
|
121
|
-
hsh = hsh.first if hsh.is_a?(Array)
|
122
|
-
hsh && new(hsh["app"])
|
123
|
-
end
|
124
|
-
|
125
|
-
def self.destroy(options)
|
126
|
-
app = find options
|
127
|
-
app.destroy if app
|
128
|
-
end
|
129
|
-
|
130
|
-
end
|
131
|
-
end
|
data/lib/dawn/api/domain.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'dawn/api/base_api'
|
2
|
-
|
3
|
-
module Dawn
|
4
|
-
class Domain
|
5
|
-
|
6
|
-
include BaseApi
|
7
|
-
|
8
|
-
attr_reader :data
|
9
|
-
attr_writer :app
|
10
|
-
|
11
|
-
def initialize(data)
|
12
|
-
@app = nil
|
13
|
-
@data = data
|
14
|
-
end
|
15
|
-
|
16
|
-
def app_id
|
17
|
-
data["app_id"]
|
18
|
-
end
|
19
|
-
|
20
|
-
def app
|
21
|
-
@app ||= App.find(id: app_id)
|
22
|
-
end
|
23
|
-
|
24
|
-
def id
|
25
|
-
data["id"]
|
26
|
-
end
|
27
|
-
|
28
|
-
def url
|
29
|
-
data["url"]
|
30
|
-
end
|
31
|
-
|
32
|
-
def refresh
|
33
|
-
@data = json_request(
|
34
|
-
expects: 200,
|
35
|
-
method: :get,
|
36
|
-
path: "/domains/#{id}",
|
37
|
-
query: options
|
38
|
-
)["domain"]
|
39
|
-
end
|
40
|
-
|
41
|
-
def update(options={})
|
42
|
-
request(
|
43
|
-
expects: 200,
|
44
|
-
method: :post,
|
45
|
-
path: "/domains/#{id}",
|
46
|
-
body: options.to_json
|
47
|
-
)
|
48
|
-
end
|
49
|
-
|
50
|
-
def destroy(options={})
|
51
|
-
request(
|
52
|
-
expects: 200,
|
53
|
-
method: :delete,
|
54
|
-
path: "/domains/#{id}",
|
55
|
-
query: options
|
56
|
-
)
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.all(options={})
|
60
|
-
json_request(
|
61
|
-
expects: 200,
|
62
|
-
method: :get,
|
63
|
-
path: "/domains",
|
64
|
-
query: options
|
65
|
-
).map { |hsh| new hsh["domain"] }
|
66
|
-
end
|
67
|
-
|
68
|
-
def self.find(options)
|
69
|
-
id = options.delete(:id)
|
70
|
-
|
71
|
-
new json_request(
|
72
|
-
expects: 200,
|
73
|
-
method: :get,
|
74
|
-
path: "/domains/#{id}",
|
75
|
-
query: options
|
76
|
-
)["domain"]
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|