Module: Hyperb::Network

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

Overview

network api wrapper

Instance Method Summary collapse

Methods included from Utils

#camelize, #check_arguments, #downcase_symbolize, #prepare_json, #underscore

Instance Method Details

#fip_allocate(params = {}) ⇒ Array

allocate a new floating ip

Parameters:

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

    A customizable set of params.

Options Hash (params):

  • :count (String)

    the number of free fips to allocate

Returns:

  • (Array)

    Array of ips (string).

Raises:

See Also:



93
94
95
96
97
98
99
100
# File 'lib/hyperb/network/fips.rb', line 93

def fip_allocate(params = {})
  raise ArgumentError, 'Invalid Arguments' unless check_arguments(params, 'count')
  path = '/fips/allocate'
  query = {}
  query[:count] = params[:count] if params.key?(:count)
  fips = JSON.parse(Hyperb::Request.new(self, path, query, 'post').perform)
  fips
end

#fip_attach(params = {}) ⇒ Object

attach a floating ip to a container

Parameters:

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

    A customizable set of params.

Options Hash (params):

  • :ip (String)
  • :container (String)

Raises:

See Also:



40
41
42
43
44
45
46
47
# File 'lib/hyperb/network/fips.rb', line 40

def fip_attach(params = {})
  raise ArgumentError, 'Invalid Arguments' unless check_arguments(params, 'container', 'ip')
  path = '/fips/attach'
  query = {}
  query[:ip] = params[:ip] if params.key?(:ip)
  query[:container] = params[:container] if params.key?(:container)
  Hyperb::Request.new(self, path, query, 'post').perform
end

#fip_detach(params = {}) ⇒ Object

detach a floating ip from a container

Parameters:

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

    A customizable set of params.

Options Hash (params):

  • :container (String)

    container name/id

Raises:

See Also:



22
23
24
25
26
27
28
# File 'lib/hyperb/network/fips.rb', line 22

def fip_detach(params = {})
  raise ArgumentError, 'Invalid Arguments' unless check_arguments(params, 'container')
  path = '/fips/detach'
  query = {}
  query[:container] = params[:container] if params.key?(:container)
  Hyperb::Request.new(self, path, query, 'post').perform
end

#fip_name(params = {}) ⇒ Object

set a name for floating ip

Parameters:

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

    A customizable set of params.

Options Hash (params):

  • :ip (String)

    fip

  • :name (String)

    the name

Raises:

See Also:



115
116
117
118
119
120
121
122
# File 'lib/hyperb/network/fips.rb', line 115

def fip_name(params = {})
  raise ArgumentError, 'Invalid Arguments' unless check_arguments(params, 'ip', 'name')
  path = '/fips/name'
  query = {}
  query[:ip] = params[:ip] if params.key?(:ip)
  query[:name] = params[:name] if params.key?(:name)
  Hyperb::Request.new(self, path, query, 'post').perform
end

#fip_release(params = {}) ⇒ Object

release a floating ip

Parameters:

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

    A customizable set of params.

Options Hash (params):

  • :ip (String)

    the number of free fips to allocate

Raises:

See Also:



76
77
78
79
80
81
# File 'lib/hyperb/network/fips.rb', line 76

def fip_release(params = {})
  path = '/fips/release'
  query = {}
  query[:ip] = params[:ip] if params.key?(:ip)
  Hyperb::Request.new(self, path, query, 'post').perform
end

#fips_ls(params = {}) ⇒ Object

list floating ips

Parameters:

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

    A customizable set of params.

Options Hash (params):

  • :filters (String)

Raises:

See Also:



60
61
62
63
64
65
# File 'lib/hyperb/network/fips.rb', line 60

def fips_ls(params = {})
  path = '/fips'
  query = {}
  query[:filters] = params[:filters] if params.key?(:filters)
  downcase_symbolize(JSON.parse(Hyperb::Request.new(self, path, query, 'get').perform))
end