1: <?php
2:
3: namespace OpenCloud\CloudMonitoring;
4:
5: use OpenCloud\OpenStack;
6: use OpenCloud\Common\Service as AbstractService;
7:
8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
18: class Service extends AbstractService
19: {
20:
21: 22: 23: 24: 25: 26:
27: private $resources = array(
28: 'Account',
29: 'Agent',
30: 'AgentConnection',
31: 'AgentHost',
32: 'AgentHostInfo',
33: 'AgentTarget',
34: 'AgentToken',
35: 'Alarm',
36: 'Changelog',
37: 'Check',
38: 'CheckType',
39: 'Entity',
40: 'Metric',
41: 'Notification',
42: 'NotificationHistory',
43: 'NotificationPlan',
44: 'NotificationType',
45: 'View',
46: 'Zone'
47: );
48:
49: 50: 51: 52: 53: 54: 55: 56: 57: 58:
59: public function __construct(OpenStack $connection, $serviceName, $serviceRegion, $urlType)
60: {
61: parent::__construct(
62: $connection, 'rax:monitor', $serviceName, $serviceRegion, $urlType
63: );
64: }
65:
66: 67: 68: 69: 70: 71:
72: public function getResources()
73: {
74: return $this->resources;
75: }
76:
77: 78: 79: 80: 81: 82: 83: 84:
85: public function resource($resourceName, $info = null)
86: {
87: $className = __NAMESPACE__ . '\\Resource\\' . ucfirst($resourceName);
88:
89: if (!class_exists($className)) {
90: throw new Exception\ServiceException(sprintf(
91: '%s resource does not exist, please try one of the following: %s',
92: $resourceName,
93: implode(', ', $this->getResources())
94: ));
95: }
96:
97: return new $className($this, $info);
98: }
99:
100: }