This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cf = Aws::CloudFront::Client.new | |
| resp = cf.create_distribution( | |
| distribution_config: { | |
| caller_reference: Time.now.to_i.to_s, | |
| aliases: { | |
| quantity: 0 | |
| }, | |
| default_root_object: '', | |
| origins: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'aws-sdk-v1' | |
| queue = AWS::SQS.new.queues['queue-arn'] | |
| topic = AWS::SNS.new.topics['topic-arn'] | |
| # this will modify the queue policy to allow the topic to send messages | |
| topic.subscribe(queue) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A simple extraction from the V1 SDK for Ruby from AWS::SQS::Queue#poll. | |
| # No effort was made to test this code. | |
| # | |
| # @example Basic Usage | |
| # | |
| # poller = QueuePoller.new(queue_url) | |
| # poller.poll { |msg| puts msg.body} | |
| # | |
| # @example Customized API client | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # You can pass client options directly to the Resource constructor, | |
| # no need to construct a client yourself | |
| s3 = Aws::S3::Resource.new( | |
| credentials: Aws::Credentials.new('akid', 'secret'), | |
| region: 'eu-west-1' | |
| ) | |
| s3.bucket('backup').object('dir/subdir/filename.txt').upload_file(local_file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| shape = sqs.config.api.operation(:receive_message).output | |
| shape = Seahorse::Model::Shapes::Structure.new({ | |
| 'members' => { | |
| shape.metadata('resultWrapper') => shape.definition, | |
| 'ResponseMetadata' => { | |
| 'type' => 'structure', | |
| 'members' => { | |
| 'RequestId' => { 'type' => 'string' } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| client = Aws::S3::Client.new(credentials: Aws::Credentials.new('akid', 'secret')) | |
| encryption_client = Aws::S3::Encryption::Client.new(client: client) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pattern = "[aws] [:client_class] operation=:operation duration=:time retries=:retries error=:error_class\n" | |
| Aws.config[:log_formatter] = Seahorse::Client::Logging::Formatter.new(pattern) | |
| # success | |
| [aws] [Aws::S3::Client] operation=list_buckets duration=0.602057 retries=0 error= | |
| # error | |
| [aws] [Aws::S3::Client] operation=head_bucket duration=1.100552 retries=0 error=Aws::S3::Errors::Forbidden |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ProgressIO | |
| def initialize(io) | |
| @io = io | |
| end | |
| def read(bytes = nil, output_buffer = nil) | |
| puts bytes | |
| @io.read(bytes, output_buffer) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ConditionalRaisePlugin < Seahorse::Client::Plugin | |
| class Handler < Seahorse::Client::Handler | |
| def call(context) | |
| response = @handler.call(context) | |
| conditional_raise(response.error, context.config.errors_to_ignore) | |
| response | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This example server accepts a simple PUT request with the 'Excpect: 100-continue' | |
| # header. It alternates between the following two responses: | |
| # | |
| # * 100 Continue, accepting the body, then 200 OK | |
| # * 403 Forbidden, not accepting the body | |
| # | |
| require 'socket' | |
| server = TCPServer.new('localhost', 3000) |
OlderNewer