Class: Fog::Compute::Google::Addresses
- Inherits:
-
Fog::Collection
- Object
- Fog::Collection
- Fog::Compute::Google::Addresses
- Defined in:
- lib/fog/google/models/compute/addresses.rb
Instance Method Summary collapse
Instance Method Details
#all(filters = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/google/models/compute/addresses.rb', line 10 def all(filters = {}) if filters[:region] data = service.list_addresses(filters[:region]).body['items'] || [] else data = [] service.list_aggregated_addresses.body['items'].each_value do |region| data.concat(region['addresses']) if region['addresses'] end end load(data) end |
#get(identity, region) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/fog/google/models/compute/addresses.rb', line 22 def get(identity, region) if address = service.get_address(identity, region).body new(address) end rescue Fog::Errors::NotFound nil end |
#get_by_ip_address(ip_address) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/fog/google/models/compute/addresses.rb', line 30 def get_by_ip_address(ip_address) addresses = service.list_aggregated_addresses(:filter => "address eq .*#{ip_address}").body['items'] address = addresses.each_value.select { |region| region.key?('addresses') } return nil if address.empty? new(address.first['addresses'].first) end |