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/Util.php";
  6: use \Saklient\Util;
  7: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/LbServer.php";
  8: use \Saklient\Cloud\Resources\LbServer;
  9: require_once __DIR__ . "/../../../Saklient/Errors/SaklientException.php";
 10: use \Saklient\Errors\SaklientException;
 11: 
 12: /**
 13:  * ロードバランサの仮想IPアドレス設定。
 14:  * 
 15:  * @property string $virtualIpAddress VIPアドレス 
 16:  * @property int $port ポート番号 
 17:  * @property int $delayLoop チェック間隔 [秒] 
 18:  * @property-read \ArrayObject $servers 実サーバ {@link \Saklient\Cloud\Resources\LbServer} の配列 
 19:  */
 20: class LbVirtualIp {
 21:     
 22:     /**
 23:      * @private
 24:      * @access protected
 25:      * @ignore
 26:      * @var string
 27:      */
 28:     protected $_virtualIpAddress;
 29:     
 30:     /**
 31:      * @access public
 32:      * @ignore
 33:      * @return string
 34:      */
 35:     public function get_virtualIpAddress()
 36:     {
 37:         return $this->_virtualIpAddress;
 38:     }
 39:     
 40:     /**
 41:      * @access public
 42:      * @ignore
 43:      * @param string $v
 44:      * @return string
 45:      */
 46:     public function set_virtualIpAddress($v)
 47:     {
 48:         Util::validateArgCount(func_num_args(), 1);
 49:         Util::validateType($v, "string");
 50:         $this->_virtualIpAddress = $v;
 51:         return $this->_virtualIpAddress;
 52:     }
 53:     
 54:     
 55:     
 56:     /**
 57:      * @private
 58:      * @access protected
 59:      * @ignore
 60:      * @var int
 61:      */
 62:     protected $_port;
 63:     
 64:     /**
 65:      * @access public
 66:      * @ignore
 67:      * @return int
 68:      */
 69:     public function get_port()
 70:     {
 71:         return $this->_port;
 72:     }
 73:     
 74:     /**
 75:      * @access public
 76:      * @ignore
 77:      * @param int|null $v
 78:      * @return int
 79:      */
 80:     public function set_port($v)
 81:     {
 82:         Util::validateArgCount(func_num_args(), 1);
 83:         Util::validateType($v, "int");
 84:         $this->_port = $v;
 85:         return $this->_port;
 86:     }
 87:     
 88:     
 89:     
 90:     /**
 91:      * @private
 92:      * @access protected
 93:      * @ignore
 94:      * @var int
 95:      */
 96:     protected $_delayLoop;
 97:     
 98:     /**
 99:      * @access public
100:      * @ignore
101:      * @return int
102:      */
103:     public function get_delayLoop()
104:     {
105:         return $this->_delayLoop;
106:     }
107:     
108:     /**
109:      * @access public
110:      * @ignore
111:      * @param int|null $v
112:      * @return int
113:      */
114:     public function set_delayLoop($v)
115:     {
116:         Util::validateArgCount(func_num_args(), 1);
117:         Util::validateType($v, "int");
118:         $this->_delayLoop = $v;
119:         return $this->_delayLoop;
120:     }
121:     
122:     
123:     
124:     /**
125:      * @private
126:      * @access protected
127:      * @ignore
128:      * @var LbServer[]
129:      */
130:     protected $_servers;
131:     
132:     /**
133:      * @access public
134:      * @ignore
135:      * @return \Saklient\Cloud\Resources\LbServer[]
136:      */
137:     public function get_servers()
138:     {
139:         return $this->_servers;
140:     }
141:     
142:     
143:     
144:     /**
145:      * @ignore
146:      * @access public
147:      * @param mixed $obj=null
148:      */
149:     public function __construct($obj=null)
150:     {
151:         if ($obj == null) {
152:             $obj = (object)[];
153:         }
154:         $vip = Util::getByPathAny(new \ArrayObject([$obj]), new \ArrayObject([
155:             "VirtualIPAddress",
156:             "virtualIpAddress",
157:             "virtual_ip_address",
158:             "vip"
159:         ]));
160:         $this->_virtualIpAddress = $vip;
161:         $port = Util::getByPathAny(new \ArrayObject([$obj]), new \ArrayObject(["Port", "port"]));
162:         $this->_port = null;
163:         if ($port != null) {
164:             $this->_port = intval($port);
165:         }
166:         if ($this->_port == 0) {
167:             $this->_port = null;
168:         }
169:         $delayLoop = Util::getByPathAny(new \ArrayObject([$obj]), new \ArrayObject([
170:             "DelayLoop",
171:             "delayLoop",
172:             "delay_loop",
173:             "delay"
174:         ]));
175:         $this->_delayLoop = null;
176:         if ($delayLoop != null) {
177:             $this->_delayLoop = intval($delayLoop);
178:         }
179:         if ($this->_delayLoop == 0) {
180:             $this->_delayLoop = null;
181:         }
182:         $this->_servers = new \ArrayObject([]);
183:         $serversDyn = Util::getByPathAny(new \ArrayObject([$obj]), new \ArrayObject(["Servers", "servers"]));
184:         if ($serversDyn != null) {
185:             $servers = $serversDyn;
186:             foreach ($servers as $server) {
187:                 $this->_servers->append(new LbServer($server));
188:             }
189:         }
190:     }
191:     
192:     /**
193:      * 監視対象サーバ設定を追加します。
194:      * 
195:      * @access public
196:      * @param mixed $settings=null 設定オブジェクト
197:      * @return \Saklient\Cloud\Resources\LbServer
198:      */
199:     public function addServer($settings=null)
200:     {
201:         $ret = new LbServer($settings);
202:         $this->_servers->append($ret);
203:         return $ret;
204:     }
205:     
206:     /**
207:      * @access public
208:      * @return mixed
209:      */
210:     public function toRawSettings()
211:     {
212:         $servers = new \ArrayObject([]);
213:         foreach ($this->_servers as $server) {
214:             $servers->append($server->toRawSettings());
215:         }
216:         return (object)[
217:             'VirtualIPAddress' => $this->_virtualIpAddress,
218:             'Port' => $this->_port,
219:             'DelayLoop' => $this->_delayLoop,
220:             'Servers' => $servers
221:         ];
222:     }
223:     
224:     /**
225:      * 指定したIPアドレスにマッチする監視対象サーバ設定のうち、最初にマッチしたものを取得します。
226:      * 
227:      * @access public
228:      * @param string $address 検索するIPアドレス
229:      * @return \Saklient\Cloud\Resources\LbServer 監視対象サーバ設定(見つからなかった場合はnull)
230:      */
231:     public function getServerByAddress($address)
232:     {
233:         Util::validateArgCount(func_num_args(), 1);
234:         Util::validateType($address, "string");
235:         foreach ($this->_servers as $srv) {
236:             if ($srv->ipAddress == $address) {
237:                 return $srv;
238:             }
239:         }
240:         return null;
241:     }
242:     
243:     /**
244:      * 指定したIPアドレスにマッチする監視対象サーバ設定をすべて削除します。
245:      * 
246:      * @access public
247:      * @param string $address
248:      * @return \Saklient\Cloud\Resources\LbVirtualIp
249:      */
250:     public function removeServerByAddress($address)
251:     {
252:         Util::validateArgCount(func_num_args(), 1);
253:         Util::validateType($address, "string");
254:         $servers = new \ArrayObject([]);
255:         foreach ($this->_servers as $srv) {
256:             if ($srv->ipAddress != $address) {
257:                 $servers->append($srv);
258:             }
259:         }
260:         $this->_servers = $servers;
261:         return $this;
262:     }
263:     
264:     /**
265:      * @ignore
266:      * @access public
267:      * @param \ArrayObject $srvs
268:      * @return \Saklient\Cloud\Resources\LbVirtualIp
269:      */
270:     public function updateStatus($srvs)
271:     {
272:         Util::validateArgCount(func_num_args(), 1);
273:         Util::validateType($srvs, "\\ArrayObject");
274:         foreach ($srvs as $srvDyn) {
275:             $ip = $srvDyn->{"IPAddress"};
276:             $srv = $this->getServerByAddress($ip);
277:             if ($srv == null) {
278:                 continue;
279:             }
280:             $srv->updateStatus($srvDyn);
281:         }
282:         return $this;
283:     }
284:     
285:     /**
286:      * @ignore
287:      */
288:     public function __get($key) {
289:         switch ($key) {
290:             case "virtualIpAddress": return $this->get_virtualIpAddress();
291:             case "port": return $this->get_port();
292:             case "delayLoop": return $this->get_delayLoop();
293:             case "servers": return $this->get_servers();
294:             default: return null;
295:         }
296:     }
297:     
298:     /**
299:      * @ignore
300:      */
301:     public function __set($key, $v) {
302:         switch ($key) {
303:             case "virtualIpAddress": return $this->set_virtualIpAddress($v);
304:             case "port": return $this->set_port($v);
305:             case "delayLoop": return $this->set_delayLoop($v);
306:             default: throw new SaklientException('non_writable_field', 'Non-writable field: Saklient\\Cloud\\Resources\\LbVirtualIp#'.$key);
307:         }
308:     }
309: 
310: }
311: 
312: 
API documentation generated by ApiGen 2.8.0