Class: Fog::Compute::Google::Subnetworks

Inherits:
Fog::Collection
  • Object
show all
Defined in:
lib/fog/compute/google/models/subnetworks.rb

Instance Method Summary collapse

Instance Method Details

#all(filters = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/compute/google/models/subnetworks.rb', line 7

def all(filters = {})
  if filters[:region]
    data = service.list_subnetworks(filters[:region]).body["items"] || []
  else
    data = []
    service.list_aggregated_subnetworks(filters).body["items"].each_value do |region|
      data.concat(region["subnetworks"]) if region["subnetworks"]
    end
  end
  load(data || [])
end

#get(identity, region) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/fog/compute/google/models/subnetworks.rb', line 19

def get(identity, region)
  if subnetwork = service.get_subnetwork(identity, region).body
    new(subnetwork)
  end
rescue Fog::Errors::NotFound
  nil
end