hyperb 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9200fb1c5348757773d70f6940a0e10cbee1564d
4
- data.tar.gz: e15cc748b6142cb74c6fdcf34a82f8954eb0b448
3
+ metadata.gz: a85a4a493a9700b5bb291c07bcf22d070270ad92
4
+ data.tar.gz: 5258bff3427542ebe431d727895c5f1033e5078b
5
5
  SHA512:
6
- metadata.gz: 15bfbc0569c83146c717d82a641830a1d6d94f23f2e77bd543dcda5066f8aa652d3a0425634391ab150dc292b3900b5318e005d81ac5e614ba4077af9add91bf
7
- data.tar.gz: 6a62201383ce5e56f50219daf4f2a83d3b76380cb9c313a8c077a615fc074f3e327addc4b865bf9aedc3f9049abc5349b7b0e2d1b2c7c8f8829e2f2ef1975850
6
+ metadata.gz: 69668e4a88193efe0c351d4791bad48d50d99942c88490ed75c479987074b4da4f9ddbf922a0dadeb91b0b2a6def4423e1d25bd1ae76571b915f2d112a2ffe39
7
+ data.tar.gz: 73257dbe7f6e14178f83a733efbd5d3f6b83bc7d7a085b4a360f7cfc388b1188fdbe203e51bbd5937a9da5474c72c26b75c78ce15ed6aaf9ef4188495242ba94
data/README.md CHANGED
@@ -122,6 +122,7 @@ For more usage examples, please see the full [documentation]().
122
122
 
123
123
  * list volumes
124
124
  * inspect volume
125
+ * create volume
125
126
  * remove volume
126
127
 
127
128
  ### Containers
data/examples/README.md CHANGED
@@ -234,6 +234,28 @@ client.rename_container id: 'django-server', name: 'its-actually-a-rails-server'
234
234
 
235
235
  ## Volumes API
236
236
 
237
+ #### create_volume
238
+
239
+ Returns a Hash containing volume information
240
+
241
+ ```ruby
242
+ vol = client.create_volume name: 'vol'
243
+ # creates default (10gb) volume
244
+ {:name=>"vol", :driver=>"hyper", :mountpoint=>"", :labels=>{:size=>"10", :snapshot=>""}, :scope=>"", :createdat=>"0001-01-01T00:00:00Z"}
245
+ ```
246
+
247
+ ```ruby
248
+ vol = client.create_volume name: 'vol1', size: 35
249
+ # creates a 35GB size volume
250
+ {:name=>"vol1", :driver=>"hyper", :mountpoint=>"", :labels=>{:size=>"35", :snapshot=>""}, :scope=>"", :createdat=>"0001-01-01T00:00:00Z"}
251
+ ```
252
+
253
+ ```ruby
254
+ vol = client.create_volume name: 'vol1', snapshot: 'dddeeefff'
255
+ # creates a volume based on a snapshot
256
+ {:name=>"vol1", :driver=>"hyper", :mountpoint=>"", :labels=>{:size=>"10", :snapshot=>"dddeeefff"}, :scope=>"", :createdat=>"0001-01-01T00:00:00Z"}
257
+ ```
258
+
237
259
  #### remove_volume
238
260
 
239
261
  ```ruby
@@ -1,3 +1,3 @@
1
1
  module Hyperb
2
- VERSION = '0.3.3'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -10,6 +10,34 @@ module Hyperb
10
10
  module Volumes
11
11
  include Hyperb::Utils
12
12
 
13
+ # create volume
14
+ #
15
+ # @see https://docs.hyper.sh/Reference/API/2016-04-04%20[Ver.%201.23]/Volume/create.html
16
+ #
17
+ # @raise [Hyperb::Error::Unauthorized] raised when credentials are not valid.
18
+ # @raise [Hyperb::Error::InternalServerError] raised hyper server returns 5xx.
19
+ #
20
+ # @return [Hash] downcased symbolized volume information.
21
+ #
22
+ # @param params [Hash] A customizable set of params.
23
+ # @option params [String] :name volume's name
24
+ # @option params [Fixnum] :size volume size unit of GB, from 10-1000 (1TB).
25
+ # @option params [String] :snapshot snapshotId
26
+ def create_volume(params = {})
27
+ path = '/volumes/create'
28
+ body = {}
29
+ body[:driver] = 'hyper'
30
+ body[:name] = params[:name] if params.key?(:name)
31
+
32
+ # setup driver opts
33
+ body[:driveropts] = {}
34
+ body[:driveropts][:snapshot] = params[:snapshot]
35
+ body[:driveropts][:size] = params[:size].to_s
36
+
37
+ response = JSON.parse(Hyperb::Request.new(self, path, {}, 'post', body).perform)
38
+ downcase_symbolize(response)
39
+ end
40
+
13
41
  # list volumes
14
42
  #
15
43
  # @see https://docs.hyper.sh/Reference/API/2016-04-04%20[Ver.%201.23]/Volume/list.html
@@ -0,0 +1,9 @@
1
+ {
2
+ "Name": "tardis",
3
+ "Driver": "hyper",
4
+ "Mountpoint": "",
5
+ "Labels": {
6
+ "size": "10",
7
+ "snapshot": ""
8
+ }
9
+ }
@@ -6,6 +6,6 @@
6
6
  "container": "",
7
7
  "size": "10",
8
8
  "snapshot": ""
9
- }
9
+ },
10
10
  "CreatedAt": "2017-03-28T13:37:43.744Z"
11
11
  }
File without changes
data/spec/volumes_spec.rb CHANGED
@@ -18,13 +18,37 @@ RSpec.describe Hyperb::Volumes do
18
18
  path = @base_path + '/id'
19
19
 
20
20
  stub_request(:delete, path)
21
- .to_return(body: fixture('remove_container.json'))
21
+ .to_return(body: "")
22
22
 
23
23
  @client.remove_volume id: 'id'
24
24
  expect(a_request(:delete, path)).to have_been_made
25
25
  end
26
26
  end
27
27
 
28
+ describe '#create_volume' do
29
+
30
+ it 'request to the correct path should be made' do
31
+ path = @base_path + '/create'
32
+
33
+ stub_request(:post, path)
34
+ .to_return(body: fixture('create_volume.json'))
35
+
36
+ @client.create_volume
37
+ expect(a_request(:post, path)).to have_been_made
38
+ end
39
+
40
+ it 'correct attrs' do
41
+ path = @base_path + '/create'
42
+
43
+ stub_request(:post, path)
44
+ .to_return(body: fixture('create_volume.json'))
45
+
46
+ vol = @client.create_volume
47
+ expect(vol[:name]).to eql 'tardis'
48
+ expect(vol[:driver]).to eql 'hyper'
49
+ end
50
+ end
51
+
28
52
  describe '#inspect_volume' do
29
53
 
30
54
  it 'should raise ArgumentError when id is not provided' do
@@ -35,7 +59,7 @@ RSpec.describe Hyperb::Volumes do
35
59
  path = @base_path + '/id'
36
60
 
37
61
  stub_request(:get, path)
38
- .to_return(body: fixture('inspect_container.json'))
62
+ .to_return(body: fixture('inspect_volume.json'))
39
63
 
40
64
  @client.inspect_volume id: 'id'
41
65
  expect(a_request(:get, path)).to have_been_made
@@ -53,7 +77,7 @@ RSpec.describe Hyperb::Volumes do
53
77
  end
54
78
  end
55
79
 
56
- describe '#inspect_volume' do
80
+ describe '#volumes' do
57
81
 
58
82
  it 'request to the correct path should be made' do
59
83
  stub_request(:get, @base_path)
@@ -63,7 +87,7 @@ RSpec.describe Hyperb::Volumes do
63
87
  expect(a_request(:get, @base_path)).to have_been_made
64
88
  end
65
89
 
66
- it 'return array of containers' do
90
+ it 'return array of volumes' do
67
91
  stub_request(:get, @base_path)
68
92
  .to_return(body: fixture('volumes.json'))
69
93
 
@@ -84,5 +108,4 @@ RSpec.describe Hyperb::Volumes do
84
108
  end
85
109
  end
86
110
  end
87
-
88
111
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - drish
@@ -164,7 +164,6 @@ files:
164
164
  - spec/compose_spec.rb
165
165
  - spec/container_spec.rb
166
166
  - spec/containers_spec.rb
167
- - spec/create_snapshot.rb
168
167
  - spec/error_spec.rb
169
168
  - spec/fixtures/auth_obj.json
170
169
  - spec/fixtures/compose_rm.json
@@ -175,6 +174,7 @@ files:
175
174
  - spec/fixtures/create_image.json
176
175
  - spec/fixtures/create_service.json
177
176
  - spec/fixtures/create_snapshot.json
177
+ - spec/fixtures/create_volume.json
178
178
  - spec/fixtures/fip_allocate.json
179
179
  - spec/fixtures/fips_ls.json
180
180
  - spec/fixtures/images.json
@@ -192,6 +192,7 @@ files:
192
192
  - spec/network_spec.rb
193
193
  - spec/request_spec.rb
194
194
  - spec/services_spec.rb
195
+ - spec/snapshots_spec.rb
195
196
  - spec/version_spec.rb
196
197
  - spec/volumes_spec.rb
197
198
  homepage: https://github.com/drish/hyperb