droplet_kit 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/CHANGELOG.md +14 -0
- data/README.md +47 -27
- data/droplet_kit.gemspec +1 -1
- data/lib/droplet_kit/mappings/action_mapping.rb +2 -1
- data/lib/droplet_kit/mappings/image_action_mapping.rb +2 -1
- data/lib/droplet_kit/mappings/ssh_key_mapping.rb +3 -3
- data/lib/droplet_kit/models/action.rb +2 -1
- data/lib/droplet_kit/models/image_action.rb +2 -1
- data/lib/droplet_kit/resources/droplet_action_resource.rb +6 -1
- data/lib/droplet_kit/version.rb +1 -1
- data/spec/fixtures/actions/all.json +3 -2
- data/spec/fixtures/actions/find.json +3 -2
- data/spec/fixtures/droplets/list_actions.json +3 -2
- data/spec/fixtures/image_actions/all.json +5 -3
- data/spec/fixtures/image_actions/create.json +3 -2
- data/spec/fixtures/image_actions/find.json +3 -2
- data/spec/lib/droplet_kit/resources/action_resource_spec.rb +35 -1
- data/spec/lib/droplet_kit/resources/droplet_action_resource_spec.rb +22 -4
- data/spec/lib/droplet_kit/resources/image_action_resource_spec.rb +4 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce63bc5aac34db2dc7a39b5c7fef9f5fb02654a1
|
4
|
+
data.tar.gz: 6d22b740f138522b5e765965ac2557965e79abbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1656f66b808a250ff08508204571c8ff0b6ceeff50c7ba3678585db457e3a9b2f1cd6faadc5982b0edc7950b553b52c8a9782e3de2c16877c7c2d4f61a96941c
|
7
|
+
data.tar.gz: aa6b612faceeb0428448d583833f8bc4345666e6a2b891fc3a6d6558b8f310375f91dcd67b51951953b283584bc526841edcffd0b7ab3de15cf7c4f927e37def
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
### Version 1.2.0
|
2
|
+
|
3
|
+
* Add droplet upgrade action.
|
4
|
+
* Pass disk option through to Droplet resize.
|
5
|
+
* Add support for region_slug in action objects.
|
6
|
+
* Test coverage for Ruby 2.2.0.
|
7
|
+
* Documentation updates.
|
8
|
+
|
9
|
+
### Version 1.1.3
|
10
|
+
|
11
|
+
* Paginate the resource for image actions to retrieve all of them.
|
12
|
+
* Fix infinite loop bug on pagination last page.
|
13
|
+
* Updates to documentation.
|
14
|
+
|
1
15
|
### Version 1.1.2
|
2
16
|
|
3
17
|
* Add `public_ip` and `private_ip` to easily get the IP address on `DropletKit::Droplet` objects returned.
|
data/README.md
CHANGED
@@ -66,8 +66,10 @@ droplet = client.droplets.find(id: 123)
|
|
66
66
|
|
67
67
|
## Droplet resource
|
68
68
|
|
69
|
-
|
70
|
-
|
69
|
+
```ruby
|
70
|
+
client = DropletKit::Client.new(access_token: 'TOKEN')
|
71
|
+
client.droplets #=> DropletKit::DropletResource
|
72
|
+
```
|
71
73
|
|
72
74
|
Actions supported:
|
73
75
|
|
@@ -82,8 +84,10 @@ Actions supported:
|
|
82
84
|
|
83
85
|
## Droplet Action resource
|
84
86
|
|
85
|
-
|
86
|
-
|
87
|
+
```ruby
|
88
|
+
client = DropletKit::Client.new(access_token: 'TOKEN')
|
89
|
+
client.droplet_actions #=> DropletKit::DropletAction
|
90
|
+
```
|
87
91
|
|
88
92
|
Actions supported:
|
89
93
|
|
@@ -95,6 +99,7 @@ Actions supported:
|
|
95
99
|
* `client.droplet_actions.password_reset(droplet_id: droplet.id)`
|
96
100
|
* `client.droplet_actions.enable_ipv6(droplet_id: droplet.id)`
|
97
101
|
* `client.droplet_actions.disable_backups(droplet_id: droplet.id)`
|
102
|
+
* `client.droplet_actions.upgrade(droplet_id: droplet.id)`
|
98
103
|
* `client.droplet_actions.enable_private_networking(droplet_id: droplet.id)`
|
99
104
|
* `client.droplet_actions.snapshot(droplet_id: droplet.id, name: 'Snapshot Name')`
|
100
105
|
* `client.droplet_actions.change_kernel(droplet_id: droplet.id, kernel: 'kernel_id')`
|
@@ -106,8 +111,10 @@ Actions supported:
|
|
106
111
|
|
107
112
|
## Domain resource
|
108
113
|
|
109
|
-
|
110
|
-
|
114
|
+
```ruby
|
115
|
+
client = DropletKit::Client.new(access_token: 'TOKEN')
|
116
|
+
client.domains #=> DropletKit::DomainResource
|
117
|
+
```
|
111
118
|
|
112
119
|
Actions supported:
|
113
120
|
|
@@ -119,14 +126,15 @@ Actions supported:
|
|
119
126
|
|
120
127
|
## Domain record resource
|
121
128
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
129
|
+
```ruby
|
130
|
+
client = DropletKit::Client.new(access_token: 'TOKEN')
|
131
|
+
client.domain_records #=> DropletKit::DomainRecordResource
|
132
|
+
domain_record = DropletKit::DomainRecord.new(
|
133
|
+
type: 'CNAME',
|
134
|
+
name: 'www',
|
135
|
+
data: '@'
|
136
|
+
)
|
137
|
+
```
|
130
138
|
|
131
139
|
Actions supported:
|
132
140
|
|
@@ -139,8 +147,10 @@ Actions supported:
|
|
139
147
|
|
140
148
|
## Image resource
|
141
149
|
|
142
|
-
|
143
|
-
|
150
|
+
```ruby
|
151
|
+
client = DropletKit::Client.new(access_token: 'TOKEN')
|
152
|
+
client.images #=> DropletKit::ImageResource
|
153
|
+
```
|
144
154
|
|
145
155
|
Actions supported:
|
146
156
|
|
@@ -152,8 +162,10 @@ Actions supported:
|
|
152
162
|
|
153
163
|
## Image Action Resource
|
154
164
|
|
155
|
-
|
156
|
-
|
165
|
+
```
|
166
|
+
client = DropletKit::Client.new(access_token: 'TOKEN')
|
167
|
+
client.image_actions #=> DropletKit::ImageActionResource
|
168
|
+
```
|
157
169
|
|
158
170
|
Image Actions Supported:
|
159
171
|
|
@@ -164,8 +176,10 @@ Image Actions Supported:
|
|
164
176
|
|
165
177
|
## Region resource
|
166
178
|
|
167
|
-
|
168
|
-
|
179
|
+
```ruby
|
180
|
+
client = DropletKit::Client.new(access_token: 'TOKEN')
|
181
|
+
client.regions #=> DropletKit::RegionResource
|
182
|
+
```
|
169
183
|
|
170
184
|
Actions supported:
|
171
185
|
|
@@ -174,18 +188,22 @@ Actions supported:
|
|
174
188
|
|
175
189
|
## Size resource
|
176
190
|
|
177
|
-
|
178
|
-
|
191
|
+
```ruby
|
192
|
+
client = DropletKit::Client.new(access_token: 'TOKEN')
|
193
|
+
client.sizes #=> DropletKit::SizeResource
|
194
|
+
```
|
179
195
|
|
180
196
|
Actions supported:
|
181
197
|
|
182
198
|
* `client.sizes.all()`
|
183
199
|
|
184
200
|
|
185
|
-
##
|
201
|
+
## SSH key resource
|
186
202
|
|
187
|
-
|
188
|
-
|
203
|
+
```ruby
|
204
|
+
client = DropletKit::Client.new(access_token: 'TOKEN')
|
205
|
+
client.ssh_keys #=> DropletKit::SSHKeyResource
|
206
|
+
```
|
189
207
|
|
190
208
|
Actions supported:
|
191
209
|
|
@@ -197,8 +215,10 @@ Actions supported:
|
|
197
215
|
|
198
216
|
## Account resource
|
199
217
|
|
200
|
-
|
201
|
-
|
218
|
+
```ruby
|
219
|
+
client = DropletKit::Client.new(access_token: 'TOKEN')
|
220
|
+
client.account #=> DropletKit::AccountResource
|
221
|
+
```
|
202
222
|
|
203
223
|
Actions supported:
|
204
224
|
|
data/droplet_kit.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "droplet_kit"
|
8
8
|
spec.version = DropletKit::VERSION
|
9
9
|
spec.authors = ["Robert Ross"]
|
10
|
-
spec.email = ["rross@digitalocean.com"]
|
10
|
+
spec.email = ["engineering@digitalocean.com", "rross@digitalocean.com"]
|
11
11
|
spec.summary = %q{Droplet Kit is the official Ruby library for DigitalOcean's API}
|
12
12
|
spec.description = %q{Droplet Kit is the official Ruby library for DigitalOcean's API}
|
13
13
|
spec.homepage = ""
|
@@ -7,11 +7,11 @@ module DropletKit
|
|
7
7
|
root_key singular: 'ssh_key', plural: 'ssh_keys', scopes: [:read]
|
8
8
|
|
9
9
|
property :id, :fingerprint, :public_key, :name,
|
10
|
-
scopes: :read
|
10
|
+
scopes: [:read]
|
11
11
|
|
12
|
-
property :name, :public_key, scopes: :create
|
12
|
+
property :name, :public_key, scopes: [:create]
|
13
13
|
|
14
|
-
property :name, scopes: :update
|
14
|
+
property :name, scopes: [:update]
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -37,7 +37,12 @@ module DropletKit
|
|
37
37
|
end
|
38
38
|
|
39
39
|
action :resize, 'POST /v2/droplets/:droplet_id/actions' do
|
40
|
-
body { |hash| { type: 'resize', size: hash[:size] }.to_json }
|
40
|
+
body { |hash| { type: 'resize', size: hash[:size], disk: hash[:disk] }.to_json }
|
41
|
+
handler(201, 200) { |response| ActionMapping.extract_single(response.body, :read) }
|
42
|
+
end
|
43
|
+
|
44
|
+
action :upgrade, 'POST /v2/droplets/:droplet_id/actions' do
|
45
|
+
body { |hash| { type: 'upgrade' }.to_json }
|
41
46
|
handler(201, 200) { |response| ActionMapping.extract_single(response.body, :read) }
|
42
47
|
end
|
43
48
|
|
data/lib/droplet_kit/version.rb
CHANGED
@@ -8,7 +8,8 @@
|
|
8
8
|
"completed_at": "2014-10-28T17:11:06Z",
|
9
9
|
"resource_id": 45646587,
|
10
10
|
"resource_type": "image",
|
11
|
-
"region": null
|
11
|
+
"region": null,
|
12
|
+
"region_slug": null
|
12
13
|
},
|
13
14
|
{
|
14
15
|
"id": 234598,
|
@@ -18,11 +19,12 @@
|
|
18
19
|
"completed_at": "2014-10-28T17:12:04Z",
|
19
20
|
"resource_id": 45646587,
|
20
21
|
"resource_type": "image",
|
21
|
-
"region": "nyc2"
|
22
|
+
"region": "nyc2",
|
23
|
+
"region_slug": "nyc2"
|
22
24
|
}
|
23
25
|
],
|
24
26
|
"links": {},
|
25
27
|
"meta": {
|
26
28
|
"total": 2
|
27
29
|
}
|
28
|
-
}
|
30
|
+
}
|
@@ -12,6 +12,23 @@ RSpec.describe DropletKit::ActionResource do
|
|
12
12
|
|
13
13
|
expect(resource.all).to eq(expected_actions)
|
14
14
|
end
|
15
|
+
|
16
|
+
it 'returns a list of correctly mapped actions' do
|
17
|
+
response = api_fixture('actions/all')
|
18
|
+
stub_do_api('/v2/actions', :get).to_return(body: response)
|
19
|
+
actions = resource.all
|
20
|
+
|
21
|
+
expect(actions.first).to be_kind_of(DropletKit::Action)
|
22
|
+
expect(actions.first.id).to eq(1)
|
23
|
+
expect(actions.first.status).to eq("in-progress")
|
24
|
+
expect(actions.first.type).to eq("test")
|
25
|
+
expect(actions.first.started_at).to eq("2014-07-29T14:35:26Z")
|
26
|
+
expect(actions.first.completed_at).to eq(nil)
|
27
|
+
expect(actions.first.resource_id).to eq(nil)
|
28
|
+
expect(actions.first.resource_type).to eq("backend")
|
29
|
+
expect(actions.first.region).to eq("nyc1")
|
30
|
+
expect(actions.first.region_slug).to eq("nyc1")
|
31
|
+
end
|
15
32
|
end
|
16
33
|
|
17
34
|
describe '#find' do
|
@@ -22,5 +39,22 @@ RSpec.describe DropletKit::ActionResource do
|
|
22
39
|
|
23
40
|
expect(resource.find(id: 123)).to eq(expected_action)
|
24
41
|
end
|
42
|
+
|
43
|
+
it 'returns a correctly mapped action' do
|
44
|
+
response = api_fixture('actions/find')
|
45
|
+
stub_do_api('/v2/actions/123', :get).to_return(body: response)
|
46
|
+
action = resource.find(id: 123)
|
47
|
+
|
48
|
+
expect(action).to be_kind_of(DropletKit::Action)
|
49
|
+
expect(action.id).to eq(2)
|
50
|
+
expect(action.status).to eq("in-progress")
|
51
|
+
expect(action.type).to eq("test")
|
52
|
+
expect(action.started_at).to eq("2014-07-29T14:35:27Z")
|
53
|
+
expect(action.completed_at).to eq(nil)
|
54
|
+
expect(action.resource_id).to eq(nil)
|
55
|
+
expect(action.resource_type).to eq("backend")
|
56
|
+
expect(action.region).to eq("nyc1")
|
57
|
+
expect(action.region_slug).to eq("nyc1")
|
58
|
+
end
|
25
59
|
end
|
26
|
-
end
|
60
|
+
end
|
@@ -13,7 +13,8 @@ RSpec.describe DropletKit::DropletActionResource do
|
|
13
13
|
"completed_at" => nil,
|
14
14
|
"resource_id" => 12,
|
15
15
|
"resource_type" => "droplet",
|
16
|
-
"region" => "nyc1"
|
16
|
+
"region" => "nyc1",
|
17
|
+
"region_slug" => "nyc1"
|
17
18
|
}
|
18
19
|
}.to_json
|
19
20
|
end
|
@@ -21,7 +22,8 @@ RSpec.describe DropletKit::DropletActionResource do
|
|
21
22
|
include_context 'resources'
|
22
23
|
|
23
24
|
ACTIONS_WITHOUT_INPUT = %w(reboot power_cycle shutdown power_off
|
24
|
-
power_on password_reset enable_ipv6 disable_backups enable_private_networking
|
25
|
+
power_on password_reset enable_ipv6 disable_backups enable_private_networking
|
26
|
+
upgrade)
|
25
27
|
|
26
28
|
ACTIONS_WITHOUT_INPUT.each do |action_name|
|
27
29
|
describe "Action #{action_name}" do
|
@@ -120,7 +122,7 @@ RSpec.describe DropletKit::DropletActionResource do
|
|
120
122
|
|
121
123
|
it 'performs the action' do
|
122
124
|
request = stub_do_api("/v2/droplets/#{droplet_id}/actions", :post).with(
|
123
|
-
body: { type: action, size: '1gb' }.to_json
|
125
|
+
body: { type: action, size: '1gb', disk: nil }.to_json
|
124
126
|
).to_return(body: json, status: 201)
|
125
127
|
|
126
128
|
returned_action = resource.send(action, droplet_id: droplet_id, size: '1gb')
|
@@ -130,6 +132,21 @@ RSpec.describe DropletKit::DropletActionResource do
|
|
130
132
|
end
|
131
133
|
end
|
132
134
|
|
135
|
+
describe "Action resize with disk" do
|
136
|
+
let(:action) { 'resize' }
|
137
|
+
|
138
|
+
it 'performs the action' do
|
139
|
+
request = stub_do_api("/v2/droplets/#{droplet_id}/actions", :post).with(
|
140
|
+
body: { type: action, size: '1gb', disk: true }.to_json
|
141
|
+
).to_return(body: json, status: 201)
|
142
|
+
|
143
|
+
returned_action = resource.send(action, droplet_id: droplet_id, size: '1gb', disk: true)
|
144
|
+
|
145
|
+
expect(request).to have_been_made
|
146
|
+
expect(returned_action.type).to eq(action)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
133
150
|
describe '#find' do
|
134
151
|
it 'returns an action' do
|
135
152
|
request = stub_do_api("/v2/droplets/1066/actions/123", :get).to_return(
|
@@ -145,6 +162,7 @@ RSpec.describe DropletKit::DropletActionResource do
|
|
145
162
|
expect(returned_action.resource_id).to eq(nil)
|
146
163
|
expect(returned_action.resource_type).to eq("backend")
|
147
164
|
expect(returned_action.region).to eq("nyc1")
|
165
|
+
expect(returned_action.region_slug).to eq("nyc1")
|
148
166
|
end
|
149
167
|
end
|
150
|
-
end
|
168
|
+
end
|
@@ -23,6 +23,7 @@ RSpec.describe DropletKit::ImageActionResource do
|
|
23
23
|
expect(action.resource_id).to eq(449676391)
|
24
24
|
expect(action.resource_type).to eq("image")
|
25
25
|
expect(action.region).to eq("nyc1")
|
26
|
+
expect(action.region_slug).to eq("nyc1")
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
@@ -49,6 +50,7 @@ RSpec.describe DropletKit::ImageActionResource do
|
|
49
50
|
expect(action.resource_id).to eq(45646587)
|
50
51
|
expect(action.resource_type).to eq("image")
|
51
52
|
expect(action.region).to eq(nil)
|
53
|
+
expect(action.region_slug).to eq(nil)
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
@@ -66,6 +68,7 @@ RSpec.describe DropletKit::ImageActionResource do
|
|
66
68
|
expect(action.resource_id).to eq(449676391)
|
67
69
|
expect(action.resource_type).to eq("image")
|
68
70
|
expect(action.region).to eq("nyc1")
|
71
|
+
expect(action.region_slug).to eq("nyc1")
|
69
72
|
end
|
70
73
|
end
|
71
|
-
end
|
74
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: droplet_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Ross
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -166,6 +166,7 @@ dependencies:
|
|
166
166
|
version: '1.18'
|
167
167
|
description: Droplet Kit is the official Ruby library for DigitalOcean's API
|
168
168
|
email:
|
169
|
+
- engineering@digitalocean.com
|
169
170
|
- rross@digitalocean.com
|
170
171
|
executables: []
|
171
172
|
extensions: []
|