Class: Fog::Compute::Google::Subnetworks
- Inherits:
-
Fog::Collection
- Object
- Fog::Collection
- Fog::Compute::Google::Subnetworks
- Defined in:
- lib/fog/compute/google/models/subnetworks.rb
Instance Method Summary collapse
- #all(region: nil, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object
- #get(identity, region = nil) ⇒ Object
Instance Method Details
#all(region: nil, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/compute/google/models/subnetworks.rb', line 7 def all(region: nil, filter: nil, max_results: nil, order_by: nil, page_token: nil) filters = { :filter => filter, :max_results => max_results, :order_by => order_by, :page_token => page_token } if region data = service.list_subnetworks(region, filters).to_h[:items] || [] else data = [] service.list_aggregated_subnetworks(filters).to_h[:items].each_value do |region_obj| data.concat(region_obj[:subnetworks]) if region_obj[:subnetworks] end end load(data) end |
#get(identity, region = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/compute/google/models/subnetworks.rb', line 26 def get(identity, region = nil) if region subnetwork = service.get_subnetwork(identity, region).to_h return new(subnetwork) elsif identity response = all(:filter => "name eq #{identity}", :max_results => 1) subnetwork = response.first unless response.empty? return subnetwork end rescue ::Google::Apis::ClientError => e raise e unless e.status_code == 404 nil end |