Sha256: 0ef3d1593adcf24599f435f50967a9e223e6b2a860328dfdd0b361efae8442af

Contents?: true

Size: 1.66 KB

Versions: 10

Compression:

Stored size: 1.66 KB

Contents

unless Fog.mocking?

  module Fog
    module AWS
      class EC2

        # 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 = indexed_params('PublicIp', public_ip)
          request({
            'Action' => 'DescribeAddresses'
          }.merge!(params), Fog::Parsers::AWS::EC2::DescribeAddresses.new)
        end

      end
    end
  end

else

  module Fog
    module AWS
      class EC2

        def describe_addresses(public_ip = [])
          response = Excon::Response.new
          public_ip = [*public_ip]
          if public_ip != []
            addresses_set = Fog::AWS::EC2.data[:addresses].reject {|key, value| !public_ip.include?(key)}.values
          else
            addresses_set = Fog::AWS::EC2.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
            }
          else
            response.status = 400
            raise(Excon::Errors.status_error({:expects => 200}, response))
          end
          response
        end

      end
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fog-0.0.41 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.40 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.39 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.38 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.37 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.36 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.35 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.34 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.33 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.32 lib/fog/aws/requests/ec2/describe_addresses.rb