mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
split out requests into their own files
This commit is contained in:
parent
079e3f49ba
commit
dbc9ebfb04
43 changed files with 1105 additions and 780 deletions
|
@ -23,7 +23,27 @@ require "#{parsers_directory}/describe_security_groups"
|
|||
require "#{parsers_directory}/describe_snapshots"
|
||||
require "#{parsers_directory}/describe_volumes"
|
||||
|
||||
requests_directory = "#{File.dirname(__FILE__)}/requests/ec2"
|
||||
requests_directory = "#{current_directory}/requests/ec2"
|
||||
require "#{requests_directory}/allocate_address"
|
||||
require "#{requests_directory}/create_key_pair"
|
||||
require "#{requests_directory}/create_security_group"
|
||||
require "#{requests_directory}/create_snapshot"
|
||||
require "#{requests_directory}/create_volume"
|
||||
require "#{requests_directory}/delete_key_pair"
|
||||
require "#{requests_directory}/delete_security_group"
|
||||
require "#{requests_directory}/delete_snapshot"
|
||||
require "#{requests_directory}/delete_volume"
|
||||
require "#{requests_directory}/describe_addresses"
|
||||
require "#{requests_directory}/describe_availability_zones"
|
||||
require "#{requests_directory}/describe_images"
|
||||
require "#{requests_directory}/describe_instances"
|
||||
require "#{requests_directory}/describe_key_pairs"
|
||||
require "#{requests_directory}/describe_security_groups"
|
||||
require "#{requests_directory}/describe_snapshots"
|
||||
require "#{requests_directory}/describe_volumes"
|
||||
require "#{requests_directory}/release_address"
|
||||
require "#{requests_directory}/run_instances"
|
||||
|
||||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
@ -55,386 +75,6 @@ module Fog
|
|||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
end
|
||||
|
||||
# Acquire an elastic IP address.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :public_ip<~String> - The acquired address
|
||||
def allocate_address
|
||||
request({
|
||||
'Action' => 'AllocateAddress'
|
||||
}, Fog::Parsers::AWS::EC2::AllocateAddress.new)
|
||||
end
|
||||
|
||||
# Create a new key pair
|
||||
#
|
||||
# ==== Parameters
|
||||
# * key_name<~String> - Unique name for key pair.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :key_name<~String> - Name of key
|
||||
# * :key_fingerprint<~String> - SHA-1 digest of DER encoded private key
|
||||
# * :key_material<~String> - Unencrypted encoded PEM private key
|
||||
# * :request_id<~String> - Id of request
|
||||
def create_key_pair(key_name)
|
||||
request({
|
||||
'Action' => 'CreateKeyPair',
|
||||
'KeyName' => key_name
|
||||
}, Fog::Parsers::AWS::EC2::CreateKeyPair.new)
|
||||
end
|
||||
|
||||
# Create a new security group
|
||||
#
|
||||
# ==== Parameters
|
||||
# * group_name<~String> - Name of the security group.
|
||||
# * group_description<~String> - Description of group.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :return<~Boolean> - success?
|
||||
def create_security_group(name, description)
|
||||
request({
|
||||
'Action' => 'CreateSecurityGroup',
|
||||
'GroupName' => name,
|
||||
'GroupDescription' => CGI.escape(description)
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
# Create a snapshot of an EBS volume and store it in S3
|
||||
#
|
||||
# ==== Parameters
|
||||
# * volume_id<~String> - Id of EBS volume to snapshot
|
||||
#
|
||||
# ==== Returns
|
||||
# FIXME: docs
|
||||
def create_snapshot(volume_id)
|
||||
request({
|
||||
'Action' => 'CreateSnapshot',
|
||||
'VolumeId' => 'VolumeId'
|
||||
}, Fog::Parsers::AWS::EC2::CreateSnapshot.new)
|
||||
end
|
||||
|
||||
# Create an EBS volume
|
||||
#
|
||||
# ==== Parameters
|
||||
# * availability_zone<~String> - availability zone to create volume in
|
||||
# * size<~Integer> - Size in GiBs for volume. Must be between 1 and 1024.
|
||||
# * snapshot_id<~String> - Optional, snapshot to create volume from
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :volume_id<~String> - Reference to volume
|
||||
# * :size<~Integer> - Size in GiBs for volume
|
||||
# * :status<~String> - State of volume
|
||||
# * :create_time<~Time> - Timestamp for creation
|
||||
# * :availability_zone<~String> - Availability zone for volume
|
||||
# * :snapshot_id<~String> - Snapshot volume was created from, if any
|
||||
def create_volume(availability_zone, size, snapshot_id = nil)
|
||||
request({
|
||||
'Action' => 'CreateVolume',
|
||||
'AvailabilityZone' => availability_zone,
|
||||
'Size' => size,
|
||||
'SnapshotId' => snapshot_id
|
||||
}, Fog::Parsers::AWS::EC2::CreateVolume.new)
|
||||
end
|
||||
|
||||
# Delete a key pair that you own
|
||||
#
|
||||
# ==== Parameters
|
||||
# * key_name<~String> - Name of the key pair.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :return<~Boolean> - success?
|
||||
def delete_key_pair(key_name)
|
||||
request({
|
||||
'Action' => 'DeleteKeyPair',
|
||||
'KeyName' => key_name
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
# Delete a security group that you own
|
||||
#
|
||||
# ==== Parameters
|
||||
# * group_name<~String> - Name of the security group.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :return<~Boolean> - success?
|
||||
def delete_security_group(name)
|
||||
request({
|
||||
'Action' => 'DeleteSecurityGroup',
|
||||
'GroupName' => name
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
# Delete a snapshot of an EBS volume that you own
|
||||
#
|
||||
# ==== Parameters
|
||||
# * snapshot_id<~String> - ID of snapshot to delete
|
||||
# ==== Returns
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :return<~Boolean> - success?
|
||||
def delete_snapshot(snapshot_id)
|
||||
request({
|
||||
'Action' => 'DeleteSnapshot',
|
||||
'SnapshotId' => snapshot_id
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
# Delete an EBS volume
|
||||
#
|
||||
# ==== Parameters
|
||||
# * volume_id<~String> - Id of volume to delete.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :return<~Boolean> - success?
|
||||
def delete_volume(volume_id)
|
||||
request({
|
||||
'Action' => 'DeleteVolume',
|
||||
'VolumeId' => volume_id
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
# Describe all or specified IP addresses.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * public_ip<~Array> - List of ips to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :address_set<~Array>:
|
||||
# * :instance_id<~String> - instance for ip address
|
||||
# * :public_ip<~String> - ip address for instance
|
||||
def describe_addresses(public_ip = [])
|
||||
params = indexed_params('PublicIp', public_ip)
|
||||
request({
|
||||
'Action' => 'DescribeAddresses'
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeAddresses.new)
|
||||
end
|
||||
|
||||
# Describe all or specified availability zones
|
||||
#
|
||||
# ==== Params
|
||||
# * zone_name<~String> - List of availability zones to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# FIXME: docs
|
||||
def describe_availability_zones(zone_name = [])
|
||||
params = indexed_params('ZoneName', zone_name)
|
||||
request({
|
||||
'Action' => 'DescribeAvailabilityZones'
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeAvailabilityZones.new)
|
||||
end
|
||||
|
||||
# Describe all or specified images.
|
||||
#
|
||||
# ==== Params
|
||||
# * options<~Hash> - Optional params
|
||||
# * :executable_by<~String> - Only return images that the executable_by
|
||||
# user has explicit permission to launch
|
||||
# * :image_id<~Array> - Ids of images to describe
|
||||
# * :owner<~String> - Only return images belonging to owner.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :image_set<~Array>:
|
||||
# * :architecture<~String> - Architecture of the image
|
||||
# * :image_id<~String> - Id of the image
|
||||
# * :image_location<~String> - Location of the image
|
||||
# * :image_owner_id<~String> - Id of the owner of the image
|
||||
# * :image_state<~String> - State of the image
|
||||
# * :image_type<~String> - Type of the image
|
||||
# * :is_public<~Boolean> - Whether or not the image is public
|
||||
def describe_images(options = {})
|
||||
params = {}
|
||||
if options[:image_id]
|
||||
params = indexed_params('ImageId', options[:image_id])
|
||||
end
|
||||
request({
|
||||
'Action' => 'DescribeImages',
|
||||
'ExecutableBy' => options[:executable_by],
|
||||
'Owner' => options[:owner]
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeImages.new)
|
||||
end
|
||||
|
||||
# Describe all or specified instances
|
||||
#
|
||||
# ==== Parameters
|
||||
# * instance_id<~Array> - List of instance ids to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
def describe_instances(instance_id = [])
|
||||
params = indexed_params('InstanceId', instance_id)
|
||||
request({
|
||||
'Action' => 'DescribeInstances',
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeInstances.new)
|
||||
end
|
||||
|
||||
# Describe all or specified key pairs
|
||||
#
|
||||
# ==== Parameters
|
||||
# * key_name<~Array>:: List of key names to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :key_set<~Array>:
|
||||
# * :key_name<~String> - Name of key
|
||||
# * :key_fingerprint<~String> - Fingerprint of key
|
||||
def describe_key_pairs(key_name = [])
|
||||
params = indexed_params('KeyName', key_name)
|
||||
request({
|
||||
'Action' => 'DescribeKeyPairs',
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeKeyPairs.new)
|
||||
end
|
||||
|
||||
# Describe all or specified security groups
|
||||
#
|
||||
# ==== Parameters
|
||||
# * group_name<~Array> - List of groups to describe, defaults to all
|
||||
#
|
||||
# === Returns
|
||||
# FIXME: docs
|
||||
def describe_security_groups(group_name = [])
|
||||
params = indexed_params('GroupName', group_name)
|
||||
request({
|
||||
'Action' => 'DescribeSecurityGroups',
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeSecurityGroups.new)
|
||||
end
|
||||
|
||||
# Describe all or specified snapshots
|
||||
#
|
||||
# ==== Parameters
|
||||
# * snapshot_id<~Array> - List of snapshots to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# FIXME: docs
|
||||
def describe_snapshots(snapshot_id = [])
|
||||
params = indexed_params('SnapshotId', snapshot_id)
|
||||
request({
|
||||
'Action' => 'DescribeSnapshots'
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeSnapshots.new)
|
||||
end
|
||||
|
||||
# Describe all or specified volumes.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * volume_ids<~Array> - List of volumes to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :volume_set<~Array>:
|
||||
# * :volume_id<~String> - Reference to volume
|
||||
# * :size<~Integer> - Size in GiBs for volume
|
||||
# * :status<~String> - State of volume
|
||||
# * :create_time<~Time> - Timestamp for creation
|
||||
# * :availability_zone<~String> - Availability zone for volume
|
||||
# * :snapshot_id<~String> - Snapshot volume was created from, if any
|
||||
# * :attachment_set<~Array>:
|
||||
# * :attachment_time<~Time> - Timestamp for attachment
|
||||
# * :device<~String> - How value is exposed to instance
|
||||
# * :instance_id<~String> - Reference to attached instance
|
||||
# * :status<~String> - Attachment state
|
||||
# * :volume_id<~String> - Reference to volume
|
||||
def describe_volumes(volume_ids = [])
|
||||
params = indexed_params('VolumeId', volume_ids)
|
||||
request({
|
||||
'Action' => 'DescribeVolumes'
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeVolumes.new)
|
||||
end
|
||||
|
||||
# Release an elastic IP address.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :return<~Boolean> - success?
|
||||
def release_address(public_ip)
|
||||
request({
|
||||
'Action' => 'ReleaseAddress',
|
||||
'PublicIp' => public_ip
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
# Launch specified instances
|
||||
#
|
||||
# ==== Parameters
|
||||
# * image_id<~String> - Id of machine image to load on instances
|
||||
# * min_count<~Integer> - Minimum number of instances to launch. If this
|
||||
# exceeds the count of available instances, no instances will be
|
||||
# launched. Must be between 1 and maximum allowed for your account
|
||||
# (by default the maximum for an account is 20)
|
||||
# * max_count<~Integer> - Maximum number of instances to launch. If this
|
||||
# exceeds the number of available instances, the largest possible
|
||||
# number of instances above min_count will be launched instead. Must
|
||||
# be between 1 and maximum allowed for you account
|
||||
# (by default the maximum for an account is 20)
|
||||
# * options<~Hash>:
|
||||
# * :availability_zone<~String> - Placement constraint for instances
|
||||
# * :data<~String> - Additional data to provide to booting instances
|
||||
# * :device_name<~String> - ?
|
||||
# * :encoding<~String> - ?
|
||||
# * :group_id<~String> - Name of security group for instances
|
||||
# * :instance_type<~String> - Type of instance to boot. Valid options
|
||||
# in ['m1.small', 'm1.large', 'm1.xlarge', 'c1.medium', 'c1.xlarge']
|
||||
# default is 'm1.small'
|
||||
# * :kernel_id<~String> - Id of kernel with which to launch
|
||||
# * :key_name<~String> - Name of a keypair to add to booting instances
|
||||
# * :monitoring_enabled<~Boolean> - Enables monitoring, defaults to
|
||||
# disabled
|
||||
# * :ramdisk_id<~String> - Id of ramdisk with which to launch
|
||||
# * :version<~String> - ?
|
||||
# * :virtual_name<~String> - ?
|
||||
#
|
||||
# ==== Returns
|
||||
def run_instances(image_id, min_count, max_count, options = {})
|
||||
request({
|
||||
'Action' => 'RunInstances',
|
||||
'ImageId' => image_id,
|
||||
'MinCount' => min_count,
|
||||
'MaxCount' => max_count,
|
||||
'AvailabilityZone' => options[:availability_zone],
|
||||
'Data' => options[:data],
|
||||
'DeviceName' => options[:device_name],
|
||||
'Encoding' => options[:encoding],
|
||||
'GroupId' => options[:group_id],
|
||||
'InstanceType' => options[:instance_type],
|
||||
'KernelId' => options[:kernel_id],
|
||||
'KeyName' => options[:key_name],
|
||||
'Monitoring.Enabled' => options[:monitoring_enabled].nil? ? nil : "#{options[:monitoring_enabled]}",
|
||||
'RamdiskId' => options[:ramdisk_id],
|
||||
'Version' => options[:version],
|
||||
'VirtualName' => options[:virtual_name]
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def indexed_params(name, params)
|
||||
|
|
19
lib/fog/aws/requests/ec2/allocate_address.rb
Normal file
19
lib/fog/aws/requests/ec2/allocate_address.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Acquire an elastic IP address.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :public_ip<~String> - The acquired address
|
||||
def allocate_address
|
||||
request({
|
||||
'Action' => 'AllocateAddress'
|
||||
}, Fog::Parsers::AWS::EC2::AllocateAddress.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/aws/requests/ec2/create_key_pair.rb
Normal file
26
lib/fog/aws/requests/ec2/create_key_pair.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Create a new key pair
|
||||
#
|
||||
# ==== Parameters
|
||||
# * key_name<~String> - Unique name for key pair.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :key_name<~String> - Name of key
|
||||
# * :key_fingerprint<~String> - SHA-1 digest of DER encoded private key
|
||||
# * :key_material<~String> - Unencrypted encoded PEM private key
|
||||
# * :request_id<~String> - Id of request
|
||||
def create_key_pair(key_name)
|
||||
request({
|
||||
'Action' => 'CreateKeyPair',
|
||||
'KeyName' => key_name
|
||||
}, Fog::Parsers::AWS::EC2::CreateKeyPair.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
25
lib/fog/aws/requests/ec2/create_security_group.rb
Normal file
25
lib/fog/aws/requests/ec2/create_security_group.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Create a new security group
|
||||
#
|
||||
# ==== Parameters
|
||||
# * group_name<~String> - Name of the security group.
|
||||
# * group_description<~String> - Description of group.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :return<~Boolean> - success?
|
||||
def create_security_group(name, description)
|
||||
request({
|
||||
'Action' => 'CreateSecurityGroup',
|
||||
'GroupName' => name,
|
||||
'GroupDescription' => CGI.escape(description)
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
21
lib/fog/aws/requests/ec2/create_snapshot.rb
Normal file
21
lib/fog/aws/requests/ec2/create_snapshot.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Create a snapshot of an EBS volume and store it in S3
|
||||
#
|
||||
# ==== Parameters
|
||||
# * volume_id<~String> - Id of EBS volume to snapshot
|
||||
#
|
||||
# ==== Returns
|
||||
# FIXME: docs
|
||||
def create_snapshot(volume_id)
|
||||
request({
|
||||
'Action' => 'CreateSnapshot',
|
||||
'VolumeId' => 'VolumeId'
|
||||
}, Fog::Parsers::AWS::EC2::CreateSnapshot.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
32
lib/fog/aws/requests/ec2/create_volume.rb
Normal file
32
lib/fog/aws/requests/ec2/create_volume.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Create an EBS volume
|
||||
#
|
||||
# ==== Parameters
|
||||
# * availability_zone<~String> - availability zone to create volume in
|
||||
# * size<~Integer> - Size in GiBs for volume. Must be between 1 and 1024.
|
||||
# * snapshot_id<~String> - Optional, snapshot to create volume from
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :volume_id<~String> - Reference to volume
|
||||
# * :size<~Integer> - Size in GiBs for volume
|
||||
# * :status<~String> - State of volume
|
||||
# * :create_time<~Time> - Timestamp for creation
|
||||
# * :availability_zone<~String> - Availability zone for volume
|
||||
# * :snapshot_id<~String> - Snapshot volume was created from, if any
|
||||
def create_volume(availability_zone, size, snapshot_id = nil)
|
||||
request({
|
||||
'Action' => 'CreateVolume',
|
||||
'AvailabilityZone' => availability_zone,
|
||||
'Size' => size,
|
||||
'SnapshotId' => snapshot_id
|
||||
}, Fog::Parsers::AWS::EC2::CreateVolume.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
23
lib/fog/aws/requests/ec2/delete_key_pair.rb
Normal file
23
lib/fog/aws/requests/ec2/delete_key_pair.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Delete a key pair that you own
|
||||
#
|
||||
# ==== Parameters
|
||||
# * key_name<~String> - Name of the key pair.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :return<~Boolean> - success?
|
||||
def delete_key_pair(key_name)
|
||||
request({
|
||||
'Action' => 'DeleteKeyPair',
|
||||
'KeyName' => key_name
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/requests/ec2/delete_security_group.rb
Normal file
24
lib/fog/aws/requests/ec2/delete_security_group.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Delete a security group that you own
|
||||
#
|
||||
# ==== Parameters
|
||||
# * group_name<~String> - Name of the security group.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :return<~Boolean> - success?
|
||||
def delete_security_group(name)
|
||||
request({
|
||||
'Action' => 'DeleteSecurityGroup',
|
||||
'GroupName' => name
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/requests/ec2/delete_snapshot.rb
Normal file
24
lib/fog/aws/requests/ec2/delete_snapshot.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Delete a snapshot of an EBS volume that you own
|
||||
#
|
||||
# ==== Parameters
|
||||
# * snapshot_id<~String> - ID of snapshot to delete
|
||||
# ==== Returns
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :return<~Boolean> - success?
|
||||
def delete_snapshot(snapshot_id)
|
||||
request({
|
||||
'Action' => 'DeleteSnapshot',
|
||||
'SnapshotId' => snapshot_id
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/requests/ec2/delete_volume.rb
Normal file
24
lib/fog/aws/requests/ec2/delete_volume.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Delete an EBS volume
|
||||
#
|
||||
# ==== Parameters
|
||||
# * volume_id<~String> - Id of volume to delete.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :return<~Boolean> - success?
|
||||
def delete_volume(volume_id)
|
||||
request({
|
||||
'Action' => 'DeleteVolume',
|
||||
'VolumeId' => volume_id
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/aws/requests/ec2/describe_addresses.rb
Normal file
26
lib/fog/aws/requests/ec2/describe_addresses.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Describe all or specified IP addresses.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * public_ip<~Array> - List of ips to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :address_set<~Array>:
|
||||
# * :instance_id<~String> - instance for ip address
|
||||
# * :public_ip<~String> - ip address for instance
|
||||
def describe_addresses(public_ip = [])
|
||||
params = indexed_params('PublicIp', public_ip)
|
||||
request({
|
||||
'Action' => 'DescribeAddresses'
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeAddresses.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/requests/ec2/describe_availability_zones.rb
Normal file
24
lib/fog/aws/requests/ec2/describe_availability_zones.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Describe all or specified availability zones
|
||||
#
|
||||
# ==== Params
|
||||
# * zone_name<~String> - List of availability zones to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# FIXME: docs
|
||||
def describe_availability_zones(zone_name = [])
|
||||
params = indexed_params('ZoneName', zone_name)
|
||||
request({
|
||||
'Action' => 'DescribeAvailabilityZones'
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeAvailabilityZones.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
40
lib/fog/aws/requests/ec2/describe_images.rb
Normal file
40
lib/fog/aws/requests/ec2/describe_images.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Describe all or specified images.
|
||||
#
|
||||
# ==== Params
|
||||
# * options<~Hash> - Optional params
|
||||
# * :executable_by<~String> - Only return images that the executable_by
|
||||
# user has explicit permission to launch
|
||||
# * :image_id<~Array> - Ids of images to describe
|
||||
# * :owner<~String> - Only return images belonging to owner.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :image_set<~Array>:
|
||||
# * :architecture<~String> - Architecture of the image
|
||||
# * :image_id<~String> - Id of the image
|
||||
# * :image_location<~String> - Location of the image
|
||||
# * :image_owner_id<~String> - Id of the owner of the image
|
||||
# * :image_state<~String> - State of the image
|
||||
# * :image_type<~String> - Type of the image
|
||||
# * :is_public<~Boolean> - Whether or not the image is public
|
||||
def describe_images(options = {})
|
||||
params = {}
|
||||
if options[:image_id]
|
||||
params = indexed_params('ImageId', options[:image_id])
|
||||
end
|
||||
request({
|
||||
'Action' => 'DescribeImages',
|
||||
'ExecutableBy' => options[:executable_by],
|
||||
'Owner' => options[:owner]
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeImages.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
23
lib/fog/aws/requests/ec2/describe_instances.rb
Normal file
23
lib/fog/aws/requests/ec2/describe_instances.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Describe all or specified instances
|
||||
#
|
||||
# ==== Parameters
|
||||
# * instance_id<~Array> - List of instance ids to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
def describe_instances(instance_id = [])
|
||||
params = indexed_params('InstanceId', instance_id)
|
||||
request({
|
||||
'Action' => 'DescribeInstances',
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeInstances.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/aws/requests/ec2/describe_key_pairs.rb
Normal file
26
lib/fog/aws/requests/ec2/describe_key_pairs.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Describe all or specified key pairs
|
||||
#
|
||||
# ==== Parameters
|
||||
# * key_name<~Array>:: List of key names to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :key_set<~Array>:
|
||||
# * :key_name<~String> - Name of key
|
||||
# * :key_fingerprint<~String> - Fingerprint of key
|
||||
def describe_key_pairs(key_name = [])
|
||||
params = indexed_params('KeyName', key_name)
|
||||
request({
|
||||
'Action' => 'DescribeKeyPairs',
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeKeyPairs.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
21
lib/fog/aws/requests/ec2/describe_security_groups.rb
Normal file
21
lib/fog/aws/requests/ec2/describe_security_groups.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Describe all or specified security groups
|
||||
#
|
||||
# ==== Parameters
|
||||
# * group_name<~Array> - List of groups to describe, defaults to all
|
||||
#
|
||||
# === Returns
|
||||
# FIXME: docs
|
||||
def describe_security_groups(group_name = [])
|
||||
params = indexed_params('GroupName', group_name)
|
||||
request({
|
||||
'Action' => 'DescribeSecurityGroups',
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeSecurityGroups.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
21
lib/fog/aws/requests/ec2/describe_snapshots.rb
Normal file
21
lib/fog/aws/requests/ec2/describe_snapshots.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Describe all or specified snapshots
|
||||
#
|
||||
# ==== Parameters
|
||||
# * snapshot_id<~Array> - List of snapshots to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# FIXME: docs
|
||||
def describe_snapshots(snapshot_id = [])
|
||||
params = indexed_params('SnapshotId', snapshot_id)
|
||||
request({
|
||||
'Action' => 'DescribeSnapshots'
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeSnapshots.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
35
lib/fog/aws/requests/ec2/describe_volumes.rb
Normal file
35
lib/fog/aws/requests/ec2/describe_volumes.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Describe all or specified volumes.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * volume_ids<~Array> - List of volumes to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :volume_set<~Array>:
|
||||
# * :volume_id<~String> - Reference to volume
|
||||
# * :size<~Integer> - Size in GiBs for volume
|
||||
# * :status<~String> - State of volume
|
||||
# * :create_time<~Time> - Timestamp for creation
|
||||
# * :availability_zone<~String> - Availability zone for volume
|
||||
# * :snapshot_id<~String> - Snapshot volume was created from, if any
|
||||
# * :attachment_set<~Array>:
|
||||
# * :attachment_time<~Time> - Timestamp for attachment
|
||||
# * :device<~String> - How value is exposed to instance
|
||||
# * :instance_id<~String> - Reference to attached instance
|
||||
# * :status<~String> - Attachment state
|
||||
# * :volume_id<~String> - Reference to volume
|
||||
def describe_volumes(volume_ids = [])
|
||||
params = indexed_params('VolumeId', volume_ids)
|
||||
request({
|
||||
'Action' => 'DescribeVolumes'
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeVolumes.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
20
lib/fog/aws/requests/ec2/release_address.rb
Normal file
20
lib/fog/aws/requests/ec2/release_address.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Release an elastic IP address.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :return<~Boolean> - success?
|
||||
def release_address(public_ip)
|
||||
request({
|
||||
'Action' => 'ReleaseAddress',
|
||||
'PublicIp' => public_ip
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
59
lib/fog/aws/requests/ec2/run_instances.rb
Normal file
59
lib/fog/aws/requests/ec2/run_instances.rb
Normal file
|
@ -0,0 +1,59 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class EC2
|
||||
|
||||
# Launch specified instances
|
||||
#
|
||||
# ==== Parameters
|
||||
# * image_id<~String> - Id of machine image to load on instances
|
||||
# * min_count<~Integer> - Minimum number of instances to launch. If this
|
||||
# exceeds the count of available instances, no instances will be
|
||||
# launched. Must be between 1 and maximum allowed for your account
|
||||
# (by default the maximum for an account is 20)
|
||||
# * max_count<~Integer> - Maximum number of instances to launch. If this
|
||||
# exceeds the number of available instances, the largest possible
|
||||
# number of instances above min_count will be launched instead. Must
|
||||
# be between 1 and maximum allowed for you account
|
||||
# (by default the maximum for an account is 20)
|
||||
# * options<~Hash>:
|
||||
# * :availability_zone<~String> - Placement constraint for instances
|
||||
# * :data<~String> - Additional data to provide to booting instances
|
||||
# * :device_name<~String> - ?
|
||||
# * :encoding<~String> - ?
|
||||
# * :group_id<~String> - Name of security group for instances
|
||||
# * :instance_type<~String> - Type of instance to boot. Valid options
|
||||
# in ['m1.small', 'm1.large', 'm1.xlarge', 'c1.medium', 'c1.xlarge']
|
||||
# default is 'm1.small'
|
||||
# * :kernel_id<~String> - Id of kernel with which to launch
|
||||
# * :key_name<~String> - Name of a keypair to add to booting instances
|
||||
# * :monitoring_enabled<~Boolean> - Enables monitoring, defaults to
|
||||
# disabled
|
||||
# * :ramdisk_id<~String> - Id of ramdisk with which to launch
|
||||
# * :version<~String> - ?
|
||||
# * :virtual_name<~String> - ?
|
||||
#
|
||||
# ==== Returns
|
||||
def run_instances(image_id, min_count, max_count, options = {})
|
||||
request({
|
||||
'Action' => 'RunInstances',
|
||||
'ImageId' => image_id,
|
||||
'MinCount' => min_count,
|
||||
'MaxCount' => max_count,
|
||||
'AvailabilityZone' => options[:availability_zone],
|
||||
'Data' => options[:data],
|
||||
'DeviceName' => options[:device_name],
|
||||
'Encoding' => options[:encoding],
|
||||
'GroupId' => options[:group_id],
|
||||
'InstanceType' => options[:instance_type],
|
||||
'KernelId' => options[:kernel_id],
|
||||
'KeyName' => options[:key_name],
|
||||
'Monitoring.Enabled' => options[:monitoring_enabled].nil? ? nil : "#{options[:monitoring_enabled]}",
|
||||
'RamdiskId' => options[:ramdisk_id],
|
||||
'Version' => options[:version],
|
||||
'VirtualName' => options[:virtual_name]
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
19
lib/fog/aws/requests/s3/copy_object.rb
Normal file
19
lib/fog/aws/requests/s3/copy_object.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
||||
# Copy an object from one S3 bucket to another
|
||||
# FIXME: docs
|
||||
def copy_object(source_bucket_name, source_object_name, destination_bucket_name, destination_object_name)
|
||||
request({
|
||||
:headers => { 'x-amz-copy-source' => "/#{source_bucket_name}/#{source_object_name}" },
|
||||
:host => "#{destination_bucket_name}.#{@host}",
|
||||
:method => 'PUT',
|
||||
:parser => Fog::Parsers::AWS::S3::CopyObject.new,
|
||||
:path => destination_object_name
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
22
lib/fog/aws/requests/s3/delete_bucket.rb
Normal file
22
lib/fog/aws/requests/s3/delete_bucket.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
||||
# Delete an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to delete
|
||||
#
|
||||
# ==== Returns
|
||||
# FIXME: docs
|
||||
def delete_bucket(bucket_name)
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'DELETE'
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
18
lib/fog/aws/requests/s3/delete_object.rb
Normal file
18
lib/fog/aws/requests/s3/delete_object.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
||||
# Delete an object from S3
|
||||
# FIXME: docs
|
||||
def delete_object(bucket_name, object_name)
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'DELETE',
|
||||
:path => object_name
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
34
lib/fog/aws/requests/s3/get_bucket.rb
Normal file
34
lib/fog/aws/requests/s3/get_bucket.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
||||
# List information about objects in an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to list object keys from
|
||||
# * options<~Hash> - config arguments for list. Defaults to {}.
|
||||
# * :prefix - limits object keys to those beginning with its value.
|
||||
# * :marker - limits object keys to only those that appear
|
||||
# lexicographically after its value.
|
||||
# * maxkeys - limits number of object keys returned
|
||||
# * :delimiter - causes keys with the same string between the prefix
|
||||
# value and the first occurence of delimiter to be rolled up
|
||||
def get_bucket(bucket_name, options = {})
|
||||
options['max-keys'] = options.delete(:maxkeys) if options[:maxkeys]
|
||||
query = '?'
|
||||
for key, value in options
|
||||
query << "#{key}=#{value};"
|
||||
end
|
||||
query.chop!
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::AWS::S3::GetBucket.new,
|
||||
:query => query
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/requests/s3/get_bucket_location.rb
Normal file
24
lib/fog/aws/requests/s3/get_bucket_location.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
||||
# Get location constraint for an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to get location constraint for
|
||||
#
|
||||
# ==== Returns
|
||||
# FIXME: docs
|
||||
def get_bucket_location(bucket_name)
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::AWS::S3::GetBucketLocation.new,
|
||||
:query => 'location'
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
18
lib/fog/aws/requests/s3/get_object.rb
Normal file
18
lib/fog/aws/requests/s3/get_object.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
||||
# Get an object from S3
|
||||
# FIXME: docs
|
||||
def get_object(bucket_name, object_name)
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'GET',
|
||||
:path => object_name
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/requests/s3/get_request_payment.rb
Normal file
24
lib/fog/aws/requests/s3/get_request_payment.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
||||
# Get configured payer for an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to get payer for
|
||||
#
|
||||
# ==== Returns
|
||||
# FIXME: docs
|
||||
def get_request_payment(bucket_name)
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::AWS::S3::GetRequestPayment.new,
|
||||
:query => 'requestPayment'
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
21
lib/fog/aws/requests/s3/get_service.rb
Normal file
21
lib/fog/aws/requests/s3/get_service.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
||||
# List information about S3 buckets for authorized user
|
||||
#
|
||||
# ==== Parameters
|
||||
# FIXME: docs
|
||||
def get_service
|
||||
request({
|
||||
:headers => {},
|
||||
:host => @host,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::AWS::S3::GetService.new,
|
||||
:url => @host
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
18
lib/fog/aws/requests/s3/head_object.rb
Normal file
18
lib/fog/aws/requests/s3/head_object.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
||||
# Get headers for an object from S3
|
||||
# FIXME: docs
|
||||
def head_object(bucket_name, object_name)
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'HEAD',
|
||||
:path => object_name
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
32
lib/fog/aws/requests/s3/put_bucket.rb
Normal file
32
lib/fog/aws/requests/s3/put_bucket.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
||||
# Create an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to create
|
||||
# * options<~Hash> - config arguments for bucket. Defaults to {}.
|
||||
# * :location_constraint<~Symbol> - sets the location for the bucket
|
||||
def put_bucket(bucket_name, options = {})
|
||||
if options[:location_constraint]
|
||||
data =
|
||||
<<-DATA
|
||||
<CreateBucketConfiguration>
|
||||
<LocationConstraint>#{options[:location_constraint]}</LocationConstraint>
|
||||
</CreateBucketConfiguration>
|
||||
DATA
|
||||
else
|
||||
data = nil
|
||||
end
|
||||
request({
|
||||
:body => data,
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'PUT'
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
20
lib/fog/aws/requests/s3/put_object.rb
Normal file
20
lib/fog/aws/requests/s3/put_object.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
||||
# Create an object in an S3 bucket
|
||||
# FIXME: docs
|
||||
def put_object(bucket_name, object_name, object, options = {})
|
||||
file = parse_file(object)
|
||||
request({
|
||||
:body => file[:body],
|
||||
:headers => options.merge!(file[:headers]),
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'PUT',
|
||||
:path => object_name
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
28
lib/fog/aws/requests/s3/put_request_payment.rb
Normal file
28
lib/fog/aws/requests/s3/put_request_payment.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
||||
# Change who pays for requests to an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to modify
|
||||
# * payer<~String> - valid values are BucketOwner or Requester
|
||||
def put_request_payment(bucket_name, payer)
|
||||
data =
|
||||
<<-DATA
|
||||
<RequestPaymentConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
||||
<Payer>#{payer}</Payer>
|
||||
</RequestPaymentConfiguration>
|
||||
DATA
|
||||
request({
|
||||
:body => data,
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'PUT',
|
||||
:query => "requestPayment"
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
31
lib/fog/aws/requests/simpledb/batch_put_attributes.rb
Normal file
31
lib/fog/aws/requests/simpledb/batch_put_attributes.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SimpleDB
|
||||
|
||||
# Put items attributes into a SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
# * items<~Hash> - Keys are the items names and may use any UTF-8
|
||||
# characters valid in xml. Control characters and sequences not allowed
|
||||
# in xml are not valid. Can be up to 1024 bytes long. Values are the
|
||||
# attributes to add to the given item and may use any UTF-8 characters
|
||||
# valid in xml. Control characters and sequences not allowed in xml are
|
||||
# not valid. Each name and value can be up to 1024 bytes long.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
def batch_put_attributes(domain_name, items, replace_attributes = Hash.new([]))
|
||||
request({
|
||||
'Action' => 'BatchPutAttributes',
|
||||
'DomainName' => domain_name
|
||||
}.merge!(encode_batch_attributes(items, replace_attributes)), Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
25
lib/fog/aws/requests/simpledb/create_domain.rb
Normal file
25
lib/fog/aws/requests/simpledb/create_domain.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SimpleDB
|
||||
|
||||
# Create a SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String>:: Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
def create_domain(domain_name)
|
||||
request({
|
||||
'Action' => 'CreateDomain',
|
||||
'DomainName' => domain_name
|
||||
}, Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
34
lib/fog/aws/requests/simpledb/delete_attributes.rb
Normal file
34
lib/fog/aws/requests/simpledb/delete_attributes.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SimpleDB
|
||||
|
||||
# List metadata for SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
# * item_name<~String> - Name of the item. May use any UTF-8 characters valid
|
||||
# in xml. Control characters and sequences not allowed in xml are not
|
||||
# valid. Can be up to 1024 bytes long.
|
||||
# * attributes<~Hash> - Name/value pairs to remove from the item. Defaults to
|
||||
# nil, which will delete the entire item. Attribute names and values may
|
||||
# use any UTF-8 characters valid in xml. Control characters and sequences
|
||||
# not allowed in xml are not valid. Each name and value can be up to 1024
|
||||
# bytes long.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
def delete_attributes(domain_name, item_name, attributes = nil)
|
||||
request({
|
||||
'Action' => 'DeleteAttributes',
|
||||
'DomainName' => domain_name,
|
||||
'ItemName' => item_name
|
||||
}.merge!(encode_attributes(attributes)), Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
25
lib/fog/aws/requests/simpledb/delete_domain.rb
Normal file
25
lib/fog/aws/requests/simpledb/delete_domain.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SimpleDB
|
||||
|
||||
# Delete a SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String>:: Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
def delete_domain(domain_name)
|
||||
request({
|
||||
'Action' => 'DeleteDomain',
|
||||
'DomainName' => domain_name
|
||||
}, Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
30
lib/fog/aws/requests/simpledb/domain_metadata.rb
Normal file
30
lib/fog/aws/requests/simpledb/domain_metadata.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SimpleDB
|
||||
|
||||
# List metadata for SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :attribute_name_count - number of unique attribute names in domain
|
||||
# * :attribute_names_size_bytes - total size of unique attribute names, in bytes
|
||||
# * :attribute_value_count - number of all name/value pairs in domain
|
||||
# * :attribute_values_size_bytes - total size of attributes, in bytes
|
||||
# * :item_count - number of items in domain
|
||||
# * :item_name_size_bytes - total size of item names in domain, in bytes
|
||||
# * :timestamp - last update time for metadata.
|
||||
def domain_metadata(domain_name)
|
||||
request({
|
||||
'Action' => 'DomainMetadata',
|
||||
'DomainName' => domain_name
|
||||
}, Fog::Parsers::AWS::SimpleDB::DomainMetadata.new(@nil_string))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
35
lib/fog/aws/requests/simpledb/get_attributes.rb
Normal file
35
lib/fog/aws/requests/simpledb/get_attributes.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SimpleDB
|
||||
|
||||
# List metadata for SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
# * item_name<~String> - Name of the item. May use any UTF-8 characters valid
|
||||
# in xml. Control characters and sequences not allowed in xml are not
|
||||
# valid. Can be up to 1024 bytes long.
|
||||
# * attributes<~Hash> - Name/value pairs to return from the item. Defaults to
|
||||
# nil, which will return all attributes. Attribute names and values may use
|
||||
# any UTF-8 characters valid in xml. Control characters and sequences not
|
||||
# allowed in xml are not valid. Each name and value can be up to 1024
|
||||
# bytes long.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
# * :attributes - list of attribute name/values for the item
|
||||
def get_attributes(domain_name, item_name, attributes = nil)
|
||||
request({
|
||||
'Action' => 'GetAttributes',
|
||||
'DomainName' => domain_name,
|
||||
'ItemName' => item_name,
|
||||
}.merge!(encode_attribute_names(attributes)), Fog::Parsers::AWS::SimpleDB::GetAttributes.new(@nil_string))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
30
lib/fog/aws/requests/simpledb/list_domains.rb
Normal file
30
lib/fog/aws/requests/simpledb/list_domains.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SimpleDB
|
||||
|
||||
# List SimpleDB domains
|
||||
#
|
||||
# ==== Parameters
|
||||
# * options<~Hash> - options, defaults to {}
|
||||
# *max_number_of_domains<~Integer> - number of domains to return
|
||||
# between 1 and 100, defaults to 100
|
||||
# *next_token<~String> - Offset token to start listing, defaults to nil
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
# * :domains - array of domain names.
|
||||
# * :next_token - offset to start with if there are are more domains to list
|
||||
def list_domains(options = {})
|
||||
request({
|
||||
'Action' => 'ListDomains',
|
||||
'MaxNumberOfDomains' => options[:max_number_of_domains],
|
||||
'NextToken' => options[:next_token]
|
||||
}, Fog::Parsers::AWS::SimpleDB::ListDomains.new(@nil_string))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
29
lib/fog/aws/requests/simpledb/put_attributes.rb
Normal file
29
lib/fog/aws/requests/simpledb/put_attributes.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SimpleDB
|
||||
|
||||
# Put item attributes into a SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
# * item_name<~String> - Name of the item. May use any UTF-8 characters valid
|
||||
# in xml. Control characters and sequences not allowed in xml are not
|
||||
# valid. Can be up to 1024 bytes long.
|
||||
# * attributes<~Hash> - Name/value pairs to add to the item. Attribute names
|
||||
# and values may use any UTF-8 characters valid in xml. Control characters
|
||||
# and sequences not allowed in xml are not valid. Each name and value can
|
||||
# be up to 1024 bytes long.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
def put_attributes(domain_name, item_name, attributes, replace_attributes = [])
|
||||
batch_put_attributes(domain_name, { item_name => attributes }, { item_name => replace_attributes })
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
29
lib/fog/aws/requests/simpledb/select.rb
Normal file
29
lib/fog/aws/requests/simpledb/select.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class SimpleDB
|
||||
|
||||
# Select item data from SimpleDB
|
||||
#
|
||||
# ==== Parameters
|
||||
# * select_expression<~String> - Expression to query domain with.
|
||||
# * next_token<~String> - Offset token to start list, defaults to nil.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
# * :items - list of attribute name/values for the items formatted as
|
||||
# { 'item_name' => { 'attribute_name' => ['attribute_value'] }}
|
||||
# * :next_token - offset to start with if there are are more domains to list
|
||||
def select(select_expression, next_token = nil)
|
||||
request({
|
||||
'Action' => 'Select',
|
||||
'NextToken' => next_token,
|
||||
'SelectExpression' => select_expression
|
||||
}, Fog::Parsers::AWS::SimpleDB::Select.new(@nil_string))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -17,6 +17,20 @@ require "#{parsers_directory}/get_bucket_location"
|
|||
require "#{parsers_directory}/get_request_payment"
|
||||
require "#{parsers_directory}/get_service"
|
||||
|
||||
requests_directory = "#{current_directory}/requests/s3"
|
||||
require "#{requests_directory}/copy_object"
|
||||
require "#{requests_directory}/delete_bucket"
|
||||
require "#{requests_directory}/delete_object"
|
||||
require "#{requests_directory}/get_bucket"
|
||||
require "#{requests_directory}/get_bucket_location"
|
||||
require "#{requests_directory}/get_object"
|
||||
require "#{requests_directory}/get_request_payment"
|
||||
require "#{requests_directory}/get_service"
|
||||
require "#{requests_directory}/head_object"
|
||||
require "#{requests_directory}/put_bucket"
|
||||
require "#{requests_directory}/put_object"
|
||||
require "#{requests_directory}/put_request_payment"
|
||||
|
||||
module Fog
|
||||
module AWS
|
||||
class S3
|
||||
|
@ -48,200 +62,6 @@ module Fog
|
|||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
end
|
||||
|
||||
# Copy an object from one S3 bucket to another
|
||||
# FIXME: docs
|
||||
def copy_object(source_bucket_name, source_object_name, destination_bucket_name, destination_object_name)
|
||||
request({
|
||||
:headers => { 'x-amz-copy-source' => "/#{source_bucket_name}/#{source_object_name}" },
|
||||
:host => "#{destination_bucket_name}.#{@host}",
|
||||
:method => 'PUT',
|
||||
:parser => Fog::Parsers::AWS::S3::CopyObject.new,
|
||||
:path => destination_object_name
|
||||
})
|
||||
end
|
||||
|
||||
# Delete an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to delete
|
||||
#
|
||||
# ==== Returns
|
||||
# FIXME: docs
|
||||
def delete_bucket(bucket_name)
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'DELETE'
|
||||
})
|
||||
end
|
||||
|
||||
# Delete an object from S3
|
||||
# FIXME: docs
|
||||
def delete_object(bucket_name, object_name)
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'DELETE',
|
||||
:path => object_name
|
||||
})
|
||||
end
|
||||
|
||||
# List information about objects in an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to list object keys from
|
||||
# * options<~Hash> - config arguments for list. Defaults to {}.
|
||||
# * :prefix - limits object keys to those beginning with its value.
|
||||
# * :marker - limits object keys to only those that appear
|
||||
# lexicographically after its value.
|
||||
# * maxkeys - limits number of object keys returned
|
||||
# * :delimiter - causes keys with the same string between the prefix
|
||||
# value and the first occurence of delimiter to be rolled up
|
||||
def get_bucket(bucket_name, options = {})
|
||||
options['max-keys'] = options.delete(:maxkeys) if options[:maxkeys]
|
||||
query = '?'
|
||||
for key, value in options
|
||||
query << "#{key}=#{value};"
|
||||
end
|
||||
query.chop!
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::AWS::S3::GetBucket.new,
|
||||
:query => query
|
||||
})
|
||||
end
|
||||
|
||||
# Get location constraint for an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to get location constraint for
|
||||
#
|
||||
# ==== Returns
|
||||
# FIXME: docs
|
||||
def get_bucket_location(bucket_name)
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::AWS::S3::GetBucketLocation.new,
|
||||
:query => 'location'
|
||||
})
|
||||
end
|
||||
|
||||
# Get an object from S3
|
||||
# FIXME: docs
|
||||
def get_object(bucket_name, object_name)
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'GET',
|
||||
:path => object_name
|
||||
})
|
||||
end
|
||||
|
||||
# Get configured payer for an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to get payer for
|
||||
#
|
||||
# ==== Returns
|
||||
# FIXME: docs
|
||||
def get_request_payment(bucket_name)
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::AWS::S3::GetRequestPayment.new,
|
||||
:query => 'requestPayment'
|
||||
})
|
||||
end
|
||||
|
||||
# List information about S3 buckets for authorized user
|
||||
#
|
||||
# ==== Parameters
|
||||
# FIXME: docs
|
||||
def get_service
|
||||
request({
|
||||
:headers => {},
|
||||
:host => @host,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::AWS::S3::GetService.new,
|
||||
:url => @host
|
||||
})
|
||||
end
|
||||
|
||||
# Get headers for an object from S3
|
||||
# FIXME: docs
|
||||
def head_object(bucket_name, object_name)
|
||||
request({
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'HEAD',
|
||||
:path => object_name
|
||||
})
|
||||
end
|
||||
|
||||
# Create an object in an S3 bucket
|
||||
# FIXME: docs
|
||||
def put_object(bucket_name, object_name, object, options = {})
|
||||
file = parse_file(object)
|
||||
request({
|
||||
:body => file[:body],
|
||||
:headers => options.merge!(file[:headers]),
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'PUT',
|
||||
:path => object_name
|
||||
})
|
||||
end
|
||||
|
||||
# Create an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to create
|
||||
# * options<~Hash> - config arguments for bucket. Defaults to {}.
|
||||
# * :location_constraint<~Symbol> - sets the location for the bucket
|
||||
def put_bucket(bucket_name, options = {})
|
||||
if options[:location_constraint]
|
||||
data =
|
||||
<<-DATA
|
||||
<CreateBucketConfiguration>
|
||||
<LocationConstraint>#{options[:location_constraint]}</LocationConstraint>
|
||||
</CreateBucketConfiguration>
|
||||
DATA
|
||||
else
|
||||
data = nil
|
||||
end
|
||||
request({
|
||||
:body => data,
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'PUT'
|
||||
})
|
||||
end
|
||||
|
||||
# Change who pays for requests to an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to modify
|
||||
# * payer<~String> - valid values are BucketOwner or Requester
|
||||
def put_request_payment(bucket_name, payer)
|
||||
data =
|
||||
<<-DATA
|
||||
<RequestPaymentConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
||||
<Payer>#{payer}</Payer>
|
||||
</RequestPaymentConfiguration>
|
||||
DATA
|
||||
request({
|
||||
:body => data,
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'PUT',
|
||||
:query => "requestPayment"
|
||||
})
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse_file(file)
|
||||
|
|
|
@ -15,6 +15,17 @@ require "#{parsers_directory}/get_attributes"
|
|||
require "#{parsers_directory}/list_domains"
|
||||
require "#{parsers_directory}/select"
|
||||
|
||||
requests_directory = "#{current_directory}/requests/simpledb"
|
||||
require "#{requests_directory}/batch_put_attributes"
|
||||
require "#{requests_directory}/create_domain"
|
||||
require "#{requests_directory}/delete_attributes"
|
||||
require "#{requests_directory}/delete_domain"
|
||||
require "#{requests_directory}/domain_metadata"
|
||||
require "#{requests_directory}/get_attributes"
|
||||
require "#{requests_directory}/list_domains"
|
||||
require "#{requests_directory}/put_attributes"
|
||||
require "#{requests_directory}/select"
|
||||
|
||||
module Fog
|
||||
module AWS
|
||||
class SimpleDB
|
||||
|
@ -47,211 +58,6 @@ module Fog
|
|||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
end
|
||||
|
||||
# Put items attributes into a SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
# * items<~Hash> - Keys are the items names and may use any UTF-8
|
||||
# characters valid in xml. Control characters and sequences not allowed
|
||||
# in xml are not valid. Can be up to 1024 bytes long. Values are the
|
||||
# attributes to add to the given item and may use any UTF-8 characters
|
||||
# valid in xml. Control characters and sequences not allowed in xml are
|
||||
# not valid. Each name and value can be up to 1024 bytes long.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
def batch_put_attributes(domain_name, items, replace_attributes = Hash.new([]))
|
||||
request({
|
||||
'Action' => 'BatchPutAttributes',
|
||||
'DomainName' => domain_name
|
||||
}.merge!(encode_batch_attributes(items, replace_attributes)), Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
|
||||
end
|
||||
|
||||
# Create a SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String>:: Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
def create_domain(domain_name)
|
||||
request({
|
||||
'Action' => 'CreateDomain',
|
||||
'DomainName' => domain_name
|
||||
}, Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
|
||||
end
|
||||
|
||||
# Delete a SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String>:: Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
def delete_domain(domain_name)
|
||||
request({
|
||||
'Action' => 'DeleteDomain',
|
||||
'DomainName' => domain_name
|
||||
}, Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
|
||||
end
|
||||
|
||||
# List metadata for SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :attribute_name_count - number of unique attribute names in domain
|
||||
# * :attribute_names_size_bytes - total size of unique attribute names, in bytes
|
||||
# * :attribute_value_count - number of all name/value pairs in domain
|
||||
# * :attribute_values_size_bytes - total size of attributes, in bytes
|
||||
# * :item_count - number of items in domain
|
||||
# * :item_name_size_bytes - total size of item names in domain, in bytes
|
||||
# * :timestamp - last update time for metadata.
|
||||
def domain_metadata(domain_name)
|
||||
request({
|
||||
'Action' => 'DomainMetadata',
|
||||
'DomainName' => domain_name
|
||||
}, Fog::Parsers::AWS::SimpleDB::DomainMetadata.new(@nil_string))
|
||||
end
|
||||
|
||||
# List SimpleDB domains
|
||||
#
|
||||
# ==== Parameters
|
||||
# * options<~Hash> - options, defaults to {}
|
||||
# *max_number_of_domains<~Integer> - number of domains to return
|
||||
# between 1 and 100, defaults to 100
|
||||
# *next_token<~String> - Offset token to start listing, defaults to nil
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
# * :domains - array of domain names.
|
||||
# * :next_token - offset to start with if there are are more domains to list
|
||||
def list_domains(options = {})
|
||||
request({
|
||||
'Action' => 'ListDomains',
|
||||
'MaxNumberOfDomains' => options[:max_number_of_domains],
|
||||
'NextToken' => options[:next_token]
|
||||
}, Fog::Parsers::AWS::SimpleDB::ListDomains.new(@nil_string))
|
||||
end
|
||||
|
||||
# Put item attributes into a SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
# * item_name<~String> - Name of the item. May use any UTF-8 characters valid
|
||||
# in xml. Control characters and sequences not allowed in xml are not
|
||||
# valid. Can be up to 1024 bytes long.
|
||||
# * attributes<~Hash> - Name/value pairs to add to the item. Attribute names
|
||||
# and values may use any UTF-8 characters valid in xml. Control characters
|
||||
# and sequences not allowed in xml are not valid. Each name and value can
|
||||
# be up to 1024 bytes long.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
def put_attributes(domain_name, item_name, attributes, replace_attributes = [])
|
||||
batch_put_attributes(domain_name, { item_name => attributes }, { item_name => replace_attributes })
|
||||
end
|
||||
|
||||
# List metadata for SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
# * item_name<~String> - Name of the item. May use any UTF-8 characters valid
|
||||
# in xml. Control characters and sequences not allowed in xml are not
|
||||
# valid. Can be up to 1024 bytes long.
|
||||
# * attributes<~Hash> - Name/value pairs to remove from the item. Defaults to
|
||||
# nil, which will delete the entire item. Attribute names and values may
|
||||
# use any UTF-8 characters valid in xml. Control characters and sequences
|
||||
# not allowed in xml are not valid. Each name and value can be up to 1024
|
||||
# bytes long.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
def delete_attributes(domain_name, item_name, attributes = nil)
|
||||
request({
|
||||
'Action' => 'DeleteAttributes',
|
||||
'DomainName' => domain_name,
|
||||
'ItemName' => item_name
|
||||
}.merge!(encode_attributes(attributes)), Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
|
||||
end
|
||||
|
||||
# List metadata for SimpleDB domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
|
||||
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
||||
# * item_name<~String> - Name of the item. May use any UTF-8 characters valid
|
||||
# in xml. Control characters and sequences not allowed in xml are not
|
||||
# valid. Can be up to 1024 bytes long.
|
||||
# * attributes<~Hash> - Name/value pairs to return from the item. Defaults to
|
||||
# nil, which will return all attributes. Attribute names and values may use
|
||||
# any UTF-8 characters valid in xml. Control characters and sequences not
|
||||
# allowed in xml are not valid. Each name and value can be up to 1024
|
||||
# bytes long.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
# * :attributes - list of attribute name/values for the item
|
||||
def get_attributes(domain_name, item_name, attributes = nil)
|
||||
request({
|
||||
'Action' => 'GetAttributes',
|
||||
'DomainName' => domain_name,
|
||||
'ItemName' => item_name,
|
||||
}.merge!(encode_attribute_names(attributes)), Fog::Parsers::AWS::SimpleDB::GetAttributes.new(@nil_string))
|
||||
end
|
||||
|
||||
# Select item data from SimpleDB
|
||||
#
|
||||
# ==== Parameters
|
||||
# * select_expression<~String> - Expression to query domain with.
|
||||
# * next_token<~String> - Offset token to start list, defaults to nil.
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :box_usage
|
||||
# * :request_id
|
||||
# * :items - list of attribute name/values for the items formatted as
|
||||
# { 'item_name' => { 'attribute_name' => ['attribute_value'] }}
|
||||
# * :next_token - offset to start with if there are are more domains to list
|
||||
def select(select_expression, next_token = nil)
|
||||
request({
|
||||
'Action' => 'Select',
|
||||
'NextToken' => next_token,
|
||||
'SelectExpression' => select_expression
|
||||
}, Fog::Parsers::AWS::SimpleDB::Select.new(@nil_string))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def encode_attributes(attributes, replace_attributes = [])
|
||||
|
|
Loading…
Reference in a new issue