hyperb 0.2.1 → 0.2.2

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.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +12 -0
  3. data/.gitignore +12 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +41 -0
  6. data/Dockerfile +7 -0
  7. data/Gemfile +16 -0
  8. data/LICENSE.txt +21 -0
  9. data/Makefile +16 -0
  10. data/README.md +188 -0
  11. data/Rakefile +24 -0
  12. data/circle.yml +13 -0
  13. data/examples/README.md +367 -0
  14. data/examples/auth-gcr-registry.md +19 -0
  15. data/examples/compose.md +75 -0
  16. data/examples/handling-errors.md +54 -0
  17. data/examples/streaming-logs.md +28 -0
  18. data/examples/streaming-stats.md +25 -0
  19. data/hyperb.gemspec +30 -0
  20. data/lib/hyperb.rb +4 -0
  21. data/lib/hyperb/api.rb +22 -0
  22. data/lib/hyperb/auth_object.rb +42 -0
  23. data/lib/hyperb/client.rb +32 -0
  24. data/lib/hyperb/compose/compose.rb +116 -0
  25. data/lib/hyperb/containers/container.rb +27 -0
  26. data/lib/hyperb/containers/containers.rb +251 -0
  27. data/lib/hyperb/error.rb +44 -0
  28. data/lib/hyperb/hyper_version.rb +12 -0
  29. data/lib/hyperb/images/image.rb +13 -0
  30. data/lib/hyperb/images/images.rb +108 -0
  31. data/lib/hyperb/network/fips.rb +102 -0
  32. data/lib/hyperb/request.rb +129 -0
  33. data/lib/hyperb/services/services.rb +59 -0
  34. data/lib/hyperb/snapshots/snapshot.rb +12 -0
  35. data/lib/hyperb/snapshots/snapshots.rb +39 -0
  36. data/lib/hyperb/utils.rb +39 -0
  37. data/lib/hyperb/version.rb +3 -0
  38. data/lib/hyperb/volumes/volume.rb +16 -0
  39. data/lib/hyperb/volumes/volumes.rb +67 -0
  40. data/spec/auth_object_spec.rb +45 -0
  41. data/spec/client_spec.rb +27 -0
  42. data/spec/compose_spec.rb +145 -0
  43. data/spec/container_spec.rb +25 -0
  44. data/spec/containers_spec.rb +442 -0
  45. data/spec/create_snapshot.rb +30 -0
  46. data/spec/error_spec.rb +18 -0
  47. data/spec/fixtures/auth_obj.json +12 -0
  48. data/spec/fixtures/compose_rm.json +1 -0
  49. data/spec/fixtures/compose_up.json +1 -0
  50. data/spec/fixtures/container_stats.json +78 -0
  51. data/spec/fixtures/containers.json +160 -0
  52. data/spec/fixtures/create_container.json +4 -0
  53. data/spec/fixtures/create_image.json +1 -0
  54. data/spec/fixtures/create_service.json +35 -0
  55. data/spec/fixtures/create_snapshot.json +8 -0
  56. data/spec/fixtures/fip_allocate.json +7 -0
  57. data/spec/fixtures/fips_ls.json +14 -0
  58. data/spec/fixtures/images.json +32 -0
  59. data/spec/fixtures/inspect_container.json +159 -0
  60. data/spec/fixtures/inspect_image.json +89 -0
  61. data/spec/fixtures/inspect_volume.json +11 -0
  62. data/spec/fixtures/remove_container.json +1 -0
  63. data/spec/fixtures/remove_image.json +5 -0
  64. data/spec/fixtures/volumes.json +13 -0
  65. data/spec/helper.rb +36 -0
  66. data/spec/image_spec.rb +17 -0
  67. data/spec/images_spec.rb +133 -0
  68. data/spec/network_spec.rb +106 -0
  69. data/spec/request_spec.rb +41 -0
  70. data/spec/services_spec.rb +193 -0
  71. data/spec/version_spec.rb +7 -0
  72. data/spec/volumes_spec.rb +88 -0
  73. metadata +74 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ae75607b923ea1b252f58a6e058e5b1d7367561
4
- data.tar.gz: 374b395b9113f4b56f0d527cb9d9b5d7806b5209
3
+ metadata.gz: 451eaa5bd6d96d215b204e67b80b087048cf5b91
4
+ data.tar.gz: c4b03081daa2592a264504f31028cb94fc49d813
5
5
  SHA512:
6
- metadata.gz: 3f800705d76ac6d24ec11c842a1187a9c094c16d86252f9250cbeb0e03536547c344465cd6a61a05e2a3b4a71a9cdf67aa2204f92dfbe4a73d0614813a9aff1d
7
- data.tar.gz: 121b440458d5c8600509698b8a0faa5fc5ca075e9c710fdbcbd8b0c4e9a2c778dbf91e1fc31a1760d548abb58fad88508fba3597bfd25a011e73ad410f6c5430
6
+ metadata.gz: c23a4d03fb11785c4beb7529adf6342df4c2ad04fac7cd36a953626c4ab8dbef8c380fe2cebfc96e2251e3540fd64bac83c5b6c1af1bed3ea406f3d6d0941848
7
+ data.tar.gz: 94ca447128b1273a91449c32cef90d20f414ab5e7ce2c5337f799c63d96b1095a38704dccbf625bd3a41b7f621bb01abea6d29f34a8bdf49c86e708caf536f5c
data/.codeclimate.yml ADDED
@@ -0,0 +1,12 @@
1
+ engines:
2
+ rubocop:
3
+ enabled: true
4
+
5
+ ratings:
6
+ paths:
7
+ - "**.rb"
8
+
9
+ exclude_paths:
10
+ - etc/**/*
11
+ - examples/**/*
12
+ - spec/**/*
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,41 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'spec/*'
4
+ - 'Rakefile'
5
+ - 'Gemfile'
6
+ - '*.gemspec'
7
+ TargetRubyVersion: 2.3
8
+
9
+ Style/FrozenStringLiteralComment:
10
+ Enabled: false
11
+
12
+ Layout/IndentHeredoc:
13
+ EnforcedStyle: powerpack
14
+
15
+ Lint/AmbiguousBlockAssociation:
16
+ Exclude:
17
+ - 'spec/*'
18
+
19
+ Lint/UselessAccessModifier:
20
+ MethodCreatingMethods:
21
+ - 'def_matcher'
22
+ - 'def_node_matcher'
23
+
24
+ Metrics/BlockLength:
25
+ Exclude:
26
+ - 'Rakefile'
27
+ - 'spec/**/*.rb'
28
+
29
+ Metrics/MethodLength:
30
+ CountComments: false # count full line comments?
31
+ Max: 15
32
+
33
+ Metrics/ModuleLength:
34
+ Exclude:
35
+ - 'spec/**/*.rb'
36
+
37
+ Metrics/LineLength:
38
+ Max: 100
39
+
40
+ Metrics/ParameterLists:
41
+ Max: 6
data/Dockerfile ADDED
@@ -0,0 +1,7 @@
1
+ FROM ruby:2.3
2
+
3
+ WORKDIR /usr/src
4
+ COPY . /usr/src
5
+ #COPY hyperb.gemspec /usr/src/hyperb.gemspec
6
+ RUN bundle install
7
+
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
8
+ gem 'yard'
9
+
10
+ group :test do
11
+ gem 'coveralls'
12
+ gem 'rubocop', '>= 0.46'
13
+ gem 'yardstick'
14
+ end
15
+
16
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 drish
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,16 @@
1
+ .PHONY: test
2
+
3
+ build:
4
+ docker build -t hyperb .
5
+
6
+ test:
7
+ docker run --rm -v $(PWD):/usr/src hyperb bundle exec rake spec
8
+
9
+ pry:
10
+ docker run --rm -it -v $(PWD):/usr/src hyperb bundle exec pry
11
+
12
+ rake:
13
+ docker run --rm -it -v $(PWD):/usr/src hyperb bundle exec rake
14
+
15
+ rubocop:
16
+ docker run --rm -it -v $(PWD):/usr/src hyperb bundle exec rake rubocop
data/README.md ADDED
@@ -0,0 +1,188 @@
1
+ <p align="center">
2
+ <h1 align="center">Hyperb</h1>
3
+ <p align="center">Hyperb is a <a href="https://hyper.sh">Hyper.sh</a> API ruby gem.</p>
4
+ <p align="center">
5
+ <a href="https://circleci.com/gh/drish/hyperb"><img src="https://circleci.com/gh/drish/hyperb.svg?style=svg"></a>
6
+ <a href="https://github.com/drish/hyperb/blob/master/LICENSE.txt"><img src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
7
+ <a href="https://coveralls.io/github/drish/hyperb?branch=master"><img src="https://coveralls.io/repos/github/drish/hyperb/badge.svg?branch=master"></a>
8
+ <a href="https://codeclimate.com/github/drish/hyperb"><img src="https://codeclimate.com/github/drish/hyperb/badges/gpa.svg" /></a>
9
+ <a href="https://badge.fury.io/rb/hyperb"><img src="https://badge.fury.io/rb/hyperb.svg"</></a>
10
+ </p>
11
+ </p>
12
+
13
+ ---
14
+
15
+ This gem is under active development.
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'hyperb'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install hyperb
32
+
33
+
34
+ ## Configuration
35
+
36
+ Hyper.sh requires you to create credentials on their [dashboard](https://console.hyper.sh/account/credential), after that you can configure your client as following:
37
+
38
+ ```ruby
39
+ client = Hyperb::Client.new(access_key: 'ak', secret_key: 'sk')
40
+ ```
41
+
42
+ ## Usage Examples
43
+
44
+ After configuring a `client`, you can run the following examples.
45
+
46
+ **get api version**
47
+
48
+ ```ruby
49
+ client.version
50
+ ```
51
+ **fetch all images**
52
+
53
+ ```ruby
54
+ client.images
55
+ ```
56
+ **remove an image**
57
+
58
+ ```ruby
59
+ client.remove_image id: 'id-or-name'
60
+ ```
61
+ **create an image (pull)**
62
+
63
+ ```ruby
64
+ client.create_image from_image: 'busybox'
65
+ ```
66
+ **pull an image from gcr (using service account)**
67
+
68
+ ```ruby
69
+ client.create_image from_image: 'gcr.io/project/owner/gcr', x_registry_auth: { username: '_json_key', password: File.new('./path/service-account.json'), email: 'e@e.com', serveraddress: 'https://gcr.io' }
70
+ ```
71
+
72
+ **create container (defaults to s1 size)**
73
+
74
+ ```ruby
75
+ client.create_container name: 'nginx-container', image: 'nginx'
76
+ ```
77
+
78
+ **create container with specific size**
79
+
80
+ ```ruby
81
+ client.create_container name: 'nginx-container', image: 'nginx', labels: { sh_hyper_instancetype: 'm1' }
82
+ ```
83
+
84
+ **start container**
85
+
86
+ ```ruby
87
+ client.start_container name: 'nginx-container'
88
+ ```
89
+
90
+ **container logs**
91
+
92
+ ```ruby
93
+ logs = client.container_logs id: 'nginx', stdout: true, stderr: true, follow: true
94
+
95
+ while body = logs.readpartial(1024)
96
+ puts body
97
+ end
98
+ ```
99
+
100
+ **allocate an floating ip**
101
+
102
+ ```ruby
103
+ ips = client.fip_allocate count: 2
104
+ puts ips
105
+ #['8.8.8.8', '5.5.5.5']
106
+ ```
107
+
108
+ For more usage examples, please see the full [documentation]().
109
+
110
+ ## APIs (v1.23) Covered
111
+
112
+ [API](https://docs.hyper.sh/Reference/API/2016-04-04%20[Ver.%201.23]/index.html)
113
+
114
+ ### Images
115
+
116
+ * inspect image
117
+ * create image
118
+ * list images
119
+ * remove images
120
+
121
+ ### Volumes
122
+
123
+ * list volumes
124
+ * inspect volume
125
+ * remove volume
126
+
127
+ ### Containers
128
+
129
+ * create container (not all arguments supported yet)
130
+ * start container
131
+ * stop container
132
+ * kill container
133
+ * get container logs
134
+ * get container stats
135
+ * remove containers
136
+ * rename container
137
+
138
+ ### Network
139
+
140
+ * floating ip allocate
141
+ * floating ip release
142
+ * floating ip list
143
+ * floating ip attach
144
+ * floating ip detach
145
+
146
+ ### Compose
147
+
148
+ * compose create
149
+ * compose up
150
+ * compose down
151
+ * compose rm
152
+
153
+ ### Snapshot
154
+
155
+ * create snapshot
156
+
157
+ ### Service
158
+
159
+ * create service
160
+ * remove service
161
+
162
+ ### Misc.
163
+
164
+ * Version
165
+
166
+ ### Security Groups
167
+
168
+ wip
169
+
170
+ ### Event
171
+
172
+ wip
173
+
174
+ ### Func (beta)
175
+
176
+ wip
177
+
178
+ ### Cron (beta)
179
+
180
+ wip
181
+
182
+ ## Contributing
183
+
184
+ Bug reports and pull requests are welcome at https://github.com/drish/hyperb.
185
+
186
+ ## License
187
+
188
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task test: :spec
8
+
9
+ RuboCop::RakeTask.new
10
+
11
+ require 'yard'
12
+ YARD::Rake::YardocTask.new
13
+
14
+ require 'yardstick/rake/measurement'
15
+ Yardstick::Rake::Measurement.new do |measurement|
16
+ measurement.output = 'measurement/report.txt'
17
+ end
18
+
19
+ require 'yardstick/rake/verify'
20
+ Yardstick::Rake::Verify.new do |verify|
21
+ verify.threshold = 50.0
22
+ end
23
+
24
+ task default: [:spec, :rubocop]
data/circle.yml ADDED
@@ -0,0 +1,13 @@
1
+ dependencies:
2
+ override:
3
+ - 'rvm-exec 2.2.0 bundle install'
4
+ - 'rvm-exec 2.3.0 bundle install'
5
+ - 'rvm-exec 2.4.0 bundle install'
6
+ - 'rvm-exec ruby-head bundle install'
7
+
8
+ test:
9
+ override:
10
+ - 'rvm-exec 2.2.0 bundle exec rake'
11
+ - 'rvm-exec 2.3.0 bundle exec rake'
12
+ - 'rvm-exec 2.4.0 bundle exec rake'
13
+ - 'rvm-exec ruby-head bundle exec rake'
@@ -0,0 +1,367 @@
1
+ # API
2
+
3
+ Other examples: [Authenticating in GCR](https://github.com/drish/hyperb/blob/master/examples/auth-gcr-registry.md), [Streaming Logs](https://github.com/drish/hyperb/blob/master/examples/streaming-logs.md), [Streaming stats](https://github.com/drish/hyperb/blob/master/examples/streaming-stats.md)
4
+
5
+ ## Images API
6
+
7
+ #### images
8
+
9
+ returns an Array of Hyperb::Image
10
+
11
+ ```ruby
12
+ images = client.images
13
+ images.each do |image|
14
+ image.is_a?(Hyperb::Image)
15
+ puts image
16
+ end
17
+ ```
18
+
19
+ #### create_image
20
+
21
+ return a [HTTP::Response::Body](http://www.rubydoc.info/gems/http/HTTP/Response/Body), which can be streamed.
22
+
23
+ ```ruby
24
+ response = client.create_image from_image: 'busybox'
25
+ puts response
26
+ ```
27
+
28
+ ```ruby
29
+ response = client.create_image(from_image: 'busybox')
30
+ while body = response.readpartial(1024)
31
+ puts body
32
+ end
33
+ ```
34
+
35
+ Authenticating in a third party docker registry, you must provide a AuthObject.
36
+
37
+ Example with gcr, [service account](https://cloud.google.com/container-registry/docs/advanced-authentication) :
38
+
39
+ ```ruby
40
+
41
+ x_registry_auth = {
42
+ username: '_json_key',
43
+ password: File.new('./path/to/service-account.json'),
44
+ email: 'email@email.com',
45
+ serveraddress: 'https://gcr.io'
46
+ }
47
+
48
+ response = client.create_image(from_image: 'gcr.io/private/repo/image', x_registry_auth: x_registry_auth)
49
+ puts response
50
+
51
+ ```
52
+
53
+ #### remove_image
54
+
55
+ returns an Array of hashes containing information about the deleted image
56
+
57
+ ```ruby
58
+ response = client.remove_image(name: 'busybox')
59
+ => [{:untagged=>"busybox:latest"}, {:deleted=>"sha256:efe10ee6727fe52d2db2eb5045518fe98d8e31fdad1cbdd5e1f737018c349ebb"}]
60
+ ```
61
+
62
+ Force delete
63
+
64
+ ```ruby
65
+ response = client.remove_image(name: 'busybox', force: true)
66
+ => [{:untagged=>"busybox:latest"}, {:deleted=>"sha256:efe10ee6727fe52d2db2eb5045518fe98d8e31fdad1cbdd5e1f737018c349ebb"}]
67
+ ```
68
+
69
+ #### inspect_image
70
+
71
+ returns a Hash containing information about the inspected image
72
+
73
+ ```ruby
74
+ info = client.inspect_image(id: 'busybox')
75
+ puts info
76
+ ```
77
+
78
+ ## Containers API
79
+
80
+ #### create_container
81
+
82
+ Return a hash containing downcased symbolized container info.
83
+
84
+ ```ruby
85
+ res = client.create_container name: 'nginx-c', image: 'nginx', labels: { sh_hyper_instancetype: 'm1' }
86
+ ```
87
+
88
+ With hostname
89
+
90
+ ```ruby
91
+ res = client.create_container name: 'nginx-c', image: 'nginx', hostname: 'nginx-hostname'
92
+ ```
93
+
94
+ With custom cmd
95
+
96
+ ```ruby
97
+ res = client.create_container name: 'nginx-c', image: 'nginx', cmd: "echo 'something'"
98
+ ```
99
+
100
+ With custom entrypoint
101
+
102
+ ```ruby
103
+ res = client.create_container name: 'nginx-c', image: 'nginx', hostname: 'hostny', entrypoint: './entrypoint.sh'
104
+ ```
105
+
106
+ With custom mounts
107
+
108
+ ```ruby
109
+ res = client.create_container name: 'nginx-c', image: 'nginx', mounts: ['./path/to/mount']'
110
+ ```
111
+
112
+ With custom network mode
113
+
114
+ ```ruby
115
+ res = client.create_container name: 'nginx-c', image: 'nginx', networkmode: 'bridge'
116
+ ```
117
+
118
+ Exposing ports
119
+
120
+ ```ruby
121
+ res = client.create_container name: 'nginx-c', image: 'nginx', exposedports: { '22/tcp': {} }
122
+ ```
123
+
124
+ #### start_container
125
+
126
+ ```ruby
127
+ client.start_container id: 'nginx'
128
+ ```
129
+
130
+ #### stop_container
131
+
132
+ ```ruby
133
+ client.stop_container id: 'nginx'
134
+ ```
135
+
136
+ ```ruby
137
+ client.stop_container id: 'nginx', t: 30
138
+ ```
139
+
140
+ #### remove_container
141
+
142
+ Simple remove
143
+
144
+ ```ruby
145
+ client.remove_container id: 'nginx'
146
+ ```
147
+
148
+ Force remove, and remove all attached volumes.
149
+
150
+ ```ruby
151
+ client.remove_container id: 'nginx', force: true, v: true
152
+ ```
153
+
154
+ #### inspect_container
155
+
156
+ Return a hash containing downcased symbolized container info.
157
+
158
+ ```ruby
159
+ data = client.inspect_container id: 'rails-server'
160
+ puts data
161
+ ```
162
+
163
+ Include size information
164
+
165
+ ```ruby
166
+ data = client.inspect_container id: 'rails-server', size: true
167
+ puts data
168
+ ```
169
+
170
+ #### container_logs
171
+
172
+ Returns a streamable [HTTP:Response::Body](http://www.rubydoc.info/gems/http/HTTP/Response/Body) object
173
+
174
+ Simple logs
175
+
176
+ ```ruby
177
+ logs = client.container_logs id: 'rails-server', stderr: true, stdout: true, tail: 100
178
+ puts logs
179
+ ```
180
+
181
+ Streaming
182
+
183
+ ```ruby
184
+ logs = client.container_logs id: 'rails-server', stdout: true, follow: true
185
+
186
+ while body = logs.readpartial(1024)
187
+ puts body
188
+ end
189
+ ```
190
+
191
+ Include size information
192
+
193
+ ```ruby
194
+ data = client.inspect_container id: 'rails-server', size: true
195
+ puts data
196
+ ```
197
+
198
+ #### container_stats
199
+
200
+ Returns a streamable [HTTP:Response::Body](http://www.rubydoc.info/gems/http/HTTP/Response/Body) object
201
+
202
+ Get stats at the time of the request
203
+
204
+ ```ruby
205
+ stats = client.container_stats id: 'django-server'
206
+ puts stats
207
+ ```
208
+
209
+ Streaming stats at real time
210
+
211
+ ```ruby
212
+ logs = client.container_logs id: 'rails-server', stream: true
213
+
214
+ while body = logs.readpartial(1024)
215
+ puts body
216
+ end
217
+ ```
218
+
219
+ #### kill_container
220
+
221
+ ```ruby
222
+ client.kill_container id: 'django-server'
223
+ ```
224
+
225
+ ```ruby
226
+ client.kill_container id: 'django-server', signal: 'sigterm'
227
+ ```
228
+
229
+ #### rename_container
230
+
231
+ ```ruby
232
+ client.rename_container id: 'django-server', name: 'its-actually-a-rails-server'
233
+ ```
234
+
235
+ ## Volumes API
236
+
237
+ #### remove_volume
238
+
239
+ ```ruby
240
+ client.remove_volume id: 'volume-name'
241
+ ```
242
+
243
+ #### inspect_volume
244
+
245
+ Return a Hash of downcase symbolized json response.
246
+
247
+ ```ruby
248
+ volume_info = client.inspect_volume id: 'volume-id'
249
+ puts volume_info
250
+ ```
251
+
252
+ #### volumes
253
+
254
+ returns an Array of Hyperb::Volume
255
+
256
+ ```ruby
257
+ volumes = client.volumes
258
+ puts volumes
259
+ ```
260
+
261
+ ## Network API
262
+
263
+ #### fip_allocate
264
+
265
+ Returns an array of allocated ips
266
+
267
+ Allocate `count` ips.
268
+
269
+ ```ruby
270
+ client.fip_allocate count: 1
271
+ ```
272
+
273
+ #### fip_release
274
+
275
+ ```ruby
276
+ client.fip_release ip: '8.8.8.8'
277
+ ```
278
+
279
+ #### fips_ls
280
+
281
+ Returns an array of floating ip objects
282
+
283
+ ```ruby
284
+ client.fips_ls
285
+ ```
286
+
287
+ #### fip_detach
288
+
289
+ ```ruby
290
+ client.fip_detach container: 'nginx'
291
+ ```
292
+
293
+ #### fip_attach
294
+
295
+ ```ruby
296
+ client.fip_attach ip: '8.8.8.8', container: 'nginx'
297
+ ```
298
+
299
+ ## Events API
300
+
301
+ wip
302
+
303
+ ## Compose API
304
+
305
+ See [compose API examples](https://github.com/drish/hyperb/blob/master/examples/compose.md)
306
+
307
+ ## Services API
308
+
309
+ #### create_service
310
+
311
+ Returns a Hash of downcased symbolized json response
312
+
313
+ ```ruby
314
+ options = {
315
+ name: 'srvc1', # required
316
+ image: 'nginx', # required
317
+ replicas: 1, # required
318
+ service_port: 80, # required
319
+ container_port: 80,
320
+ labels: { # required
321
+ 'app': 'web1'
322
+ },
323
+ cmd: 'command',
324
+ entrypoint: 'entry.sh',
325
+ env: ['env=123', 'env2=456'],
326
+ protocol: 'https',
327
+ algorithm: 'roundrobin'
328
+ }
329
+
330
+ srvc = client.create_service(options)
331
+ puts srvc
332
+ ````
333
+
334
+ #### remove_service
335
+
336
+ ```ruby
337
+ client.remove_service name: 'srvc1'
338
+ ````
339
+
340
+ ```ruby
341
+ client.remove_service name: 'srvc1', keep: true
342
+ ````
343
+
344
+ ## Snapshot API
345
+
346
+ Return hash containing snapshot information
347
+
348
+ ```ruby
349
+ snapshot = client.create_snapshot name: 'snappy', volume: 'volumeId'
350
+ ```
351
+
352
+ ## Misc.
353
+
354
+ #### Version
355
+
356
+ ```ruby
357
+ client.version
358
+ => {
359
+ "Version"=>"Hyper.sh Public Service",
360
+ "ApiVersion"=>"1.23",
361
+ "GitCommit"=>"",
362
+ "GoVersion"=>"go1.8.1",
363
+ "Os"=>"linux",
364
+ "Arch"=>"amd64",
365
+ "KernelVersion"=>"4.0.0"
366
+ }
367
+ ```