Module: Fog::CDN::Rackspace::Base
Constant Summary collapse
- URI_HEADERS =
{ "X-Cdn-Ios-Uri" => :ios_uri, "X-Cdn-Uri" => :uri, "X-Cdn-Streaming-Uri" => :streaming_uri, "X-Cdn-Ssl-Uri" => :ssl_uri }.freeze
Instance Method Summary collapse
- #apply_options(options) ⇒ Object
-
#enabled? ⇒ Boolean
Returns true if CDN service is enabled.
- #endpoint_uri(service_endpoint_url = nil) ⇒ Object
-
#publish_container(container, publish = true) ⇒ Hash
Publish container to CDN.
- #region ⇒ Object
- #request_id_header ⇒ Object
- #service_name ⇒ Object
-
#urls(container) ⇒ Hash
Returns hash of urls for container.
Instance Method Details
#apply_options(options) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fog/rackspace/cdn.rb', line 24 def () # api_key and username missing from instance variable sets @rackspace_api_key = [:rackspace_api_key] @rackspace_username = [:rackspace_username] @connection_options = [:connection_options] || {} @rackspace_auth_url = [:rackspace_auth_url] @rackspace_cdn_url = [:rackspace_cdn_url] @rackspace_region = [:rackspace_region] end |
#enabled? ⇒ Boolean
Returns true if CDN service is enabled
49 50 51 |
# File 'lib/fog/rackspace/cdn.rb', line 49 def enabled? @enabled end |
#endpoint_uri(service_endpoint_url = nil) ⇒ Object
53 54 55 |
# File 'lib/fog/rackspace/cdn.rb', line 53 def endpoint_uri(service_endpoint_url=nil) @uri = super(@rackspace_cdn_url || service_endpoint_url, :rackspace_cdn_url) end |
#publish_container(container, publish = true) ⇒ Hash
Publish container to CDN
65 66 67 68 69 70 |
# File 'lib/fog/rackspace/cdn.rb', line 65 def publish_container(container, publish = true) enabled = publish ? 'True' : 'False' response = put_container(container.key, 'X-Cdn-Enabled' => enabled) return {} unless publish urls_from_headers(response.headers) end |
#region ⇒ Object
39 40 41 |
# File 'lib/fog/rackspace/cdn.rb', line 39 def region @rackspace_region end |
#request_id_header ⇒ Object
43 44 45 |
# File 'lib/fog/rackspace/cdn.rb', line 43 def request_id_header "X-Trans-Id" end |
#service_name ⇒ Object
35 36 37 |
# File 'lib/fog/rackspace/cdn.rb', line 35 def service_name :cloudFilesCDN end |
#urls(container) ⇒ Hash
Note:
If unable to find container or container is not published this method will return an empty hash.
Returns hash of urls for container
79 80 81 82 83 84 85 86 87 |
# File 'lib/fog/rackspace/cdn.rb', line 79 def urls(container) begin response = head_container(container.key) return {} unless response.headers['X-Cdn-Enabled'] == 'True' urls_from_headers response.headers rescue Fog::Service::NotFound {} end end |