Sha256: e144449071e0b2f77686b12586d2f0fb208256239720adeebdd9ad6868daddc3

Contents?: true

Size: 1.32 KB

Versions: 15

Compression:

Stored size: 1.32 KB

Contents

module Fog
  module Compute
    class Google
      class ForwardingRules < Fog::Collection
        model Fog::Compute::Google::ForwardingRule

        def all(region: nil, filter: nil, max_results: nil,
                order_by: nil, page_token: nil)

          opts = {
            :filter => filter,
            :max_results => max_results,
            :order_by => order_by,
            :page_token => page_token
          }

          if region
            data = service.list_forwarding_rules(region, opts).items
          else
            data = []
            service.list_aggregated_forwarding_rules(opts).items
                   .each_value do |scoped_list|
              if scoped_list && scoped_list.forwarding_rules
                data.concat(scoped_list.forwarding_rules)
              end
            end
          end
          load(data.map(&:to_h))
        end

        def get(identity, region = nil)
          response = nil
          if region
            response = service.get_forwarding_rule(identity, region).to_h
          else
            response = all(
              :filter => "name eq #{identity}", :max_results => 1
            ).first
            response = response.attributes unless response.nil?
          end

          return nil if response.nil?
          new(response)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fog-google-1.7.1 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.7.0 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.6.0 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.5.0 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.4.0 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.3.3 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.3.2 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.3.1 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.3.0 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.2.2 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.2.1 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.2.0 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.1.0 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.0.1 lib/fog/compute/google/models/forwarding_rules.rb
fog-google-1.0.0 lib/fog/compute/google/models/forwarding_rules.rb