Overview

Namespaces

  • PHP
  • Saklient
    • Cloud
      • Enums
      • Errors
      • Models
      • Resources
    • Errors

Classes

  • Activity
  • Appliance
  • Archive
  • Bridge
  • Disk
  • DiskActivity
  • DiskConfig
  • DiskPlan
  • FtpInfo
  • Icon
  • Iface
  • IfaceActivity
  • Ipv4Net
  • Ipv4Range
  • Ipv6Net
  • IsoImage
  • LbServer
  • LbVirtualIp
  • License
  • LicenseInfo
  • LoadBalancer
  • Region
  • Router
  • RouterActivity
  • RouterPlan
  • Script
  • Server
  • ServerActivity
  • ServerInstance
  • ServerPlan
  • Swytch
  • VpcRouter
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: namespace Saklient\Cloud\Resources;
  4: 
  5: require_once __DIR__ . "/../../../Saklient/Errors/SaklientException.php";
  6: use \Saklient\Errors\SaklientException;
  7: require_once __DIR__ . "/../../../Saklient/Cloud/Client.php";
  8: use \Saklient\Cloud\Client;
  9: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Resource.php";
 10: use \Saklient\Cloud\Resources\Resource;
 11: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Icon.php";
 12: use \Saklient\Cloud\Resources\Icon;
 13: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Router.php";
 14: use \Saklient\Cloud\Resources\Router;
 15: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Ipv4Net.php";
 16: use \Saklient\Cloud\Resources\Ipv4Net;
 17: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Ipv6Net.php";
 18: use \Saklient\Cloud\Resources\Ipv6Net;
 19: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Bridge.php";
 20: use \Saklient\Cloud\Resources\Bridge;
 21: require_once __DIR__ . "/../../../Saklient/Util.php";
 22: use \Saklient\Util;
 23: 
 24: /**
 25:  * スイッチの実体1つに対応し、属性の取得や操作を行うためのクラス。
 26:  * 
 27:  * @property-read string $id ID 
 28:  * @property string $name 名前 
 29:  * @property string $description 説明 
 30:  * @property \ArrayObject $tags タグ文字列の配列 
 31:  * @property \Saklient\Cloud\Resources\Icon $icon アイコン 
 32:  * @property-read string $userDefaultRoute ユーザ設定IPv4ネットワークのゲートウェイ 
 33:  * @property-read int $userMaskLen ユーザ設定IPv4ネットワークのマスク長 
 34:  * @property-read \Saklient\Cloud\Resources\Router $router 接続されているルータ 
 35:  * @property-read \Saklient\Cloud\Resources\Bridge $bridge 接続されているブリッジ 
 36:  * @property-read \ArrayObject $ipv4Nets IPv4ネットワーク(ルータによる自動割当) {@link \Saklient\Cloud\Resources\Ipv4Net} の配列 
 37:  * @property-read \ArrayObject $ipv6Nets IPv6ネットワーク(ルータによる自動割当) {@link \Saklient\Cloud\Resources\Ipv6Net} の配列 
 38:  */
 39: class Swytch extends Resource {
 40:     
 41:     /**
 42:      * ID
 43:      * 
 44:      * @access protected
 45:      * @ignore
 46:      * @var string
 47:      */
 48:     protected $m_id;
 49:     
 50:     /**
 51:      * 名前
 52:      * 
 53:      * @access protected
 54:      * @ignore
 55:      * @var string
 56:      */
 57:     protected $m_name;
 58:     
 59:     /**
 60:      * 説明
 61:      * 
 62:      * @access protected
 63:      * @ignore
 64:      * @var string
 65:      */
 66:     protected $m_description;
 67:     
 68:     /**
 69:      * タグ文字列の配列
 70:      * 
 71:      * @access protected
 72:      * @ignore
 73:      * @var string[]
 74:      */
 75:     protected $m_tags;
 76:     
 77:     /**
 78:      * アイコン
 79:      * 
 80:      * @access protected
 81:      * @ignore
 82:      * @var Icon
 83:      */
 84:     protected $m_icon;
 85:     
 86:     /**
 87:      * ユーザ設定IPv4ネットワークのゲートウェイ
 88:      * 
 89:      * @access protected
 90:      * @ignore
 91:      * @var string
 92:      */
 93:     protected $m_userDefaultRoute;
 94:     
 95:     /**
 96:      * ユーザ設定IPv4ネットワークのマスク長
 97:      * 
 98:      * @access protected
 99:      * @ignore
100:      * @var int
101:      */
102:     protected $m_userMaskLen;
103:     
104:     /**
105:      * 接続されているルータ
106:      * 
107:      * @access protected
108:      * @ignore
109:      * @var Router
110:      */
111:     protected $m_router;
112:     
113:     /**
114:      * 接続されているブリッジ
115:      * 
116:      * @access protected
117:      * @ignore
118:      * @var Bridge
119:      */
120:     protected $m_bridge;
121:     
122:     /**
123:      * IPv4ネットワーク(ルータによる自動割当) {@link \Saklient\Cloud\Resources\Ipv4Net} の配列
124:      * 
125:      * @access protected
126:      * @ignore
127:      * @var Ipv4Net[]
128:      */
129:     protected $m_ipv4Nets;
130:     
131:     /**
132:      * IPv6ネットワーク(ルータによる自動割当) {@link \Saklient\Cloud\Resources\Ipv6Net} の配列
133:      * 
134:      * @access protected
135:      * @ignore
136:      * @var Ipv6Net[]
137:      */
138:     protected $m_ipv6Nets;
139:     
140:     /**
141:      * @private
142:      * @access protected
143:      * @ignore
144:      * @return string
145:      */
146:     protected function _apiPath()
147:     {
148:         return "/switch";
149:     }
150:     
151:     /**
152:      * @private
153:      * @access protected
154:      * @ignore
155:      * @return string
156:      */
157:     protected function _rootKey()
158:     {
159:         return "Switch";
160:     }
161:     
162:     /**
163:      * @private
164:      * @access protected
165:      * @ignore
166:      * @return string
167:      */
168:     protected function _rootKeyM()
169:     {
170:         return "Switches";
171:     }
172:     
173:     /**
174:      * @private
175:      * @access public
176:      * @ignore
177:      * @return string
178:      */
179:     public function _className()
180:     {
181:         return "Swytch";
182:     }
183:     
184:     /**
185:      * @private
186:      * @access public
187:      * @ignore
188:      * @return string
189:      */
190:     public function _id()
191:     {
192:         return $this->get_id();
193:     }
194:     
195:     /**
196:      * このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し、新規作成または上書き保存します。
197:      * 
198:      * @access public
199:      * @return \Saklient\Cloud\Resources\Swytch this
200:      */
201:     public function save()
202:     {
203:         return $this->_save();
204:     }
205:     
206:     /**
207:      * 最新のリソース情報を再取得します。
208:      * 
209:      * @access public
210:      * @return \Saklient\Cloud\Resources\Swytch this
211:      */
212:     public function reload()
213:     {
214:         return $this->_reload();
215:     }
216:     
217:     /**
218:      * @ignore
219:      * @access public
220:      * @param \Saklient\Cloud\Client $client
221:      * @param mixed $obj
222:      * @param boolean $wrapped=false
223:      */
224:     public function __construct(\Saklient\Cloud\Client $client, $obj, $wrapped=false)
225:     {
226:         parent::__construct($client);
227:         Util::validateArgCount(func_num_args(), 2);
228:         Util::validateType($client, "\\Saklient\\Cloud\\Client");
229:         Util::validateType($wrapped, "boolean");
230:         $this->apiDeserialize($obj, $wrapped);
231:     }
232:     
233:     /**
234:      * このルータ+スイッチでIPv6アドレスを有効にします。
235:      * 
236:      * @access public
237:      * @return \Saklient\Cloud\Resources\Ipv6Net 有効化されたIPv6ネットワーク
238:      */
239:     public function addIpv6Net()
240:     {
241:         $ret = $this->get_router()->addIpv6Net();
242:         $this->reload();
243:         return $ret;
244:     }
245:     
246:     /**
247:      * このルータ+スイッチでIPv6アドレスを無効にします。
248:      * 
249:      * @access public
250:      * @return \Saklient\Cloud\Resources\Swytch this
251:      */
252:     public function removeIpv6Net()
253:     {
254:         $nets = $this->get_ipv6Nets();
255:         $this->get_router()->removeIpv6Net($nets[0]);
256:         $this->reload();
257:         return $this;
258:     }
259:     
260:     /**
261:      * このルータ+スイッチにスタティックルートを追加します。
262:      * 
263:      * @access public
264:      * @param int $maskLen
265:      * @param string $nextHop
266:      * @return \Saklient\Cloud\Resources\Ipv4Net 追加されたIPv4ネットワーク
267:      */
268:     public function addStaticRoute($maskLen, $nextHop)
269:     {
270:         Util::validateArgCount(func_num_args(), 2);
271:         Util::validateType($maskLen, "int");
272:         Util::validateType($nextHop, "string");
273:         $ret = $this->get_router()->addStaticRoute($maskLen, $nextHop);
274:         $this->reload();
275:         return $ret;
276:     }
277:     
278:     /**
279:      * このルータ+スイッチからスタティックルートを削除します。
280:      * 
281:      * @access public
282:      * @param \Saklient\Cloud\Resources\Ipv4Net $ipv4Net
283:      * @return \Saklient\Cloud\Resources\Swytch this
284:      */
285:     public function removeStaticRoute(\Saklient\Cloud\Resources\Ipv4Net $ipv4Net)
286:     {
287:         Util::validateArgCount(func_num_args(), 1);
288:         Util::validateType($ipv4Net, "\\Saklient\\Cloud\\Resources\\Ipv4Net");
289:         $this->get_router()->removeStaticRoute($ipv4Net);
290:         $this->reload();
291:         return $this;
292:     }
293:     
294:     /**
295:      * このルータ+スイッチの帯域プランを変更します。
296:      * 
297:      * @access public
298:      * @param int $bandWidthMbps 帯域幅(api.product.router.find() から取得できる {@link RouterPlan} の bandWidthMbps を指定)。
299:      * @return \Saklient\Cloud\Resources\Swytch this
300:      */
301:     public function changePlan($bandWidthMbps)
302:     {
303:         Util::validateArgCount(func_num_args(), 1);
304:         Util::validateType($bandWidthMbps, "int");
305:         $this->get_router()->changePlan($bandWidthMbps);
306:         $this->reload();
307:         return $this;
308:     }
309:     
310:     /**
311:      * このルータ+スイッチをブリッジに接続します。
312:      * 
313:      * @access public
314:      * @param $swytch 接続先のブリッジ。
315:      * @param \Saklient\Cloud\Resources\Bridge $bridge
316:      * @return \Saklient\Cloud\Resources\Swytch this
317:      */
318:     public function connectToBridge(\Saklient\Cloud\Resources\Bridge $bridge)
319:     {
320:         Util::validateArgCount(func_num_args(), 1);
321:         Util::validateType($bridge, "\\Saklient\\Cloud\\Resources\\Bridge");
322:         $result = $this->_client->request("PUT", $this->_apiPath() . "/" . $this->_id() . "/to/bridge/" . $bridge->_id());
323:         $this->reload();
324:         return $this;
325:     }
326:     
327:     /**
328:      * このルータ+スイッチをブリッジから切断します。
329:      * 
330:      * @access public
331:      * @return \Saklient\Cloud\Resources\Swytch this
332:      */
333:     public function disconnectFromBridge()
334:     {
335:         $result = $this->_client->request("DELETE", $this->_apiPath() . "/" . $this->_id() . "/to/bridge");
336:         $this->reload();
337:         return $this;
338:     }
339:     
340:     /**
341:      * @private
342:      * @ignore
343:      * @access protected
344:      * @return mixed
345:      */
346:     protected function _usedIpv4AddressHash()
347:     {
348:         $filter = (object)[];
349:         $filter->{"Switch" . ".ID"} = $this->_id();
350:         $query = (object)[];
351:         Util::setByPath($query, "Count", 0);
352:         Util::setByPath($query, "Filter", $filter);
353:         Util::setByPath($query, "Include", new \ArrayObject(["IPAddress", "UserIPAddress"]));
354:         $result = $this->_client->request("GET", "/interface", $query);
355:         if ($result == null) {
356:             return null;
357:         }
358:         $result = $result->{"Interfaces"};
359:         if ($result == null) {
360:             return null;
361:         }
362:         $ifaces = $result;
363:         if ($ifaces == null) {
364:             return null;
365:         }
366:         $found = (object)[];
367:         foreach ($ifaces as $iface) {
368:             $ip = $iface->{"IPAddress"};
369:             $userIp = $iface->{"UserIPAddress"};
370:             if ($ip == null) {
371:                 $ip = $userIp;
372:             }
373:             if ($ip != null) {
374:                 $found->{$ip} = true;
375:             }
376:         }
377:         return $found;
378:     }
379:     
380:     /**
381:      * このルータ+スイッチに接続中のインタフェースに割り当てられているIPアドレスを収集します。
382:      * 
383:      * @access public
384:      * @return string[]
385:      */
386:     public function collectUsedIpv4Addresses()
387:     {
388:         $found = $this->_usedIpv4AddressHash();
389:         return Util::sortArray(new \ArrayObject(array_keys((array)$found)));
390:     }
391:     
392:     /**
393:      * このルータ+スイッチで利用できる未使用のIPアドレスを収集します。
394:      * 
395:      * @access public
396:      * @return string[]
397:      */
398:     public function collectUnusedIpv4Addresses()
399:     {
400:         $nets = $this->get_ipv4Nets();
401:         if ($nets->count() < 1) {
402:             return null;
403:         }
404:         $used = $this->_usedIpv4AddressHash();
405:         $ret = new \ArrayObject([]);
406:         foreach ($nets[0]->get_range()->get_asArray() as $ip) {
407:             if (!array_key_exists($ip, (array)($used))) {
408:                 $ret->append($ip);
409:             }
410:         }
411:         return Util::sortArray($ret);
412:     }
413:     
414:     /**
415:      * @access private
416:      * @ignore
417:      * @var boolean
418:      */
419:     private $n_id = false;
420:     
421:     /**
422:      * (This method is generated in Translator_default#buildImpl)
423:      * 
424:      * @access private
425:      * @ignore
426:      * @return string
427:      */
428:     private function get_id()
429:     {
430:         return $this->m_id;
431:     }
432:     
433:     
434:     
435:     /**
436:      * @access private
437:      * @ignore
438:      * @var boolean
439:      */
440:     private $n_name = false;
441:     
442:     /**
443:      * (This method is generated in Translator_default#buildImpl)
444:      * 
445:      * @access private
446:      * @ignore
447:      * @return string
448:      */
449:     private function get_name()
450:     {
451:         return $this->m_name;
452:     }
453:     
454:     /**
455:      * (This method is generated in Translator_default#buildImpl)
456:      * 
457:      * @access private
458:      * @ignore
459:      * @param string $v
460:      * @return string
461:      */
462:     private function set_name($v)
463:     {
464:         Util::validateArgCount(func_num_args(), 1);
465:         Util::validateType($v, "string");
466:         $this->m_name = $v;
467:         $this->n_name = true;
468:         return $this->m_name;
469:     }
470:     
471:     
472:     
473:     /**
474:      * @access private
475:      * @ignore
476:      * @var boolean
477:      */
478:     private $n_description = false;
479:     
480:     /**
481:      * (This method is generated in Translator_default#buildImpl)
482:      * 
483:      * @access private
484:      * @ignore
485:      * @return string
486:      */
487:     private function get_description()
488:     {
489:         return $this->m_description;
490:     }
491:     
492:     /**
493:      * (This method is generated in Translator_default#buildImpl)
494:      * 
495:      * @access private
496:      * @ignore
497:      * @param string $v
498:      * @return string
499:      */
500:     private function set_description($v)
501:     {
502:         Util::validateArgCount(func_num_args(), 1);
503:         Util::validateType($v, "string");
504:         $this->m_description = $v;
505:         $this->n_description = true;
506:         return $this->m_description;
507:     }
508:     
509:     
510:     
511:     /**
512:      * @access private
513:      * @ignore
514:      * @var boolean
515:      */
516:     private $n_tags = false;
517:     
518:     /**
519:      * (This method is generated in Translator_default#buildImpl)
520:      * 
521:      * @access private
522:      * @ignore
523:      * @return string[]
524:      */
525:     private function get_tags()
526:     {
527:         $this->n_tags = true;
528:         return $this->m_tags;
529:     }
530:     
531:     /**
532:      * (This method is generated in Translator_default#buildImpl)
533:      * 
534:      * @access private
535:      * @ignore
536:      * @param string[] $v
537:      * @return string[]
538:      */
539:     private function set_tags($v)
540:     {
541:         Util::validateArgCount(func_num_args(), 1);
542:         Util::validateType($v, "\\ArrayObject");
543:         if (is_array($v)) $v = Client::array2ArrayObject($v);
544:         $this->m_tags = $v;
545:         $this->n_tags = true;
546:         return $this->m_tags;
547:     }
548:     
549:     
550:     
551:     /**
552:      * @access private
553:      * @ignore
554:      * @var boolean
555:      */
556:     private $n_icon = false;
557:     
558:     /**
559:      * (This method is generated in Translator_default#buildImpl)
560:      * 
561:      * @access private
562:      * @ignore
563:      * @return \Saklient\Cloud\Resources\Icon
564:      */
565:     private function get_icon()
566:     {
567:         return $this->m_icon;
568:     }
569:     
570:     /**
571:      * (This method is generated in Translator_default#buildImpl)
572:      * 
573:      * @access private
574:      * @ignore
575:      * @param \Saklient\Cloud\Resources\Icon|null $v
576:      * @return \Saklient\Cloud\Resources\Icon
577:      */
578:     private function set_icon(\Saklient\Cloud\Resources\Icon $v=null)
579:     {
580:         Util::validateArgCount(func_num_args(), 1);
581:         Util::validateType($v, "\\Saklient\\Cloud\\Resources\\Icon");
582:         $this->m_icon = $v;
583:         $this->n_icon = true;
584:         return $this->m_icon;
585:     }
586:     
587:     
588:     
589:     /**
590:      * @access private
591:      * @ignore
592:      * @var boolean
593:      */
594:     private $n_userDefaultRoute = false;
595:     
596:     /**
597:      * (This method is generated in Translator_default#buildImpl)
598:      * 
599:      * @access private
600:      * @ignore
601:      * @return string
602:      */
603:     private function get_userDefaultRoute()
604:     {
605:         return $this->m_userDefaultRoute;
606:     }
607:     
608:     
609:     
610:     /**
611:      * @access private
612:      * @ignore
613:      * @var boolean
614:      */
615:     private $n_userMaskLen = false;
616:     
617:     /**
618:      * (This method is generated in Translator_default#buildImpl)
619:      * 
620:      * @access private
621:      * @ignore
622:      * @return int
623:      */
624:     private function get_userMaskLen()
625:     {
626:         return $this->m_userMaskLen;
627:     }
628:     
629:     
630:     
631:     /**
632:      * @access private
633:      * @ignore
634:      * @var boolean
635:      */
636:     private $n_router = false;
637:     
638:     /**
639:      * (This method is generated in Translator_default#buildImpl)
640:      * 
641:      * @access private
642:      * @ignore
643:      * @return \Saklient\Cloud\Resources\Router
644:      */
645:     private function get_router()
646:     {
647:         return $this->m_router;
648:     }
649:     
650:     
651:     
652:     /**
653:      * @access private
654:      * @ignore
655:      * @var boolean
656:      */
657:     private $n_bridge = false;
658:     
659:     /**
660:      * (This method is generated in Translator_default#buildImpl)
661:      * 
662:      * @access private
663:      * @ignore
664:      * @return \Saklient\Cloud\Resources\Bridge
665:      */
666:     private function get_bridge()
667:     {
668:         return $this->m_bridge;
669:     }
670:     
671:     
672:     
673:     /**
674:      * @access private
675:      * @ignore
676:      * @var boolean
677:      */
678:     private $n_ipv4Nets = false;
679:     
680:     /**
681:      * (This method is generated in Translator_default#buildImpl)
682:      * 
683:      * @access private
684:      * @ignore
685:      * @return \Saklient\Cloud\Resources\Ipv4Net[]
686:      */
687:     private function get_ipv4Nets()
688:     {
689:         return $this->m_ipv4Nets;
690:     }
691:     
692:     
693:     
694:     /**
695:      * @access private
696:      * @ignore
697:      * @var boolean
698:      */
699:     private $n_ipv6Nets = false;
700:     
701:     /**
702:      * (This method is generated in Translator_default#buildImpl)
703:      * 
704:      * @access private
705:      * @ignore
706:      * @return \Saklient\Cloud\Resources\Ipv6Net[]
707:      */
708:     private function get_ipv6Nets()
709:     {
710:         return $this->m_ipv6Nets;
711:     }
712:     
713:     
714:     
715:     /**
716:      * (This method is generated in Translator_default#buildImpl)
717:      * 
718:      * @access protected
719:      * @ignore
720:      * @param mixed $r
721:      */
722:     protected function apiDeserializeImpl($r)
723:     {
724:         Util::validateArgCount(func_num_args(), 1);
725:         $this->isNew = $r == null;
726:         if ($this->isNew) {
727:             $r = (object)[];
728:         }
729:         $this->isIncomplete = false;
730:         if (Util::existsPath($r, "ID")) {
731:             $this->m_id = Util::getByPath($r, "ID") == null ? null : "" . Util::getByPath($r, "ID");
732:         }
733:         else {
734:             $this->m_id = null;
735:             $this->isIncomplete = true;
736:         }
737:         $this->n_id = false;
738:         if (Util::existsPath($r, "Name")) {
739:             $this->m_name = Util::getByPath($r, "Name") == null ? null : "" . Util::getByPath($r, "Name");
740:         }
741:         else {
742:             $this->m_name = null;
743:             $this->isIncomplete = true;
744:         }
745:         $this->n_name = false;
746:         if (Util::existsPath($r, "Description")) {
747:             $this->m_description = Util::getByPath($r, "Description") == null ? null : "" . Util::getByPath($r, "Description");
748:         }
749:         else {
750:             $this->m_description = null;
751:             $this->isIncomplete = true;
752:         }
753:         $this->n_description = false;
754:         if (Util::existsPath($r, "Tags")) {
755:             if (Util::getByPath($r, "Tags") == null) {
756:                 $this->m_tags = new \ArrayObject([]);
757:             }
758:             else {
759:                 $this->m_tags = new \ArrayObject([]);
760:                 foreach (Util::getByPath($r, "Tags") as $t) {
761:                     $v1 = null;
762:                     $v1 = $t == null ? null : "" . $t;
763:                     $this->m_tags->append($v1);
764:                 }
765:             }
766:         }
767:         else {
768:             $this->m_tags = null;
769:             $this->isIncomplete = true;
770:         }
771:         $this->n_tags = false;
772:         if (Util::existsPath($r, "Icon")) {
773:             $this->m_icon = Util::getByPath($r, "Icon") == null ? null : new Icon($this->_client, Util::getByPath($r, "Icon"));
774:         }
775:         else {
776:             $this->m_icon = null;
777:             $this->isIncomplete = true;
778:         }
779:         $this->n_icon = false;
780:         if (Util::existsPath($r, "UserSubnet.DefaultRoute")) {
781:             $this->m_userDefaultRoute = Util::getByPath($r, "UserSubnet.DefaultRoute") == null ? null : "" . Util::getByPath($r, "UserSubnet.DefaultRoute");
782:         }
783:         else {
784:             $this->m_userDefaultRoute = null;
785:             $this->isIncomplete = true;
786:         }
787:         $this->n_userDefaultRoute = false;
788:         if (Util::existsPath($r, "UserSubnet.NetworkMaskLen")) {
789:             $this->m_userMaskLen = Util::getByPath($r, "UserSubnet.NetworkMaskLen") == null ? null : intval("" . Util::getByPath($r, "UserSubnet.NetworkMaskLen"));
790:         }
791:         else {
792:             $this->m_userMaskLen = null;
793:             $this->isIncomplete = true;
794:         }
795:         $this->n_userMaskLen = false;
796:         if (Util::existsPath($r, "Internet")) {
797:             $this->m_router = Util::getByPath($r, "Internet") == null ? null : new Router($this->_client, Util::getByPath($r, "Internet"));
798:         }
799:         else {
800:             $this->m_router = null;
801:             $this->isIncomplete = true;
802:         }
803:         $this->n_router = false;
804:         if (Util::existsPath($r, "Bridge")) {
805:             $this->m_bridge = Util::getByPath($r, "Bridge") == null ? null : new Bridge($this->_client, Util::getByPath($r, "Bridge"));
806:         }
807:         else {
808:             $this->m_bridge = null;
809:             $this->isIncomplete = true;
810:         }
811:         $this->n_bridge = false;
812:         if (Util::existsPath($r, "Subnets")) {
813:             if (Util::getByPath($r, "Subnets") == null) {
814:                 $this->m_ipv4Nets = new \ArrayObject([]);
815:             }
816:             else {
817:                 $this->m_ipv4Nets = new \ArrayObject([]);
818:                 foreach (Util::getByPath($r, "Subnets") as $t) {
819:                     $v2 = null;
820:                     $v2 = $t == null ? null : new Ipv4Net($this->_client, $t);
821:                     $this->m_ipv4Nets->append($v2);
822:                 }
823:             }
824:         }
825:         else {
826:             $this->m_ipv4Nets = null;
827:             $this->isIncomplete = true;
828:         }
829:         $this->n_ipv4Nets = false;
830:         if (Util::existsPath($r, "IPv6Nets")) {
831:             if (Util::getByPath($r, "IPv6Nets") == null) {
832:                 $this->m_ipv6Nets = new \ArrayObject([]);
833:             }
834:             else {
835:                 $this->m_ipv6Nets = new \ArrayObject([]);
836:                 foreach (Util::getByPath($r, "IPv6Nets") as $t) {
837:                     $v3 = null;
838:                     $v3 = $t == null ? null : new Ipv6Net($this->_client, $t);
839:                     $this->m_ipv6Nets->append($v3);
840:                 }
841:             }
842:         }
843:         else {
844:             $this->m_ipv6Nets = null;
845:             $this->isIncomplete = true;
846:         }
847:         $this->n_ipv6Nets = false;
848:     }
849:     
850:     /**
851:      * @ignore
852:      * @access protected
853:      * @param boolean $withClean=false
854:      * @return mixed
855:      */
856:     protected function apiSerializeImpl($withClean=false)
857:     {
858:         Util::validateType($withClean, "boolean");
859:         $missing = new \ArrayObject([]);
860:         $ret = (object)[];
861:         if ($withClean || $this->n_id) {
862:             Util::setByPath($ret, "ID", $this->m_id);
863:         }
864:         if ($withClean || $this->n_name) {
865:             Util::setByPath($ret, "Name", $this->m_name);
866:         }
867:         else {
868:             if ($this->isNew) {
869:                 $missing->append("name");
870:             }
871:         }
872:         if ($withClean || $this->n_description) {
873:             Util::setByPath($ret, "Description", $this->m_description);
874:         }
875:         if ($withClean || $this->n_tags) {
876:             Util::setByPath($ret, "Tags", new \ArrayObject([]));
877:             foreach ($this->m_tags as $r1) {
878:                 $v = null;
879:                 $v = $r1;
880:                 $ret->{"Tags"}->append($v);
881:             }
882:         }
883:         if ($withClean || $this->n_icon) {
884:             Util::setByPath($ret, "Icon", $withClean ? ($this->m_icon == null ? null : $this->m_icon->apiSerialize($withClean)) : ($this->m_icon == null ? (object)['ID' => "0"] : $this->m_icon->apiSerializeID()));
885:         }
886:         if ($withClean || $this->n_userDefaultRoute) {
887:             Util::setByPath($ret, "UserSubnet.DefaultRoute", $this->m_userDefaultRoute);
888:         }
889:         if ($withClean || $this->n_userMaskLen) {
890:             Util::setByPath($ret, "UserSubnet.NetworkMaskLen", $this->m_userMaskLen);
891:         }
892:         if ($withClean || $this->n_router) {
893:             Util::setByPath($ret, "Internet", $withClean ? ($this->m_router == null ? null : $this->m_router->apiSerialize($withClean)) : ($this->m_router == null ? (object)['ID' => "0"] : $this->m_router->apiSerializeID()));
894:         }
895:         if ($withClean || $this->n_bridge) {
896:             Util::setByPath($ret, "Bridge", $withClean ? ($this->m_bridge == null ? null : $this->m_bridge->apiSerialize($withClean)) : ($this->m_bridge == null ? (object)['ID' => "0"] : $this->m_bridge->apiSerializeID()));
897:         }
898:         if ($withClean || $this->n_ipv4Nets) {
899:             Util::setByPath($ret, "Subnets", new \ArrayObject([]));
900:             foreach ($this->m_ipv4Nets as $r2) {
901:                 $v = null;
902:                 $v = $withClean ? ($r2 == null ? null : $r2->apiSerialize($withClean)) : ($r2 == null ? (object)['ID' => "0"] : $r2->apiSerializeID());
903:                 $ret->{"Subnets"}->append($v);
904:             }
905:         }
906:         if ($withClean || $this->n_ipv6Nets) {
907:             Util::setByPath($ret, "IPv6Nets", new \ArrayObject([]));
908:             foreach ($this->m_ipv6Nets as $r3) {
909:                 $v = null;
910:                 $v = $withClean ? ($r3 == null ? null : $r3->apiSerialize($withClean)) : ($r3 == null ? (object)['ID' => "0"] : $r3->apiSerializeID());
911:                 $ret->{"IPv6Nets"}->append($v);
912:             }
913:         }
914:         if ($missing->count() > 0) {
915:             throw new SaklientException("required_field", "Required fields must be set before the Swytch creation: " . implode(", ", (array)($missing)));
916:         }
917:         return $ret;
918:     }
919:     
920:     /**
921:      * @ignore
922:      */
923:     public function __get($key) {
924:         switch ($key) {
925:             case "id": return $this->get_id();
926:             case "name": return $this->get_name();
927:             case "description": return $this->get_description();
928:             case "tags": return $this->get_tags();
929:             case "icon": return $this->get_icon();
930:             case "userDefaultRoute": return $this->get_userDefaultRoute();
931:             case "userMaskLen": return $this->get_userMaskLen();
932:             case "router": return $this->get_router();
933:             case "bridge": return $this->get_bridge();
934:             case "ipv4Nets": return $this->get_ipv4Nets();
935:             case "ipv6Nets": return $this->get_ipv6Nets();
936:             default: return parent::__get($key);
937:         }
938:     }
939:     
940:     /**
941:      * @ignore
942:      */
943:     public function __set($key, $v) {
944:         switch ($key) {
945:             case "name": return $this->set_name($v);
946:             case "description": return $this->set_description($v);
947:             case "tags": return $this->set_tags($v);
948:             case "icon": return $this->set_icon($v);
949:             default: return parent::__set($key, $v);
950:         }
951:     }
952: 
953: }
954: 
955: 
API documentation generated by ApiGen 2.8.0