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/Errors/SaklientException.php";
8: use \Saklient\Errors\SaklientException;
9:
10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22: class LbServer {
23:
24: 25: 26: 27: 28: 29:
30: protected $_enabled;
31:
32: 33: 34: 35: 36:
37: public function get_enabled()
38: {
39: return $this->_enabled;
40: }
41:
42: 43: 44: 45: 46: 47:
48: public function set_enabled($v)
49: {
50: Util::validateArgCount(func_num_args(), 1);
51: Util::validateType($v, "boolean");
52: $this->_enabled = $v;
53: return $this->_enabled;
54: }
55:
56:
57:
58: 59: 60: 61: 62: 63:
64: protected $_ipAddress;
65:
66: 67: 68: 69: 70:
71: public function get_ipAddress()
72: {
73: return $this->_ipAddress;
74: }
75:
76: 77: 78: 79: 80: 81:
82: public function set_ipAddress($v)
83: {
84: Util::validateArgCount(func_num_args(), 1);
85: Util::validateType($v, "string");
86: $this->_ipAddress = $v;
87: return $this->_ipAddress;
88: }
89:
90:
91:
92: 93: 94: 95: 96: 97:
98: protected $_port;
99:
100: 101: 102: 103: 104:
105: public function get_port()
106: {
107: return $this->_port;
108: }
109:
110: 111: 112: 113: 114: 115:
116: public function set_port($v)
117: {
118: Util::validateArgCount(func_num_args(), 1);
119: Util::validateType($v, "int");
120: $this->_port = $v;
121: return $this->_port;
122: }
123:
124:
125:
126: 127: 128: 129: 130: 131:
132: protected $_protocol;
133:
134: 135: 136: 137: 138:
139: public function get_protocol()
140: {
141: return $this->_protocol;
142: }
143:
144: 145: 146: 147: 148: 149:
150: public function set_protocol($v)
151: {
152: Util::validateArgCount(func_num_args(), 1);
153: Util::validateType($v, "string");
154: $this->_protocol = $v;
155: return $this->_protocol;
156: }
157:
158:
159:
160: 161: 162: 163: 164: 165:
166: protected $_pathToCheck;
167:
168: 169: 170: 171: 172:
173: public function get_pathToCheck()
174: {
175: return $this->_pathToCheck;
176: }
177:
178: 179: 180: 181: 182: 183:
184: public function set_pathToCheck($v)
185: {
186: Util::validateArgCount(func_num_args(), 1);
187: Util::validateType($v, "string");
188: $this->_pathToCheck = $v;
189: return $this->_pathToCheck;
190: }
191:
192:
193:
194: 195: 196: 197: 198: 199:
200: protected $_responseExpected;
201:
202: 203: 204: 205: 206:
207: public function get_responseExpected()
208: {
209: return $this->_responseExpected;
210: }
211:
212: 213: 214: 215: 216: 217:
218: public function set_responseExpected($v)
219: {
220: Util::validateArgCount(func_num_args(), 1);
221: Util::validateType($v, "int");
222: $this->_responseExpected = $v;
223: return $this->_responseExpected;
224: }
225:
226:
227:
228: 229: 230: 231: 232: 233:
234: protected $_activeConnections;
235:
236: 237: 238: 239: 240:
241: public function get_activeConnections()
242: {
243: return $this->_activeConnections;
244: }
245:
246:
247:
248: 249: 250: 251: 252: 253:
254: protected $_status;
255:
256: 257: 258: 259: 260:
261: public function get_status()
262: {
263: return $this->_status;
264: }
265:
266:
267:
268: 269: 270: 271: 272:
273: public function __construct($obj=null)
274: {
275: if ($obj == null) {
276: $obj = (object)[];
277: }
278: $health = Util::getByPathAny(new \ArrayObject([$obj]), new \ArrayObject([
279: "HealthCheck",
280: "healthCheck",
281: "health_check",
282: "health"
283: ]));
284: $enabled = Util::getByPathAny(new \ArrayObject([$obj]), new \ArrayObject(["Enabled", "enabled"]));
285: $this->_enabled = null;
286: if ($enabled != null) {
287: $enabledStr = $enabled;
288: $this->_enabled = strtolower($enabledStr) == "true";
289: }
290: $this->_ipAddress = Util::getByPathAny(new \ArrayObject([$obj]), new \ArrayObject([
291: "IPAddress",
292: "ipAddress",
293: "ip_address",
294: "ip"
295: ]));
296: $this->_protocol = Util::getByPathAny(new \ArrayObject([$health, $obj]), new \ArrayObject(["Protocol", "protocol"]));
297: $this->_pathToCheck = Util::getByPathAny(new \ArrayObject([$health, $obj]), new \ArrayObject([
298: "Path",
299: "path",
300: "pathToCheck",
301: "path_to_check"
302: ]));
303: $port = Util::getByPathAny(new \ArrayObject([$obj]), new \ArrayObject(["Port", "port"]));
304: $this->_port = null;
305: if ($port != null) {
306: $this->_port = intval($port);
307: }
308: if ($this->_port == 0) {
309: $this->_port = null;
310: }
311: $responseExpected = Util::getByPathAny(new \ArrayObject([$health, $obj]), new \ArrayObject([
312: "Status",
313: "status",
314: "responseExpected",
315: "response_expected"
316: ]));
317: $this->_responseExpected = null;
318: if ($responseExpected != null) {
319: $this->_responseExpected = intval($responseExpected);
320: }
321: if ($this->_responseExpected == 0) {
322: $this->_responseExpected = null;
323: }
324: $this->_activeConnections = 0;
325: $this->_status = null;
326: }
327:
328: 329: 330: 331:
332: public function toRawSettings()
333: {
334: return (object)[
335: 'Enabled' => $this->_enabled == null ? null : ($this->_enabled ? "True" : "False"),
336: 'IPAddress' => $this->_ipAddress,
337: 'Port' => $this->_port,
338: 'HealthCheck' => (object)[
339: 'Protocol' => $this->_protocol,
340: 'Path' => $this->_pathToCheck,
341: 'Status' => $this->_responseExpected
342: ]
343: ];
344: }
345:
346: 347: 348: 349: 350: 351:
352: public function updateStatus($obj)
353: {
354: Util::validateArgCount(func_num_args(), 1);
355: $connStr = $obj->{"ActiveConn"};
356: $this->_activeConnections = 0;
357: if ($connStr != null) {
358: $this->_activeConnections = intval($connStr);
359: }
360: $status = $obj->{"Status"};
361: $this->_status = $status == null ? null : strtolower($status);
362: return $this;
363: }
364:
365: 366: 367:
368: public function __get($key) {
369: switch ($key) {
370: case "enabled": return $this->get_enabled();
371: case "ipAddress": return $this->get_ipAddress();
372: case "port": return $this->get_port();
373: case "protocol": return $this->get_protocol();
374: case "pathToCheck": return $this->get_pathToCheck();
375: case "responseExpected": return $this->get_responseExpected();
376: case "activeConnections": return $this->get_activeConnections();
377: case "status": return $this->get_status();
378: default: return null;
379: }
380: }
381:
382: 383: 384:
385: public function __set($key, $v) {
386: switch ($key) {
387: case "enabled": return $this->set_enabled($v);
388: case "ipAddress": return $this->set_ipAddress($v);
389: case "port": return $this->set_port($v);
390: case "protocol": return $this->set_protocol($v);
391: case "pathToCheck": return $this->set_pathToCheck($v);
392: case "responseExpected": return $this->set_responseExpected($v);
393: default: throw new SaklientException('non_writable_field', 'Non-writable field: Saklient\\Cloud\\Resources\\LbServer#'.$key);
394: }
395: }
396:
397: }
398:
399: