Sha256: 4c66f5069eb692467b5a912b154eb1a636f5fab5d6f084b9cbfbc204e95dddb8

Contents?: true

Size: 1.58 KB

Versions: 14

Compression:

Stored size: 1.58 KB

Contents

module Fog
  module Compute
    class Google
      class Mock
        def list_aggregated_servers(options = {})
          # Create a Hash of unique zones from the servers Array previously filled when servers are created
          zones = Hash[data[:servers].values.map { |server| ["zones/#{server['zone'].split('/')[-1]}", { "instances" => [] }] }]
          if options[:filter]
            # Look up for the server name
            server = data[:servers][options[:filter].gsub(/name eq \.\*/, "")]
            # Fill the zones Hash with the server (if it's found)
            zones["zones/#{server['zone'].split('/')[-1]}"]["instances"].concat([server]) if server
          else
            # Fill the zones Hash with the servers attached to each zone
            data[:servers].values.each { |server| zones["zones/#{server['zone'].split('/')[-1]}"]["instances"].concat([server]) }
          end
          build_excon_response("kind" => "compute#instanceAggregatedList",
                               "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/aggregated/instances",
                               "id" => "projects/#{@project}/aggregated/instances",
                               "items" => zones)
        end
      end

      class Real
        def list_aggregated_servers(options = {})
          api_method = @compute.instances.aggregated_list
          parameters = {
            "project" => @project
          }
          parameters["filter"] = options[:filter] if options[:filter]

          request(api_method, parameters)
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-google-0.6.0 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.5.5 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.5.4 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.5.3 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.5.2 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.5.1 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.5.0 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.4.2 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.4.1 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.4.0 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.3.2 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.3.1 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.3.0 lib/fog/compute/google/requests/list_aggregated_servers.rb
fog-google-0.2.0 lib/fog/compute/google/requests/list_aggregated_servers.rb