Overview

Namespaces

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

Classes

  • Flavor
  • Service
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Copyright 2012-2014 Rackspace US, Inc.
  4:  *
  5:  * Licensed under the Apache License, Version 2.0 (the "License");
  6:  * you may not use this file except in compliance with the License.
  7:  * You may obtain a copy of the License at
  8:  *
  9:  * http://www.apache.org/licenses/LICENSE-2.0
 10:  *
 11:  * Unless required by applicable law or agreed to in writing, software
 12:  * distributed under the License is distributed on an "AS IS" BASIS,
 13:  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14:  * See the License for the specific language governing permissions and
 15:  * limitations under the License.
 16:  */
 17: 
 18: namespace OpenCloud\CDN\Resource;
 19: 
 20: use OpenCloud\Common\Resource\PersistentResource;
 21: 
 22: /**
 23:  * A service represents your application that has its content cached to the
 24:  * edge nodes.
 25:  *
 26:  * @package OpenCloud\CDN\Resource
 27:  */
 28: class Service extends PersistentResource
 29: {
 30:     protected static $url_resource = 'services';
 31:     protected static $json_name = 'service';
 32: 
 33:     protected $id;
 34:     protected $name;
 35:     protected $domains;
 36:     protected $origins;
 37:     protected $caching;
 38:     protected $restrictions;
 39:     protected $flavorId;
 40:     protected $status;
 41:     protected $links;
 42:     protected $errors;
 43: 
 44:     protected $aliases = array(
 45:         'flavor_id' => 'flavorId',
 46:         'http_host' => 'httpHost',
 47:         'request_url' => 'requestUrl'
 48:     );
 49: 
 50:     protected $createKeys = array(
 51:         'name',
 52:         'domains',
 53:         'origins',
 54:         'caching',
 55:         'restrictions',
 56:         'flavorId'
 57:     );
 58: 
 59:     protected $updateKeys = array(
 60:         'name',
 61:         'domains',
 62:         'origins',
 63:         'caching',
 64:         'restrictions',
 65:         'flavorId'
 66:     );
 67: 
 68:     public function purgeAssets($assetUrl = null)
 69:     {
 70:         $assetsUrl = $this->assetsUrl();
 71:         if (null === $assetUrl) {
 72:             $assetsUrl->setQuery(array('all' => 'true'));
 73:         } else {
 74:             $assetsUrl->setQuery(array('url' => $assetUrl));
 75:         }
 76: 
 77:         $request = $this->getClient()->delete($assetsUrl);
 78: 
 79:         // This is necessary because the response does not include a body
 80:         // and fails with a 406 Not Acceptable if the default
 81:         // 'Accept: application/json' header is used in the request.
 82:         $request->removeHeader('Accept');
 83: 
 84:         return $request->send();
 85:     }
 86: 
 87:     protected function assetsUrl()
 88:     {
 89:         $url = clone $this->getUrl();
 90:         $url->addPath('assets');
 91: 
 92:         return $url;
 93:     }
 94: 
 95:     protected function createJson()
 96:     {
 97:         $createJson = parent::createJson();
 98:         return $createJson->{self::$json_name};
 99:     }
100: 
101:     /**
102:      * Update this resource
103:      *
104:      * @param array $params
105:      * @return \Guzzle\Http\Message\Response
106:      */
107:     public function update($params = array())
108:     {
109:         $json = $this->generateJsonPatch($params);
110: 
111:         return $this->getClient()
112:             ->patch($this->getUrl(), $this->getPatchHeaders(), $json)
113:             ->send();
114:     }
115: }
116: 
API documentation generated by ApiGen 2.8.0