Overview

Namespaces

  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Collection
      • Constants
      • Exceptions
      • Http
        • Message
      • Identity
      • Log
      • Service
    • Compute
      • Constants
      • Exception
      • Resource
    • Database
      • Resource
    • DNS
      • Resource
    • LoadBalancer
      • Resource
    • ObjectStore
      • Constants
      • Exception
      • Resource
      • Upload
    • Orchestration
    • Queues
      • Exception
      • Resource
    • Volume
      • Resource
  • PHP

Classes

  • Service
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
  1: <?php
  2: /**
  3:  * PHP OpenCloud library.
  4:  * 
  5:  * @copyright 2013 Rackspace Hosting, Inc. See LICENSE for information.
  6:  * @license   https://www.apache.org/licenses/LICENSE-2.0
  7:  * @author    Jamie Hannaford <jamie.hannaford@rackspace.com>
  8:  */
  9: 
 10: namespace OpenCloud\CloudMonitoring;
 11: 
 12: use OpenCloud\Common\Service\AbstractService;
 13: use OpenCloud\Common\Http\Message\Formatter;
 14: 
 15: /**
 16:  * Cloud Monitoring service.
 17:  *
 18:  * @package OpenCloud\CloudMonitoring
 19:  * @link    http://docs.rackspace.com/cm/api/v1.0/cm-devguide/content/index.html
 20:  */
 21: class Service extends AbstractService
 22: {
 23:     const DEFAULT_TYPE = 'rax:monitor';
 24:     const DEFAULT_NAME = 'cloudMonitoring';
 25: 
 26:     /**
 27:      * @var array CloudMonitoring resources.
 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:      * Get an agent.
 52:      *
 53:      * @return \OpenCloud\CloudMonitoring\Resource\Agent
 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:      * Return a collection of Entities.
 87:      *
 88:      * @return \OpenCloud\Common\Collection
 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:      * Get either an empty object, or a populated one that exists on the API.
102:      *
103:      * @param null $id
104:      * @return \OpenCloud\CloudMonitoring\Resource\Entity
105:      */
106:     public function getEntity($id = null)
107:     {
108:         return $this->resource('Entity', $id);
109:     }
110: 
111:     /**
112:      * Get a collection of possible check types.
113:      *
114:      * @return \OpenCloud\Common\Collection
115:      */
116:     public function getCheckTypes()
117:     {
118:         return $this->resourceList('CheckType');
119:     }
120: 
121:     /**
122:      * Get a particular check type.
123:      *
124:      * @param null $id
125:      * @return \OpenCloud\CloudMonitoring\Resource\CheckType
126:      */
127:     public function getCheckType($id = null)
128:     {
129:         return $this->resource('CheckType', $id);
130:     }
131: 
132:     /**
133:      * Create a new notification.
134:      *
135:      * @param array $params
136:      * @return
137:      */
138:     public function createNotification(array $params)
139:     {
140:         return $this->getNotification($params)->create();
141:     }
142: 
143:     /**
144:      * Test the parameters of a notification before creating it.
145:      *
146:      * @param array $params
147:      * @return mixed
148:      */
149:     public function testNotification(array $params)
150:     {
151:         return $this->getNotification()->testParams($params);
152:     }
153: 
154:     /**
155:      * Get a particular notification.
156:      *
157:      * @param null $id
158:      * @return \OpenCloud\CloudMonitoring\Resource\Notification
159:      */
160:     public function getNotification($id = null)
161:     {
162:         return $this->resource('Notification', $id);
163:     }
164: 
165:     /**
166:      * Get a collection of Notifications.
167:      *
168:      * @return \OpenCloud\Common\Collection
169:      */
170:     public function getNotifications()
171:     {
172:         return $this->resourceList('Notification');
173:     }
174: 
175:     /**
176:      * Create a new notification plan.
177:      *
178:      * @param array $params
179:      * @return mixed
180:      */
181:     public function createNotificationPlan(array $params)
182:     {
183:         return $this->getNotificationPlan()->create($params);
184:     }
185: 
186:     /**
187:      * Get a particular notification plan.
188:      *
189:      * @param null $id
190:      * @return \OpenCloud\CloudMonitoring\Resource\NotificationPlan
191:      */
192:     public function getNotificationPlan($id = null)
193:     {
194:         return $this->resource('NotificationPlan', $id);
195:     }
196: 
197:     /**
198:      * Get a collection of notification plans.
199:      *
200:      * @return \OpenCloud\Common\Collection
201:      */
202:     public function getNotificationPlans()
203:     {
204:         return $this->resourceList('NotificationPlan');
205:     }
206: 
207:     /**
208:      * Get a particular notification type.
209:      *
210:      * @param null $id
211:      * @return \OpenCloud\CloudMonitoring\Resource\NotificationType
212:      */
213:     public function getNotificationType($id = null)
214:     {
215:         return $this->resource('NotificationType', $id);
216:     }
217: 
218:     /**
219:      * Get a collection of notification types.
220:      *
221:      * @return \OpenCloud\Common\Collection
222:      */
223:     public function getNotificationTypes()
224:     {
225:         return $this->resourceList('NotificationType');
226:     }
227: 
228:     /**
229:      * Get a collection of monitoring zones.
230:      *
231:      * @return \OpenCloud\Common\Collection
232:      */
233:     public function getMonitoringZones()
234:     {
235:         return $this->resourceList('Zone');
236:     }
237: 
238:     /**
239:      * Get a particular monitoring zone.
240:      *
241:      * @param null $id
242:      * @return \OpenCloud\CloudMonitoring\Resource\Zone
243:      */
244:     public function getMonitoringZone($id = null)
245:     {
246:         return $this->resource('Zone', $id);
247:     }
248: 
249:     /**
250:      * Get a changelog - either a general one or one catered for a particular entity.
251:      *
252:      * @param string|null $entityId
253:      * @return object|false
254:      */
255:     public function getChangelog($data = null)
256:     {
257:         // Cater for Collections
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:      * @return object|false
273:      */
274:     public function getViews()
275:     {
276:         return $this->resourceList('View');
277:     }
278: 
279: }
PHP OpenCloud API API documentation generated by ApiGen 2.8.0