     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:
    22: /**
    23:  * Agent class.
    24:  */
    25: class AgentHost extends ReadOnlyResource
    26: {
    27:     private $token;
    28:     private $label;
    29:
    30:     protected static $json_name = false;
    31:     protected static $json_collection_name = 'info';
    32:     protected static $url_resource = 'host_info';
    33:
    34:     private $allowedTypes = array(
    35:         'cpus',
    36:         'disks',
    37:         'filesystems',
    38:         'memory',
    39:         'network_interfaces',
    40:         'processes',
    41:         'system',
    42:         'who'
    43:     );
    44:
    45:     public function info($type)
    46:     {
    47:         if (!in_array($type, $this->allowedTypes)) {
    48:             throw new Exception\AgentException(sprintf(
    49:                 'Incorrect info type. Please specify one of the following: %s',
    50:                 implode(', ', $this->allowedTypes)
    51:             ));
    52:         }
    53:
    54:         return $this->getService()->resourceList('AgentHostInfo', $this->getUrl($type), $this);
    55:     }
    56: }
    57: