Class: Fog::CDN::Rackspace::Mock
- Inherits:
-
Rackspace::Service
show all
- Includes:
- Base
- Defined in:
- lib/fog/rackspace/cdn.rb,
lib/fog/rackspace/requests/cdn/delete_object.rb,
lib/fog/rackspace/requests/cdn/put_container.rb,
lib/fog/rackspace/requests/cdn/get_containers.rb,
lib/fog/rackspace/requests/cdn/head_container.rb,
lib/fog/rackspace/requests/cdn/post_container.rb
Constant Summary
Constants included
from Base
Base::URI_HEADERS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Base
#apply_options, #enabled?, #endpoint_uri, #publish_container, #region, #request_id_header, #service_name, #urls
#authenticate, #endpoint_uri, #region, #request, #request_without_retry, #service_name, #service_net?
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
114
115
116
117
118
|
# File 'lib/fog/rackspace/cdn.rb', line 114
def initialize(options={})
apply_options(options)
authenticate(options)
@enabled = !! endpoint_uri
end
|
Class Method Details
.data ⇒ Object
104
105
106
107
108
|
# File 'lib/fog/rackspace/cdn.rb', line 104
def self.data
@data ||= Hash.new do |hash, key|
hash[key] = {}
end
end
|
.reset ⇒ Object
110
111
112
|
# File 'lib/fog/rackspace/cdn.rb', line 110
def self.reset
@data = nil
end
|
Instance Method Details
#data ⇒ Object
120
121
122
|
# File 'lib/fog/rackspace/cdn.rb', line 120
def data
self.class.data[@rackspace_username]
end
|
#delete_object(container, object) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/fog/rackspace/requests/cdn/delete_object.rb', line 25
def delete_object(container, object)
response = Excon::Response.new
response.status = 204
response. = {
"Content-Length"=>"0",
"Date"=>"Fri, 01 Feb 2013 21:34:33 GMT",
"X-Trans-Id"=>"tx860f26bd76284a849384c0a467767b57"
}
response.body = ""
response
end
|
#get_containers(options = {}) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/fog/rackspace/requests/cdn/get_containers.rb', line 34
def get_containers(options = {})
response = Excon::Response.new
response.status = 200
response. = {
"Content-Length"=>"4402",
"Date"=>"Fri, 01 Feb 2013 21:16:54 GMT",
"Content-Type"=>"application/json",
"X-Trans-Id"=>"tx6c79ea47300941c49f2291b4d47d4ef5"
}
response.body = [
{ "log_retention"=>false,
"cdn_ios_uri"=>"http://a590286a323fec6aed22-d1e9259b2132e81da48ed3e1e802ef22.iosr.cf1.rackcdn.com",
"ttl"=>3600,
"cdn_enabled"=>true,
"cdn_streaming_uri"=>"http://168e307d41afe64f1a62-d1e9259b2132e81da48ed3e1e802ef22.r2.stream.cf1.rackcdn.com",
"name"=>"brown", "cdn_uri"=>"http://6e8f4bf5125c9c2e4e3a-d1e9259b2132e81da48ed3e1e802ef22.r2.cf1.rackcdn.com",
"cdn_ssl_uri"=>"https://f83cb7d39e0b9ff9581b-d1e9259b2132e81da48ed3e1e802ef22.ssl.cf1.rackcdn.com"
},
{ "log_retention"=>false,
"cdn_ios_uri"=>"http://b141f80caedd02158f10-cf33674d895dc8b8e6e5207fdbd5cae4.iosr.cf1.rackcdn.com",
"ttl"=>5000,
"cdn_enabled"=>false,
"cdn_streaming_uri"=>"http://ea5feee96b8087a3d5e5-cf33674d895dc8b8e6e5207fdbd5cae4.r72.stream.cf1.rackcdn.com",
"name"=>"fogcontainertests", "cdn_uri"=>"http://0115a9de56617a5d5473-cf33674d895dc8b8e6e5207fdbd5cae4.r72.cf1.rackcdn.com",
"cdn_ssl_uri"=>"https://a5df8bd8a418ca88061e-cf33674d895dc8b8e6e5207fdbd5cae4.ssl.cf1.rackcdn.com"
}
]
response
end
|
#head_container(container) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/fog/rackspace/requests/cdn/head_container.rb', line 36
def head_container(container)
raise Fog::Storage::Rackspace::NotFound.new "#{container} not found" unless container == 'fogcontainertests'
response = Excon::Response.new
response.status = 204
response. = {
"X-Cdn-Uri"=>"http://e4bbc22477d80eaf22bd-ca4e4e61e477bbd430e1f5b9dc9a19f5.r53.cf1.rackcdn.com",
"X-Cdn-Ios-Uri"=>"http://3c10ef49037f74416445-ca4e4e61e477bbd430e1f5b9dc9a19f5.iosr.cf1.rackcdn.com",
"X-Cdn-Ssl-Uri"=>"https://b722b8ee248259c37901-ca4e4e61e477bbd430e1f5b9dc9a19f5.ssl.cf1.rackcdn.com",
"X-Log-Retention"=>"False",
"X-Cdn-Enabled"=>"True",
"Content-Length"=>"0",
"Date"=>"Fri, 01 Feb 2013 21:25:57 GMT",
"X-Cdn-Streaming-Uri"=>"http://b82027c64cb4dd03670a-ca4e4e61e477bbd430e1f5b9dc9a19f5.r53.stream.cf1.rackcdn.com",
"X-Ttl"=>"259200",
"X-Trans-Id"=>"txca40ffd0412943608bb3e9656c8b81ef"
}
response.body = ""
response
end
|
#post_container(name, options = {}) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/fog/rackspace/requests/cdn/post_container.rb', line 33
def post_container(name, options = {})
raise Fog::Storage::Rackspace::NotFound.new "#{name} not found" unless name == 'fogcontainertests'
response = Excon::Response.new
response.status = 202
response. = {
"X-Cdn-Uri"=>"http://e4bbc22477d80eaf22bd-ca4e4e61e477bbd430e1f5b9dc9a19f5.r53.cf1.rackcdn.com",
"X-Cdn-Ios-Uri"=>"http://3c10ef49037f74416445-ca4e4e61e477bbd430e1f5b9dc9a19f5.iosr.cf1.rackcdn.com",
"X-Cdn-Ssl-Uri"=>"https://b722b8ee248259c37901-ca4e4e61e477bbd430e1f5b9dc9a19f5.ssl.cf1.rackcdn.com",
"Content-Length"=>"58", "Date"=>"Fri, 01 Feb 2013 21:31:30 GMT",
"Content-Type"=>"text/plain; charset=UTF-8",
"X-Cdn-Streaming-Uri"=>"http://b82027c64cb4dd03670a-ca4e4e61e477bbd430e1f5b9dc9a19f5.r53.stream.cf1.rackcdn.com",
"X-Trans-Id"=>"tx4a3206e63dfc446bb5b60e34a62f749d"
}
response.body = "202 Accepted\n\nThe request is accepted for processing.\n\n "
response
end
|
#purge(object) ⇒ Object
124
125
126
127
|
# File 'lib/fog/rackspace/cdn.rb', line 124
def purge(object)
return true if object.is_a? Fog::Storage::Rackspace::File
raise Fog::Errors::NotImplemented.new("#{object.class} does not support CDN purging") if object
end
|
#put_container(name, options = {}) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/fog/rackspace/requests/cdn/put_container.rb', line 33
def put_container(name, options = {})
response = Excon::Response.new
response.status = 201
response. = {
"X-Cdn-Uri"=>"http://e4bbc22477d80eaf22bd-ca4e4e61e477bbd430e1f5b9dc9a19f5.r53.cf1.rackcdn.com",
"X-Cdn-Ios-Uri"=>"http://3c10ef49037f74416445-ca4e4e61e477bbd430e1f5b9dc9a19f5.iosr.cf1.rackcdn.com",
"X-Cdn-Ssl-Uri"=>"https://b722b8ee248259c37901-ca4e4e61e477bbd430e1f5b9dc9a19f5.ssl.cf1.rackcdn.com",
"Content-Length"=>"18",
"Date"=>"Fri, 01 Feb 2013 21:21:45 GMT",
"Content-Type"=>"text/plain; charset=UTF-8",
"X-Cdn-Streaming-Uri"=>"http://b82027c64cb4dd03670a-ca4e4e61e477bbd430e1f5b9dc9a19f5.r53.stream.cf1.rackcdn.com",
"X-Trans-Id"=>"tx1b41ec63189f4862baa65e0c08711772"
}
response.body = "201 Created\n\n\n\n "
response
end
|
#reset_data ⇒ Object
129
130
131
|
# File 'lib/fog/rackspace/cdn.rb', line 129
def reset_data
self.class.data.delete(@rackspace_username)
end
|