Module: Fog::AWS

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

Classes: Compute, EC2, ELB, Mock, S3, SimpleDB, Storage

Class Method Summary collapse

Methods included from Provider

service, service_path, services

Class Method Details

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



14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/aws.rb', line 14

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



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/aws.rb', line 25

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