Overview

Namespaces

  • None
  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Exceptions
      • Log
      • Request
        • Response
    • Compute
    • Database
    • DNS
    • LoadBalancer
      • Resources
    • ObjectStore
      • Resource
    • Orchestration
    • Volume
  • PHP

Classes

  • Service
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
  1: <?php
  2: 
  3: namespace OpenCloud\CloudMonitoring;
  4: 
  5: use OpenCloud\OpenStack;
  6: use OpenCloud\Common\Service as AbstractService;
  7: 
  8: /**
  9:  * The Rackspace Cloud Monitoring service.
 10:  *
 11:  * @copyright 2012-2013 Rackspace Hosting, Inc.
 12:  *      See COPYING for licensing information
 13:  * @package phpOpenCloud
 14:  * @version 1.0
 15:  * @author  Jamie Hannaford <jamie.hannaford@rackspace.com>
 16:  * @extends AbstractService
 17:  */
 18: class Service extends AbstractService
 19: {
 20: 
 21:     /**
 22:      * Cloud Monitoring resources.
 23:      * 
 24:      * @var     array
 25:      * @access  private
 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:      * Main service constructor.
 51:      * 
 52:      * @access public
 53:      * @param OpenStack $connection
 54:      * @param mixed $serviceName
 55:      * @param mixed $serviceRegion
 56:      * @param mixed $urlType
 57:      * @return void
 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:      * getResources function.
 68:      * 
 69:      * @access public
 70:      * @return void
 71:      */
 72:     public function getResources()
 73:     {
 74:         return $this->resources;
 75:     }
 76: 
 77:     /**
 78:      * Factory method for instantiating resource objects.
 79:      * 
 80:      * @access public
 81:      * @param string $resourceName
 82:      * @param mixed $info (default: null)
 83:      * @return void
 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: }
PHP OpenCloud API API documentation generated by ApiGen 2.8.0