Skip to content

Instantly share code, notes, and snippets.

@vijaykramesh
Created November 14, 2013 22:06
Show Gist options
  • Save vijaykramesh/7475134 to your computer and use it in GitHub Desktop.
Save vijaykramesh/7475134 to your computer and use it in GitHub Desktop.
example plugin with aws-sdk-core
require 'aws-sdk-core'
class GlacierAccountId < Seahorse::Client::Plugin
option :account_id, '-'
# :validate, :build, :sign, :send - where in the stack you want the middleware to apply
handle_request(step: :validate, priority: 99) do |context|
context.params[:account_id] ||= context.config.account_id
end
end
Aws::Glacier.new.list_vaults # fails because the plugin hasn't been applied
Aws::Glacier.add_plugin GlacierAccountId
Aws::Glacier.new.list_vaults # now works!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment