Module: Hyperb::Images
Overview
images api wrapper
Instance Method Summary collapse
-
#create_image(params = {}) ⇒ HTTP::Response::Body
create (pull) an image.
-
#images(params = {}) ⇒ Hyperb::Image
list images.
-
#inspect_image(params = {}) ⇒ Hash
inspect an image.
-
#remove_image(params = {}) ⇒ Array
remove an image.
Methods included from Utils
#camelize, #check_arguments, #downcase_symbolize, #prepare_json, #underscore
Instance Method Details
#create_image(params = {}) ⇒ HTTP::Response::Body
create (pull) an image
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/hyperb/images/images.rb', line 52 def create_image(params = {}) raise ArgumentError, 'Invalid arguments.' unless check_arguments(params, 'from_image') path = '/images/create' query = { fromImage: params[:from_image] } query[:tag] = params[:tag] if params.key?(:tag) additional_headers = {} if params.key?(:x_registry_auth) auth = params[:x_registry_auth] additional_headers[:x_registry_auth] = Hyperb::AuthObject.new(auth).encode end res = Hyperb::Request.new(self, path, query, 'post', '', additional_headers).perform res end |
#images(params = {}) ⇒ Hyperb::Image
list images
24 25 26 27 28 29 30 31 |
# File 'lib/hyperb/images/images.rb', line 24 def images(params = {}) path = '/images/json' query = {} query[:all] = params[:all] || true query[:filter] = params[:filter] if params.key?(:filter) response = JSON.parse(Hyperb::Request.new(self, path, query, 'get').perform) response.map { |image| Hyperb::Image.new(image) } end |
#inspect_image(params = {}) ⇒ Hash
inspect an image
101 102 103 104 105 106 |
# File 'lib/hyperb/images/images.rb', line 101 def inspect_image(params = {}) raise ArgumentError, 'Invalid arguments.' unless check_arguments(params, 'name') path = '/images/' + params[:name] + '/json' res = JSON.parse(Hyperb::Request.new(self, path, {}, 'get').perform) downcase_symbolize(res) end |
#remove_image(params = {}) ⇒ Array
remove an image
80 81 82 83 84 85 86 87 |
# File 'lib/hyperb/images/images.rb', line 80 def remove_image(params = {}) raise ArgumentError, 'Invalid arguments.' unless check_arguments(params, 'name') path = '/images/' + params[:name] query = {} query[:force] = true if params.key?(:force) res = JSON.parse(Hyperb::Request.new(self, path, query, 'delete').perform) downcase_symbolize(res) end |