dawn-api 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/lib/dawn/api/authenticate.rb +33 -7
- data/lib/dawn/api/base_api.rb +52 -6
- data/lib/dawn/api/health_check.rb +14 -0
- data/lib/dawn/api/hosts.rb +16 -3
- data/lib/dawn/api/models/account.rb +44 -15
- data/lib/dawn/api/models/app/domains.rb +30 -6
- data/lib/dawn/api/models/app/drains.rb +30 -6
- data/lib/dawn/api/models/app/env.rb +19 -5
- data/lib/dawn/api/models/app/gears.rb +31 -7
- data/lib/dawn/api/models/app/releases.rb +28 -8
- data/lib/dawn/api/models/app.rb +93 -16
- data/lib/dawn/api/models/domain.rb +36 -11
- data/lib/dawn/api/models/drain.rb +33 -19
- data/lib/dawn/api/models/gear.rb +45 -25
- data/lib/dawn/api/models/key.rb +33 -15
- data/lib/dawn/api/models/login.rb +5 -4
- data/lib/dawn/api/models/release.rb +32 -14
- data/lib/dawn/api/safe/base_api.rb +3 -3
- data/lib/dawn/api/safe/safe_extension.rb +20 -5
- data/lib/dawn/api/version.rb +5 -5
- data/lib/dawn/api.rb +1 -1
- data/spec/api/account_spec.rb +21 -0
- data/spec/api/app/domains_spec.rb +30 -0
- data/spec/api/app/drains_spec.rb +30 -0
- data/spec/api/app/gears_spec.rb +38 -0
- data/spec/api/app/releases_spec.rb +30 -0
- data/spec/api/app_spec.rb +166 -0
- data/spec/api/domain_spec.rb +54 -0
- data/spec/api/drain_spec.rb +54 -0
- data/spec/api/gear_spec.rb +65 -0
- data/spec/api/key_spec.rb +54 -0
- data/spec/api/release_spec.rb +13 -0
- data/spec/api_spec_helper.rb +18 -0
- data/spec/references/data.yml +16 -0
- data/spec/seed.rb +70 -0
- data/spec/seedlog.log +1454 -0
- data/spec/support/vcr.rb +11 -0
- data/spec/vcr/Dawn_Account/_current/should_retrieve_current_user_account.yml +51 -0
- data/spec/vcr/Dawn_Account/_update/should_update_an_account.yml +99 -0
- data/spec/vcr/Dawn_App/_all/should_only_have_an_array_of_apps.yml +62 -0
- data/spec/vcr/Dawn_App/_all/should_retrieve_all_user_apps.yml +62 -0
- data/spec/vcr/Dawn_App/_create/should_create_a_new_app_given_a_name.yml +51 -0
- data/spec/vcr/Dawn_App/_create/should_raise_an_Excon_Errors_UnprocessableEntity_when_an_invalid_name_is_given.yml +49 -0
- data/spec/vcr/Dawn_App/_destroy/should_destroy_1_app.yml +49 -0
- data/spec/vcr/Dawn_App/_destroy/should_fail_to_destroy_non-existant_app.yml +48 -0
- data/spec/vcr/Dawn_App/_domains/should_have_domains.yml +51 -0
- data/spec/vcr/Dawn_App/_domains/should_retrieve_domains.yml +98 -0
- data/spec/vcr/Dawn_App/_drains/should_have_drains.yml +51 -0
- data/spec/vcr/Dawn_App/_find/should_fail_to_find_a_non_existant_app.yml +48 -0
- data/spec/vcr/Dawn_App/_find/should_retrieve_1_app_by_id.yml +111 -0
- data/spec/vcr/Dawn_App/_find/should_retrieve_1_app_by_name.yml +51 -0
- data/spec/vcr/Dawn_App/_gears/should_have_gears.yml +51 -0
- data/spec/vcr/Dawn_App/_gears/should_restart_gears.yml +98 -0
- data/spec/vcr/Dawn_App/_gears/should_retrieve_gears.yml +98 -0
- data/spec/vcr/Dawn_App/_logs/should_fail_to_retrieve_logs_uri_for_a_non_existant_app.yml +48 -0
- data/spec/vcr/Dawn_App/_logs/should_retrieve_logs_url_for_app.yml +98 -0
- data/spec/vcr/Dawn_App/_releases/should_have_releases.yml +51 -0
- data/spec/vcr/Dawn_App/_releases/should_retrieve_releases.yml +98 -0
- data/spec/vcr/Dawn_App/_restart/should_fail_to_restart_a_non_existant_app.yml +48 -0
- data/spec/vcr/Dawn_App/_scale/should_have_updated_formation.yml +51 -0
- data/spec/vcr/Dawn_App/_scale/should_raise_an_IndexError_if_app_key_is_missing.yml +51 -0
- data/spec/vcr/Dawn_App/_scale/should_scale_app.yml +98 -0
- data/spec/vcr/Dawn_App/_update/should_fail_to_update_non-existant_app.yml +48 -0
- data/spec/vcr/Dawn_App_Domains/_all/should_have_only_domains.yml +98 -0
- data/spec/vcr/Dawn_App_Domains/_all/should_return_all_domains.yml +98 -0
- data/spec/vcr/Dawn_App_Domains/_create/should_create_a_new_domain.yml +99 -0
- data/spec/vcr/Dawn_App_Drains/_all/should_have_only_drains.yml +98 -0
- data/spec/vcr/Dawn_App_Drains/_all/should_return_all_drains.yml +98 -0
- data/spec/vcr/Dawn_App_Drains/_create/should_create_a_new_drain.yml +99 -0
- data/spec/vcr/Dawn_App_Gears/_all/should_return_all_gears.yml +98 -0
- data/spec/vcr/Dawn_App_Releases/_all/should_return_all_releases.yml +98 -0
- data/spec/vcr/Dawn_App_Releases/_create/should_create_a_new_release.yml +423 -0
- data/spec/vcr/Dawn_Key/_all/should_retrieve_all_user_keys.yml +52 -0
- data/spec/vcr/Dawn_Key/_create/should_create_a_new_sshkey.yml +51 -0
- data/spec/vcr/Dawn_Key/_create/should_fail_if_sshkey_is_invalid.yml +49 -0
- data/spec/vcr/Dawn_Key/_destroy/should_404_if_key_does_not_exist.yml +48 -0
- data/spec/vcr/Dawn_Key/_destroy/should_remove_a_key_by_id.yml +98 -0
- data/spec/vcr/Dawn_Key/_find/should_404_if_key_does_not_exist.yml +48 -0
- data/spec/vcr/Dawn_Key/_find/should_find_a_key_by_id.yml +99 -0
- data/spec/vcr/Dawn_Release/_find/should_find_1_release_by_id.yml +48 -0
- metadata +62 -3
- data/lib/dawn/api/safe.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b1e546771ef62776a3f7def9a4de87059776ac6
|
4
|
+
data.tar.gz: 0f99cf21c60e819dcc1580698579fe35e0c0caea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ab169c0ee2d465c74e50a566c4dfb4de03d1dd3825be826e9826fcb35615526e6bf7e756e0bcf7e0d55e8dba00cd7015bb5580d09d05e5a7f39c7e3a7f1dd28
|
7
|
+
data.tar.gz: f0127406fc40a51e23ac2b467b5e18372aba70bf479ace4f7c043d10272d387574bc1667fc3adf70aaf47823148ead06baf406ae0e079ce48ed055823120800c
|
data/README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
Dawn-API
|
2
2
|
========
|
3
|
-
[link](https://github.com/dawn/dawn-api)
|
4
|
-
|
5
3
|
[![Dependency Status](https://gemnasium.com/dawn/dawn-api.svg)](https://gemnasium.com/dawn/dawn-api)
|
6
4
|
[![Gem Version](https://badge.fury.io/rb/dawn-api.svg)](http://badge.fury.io/rb/dawn-api)
|
7
5
|
[![Code Climate](https://codeclimate.com/github/dawn/dawn-api.png)](https://codeclimate.com/github/dawn/dawn-api)
|
6
|
+
[![Inch-CI](http://inch-ci.org/github/dawn/dawn-api.png?branch=master)](http://inch-ci.org/github/dawn/dawn-api)
|
8
7
|
|
9
|
-
API for [Dawn](https://github.com/dawn/dawn)
|
8
|
+
Ruby [API](https://github.com/dawn/dawn-api) for [Dawn](https://github.com/dawn/dawn)
|
10
9
|
|
11
10
|
## Installation
|
12
11
|
```shell
|
@@ -44,6 +43,6 @@ One day I'll write this properly, however for now:
|
|
44
43
|
```ruby
|
45
44
|
Dawn.authenticate
|
46
45
|
my_app = Dawn::App.create
|
47
|
-
my_app.
|
46
|
+
my_app.domains.all
|
48
47
|
my_app.gears.restart
|
49
48
|
```
|
@@ -3,8 +3,10 @@ require 'base64'
|
|
3
3
|
require 'excon'
|
4
4
|
require 'netrc'
|
5
5
|
|
6
|
-
module Dawn
|
7
|
-
|
6
|
+
module Dawn #:nodoc:
|
7
|
+
###
|
8
|
+
# Default request header
|
9
|
+
###
|
8
10
|
HEADERS = {
|
9
11
|
'Accept' => 'application/json',
|
10
12
|
'Content-Type' => 'application/json',
|
@@ -24,19 +26,44 @@ module Dawn
|
|
24
26
|
|
25
27
|
class << self
|
26
28
|
attr_accessor :last_response_body
|
29
|
+
attr_accessor :log
|
30
|
+
end
|
31
|
+
|
32
|
+
###
|
33
|
+
# wrapper method for @log.puts
|
34
|
+
# This method will do nothing if log is nil or false
|
35
|
+
# @param [*] args
|
36
|
+
# @param [&] block
|
37
|
+
###
|
38
|
+
def self.debug(*args, &block)
|
39
|
+
@log && @log.puts(*args, &block)
|
27
40
|
end
|
28
41
|
|
42
|
+
###
|
43
|
+
# @param [Hash] options
|
44
|
+
###
|
29
45
|
def self.request(options)
|
30
46
|
Dawn.authenticate unless @connection
|
31
|
-
expects = options.delete(:expects)
|
32
47
|
response = @connection.request(options)
|
33
48
|
self.last_response_body = response.body
|
34
|
-
if expects && response.status != expects
|
35
|
-
raise Excon::Errors.status_error(options.merge(expects: expects), response)
|
36
|
-
end
|
37
49
|
response
|
50
|
+
rescue Excon::Errors::HTTPStatusError => ex
|
51
|
+
self.last_response_body = ex.response.body
|
52
|
+
debug Time.now.strftime("%D %T")
|
53
|
+
debug options.inspect
|
54
|
+
debug ex.response.body
|
55
|
+
debug "\n"
|
56
|
+
raise ex
|
38
57
|
end
|
39
58
|
|
59
|
+
###
|
60
|
+
# @overload .authenticate
|
61
|
+
# login using netrc
|
62
|
+
# @overload .authenticate(options)
|
63
|
+
# Expects that options includes username and password keys, else defaults
|
64
|
+
# to netrc login
|
65
|
+
# @param [Hash] options
|
66
|
+
###
|
40
67
|
def self.authenticate(options={})
|
41
68
|
options = OPTIONS.merge(host: dawn_api_host, scheme: dawn_scheme).merge(options)
|
42
69
|
options[:headers] = options[:headers].merge(HEADERS)
|
@@ -73,5 +100,4 @@ module Dawn
|
|
73
100
|
)
|
74
101
|
@connection = Excon.new "#{options[:scheme]}://#{options[:host]}", headers: @headers
|
75
102
|
end
|
76
|
-
|
77
103
|
end
|
data/lib/dawn/api/base_api.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
require 'dawn/api/authenticate'
|
2
|
+
require 'dawn/api/safe/base_api'
|
2
3
|
require 'json'
|
3
4
|
|
4
|
-
module Dawn
|
5
|
-
module BaseApi
|
5
|
+
module Dawn #:nodoc:
|
6
|
+
module BaseApi #:nodoc:
|
7
|
+
###
|
8
|
+
# Base request extension module
|
9
|
+
###
|
6
10
|
module RequestExtension
|
11
|
+
###
|
12
|
+
# Wrapper function around Dawn.request
|
13
|
+
# @param [Hash] options
|
14
|
+
###
|
7
15
|
def request(options)
|
8
16
|
options[:expects] = 200 unless options.key?(:expects)
|
9
17
|
JSON.load Dawn.request(options).body
|
@@ -14,31 +22,69 @@ module Dawn
|
|
14
22
|
end
|
15
23
|
end
|
16
24
|
|
17
|
-
module ClassExtension
|
25
|
+
module ClassExtension #:nodoc:
|
18
26
|
include RequestExtension
|
19
27
|
|
28
|
+
###
|
29
|
+
# Strips a valid id parameter from the given options.
|
30
|
+
# This method is normally overwritten in each subclass to suite their
|
31
|
+
# id needs.
|
32
|
+
# @param [Hash] options
|
33
|
+
# @return [String]
|
34
|
+
###
|
20
35
|
def id_param(options)
|
21
36
|
options.delete(:id)
|
22
37
|
end
|
23
38
|
|
24
|
-
|
39
|
+
###
|
40
|
+
# @return [Array]
|
41
|
+
###
|
42
|
+
def data_keys
|
43
|
+
@data_keys ||= []
|
44
|
+
end
|
45
|
+
|
46
|
+
###
|
47
|
+
# Defines accessor for an internal @data Hash.
|
48
|
+
# Methods defined are (key_name) and (key_name)=
|
49
|
+
# @param [Symbol] key_name
|
50
|
+
# @param [Hash] options
|
51
|
+
###
|
52
|
+
def data_key(key_name, options={})
|
53
|
+
options = { write: true, read: true, path: key_name }.merge(options)
|
54
|
+
key_path = options.fetch(:path)
|
55
|
+
|
25
56
|
route = key_path.to_s.split("/")
|
26
57
|
route_dp = route.dup
|
27
58
|
last_key = route_dp.pop
|
28
59
|
|
29
60
|
define_method(key_name) do
|
30
61
|
route.inject(@data) { |d, key| d[key] }
|
31
|
-
end
|
62
|
+
end if options.fetch(:read)
|
32
63
|
define_method(key_name.to_s+"=") do |v|
|
33
64
|
route_dp.inject(@data) { |d, key| d[key] }[last_key] = v
|
34
|
-
end
|
65
|
+
end if options.fetch(:write)
|
66
|
+
|
67
|
+
data_keys.push(key_name)
|
68
|
+
|
69
|
+
return key_name
|
35
70
|
end
|
36
71
|
end
|
37
72
|
|
73
|
+
# :nodoc:
|
38
74
|
def self.included(mod)
|
39
75
|
mod.extend ClassExtension
|
40
76
|
end
|
41
77
|
|
42
78
|
include RequestExtension
|
79
|
+
|
80
|
+
###
|
81
|
+
# Generates a Hash from the data_keys
|
82
|
+
# @return [Hash]
|
83
|
+
###
|
84
|
+
def to_h
|
85
|
+
self.class.data_keys.each_with_object({}) do |key, hash|
|
86
|
+
hash[key] = send(key) if respond_to?(key)
|
87
|
+
end
|
88
|
+
end
|
43
89
|
end
|
44
90
|
end
|
data/lib/dawn/api/hosts.rb
CHANGED
@@ -1,23 +1,36 @@
|
|
1
|
-
module Dawn
|
2
|
-
|
1
|
+
module Dawn #:nodoc:
|
2
|
+
###
|
3
|
+
# @return [String]
|
4
|
+
###
|
3
5
|
def self.dawn_scheme
|
4
6
|
ENV["DAWN_SCHEME"] || "http"
|
5
7
|
end
|
6
8
|
|
9
|
+
###
|
10
|
+
# @return [String]
|
11
|
+
###
|
7
12
|
def self.dawn_host
|
8
13
|
ENV["DAWN_HOST"] || "dawn.dev"
|
9
14
|
end
|
10
15
|
|
16
|
+
###
|
17
|
+
# @return [String]
|
18
|
+
###
|
11
19
|
def self.dawn_api_host
|
12
20
|
ENV["DAWN_API_HOST"] || "api.#{dawn_host}"
|
13
21
|
end
|
14
22
|
|
23
|
+
###
|
24
|
+
# @return [String]
|
25
|
+
###
|
15
26
|
def self.git_host
|
16
27
|
ENV["DAWN_GIT_HOST"] || dawn_host
|
17
28
|
end
|
18
29
|
|
30
|
+
###
|
31
|
+
# @return [String]
|
32
|
+
###
|
19
33
|
def self.log_host
|
20
34
|
ENV["DAWN_LOG_HOST"] || "#{dawn_host}:8001"
|
21
35
|
end
|
22
|
-
|
23
36
|
end
|
@@ -1,43 +1,72 @@
|
|
1
1
|
require 'dawn/api/base_api'
|
2
2
|
|
3
|
-
module Dawn
|
4
|
-
class Account
|
5
|
-
|
3
|
+
module Dawn #:nodoc:
|
4
|
+
class Account #:nodoc:
|
6
5
|
include BaseApi
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
data_key :
|
14
|
-
|
7
|
+
# @type [String]
|
8
|
+
data_key :id, write: false
|
9
|
+
# @type [Integer]
|
10
|
+
data_key :created_at, write: false
|
11
|
+
# @type [Integer]
|
12
|
+
data_key :updated_at, write: false
|
13
|
+
# @type [String]
|
15
14
|
data_key :username
|
15
|
+
# @type [String]
|
16
16
|
data_key :email
|
17
|
-
|
17
|
+
# @type [String]
|
18
|
+
data_key :api_key, write: false
|
19
|
+
|
20
|
+
###
|
21
|
+
# @param [Hash] data
|
22
|
+
###
|
23
|
+
def initialize(data)
|
24
|
+
@data = data
|
25
|
+
end
|
18
26
|
|
27
|
+
###
|
28
|
+
# @param [Hash] options
|
29
|
+
# @return [self]
|
30
|
+
###
|
19
31
|
def refresh(options={})
|
20
32
|
@data = get(
|
21
33
|
path: "/account",
|
22
34
|
query: options
|
23
|
-
)["
|
35
|
+
)["user"]
|
36
|
+
self
|
24
37
|
end
|
25
38
|
|
39
|
+
###
|
40
|
+
# @param [Hash] options
|
41
|
+
# @return [self]
|
42
|
+
###
|
26
43
|
def update(options={})
|
27
44
|
options.fetch(:account)
|
28
45
|
|
29
46
|
@data = patch(
|
30
47
|
path: "/account",
|
31
48
|
body: options.to_json
|
32
|
-
)["
|
49
|
+
)["user"]
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
###
|
54
|
+
# Using the currently stored @data, #update self
|
55
|
+
# @return [self]
|
56
|
+
###
|
57
|
+
def save
|
58
|
+
update(account: @data)
|
33
59
|
end
|
34
60
|
|
61
|
+
###
|
62
|
+
# @param [Hash] data
|
63
|
+
# @return [Dawn::Account]
|
64
|
+
###
|
35
65
|
def self.current(options={})
|
36
66
|
new get(
|
37
67
|
path: "/account",
|
38
68
|
query: options
|
39
|
-
)["
|
69
|
+
)["user"]
|
40
70
|
end
|
41
|
-
|
42
71
|
end
|
43
72
|
end
|
@@ -1,23 +1,38 @@
|
|
1
1
|
require 'dawn/api/base_api'
|
2
2
|
require 'dawn/api/models/domain'
|
3
3
|
|
4
|
-
module Dawn
|
5
|
-
class App
|
6
|
-
class Domains
|
7
|
-
|
8
|
-
include BaseApi
|
9
|
-
include Enumerable
|
4
|
+
module Dawn #:nodoc:
|
5
|
+
class App #:nodoc:
|
6
|
+
class Domains #:nodoc:
|
7
|
+
include BaseApi, Enumerable
|
10
8
|
|
9
|
+
# @type [Dawn::App]
|
11
10
|
attr_reader :app
|
12
11
|
|
12
|
+
###
|
13
|
+
# @param [Dawn::App] app
|
14
|
+
###
|
13
15
|
def initialize(app)
|
14
16
|
@app = app
|
15
17
|
end
|
16
18
|
|
19
|
+
###
|
20
|
+
# @return [Array<Dawn::Domain>]
|
21
|
+
###
|
22
|
+
def to_a
|
23
|
+
all
|
24
|
+
end
|
25
|
+
|
26
|
+
###
|
27
|
+
# @overload each { |domain| do_stuff_with_domain }
|
28
|
+
###
|
17
29
|
def each(&block)
|
18
30
|
all.each(&block)
|
19
31
|
end
|
20
32
|
|
33
|
+
###
|
34
|
+
# @return [Dawn::Domain]
|
35
|
+
###
|
21
36
|
def create(options)
|
22
37
|
options.fetch(:domain)
|
23
38
|
|
@@ -27,6 +42,9 @@ module Dawn
|
|
27
42
|
)["domain"]).tap { |d| d.app = @app }
|
28
43
|
end
|
29
44
|
|
45
|
+
###
|
46
|
+
# @return [Array<Dawn::Domain>]
|
47
|
+
###
|
30
48
|
def all(options={})
|
31
49
|
get(
|
32
50
|
path: "/apps/#{app.id}/domains",
|
@@ -34,10 +52,16 @@ module Dawn
|
|
34
52
|
).map { |hsh| Domain.new(hsh["domain"]).tap { |d| d.app = @app } }
|
35
53
|
end
|
36
54
|
|
55
|
+
###
|
56
|
+
# @return [Dawn::Domain]
|
57
|
+
###
|
37
58
|
def find(options)
|
38
59
|
Domain.find(options).tap { |d| d.app = @app }
|
39
60
|
end
|
40
61
|
|
62
|
+
def destroy(options)
|
63
|
+
Domain.destroy(options)
|
64
|
+
end
|
41
65
|
end
|
42
66
|
end
|
43
67
|
end
|
@@ -1,23 +1,38 @@
|
|
1
1
|
require 'dawn/api/base_api'
|
2
2
|
require 'dawn/api/models/drain'
|
3
3
|
|
4
|
-
module Dawn
|
5
|
-
class App
|
6
|
-
class Drains
|
7
|
-
|
8
|
-
include BaseApi
|
9
|
-
include Enumerable
|
4
|
+
module Dawn #:nodoc:
|
5
|
+
class App #:nodoc:
|
6
|
+
class Drains #:nodoc:
|
7
|
+
include BaseApi, Enumerable
|
10
8
|
|
9
|
+
# @type [Dawn::App]
|
11
10
|
attr_reader :app
|
12
11
|
|
12
|
+
###
|
13
|
+
# @param [Dawn::App] app
|
14
|
+
###
|
13
15
|
def initialize(app)
|
14
16
|
@app = app
|
15
17
|
end
|
16
18
|
|
19
|
+
###
|
20
|
+
# @return [Array<Dawn::Drain>]
|
21
|
+
###
|
22
|
+
def to_a
|
23
|
+
all
|
24
|
+
end
|
25
|
+
|
26
|
+
###
|
27
|
+
# @overload each { |drain| do_stuff_with_drain }
|
28
|
+
###
|
17
29
|
def each(&block)
|
18
30
|
all.each(&block)
|
19
31
|
end
|
20
32
|
|
33
|
+
###
|
34
|
+
# @return [Dawn::Drain]
|
35
|
+
###
|
21
36
|
def create(options={})
|
22
37
|
options.fetch(:drain)
|
23
38
|
|
@@ -27,6 +42,9 @@ module Dawn
|
|
27
42
|
)["drain"]).tap { |d| d.app = @app }
|
28
43
|
end
|
29
44
|
|
45
|
+
###
|
46
|
+
# @return [Array<Dawn::Drain>]
|
47
|
+
###
|
30
48
|
def all(options={})
|
31
49
|
get(
|
32
50
|
path: "/apps/#{app.id}/drains",
|
@@ -34,10 +52,16 @@ module Dawn
|
|
34
52
|
).map { |hsh| Drain.new(hsh["drain"]).tap { |d| d.app = @app } }
|
35
53
|
end
|
36
54
|
|
55
|
+
###
|
56
|
+
# @return [Dawn::Drain]
|
57
|
+
###
|
37
58
|
def find(options={})
|
38
59
|
Drain.find(options).tap { |d| d.app = @app }
|
39
60
|
end
|
40
61
|
|
62
|
+
def destroy(options)
|
63
|
+
Drain.destroy(options)
|
64
|
+
end
|
41
65
|
end
|
42
66
|
end
|
43
67
|
end
|
@@ -1,19 +1,31 @@
|
|
1
1
|
require 'dawn/api/base_api'
|
2
2
|
|
3
|
-
module Dawn
|
4
|
-
class App
|
5
|
-
class Env < Hash
|
6
|
-
|
3
|
+
module Dawn #:nodoc:
|
4
|
+
class App #:nodoc:
|
5
|
+
class Env < Hash #:nodoc:
|
6
|
+
# horrible hack to restore Hash#delete
|
7
|
+
alias :__delete__ :delete
|
7
8
|
include BaseApi
|
9
|
+
alias :api_delete :delete
|
10
|
+
alias :delete :__delete__
|
11
|
+
remove_method :__delete__
|
8
12
|
|
13
|
+
# @type [Dawn::App]
|
9
14
|
attr_reader :app
|
10
15
|
|
16
|
+
###
|
17
|
+
# @param [Dawn::App] app
|
18
|
+
# @param [Hash] data
|
19
|
+
###
|
11
20
|
def initialize(app, data)
|
12
21
|
@app = app
|
13
22
|
super()
|
14
23
|
replace(data)
|
15
24
|
end
|
16
25
|
|
26
|
+
###
|
27
|
+
# @param [Hash] options
|
28
|
+
###
|
17
29
|
def refresh(options={})
|
18
30
|
replace get(
|
19
31
|
path: "/apps/#{app.id}/env",
|
@@ -21,13 +33,15 @@ module Dawn
|
|
21
33
|
)["env"]
|
22
34
|
end
|
23
35
|
|
36
|
+
###
|
37
|
+
# @param [Hash] options
|
38
|
+
###
|
24
39
|
def save(options={})
|
25
40
|
replace post(
|
26
41
|
path: "/apps/#{app.id}/env",
|
27
42
|
body: { app: { env: merge(options) } }.to_json
|
28
43
|
)["env"]
|
29
44
|
end
|
30
|
-
|
31
45
|
end
|
32
46
|
end
|
33
47
|
end
|
@@ -1,25 +1,40 @@
|
|
1
1
|
require 'dawn/api/base_api'
|
2
2
|
require 'dawn/api/models/gear'
|
3
3
|
|
4
|
-
module Dawn
|
5
|
-
class App
|
6
|
-
class Gears
|
7
|
-
|
8
|
-
include BaseApi
|
9
|
-
include Enumerable
|
4
|
+
module Dawn #:nodoc:
|
5
|
+
class App #:nodoc:
|
6
|
+
class Gears #:nodoc:
|
7
|
+
include BaseApi, Enumerable
|
10
8
|
|
9
|
+
# @type [Dawn::App]
|
11
10
|
attr_reader :app
|
12
11
|
|
12
|
+
###
|
13
|
+
# @param [Dawn::App] app
|
14
|
+
###
|
13
15
|
def initialize(app)
|
14
16
|
@app = app
|
15
17
|
end
|
16
18
|
|
19
|
+
###
|
20
|
+
# @return [Array<Dawn::Gear>]
|
21
|
+
###
|
22
|
+
def to_a
|
23
|
+
all
|
24
|
+
end
|
25
|
+
|
26
|
+
###
|
27
|
+
# @overload each { |gear| do_stuff_with_gear }
|
28
|
+
###
|
17
29
|
def each(&block)
|
18
30
|
all.each(&block)
|
19
31
|
end
|
20
32
|
|
33
|
+
###
|
34
|
+
# @return [Dawn::Gear]
|
35
|
+
###
|
21
36
|
def create(options={})
|
22
|
-
options.fetch(:gear)
|
37
|
+
#options.fetch(:gear)
|
23
38
|
|
24
39
|
Gear.new(post(
|
25
40
|
path: "/apps/#{app.id}/gears",
|
@@ -27,6 +42,9 @@ module Dawn
|
|
27
42
|
)["gear"]).tap { |d| d.app = @app }
|
28
43
|
end
|
29
44
|
|
45
|
+
###
|
46
|
+
# @return [Array<Dawn::Gear>]
|
47
|
+
###
|
30
48
|
def all(options={})
|
31
49
|
get(
|
32
50
|
path: "/apps/#{app.id}/gears",
|
@@ -34,6 +52,9 @@ module Dawn
|
|
34
52
|
).map { |hsh| Gear.new(hsh["gear"]).tap { |d| d.app = @app } }
|
35
53
|
end
|
36
54
|
|
55
|
+
###
|
56
|
+
# @return [Dawn::Gear]
|
57
|
+
###
|
37
58
|
def find(options={})
|
38
59
|
Gear.find(options).tap { |d| d.app = @app }
|
39
60
|
end
|
@@ -45,6 +66,9 @@ module Dawn
|
|
45
66
|
)
|
46
67
|
end
|
47
68
|
|
69
|
+
def destroy(options)
|
70
|
+
Gear.destroy(options)
|
71
|
+
end
|
48
72
|
end
|
49
73
|
end
|
50
74
|
end
|
@@ -1,25 +1,40 @@
|
|
1
1
|
require 'dawn/api/base_api'
|
2
2
|
require 'dawn/api/models/release'
|
3
3
|
|
4
|
-
module Dawn
|
5
|
-
class App
|
6
|
-
class Releases
|
7
|
-
|
8
|
-
include BaseApi
|
9
|
-
include Enumerable
|
4
|
+
module Dawn #:nodoc:
|
5
|
+
class App #:nodoc:
|
6
|
+
class Releases #:nodoc:
|
7
|
+
include BaseApi, Enumerable
|
10
8
|
|
9
|
+
# @type [Dawn::App]
|
11
10
|
attr_reader :app
|
12
11
|
|
12
|
+
###
|
13
|
+
# @param [Dawn::App] app
|
14
|
+
###
|
13
15
|
def initialize(app)
|
14
16
|
@app = app
|
15
17
|
end
|
16
18
|
|
19
|
+
###
|
20
|
+
# @return [Array<Dawn::Release>]
|
21
|
+
###
|
22
|
+
def to_a
|
23
|
+
all
|
24
|
+
end
|
25
|
+
|
26
|
+
###
|
27
|
+
# @overload each { |release| do_stuff_with_release }
|
28
|
+
###
|
17
29
|
def each(&block)
|
18
30
|
all.each(&block)
|
19
31
|
end
|
20
32
|
|
33
|
+
###
|
34
|
+
# @return [Dawn::Release]
|
35
|
+
###
|
21
36
|
def create(options={})
|
22
|
-
options.fetch(:release)
|
37
|
+
#options.fetch(:release)
|
23
38
|
|
24
39
|
Release.new(post(
|
25
40
|
path: "/apps/#{app.id}/releases",
|
@@ -27,6 +42,9 @@ module Dawn
|
|
27
42
|
)["release"]).tap { |d| d.app = @app }
|
28
43
|
end
|
29
44
|
|
45
|
+
###
|
46
|
+
# @return [Array<Dawn::Release>]
|
47
|
+
###
|
30
48
|
def all(options={})
|
31
49
|
get(
|
32
50
|
path: "/apps/#{app.id}/releases",
|
@@ -34,10 +52,12 @@ module Dawn
|
|
34
52
|
).map { |hsh| Release.new(hsh["release"]).tap { |d| d.app = @app } }
|
35
53
|
end
|
36
54
|
|
55
|
+
###
|
56
|
+
# @return [Dawn::Release]
|
57
|
+
###
|
37
58
|
def find(options={})
|
38
59
|
Release.find(options).tap { |d| d.app = @app }
|
39
60
|
end
|
40
|
-
|
41
61
|
end
|
42
62
|
end
|
43
63
|
end
|