1: <?php
2:
3: namespace OpenCloud\CloudMonitoring\Resource;
4:
5: use OpenCloud\Common\PersistentObject;
6: use OpenCloud\CloudMonitoring\Exception;
7:
8: 9: 10: 11: 12: 13:
14: class AgentHost extends ReadOnlyResource implements ResourceInterface
15: {
16:
17: public $token;
18: public $label;
19:
20: protected static $json_name = false;
21: protected static $json_collection_name = 'info';
22: protected static $url_resource = 'host_info';
23:
24: private $allowedTypes = array(
25: 'cpus',
26: 'disks',
27: 'filesystems',
28: 'memory',
29: 'network_interfaces',
30: 'processes',
31: 'system',
32: 'who'
33: );
34:
35: public function baseUrl()
36: {
37: return $this->Parent()->Url($this->Parent()->id . '/' . $this->ResourceName());
38: }
39:
40: public function info($type)
41: {
42: if (!in_array($type, $this->allowedTypes)) {
43: throw new Exception\AgentException(sprintf(
44: 'Incorrect info type. Please specify one of the following: %s',
45: implode(', ', $this->allowedTypes)
46: ));
47: }
48:
49: return $this->Service()->Collection(__NAMESPACE__ . '\AgentHostInfo', $this->Url($type));
50: }
51:
52: }