1: <?php
2:
3: namespace Saklient\Cloud;
4:
5: require_once __DIR__ . "/../../Saklient/Util.php";
6: use \Saklient\Util;
7: require_once __DIR__ . "/../../Saklient/Cloud/Client.php";
8: use \Saklient\Cloud\Client;
9: require_once __DIR__ . "/../../Saklient/Cloud/Product.php";
10: use \Saklient\Cloud\Product;
11: require_once __DIR__ . "/../../Saklient/Cloud/Facility.php";
12: use \Saklient\Cloud\Facility;
13: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_Icon.php";
14: use \Saklient\Cloud\Models\Model_Icon;
15: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_Server.php";
16: use \Saklient\Cloud\Models\Model_Server;
17: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_Disk.php";
18: use \Saklient\Cloud\Models\Model_Disk;
19: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_Appliance.php";
20: use \Saklient\Cloud\Models\Model_Appliance;
21: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_Archive.php";
22: use \Saklient\Cloud\Models\Model_Archive;
23: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_IsoImage.php";
24: use \Saklient\Cloud\Models\Model_IsoImage;
25: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_Iface.php";
26: use \Saklient\Cloud\Models\Model_Iface;
27: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_Swytch.php";
28: use \Saklient\Cloud\Models\Model_Swytch;
29: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_Router.php";
30: use \Saklient\Cloud\Models\Model_Router;
31: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_Bridge.php";
32: use \Saklient\Cloud\Models\Model_Bridge;
33: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_Ipv6Net.php";
34: use \Saklient\Cloud\Models\Model_Ipv6Net;
35: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_Script.php";
36: use \Saklient\Cloud\Models\Model_Script;
37: require_once __DIR__ . "/../../Saklient/Cloud/Models/Model_License.php";
38: use \Saklient\Cloud\Models\Model_License;
39: require_once __DIR__ . "/../../Saklient/Errors/SaklientException.php";
40: use \Saklient\Errors\SaklientException;
41:
42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61:
62: class API {
63:
64: 65: 66: 67: 68: 69:
70: protected $_client;
71:
72: 73: 74: 75: 76:
77: protected function get_client()
78: {
79: return $this->_client;
80: }
81:
82:
83:
84: 85: 86: 87: 88: 89:
90: protected $_product;
91:
92: 93: 94: 95: 96:
97: protected function get_product()
98: {
99: return $this->_product;
100: }
101:
102:
103:
104: 105: 106: 107: 108: 109:
110: protected $_facility;
111:
112: 113: 114: 115: 116:
117: protected function get_facility()
118: {
119: return $this->_facility;
120: }
121:
122:
123:
124: 125: 126: 127: 128: 129:
130: protected $_icon;
131:
132: 133: 134: 135: 136:
137: protected function get_icon()
138: {
139: return $this->_icon;
140: }
141:
142:
143:
144: 145: 146: 147: 148: 149:
150: protected $_server;
151:
152: 153: 154: 155: 156:
157: protected function get_server()
158: {
159: return $this->_server;
160: }
161:
162:
163:
164: 165: 166: 167: 168: 169:
170: protected $_disk;
171:
172: 173: 174: 175: 176:
177: protected function get_disk()
178: {
179: return $this->_disk;
180: }
181:
182:
183:
184: 185: 186: 187: 188: 189:
190: protected $_appliance;
191:
192: 193: 194: 195: 196:
197: protected function get_appliance()
198: {
199: return $this->_appliance;
200: }
201:
202:
203:
204: 205: 206: 207: 208: 209:
210: protected $_archive;
211:
212: 213: 214: 215: 216:
217: protected function get_archive()
218: {
219: return $this->_archive;
220: }
221:
222:
223:
224: 225: 226: 227: 228: 229:
230: protected $_isoImage;
231:
232: 233: 234: 235: 236:
237: protected function get_isoImage()
238: {
239: return $this->_isoImage;
240: }
241:
242:
243:
244: 245: 246: 247: 248: 249:
250: protected $_iface;
251:
252: 253: 254: 255: 256:
257: protected function get_iface()
258: {
259: return $this->_iface;
260: }
261:
262:
263:
264: 265: 266: 267: 268: 269:
270: protected $_swytch;
271:
272: 273: 274: 275: 276:
277: protected function get_swytch()
278: {
279: return $this->_swytch;
280: }
281:
282:
283:
284: 285: 286: 287: 288: 289:
290: protected $_router;
291:
292: 293: 294: 295: 296:
297: protected function get_router()
298: {
299: return $this->_router;
300: }
301:
302:
303:
304: 305: 306: 307: 308: 309:
310: protected $_bridge;
311:
312: 313: 314: 315: 316:
317: protected function get_bridge()
318: {
319: return $this->_bridge;
320: }
321:
322:
323:
324: 325: 326: 327: 328: 329:
330: protected $_ipv6Net;
331:
332: 333: 334: 335: 336:
337: protected function get_ipv6Net()
338: {
339: return $this->_ipv6Net;
340: }
341:
342:
343:
344: 345: 346: 347: 348: 349:
350: protected $_script;
351:
352: 353: 354: 355: 356:
357: protected function get_script()
358: {
359: return $this->_script;
360: }
361:
362:
363:
364: 365: 366: 367: 368: 369:
370: protected $_license;
371:
372: 373: 374: 375: 376:
377: protected function get_license()
378: {
379: return $this->_license;
380: }
381:
382:
383:
384: 385: 386: 387: 388:
389: protected function __construct(\Saklient\Cloud\Client $client)
390: {
391: Util::validateArgCount(func_num_args(), 1);
392: Util::validateType($client, "\\Saklient\\Cloud\\Client");
393: $this->_client = $client;
394: $this->_product = new Product($client);
395: $this->_facility = new Facility($client);
396: $this->_icon = new Model_Icon($client);
397: $this->_server = new Model_Server($client);
398: $this->_disk = new Model_Disk($client);
399: $this->_appliance = new Model_Appliance($client);
400: $this->_archive = new Model_Archive($client);
401: $this->_isoImage = new Model_IsoImage($client);
402: $this->_iface = new Model_Iface($client);
403: $this->_swytch = new Model_Swytch($client);
404: $this->_router = new Model_Router($client);
405: $this->_bridge = new Model_Bridge($client);
406: $this->_ipv6Net = new Model_Ipv6Net($client);
407: $this->_script = new Model_Script($client);
408: $this->_license = new Model_License($client);
409: }
410:
411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422:
423: static public function authorize($token, $secret, $zone=null)
424: {
425: Util::validateArgCount(func_num_args(), 2);
426: Util::validateType($token, "string");
427: Util::validateType($secret, "string");
428: Util::validateType($zone, "string");
429: $c = new Client($token, $secret);
430: $ret = new API($c);
431: return $zone != null ? $ret->inZone($zone) : $ret;
432: }
433:
434: 435: 436: 437: 438: 439: 440:
441: public function inZone($name)
442: {
443: Util::validateArgCount(func_num_args(), 1);
444: Util::validateType($name, "string");
445: $ret = new API($this->_client->cloneInstance());
446: $suffix = "";
447: if ($name == "is1x" || $name == "is1y") {
448: $suffix = "-test";
449: }
450: $ret->_client->setApiRoot("https://secure.sakura.ad.jp/cloud" . $suffix . "/");
451: $ret->_client->setApiRootSuffix("zone/" . $name);
452: return $ret;
453: }
454:
455: 456: 457:
458: public function __get($key) {
459: switch ($key) {
460: case "client": return $this->get_client();
461: case "product": return $this->get_product();
462: case "facility": return $this->get_facility();
463: case "icon": return $this->get_icon();
464: case "server": return $this->get_server();
465: case "disk": return $this->get_disk();
466: case "appliance": return $this->get_appliance();
467: case "archive": return $this->get_archive();
468: case "isoImage": return $this->get_isoImage();
469: case "iface": return $this->get_iface();
470: case "swytch": return $this->get_swytch();
471: case "router": return $this->get_router();
472: case "bridge": return $this->get_bridge();
473: case "ipv6Net": return $this->get_ipv6Net();
474: case "script": return $this->get_script();
475: case "license": return $this->get_license();
476: default: return null;
477: }
478: }
479:
480: }
481:
482: