Sha256: 1e848166d1d2a9a146c54633b65ba7913fd0df89ff3795c4ee8a829549dab050

Contents?: true

Size: 1.69 KB

Versions: 33

Compression:

Stored size: 1.69 KB

Contents

module Fog
  module AWS
    module EC2
      class Real

        require 'fog/aws/parsers/ec2/describe_addresses'

        # Describe all or specified IP addresses.
        #
        # ==== Parameters
        # * public_ip<~Array> - List of ips to describe, defaults to all
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'requestId'<~String> - Id of request
        #     * 'addressesSet'<~Array>:
        #       * 'instanceId'<~String> - instance for ip address
        #       * 'publicIp'<~String> - ip address for instance
        def describe_addresses(public_ip = [])
          params = AWS.indexed_param('PublicIp', public_ip)
          request({
            'Action'    => 'DescribeAddresses',
            :idempotent => true,
            :parser     => Fog::Parsers::AWS::EC2::DescribeAddresses.new
          }.merge!(params))
        end

      end

      class Mock

        def describe_addresses(public_ip = [])
          response = Excon::Response.new
          public_ip = [*public_ip]
          if public_ip != []
            addresses_set = @data[:addresses].reject {|key, value| !public_ip.include?(key)}.values
          else
            addresses_set = @data[:addresses].values
          end
          if public_ip.length == 0 || public_ip.length == addresses_set.length
            response.status = 200
            response.body = {
              'requestId'     => Fog::AWS::Mock.request_id,
              'addressesSet'  => addresses_set
            }
            response
          else
            raise Fog::AWS::EC2::NotFound.new("Address #{public_ip.inspect} not found.")
          end
        end

      end
    end
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
fog-0.2.30 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.28 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.27 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.26 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.25 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.24 lib/fog/aws/requests/ec2/describe_addresses.rb
tecnh-fog-0.2.23.vpc lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.23 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.22 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.21 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.20 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.19 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.18 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.17 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.16 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.15 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.14 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.13 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.12 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.2.11 lib/fog/aws/requests/ec2/describe_addresses.rb