Module: Fog::AWS

Defined in:
lib/fog/aws.rb,
lib/fog/aws/s3.rb,
lib/fog/aws/ec2.rb,
lib/fog/aws/elb.rb,
lib/fog/aws/simpledb.rb,
lib/fog/aws/models/s3/file.rb,
lib/fog/aws/models/s3/files.rb,
lib/fog/aws/models/ec2/image.rb,
lib/fog/aws/models/ec2/flavor.rb,
lib/fog/aws/models/ec2/images.rb,
lib/fog/aws/models/ec2/server.rb,
lib/fog/aws/models/ec2/volume.rb,
lib/fog/aws/models/ec2/address.rb,
lib/fog/aws/models/ec2/flavors.rb,
lib/fog/aws/models/ec2/servers.rb,
lib/fog/aws/models/ec2/volumes.rb,
lib/fog/aws/models/ec2/key_pair.rb,
lib/fog/aws/models/ec2/snapshot.rb,
lib/fog/aws/models/s3/directory.rb,
lib/fog/aws/models/ec2/addresses.rb,
lib/fog/aws/models/ec2/key_pairs.rb,
lib/fog/aws/models/ec2/snapshots.rb,
lib/fog/aws/models/s3/directories.rb,
lib/fog/aws/requests/s3/get_bucket.rb,
lib/fog/aws/requests/s3/get_object.rb,
lib/fog/aws/requests/s3/put_bucket.rb,
lib/fog/aws/requests/s3/put_object.rb,
lib/fog/aws/requests/s3/copy_object.rb,
lib/fog/aws/requests/s3/get_service.rb,
lib/fog/aws/requests/s3/head_object.rb,
lib/fog/aws/requests/simpledb/select.rb,
lib/fog/aws/models/ec2/security_group.rb,
lib/fog/aws/requests/s3/delete_bucket.rb,
lib/fog/aws/requests/s3/delete_object.rb,
lib/fog/aws/models/ec2/security_groups.rb,
lib/fog/aws/requests/ec2/attach_volume.rb,
lib/fog/aws/requests/ec2/create_volume.rb,
lib/fog/aws/requests/ec2/delete_volume.rb,
lib/fog/aws/requests/ec2/detach_volume.rb,
lib/fog/aws/requests/ec2/run_instances.rb,
lib/fog/aws/requests/s3/get_bucket_acl.rb,
lib/fog/aws/requests/s3/get_object_acl.rb,
lib/fog/aws/requests/s3/get_object_url.rb,
lib/fog/aws/requests/s3/put_bucket_acl.rb,
lib/fog/aws/requests/s3/put_object_url.rb,
lib/fog/aws/requests/ec2/create_key_pair.rb,
lib/fog/aws/requests/ec2/create_snapshot.rb,
lib/fog/aws/requests/ec2/delete_key_pair.rb,
lib/fog/aws/requests/ec2/delete_snapshot.rb,
lib/fog/aws/requests/ec2/describe_images.rb,
lib/fog/aws/requests/ec2/release_address.rb,
lib/fog/aws/requests/ec2/allocate_address.rb,
lib/fog/aws/requests/ec2/describe_regions.rb,
lib/fog/aws/requests/ec2/describe_volumes.rb,
lib/fog/aws/requests/ec2/reboot_instances.rb,
lib/fog/aws/requests/ec2/associate_address.rb,
lib/fog/aws/requests/s3/get_bucket_logging.rb,
lib/fog/aws/requests/s3/get_object_torrent.rb,
lib/fog/aws/requests/s3/put_bucket_logging.rb,
lib/fog/aws/requests/simpledb/list_domains.rb,
lib/fog/aws/requests/ec2/describe_addresses.rb,
lib/fog/aws/requests/ec2/describe_instances.rb,
lib/fog/aws/requests/ec2/describe_key_pairs.rb,
lib/fog/aws/requests/ec2/describe_snapshots.rb,
lib/fog/aws/requests/ec2/get_console_output.rb,
lib/fog/aws/requests/s3/get_bucket_location.rb,
lib/fog/aws/requests/s3/get_request_payment.rb,
lib/fog/aws/requests/s3/put_request_payment.rb,
lib/fog/aws/requests/simpledb/create_domain.rb,
lib/fog/aws/requests/simpledb/delete_domain.rb,
lib/fog/aws/requests/ec2/terminate_instances.rb,
lib/fog/aws/requests/simpledb/get_attributes.rb,
lib/fog/aws/requests/simpledb/put_attributes.rb,
lib/fog/aws/requests/ec2/disassociate_address.rb,
lib/fog/aws/requests/elb/create_load_balancer.rb,
lib/fog/aws/requests/elb/delete_load_balancer.rb,
lib/fog/aws/requests/s3/get_bucket_versioning.rb,
lib/fog/aws/requests/s3/put_bucket_versioning.rb,
lib/fog/aws/requests/simpledb/domain_metadata.rb,
lib/fog/aws/requests/ec2/create_security_group.rb,
lib/fog/aws/requests/ec2/delete_security_group.rb,
lib/fog/aws/requests/simpledb/delete_attributes.rb,
lib/fog/aws/requests/ec2/modify_image_attributes.rb,
lib/fog/aws/requests/elb/describe_load_balancers.rb,
lib/fog/aws/requests/ec2/describe_security_groups.rb,
lib/fog/aws/requests/elb/describe_instance_health.rb,
lib/fog/aws/requests/s3/get_bucket_object_versions.rb,
lib/fog/aws/requests/simpledb/batch_put_attributes.rb,
lib/fog/aws/requests/ec2/describe_availability_zones.rb,
lib/fog/aws/requests/ec2/describe_reserved_instances.rb,
lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb,
lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb,
lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb,
lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb,
lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb,
lib/fog/aws/requests/elb/disable_availability_zones_for_load_balancer.rb

Defined Under Namespace

Modules: EC2, ELB, S3, SimpleDB Classes: Mock

Class Method Summary collapse

Class Method Details

.indexed_param(key, values, offset = 0) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/aws.rb', line 9

def self.indexed_param(key, values, offset = 0)
  params = {}
  unless key.include?('%d')
    key << '.%d'
  end
  [*values].each_with_index do |value, index|
    params[format(key, index + offset)] = value
  end
  params
end

.signed_params(params, options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/aws.rb', line 20

def self.signed_params(params, options = {})
  params.merge!({
    'AWSAccessKeyId'    => options[:aws_access_key_id],
    'SignatureMethod'   => 'HmacSHA256',
    'SignatureVersion'  => '2',
    'Timestamp'         => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
    'Version'           => options[:version]
  })

  body = ''
  for key in params.keys.sort
    unless (value = params[key]).nil?
      body << "#{key}=#{CGI.escape(value.to_s).gsub(/\+/, '%20')}&"
    end
  end
  string_to_sign = "POST\n#{options[:host]}\n/\n" << body.chop
  signed_string = options[:hmac].sign(string_to_sign)
  body << "Signature=#{CGI.escape(Base64.encode64(signed_string).chomp!).gsub(/\+/, '%20')}"

  body
end