1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17:
18: namespace OpenCloud\CloudMonitoring;
19:
20: use OpenCloud\Common\Service\CatalogService;
21:
22: 23: 24: 25: 26: 27:
28: class Service extends CatalogService
29: {
30: const DEFAULT_TYPE = 'rax:monitor';
31: const DEFAULT_NAME = 'cloudMonitoring';
32:
33: protected $regionless = true;
34:
35: 36: 37:
38: protected $resources = array(
39: 'Agent',
40: 'AgentConnection',
41: 'AgentHost',
42: 'AgentHostInfo',
43: 'AgentTarget',
44: 'AgentToken',
45: 'Alarm',
46: 'Changelog',
47: 'Check',
48: 'CheckType',
49: 'Entity',
50: 'Metric',
51: 'Notification',
52: 'NotificationHistory',
53: 'NotificationPlan',
54: 'NotificationType',
55: 'View',
56: 'Zone'
57: );
58:
59: 60: 61: 62: 63: 64:
65: public function getAgent($id = null)
66: {
67: return $this->resource('Agent', $id);
68: }
69:
70: public function getAgents()
71: {
72: return $this->resourceList('Agent');
73: }
74:
75: public function getAgentHost($id = null)
76: {
77: return $this->resource('AgentHost', $id);
78: }
79:
80: public function getAgentTargets()
81: {
82: return $this->resourceList('AgentTarget');
83: }
84:
85: public function getAgentToken($id = null)
86: {
87: return $this->resource('AgentToken', $id);
88: }
89:
90: public function getAgentTokens()
91: {
92: return $this->resourceList('AgentToken');
93: }
94:
95: 96: 97: 98: 99:
100: public function getEntities()
101: {
102: return $this->resourceList('Entity');
103: }
104:
105: public function createEntity(array $params)
106: {
107: return $this->getEntity()->create($params);
108: }
109:
110: 111: 112: 113: 114: 115:
116: public function getEntity($id = null)
117: {
118: return $this->resource('Entity', $id);
119: }
120:
121: 122: 123: 124: 125:
126: public function getCheckTypes()
127: {
128: return $this->resourceList('CheckType');
129: }
130:
131: 132: 133: 134: 135: 136:
137: public function getCheckType($id = null)
138: {
139: return $this->resource('CheckType', $id);
140: }
141:
142: 143: 144: 145: 146: 147:
148: public function createNotification(array $params)
149: {
150: return $this->getNotification($params)->create();
151: }
152:
153: 154: 155: 156: 157: 158:
159: public function testNotification(array $params)
160: {
161: return $this->getNotification()->testParams($params);
162: }
163:
164: 165: 166: 167: 168: 169:
170: public function getNotification($id = null)
171: {
172: return $this->resource('Notification', $id);
173: }
174:
175: 176: 177: 178: 179:
180: public function getNotifications()
181: {
182: return $this->resourceList('Notification');
183: }
184:
185: 186: 187: 188: 189: 190:
191: public function createNotificationPlan(array $params)
192: {
193: return $this->getNotificationPlan()->create($params);
194: }
195:
196: 197: 198: 199: 200: 201:
202: public function getNotificationPlan($id = null)
203: {
204: return $this->resource('NotificationPlan', $id);
205: }
206:
207: 208: 209: 210: 211:
212: public function getNotificationPlans()
213: {
214: return $this->resourceList('NotificationPlan');
215: }
216:
217: 218: 219: 220: 221: 222:
223: public function getNotificationType($id = null)
224: {
225: return $this->resource('NotificationType', $id);
226: }
227:
228: 229: 230: 231: 232:
233: public function getNotificationTypes()
234: {
235: return $this->resourceList('NotificationType');
236: }
237:
238: 239: 240: 241: 242:
243: public function getMonitoringZones()
244: {
245: return $this->resourceList('Zone');
246: }
247:
248: 249: 250: 251: 252: 253:
254: public function getMonitoringZone($id = null)
255: {
256: return $this->resource('Zone', $id);
257: }
258:
259: 260: 261: 262: 263: 264:
265: public function getChangelog($data = null)
266: {
267:
268: if (is_object($data)) {
269: return $this->resource('Changelog', $data);
270: }
271:
272: $url = $this->resource('Changelog')->getUrl();
273:
274: if ($data) {
275: $url->setQuery(array('entityId' => (string) $data));
276: }
277:
278: return $this->resourceList('Changelog', $url);
279: }
280:
281: 282: 283:
284: public function getViews()
285: {
286: return $this->resourceList('View');
287: }
288: }
289: