1 <?php
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
17
18 namespace OpenCloud\CloudMonitoring\Resource;
19
20 use Guzzle\Http\Exception\ClientErrorResponseException;
21 use OpenCloud\CloudMonitoring\Exception;
22 use OpenCloud\Common\Http\Message\Formatter;
23
24 25 26
27 class Zone extends ReadOnlyResource
28 {
29
30 private $id;
31
32
33 private $country_code;
34
35
36 private $label;
37
38
39 private $source_ips;
40
41 protected static $json_name = false;
42 protected static $json_collection_name = 'values';
43 protected static $url_resource = 'monitoring_zones';
44
45 public function traceroute(array $options)
46 {
47 if (!$this->getId()) {
48 throw new Exception\ZoneException(
49 'Please specify a zone ID'
50 );
51 }
52
53 if (!isset($options['target']) || !isset($options['target_resolver'])) {
54 throw new Exception\ZoneException(
55 'Please specify a "target" and "target_resolver" value'
56 );
57 }
58
59 $params = (object) array(
60 'target' => $options['target'],
61 'target_resolver' => $options['target_resolver']
62 );
63 try {
64 $response = $this->getService()
65 ->getClient()
66 ->post($this->url('traceroute'), self::getJsonHeader(), json_encode($params))
67 ->send();
68
69 $body = Formatter::decode($response);
70
71 return (isset($body->result)) ? $body->result : false;
72 } catch (ClientErrorResponseException $e) {
73 return false;
74 }
75 }
76 }
77