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

  • AbstractResource
  • Agent
  • AgentConnection
  • AgentHost
  • AgentHostInfo
  • AgentTarget
  • AgentToken
  • Alarm
  • Changelog
  • Check
  • CheckType
  • Entity
  • Metric
  • Notification
  • NotificationHistory
  • NotificationPlan
  • NotificationType
  • ReadonlyResource
  • View
  • Zone
  • 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    Glen Campbell <glen.campbell@rackspace.com>
 8:  * @author    Jamie Hannaford <jamie.hannaford@rackspace.com>
 9:  */
10: 
11: namespace OpenCloud\CloudMonitoring\Resource;
12: 
13: use OpenCloud\CloudMonitoring\Exception;
14: use OpenCloud\Common\Http\Message\Formatter;
15: 
16: /**
17:  * Agent class.
18:  */
19: class Agent extends ReadOnlyResource
20: {
21:     /**
22:      * Agent IDs are user specified strings that are a maximum of 255 characters and can contain letters, numbers,
23:      * dashes and dots.
24:      *
25:      * @var string
26:      */
27:     private $id;
28: 
29:     /**
30:      * @var int UTC timestamp of last connection.
31:      */
32:     private $last_connected;
33:     
34:     protected static $json_name = false;
35:     protected static $json_collection_name = 'values';
36:     protected static $url_resource = 'agents';
37: 
38:     /**
39:      * @return mixed
40:      * @throws \OpenCloud\CloudMonitoring\Exception\AgentException
41:      */
42:     public function getConnections()
43:     {
44:         if (!$this->getId()) {
45:             throw new Exception\AgentException(
46:                'Please specify an "ID" value'
47:             );
48:         }
49: 
50:         return $this->getService()->resourceList('AgentConnection', $this->getUrl('connections'));
51:     }
52: 
53:     /**
54:      * @param $connectionId
55:      * @return mixed
56:      * @throws \OpenCloud\CloudMonitoring\Exception\AgentException
57:      */
58:     public function getConnection($connectionId)
59:     {
60:         if (!$this->getId()) {
61:             throw new Exception\AgentException(
62:                'Please specify an "ID" value'
63:             );
64:         }
65:         
66:         $url = clone $this->getUrl();
67:         $url->addPath('connections')->addPath($connectionId);
68: 
69:         $response = $this->getClient()->get($url)->send();
70:         $body = Formatter::decode($response);
71: 
72:         return $this->getService()->resource('AgentConnection', $body);
73:     }
74:     
75: }
PHP OpenCloud API API documentation generated by ApiGen 2.8.0