fog 0.0.93 → 0.0.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. data/Gemfile +2 -1
  2. data/Gemfile.lock +13 -7
  3. data/bin/fog +6 -0
  4. data/fog.gemspec +40 -3
  5. data/lib/fog.rb +2 -1
  6. data/lib/fog/aws.rb +12 -8
  7. data/lib/fog/aws/parsers/s3/get_bucket_logging.rb +40 -0
  8. data/lib/fog/aws/parsers/s3/get_bucket_object_versions.rb +88 -0
  9. data/lib/fog/aws/parsers/s3/get_bucket_versioning.rb +24 -0
  10. data/lib/fog/aws/requests/ec2/associate_address.rb +3 -0
  11. data/lib/fog/aws/requests/ec2/describe_instances.rb +4 -3
  12. data/lib/fog/aws/requests/ec2/disassociate_address.rb +4 -0
  13. data/lib/fog/aws/requests/s3/get_bucket.rb +6 -5
  14. data/lib/fog/aws/requests/s3/get_bucket_logging.rb +53 -0
  15. data/lib/fog/aws/requests/s3/get_bucket_object_versions.rb +83 -0
  16. data/lib/fog/aws/requests/s3/get_bucket_versioning.rb +43 -0
  17. data/lib/fog/aws/requests/s3/get_object.rb +6 -1
  18. data/lib/fog/aws/requests/s3/get_object_acl.rb +8 -2
  19. data/lib/fog/aws/requests/s3/head_object.rb +4 -1
  20. data/lib/fog/aws/requests/s3/put_bucket_acl.rb +1 -1
  21. data/lib/fog/aws/requests/s3/put_bucket_logging.rb +87 -0
  22. data/lib/fog/aws/requests/s3/put_bucket_versioning.rb +40 -0
  23. data/lib/fog/aws/s3.rb +9 -1
  24. data/lib/fog/bin.rb +1 -1
  25. data/lib/fog/credentials.rb +6 -2
  26. data/lib/fog/vcloud.rb +288 -0
  27. data/lib/fog/vcloud/bin.rb +57 -0
  28. data/lib/fog/vcloud/parser.rb +34 -0
  29. data/lib/fog/vcloud/parsers/get_organization.rb +37 -0
  30. data/lib/fog/vcloud/parsers/get_vdc.rb +37 -0
  31. data/lib/fog/vcloud/parsers/get_versions.rb +46 -0
  32. data/lib/fog/vcloud/parsers/login.rb +40 -0
  33. data/lib/fog/vcloud/requests/get_organization.rb +55 -0
  34. data/lib/fog/vcloud/requests/get_vdc.rb +59 -0
  35. data/lib/fog/vcloud/requests/get_versions.rb +43 -0
  36. data/lib/fog/vcloud/requests/login.rb +46 -0
  37. data/lib/fog/vcloud/terremark/all.rb +9 -0
  38. data/lib/fog/vcloud/terremark/ecloud.rb +47 -0
  39. data/lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb +59 -0
  40. data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +94 -0
  41. data/lib/fog/vcloud/terremark/ecloud/requests/login.rb +27 -0
  42. data/lib/fog/vcloud/terremark/vcloud.rb +43 -0
  43. data/lib/fog/vcloud/terremark/vcloud/parsers/get_vdc.rb +34 -0
  44. data/lib/fog/vcloud/terremark/vcloud/requests/get_vdc.rb +65 -0
  45. data/spec/aws/requests/ec2/describe_instances_spec.rb +4 -4
  46. data/spec/spec_helper.rb +3 -1
  47. data/spec/vcloud/bin_spec.rb +31 -0
  48. data/spec/vcloud/requests/get_organization_spec.rb +46 -0
  49. data/spec/vcloud/requests/get_vdc_spec.rb +50 -0
  50. data/spec/vcloud/requests/get_versions_spec.rb +28 -0
  51. data/spec/vcloud/requests/login_spec.rb +8 -0
  52. data/spec/vcloud/spec_helper.rb +184 -0
  53. data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +135 -0
  54. data/spec/vcloud/terremark/ecloud/requests/login_spec.rb +7 -0
  55. data/spec/vcloud/terremark/vcloud/requests/get_vdc_spec.rb +74 -0
  56. data/spec/vcloud/vcloud_spec.rb +17 -0
  57. data/tests/aws/requests/ec2/address_tests.rb +3 -0
  58. metadata +42 -5
@@ -0,0 +1,53 @@
1
+ module Fog
2
+ module AWS
3
+ module S3
4
+ class Real
5
+
6
+ # Get logging status for an S3 bucket
7
+ #
8
+ # ==== Parameters
9
+ # * bucket_name<~String> - name of bucket to get logging status for
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Hash>:
14
+ # * 'BucketLoggingStatus'<~Hash>: (will be empty if logging is disabled)
15
+ # * 'LoggingEnabled'<~Hash>:
16
+ # * 'TargetBucket'<~String> - bucket where logs are stored
17
+ # * 'TargetPrefix'<~String> - prefix logs are stored with
18
+ # * 'TargetGrants'<~Array>:
19
+ # * 'Grant'<~Hash>:
20
+ # * 'Grantee'<~Hash>:
21
+ # * 'DisplayName'<~String> - Display name of grantee
22
+ # * 'ID'<~String> - Id of grantee
23
+ # or
24
+ # * 'URI'<~String> - URI of group to grant access for
25
+ # * 'Permission'<~String> - Permission, in [FULL_CONTROL, WRITE, WRITE_ACP, READ, READ_ACP]
26
+ #
27
+ def get_bucket_logging(bucket_name)
28
+ unless bucket_name
29
+ raise ArgumentError.new('bucket_name is required')
30
+ end
31
+ request({
32
+ :expects => 200,
33
+ :headers => {},
34
+ :host => "#{bucket_name}.#{@host}",
35
+ :idempotent => true,
36
+ :method => 'GET',
37
+ :parser => Fog::Parsers::AWS::S3::GetBucketLogging.new,
38
+ :query => 'logging'
39
+ })
40
+ end
41
+
42
+ end
43
+
44
+ class Mock
45
+
46
+ def get_bucket_logging(bucket_name)
47
+ raise MockNotImplemented.new("Contributions welcome!")
48
+ end
49
+
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,83 @@
1
+ module Fog
2
+ module AWS
3
+ module S3
4
+ class Real
5
+
6
+ # List information about object versions in an S3 bucket
7
+ #
8
+ # ==== Parameters
9
+ # * bucket_name<~String> - name of bucket to list object keys from
10
+ # * options<~Hash> - config arguments for list. Defaults to {}.
11
+ # * 'delimiter'<~String> - causes keys with the same string between the prefix
12
+ # value and the first occurence of delimiter to be rolled up
13
+ # * 'key-marker'<~String> - limits object keys to only those that appear
14
+ # lexicographically after its value.
15
+ # * 'max-keys'<~Integer> - limits number of object keys returned
16
+ # * 'prefix'<~String> - limits object keys to those beginning with its value.
17
+ # * 'version-id-marker'<~String> - limits object versions to only those that
18
+ # appear lexicographically after its value
19
+ #
20
+ # ==== Returns
21
+ # * response<~Excon::Response>:
22
+ # * body<~Hash>:
23
+ # * 'Delimeter'<~String> - Delimiter specified for query
24
+ # * 'KeyMarker'<~String> - Key marker specified for query
25
+ # * 'MaxKeys'<~Integer> - Maximum number of keys specified for query
26
+ # * 'Name'<~String> - Name of the bucket
27
+ # * 'Prefix'<~String> - Prefix specified for query
28
+ # * 'VersionIdMarker'<~String> - Version id marker specified for query
29
+ # * 'IsTruncated'<~Boolean> - Whether or not this is the totality of the bucket
30
+ # * 'Versions'<~Array>:
31
+ # * 'DeleteMarker'<~Hash>:
32
+ # * 'IsLatest'<~Boolean> - Whether or not this is the latest version
33
+ # * 'Key'<~String> - Name of object
34
+ # * 'LastModified'<~String>: Timestamp of last modification of object
35
+ # * 'Owner'<~Hash>:
36
+ # * 'DisplayName'<~String> - Display name of object owner
37
+ # * 'ID'<~String> - Id of object owner
38
+ # * 'VersionId'<~String> - The id of this version
39
+ # or
40
+ # * 'Version'<~Hash>:
41
+ # * 'ETag'<~String>: Etag of object
42
+ # * 'IsLatest'<~Boolean> - Whether or not this is the latest version
43
+ # * 'Key'<~String> - Name of object
44
+ # * 'LastModified'<~String>: Timestamp of last modification of object
45
+ # * 'Owner'<~Hash>:
46
+ # * 'DisplayName'<~String> - Display name of object owner
47
+ # * 'ID'<~String> - Id of object owner
48
+ # * 'Size'<~Integer> - Size of object
49
+ # * 'StorageClass'<~String> - Storage class of object
50
+ # * 'VersionId'<~String> - The id of this version
51
+ #
52
+ def get_bucket_object_versions(bucket_name, options = {})
53
+ unless bucket_name
54
+ raise ArgumentError.new('bucket_name is required')
55
+ end
56
+ query = ''
57
+ for key, value in options
58
+ query << "#{key}=#{CGI.escape(value.to_s).gsub(/\+/, '%20')}&"
59
+ end
60
+ query.chop!
61
+ request({
62
+ :expects => 200,
63
+ :headers => {},
64
+ :host => "#{bucket_name}.#{@host}",
65
+ :idempotent => true,
66
+ :method => 'GET',
67
+ :parser => Fog::Parsers::AWS::S3::GetBucketObjectVersions.new,
68
+ :query => query
69
+ })
70
+ end
71
+
72
+ end
73
+
74
+ class Mock
75
+
76
+ def get_bucket_object_versions(bucket_name, options = {})
77
+ raise MockNotImplemented.new("Contributions welcome!")
78
+ end
79
+
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,43 @@
1
+ module Fog
2
+ module AWS
3
+ module S3
4
+ class Real
5
+
6
+ # Get versioning status for an S3 bucket
7
+ #
8
+ # ==== Parameters
9
+ # * bucket_name<~String> - name of bucket to get versioning status for
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Hash>:
14
+ # * 'VersioningConfiguration'<~Hash>
15
+ # * Status<~String>: Versioning status in ['Enabled', 'Suspended', nil]
16
+ #
17
+ def get_bucket_versioning(bucket_name)
18
+ unless bucket_name
19
+ raise ArgumentError.new('bucket_name is required')
20
+ end
21
+ request({
22
+ :expects => 200,
23
+ :headers => {},
24
+ :host => "#{bucket_name}.#{@host}",
25
+ :idempotent => true,
26
+ :method => 'GET',
27
+ :parser => Fog::Parsers::AWS::S3::GetBucketVersioning.new,
28
+ :query => 'versioning'
29
+ })
30
+ end
31
+
32
+ end
33
+
34
+ class Mock
35
+
36
+ def get_bucket_versioning(bucket_name)
37
+ raise MockNotImplemented.new("Contributions welcome!")
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -14,6 +14,8 @@ module Fog
14
14
  # * 'If-None-Match'<~String> - Returns object only if its etag differs from this value, otherwise returns 304 (Not Modified)
15
15
  # * 'If-Unmodified-Since'<~Time> - Returns object only if it has not been modified since this time, otherwise returns 412 (Precodition Failed).
16
16
  # * 'Range'<~String> - Range of object to download
17
+ # * 'versionId'<~String> - specify a particular version to retrieve
18
+ #
17
19
  # ==== Returns
18
20
  # * response<~Excon::Response>:
19
21
  # * body<~String> - Contents of object
@@ -22,6 +24,7 @@ module Fog
22
24
  # * 'Content-Type'<~String> - MIME type of object
23
25
  # * 'ETag'<~String> - Etag of object
24
26
  # * 'Last-Modified'<~String> - Last modified timestamp for object
27
+ #
25
28
  def get_object(bucket_name, object_name, options = {}, &block)
26
29
  unless bucket_name
27
30
  raise ArgumentError.new('bucket_name is required')
@@ -29,6 +32,7 @@ module Fog
29
32
  unless object_name
30
33
  raise ArgumentError.new('object_name is required')
31
34
  end
35
+ version_id = options.delete('versionId')
32
36
  headers = {}
33
37
  headers['If-Modified-Since'] = options['If-Modified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if options['If-Modified-Since']
34
38
  headers['If-Unmodified-Since'] = options['If-Unmodified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if options['If-Modified-Since']
@@ -39,7 +43,8 @@ module Fog
39
43
  :host => "#{bucket_name}.#{@host}",
40
44
  :idempotent => true,
41
45
  :method => 'GET',
42
- :path => CGI.escape(object_name)
46
+ :path => CGI.escape(object_name),
47
+ :query => CGI.escape(version_id)
43
48
  }, &block)
44
49
  end
45
50
 
@@ -8,6 +8,8 @@ module Fog
8
8
  # ==== Parameters
9
9
  # * bucket_name<~String> - name of bucket containing object
10
10
  # * object_name<~String> - name of object to get access control list for
11
+ # * options<~Hash>:
12
+ # * 'versionId'<~String> - specify a particular version to retrieve
11
13
  #
12
14
  # ==== Returns
13
15
  # * response<~Excon::Response>:
@@ -25,13 +27,17 @@ module Fog
25
27
  # * 'URI'<~String> - URI of group to grant access for
26
28
  # * 'Permission'<~String> - Permission, in [FULL_CONTROL, WRITE, WRITE_ACP, READ, READ_ACP]
27
29
  #
28
- def get_object_acl(bucket_name, object_name)
30
+ def get_object_acl(bucket_name, object_name, options = {})
29
31
  unless bucket_name
30
32
  raise ArgumentError.new('bucket_name is required')
31
33
  end
32
34
  unless object_name
33
35
  raise ArgumentError.new('object_name is required')
34
36
  end
37
+ query = 'acl'
38
+ if version_id = options.delete('versionId')
39
+ query << "&#{CGI.escape(version_id)}"
40
+ end
35
41
  request({
36
42
  :expects => 200,
37
43
  :headers => {},
@@ -40,7 +46,7 @@ module Fog
40
46
  :method => 'GET',
41
47
  :parser => Fog::Parsers::AWS::S3::AccessControlList.new,
42
48
  :path => CGI.escape(object_name),
43
- :query => 'acl'
49
+ :query => query
44
50
  })
45
51
  end
46
52
 
@@ -14,6 +14,7 @@ module Fog
14
14
  # * 'If-None-Match'<~String> - Returns object only if its etag differs from this value, otherwise returns 304 (Not Modified)
15
15
  # * 'If-Unmodified-Since'<~Time> - Returns object only if it has not been modified since this time, otherwise returns 412 (Precodition Failed).
16
16
  # * 'Range'<~String> - Range of object to download
17
+ # * 'versionId'<~String> - specify a particular version to retrieve
17
18
  #
18
19
  # ==== Returns
19
20
  # * response<~Excon::Response>:
@@ -24,6 +25,7 @@ module Fog
24
25
  # * 'ETag'<~String> - Etag of object
25
26
  # * 'Last-Modified'<~String> - Last modified timestamp for object
26
27
  def head_object(bucket_name, object_name, options={})
28
+ version_id = options.delete('versionId')
27
29
  headers = {}
28
30
  headers['If-Modified-Since'] = options['If-Modified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if options['If-Modified-Since']
29
31
  headers['If-Unmodified-Since'] = options['If-Unmodified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if options['If-Modified-Since']
@@ -33,7 +35,8 @@ module Fog
33
35
  :headers => headers,
34
36
  :host => "#{bucket_name}.#{@host}",
35
37
  :method => 'HEAD',
36
- :path => CGI.escape(object_name)
38
+ :path => CGI.escape(object_name),
39
+ :query => CGI.escape(version_id)
37
40
  })
38
41
  end
39
42
 
@@ -50,7 +50,7 @@ DATA
50
50
  data << " </Grant>"
51
51
  end
52
52
 
53
- data <<
53
+ data <<
54
54
  <<-DATA
55
55
  </AccessControlList>
56
56
  </AccessControlPolicy>
@@ -0,0 +1,87 @@
1
+ module Fog
2
+ module AWS
3
+ module S3
4
+ class Real
5
+
6
+ # Change logging status for an S3 bucket
7
+ #
8
+ # ==== Parameters
9
+ # * bucket_name<~String> - name of bucket to modify
10
+ # * logging_status<~Hash>:
11
+ # * Owner<~Hash>:
12
+ # * ID<~String>: id of owner
13
+ # * DisplayName<~String>: display name of owner
14
+ # * AccessControlList<~Array>:
15
+ # * Grantee<~Hash>:
16
+ # * 'DisplayName'<~String> - Display name of grantee
17
+ # * 'ID'<~String> - Id of grantee
18
+ # or
19
+ # * 'EmailAddress'<~String> - Email address of grantee
20
+ # or
21
+ # * 'URI'<~String> - URI of group to grant access for
22
+ # * Permission<~String> - Permission, in [FULL_CONTROL, WRITE, WRITE_ACP, READ, READ_ACP]
23
+ def put_bucket_logging(bucket_name, logging_status)
24
+ if logging_status['LoggingEnabled'].empty?
25
+ data =
26
+ <<-DATA
27
+ <BucketLoggingStatus xmlns="http://doc.s3.amazonaws.com/2006-03-01" />
28
+ DATA
29
+ else
30
+ data =
31
+ <<-DATA
32
+ <BucketLoggingStatus xmlns="http://doc.s3.amazonaws.com/2006-03-01">
33
+ <LoggingEnabled>
34
+ <TargetBucket>#{logging_status['LoggingEnabled']['TargetBucket']}</TargetBucket>
35
+ <TargetPrefix>#{logging_status['LoggingEnabled']['TargetBucket']}</TargetPrefix>
36
+ <TargetGrants>
37
+ DATA
38
+
39
+ acl['AccessControlList'].each do |grant|
40
+ data << " <Grant>"
41
+ type = case grant['Grantee'].keys.sort
42
+ when ['DisplayName', 'ID']
43
+ 'CanonicalUser'
44
+ when ['EmailAddress']
45
+ 'AmazonCustomerByEmail'
46
+ when ['URI']
47
+ 'Group'
48
+ end
49
+ data << " <Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"#{type}\">"
50
+ for key, value in grant['Grantee']
51
+ data << " <#{key}>#{value}</#{key}>"
52
+ end
53
+ data << " </Grantee>"
54
+ data << " <Permission>#{grant['Permission']}</Permission>"
55
+ data << " </Grant>"
56
+ end
57
+
58
+ data <<
59
+ <<-DATA
60
+ </TargetGrants>
61
+ </LoggingEnabled>
62
+ </BucketLoggingStatus>
63
+ DATA
64
+ end
65
+
66
+ request({
67
+ :body => data,
68
+ :expects => 200,
69
+ :headers => {},
70
+ :host => "#{bucket_name}.#{@host}",
71
+ :method => 'PUT',
72
+ :query => 'logging'
73
+ })
74
+ end
75
+
76
+ end
77
+
78
+ class Mock
79
+
80
+ def put_bucket_logging(bucket_name, logging_status)
81
+ raise MockNotImplemented.new("Contributions welcome!")
82
+ end
83
+
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,40 @@
1
+ module Fog
2
+ module AWS
3
+ module S3
4
+ class Real
5
+
6
+ # Change versioning status for an S3 bucket
7
+ #
8
+ # ==== Parameters
9
+ # * bucket_name<~String> - name of bucket to modify
10
+ # * status<~String> - Status to change to in ['Enabled', 'Suspended']
11
+ def put_bucket_versioning(bucket_name, status)
12
+ data =
13
+ <<-DATA
14
+ <VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
15
+ <Status>#{status}</Status>
16
+ </VersioningConfiguration>
17
+ DATA
18
+
19
+ request({
20
+ :body => data,
21
+ :expects => 200,
22
+ :headers => {},
23
+ :host => "#{bucket_name}.#{@host}",
24
+ :method => 'PUT',
25
+ :query => 'versioning'
26
+ })
27
+ end
28
+
29
+ end
30
+
31
+ class Mock
32
+
33
+ def put_bucket_versioning(bucket_name, status)
34
+ raise MockNotImplemented.new("Contributions welcome!")
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+ end
@@ -13,6 +13,9 @@ module Fog
13
13
  require 'fog/aws/parsers/s3/copy_object'
14
14
  require 'fog/aws/parsers/s3/get_bucket'
15
15
  require 'fog/aws/parsers/s3/get_bucket_location'
16
+ require 'fog/aws/parsers/s3/get_bucket_logging'
17
+ require 'fog/aws/parsers/s3/get_bucket_object_versions'
18
+ require 'fog/aws/parsers/s3/get_bucket_versioning'
16
19
  require 'fog/aws/parsers/s3/get_request_payment'
17
20
  require 'fog/aws/parsers/s3/get_service'
18
21
  require 'fog/aws/requests/s3/copy_object'
@@ -21,6 +24,9 @@ module Fog
21
24
  require 'fog/aws/requests/s3/get_bucket'
22
25
  require 'fog/aws/requests/s3/get_bucket_acl'
23
26
  require 'fog/aws/requests/s3/get_bucket_location'
27
+ require 'fog/aws/requests/s3/get_bucket_logging'
28
+ require 'fog/aws/requests/s3/get_bucket_object_versions'
29
+ require 'fog/aws/requests/s3/get_bucket_versioning'
24
30
  require 'fog/aws/requests/s3/get_object'
25
31
  require 'fog/aws/requests/s3/get_object_acl'
26
32
  require 'fog/aws/requests/s3/get_object_torrent'
@@ -30,6 +36,8 @@ module Fog
30
36
  require 'fog/aws/requests/s3/head_object'
31
37
  require 'fog/aws/requests/s3/put_bucket'
32
38
  require 'fog/aws/requests/s3/put_bucket_acl'
39
+ require 'fog/aws/requests/s3/put_bucket_logging'
40
+ require 'fog/aws/requests/s3/put_bucket_versioning'
33
41
  require 'fog/aws/requests/s3/put_object'
34
42
  require 'fog/aws/requests/s3/put_request_payment'
35
43
  @required = true
@@ -195,7 +203,7 @@ DATA
195
203
  canonical_resource << "#{CGI.escape(subdomain).downcase}/"
196
204
  end
197
205
  canonical_resource << "#{params[:path]}"
198
- if ['acl', 'location', 'logging', 'requestPayment', 'torrent'].include?(params[:query])
206
+ if params[:query]
199
207
  canonical_resource << "?#{params[:query]}"
200
208
  end
201
209
  string_to_sign << "#{canonical_resource}"