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/Util.php";
10: use \Saklient\Util;
11: require_once __DIR__ . "/../../../Saklient/Errors/SaklientException.php";
12: use \Saklient\Errors\SaklientException;
13:
14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
24: class ServerPlan extends Resource {
25:
26: 27: 28: 29: 30: 31: 32:
33: protected $m_id;
34:
35: 36: 37: 38: 39: 40: 41:
42: protected $m_name;
43:
44: 45: 46: 47: 48: 49: 50:
51: protected $m_cpu;
52:
53: 54: 55: 56: 57: 58: 59:
60: protected $m_memoryMib;
61:
62: 63: 64: 65: 66: 67: 68:
69: protected $m_serviceClass;
70:
71: 72: 73: 74: 75: 76:
77: protected function _apiPath()
78: {
79: return "/product/server";
80: }
81:
82: 83: 84: 85: 86: 87:
88: protected function _rootKey()
89: {
90: return "ServerPlan";
91: }
92:
93: 94: 95: 96: 97: 98:
99: protected function _rootKeyM()
100: {
101: return "ServerPlans";
102: }
103:
104: 105: 106: 107: 108: 109:
110: public function _className()
111: {
112: return "ServerPlan";
113: }
114:
115: 116: 117: 118: 119: 120:
121: public function _id()
122: {
123: return $this->get_id();
124: }
125:
126: 127: 128: 129: 130: 131: 132:
133: public function __construct(\Saklient\Cloud\Client $client, $obj, $wrapped=false)
134: {
135: parent::__construct($client);
136: Util::validateArgCount(func_num_args(), 2);
137: Util::validateType($client, "\\Saklient\\Cloud\\Client");
138: Util::validateType($wrapped, "boolean");
139: $this->apiDeserialize($obj, $wrapped);
140: }
141:
142: 143: 144: 145: 146:
147: protected function get_memoryGib()
148: {
149: $memoryMib = $this->get_memoryMib();
150: return $memoryMib == null ? null : $memoryMib >> 10;
151: }
152:
153:
154:
155: 156: 157: 158: 159:
160: private $n_id = false;
161:
162: 163: 164: 165: 166: 167: 168:
169: private function get_id()
170: {
171: return $this->m_id;
172: }
173:
174:
175:
176: 177: 178: 179: 180:
181: private $n_name = false;
182:
183: 184: 185: 186: 187: 188: 189:
190: private function get_name()
191: {
192: return $this->m_name;
193: }
194:
195:
196:
197: 198: 199: 200: 201:
202: private $n_cpu = false;
203:
204: 205: 206: 207: 208: 209: 210:
211: private function get_cpu()
212: {
213: return $this->m_cpu;
214: }
215:
216:
217:
218: 219: 220: 221: 222:
223: private $n_memoryMib = false;
224:
225: 226: 227: 228: 229: 230: 231:
232: private function get_memoryMib()
233: {
234: return $this->m_memoryMib;
235: }
236:
237:
238:
239: 240: 241: 242: 243:
244: private $n_serviceClass = false;
245:
246: 247: 248: 249: 250: 251: 252:
253: private function get_serviceClass()
254: {
255: return $this->m_serviceClass;
256: }
257:
258:
259:
260: 261: 262: 263: 264: 265: 266:
267: protected function apiDeserializeImpl($r)
268: {
269: Util::validateArgCount(func_num_args(), 1);
270: $this->isNew = $r == null;
271: if ($this->isNew) {
272: $r = (object)[];
273: }
274: $this->isIncomplete = false;
275: if (Util::existsPath($r, "ID")) {
276: $this->m_id = Util::getByPath($r, "ID") == null ? null : "" . Util::getByPath($r, "ID");
277: }
278: else {
279: $this->m_id = null;
280: $this->isIncomplete = true;
281: }
282: $this->n_id = false;
283: if (Util::existsPath($r, "Name")) {
284: $this->m_name = Util::getByPath($r, "Name") == null ? null : "" . Util::getByPath($r, "Name");
285: }
286: else {
287: $this->m_name = null;
288: $this->isIncomplete = true;
289: }
290: $this->n_name = false;
291: if (Util::existsPath($r, "CPU")) {
292: $this->m_cpu = Util::getByPath($r, "CPU") == null ? null : intval("" . Util::getByPath($r, "CPU"));
293: }
294: else {
295: $this->m_cpu = null;
296: $this->isIncomplete = true;
297: }
298: $this->n_cpu = false;
299: if (Util::existsPath($r, "MemoryMB")) {
300: $this->m_memoryMib = Util::getByPath($r, "MemoryMB") == null ? null : intval("" . Util::getByPath($r, "MemoryMB"));
301: }
302: else {
303: $this->m_memoryMib = null;
304: $this->isIncomplete = true;
305: }
306: $this->n_memoryMib = false;
307: if (Util::existsPath($r, "ServiceClass")) {
308: $this->m_serviceClass = Util::getByPath($r, "ServiceClass") == null ? null : "" . Util::getByPath($r, "ServiceClass");
309: }
310: else {
311: $this->m_serviceClass = null;
312: $this->isIncomplete = true;
313: }
314: $this->n_serviceClass = false;
315: }
316:
317: 318: 319: 320: 321: 322:
323: protected function apiSerializeImpl($withClean=false)
324: {
325: Util::validateType($withClean, "boolean");
326: $ret = (object)[];
327: if ($withClean || $this->n_id) {
328: Util::setByPath($ret, "ID", $this->m_id);
329: }
330: if ($withClean || $this->n_name) {
331: Util::setByPath($ret, "Name", $this->m_name);
332: }
333: if ($withClean || $this->n_cpu) {
334: Util::setByPath($ret, "CPU", $this->m_cpu);
335: }
336: if ($withClean || $this->n_memoryMib) {
337: Util::setByPath($ret, "MemoryMB", $this->m_memoryMib);
338: }
339: if ($withClean || $this->n_serviceClass) {
340: Util::setByPath($ret, "ServiceClass", $this->m_serviceClass);
341: }
342: return $ret;
343: }
344:
345: 346: 347:
348: public function __get($key) {
349: switch ($key) {
350: case "memoryGib": return $this->get_memoryGib();
351: case "id": return $this->get_id();
352: case "name": return $this->get_name();
353: case "cpu": return $this->get_cpu();
354: case "memoryMib": return $this->get_memoryMib();
355: case "serviceClass": return $this->get_serviceClass();
356: default: return parent::__get($key);
357: }
358: }
359:
360: }
361:
362: