fog 1.12.1 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. data/.travis.yml +1 -1
  2. data/Gemfile +5 -0
  3. data/Rakefile +14 -4
  4. data/bin/fog +22 -0
  5. data/changelog.txt +262 -0
  6. data/fog.gemspec +8 -4
  7. data/lib/fog/aws.rb +11 -0
  8. data/lib/fog/aws/auto_scaling.rb +15 -18
  9. data/lib/fog/aws/beanstalk.rb +8 -10
  10. data/lib/fog/aws/cloud_formation.rb +9 -12
  11. data/lib/fog/aws/compute.rb +8 -10
  12. data/lib/fog/aws/credential_fetcher.rb +6 -6
  13. data/lib/fog/aws/elasticache.rb +13 -17
  14. data/lib/fog/aws/elb.rb +29 -31
  15. data/lib/fog/aws/iam.rb +10 -13
  16. data/lib/fog/aws/models/auto_scaling/group.rb +6 -3
  17. data/lib/fog/aws/models/compute/spot_request.rb +1 -11
  18. data/lib/fog/aws/models/rds/log_file.rb +26 -0
  19. data/lib/fog/aws/models/rds/log_files.rb +50 -0
  20. data/lib/fog/aws/models/rds/server.rb +3 -1
  21. data/lib/fog/aws/models/rds/snapshot.rb +1 -0
  22. data/lib/fog/aws/models/rds/snapshots.rb +20 -13
  23. data/lib/fog/aws/parsers/rds/db_parser.rb +1 -1
  24. data/lib/fog/aws/parsers/rds/describe_db_log_files.rb +44 -0
  25. data/lib/fog/aws/parsers/rds/download_db_logfile_portion.rb +26 -0
  26. data/lib/fog/aws/parsers/ses/verify_domain_identity.rb +26 -0
  27. data/lib/fog/aws/parsers/storage/complete_multipart_upload.rb +1 -1
  28. data/lib/fog/aws/parsers/sts/assume_role.rb +30 -0
  29. data/lib/fog/aws/rds.rb +27 -14
  30. data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +8 -0
  31. data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +8 -1
  32. data/lib/fog/aws/requests/compute/create_volume.rb +3 -3
  33. data/lib/fog/aws/requests/rds/create_db_instance.rb +3 -1
  34. data/lib/fog/aws/requests/rds/describe_db_log_files.rb +67 -0
  35. data/lib/fog/aws/requests/rds/download_db_logfile_portion.rb +63 -0
  36. data/lib/fog/aws/requests/ses/send_raw_email.rb +1 -1
  37. data/lib/fog/aws/requests/ses/verify_domain_identity.rb +30 -0
  38. data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +6 -2
  39. data/lib/fog/aws/requests/storage/get_object.rb +1 -1
  40. data/lib/fog/aws/requests/sts/assume_role.rb +46 -0
  41. data/lib/fog/aws/ses.rb +26 -9
  42. data/lib/fog/aws/storage.rb +2 -1
  43. data/lib/fog/aws/sts.rb +31 -21
  44. data/lib/fog/bin.rb +0 -1
  45. data/lib/fog/bin/openstack.rb +5 -0
  46. data/lib/fog/brightbox/compute.rb +20 -212
  47. data/lib/fog/brightbox/compute/shared.rb +232 -0
  48. data/lib/fog/brightbox/models/compute/collaboration.rb +43 -0
  49. data/lib/fog/brightbox/models/compute/collaborations.rb +23 -0
  50. data/lib/fog/brightbox/models/compute/user_collaboration.rb +29 -0
  51. data/lib/fog/brightbox/models/compute/user_collaborations.rb +23 -0
  52. data/lib/fog/brightbox/requests/compute/accept_user_collaboration.rb +21 -0
  53. data/lib/fog/brightbox/requests/compute/create_collaboration.rb +23 -0
  54. data/lib/fog/brightbox/requests/compute/delete_collaboration.rb +28 -0
  55. data/lib/fog/brightbox/requests/compute/delete_user_collaboration.rb +28 -0
  56. data/lib/fog/brightbox/requests/compute/destroy_user_collaboration.rb +21 -0
  57. data/lib/fog/brightbox/requests/compute/get_collaboration.rb +21 -0
  58. data/lib/fog/brightbox/requests/compute/get_user_collaboration.rb +21 -0
  59. data/lib/fog/brightbox/requests/compute/list_collaborations.rb +19 -0
  60. data/lib/fog/brightbox/requests/compute/list_user_collaborations.rb +19 -0
  61. data/lib/fog/brightbox/requests/compute/reject_user_collaboration.rb +21 -0
  62. data/lib/fog/brightbox/requests/compute/resend_collaboration.rb +21 -0
  63. data/lib/fog/cloudsigma/docs/getting_started.md +59 -0
  64. data/lib/fog/core.rb +7 -2
  65. data/lib/fog/core/connection.rb +62 -29
  66. data/lib/fog/core/deprecated/connection.rb +24 -0
  67. data/lib/fog/core/parser.rb +1 -1
  68. data/lib/fog/digitalocean/examples/getting_started.md +1 -1
  69. data/lib/fog/digitalocean/models/compute/server.rb +2 -2
  70. data/lib/fog/google/compute.rb +31 -7
  71. data/lib/fog/google/models/compute/disk.rb +80 -0
  72. data/lib/fog/google/models/compute/disks.rb +28 -0
  73. data/lib/fog/google/models/compute/image.rb +36 -0
  74. data/lib/fog/google/models/compute/server.rb +46 -33
  75. data/lib/fog/google/models/compute/servers.rb +15 -8
  76. data/lib/fog/google/requests/compute/delete_server.rb +5 -2
  77. data/lib/fog/google/requests/compute/get_disk.rb +3 -0
  78. data/lib/fog/google/requests/compute/get_server.rb +7 -1
  79. data/lib/fog/google/requests/compute/insert_disk.rb +8 -2
  80. data/lib/fog/google/requests/compute/insert_server.rb +51 -22
  81. data/lib/fog/google/requests/compute/list_machine_types.rb +3 -2
  82. data/lib/fog/google/requests/storage/get_object.rb +1 -1
  83. data/lib/fog/hp/requests/storage/get_object.rb +1 -1
  84. data/lib/fog/hp/storage.rb +26 -9
  85. data/lib/fog/ibm/requests/compute/create_instance.rb +20 -15
  86. data/lib/fog/internet_archive/requests/storage/get_object.rb +1 -1
  87. data/lib/fog/{core/json.rb → json.rb} +13 -2
  88. data/lib/fog/metering.rb +25 -0
  89. data/lib/fog/openstack.rb +1 -0
  90. data/lib/fog/openstack/metering.rb +215 -0
  91. data/lib/fog/openstack/models/compute/flavors.rb +2 -2
  92. data/lib/fog/openstack/models/compute/metadata.rb +1 -1
  93. data/lib/fog/openstack/models/compute/server.rb +5 -2
  94. data/lib/fog/openstack/models/image/images.rb +1 -1
  95. data/lib/fog/openstack/models/metering/meter.rb +0 -0
  96. data/lib/fog/openstack/models/metering/meters.rb +0 -0
  97. data/lib/fog/openstack/models/metering/resource.rb +24 -0
  98. data/lib/fog/openstack/models/metering/resources.rb +25 -0
  99. data/lib/fog/openstack/models/volume/volume.rb +3 -1
  100. data/lib/fog/openstack/models/volume/volumes.rb +2 -1
  101. data/lib/fog/openstack/network.rb +1 -1
  102. data/lib/fog/openstack/requests/compute/create_flavor.rb +1 -1
  103. data/lib/fog/openstack/requests/compute/create_server.rb +19 -1
  104. data/lib/fog/openstack/requests/compute/detach_volume.rb +2 -1
  105. data/lib/fog/openstack/requests/compute/list_flavors_detail.rb +4 -3
  106. data/lib/fog/openstack/requests/compute/list_security_groups.rb +1 -1
  107. data/lib/fog/openstack/requests/identity/create_tenant.rb +2 -2
  108. data/lib/fog/openstack/requests/metering/get_resource.rb +32 -0
  109. data/lib/fog/openstack/requests/metering/get_samples.rb +55 -0
  110. data/lib/fog/openstack/requests/metering/get_statistics.rb +56 -0
  111. data/lib/fog/openstack/requests/metering/list_meters.rb +50 -0
  112. data/lib/fog/openstack/requests/metering/list_resources.rb +32 -0
  113. data/lib/fog/openstack/requests/volume/create_volume.rb +4 -2
  114. data/lib/fog/rackspace.rb +16 -1
  115. data/lib/fog/rackspace/block_storage.rb +13 -28
  116. data/lib/fog/rackspace/cdn.rb +10 -24
  117. data/lib/fog/rackspace/compute.rb +17 -45
  118. data/lib/fog/rackspace/compute_v2.rb +13 -33
  119. data/lib/fog/rackspace/databases.rb +13 -29
  120. data/lib/fog/rackspace/dns.rb +27 -23
  121. data/lib/fog/rackspace/identity.rb +10 -26
  122. data/lib/fog/rackspace/load_balancers.rb +13 -29
  123. data/lib/fog/rackspace/mock_data.rb +3 -3
  124. data/lib/fog/rackspace/models/compute/server.rb +1 -1
  125. data/lib/fog/rackspace/models/dns/zones.rb +34 -21
  126. data/lib/fog/rackspace/models/identity/users.rb +2 -2
  127. data/lib/fog/rackspace/models/storage/file.rb +1 -0
  128. data/lib/fog/rackspace/requests/dns/list_domains.rb +2 -2
  129. data/lib/fog/rackspace/requests/storage/delete_multiple_objects.rb +75 -0
  130. data/lib/fog/rackspace/requests/storage/delete_static_large_object.rb +50 -0
  131. data/lib/fog/rackspace/requests/storage/get_object.rb +3 -1
  132. data/lib/fog/rackspace/requests/storage/put_dynamic_obj_manifest.rb +44 -0
  133. data/lib/fog/rackspace/requests/storage/put_object_manifest.rb +3 -30
  134. data/lib/fog/rackspace/requests/storage/put_static_obj_manifest.rb +60 -0
  135. data/lib/fog/rackspace/service.rb +43 -1
  136. data/lib/fog/rackspace/storage.rb +25 -43
  137. data/lib/fog/riakcs/provisioning.rb +2 -1
  138. data/lib/fog/riakcs/usage.rb +2 -1
  139. data/lib/fog/vcloud/requests/compute/configure_vm_cpus.rb +1 -1
  140. data/lib/fog/vcloud/requests/compute/configure_vm_memory.rb +1 -1
  141. data/lib/fog/version.rb +1 -1
  142. data/lib/fog/vsphere/requests/compute/get_folder.rb +1 -1
  143. data/lib/fog/xenserver/compute.rb +2 -0
  144. data/lib/fog/xenserver/models/compute/server.rb +9 -7
  145. data/lib/fog/xenserver/requests/compute/snapshot_revert.rb +22 -0
  146. data/lib/fog/xenserver/requests/compute/snapshot_server.rb +22 -0
  147. data/lib/fog/xml.rb +21 -0
  148. data/lib/fog/xml/sax_parser_connection.rb +43 -0
  149. data/lib/tasks/changelog_task.rb +1 -0
  150. data/tests/aws/models/auto_scaling/groups_test.rb +22 -0
  151. data/tests/aws/requests/compute/volume_tests.rb +3 -3
  152. data/tests/aws/requests/rds/helper.rb +14 -0
  153. data/tests/aws/requests/rds/log_file_tests.rb +19 -0
  154. data/tests/aws/requests/ses/verified_domain_identity_tests.rb +16 -0
  155. data/tests/aws/requests/sts/assume_role_tests.rb +19 -0
  156. data/tests/brightbox/requests/compute/collaboration_tests.rb +41 -0
  157. data/tests/brightbox/requests/compute/helper.rb +46 -2
  158. data/tests/brightbox/requests/compute/user_collaboration_tests.rb +67 -0
  159. data/tests/core/connection_tests.rb +26 -0
  160. data/tests/helper.rb +13 -0
  161. data/tests/openstack/requests/metering/meter_tests.rb +52 -0
  162. data/tests/openstack/requests/metering/resource_tests.rb +19 -0
  163. data/tests/openvz/helper.rb +14 -8
  164. data/tests/rackspace/block_storage_tests.rb +9 -0
  165. data/tests/rackspace/compute_tests.rb +9 -0
  166. data/tests/rackspace/compute_v2_tests.rb +9 -0
  167. data/tests/rackspace/databases_tests.rb +9 -0
  168. data/tests/rackspace/dns_tests.rb +20 -0
  169. data/tests/rackspace/helper.rb +12 -1
  170. data/tests/rackspace/identity_tests.rb +25 -0
  171. data/tests/rackspace/load_balancer_tests.rb +10 -0
  172. data/tests/rackspace/models/block_storage/volume_tests.rb +2 -2
  173. data/tests/rackspace/models/compute_v2/metadata_tests.rb +2 -2
  174. data/tests/rackspace/models/compute_v2/server_tests.rb +22 -21
  175. data/tests/rackspace/models/dns/zones_tests.rb +19 -5
  176. data/tests/rackspace/models/storage/file_tests.rb +22 -6
  177. data/tests/rackspace/rackspace_tests.rb +35 -0
  178. data/tests/rackspace/requests/block_storage/snapshot_tests.rb +2 -3
  179. data/tests/rackspace/requests/block_storage/volume_type_tests.rb +4 -11
  180. data/tests/rackspace/requests/compute_v2/address_tests.rb +1 -1
  181. data/tests/rackspace/requests/compute_v2/attachment_tests.rb +8 -9
  182. data/tests/rackspace/requests/compute_v2/flavor_tests.rb +1 -1
  183. data/tests/rackspace/requests/compute_v2/metadata_tests.rb +4 -4
  184. data/tests/rackspace/requests/databases/database_tests.rb +23 -20
  185. data/tests/rackspace/requests/databases/user_tests.rb +6 -6
  186. data/tests/rackspace/requests/identity/user_tests.rb +4 -1
  187. data/tests/rackspace/requests/load_balancers/usage_tests.rb +4 -2
  188. data/tests/rackspace/requests/storage/large_object_tests.rb +303 -59
  189. data/tests/rackspace/requests/storage/object_tests.rb +73 -18
  190. data/tests/rackspace/service_tests.rb +83 -0
  191. data/tests/rackspace/storage_tests.rb +9 -0
  192. data/tests/xenserver/models/compute/server_tests.rb +11 -1
  193. metadata +89 -19
  194. data/tests/core/user_agent_tests.rb +0 -6
@@ -3,6 +3,7 @@ require 'fog/rackspace'
3
3
  module Fog
4
4
  module Rackspace
5
5
  class Identity < Fog::Service
6
+
6
7
  US_ENDPOINT = 'https://identity.api.rackspacecloud.com/v2.0'
7
8
  UK_ENDPOINT = 'https://lon.identity.api.rackspacecloud.com/v2.0'
8
9
 
@@ -33,7 +34,7 @@ module Fog
33
34
  request :update_user
34
35
  request :delete_user
35
36
 
36
- class Mock
37
+ class Mock < Fog::Rackspace::Service
37
38
  attr_reader :service_catalog
38
39
 
39
40
  def request
@@ -41,7 +42,7 @@ module Fog
41
42
  end
42
43
  end
43
44
 
44
- class Real
45
+ class Real < Fog::Rackspace::Service
45
46
  attr_reader :service_catalog, :auth_token
46
47
 
47
48
  def initialize(options={})
@@ -50,36 +51,19 @@ module Fog
50
51
  @rackspace_region = options[:rackspace_region]
51
52
  @rackspace_auth_url = options[:rackspace_auth_url] || US_ENDPOINT
52
53
 
53
- uri = URI.parse(@rackspace_auth_url)
54
- @host = uri.host
55
- @path = uri.path
56
- @port = uri.port
57
- @scheme = uri.scheme
54
+ @uri = URI.parse(@rackspace_auth_url)
55
+ @host = @uri.host
56
+ @path = @uri.path
57
+ @port = @uri.port
58
+ @scheme = @uri.scheme
58
59
  @persistent = options[:persistent] || false
59
60
  @connection_options = options[:connection_options] || {}
60
- @connection = Fog::Connection.new(uri.to_s, @persistent, @connection_options)
61
+ @connection = Fog::Connection.new(@uri.to_s, @persistent, @connection_options)
61
62
 
62
63
  authenticate
63
64
  end
64
65
 
65
- def request(params)
66
- begin
67
- parameters = params.merge!({
68
- :headers => {
69
- 'Content-Type' => 'application/json',
70
- 'Accept' => 'application/json',
71
- 'X-Auth-Token' => @auth_token
72
- },
73
- :host => @host,
74
- :path => "#{@path}/#{params[:path]}"
75
- })
76
- response = @connection.request(parameters)
77
- response.body = Fog::JSON.decode(response.body) unless response.body.empty?
78
- response
79
- end
80
- end
81
-
82
- def authenticate
66
+ def authenticate(options={})
83
67
  data = self.create_token(@rackspace_username, @rackspace_api_key).body
84
68
  @service_catalog = ServiceCatalog.from_response(self, data)
85
69
  @auth_token = data['access']['token']['id']
@@ -119,41 +119,25 @@ module Fog
119
119
  @connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
120
120
  end
121
121
 
122
- def request(params)
123
- #TODO - Unify code with other rackspace services
124
- begin
125
- response = @connection.request(params.merge!({
126
- :headers => {
127
- 'Content-Type' => 'application/json',
128
- 'Accept' => 'application/json',
129
- 'X-Auth-Token' => auth_token
130
- }.merge!(params[:headers] || {}),
131
- :host => endpoint_uri.host,
132
- :path => "#{endpoint_uri.path}/#{params[:path]}"
133
- }))
134
- rescue Excon::Errors::NotFound => error
135
- raise NotFound.slurp(error, region)
136
- rescue Excon::Errors::BadRequest => error
137
- raise BadRequest.slurp error
138
- rescue Excon::Errors::InternalServerError => error
139
- raise InternalServerError.slurp error
140
- rescue Excon::Errors::HTTPStatusError => error
141
- raise ServiceError.slurp error
142
- end
143
- unless response.body.empty?
144
- response.body = Fog::JSON.decode(response.body)
145
- end
146
- response
122
+ def request(params, parse_json = true, &block)
123
+ super(params, parse_json, &block)
124
+ rescue Excon::Errors::NotFound => error
125
+ raise NotFound.slurp(error, region)
126
+ rescue Excon::Errors::BadRequest => error
127
+ raise BadRequest.slurp error
128
+ rescue Excon::Errors::InternalServerError => error
129
+ raise InternalServerError.slurp error
130
+ rescue Excon::Errors::HTTPStatusError => error
131
+ raise ServiceError.slurp error
147
132
  end
148
133
 
149
- def authenticate
150
- options = {
134
+ def authenticate(options={})
135
+ super({
151
136
  :rackspace_api_key => @rackspace_api_key,
152
137
  :rackspace_username => @rackspace_username,
153
138
  :rackspace_auth_url => @rackspace_auth_url,
154
139
  :connection_options => @connection_options
155
- }
156
- super(options)
140
+ })
157
141
  end
158
142
 
159
143
  def service_name
@@ -14,7 +14,7 @@ module Fog
14
14
  network_id = Fog::Rackspace::MockData.uuid
15
15
 
16
16
  flavor = {
17
- "OS-FLV-DISABLED:disabled" => false,
17
+ "OS-FLV-EXT-DATA:ephemeral" => 4,
18
18
  "disk" => 20,
19
19
  "id" => flavor_id,
20
20
  "links" => [
@@ -89,8 +89,8 @@ module Fog
89
89
  }
90
90
 
91
91
  #Block Storage
92
- volume_type1_id = Fog::Mock.random_numbers(3).to_i
93
- volume_type2_id = Fog::Mock.random_numbers(3).to_i
92
+ volume_type1_id = Fog::Mock.random_numbers(3).to_s
93
+ volume_type2_id = Fog::Mock.random_numbers(3).to_s
94
94
 
95
95
  volume_type1 = {
96
96
  "id" => volume_type1_id,
@@ -65,7 +65,7 @@ module Fog
65
65
  true
66
66
  end
67
67
 
68
- def save
68
+ def save(options = {})
69
69
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
70
70
  requires :flavor_id, :image_id
71
71
  options = {
@@ -6,6 +6,8 @@ module Fog
6
6
  class Rackspace
7
7
  class Zones < Fog::Collection
8
8
 
9
+ attribute :total_entries, :aliases => "totalEntries"
10
+
9
11
  model Fog::DNS::Rackspace::Zone
10
12
 
11
13
  # List all domains. Return by default a maximum of 100 items
@@ -15,32 +17,27 @@ module Fog
15
17
  # @option options [Integer] :offset starting offset of records to return
16
18
  def all(options={})
17
19
  clear
18
- data = service.list_domains(options).body['domains']
19
- load(data)
20
+ body = service.list_domains(options).body
21
+ merge_attributes(body)
22
+
23
+ load(body['domains'])
20
24
  end
21
25
 
22
26
  alias :each_zone_this_page :each
23
27
  def each
24
- if !block_given?
25
- self
26
- else
27
- body = service.list_domains.body
28
- subset = dup.all
29
-
30
- subset.each_zone_this_page {|f| yield f}
31
- if body.has_key?('links')
32
- while !body['links'].select{|l| l['rel'] == 'next'}.empty?
33
- url = body['links'].select{|l| l['rel'] == 'next'}.first['href']
34
- query = url.match(/\?(.+)/)
35
- parsed = CGI.parse($1)
36
-
37
- body = service.list_domains(:offset => parsed['offset'], :limit => parsed['limit']).body
38
- subset = dup.all(:offset => parsed['offset'], :limit => parsed['limit'])
39
- subset.each_zone_this_page {|f| yield f}
40
- end
41
- end
42
- self
28
+ return self unless block_given?
29
+
30
+ params = { :limit => 100} # prime loop (100 Records is default page size for Rackspace Cloud)
31
+ while params
32
+ body = service.list_domains(params).body
33
+ subset = dup.load(body["domains"])
34
+ self.merge_attributes(body)
35
+
36
+ params = next_params(body)
37
+
38
+ subset.each_zone_this_page {|zone| yield zone}
43
39
  end
40
+ self
44
41
  end
45
42
 
46
43
  def get(zone_id)
@@ -56,7 +53,23 @@ module Fog
56
53
  rescue Fog::Rackspace::Errors::ServiceUnavailable
57
54
  nil
58
55
  end
56
+
57
+ private
58
+ def next_params(body)
59
+ # return if we don't have any links
60
+ return nil unless body && body['links']
61
+
62
+ #return if links don't contain a href for the next page
63
+ next_link = body['links'].find {|h| h['rel'] == 'next'}
64
+ return nil unless next_link && next_link['href']
65
+
66
+ url = next_link['href']
67
+ uri = URI.parse url
68
+ return nil unless uri.query
69
+ CGI.parse uri.query
70
+ end
59
71
  end
72
+
60
73
  end
61
74
  end
62
75
  end
@@ -18,7 +18,7 @@ module Fog
18
18
  new(data)
19
19
  rescue Excon::Errors::NotFound
20
20
  nil
21
- rescue Excon::Errors::NotAuthorized
21
+ rescue Excon::Errors::Unauthorized
22
22
  nil
23
23
  end
24
24
 
@@ -27,7 +27,7 @@ module Fog
27
27
  new(data)
28
28
  rescue Excon::Errors::NotFound
29
29
  nil
30
- rescue Excon::Errors::NotAuthorized
30
+ rescue Excon::Errors::Unauthorized
31
31
  nil
32
32
  end
33
33
  end
@@ -227,6 +227,7 @@ module Fog
227
227
  options['Access-Control-Allow-Origin'] = access_control_allow_origin if access_control_allow_origin
228
228
  options['Origin'] = origin if origin
229
229
  options['Content-Disposition'] = content_disposition if content_disposition
230
+ options['Etag'] = etag if etag
230
231
  options.merge!(metadata.to_headers)
231
232
 
232
233
  data = service.put_object(directory.key, key, body, options)
@@ -5,8 +5,8 @@ module Fog
5
5
  def list_domains(options={})
6
6
 
7
7
  path = 'domains'
8
- if !options.empty?
9
- path = path + '?' + array_to_query_string(options)
8
+ unless options.empty?
9
+ path += "?#{array_to_query_string(options)}"
10
10
  end
11
11
 
12
12
  request(
@@ -0,0 +1,75 @@
1
+ module Fog
2
+ module Storage
3
+ class Rackspace
4
+ class Real
5
+
6
+ # Deletes multiple objects or containers with a single request.
7
+ #
8
+ # To delete objects from a single container, +container+ may be provided
9
+ # and +object_names+ should be an Array of object names within the container.
10
+ #
11
+ # To delete objects from multiple containers or delete containers,
12
+ # +container+ should be +nil+ and all +object_names+ should be prefixed with a container name.
13
+ #
14
+ # Containers must be empty when deleted. +object_names+ are processed in the order given,
15
+ # so objects within a container should be listed first to empty the container.
16
+ #
17
+ # Up to 10,000 objects may be deleted in a single request.
18
+ # The server will respond with +200 OK+ for all requests.
19
+ # +response.body+ must be inspected for actual results.
20
+ #
21
+ # @example Delete objects from a container
22
+ # object_names = ['object', 'another/object']
23
+ # conn.delete_multiple_objects('my_container', object_names)
24
+ #
25
+ # @example Delete objects from multiple containers
26
+ # object_names = ['container_a/object', 'container_b/object']
27
+ # conn.delete_multiple_objects(nil, object_names)
28
+ #
29
+ # @example Delete a container and all it's objects
30
+ # object_names = ['my_container/object_a', 'my_container/object_b', 'my_container']
31
+ # conn.delete_multiple_objects(nil, object_names)
32
+ #
33
+ # @param container [String,nil] Name of container.
34
+ # @param object_names [Array<String>] Object names to be deleted.
35
+ # @param options [Hash] Additional request headers.
36
+ #
37
+ # @return [Excon::Response]
38
+ # * body [Hash] - Results of the operation.
39
+ # * "Number Not Found" [Integer] - Number of missing objects or containers.
40
+ # * "Response Status" [String] - Response code for the subrequest of the last failed operation.
41
+ # * "Errors" [Array<object_name, response_status>]
42
+ # * object_name [String] - Object that generated an error when the delete was attempted.
43
+ # * response_status [String] - Response status from the subrequest for object_name.
44
+ # * "Number Deleted" [Integer] - Number of objects or containers deleted.
45
+ # * "Response Body" [String] - Response body for "Response Status".
46
+ #
47
+ # @raise [Fog::Storage::Rackspace::NotFound] HTTP 404
48
+ # @raise [Fog::Storage::Rackspace::BadRequest] HTTP 400
49
+ # @raise [Fog::Storage::Rackspace::InternalServerError] HTTP 500
50
+ # @raise [Fog::Storage::Rackspace::ServiceError]
51
+ # @raise [Excon::Errors::Unauthorized] HTTP 401
52
+ #
53
+ # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Bulk_Delete-d1e2338.html
54
+ def delete_multiple_objects(container, object_names, options = {})
55
+ body = object_names.map do |name|
56
+ object_name = container ? "#{ container }/#{ name }" : name
57
+ URI.encode(object_name)
58
+ end.join("\n")
59
+
60
+ response = request({
61
+ :expects => 200,
62
+ :method => 'DELETE',
63
+ :headers => options.merge('Content-Type' => 'text/plain',
64
+ 'Accept' => 'application/json'),
65
+ :body => body,
66
+ :query => { 'bulk-delete' => true }
67
+ }, false)
68
+ response.body = Fog::JSON.decode(response.body)
69
+ response
70
+ end
71
+
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,50 @@
1
+ module Fog
2
+ module Storage
3
+ class Rackspace
4
+ class Real
5
+
6
+ # Delete a static large object.
7
+ #
8
+ # Deletes the SLO manifest +object+ and all segments that it references.
9
+ # The server will respond with +200 OK+ for all requests.
10
+ # +response.body+ must be inspected for actual results.
11
+ #
12
+ # @param container [String] Name of container.
13
+ # @param object [String] Name of the SLO manifest object.
14
+ # @param options [Hash] Additional request headers.
15
+ #
16
+ # @return [Excon::Response]
17
+ # * body [Hash] - Results of the operation.
18
+ # * "Number Not Found" [Integer] - Number of missing segments.
19
+ # * "Response Status" [String] - Response code for the subrequest of the last failed operation.
20
+ # * "Errors" [Array<object_name, response_status>]
21
+ # * object_name [String] - Object that generated an error when the delete was attempted.
22
+ # * response_status [String] - Response status from the subrequest for object_name.
23
+ # * "Number Deleted" [Integer] - Number of segments deleted.
24
+ # * "Response Body" [String] - Response body for Response Status.
25
+ #
26
+ # @raise [Fog::Storage::Rackspace::NotFound] HTTP 404
27
+ # @raise [Fog::Storage::Rackspace::BadRequest] HTTP 400
28
+ # @raise [Fog::Storage::Rackspace::InternalServerError] HTTP 500
29
+ # @raise [Fog::Storage::Rackspace::ServiceError]
30
+ # @raise [Excon::Errors::Unauthorized] HTTP 401
31
+ #
32
+ # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Deleting_a_Large_Object-d1e2228.html
33
+ def delete_static_large_object(container, object, options = {})
34
+ response = request({
35
+ :expects => 200,
36
+ :method => 'DELETE',
37
+ :headers => options.merge('Content-Type' => 'text/plain',
38
+ 'Accept' => 'application/json'),
39
+ :path => "#{Fog::Rackspace.escape(container)}/#{Fog::Rackspace.escape(object)}",
40
+ :query => { 'multipart-manifest' => 'delete' }
41
+ }, false)
42
+ response.body = Fog::JSON.decode(response.body)
43
+ response
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+ end
50
+
@@ -23,7 +23,9 @@ module Fog
23
23
  :expects => 200,
24
24
  :method => 'GET',
25
25
  :path => "#{Fog::Rackspace.escape(container)}/#{Fog::Rackspace.escape(object)}"
26
- }), false)
26
+ }),
27
+ false,
28
+ &block)
27
29
  end
28
30
 
29
31
  end
@@ -0,0 +1,44 @@
1
+ module Fog
2
+ module Storage
3
+ class Rackspace
4
+ class Real
5
+
6
+ # Create a new dynamic large object manifest
7
+ #
8
+ # Creates an object with a +X-Object-Manifest+ header that specifies the common prefix ("<container>/<prefix>")
9
+ # for all uploaded segments. Retrieving the manifest object streams all segments matching this prefix.
10
+ # Segments must sort in the order they should be concatenated. Note that any future objects stored in the container
11
+ # along with the segments that match the prefix will be included when retrieving the manifest object.
12
+ #
13
+ # All segments must be stored in the same container, but may be in a different container than the manifest object.
14
+ # The default +X-Object-Manifest+ header is set to "+container+/+object+", but may be overridden in +options+
15
+ # to specify the prefix and/or the container where segments were stored.
16
+ # If overridden, names should be CGI escaped (excluding spaces) if needed (see {Fog::Rackspace.escape}).
17
+ #
18
+ # @param container [String] Name for container where +object+ will be stored. Should be < 256 bytes and must not contain '/'
19
+ # @param object [String] Name for manifest object.
20
+ # @param options [Hash] Config headers for +object+.
21
+ # @option options [String] 'X-Object-Manifest' ("container/object") "<container>/<prefix>" for segment objects.
22
+ #
23
+ # @raise [Fog::Storage::Rackspace::NotFound] HTTP 404
24
+ # @raise [Fog::Storage::Rackspace::BadRequest] HTTP 400
25
+ # @raise [Fog::Storage::Rackspace::InternalServerError] HTTP 500
26
+ # @raise [Fog::Storage::Rackspace::ServiceError]
27
+ # @raise [Excon::Errors::Unauthorized]
28
+ #
29
+ # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Large_Object_Creation-d1e2019.html
30
+ def put_dynamic_obj_manifest(container, object, options = {})
31
+ path = "#{Fog::Rackspace.escape(container)}/#{Fog::Rackspace.escape(object)}"
32
+ headers = {'X-Object-Manifest' => path}.merge(options)
33
+ request(
34
+ :expects => 201,
35
+ :headers => headers,
36
+ :method => 'PUT',
37
+ :path => path
38
+ )
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end