Sha256: 5cbb1f84be932c07a939aa2da5107e0f0b3c3613e04d486039ad945b8b80f4a1

Contents?: true

Size: 1.65 KB

Versions: 11

Compression:

Stored size: 1.65 KB

Contents

module Fog
  module Compute
    class AWS
      class Real
        require 'fog/aws/parsers/compute/restore_address_to_classic'

        # Move address from VPC to Classic
        #
        # === Returns
        # * response<~Excon::Response>:
        #   * body<~<Hash>:
        #     * 'publicIp'<~String> - IP address
        #     * 'requestId'<~String> - Id of the request
        #     * 'status'<~String> - The status of the move of the IP address (MoveInProgress | InVpc | InClassic)

        def restore_address_to_classic(public_ip)
          request(
            'Action' => 'RestoreAddressToClassic',
            'PublicIp' => public_ip,
            :idempotent => true,
            :parser => Fog::Parsers::Compute::AWS::RestoreAddressToClassic.new
          )
        end
      end

      class Mock
        def restore_address_to_classic(public_ip)
          response      = Excon::Response.new

          address = self.data[:addresses][public_ip]

          if address
            if address[:origin] == 'vpc'
              raise Fog::Compute::AWS::Error.new("InvalidState => You cannot migrate an Elastic IP address that was originally allocated for use in EC2-VPC to EC2-Classic.")
            end

            address['domain']       = 'standard'
            address.delete("allocationId")

            response.status = 200
            response.body = {
              'requestId' => Fog::AWS::Mock.request_id,
              'publicIp'  => public_ip,
              'status'    => "InClassic"
            }

            response
          else
            raise Fog::Compute::AWS::NotFound.new("Address does not exist")
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 9 versions & 2 rubygems

Version Path
fog-aws-3.1.0 lib/fog/aws/requests/compute/restore_address_to_classic.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-aws-2.0.1/lib/fog/aws/requests/compute/restore_address_to_classic.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aws-2.0.1/lib/fog/aws/requests/compute/restore_address_to_classic.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aws-2.0.1/lib/fog/aws/requests/compute/restore_address_to_classic.rb
fog-aws-3.0.0 lib/fog/aws/requests/compute/restore_address_to_classic.rb
fog-aws-2.0.1 lib/fog/aws/requests/compute/restore_address_to_classic.rb
fog-aws-2.0.0 lib/fog/aws/requests/compute/restore_address_to_classic.rb
fog-aws-1.4.1 lib/fog/aws/requests/compute/restore_address_to_classic.rb
fog-aws-1.4.0 lib/fog/aws/requests/compute/restore_address_to_classic.rb
fog-aws-1.3.0 lib/fog/aws/requests/compute/restore_address_to_classic.rb
fog-aws-1.2.1 lib/fog/aws/requests/compute/restore_address_to_classic.rb