class Aws::Api::Customizer

Attributes

api[R]

@return [Seahorse::Model::Api]

client_class[R]

@return [Class<Seahorse::Client::Base>]

Public Class Methods

new(client_class) click to toggle source

@api private

# File lib/aws-sdk-core/api/customizer.rb, line 6
def initialize(client_class)
  @client_class = client_class
  @api = client_class.api
end

Public Instance Methods

add_plugin(plugin) click to toggle source

@param [String, Class<Seahorse::Client::Plugin>] plugin

# File lib/aws-sdk-core/api/customizer.rb, line 23
def add_plugin(plugin)
  @client_class.add_plugin(plugin)
end
add_shape(shape_name, definition) click to toggle source
# File lib/aws-sdk-core/api/customizer.rb, line 36
def add_shape(shape_name, definition)
  @client_class.api.definition['shapes'][shape_name] = definition
end
apply(&customizations) click to toggle source

@api private

# File lib/aws-sdk-core/api/customizer.rb, line 18
def apply(&customizations)
  instance_eval(&customizations)
end
each_operation(&block) click to toggle source
# File lib/aws-sdk-core/api/customizer.rb, line 61
def each_operation(&block)
  @client_class.api.definition['operations'].each(&block)
end
metadata(key, value) click to toggle source
# File lib/aws-sdk-core/api/customizer.rb, line 32
def metadata(key, value)
  @client_class.api.definition['metadata'][key] = value
end
remove_plugin(plugin) click to toggle source

@param [String, Class<Seahorse::Client::Plugin>] plugin

# File lib/aws-sdk-core/api/customizer.rb, line 28
def remove_plugin(plugin)
  @client_class.remove_plugin(plugin)
end
reshape(shape_name, modifications) click to toggle source
# File lib/aws-sdk-core/api/customizer.rb, line 40
def reshape(shape_name, modifications)
  shape = @client_class.api.definition['shapes'][shape_name]
  shape = deep_merge(shape, modifications)
  @client_class.api.definition['shapes'][shape_name] = shape
end
reshape_members(member_regex, modifications) click to toggle source
# File lib/aws-sdk-core/api/customizer.rb, line 46
def reshape_members(member_regex, modifications)
  if member_regex.is_a?(String)
    member_regex = /^#{member_regex}$/
  end
  @client_class.api.definition['shapes'].each do |shape_name, shape|
    if shape['members']
      shape['members'].each do |member_name, member_ref|
        if member_name.match(member_regex)
          shape['members'][member_name] = deep_merge(member_ref, modifications)
        end
      end
    end
  end
end

Private Instance Methods

deep_merge(first_hash, other_hash) click to toggle source
# File lib/aws-sdk-core/api/customizer.rb, line 67
def deep_merge(first_hash, other_hash)
  first_hash.merge(other_hash) do |key, old, new|
    Hash === old && Hash === new ? deep_merge(old, new) : new
  end
end