Example #1
0
 /**
  * Return an existing CDN-enabled container.
  *
  * @param \stdClass $data Data to initialize container.
  * @return CDNContainer CDN-enabled Container
  */
 public function cdnContainer($data)
 {
     $container = new CDNContainer($this, $data);
     $metadata = new ContainerMetadata();
     $metadata->setArray(array('Streaming-Uri' => $data->cdn_streaming_uri, 'Ios-Uri' => $data->cdn_ios_uri, 'Ssl-Uri' => $data->cdn_ssl_uri, 'Enabled' => $data->cdn_enabled, 'Ttl' => $data->ttl, 'Log-Retention' => $data->log_retention, 'Uri' => $data->cdn_uri));
     $container->setMetadata($metadata);
     return $container;
 }
Example #2
0
 protected function refreshCdnObject()
 {
     try {
         if (null !== ($cdnService = $this->getService()->getCDNService())) {
             $cdn = new CDNContainer($cdnService);
             $cdn->setName($this->name);
             $response = $cdn->createRefreshRequest()->send();
             if ($response->isSuccessful()) {
                 $this->cdn = $cdn;
                 $this->cdn->setMetadata($response->getHeaders(), true);
             }
         } else {
             $this->cdn = null;
         }
     } catch (ClientErrorResponseException $e) {
     }
 }
Example #3
0
 public function isCdnEnabled()
 {
     return $this->cdn instanceof CDNContainer && $this->cdn->isCdnEnabled();
 }
Example #4
0
 /**
  * Returns the service associated with this object
  *
  * It's actually the object's container's service, so this method will
  * simplify things a bit.
  */
 private function getService()
 {
     return $this->container->getService();
 }
Example #5
0
 /**
  * Refreshes, then associates the CDN container
  */
 public function refresh($id = null, $url = null)
 {
     parent::refresh($id, $url);
     // @codeCoverageIgnoreStart
     if ($this->getService() instanceof CDNService) {
         return;
     }
     if (null !== ($cdn = $this->getService()->CDN())) {
         try {
             $this->cdn = new CDNContainer($cdn, $this->name);
         } catch (Exceptions\ContainerNotFoundError $e) {
             $this->cdn = new CDNContainer($cdn);
             $this->cdn->name = $this->name;
         }
     }
     // @codeCoverageIgnoreEnd
 }
Example #6
0
 public function refresh($id = null, $url = null)
 {
     $headers = $this->createRefreshRequest()->send()->getHeaders();
     $this->setMetadata($headers, true);
     try {
         $cdn = new CDNContainer($this->getService()->getCDNService());
         $cdn->setName($this->name);
         $response = $cdn->createRefreshRequest()->send();
         if ($response->isSuccessful()) {
             $this->cdn = $cdn;
             $this->cdn->setMetadata($response->getHeaders(), true);
         }
     } catch (ClientErrorResponseException $e) {
     }
 }