1: <?php
2:
3: namespace Saklient\Cloud\Resources;
4:
5: require_once __DIR__ . "/../../../Saklient/Cloud/Client.php";
6: use \Saklient\Cloud\Client;
7: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Resource.php";
8: use \Saklient\Cloud\Resources\Resource;
9: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Swytch.php";
10: use \Saklient\Cloud\Resources\Swytch;
11: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Ipv4Range.php";
12: use \Saklient\Cloud\Resources\Ipv4Range;
13: require_once __DIR__ . "/../../../Saklient/Util.php";
14: use \Saklient\Util;
15: require_once __DIR__ . "/../../../Saklient/Errors/SaklientException.php";
16: use \Saklient\Errors\SaklientException;
17:
18: 19: 20: 21: 22: 23: 24: 25: 26: 27:
28: class Ipv4Net extends Resource {
29:
30: 31: 32: 33: 34: 35: 36:
37: protected $m_id;
38:
39: 40: 41: 42: 43: 44: 45:
46: protected $m_address;
47:
48: 49: 50: 51: 52: 53: 54:
55: protected $m_maskLen;
56:
57: 58: 59: 60: 61: 62: 63:
64: protected $m_defaultRoute;
65:
66: 67: 68: 69: 70: 71: 72:
73: protected $m_nextHop;
74:
75: 76: 77: 78: 79: 80:
81: protected $_range;
82:
83: 84: 85: 86: 87:
88: public function get_range()
89: {
90: return $this->_range;
91: }
92:
93:
94:
95: 96: 97: 98: 99: 100:
101: protected function _apiPath()
102: {
103: return "/subnet";
104: }
105:
106: 107: 108: 109: 110: 111:
112: protected function _rootKey()
113: {
114: return "Subnet";
115: }
116:
117: 118: 119: 120: 121: 122:
123: protected function _rootKeyM()
124: {
125: return "Subnets";
126: }
127:
128: 129: 130: 131: 132: 133:
134: public function _className()
135: {
136: return "Ipv4Net";
137: }
138:
139: 140: 141: 142: 143: 144:
145: public function _id()
146: {
147: return $this->get_id();
148: }
149:
150: 151: 152: 153: 154: 155:
156: public function reload()
157: {
158: return $this->_reload();
159: }
160:
161: 162: 163: 164: 165: 166: 167:
168: public function __construct(\Saklient\Cloud\Client $client, $obj, $wrapped=false)
169: {
170: parent::__construct($client);
171: Util::validateArgCount(func_num_args(), 2);
172: Util::validateType($client, "\\Saklient\\Cloud\\Client");
173: Util::validateType($wrapped, "boolean");
174: $this->apiDeserialize($obj, $wrapped);
175: }
176:
177: 178: 179: 180: 181: 182: 183: 184:
185: protected function _onAfterApiDeserialize($r, $root)
186: {
187: Util::validateArgCount(func_num_args(), 2);
188: $this->_range = null;
189: $addresses = $r->{"IPAddresses"};
190: if ($addresses != null) {
191: $this->_range = new Ipv4Range($addresses);
192: }
193: }
194:
195: 196: 197: 198: 199:
200: private $n_id = false;
201:
202: 203: 204: 205: 206: 207: 208:
209: private function get_id()
210: {
211: return $this->m_id;
212: }
213:
214:
215:
216: 217: 218: 219: 220:
221: private $n_address = false;
222:
223: 224: 225: 226: 227: 228: 229:
230: private function get_address()
231: {
232: return $this->m_address;
233: }
234:
235:
236:
237: 238: 239: 240: 241:
242: private $n_maskLen = false;
243:
244: 245: 246: 247: 248: 249: 250:
251: private function get_maskLen()
252: {
253: return $this->m_maskLen;
254: }
255:
256:
257:
258: 259: 260: 261: 262:
263: private $n_defaultRoute = false;
264:
265: 266: 267: 268: 269: 270: 271:
272: private function get_defaultRoute()
273: {
274: return $this->m_defaultRoute;
275: }
276:
277:
278:
279: 280: 281: 282: 283:
284: private $n_nextHop = false;
285:
286: 287: 288: 289: 290: 291: 292:
293: private function get_nextHop()
294: {
295: return $this->m_nextHop;
296: }
297:
298:
299:
300: 301: 302: 303: 304: 305: 306:
307: protected function apiDeserializeImpl($r)
308: {
309: Util::validateArgCount(func_num_args(), 1);
310: $this->isNew = $r == null;
311: if ($this->isNew) {
312: $r = (object)[];
313: }
314: $this->isIncomplete = false;
315: if (Util::existsPath($r, "ID")) {
316: $this->m_id = Util::getByPath($r, "ID") == null ? null : "" . Util::getByPath($r, "ID");
317: }
318: else {
319: $this->m_id = null;
320: $this->isIncomplete = true;
321: }
322: $this->n_id = false;
323: if (Util::existsPath($r, "NetworkAddress")) {
324: $this->m_address = Util::getByPath($r, "NetworkAddress") == null ? null : "" . Util::getByPath($r, "NetworkAddress");
325: }
326: else {
327: $this->m_address = null;
328: $this->isIncomplete = true;
329: }
330: $this->n_address = false;
331: if (Util::existsPath($r, "NetworkMaskLen")) {
332: $this->m_maskLen = Util::getByPath($r, "NetworkMaskLen") == null ? null : intval("" . Util::getByPath($r, "NetworkMaskLen"));
333: }
334: else {
335: $this->m_maskLen = null;
336: $this->isIncomplete = true;
337: }
338: $this->n_maskLen = false;
339: if (Util::existsPath($r, "DefaultRoute")) {
340: $this->m_defaultRoute = Util::getByPath($r, "DefaultRoute") == null ? null : "" . Util::getByPath($r, "DefaultRoute");
341: }
342: else {
343: $this->m_defaultRoute = null;
344: $this->isIncomplete = true;
345: }
346: $this->n_defaultRoute = false;
347: if (Util::existsPath($r, "NextHop")) {
348: $this->m_nextHop = Util::getByPath($r, "NextHop") == null ? null : "" . Util::getByPath($r, "NextHop");
349: }
350: else {
351: $this->m_nextHop = null;
352: $this->isIncomplete = true;
353: }
354: $this->n_nextHop = false;
355: }
356:
357: 358: 359: 360: 361: 362:
363: protected function apiSerializeImpl($withClean=false)
364: {
365: Util::validateType($withClean, "boolean");
366: $ret = (object)[];
367: if ($withClean || $this->n_id) {
368: Util::setByPath($ret, "ID", $this->m_id);
369: }
370: if ($withClean || $this->n_address) {
371: Util::setByPath($ret, "NetworkAddress", $this->m_address);
372: }
373: if ($withClean || $this->n_maskLen) {
374: Util::setByPath($ret, "NetworkMaskLen", $this->m_maskLen);
375: }
376: if ($withClean || $this->n_defaultRoute) {
377: Util::setByPath($ret, "DefaultRoute", $this->m_defaultRoute);
378: }
379: if ($withClean || $this->n_nextHop) {
380: Util::setByPath($ret, "NextHop", $this->m_nextHop);
381: }
382: return $ret;
383: }
384:
385: 386: 387:
388: public function __get($key) {
389: switch ($key) {
390: case "range": return $this->get_range();
391: case "id": return $this->get_id();
392: case "address": return $this->get_address();
393: case "maskLen": return $this->get_maskLen();
394: case "defaultRoute": return $this->get_defaultRoute();
395: case "nextHop": return $this->get_nextHop();
396: default: return parent::__get($key);
397: }
398: }
399:
400: }
401:
402: