1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
This commit is contained in:
Wesley Beary 2009-07-20 19:47:48 -07:00
parent 76e476c4d9
commit 4c92ee236e
18 changed files with 121 additions and 23 deletions

View file

@ -15,6 +15,8 @@ module Fog
when 'Contents'
@response[:contents] << @object
@object = { :owner => {} }
when 'Delimeter'
@object[:delimiter] = @value
when 'DisplayName'
@object[:owner][:display_name] = @value
when 'ETag'

View file

@ -8,7 +8,14 @@ module Fog
# * volume_id<~String> - Id of EBS volume to snapshot
#
# ==== Returns
# FIXME: docs
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :progress<~String> - The percentage progress of the snapshot
# * :request_id<~String> - id of request
# * :snapshot_id<~String> - id of snapshot
# * :start_time<~Time> - timestamp when snapshot was initiated
# * :status<~String> - state of snapshot
# * :volume_id<~String> - id of volume snapshot targets
def create_snapshot(volume_id)
request({
'Action' => 'CreateSnapshot',

View file

@ -11,7 +11,10 @@ module Fog
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :request_id<~String> - Id of request
# FIXME: docs
# * :availability_zone_info<~Array>:
# * :region_name<~String> - Name of region
# * :zone_name<~String> - Name of zone
# * :zone_state<~String> - State of zone
def describe_availability_zones(zone_name = [])
params = indexed_params('ZoneName', zone_name)
request({

View file

@ -11,6 +11,7 @@ module Fog
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :request_id<~String> - Id of request
# FIXME: docs
def describe_instances(instance_id = [])
params = indexed_params('InstanceId', instance_id)
request({

View file

@ -8,7 +8,22 @@ module Fog
# * group_name<~Array> - List of groups to describe, defaults to all
#
# === Returns
# FIXME: docs
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :request_id<~String> - Id of request
# * :security_group_info<~Array>:
# * :group_description<~String> - Description of security group
# * :group_name<~String> - Name of security group
# * :ip_permissions<~Array>:
# * :from_port<~Integer> - Start of port range (or -1 for ICMP wildcard)
# * :groups<~Array>:
# * :group_name<~String> - Name of security group
# * :user_id<~String> - AWS User Id of account
# * :ip_protocol<~String> - Ip protocol, must be in ['tcp', 'udp', 'icmp']
# * :ip_ranges<~Array>:
# * :cidr_ip<~String> - CIDR range
# * :to_port<~Integer> - End of port range (or -1 for ICMP wildcard)
# * :owner_id<~String> - AWS Access Key Id of the owner of the security group
def describe_security_groups(group_name = [])
params = indexed_params('GroupName', group_name)
request({

View file

@ -3,7 +3,20 @@ module Fog
class S3
# Copy an object from one S3 bucket to another
# FIXME: docs
#
# ==== Parameters
# * source_bucket_name<~String> - Name of source bucket
# * source_object_name<~String> - Name of source object
# * destination_bucket_name<~String> - Name of bucket to create copy in
# * destination_object_name<~String> - Name for new copy of object
#
# ==== Returns
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :etag<~String> - etag of new object
# * :last_modified<~Time> - date object was last modified
#
# FIXME: allow for optional params, see aws docs
def copy_object(source_bucket_name, source_object_name, destination_bucket_name, destination_object_name)
request({
:expects => 200,

View file

@ -8,7 +8,8 @@ module Fog
# * bucket_name<~String> - name of bucket to delete
#
# ==== Returns
# FIXME: docs
# * response<~Fog::AWS::Response>:
# * status<~Integer> - 204
def delete_bucket(bucket_name)
request({
:expects => 204,

View file

@ -3,7 +3,14 @@ module Fog
class S3
# Delete an object from S3
# FIXME: docs
#
# ==== Parameters
# * bucket_name<~String> - Name of bucket containing object to delete
# * object_name<~String> - Name of object to delete
#
# ==== Returns
# * response<~Fog::AWS::Response>:
# * status<~Integer> - 204
def delete_object(bucket_name, object_name)
request({
:expects => 204,

View file

@ -13,6 +13,23 @@ module Fog
# * 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
#
# ==== Returns
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :delimeter<~String> - Delimiter specified for query
# * :marker<~String> - Marker specified for query
# * :max_keys<~Integer> - Maximum number of keys specified for query
# * :name<~String> - Name of the bucket
# * :prefix<~String> - Prefix specified for query
# * :contents<~Array>:
# * :key<~String>: Name of object
# * :last_modified<~String>: Timestamp of last modification of object
# * :owner<~Hash>:
# * :display_name<~String> - Display name of object owner
# * :id<~String> - Id of object owner
# * :size<~Integer> - Size of object
# * :storage_class<~String> - Storage class of object
def get_bucket(bucket_name, options = {})
options['max-keys'] = options.delete(:maxkeys) if options[:maxkeys]
query = '?'

View file

@ -8,7 +8,9 @@ module Fog
# * bucket_name<~String> - name of bucket to get location constraint for
#
# ==== Returns
# FIXME: docs
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :location_constraint<~String> - Location constraint of the bucket
def get_bucket_location(bucket_name)
request({
:expects => 200,

View file

@ -3,7 +3,14 @@ module Fog
class S3
# Get an object from S3
# FIXME: docs
# ==== Parameters
# * bucket_name<~String> - Name of bucket to read from
# * object_name<~String> - Name of object to read
#
# ==== Returns
# * response<~Fog::AWS::Response>:
# * body<~String> - Contents of object
# FIXME: headers
def get_object(bucket_name, object_name)
request({
:expects => 200,

View file

@ -8,7 +8,9 @@ module Fog
# * bucket_name<~String> - name of bucket to get payer for
#
# ==== Returns
# FIXME: docs
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :payer<~String> - Specifies who pays for download and requests
def get_request_payment(bucket_name)
request({
:expects => 200,

View file

@ -4,8 +4,15 @@ module Fog
# List information about S3 buckets for authorized user
#
# ==== Parameters
# FIXME: docs
# ==== Returns
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :buckets<~Hash>:
# * :name<~String> - Name of bucket
# * :creation_time<~Time> - Timestamp of bucket creation
# * :owner<~Hash>:
# * :display_name<~String> - Display name of bucket owner
# * :id<~String> - Id of bucket owner
def get_service
request({
:expects => 200,

View file

@ -8,6 +8,10 @@ module Fog
# * 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
#
# ==== Returns
# * response<~Fog::AWS::Response>:
# * status<~Integer> - 200
def put_bucket(bucket_name, options = {})
if options[:location_constraint]
data =

View file

@ -3,7 +3,17 @@ module Fog
class S3
# Create an object in an S3 bucket
# FIXME: docs
#
# ==== Parameters
# * bucket_name<~String> - Name of bucket to create object in
# * object_name<~String> - Name of object to create
# * object<~String> - File to create object from
# FIXME: deal with optional params
#
# ==== Returns
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :etag<~String> - etag of new object
def put_object(bucket_name, object_name, object, options = {})
file = parse_file(object)
request({

View file

@ -16,14 +16,14 @@ describe 'EC2.describe_security_groups' do
ip_permission = security_group[:ip_permissions].first
ip_permission[:groups].should be_an(Array)
group = ip_permission[:groups].first
group[:user_id].should be_a(String)
group[:group_name].should be_a(String)
group[:user_id].should be_a(String)
ip_permission[:from_port].should be_an(Integer)
ip_permission[:ip_protocol].should be_a(String)
ip_permission[:ip_ranges].should be_an(Array)
ip_permission[:to_port].should be_an(Integer)
end
it "should return proper attributes with params" do
actual = ec2.describe_security_groups('default')
actual.body[:request_id].should be_a(String)
@ -31,15 +31,15 @@ describe 'EC2.describe_security_groups' do
security_group = actual.body[:security_group_info].select do |security_group|
security_group[:group_name] == 'default'
end.first
security_group[:group_description].should be_a(String)
security_group[:group_name].should be_a(String)
security_group[:group_description].should be_a(String)
security_group[:owner_id].should be_a(String)
security_group[:ip_permissions].should be_an(Array)
ip_permission = security_group[:ip_permissions].first
ip_permission[:groups].should be_an(Array)
group = ip_permission[:groups].first
group[:user_id].should be_a(String)
group[:group_name].should be_a(String)
group[:user_id].should be_a(String)
ip_permission[:from_port].should be_an(Integer)
ip_permission[:ip_protocol].should be_a(String)
ip_permission[:ip_ranges].should be_an(Array)

View file

@ -15,18 +15,18 @@ describe 'S3.get_bucket' do
it 'should return proper attributes' do
actual = s3.get_bucket('foggetbucket')
actual.status.should == 200
actual.body[:name].should be_a(String)
actual.body[:is_truncated].should == false
actual.body[:marker].should be_a(String)
actual.body[:max_keys].should be_an(Integer)
actual.body[:name].should be_a(String)
actual.body[:prefix].should be_a(String)
actual.body[:contents].should be_an(Array)
object = actual.body[:contents].first
object[:key].should == 'fog_get_bucket'
object[:last_modified].should be_a(Time)
object[:owner][:display_name].should be_a(String)
object[:owner][:id].should be_a(String)
owner = object[:owner]
owner[:display_name].should be_a(String)
owner[:id].should be_a(String)
object[:size].should be_an(Integer)
object[:storage_class].should be_a(String)
end

View file

@ -12,13 +12,13 @@ describe 'S3.get_service' do
it 'should return proper_attributes' do
actual = s3.get_service
actual.status.should == 200
actual.body[:owner][:display_name].should be_a(String)
actual.body[:owner][:id].should be_a(String)
actual.body[:buckets].should be_an(Array)
bucket = actual.body[:buckets].select {|bucket| bucket[:name] == 'foggetservice'}.first
bucket[:creation_date].should be_a(Time)
bucket[:name].should == 'foggetservice'
owner = actual.body[:owner]
owner[:display_name].should be_a(String)
owner[:id].should be_a(String)
end
it 'should include foggetservice in get_service' do