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/Swytch.php";
 12: use \Saklient\Cloud\Resources\Swytch;
 13: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/IfaceActivity.php";
 14: use \Saklient\Cloud\Resources\IfaceActivity;
 15: require_once __DIR__ . "/../../../Saklient/Util.php";
 16: use \Saklient\Util;
 17: 
 18: /**
 19:  * インタフェースの実体1つに対応し、属性の取得や操作を行うためのクラス。
 20:  * 
 21:  * @property-read \Saklient\Cloud\Resources\IfaceActivity $activity アクティビティ 
 22:  * @property-read string $id ID 
 23:  * @property-read string $macAddress MACアドレス 
 24:  * @property-read string $ipAddress IPv4アドレス(共有セグメントによる自動割当) 
 25:  * @property string $userIpAddress ユーザ設定IPv4アドレス 
 26:  * @property string $serverId このインタフェースが取り付けられているサーバのID 
 27:  */
 28: class Iface extends Resource {
 29:     
 30:     /**
 31:      * ID
 32:      * 
 33:      * @access protected
 34:      * @ignore
 35:      * @var string
 36:      */
 37:     protected $m_id;
 38:     
 39:     /**
 40:      * MACアドレス
 41:      * 
 42:      * @access protected
 43:      * @ignore
 44:      * @var string
 45:      */
 46:     protected $m_macAddress;
 47:     
 48:     /**
 49:      * IPv4アドレス(共有セグメントによる自動割当)
 50:      * 
 51:      * @access protected
 52:      * @ignore
 53:      * @var string
 54:      */
 55:     protected $m_ipAddress;
 56:     
 57:     /**
 58:      * ユーザ設定IPv4アドレス
 59:      * 
 60:      * @access protected
 61:      * @ignore
 62:      * @var string
 63:      */
 64:     protected $m_userIpAddress;
 65:     
 66:     /**
 67:      * このインタフェースが取り付けられているサーバのID
 68:      * 
 69:      * @access protected
 70:      * @ignore
 71:      * @var string
 72:      */
 73:     protected $m_serverId;
 74:     
 75:     /**
 76:      * @private
 77:      * @access protected
 78:      * @ignore
 79:      * @return string
 80:      */
 81:     protected function _apiPath()
 82:     {
 83:         return "/interface";
 84:     }
 85:     
 86:     /**
 87:      * @private
 88:      * @access protected
 89:      * @ignore
 90:      * @return string
 91:      */
 92:     protected function _rootKey()
 93:     {
 94:         return "Interface";
 95:     }
 96:     
 97:     /**
 98:      * @private
 99:      * @access protected
100:      * @ignore
101:      * @return string
102:      */
103:     protected function _rootKeyM()
104:     {
105:         return "Interfaces";
106:     }
107:     
108:     /**
109:      * @private
110:      * @access public
111:      * @ignore
112:      * @return string
113:      */
114:     public function _className()
115:     {
116:         return "Iface";
117:     }
118:     
119:     /**
120:      * @private
121:      * @access public
122:      * @ignore
123:      * @return string
124:      */
125:     public function _id()
126:     {
127:         return $this->get_id();
128:     }
129:     
130:     /**
131:      * このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し、新規作成または上書き保存します。
132:      * 
133:      * @access public
134:      * @return \Saklient\Cloud\Resources\Iface this
135:      */
136:     public function save()
137:     {
138:         return $this->_save();
139:     }
140:     
141:     /**
142:      * 最新のリソース情報を再取得します。
143:      * 
144:      * @access public
145:      * @return \Saklient\Cloud\Resources\Iface this
146:      */
147:     public function reload()
148:     {
149:         return $this->_reload();
150:     }
151:     
152:     /**
153:      * @private
154:      * @access protected
155:      * @ignore
156:      * @var IfaceActivity
157:      */
158:     protected $_activity;
159:     
160:     /**
161:      * @access public
162:      * @ignore
163:      * @return \Saklient\Cloud\Resources\IfaceActivity
164:      */
165:     public function get_activity()
166:     {
167:         return $this->_activity;
168:     }
169:     
170:     
171:     
172:     /**
173:      * @ignore
174:      * @access public
175:      * @param \Saklient\Cloud\Client $client
176:      * @param mixed $obj
177:      * @param boolean $wrapped=false
178:      */
179:     public function __construct(\Saklient\Cloud\Client $client, $obj, $wrapped=false)
180:     {
181:         parent::__construct($client);
182:         Util::validateArgCount(func_num_args(), 2);
183:         Util::validateType($client, "\\Saklient\\Cloud\\Client");
184:         Util::validateType($wrapped, "boolean");
185:         $this->_activity = new IfaceActivity($client);
186:         $this->apiDeserialize($obj, $wrapped);
187:     }
188:     
189:     /**
190:      * @private
191:      * @access protected
192:      * @ignore
193:      * @param mixed $r
194:      * @param mixed $root
195:      * @return void
196:      */
197:     protected function _onAfterApiDeserialize($r, $root)
198:     {
199:         Util::validateArgCount(func_num_args(), 2);
200:         if ($r != null) {
201:             $this->_activity->setSourceId($this->_id());
202:         }
203:     }
204:     
205:     /**
206:      * スイッチに接続します。
207:      * 
208:      * @access public
209:      * @param \Saklient\Cloud\Resources\Swytch $swytch 接続先のスイッチ。
210:      * @return \Saklient\Cloud\Resources\Iface this
211:      */
212:     public function connectToSwytch(\Saklient\Cloud\Resources\Swytch $swytch)
213:     {
214:         Util::validateArgCount(func_num_args(), 1);
215:         Util::validateType($swytch, "\\Saklient\\Cloud\\Resources\\Swytch");
216:         $this->_client->request("PUT", $this->_apiPath() . "/" . Util::urlEncode($this->_id()) . "/to/switch/" . Util::urlEncode($swytch->_id()));
217:         return $this->reload();
218:     }
219:     
220:     /**
221:      * 共有セグメントに接続します。
222:      * 
223:      * @access public
224:      * @return \Saklient\Cloud\Resources\Iface this
225:      */
226:     public function connectToSharedSegment()
227:     {
228:         $this->_client->request("PUT", $this->_apiPath() . "/" . Util::urlEncode($this->_id()) . "/to/switch/shared");
229:         return $this->reload();
230:     }
231:     
232:     /**
233:      * スイッチから切断します。
234:      * 
235:      * @access public
236:      * @return \Saklient\Cloud\Resources\Iface this
237:      */
238:     public function disconnectFromSwytch()
239:     {
240:         $this->_client->request("DELETE", $this->_apiPath() . "/" . Util::urlEncode($this->_id()) . "/to/switch");
241:         return $this->reload();
242:     }
243:     
244:     /**
245:      * @access private
246:      * @ignore
247:      * @var boolean
248:      */
249:     private $n_id = false;
250:     
251:     /**
252:      * (This method is generated in Translator_default#buildImpl)
253:      * 
254:      * @access private
255:      * @ignore
256:      * @return string
257:      */
258:     private function get_id()
259:     {
260:         return $this->m_id;
261:     }
262:     
263:     
264:     
265:     /**
266:      * @access private
267:      * @ignore
268:      * @var boolean
269:      */
270:     private $n_macAddress = false;
271:     
272:     /**
273:      * (This method is generated in Translator_default#buildImpl)
274:      * 
275:      * @access private
276:      * @ignore
277:      * @return string
278:      */
279:     private function get_macAddress()
280:     {
281:         return $this->m_macAddress;
282:     }
283:     
284:     
285:     
286:     /**
287:      * @access private
288:      * @ignore
289:      * @var boolean
290:      */
291:     private $n_ipAddress = false;
292:     
293:     /**
294:      * (This method is generated in Translator_default#buildImpl)
295:      * 
296:      * @access private
297:      * @ignore
298:      * @return string
299:      */
300:     private function get_ipAddress()
301:     {
302:         return $this->m_ipAddress;
303:     }
304:     
305:     
306:     
307:     /**
308:      * @access private
309:      * @ignore
310:      * @var boolean
311:      */
312:     private $n_userIpAddress = false;
313:     
314:     /**
315:      * (This method is generated in Translator_default#buildImpl)
316:      * 
317:      * @access private
318:      * @ignore
319:      * @return string
320:      */
321:     private function get_userIpAddress()
322:     {
323:         return $this->m_userIpAddress;
324:     }
325:     
326:     /**
327:      * (This method is generated in Translator_default#buildImpl)
328:      * 
329:      * @access private
330:      * @ignore
331:      * @param string $v
332:      * @return string
333:      */
334:     private function set_userIpAddress($v)
335:     {
336:         Util::validateArgCount(func_num_args(), 1);
337:         Util::validateType($v, "string");
338:         $this->m_userIpAddress = $v;
339:         $this->n_userIpAddress = true;
340:         return $this->m_userIpAddress;
341:     }
342:     
343:     
344:     
345:     /**
346:      * @access private
347:      * @ignore
348:      * @var boolean
349:      */
350:     private $n_serverId = false;
351:     
352:     /**
353:      * (This method is generated in Translator_default#buildImpl)
354:      * 
355:      * @access private
356:      * @ignore
357:      * @return string
358:      */
359:     private function get_serverId()
360:     {
361:         return $this->m_serverId;
362:     }
363:     
364:     /**
365:      * (This method is generated in Translator_default#buildImpl)
366:      * 
367:      * @access private
368:      * @ignore
369:      * @param string $v
370:      * @return string
371:      */
372:     private function set_serverId($v)
373:     {
374:         Util::validateArgCount(func_num_args(), 1);
375:         Util::validateType($v, "string");
376:         if (!$this->isNew) {
377:             throw new SaklientException("immutable_field", "Immutable fields cannot be modified after the resource creation: " . "Saklient\\Cloud\\Resources\\Iface#serverId");
378:         }
379:         $this->m_serverId = $v;
380:         $this->n_serverId = true;
381:         return $this->m_serverId;
382:     }
383:     
384:     
385:     
386:     /**
387:      * (This method is generated in Translator_default#buildImpl)
388:      * 
389:      * @access protected
390:      * @ignore
391:      * @param mixed $r
392:      */
393:     protected function apiDeserializeImpl($r)
394:     {
395:         Util::validateArgCount(func_num_args(), 1);
396:         $this->isNew = $r == null;
397:         if ($this->isNew) {
398:             $r = (object)[];
399:         }
400:         $this->isIncomplete = false;
401:         if (Util::existsPath($r, "ID")) {
402:             $this->m_id = Util::getByPath($r, "ID") == null ? null : "" . Util::getByPath($r, "ID");
403:         }
404:         else {
405:             $this->m_id = null;
406:             $this->isIncomplete = true;
407:         }
408:         $this->n_id = false;
409:         if (Util::existsPath($r, "MACAddress")) {
410:             $this->m_macAddress = Util::getByPath($r, "MACAddress") == null ? null : "" . Util::getByPath($r, "MACAddress");
411:         }
412:         else {
413:             $this->m_macAddress = null;
414:             $this->isIncomplete = true;
415:         }
416:         $this->n_macAddress = false;
417:         if (Util::existsPath($r, "IPAddress")) {
418:             $this->m_ipAddress = Util::getByPath($r, "IPAddress") == null ? null : "" . Util::getByPath($r, "IPAddress");
419:         }
420:         else {
421:             $this->m_ipAddress = null;
422:             $this->isIncomplete = true;
423:         }
424:         $this->n_ipAddress = false;
425:         if (Util::existsPath($r, "UserIPAddress")) {
426:             $this->m_userIpAddress = Util::getByPath($r, "UserIPAddress") == null ? null : "" . Util::getByPath($r, "UserIPAddress");
427:         }
428:         else {
429:             $this->m_userIpAddress = null;
430:             $this->isIncomplete = true;
431:         }
432:         $this->n_userIpAddress = false;
433:         if (Util::existsPath($r, "Server.ID")) {
434:             $this->m_serverId = Util::getByPath($r, "Server.ID") == null ? null : "" . Util::getByPath($r, "Server.ID");
435:         }
436:         else {
437:             $this->m_serverId = null;
438:             $this->isIncomplete = true;
439:         }
440:         $this->n_serverId = false;
441:     }
442:     
443:     /**
444:      * @ignore
445:      * @access protected
446:      * @param boolean $withClean=false
447:      * @return mixed
448:      */
449:     protected function apiSerializeImpl($withClean=false)
450:     {
451:         Util::validateType($withClean, "boolean");
452:         $missing = new \ArrayObject([]);
453:         $ret = (object)[];
454:         if ($withClean || $this->n_id) {
455:             Util::setByPath($ret, "ID", $this->m_id);
456:         }
457:         if ($withClean || $this->n_macAddress) {
458:             Util::setByPath($ret, "MACAddress", $this->m_macAddress);
459:         }
460:         if ($withClean || $this->n_ipAddress) {
461:             Util::setByPath($ret, "IPAddress", $this->m_ipAddress);
462:         }
463:         if ($withClean || $this->n_userIpAddress) {
464:             Util::setByPath($ret, "UserIPAddress", $this->m_userIpAddress);
465:         }
466:         if ($withClean || $this->n_serverId) {
467:             Util::setByPath($ret, "Server.ID", $this->m_serverId);
468:         }
469:         else {
470:             if ($this->isNew) {
471:                 $missing->append("serverId");
472:             }
473:         }
474:         if ($missing->count() > 0) {
475:             throw new SaklientException("required_field", "Required fields must be set before the Iface creation: " . implode(", ", (array)($missing)));
476:         }
477:         return $ret;
478:     }
479:     
480:     /**
481:      * @ignore
482:      */
483:     public function __get($key) {
484:         switch ($key) {
485:             case "activity": return $this->get_activity();
486:             case "id": return $this->get_id();
487:             case "macAddress": return $this->get_macAddress();
488:             case "ipAddress": return $this->get_ipAddress();
489:             case "userIpAddress": return $this->get_userIpAddress();
490:             case "serverId": return $this->get_serverId();
491:             default: return parent::__get($key);
492:         }
493:     }
494:     
495:     /**
496:      * @ignore
497:      */
498:     public function __set($key, $v) {
499:         switch ($key) {
500:             case "userIpAddress": return $this->set_userIpAddress($v);
501:             case "serverId": return $this->set_serverId($v);
502:             default: return parent::__set($key, $v);
503:         }
504:     }
505: 
506: }
507: 
508: 
API documentation generated by ApiGen 2.8.0