1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: namespace OpenCloud\CloudMonitoring\Resource;
12:
13: use OpenCloud\CloudMonitoring\Exception;
14: use OpenCloud\Common\Http\Message\Formatter;
15:
16: 17: 18:
19: class AgentTarget extends ReadOnlyResource
20: {
21:
22: private $type = 'agent.filesystem';
23:
24: protected static $json_name = 'targets';
25: protected static $json_collection_name = 'targets';
26: protected static $url_resource = 'targets';
27:
28: protected $allowedTypes = array(
29: 'agent.filesystem',
30: 'agent.memory',
31: 'agent.load_average',
32: 'agent.cpu',
33: 'agent.disk',
34: 'agent.network',
35: 'agent.plugin'
36: );
37:
38: public function getUrl($path = null, array $query = array())
39: {
40: $path = "agent/check_types/{$this->type}/{$this->resourceName()}";
41: return $this->getParent()->getUrl($path);
42: }
43:
44: public function setType($type)
45: {
46: if (!in_array($type, $this->allowedTypes)) {
47: throw new Exception\AgentException(sprintf(
48: 'Incorrect target type. Please specify one of the following: %s',
49: implode(', ', $this->allowedTypes)
50: ));
51: }
52:
53: $this->type = $type;
54: }
55:
56: public function getType()
57: {
58: return $this->type;
59: }
60:
61: }