Sha256: 0a3b61887de5afe8d7a309ccb94dc49761c7d9a4f2d570827f6623a20f0273ba

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

module Fog
  module DNS
    class AWS
      class Real

        require 'fog/aws/parsers/dns/get_change'

        # returns the current state of a change request
        #
        # ==== Parameters
        # * change_id<~String>
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'Id'<~String>
        #     * 'Status'<~String>
        #     * 'SubmittedAt'<~String>
        #   * status<~Integer> - 200 when successful
        def get_change(change_id)

          # AWS methods return change_ids that looks like '/change/id'.  Let the caller either use
          # that form or just the actual id (which is what this request needs)
          change_id = change_id.sub('/change/', '')

          request({
            :expects => 200,
            :parser  => Fog::Parsers::DNS::AWS::GetChange.new,
            :method  => 'GET',
            :path    => "change/#{change_id}"
          })

        end

      end

      class Mock
        def get_change(change_id)
          response = Excon::Response.new
          # find the record with matching change_id
          # records = data[:zones].values.map{|z| z[:records].values.map{|r| r.values}}.flatten
          change = self.data[:changes][change_id]

          if change
            response.status = 200
            response.body = {
              'Id' => change[:id],
              'Status' => 'INSYNC', # TODO do some logic here
              'SubmittedAt' => change[:submitted_at]
            }
            response
          else
            response.status = 404
            response.body = "<?xml version=\"1.0\"?><ErrorResponse xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><Error><Type>Sender</Type><Code>NoSuchChange</Code><Message>Could not find resource with ID: #{change_id}</Message></Error><RequestId>#{Fog::AWS::Mock.request_id}</RequestId></ErrorResponse>"
            raise(Excon::Errors.status_error({:expects => 200}, response))
          end
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-maestrodev-1.18.0.20131114200144 lib/fog/aws/requests/dns/get_change.rb