Overview
  • Namespace
  • Class

Namespaces

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

Classes

  • OpenCloud\Volume\Resource\Snapshot
  • OpenCloud\Volume\Resource\Volume
  • OpenCloud\Volume\Resource\VolumeType
 1 <?php
 2 /**
 3  * Copyright 2012-2014 Rackspace US, Inc.
 4  *
 5  * Licensed under the Apache License, Version 2.0 (the "License");
 6  * you may not use this file except in compliance with the License.
 7  * You may obtain a copy of the License at
 8  *
 9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 namespace OpenCloud\CloudMonitoring\Resource;
19 
20 use OpenCloud\CloudMonitoring\Exception;
21 use OpenCloud\Common\Http\Message\Formatter;
22 
23 /**
24  * Agent class.
25  */
26 class Agent extends ReadOnlyResource
27 {
28     /**
29      * Agent IDs are user specified strings that are a maximum of 255 characters and can contain letters, numbers,
30      * dashes and dots.
31      *
32      * @var string
33      */
34     private $id;
35 
36     /**
37      * @var int UTC timestamp of last connection.
38      */
39     private $last_connected;
40 
41     protected static $json_name = false;
42     protected static $json_collection_name = 'values';
43     protected static $url_resource = 'agents';
44 
45     /**
46      * @return mixed
47      * @throws \OpenCloud\CloudMonitoring\Exception\AgentException
48      */
49     public function getConnections()
50     {
51         if (!$this->getId()) {
52             throw new Exception\AgentException(
53                 'Please specify an "ID" value'
54             );
55         }
56 
57         return $this->getService()->resourceList('AgentConnection', $this->getUrl('connections'));
58     }
59 
60     /**
61      * @param $connectionId
62      * @return mixed
63      * @throws \OpenCloud\CloudMonitoring\Exception\AgentException
64      */
65     public function getConnection($connectionId)
66     {
67         if (!$this->getId()) {
68             throw new Exception\AgentException(
69                 'Please specify an "ID" value'
70             );
71         }
72 
73         $url = clone $this->getUrl();
74         $url->addPath('connections')->addPath($connectionId);
75 
76         $response = $this->getClient()->get($url)->send();
77         $body = Formatter::decode($response);
78 
79         return $this->getService()->resource('AgentConnection', $body);
80     }
81 
82     /**
83      * Retrieves the agent host object responsible for monitoring certain
84      * metrics for an agent.
85      *
86      * @return AgentHost
87      */
88     public function getAgentHost()
89     {
90         return $this->getService()->resource('AgentHost', null, $this);
91     }
92 }
93 
API documentation generated by ApiGen