Sha256: f980ee07a040807d3206df2325a560f685c057e780e56aa2f7d79a48fa8a389c

Contents?: true

Size: 1.06 KB

Versions: 10

Compression:

Stored size: 1.06 KB

Contents

module Fog
  module Compute
    class Google
      class Subnetworks < Fog::Collection
        model Fog::Compute::Google::Subnetwork

        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.nil?
            data = []
            service.list_aggregated_subnetworks(filters).to_h[:items].each_value do |region_obj|
              data.concat(region_obj["subnetworks"]) if region_obj["subnetworks"]
            end
          else
            data = service.list_subnetworks(region, filters).to_h[:items]
          end
          load(data || [])
        end

        def get(identity, region)
          if subnetwork = service.get_subnetwork(identity, region).to_h
            new(subnetwork)
          end
        rescue ::Google::Apis::ClientError => e
          raise e unless e.status_code == 404
          nil
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fog-google-1.3.3 lib/fog/compute/google/models/subnetworks.rb
fog-google-1.3.2 lib/fog/compute/google/models/subnetworks.rb
fog-google-1.3.1 lib/fog/compute/google/models/subnetworks.rb
fog-google-1.3.0 lib/fog/compute/google/models/subnetworks.rb
fog-google-1.2.2 lib/fog/compute/google/models/subnetworks.rb
fog-google-1.2.1 lib/fog/compute/google/models/subnetworks.rb
fog-google-1.2.0 lib/fog/compute/google/models/subnetworks.rb
fog-google-1.1.0 lib/fog/compute/google/models/subnetworks.rb
fog-google-1.0.1 lib/fog/compute/google/models/subnetworks.rb
fog-google-1.0.0 lib/fog/compute/google/models/subnetworks.rb