      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: /**
     21:  * Entity class.
     22:  */
     23: class Entity extends AbstractResource
     24: {
     25:     /**
     26:      * @var string
     27:      */
     28:     private $id;
     29:
     30:     /**
     31:      * @var string Defines a name for the entity.
     32:      */
     33:     private $label;
     34:
     35:     /**
     36:      * @var string Agent to which this entity is bound to.
     37:      */
     38:     private $agent_id;
     39:
     40:     /**
     41:      * @var array Hash of IP addresses that can be referenced by checks on this entity.
     42:      */
     43:     private $ip_addresses;
     44:
     45:     protected static $json_name = false;
     46:     protected static $url_resource = 'entities';
     47:     protected static $json_collection_name = 'values';
     48:
     49:     protected static $emptyObject = array(
     50:         'label',
     51:         'agent_id',
     52:         'ip_addresses',
     53:         'metadata'
     54:     );
     55:
     56:     protected static $requiredKeys = array(
     57:         'label'
     58:     );
     59:
     60:     public function getChecks()
     61:     {
     62:         return $this->getService()->resourceList('Check', null, $this);
     63:     }
     64:
     65:     public function getCheck($id = null)
     66:     {
     67:         return $this->getService()->resource('Check', $id, $this);
     68:     }
     69:
     70:     public function createCheck(array $params)
     71:     {
     72:         return $this->getCheck()->create($params);
     73:     }
     74:
     75:     public function testNewCheckParams(array $params, $debug = false)
     76:     {
     77:         return $this->getCheck()->testParams($params, $debug);
     78:     }
     79:
     80:     public function createAlarm(array $params)
     81:     {
     82:         return $this->getService()->resource('Alarm', $params, $this)->create();
     83:     }
     84:
     85:     public function testAlarm(array $params)
     86:     {
     87:         return $this->getService()->resource('Alarm', null, $this)->test($params);
     88:     }
     89:
     90:     public function getAlarms()
     91:     {
     92:         return $this->getService()->resourceList('Alarm', null, $this);
     93:     }
     94:
     95:     public function getAlarm($id = null)
     96:     {
     97:         return $this->getService()->resource('Alarm', $id, $this);
     98:     }
     99: }
    100: