fog 1.12.1 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -1
- data/Gemfile +5 -0
- data/Rakefile +14 -4
- data/bin/fog +22 -0
- data/changelog.txt +262 -0
- data/fog.gemspec +8 -4
- data/lib/fog/aws.rb +11 -0
- data/lib/fog/aws/auto_scaling.rb +15 -18
- data/lib/fog/aws/beanstalk.rb +8 -10
- data/lib/fog/aws/cloud_formation.rb +9 -12
- data/lib/fog/aws/compute.rb +8 -10
- data/lib/fog/aws/credential_fetcher.rb +6 -6
- data/lib/fog/aws/elasticache.rb +13 -17
- data/lib/fog/aws/elb.rb +29 -31
- data/lib/fog/aws/iam.rb +10 -13
- data/lib/fog/aws/models/auto_scaling/group.rb +6 -3
- data/lib/fog/aws/models/compute/spot_request.rb +1 -11
- data/lib/fog/aws/models/rds/log_file.rb +26 -0
- data/lib/fog/aws/models/rds/log_files.rb +50 -0
- data/lib/fog/aws/models/rds/server.rb +3 -1
- data/lib/fog/aws/models/rds/snapshot.rb +1 -0
- data/lib/fog/aws/models/rds/snapshots.rb +20 -13
- data/lib/fog/aws/parsers/rds/db_parser.rb +1 -1
- data/lib/fog/aws/parsers/rds/describe_db_log_files.rb +44 -0
- data/lib/fog/aws/parsers/rds/download_db_logfile_portion.rb +26 -0
- data/lib/fog/aws/parsers/ses/verify_domain_identity.rb +26 -0
- data/lib/fog/aws/parsers/storage/complete_multipart_upload.rb +1 -1
- data/lib/fog/aws/parsers/sts/assume_role.rb +30 -0
- data/lib/fog/aws/rds.rb +27 -14
- data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +8 -0
- data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +8 -1
- data/lib/fog/aws/requests/compute/create_volume.rb +3 -3
- data/lib/fog/aws/requests/rds/create_db_instance.rb +3 -1
- data/lib/fog/aws/requests/rds/describe_db_log_files.rb +67 -0
- data/lib/fog/aws/requests/rds/download_db_logfile_portion.rb +63 -0
- data/lib/fog/aws/requests/ses/send_raw_email.rb +1 -1
- data/lib/fog/aws/requests/ses/verify_domain_identity.rb +30 -0
- data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +6 -2
- data/lib/fog/aws/requests/storage/get_object.rb +1 -1
- data/lib/fog/aws/requests/sts/assume_role.rb +46 -0
- data/lib/fog/aws/ses.rb +26 -9
- data/lib/fog/aws/storage.rb +2 -1
- data/lib/fog/aws/sts.rb +31 -21
- data/lib/fog/bin.rb +0 -1
- data/lib/fog/bin/openstack.rb +5 -0
- data/lib/fog/brightbox/compute.rb +20 -212
- data/lib/fog/brightbox/compute/shared.rb +232 -0
- data/lib/fog/brightbox/models/compute/collaboration.rb +43 -0
- data/lib/fog/brightbox/models/compute/collaborations.rb +23 -0
- data/lib/fog/brightbox/models/compute/user_collaboration.rb +29 -0
- data/lib/fog/brightbox/models/compute/user_collaborations.rb +23 -0
- data/lib/fog/brightbox/requests/compute/accept_user_collaboration.rb +21 -0
- data/lib/fog/brightbox/requests/compute/create_collaboration.rb +23 -0
- data/lib/fog/brightbox/requests/compute/delete_collaboration.rb +28 -0
- data/lib/fog/brightbox/requests/compute/delete_user_collaboration.rb +28 -0
- data/lib/fog/brightbox/requests/compute/destroy_user_collaboration.rb +21 -0
- data/lib/fog/brightbox/requests/compute/get_collaboration.rb +21 -0
- data/lib/fog/brightbox/requests/compute/get_user_collaboration.rb +21 -0
- data/lib/fog/brightbox/requests/compute/list_collaborations.rb +19 -0
- data/lib/fog/brightbox/requests/compute/list_user_collaborations.rb +19 -0
- data/lib/fog/brightbox/requests/compute/reject_user_collaboration.rb +21 -0
- data/lib/fog/brightbox/requests/compute/resend_collaboration.rb +21 -0
- data/lib/fog/cloudsigma/docs/getting_started.md +59 -0
- data/lib/fog/core.rb +7 -2
- data/lib/fog/core/connection.rb +62 -29
- data/lib/fog/core/deprecated/connection.rb +24 -0
- data/lib/fog/core/parser.rb +1 -1
- data/lib/fog/digitalocean/examples/getting_started.md +1 -1
- data/lib/fog/digitalocean/models/compute/server.rb +2 -2
- data/lib/fog/google/compute.rb +31 -7
- data/lib/fog/google/models/compute/disk.rb +80 -0
- data/lib/fog/google/models/compute/disks.rb +28 -0
- data/lib/fog/google/models/compute/image.rb +36 -0
- data/lib/fog/google/models/compute/server.rb +46 -33
- data/lib/fog/google/models/compute/servers.rb +15 -8
- data/lib/fog/google/requests/compute/delete_server.rb +5 -2
- data/lib/fog/google/requests/compute/get_disk.rb +3 -0
- data/lib/fog/google/requests/compute/get_server.rb +7 -1
- data/lib/fog/google/requests/compute/insert_disk.rb +8 -2
- data/lib/fog/google/requests/compute/insert_server.rb +51 -22
- data/lib/fog/google/requests/compute/list_machine_types.rb +3 -2
- data/lib/fog/google/requests/storage/get_object.rb +1 -1
- data/lib/fog/hp/requests/storage/get_object.rb +1 -1
- data/lib/fog/hp/storage.rb +26 -9
- data/lib/fog/ibm/requests/compute/create_instance.rb +20 -15
- data/lib/fog/internet_archive/requests/storage/get_object.rb +1 -1
- data/lib/fog/{core/json.rb → json.rb} +13 -2
- data/lib/fog/metering.rb +25 -0
- data/lib/fog/openstack.rb +1 -0
- data/lib/fog/openstack/metering.rb +215 -0
- data/lib/fog/openstack/models/compute/flavors.rb +2 -2
- data/lib/fog/openstack/models/compute/metadata.rb +1 -1
- data/lib/fog/openstack/models/compute/server.rb +5 -2
- data/lib/fog/openstack/models/image/images.rb +1 -1
- data/lib/fog/openstack/models/metering/meter.rb +0 -0
- data/lib/fog/openstack/models/metering/meters.rb +0 -0
- data/lib/fog/openstack/models/metering/resource.rb +24 -0
- data/lib/fog/openstack/models/metering/resources.rb +25 -0
- data/lib/fog/openstack/models/volume/volume.rb +3 -1
- data/lib/fog/openstack/models/volume/volumes.rb +2 -1
- data/lib/fog/openstack/network.rb +1 -1
- data/lib/fog/openstack/requests/compute/create_flavor.rb +1 -1
- data/lib/fog/openstack/requests/compute/create_server.rb +19 -1
- data/lib/fog/openstack/requests/compute/detach_volume.rb +2 -1
- data/lib/fog/openstack/requests/compute/list_flavors_detail.rb +4 -3
- data/lib/fog/openstack/requests/compute/list_security_groups.rb +1 -1
- data/lib/fog/openstack/requests/identity/create_tenant.rb +2 -2
- data/lib/fog/openstack/requests/metering/get_resource.rb +32 -0
- data/lib/fog/openstack/requests/metering/get_samples.rb +55 -0
- data/lib/fog/openstack/requests/metering/get_statistics.rb +56 -0
- data/lib/fog/openstack/requests/metering/list_meters.rb +50 -0
- data/lib/fog/openstack/requests/metering/list_resources.rb +32 -0
- data/lib/fog/openstack/requests/volume/create_volume.rb +4 -2
- data/lib/fog/rackspace.rb +16 -1
- data/lib/fog/rackspace/block_storage.rb +13 -28
- data/lib/fog/rackspace/cdn.rb +10 -24
- data/lib/fog/rackspace/compute.rb +17 -45
- data/lib/fog/rackspace/compute_v2.rb +13 -33
- data/lib/fog/rackspace/databases.rb +13 -29
- data/lib/fog/rackspace/dns.rb +27 -23
- data/lib/fog/rackspace/identity.rb +10 -26
- data/lib/fog/rackspace/load_balancers.rb +13 -29
- data/lib/fog/rackspace/mock_data.rb +3 -3
- data/lib/fog/rackspace/models/compute/server.rb +1 -1
- data/lib/fog/rackspace/models/dns/zones.rb +34 -21
- data/lib/fog/rackspace/models/identity/users.rb +2 -2
- data/lib/fog/rackspace/models/storage/file.rb +1 -0
- data/lib/fog/rackspace/requests/dns/list_domains.rb +2 -2
- data/lib/fog/rackspace/requests/storage/delete_multiple_objects.rb +75 -0
- data/lib/fog/rackspace/requests/storage/delete_static_large_object.rb +50 -0
- data/lib/fog/rackspace/requests/storage/get_object.rb +3 -1
- data/lib/fog/rackspace/requests/storage/put_dynamic_obj_manifest.rb +44 -0
- data/lib/fog/rackspace/requests/storage/put_object_manifest.rb +3 -30
- data/lib/fog/rackspace/requests/storage/put_static_obj_manifest.rb +60 -0
- data/lib/fog/rackspace/service.rb +43 -1
- data/lib/fog/rackspace/storage.rb +25 -43
- data/lib/fog/riakcs/provisioning.rb +2 -1
- data/lib/fog/riakcs/usage.rb +2 -1
- data/lib/fog/vcloud/requests/compute/configure_vm_cpus.rb +1 -1
- data/lib/fog/vcloud/requests/compute/configure_vm_memory.rb +1 -1
- data/lib/fog/version.rb +1 -1
- data/lib/fog/vsphere/requests/compute/get_folder.rb +1 -1
- data/lib/fog/xenserver/compute.rb +2 -0
- data/lib/fog/xenserver/models/compute/server.rb +9 -7
- data/lib/fog/xenserver/requests/compute/snapshot_revert.rb +22 -0
- data/lib/fog/xenserver/requests/compute/snapshot_server.rb +22 -0
- data/lib/fog/xml.rb +21 -0
- data/lib/fog/xml/sax_parser_connection.rb +43 -0
- data/lib/tasks/changelog_task.rb +1 -0
- data/tests/aws/models/auto_scaling/groups_test.rb +22 -0
- data/tests/aws/requests/compute/volume_tests.rb +3 -3
- data/tests/aws/requests/rds/helper.rb +14 -0
- data/tests/aws/requests/rds/log_file_tests.rb +19 -0
- data/tests/aws/requests/ses/verified_domain_identity_tests.rb +16 -0
- data/tests/aws/requests/sts/assume_role_tests.rb +19 -0
- data/tests/brightbox/requests/compute/collaboration_tests.rb +41 -0
- data/tests/brightbox/requests/compute/helper.rb +46 -2
- data/tests/brightbox/requests/compute/user_collaboration_tests.rb +67 -0
- data/tests/core/connection_tests.rb +26 -0
- data/tests/helper.rb +13 -0
- data/tests/openstack/requests/metering/meter_tests.rb +52 -0
- data/tests/openstack/requests/metering/resource_tests.rb +19 -0
- data/tests/openvz/helper.rb +14 -8
- data/tests/rackspace/block_storage_tests.rb +9 -0
- data/tests/rackspace/compute_tests.rb +9 -0
- data/tests/rackspace/compute_v2_tests.rb +9 -0
- data/tests/rackspace/databases_tests.rb +9 -0
- data/tests/rackspace/dns_tests.rb +20 -0
- data/tests/rackspace/helper.rb +12 -1
- data/tests/rackspace/identity_tests.rb +25 -0
- data/tests/rackspace/load_balancer_tests.rb +10 -0
- data/tests/rackspace/models/block_storage/volume_tests.rb +2 -2
- data/tests/rackspace/models/compute_v2/metadata_tests.rb +2 -2
- data/tests/rackspace/models/compute_v2/server_tests.rb +22 -21
- data/tests/rackspace/models/dns/zones_tests.rb +19 -5
- data/tests/rackspace/models/storage/file_tests.rb +22 -6
- data/tests/rackspace/rackspace_tests.rb +35 -0
- data/tests/rackspace/requests/block_storage/snapshot_tests.rb +2 -3
- data/tests/rackspace/requests/block_storage/volume_type_tests.rb +4 -11
- data/tests/rackspace/requests/compute_v2/address_tests.rb +1 -1
- data/tests/rackspace/requests/compute_v2/attachment_tests.rb +8 -9
- data/tests/rackspace/requests/compute_v2/flavor_tests.rb +1 -1
- data/tests/rackspace/requests/compute_v2/metadata_tests.rb +4 -4
- data/tests/rackspace/requests/databases/database_tests.rb +23 -20
- data/tests/rackspace/requests/databases/user_tests.rb +6 -6
- data/tests/rackspace/requests/identity/user_tests.rb +4 -1
- data/tests/rackspace/requests/load_balancers/usage_tests.rb +4 -2
- data/tests/rackspace/requests/storage/large_object_tests.rb +303 -59
- data/tests/rackspace/requests/storage/object_tests.rb +73 -18
- data/tests/rackspace/service_tests.rb +83 -0
- data/tests/rackspace/storage_tests.rb +9 -0
- data/tests/xenserver/models/compute/server_tests.rb +11 -1
- metadata +89 -19
- 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
|
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
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
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-
|
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).
|
93
|
-
volume_type2_id = Fog::Mock.random_numbers(3).
|
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,
|
@@ -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
|
-
|
19
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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::
|
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::
|
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)
|
@@ -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
|
+
|
@@ -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
|