Class: Brightbox::CloudIP

Inherits:
Api
  • Object
show all
Defined in:
lib/bbcloud/cloud_ips.rb

Instance Attribute Summary

Attributes inherited from Api

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Api

cache_all!, cached_get, conn, #exists?, find, find_by_handle, #fog_model, #initialize, #method_missing, #to_s

Constructor Details

This class inherits a constructor from Brightbox::Api

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Brightbox::Api

Class Method Details

.allObject



7
8
9
# File 'lib/bbcloud/cloud_ips.rb', line 7

def self.all
  conn.cloud_ips
end

.createObject



11
12
13
14
15
16
17
18
# File 'lib/bbcloud/cloud_ips.rb', line 11

def self.create
  r = conn.create_cloud_ip
  new(r["id"])
rescue Excon::Errors::Forbidden => e
  response = JSON.parse(e.response.body) rescue {}
  response = response.fetch("error", {})
  raise Forbidden, "#{response["details"]}: #{response["summary"]}"
end

.default_field_orderObject



32
33
34
# File 'lib/bbcloud/cloud_ips.rb', line 32

def self.default_field_order
  [:id, :status, :public_ip, :server_id, :interface_id, :reverse_dns]
end

.get(id) ⇒ Object



3
4
5
# File 'lib/bbcloud/cloud_ips.rb', line 3

def self.get id
  conn.cloud_ips.get id
end

Instance Method Details

#<=>(b) ⇒ Object



36
37
38
# File 'lib/bbcloud/cloud_ips.rb', line 36

def <=>(b)
  self.status <=> b.status
end

#attributesObject



20
21
22
# File 'lib/bbcloud/cloud_ips.rb', line 20

def attributes
  fog_model.attributes
end

#mapped?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/bbcloud/cloud_ips.rb', line 28

def mapped?
  status == 'mapped'
end

#to_rowObject



24
25
26
# File 'lib/bbcloud/cloud_ips.rb', line 24

def to_row
  attributes
end