Overview

Namespaces

  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Collection
      • Constants
      • Exceptions
      • Http
        • Message
      • Identity
      • Log
      • Service
    • Compute
      • Constants
      • Exception
      • Resource
    • Database
      • Resource
    • DNS
      • Resource
    • LoadBalancer
      • Resource
    • ObjectStore
      • Constants
      • Exception
      • Resource
      • Upload
    • Orchestration
    • Queues
      • Exception
      • Resource
    • Volume
      • Resource
  • PHP

Classes

  • AbstractContainer
  • AbstractResource
  • Account
  • CDNContainer
  • Container
  • ContainerMetadata
  • DataObject
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
  1: <?php
  2: /**
  3:  * PHP OpenCloud library.
  4:  * 
  5:  * @copyright 2013 Rackspace Hosting, Inc. See LICENSE for information.
  6:  * @license   https://www.apache.org/licenses/LICENSE-2.0
  7:  * @author    Jamie Hannaford <jamie.hannaford@rackspace.com>
  8:  * @author    Glen Campbell <glen.campbell@rackspace.com>
  9:  */
 10: 
 11: namespace OpenCloud\ObjectStore\Resource;
 12: 
 13: /**
 14:  * A container that has been CDN-enabled. Each CDN-enabled container has a unique 
 15:  * Uniform Resource Locator (URL) that can be combined with its object names and 
 16:  * openly distributed in web pages, emails, or other applications.
 17:  */
 18: class CDNContainer extends AbstractContainer
 19: {
 20:     const METADATA_LABEL = 'Cdn';
 21: 
 22:     /**
 23:      * @return null|string|int
 24:      */
 25:     public function getCdnSslUri()
 26:     {
 27:         return $this->metadata->getProperty('Ssl-Uri');
 28:     }
 29: 
 30:     /**
 31:      * @return null|string|int
 32:      */
 33:     public function getCdnUri()
 34:     {
 35:         return $this->metadata->getProperty('Uri');
 36:     }
 37: 
 38:     /**
 39:      * @return null|string|int
 40:      */
 41:     public function getTtl()
 42:     {
 43:         return $this->metadata->getProperty('Ttl');
 44:     }
 45: 
 46:     /**
 47:      * @return null|string|int
 48:      */
 49:     public function getCdnStreamingUri()
 50:     {
 51:         return $this->metadata->getProperty('Streaming-Uri');
 52:     }
 53: 
 54:     /**
 55:      * @return null|string|int
 56:      */
 57:     public function getIosStreamingUri()
 58:     {
 59:         return $this->metadata->getProperty('Ios-Uri');
 60:     }
 61: 
 62:     public function refresh($name = null, $url = null)
 63:     {
 64:         $response = $this->createRefreshRequest()->send();
 65: 
 66:         $headers = $response->getHeaders();
 67:         $this->setMetadata($headers, true);
 68: 
 69:         return $headers;  
 70:     }
 71: 
 72:     /**
 73:      * This method will enable your CDN-enabled container to serve out HTML content like a website.
 74:      *
 75:      * @param $indexPage The data object name (i.e. a .html file) that will serve as the main index page.
 76:      * @return \Guzzle\Http\Message\Response
 77:      */
 78:     public function setStaticIndexPage($page)
 79:     {
 80:         $headers = array('X-Container-Meta-Web-Index' => $page);
 81:         return $this->getClient()->post($this->getUrl(), $headers)->send();
 82:     }
 83: 
 84:     /**
 85:      * Set the default error page for your static site.
 86:      *
 87:      * @param $name The data object name (i.e. a .html file) that will serve as the main error page.
 88:      * @return \Guzzle\Http\Message\Response
 89:      */
 90:     public function setStaticErrorPage($page)
 91:     {
 92:         $headers = array('X-Container-Meta-Web-Error' => $page);
 93:         return $this->getClient()->post($this->getUrl(), $headers)->send();
 94:     }
 95: 
 96:     /**
 97:      * Turn on access logs, which track all the web traffic that your data objects accrue.
 98:      *
 99:      * @return \Guzzle\Http\Message\Response
100:      */
101:     public function enableCdnLogging()
102:     {
103:         $headers = array('X-Log-Retention' => 'True');
104:         return $this->getClient()->put($this->getUrl(), $headers)->send();
105:     }
106: 
107:     /**
108:      * Disable access logs.
109:      *
110:      * @return \Guzzle\Http\Message\Response
111:      */
112:     public function disableCdnLogging()
113:     {
114:         $headers = array('X-Log-Retention' => 'False');
115:         return $this->getClient()->put($this->getUrl(), $headers)->send();
116:     }
117:     
118: }
119: 
PHP OpenCloud API API documentation generated by ApiGen 2.8.0