Sha256: 1fd04652208804ef59567952d95c01f62a3648aecf4a90b91d8e8eb5b09a6654

Contents?: true

Size: 1.67 KB

Versions: 16

Compression:

Stored size: 1.67 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',
            :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
            }
          else
            response.status = 400
            raise(Excon::Errors.status_error({:expects => 200}, response))
          end
          response
        end

      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fog-0.0.72 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.71 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.70 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.69 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.68 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.67 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.66 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.65 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.64 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.63 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.62 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.61 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.60 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.59 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.58 lib/fog/aws/requests/ec2/describe_addresses.rb
fog-0.0.57 lib/fog/aws/requests/ec2/describe_addresses.rb