Class: Fog::Network::Softlayer::Ips
- Inherits:
-
Collection
- Object
- Collection
- Fog::Network::Softlayer::Ips
- Defined in:
- lib/fog/softlayer/models/network/ips.rb
Instance Method Summary collapse
- #all(filters = filters) ⇒ Object
- #by_address(address) ⇒ Object
- #get(id) ⇒ Object
- #global_records ⇒ Object
-
#initialize(attributes) ⇒ Ips
constructor
A new instance of Ips.
Constructor Details
permalink #initialize(attributes) ⇒ Ips
Returns a new instance of Ips.
18 19 20 21 |
# File 'lib/fog/softlayer/models/network/ips.rb', line 18 def initialize(attributes) self.filters ||= {} super end |
Instance Method Details
permalink #all(filters = filters) ⇒ Object
[View source]
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fog/softlayer/models/network/ips.rb', line 23 def all(filters = filters) self.filters = filters ips = service.get_ip_addresses.body ips.each_with_index do |ip,i| if global_records.keys.include?(ip['id']) ips[i] = parse_global_ip_record(service.get_global_ip_address(global_records[ip['id']]['id']).body) end end load(ips) end |
permalink #by_address(address) ⇒ Object
[View source]
36 37 38 39 40 41 |
# File 'lib/fog/softlayer/models/network/ips.rb', line 36 def by_address(address) ip = service.get_ip_addresses.body.select do |ip| ip['ipAddress'] == address end.first new(ip) if ip end |
permalink #get(id) ⇒ Object
[View source]
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fog/softlayer/models/network/ips.rb', line 43 def get(id) if global_records.keys.include?(id) response = service.get_global_ip_address(global_records[id]['id']).body ip = parse_global_ip_record(response) else ip = service.get_ip_address(id).body end new(ip) if ip rescue Fog::Network::Softlayer::NotFound nil end |
permalink #global_records ⇒ Object
[View source]
57 58 59 60 61 |
# File 'lib/fog/softlayer/models/network/ips.rb', line 57 def global_records @records ||= {} service.get_global_ip_records.body.each { |record| @records[record['ipAddressId']] = record } if @records.empty? @records end |