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