1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17:
18: namespace OpenCloud\CDN\Resource;
19:
20: use OpenCloud\Common\Resource\PersistentResource;
21:
22: 23: 24: 25: 26: 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:
80:
81:
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: 103: 104: 105: 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: