Class: Fog::Compute::Google::TargetPools

Inherits:
Fog::Collection
  • Object
show all
Defined in:
lib/fog/google/models/compute/target_pools.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/target_pools.rb', line 10

def all(filters={})
  if filters['region'].nil?
    data = []
    service.list_regions.body['items'].each do |region|
      data += service.list_target_pools(region['name']).body['items'] || []
    end
  else
    data = service.list_target_pools(filters['region']).body['items'] || []
  end
  load(data)
end

#get(identity, region = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/google/models/compute/target_pools.rb', line 22

def get(identity, region=nil)
  response = nil
  if region.nil?
    service.regions.all.each do |region|
      begin
        response = service.get_target_pool(identity, region.name)
        break if response.status == 200
      rescue Fog::Errors::Error
      end
    end
  else
    response = service.get_target_pool(identity, region)
  end
  return nil if response.nil?
  new(response.body)
end