Sha256: 2e543320c6749fed57aca177d65a8830302011c07b92b83a26febe2fe325a040

Contents?: true

Size: 1.73 KB

Versions: 1039

Compression:

Stored size: 1.73 KB

Contents

module Aws
  module Plugins

    # The Amazon Route 53 API returns hosted zones and request Ids as strings
    # formatted like:
    #
    #     '/hostedzone/ID'
    #     '/change/ID'
    #
    # However, their API does not accept Ids with the '/hostedzone/' or
    # '/change/' prefixes. This plugin removes those prefixes before
    # serializing their Ids onto the request. This allows a user to
    # use the prefixed Ids returned in {Aws::Route53::Client} responses.
    class Route53IdFix < Seahorse::Client::Plugin

      class Handler < Seahorse::Client::Handler

        def call(context)
          remove_id_prefixes(context.params)
          @handler.call(context)
        end

        private

        def remove_id_prefixes(params)
          # Many operations accept of :id or :hosted_zone_id as a root-level
          # param, pruning prefixes from those.
          [:id, :hosted_zone_id, :delegation_set_id].each do |key|
            params[key] = remove_prefix(params[key]) if params[key]
          end

          # The `#change_resource_record_sets operation` has a deeply nested
          # target with a :hosted_zone_id that needs to be pruned.
          if params[:change_batch]
            params[:change_batch][:changes].each do |batch|
              if target = batch[:resource_record_set][:alias_target]
                target[:hosted_zone_id] = remove_prefix(target[:hosted_zone_id])
              end
            end
          end
        end

        def remove_prefix(str)
          str.sub(/^\/(hostedzone|change|delegationset)\//, '')
        end

      end

      # Run this handler after params have been validated, but before
      # they are serialized onto the request
      handler(Handler, priority: 99, step: :build)

    end
  end
end

Version data entries

1,039 entries across 1,039 versions & 2 rubygems

Version Path
aws-sdk-core-2.11.632 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.631 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.630 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.629 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.628 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.627 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.626 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.625 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.624 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.623 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.622 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.621 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.620 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.619 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.618 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.617 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.616 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.615 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.614 lib/aws-sdk-core/plugins/route_53_id_fix.rb
aws-sdk-core-2.11.613 lib/aws-sdk-core/plugins/route_53_id_fix.rb