fog 0.3.17 → 0.3.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/Gemfile.lock +5 -5
  2. data/README.rdoc +16 -7
  3. data/fog.gemspec +102 -27
  4. data/lib/fog.rb +3 -2
  5. data/lib/fog/aws/cdn.rb +2 -1
  6. data/lib/fog/aws/compute.rb +3 -2
  7. data/lib/fog/aws/iam.rb +8 -0
  8. data/lib/fog/aws/models/compute/flavors.rb +2 -1
  9. data/lib/fog/aws/models/compute/server.rb +3 -0
  10. data/lib/fog/aws/models/compute/volume.rb +9 -8
  11. data/lib/fog/aws/models/storage/file.rb +24 -14
  12. data/lib/fog/aws/models/storage/files.rb +4 -14
  13. data/lib/fog/aws/parsers/cdn/distribution.rb +16 -1
  14. data/lib/fog/aws/parsers/cdn/get_distribution_list.rb +13 -0
  15. data/lib/fog/aws/parsers/compute/describe_volumes.rb +2 -0
  16. data/lib/fog/aws/parsers/iam/create_group.rb +2 -2
  17. data/lib/fog/aws/parsers/iam/create_user.rb +26 -0
  18. data/lib/fog/aws/parsers/iam/list_group_policies.rb +28 -0
  19. data/lib/fog/aws/parsers/iam/list_groups.rb +1 -1
  20. data/lib/fog/aws/parsers/storage/complete_multipart_upload.rb +24 -0
  21. data/lib/fog/aws/parsers/storage/initiate_multipart_upload.rb +24 -0
  22. data/lib/fog/aws/parsers/storage/list_multipart_uploads.rb +56 -0
  23. data/lib/fog/aws/parsers/storage/list_parts.rb +40 -0
  24. data/lib/fog/aws/requests/cdn/get_distribution.rb +11 -1
  25. data/lib/fog/aws/requests/cdn/get_distribution_list.rb +9 -1
  26. data/lib/fog/aws/requests/cdn/post_distribution.rb +16 -5
  27. data/lib/fog/aws/requests/cdn/put_distribution_config.rb +102 -0
  28. data/lib/fog/aws/requests/compute/describe_volumes.rb +1 -0
  29. data/lib/fog/aws/requests/compute/run_instances.rb +1 -1
  30. data/lib/fog/aws/requests/iam/add_user_to_group.rb +42 -0
  31. data/lib/fog/aws/requests/iam/create_group.rb +7 -3
  32. data/lib/fog/aws/requests/iam/create_user.rb +47 -0
  33. data/lib/fog/aws/requests/iam/delete_group.rb +5 -1
  34. data/lib/fog/aws/requests/iam/delete_group_policy.rb +42 -0
  35. data/lib/fog/aws/requests/iam/delete_user.rb +40 -0
  36. data/lib/fog/aws/requests/iam/list_group_policies.rb +47 -0
  37. data/lib/fog/aws/requests/iam/list_groups.rb +9 -4
  38. data/lib/fog/aws/requests/iam/put_group_policy.rb +44 -0
  39. data/lib/fog/aws/requests/iam/remove_user_from_group.rb +42 -0
  40. data/lib/fog/aws/requests/simpledb/put_attributes.rb +2 -2
  41. data/lib/fog/aws/requests/storage/abort_multipart_upload.rb +38 -0
  42. data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +60 -0
  43. data/lib/fog/aws/requests/storage/get_service.rb +1 -1
  44. data/lib/fog/aws/requests/storage/initiate_multipart_upload.rb +55 -0
  45. data/lib/fog/aws/requests/storage/list_multipart_uploads.rb +68 -0
  46. data/lib/fog/aws/requests/storage/list_parts.rb +67 -0
  47. data/lib/fog/aws/requests/storage/put_object.rb +12 -5
  48. data/lib/fog/aws/requests/storage/upload_part.rb +51 -0
  49. data/lib/fog/aws/storage.rb +12 -6
  50. data/lib/fog/brightbox.rb +7 -0
  51. data/lib/fog/brightbox/bin.rb +23 -0
  52. data/lib/fog/brightbox/compute.rb +134 -0
  53. data/lib/fog/brightbox/models/compute/account.rb +51 -0
  54. data/lib/fog/brightbox/models/compute/cloud_ip.rb +43 -0
  55. data/lib/fog/brightbox/models/compute/cloud_ips.rb +34 -0
  56. data/lib/fog/brightbox/models/compute/flavor.rb +33 -0
  57. data/lib/fog/brightbox/models/compute/flavors.rb +28 -0
  58. data/lib/fog/brightbox/models/compute/image.rb +52 -0
  59. data/lib/fog/brightbox/models/compute/images.rb +28 -0
  60. data/lib/fog/brightbox/models/compute/server.rb +94 -0
  61. data/lib/fog/brightbox/models/compute/servers.rb +29 -0
  62. data/lib/fog/brightbox/models/compute/user.rb +39 -0
  63. data/lib/fog/brightbox/models/compute/users.rb +29 -0
  64. data/lib/fog/brightbox/models/compute/zone.rb +21 -0
  65. data/lib/fog/brightbox/models/compute/zones.rb +29 -0
  66. data/lib/fog/brightbox/requests/compute/create_api_client.rb +27 -0
  67. data/lib/fog/brightbox/requests/compute/create_cloud_ip.rb +27 -0
  68. data/lib/fog/brightbox/requests/compute/create_image.rb +27 -0
  69. data/lib/fog/brightbox/requests/compute/create_server.rb +27 -0
  70. data/lib/fog/brightbox/requests/compute/destroy_api_client.rb +28 -0
  71. data/lib/fog/brightbox/requests/compute/destroy_cloud_ip.rb +28 -0
  72. data/lib/fog/brightbox/requests/compute/destroy_image.rb +28 -0
  73. data/lib/fog/brightbox/requests/compute/destroy_server.rb +28 -0
  74. data/lib/fog/brightbox/requests/compute/get_account.rb +27 -0
  75. data/lib/fog/brightbox/requests/compute/get_api_client.rb +28 -0
  76. data/lib/fog/brightbox/requests/compute/get_cloud_ip.rb +28 -0
  77. data/lib/fog/brightbox/requests/compute/get_image.rb +28 -0
  78. data/lib/fog/brightbox/requests/compute/get_interface.rb +28 -0
  79. data/lib/fog/brightbox/requests/compute/get_server.rb +28 -0
  80. data/lib/fog/brightbox/requests/compute/get_server_type.rb +28 -0
  81. data/lib/fog/brightbox/requests/compute/get_user.rb +28 -0
  82. data/lib/fog/brightbox/requests/compute/get_zone.rb +28 -0
  83. data/lib/fog/brightbox/requests/compute/list_api_clients.rb +27 -0
  84. data/lib/fog/brightbox/requests/compute/list_cloud_ips.rb +27 -0
  85. data/lib/fog/brightbox/requests/compute/list_images.rb +27 -0
  86. data/lib/fog/brightbox/requests/compute/list_server_types.rb +27 -0
  87. data/lib/fog/brightbox/requests/compute/list_servers.rb +27 -0
  88. data/lib/fog/brightbox/requests/compute/list_users.rb +27 -0
  89. data/lib/fog/brightbox/requests/compute/list_zones.rb +27 -0
  90. data/lib/fog/brightbox/requests/compute/map_cloud_ip.rb +28 -0
  91. data/lib/fog/brightbox/requests/compute/reset_ftp_password_account.rb +27 -0
  92. data/lib/fog/brightbox/requests/compute/resize_server.rb +27 -0
  93. data/lib/fog/brightbox/requests/compute/shutdown_server.rb +28 -0
  94. data/lib/fog/brightbox/requests/compute/snapshot_server.rb +28 -0
  95. data/lib/fog/brightbox/requests/compute/start_server.rb +28 -0
  96. data/lib/fog/brightbox/requests/compute/stop_server.rb +28 -0
  97. data/lib/fog/brightbox/requests/compute/unmap_cloud_ip.rb +28 -0
  98. data/lib/fog/brightbox/requests/compute/update_account.rb +28 -0
  99. data/lib/fog/brightbox/requests/compute/update_api_client.rb +29 -0
  100. data/lib/fog/brightbox/requests/compute/update_image.rb +29 -0
  101. data/lib/fog/brightbox/requests/compute/update_server.rb +29 -0
  102. data/lib/fog/brightbox/requests/compute/update_user.rb +29 -0
  103. data/lib/fog/core/attributes.rb +3 -3
  104. data/lib/fog/core/bin.rb +2 -0
  105. data/lib/fog/core/compute.rb +5 -2
  106. data/lib/fog/core/credentials.rb +2 -0
  107. data/lib/fog/core/service.rb +24 -12
  108. data/lib/fog/google/models/storage/file.rb +23 -14
  109. data/lib/fog/google/models/storage/files.rb +4 -14
  110. data/lib/fog/google/requests/storage/get_bucket.rb +0 -1
  111. data/lib/fog/google/requests/storage/put_object.rb +9 -2
  112. data/lib/fog/rackspace/models/storage/file.rb +3 -3
  113. data/lib/fog/rackspace/models/storage/files.rb +5 -13
  114. data/spec/aws/models/compute/server_spec.rb +0 -3
  115. data/spec/aws/requests/simpledb/get_attributes_spec.rb +11 -0
  116. data/spec/core/attributes_spec.rb +52 -0
  117. data/spec/vcloud/bin_spec.rb +1 -1
  118. data/spec/vcloud/vcloud_spec.rb +1 -1
  119. data/tests/aws/models/compute/flavors_tests.rb +5 -0
  120. data/tests/aws/models/compute/server_tests.rb +6 -0
  121. data/tests/aws/models/compute/servers_tests.rb +6 -0
  122. data/tests/aws/requests/storage/bucket_tests.rb +1 -1
  123. data/tests/aws/requests/storage/multipart_upload_tests.rb +135 -0
  124. data/tests/bluebox/models/compute/flavors_tests.rb +5 -0
  125. data/tests/bluebox/models/compute/server_tests.rb +5 -0
  126. data/tests/bluebox/models/compute/servers_tests.rb +6 -0
  127. data/tests/brightbox/helper.rb +0 -0
  128. data/tests/brightbox/models/compute/flavors_tests.rb +5 -0
  129. data/tests/brightbox/models/compute/server_tests.rb +6 -0
  130. data/tests/brightbox/models/compute/servers_tests.rb +6 -0
  131. data/tests/google/requests/storage/bucket_tests.rb +78 -0
  132. data/tests/google/requests/storage/object_tests.rb +81 -0
  133. data/tests/helper.rb +19 -4
  134. data/tests/helpers/collection_tests.rb +51 -0
  135. data/tests/helpers/compute/flavors_tests.rb +34 -0
  136. data/tests/helpers/compute/server_tests.rb +19 -0
  137. data/tests/helpers/compute/servers_tests.rb +11 -0
  138. data/tests/helpers/model_tests.rb +28 -0
  139. data/tests/helpers/storage/directories_tests.rb +4 -36
  140. data/tests/helpers/storage/directory_tests.rb +8 -22
  141. data/tests/helpers/storage/file_tests.rb +8 -25
  142. data/tests/helpers/storage/files_tests.rb +5 -39
  143. data/tests/local/models/storage/directories_tests.rb +1 -1
  144. data/tests/local/models/storage/directory_tests.rb +1 -1
  145. data/tests/local/models/storage/file_tests.rb +1 -1
  146. data/tests/local/models/storage/files_tests.rb +1 -1
  147. data/tests/rackspace/models/compute/flavors_tests.rb +5 -0
  148. data/tests/rackspace/models/compute/server_tests.rb +6 -0
  149. data/tests/rackspace/models/compute/servers_tests.rb +6 -0
  150. data/tests/rackspace/models/storage/directories_tests.rb +1 -1
  151. data/tests/rackspace/models/storage/directory_tests.rb +1 -1
  152. data/tests/rackspace/models/storage/file_tests.rb +1 -1
  153. data/tests/rackspace/models/storage/files_tests.rb +1 -1
  154. data/tests/slicehost/models/compute/flavors_tests.rb +5 -0
  155. data/tests/slicehost/models/compute/server_tests.rb +6 -0
  156. data/tests/slicehost/models/compute/servers_tests.rb +6 -0
  157. metadata +108 -31
  158. data/spec/aws/models/compute/flavors_spec.rb +0 -14
  159. data/spec/aws/models/compute/servers_spec.rb +0 -21
  160. data/spec/bluebox/models/compute/flavors_spec.rb +0 -17
  161. data/spec/bluebox/models/compute/server_spec.rb +0 -29
  162. data/spec/bluebox/models/compute/servers_spec.rb +0 -31
  163. data/spec/google/requests/storage/copy_object_spec.rb +0 -61
  164. data/spec/google/requests/storage/delete_bucket_spec.rb +0 -35
  165. data/spec/google/requests/storage/delete_object_spec.rb +0 -38
  166. data/spec/google/requests/storage/get_bucket_spec.rb +0 -110
  167. data/spec/google/requests/storage/get_object_spec.rb +0 -58
  168. data/spec/google/requests/storage/get_service_spec.rb +0 -32
  169. data/spec/google/requests/storage/head_object_spec.rb +0 -26
  170. data/spec/google/requests/storage/put_bucket_spec.rb +0 -21
  171. data/spec/google/requests/storage/put_object_spec.rb +0 -43
  172. data/spec/rackspace/models/compute/flavors_spec.rb +0 -18
  173. data/spec/rackspace/models/compute/server_spec.rb +0 -55
  174. data/spec/rackspace/models/compute/servers_spec.rb +0 -22
  175. data/spec/shared_examples/flavors_examples.rb +0 -16
  176. data/spec/shared_examples/server_examples.rb +0 -43
  177. data/spec/shared_examples/servers_examples.rb +0 -37
  178. data/spec/slicehost/models/compute/flavors_spec.rb +0 -18
  179. data/spec/slicehost/models/compute/server_spec.rb +0 -55
  180. data/spec/slicehost/models/compute/servers_spec.rb +0 -26
@@ -23,19 +23,24 @@ module Fog
23
23
  # * GroupName<~String> -
24
24
  # * Path<~String> -
25
25
  # * 'IsTruncated<~Boolean> - Whether or not results were truncated
26
+ # * 'Marker'<~String> - appears when IsTruncated is true as the next marker to use
26
27
  # * 'RequestId'<~String> - Id of the request
27
- def list_groups
28
- request(
28
+ #
29
+ # ==== See Also
30
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_ListGroups.html
31
+ #
32
+ def list_groups(options = {})
33
+ request({
29
34
  'Action' => 'ListGroups',
30
35
  :parser => Fog::Parsers::AWS::IAM::ListGroups.new
31
- )
36
+ }.merge!(options))
32
37
  end
33
38
 
34
39
  end
35
40
 
36
41
  class Mock
37
42
 
38
- def list_groups
43
+ def list_groups(options = {})
39
44
  Fog::Mock.not_implemented
40
45
  end
41
46
 
@@ -0,0 +1,44 @@
1
+ module Fog
2
+ module AWS
3
+ class IAM
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/iam/basic'
7
+
8
+ # Add or update a policy for a group
9
+ #
10
+ # ==== Parameters
11
+ # * group_name<~String>: name of the group
12
+ # * policy_name<~String>: name of policy document
13
+ # * policy_document<~Hash>: policy document, see: http://docs.amazonwebservices.com/IAM/latest/UserGuide/PoliciesOverview.html
14
+ #
15
+ # ==== Returns
16
+ # * response<~Excon::Response>:
17
+ # * body<~Hash>:
18
+ # * 'RequestId'<~String> - Id of the request def put_group_policy(group_name, path = '/')
19
+ #
20
+ # ==== See Also
21
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_PutGroupPolicy.html
22
+ #
23
+ def put_group_policy(group_name, policy_name, policy_document)
24
+ request(
25
+ 'Action' => 'PutGroupPolicy',
26
+ 'GroupName' => group_name,
27
+ 'PolicyName' => policy_name,
28
+ 'PolicyDocument' => policy_document.to_json,
29
+ :parser => Fog::Parsers::AWS::IAM::Basic.new
30
+ )
31
+ end
32
+
33
+ end
34
+
35
+ class Mock
36
+
37
+ def put_group_policy(group_name, policy_name, policy_document)
38
+ Fog::Mock.not_implemented
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,42 @@
1
+ module Fog
2
+ module AWS
3
+ class IAM
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/iam/basic'
7
+
8
+ # Remove a user from a group
9
+ #
10
+ # ==== Parameters
11
+ # * group_name<~String>: name of the group
12
+ # * user_name<~String>: name of user to remove
13
+ #
14
+ # ==== Returns
15
+ # * response<~Excon::Response>:
16
+ # * body<~Hash>:
17
+ # * 'RequestId'<~String> - Id of the request
18
+ #
19
+ # ==== See Also
20
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_RemoveUserFromGroup.html
21
+ #
22
+ def remove_user_from_group(group_name, user_name)
23
+ request(
24
+ 'Action' => 'RemoveUserFromGroup',
25
+ 'GroupName' => group_name,
26
+ 'UserName' => user_name,
27
+ :parser => Fog::Parsers::AWS::IAM::Basic.new
28
+ )
29
+ end
30
+
31
+ end
32
+
33
+ class Mock
34
+
35
+ def remove_user_from_group(group_name, user_name)
36
+ Fog::Mock.not_implemented
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -54,9 +54,9 @@ module Fog
54
54
  @data[:domains][domain_name][item_name] ||= {}
55
55
  @data[:domains][domain_name][item_name][key.to_s] = [] unless @data[:domains][domain_name][item_name][key.to_s]
56
56
  if options[:replace].include?(key.to_s)
57
- @data[:domains][domain_name][item_name][key.to_s] = [value.to_s]
57
+ @data[:domains][domain_name][item_name][key.to_s] = [*value].map {|x| x.to_s}
58
58
  else
59
- @data[:domains][domain_name][item_name][key.to_s] += [value.to_s]
59
+ @data[:domains][domain_name][item_name][key.to_s] += [*value].map {|x| x.to_s}
60
60
  end
61
61
  end
62
62
  response.status = 200
@@ -0,0 +1,38 @@
1
+ module Fog
2
+ module AWS
3
+ class Storage
4
+ class Real
5
+
6
+ # Abort a multipart upload
7
+ #
8
+ # ==== Parameters
9
+ # * bucket_name<~String> - Name of bucket to abort multipart upload on
10
+ # * object_name<~String> - Name of object to abort multipart upload on
11
+ # * upload_id<~String> - Id of upload to add part to
12
+ #
13
+ # ==== See Also
14
+ # http://docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadAbort.html
15
+ #
16
+ def abort_multipart_upload(bucket_name, object_name, upload_id)
17
+ request({
18
+ :expects => 204,
19
+ :headers => {},
20
+ :host => "#{bucket_name}.#{@host}",
21
+ :method => 'DELETE',
22
+ :path => CGI.escape(object_name),
23
+ :query => {'uploadId' => upload_id}
24
+ })
25
+ end
26
+
27
+ end # Real
28
+
29
+ class Mock # :nodoc:all
30
+
31
+ def abort_multipart_upload(bucket_name, object_name, upload_id)
32
+ Fog::Mock.not_implemented
33
+ end
34
+
35
+ end # Mock
36
+ end # Storage
37
+ end # AWS
38
+ end # Fog
@@ -0,0 +1,60 @@
1
+ module Fog
2
+ module AWS
3
+ class Storage
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/storage/complete_multipart_upload'
7
+
8
+ # Complete a multipart upload
9
+ #
10
+ # ==== Parameters
11
+ # * bucket_name<~String> - Name of bucket to complete multipart upload for
12
+ # * object_name<~String> - Name of object to complete multipart upload for
13
+ # * upload_id<~String> - Id of upload to add part to
14
+ # * parts<~Array>: Array of etags for parts
15
+ # * :etag<~String> - Etag for this part
16
+ #
17
+ # ==== Returns
18
+ # * response<~Excon::Response>:
19
+ # * headers<~Hash>:
20
+ # * 'Bucket'<~String> - bucket of new object
21
+ # * 'ETag'<~String> - etag of new object (will be needed to complete upload)
22
+ # * 'Key'<~String> - key of new object
23
+ # * 'Location'<~String> - location of new object
24
+ #
25
+ # ==== See Also
26
+ # http://docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadComplete.html
27
+ #
28
+ def complete_multipart_upload(bucket_name, object_name, upload_id, parts)
29
+ data = "<CompleteMultipartUpload>"
30
+ parts.each_with_index do |part, index|
31
+ data << "<Part>"
32
+ data << "<PartNumber>#{index + 1}</PartNumber>"
33
+ data << "<ETag>#{part}</ETag>"
34
+ data << "</Part>"
35
+ end
36
+ data << "</CompleteMultipartUpload>"
37
+ request({
38
+ :body => data,
39
+ :expects => 200,
40
+ :headers => { 'Content-Length' => data.length },
41
+ :host => "#{bucket_name}.#{@host}",
42
+ :method => 'POST',
43
+ :parser => Fog::Parsers::AWS::Storage::CompleteMultipartUpload.new,
44
+ :path => CGI.escape(object_name),
45
+ :query => {'uploadId' => upload_id}
46
+ })
47
+ end
48
+
49
+ end # Real
50
+
51
+ class Mock # :nodoc:all
52
+
53
+ def complete_multipart_upload(bucket_name, object_name, upload_id, parts)
54
+ Fog::Mock.not_implemented
55
+ end
56
+
57
+ end # Mock
58
+ end # Storage
59
+ end # AWS
60
+ end # Fog
@@ -19,7 +19,7 @@ module Fog
19
19
  #
20
20
  # ==== See Also
21
21
  # http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTServiceGET.html
22
-
22
+ #
23
23
  def get_service
24
24
  request({
25
25
  :expects => 200,
@@ -0,0 +1,55 @@
1
+ module Fog
2
+ module AWS
3
+ class Storage
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/storage/initiate_multipart_upload'
7
+
8
+ # Initiate a multipart upload to an S3 bucket
9
+ #
10
+ # ==== Parameters
11
+ # * bucket_name<~String> - Name of bucket to create object in
12
+ # * object_name<~String> - Name of object to create
13
+ # * options<~Hash>:
14
+ # * 'Cache-Control'<~String> - Caching behaviour
15
+ # * 'Content-Disposition'<~String> - Presentational information for the object
16
+ # * 'Content-Encoding'<~String> - Encoding of object data
17
+ # * 'Content-MD5'<~String> - Base64 encoded 128-bit MD5 digest of message (defaults to Base64 encoded MD5 of object.read)
18
+ # * 'Content-Type'<~String> - Standard MIME type describing contents (defaults to MIME::Types.of.first)
19
+ # * 'x-amz-acl'<~String> - Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']
20
+ # * "x-amz-meta-#{name}" - Headers to be returned with object, note total size of request without body must be less than 8 KB.
21
+ #
22
+ # ==== Returns
23
+ # * response<~Excon::Response>:
24
+ # * body<~Hash>:
25
+ # * 'Bucket'<~String> - Bucket where upload was initiated
26
+ # * 'Key'<~String> - Object key where the upload was initiated
27
+ # * 'UploadId'<~String> - Id for initiated multipart upload
28
+ #
29
+ # ==== See Also
30
+ # http://docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadInitiate.html
31
+ #
32
+ def initiate_multipart_upload(bucket_name, object_name, options = {})
33
+ request({
34
+ :expects => 200,
35
+ :headers => options,
36
+ :host => "#{bucket_name}.#{@host}",
37
+ :method => 'POST',
38
+ :parser => Fog::Parsers::AWS::Storage::InitiateMultipartUpload.new,
39
+ :path => CGI.escape(object_name),
40
+ :query => {'uploads' => nil}
41
+ })
42
+ end
43
+
44
+ end # Real
45
+
46
+ class Mock # :nodoc:all
47
+
48
+ def initiate_multipart_upload(bucket_name, object_name, options = {})
49
+ Fog::Mock.not_implemented
50
+ end
51
+
52
+ end # Mock
53
+ end # Storage
54
+ end # AWS
55
+ end # Fog
@@ -0,0 +1,68 @@
1
+ module Fog
2
+ module AWS
3
+ class Storage
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/storage/list_multipart_uploads'
7
+
8
+ # List multipart uploads for a bucket
9
+ #
10
+ # ==== Parameters
11
+ # * bucket_name<~String> - Name of bucket to list multipart uploads for
12
+ # * upload_id<~String> - upload id to list objects for
13
+ # * options<~Hash> - config arguments for list. Defaults to {}.
14
+ # * 'key-marker'<~String> - limits parts to only those that appear
15
+ # lexicographically after this key.
16
+ # * 'max-uploads'<~Integer> - limits number of uploads returned
17
+ # * 'upload-id-marker'<~String> - limits uploads to only those that appear
18
+ # lexicographically after this upload id.
19
+ #
20
+ # ==== Returns
21
+ # * response<~Excon::Response>:
22
+ # * body<~Hash>:
23
+ # * 'Bucket'<~string> - Bucket where the multipart upload was initiated
24
+ # * 'IsTruncated'<~Boolean> - Whether or not the listing is truncated
25
+ # * 'KeyMarker'<~String> - first key in list, only upload ids after this lexographically will appear
26
+ # * 'MaxUploads'<~Integer> - Maximum results to return
27
+ # * 'NextKeyMarker'<~String> - last key in list, for further pagination
28
+ # * 'NextUploadIdMarker'<~String> - last key in list, for further pagination
29
+ # * 'Upload'<~Hash>:
30
+ # * 'Initiated'<~Time> - Time when upload was initiated
31
+ # * 'Initiator'<~Hash>:
32
+ # * 'DisplayName'<~String> - Display name of upload initiator
33
+ # * 'ID'<~String> - Id of upload initiator
34
+ # * 'Key'<~String> - Key where multipart upload was initiated
35
+ # * 'Owner'<~Hash>:
36
+ # * 'DisplayName'<~String> - Display name of upload owner
37
+ # * 'ID'<~String> - Id of upload owner
38
+ # * 'StorageClass'<~String> - Storage class of object
39
+ # * 'UploadId'<~String> - upload id of upload containing part
40
+ # * 'UploadIdMarker'<String> - first key in list, only upload ids after this lexographically will appear
41
+ #
42
+ # ==== See Also
43
+ # http://docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadListMPUpload.html
44
+ #
45
+ def list_multipart_uploads(bucket_name, options = {})
46
+ request({
47
+ :expects => 200,
48
+ :headers => {},
49
+ :host => "#{bucket_name}.#{@host}",
50
+ :idempotent => true,
51
+ :method => 'GET',
52
+ :parser => Fog::Parsers::AWS::Storage::ListMultipartUploads.new,
53
+ :query => options.merge!({'uploads' => nil})
54
+ })
55
+ end
56
+
57
+ end
58
+
59
+ class Mock # :nodoc:all
60
+
61
+ def list_multipart_uploads(bucket_name, options = {})
62
+ Fog::Mock.not_implemented
63
+ end
64
+
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,67 @@
1
+ module Fog
2
+ module AWS
3
+ class Storage
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/storage/list_parts'
7
+
8
+ # List parts for a multipart upload
9
+ #
10
+ # ==== Parameters
11
+ # * bucket_name<~String> - Name of bucket to list parts for
12
+ # * object_name<~String> - Name of object to list parts for
13
+ # * upload_id<~String> - upload id to list objects for
14
+ # * options<~Hash> - config arguments for list. Defaults to {}.
15
+ # * 'max-parts'<~Integer> - limits number of parts returned
16
+ # * 'part-number-marker'<~String> - limits parts to only those that appear
17
+ # lexicographically after this part number.
18
+ #
19
+ # ==== Returns
20
+ # * response<~Excon::Response>:
21
+ # * body<~Hash>:
22
+ # * 'Bucket'<~string> - Bucket where the multipart upload was initiated
23
+ # * 'Initiator'<~Hash>:
24
+ # * 'DisplayName'<~String> - Display name of upload initiator
25
+ # * 'ID'<~String> - Id of upload initiator
26
+ # * 'IsTruncated'<~Boolean> - Whether or not the listing is truncated
27
+ # * 'Key'<~String> - Key where multipart upload was initiated
28
+ # * 'MaxParts'<~String> - maximum number of replies alllowed in response
29
+ # * 'NextPartNumberMarker'<~String> - last item in list, for further pagination
30
+ # * 'Part'<~Array>:
31
+ # * 'ETag'<~String> - ETag of part
32
+ # * 'LastModified'<~Timestamp> - Last modified for part
33
+ # * 'PartNumber'<~String> - Part number for part
34
+ # * 'Size'<~Integer> - Size of part
35
+ # * 'PartNumberMarker'<~String> - Part number after which listing begins
36
+ # * 'StorageClass'<~String> - Storage class of object
37
+ # * 'UploadId'<~String> - upload id of upload containing part
38
+ #
39
+ # ==== See Also
40
+ # http://docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadListParts.html
41
+ #
42
+ def list_parts(bucket_name, object_name, upload_id, options = {})
43
+ options['uploadId'] = upload_id
44
+ request({
45
+ :expects => 200,
46
+ :headers => {},
47
+ :host => "#{bucket_name}.#{@host}",
48
+ :idempotent => true,
49
+ :method => 'GET',
50
+ :parser => Fog::Parsers::AWS::Storage::ListParts.new,
51
+ :path => CGI.escape(object_name),
52
+ :query => options.merge!({'uploadId' => upload_id})
53
+ })
54
+ end
55
+
56
+ end
57
+
58
+ class Mock # :nodoc:all
59
+
60
+ def list_parts(bucket_name, object_name, upload_id, options = {})
61
+ Fog::Mock.not_implemented
62
+ end
63
+
64
+ end
65
+ end
66
+ end
67
+ end
@@ -8,13 +8,13 @@ module Fog
8
8
  # ==== Parameters
9
9
  # * bucket_name<~String> - Name of bucket to create object in
10
10
  # * object_name<~String> - Name of object to create
11
- # * data<~File> - File or String to create object from
11
+ # * data<~File||String> - File or String to create object from
12
12
  # * options<~Hash>:
13
13
  # * 'Cache-Control'<~String> - Caching behaviour
14
14
  # * 'Content-Disposition'<~String> - Presentational information for the object
15
15
  # * 'Content-Encoding'<~String> - Encoding of object data
16
16
  # * 'Content-Length'<~String> - Size of object in bytes (defaults to object.read.length)
17
- # * 'Content-MD5'<~String> - Base64 encoded 128-bit MD5 digest of message (defaults to Base64 encoded MD5 of object.read)
17
+ # * 'Content-MD5'<~String> - Base64 encoded 128-bit MD5 digest of message
18
18
  # * 'Content-Type'<~String> - Standard MIME type describing contents (defaults to MIME::Types.of.first)
19
19
  # * 'x-amz-acl'<~String> - Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']
20
20
  # * "x-amz-meta-#{name}" - Headers to be returned with object, note total size of request without body must be less than 8 KB.
@@ -26,7 +26,7 @@ module Fog
26
26
  #
27
27
  # ==== See Also
28
28
  # http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectPUT.html
29
-
29
+ #
30
30
  def put_object(bucket_name, object_name, data, options = {})
31
31
  data = parse_data(data)
32
32
  headers = data[:headers].merge!(options)
@@ -53,15 +53,22 @@ module Fog
53
53
  response = Excon::Response.new
54
54
  if (bucket = @data[:buckets][bucket_name])
55
55
  response.status = 200
56
- bucket[:objects][object_name] = {
56
+ object = {
57
57
  :body => data[:body],
58
+ 'Content-Type' => data[:headers]['Content-Type'],
58
59
  'ETag' => Fog::AWS::Mock.etag,
59
60
  'Key' => object_name,
60
61
  'LastModified' => Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S +0000"),
61
62
  'Size' => data[:headers]['Content-Length'],
62
63
  'StorageClass' => 'STANDARD'
63
64
  }
64
- bucket[:objects][object_name]['Content-Type'] = data[:headers]['Content-Type']
65
+ bucket[:objects][object_name] = object
66
+ response.headers = {
67
+ 'Content-Length' => object['Size'],
68
+ 'Content-Type' => object['Content-Type'],
69
+ 'ETag' => object['ETag'],
70
+ 'Last-Modified' => object['LastModified']
71
+ }
65
72
  else
66
73
  response.status = 404
67
74
  raise(Excon::Errors.status_error({:expects => 200}, response))