Module: Hyperb::Images

Includes:
Utils
Included in:
API
Defined in:
lib/hyperb/images/images.rb

Overview

images api wrapper

Instance Method Summary collapse

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

Parameters:

  • params (Hash) (defaults to: {})

    A customizable set of params.

Options Hash (params):

  • :tag (String)

    image tag name

  • :x_registry_auth (Hash)

    object containing either login information.

  • x_registry_auth (String)

    :username

  • x_registry_auth (String)

    :email

  • x_registry_auth (String)

    :password

Returns:

  • (HTTP::Response::Body)

    a streamable response object.

Raises:

See Also:



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

Parameters:

  • params (Hash) (defaults to: {})

    A customizable set of params.

Options Hash (params):

  • :all (String)

    default is true

  • :filter (String)

    only return image with the specified name

Returns:

Raises:

See Also:



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

Parameters:

  • params (Hash) (defaults to: {})

    A customizable set of params.

Options Hash (params):

  • :name (String)

    image name to be removed

Returns:

  • (Hash)

    downcased symbolized ‘inspect` json response.

Raises:

See Also:



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

Parameters:

  • params (Hash) (defaults to: {})

    A customizable set of params.

Options Hash (params):

  • :name (String)

    image name to be removed

  • :force (Boolean)

    force image to be removed

Returns:

  • (Array)

    array of downcase symbolized json response.

Raises:

See Also:



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