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/Client.php";
  8: use \Saklient\Cloud\Client;
  9: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Script.php";
 10: use \Saklient\Cloud\Resources\Script;
 11: require_once __DIR__ . "/../../../Saklient/Errors/SaklientException.php";
 12: use \Saklient\Errors\SaklientException;
 13: 
 14: /**
 15:  * ディスク修正のパラメータ。
 16:  * 
 17:  * @property string $hostName ホスト名 
 18:  * @property string $password ログインパスワード 
 19:  * @property string $sshKey SSHキー 
 20:  * @property-read \ArrayObject $sshKeys SSHキー 
 21:  * @property string $ipAddress IPアドレス 
 22:  * @property string $defaultRoute デフォルトルート 
 23:  * @property int $networkMaskLen ネットワークマスク長 
 24:  * @property-read \ArrayObject $scripts スタートアップスクリプト {@link \Saklient\Cloud\Resources\Script} の配列(pushによりスクリプトを追加できます) 
 25:  */
 26: class DiskConfig {
 27:     
 28:     /**
 29:      * @private
 30:      * @access protected
 31:      * @ignore
 32:      * @var Client
 33:      */
 34:     protected $_client;
 35:     
 36:     /**
 37:      * @access protected
 38:      * @ignore
 39:      * @return \Saklient\Cloud\Client
 40:      */
 41:     protected function get_client()
 42:     {
 43:         return $this->_client;
 44:     }
 45:     
 46:     
 47:     
 48:     /**
 49:      * @private
 50:      * @access protected
 51:      * @ignore
 52:      * @var string
 53:      */
 54:     protected $_diskId;
 55:     
 56:     /**
 57:      * @access protected
 58:      * @ignore
 59:      * @return string
 60:      */
 61:     protected function get_diskId()
 62:     {
 63:         return $this->_diskId;
 64:     }
 65:     
 66:     
 67:     
 68:     /**
 69:      * @private
 70:      * @access protected
 71:      * @ignore
 72:      * @var string
 73:      */
 74:     protected $_hostName;
 75:     
 76:     /**
 77:      * @access protected
 78:      * @ignore
 79:      * @return string
 80:      */
 81:     protected function get_hostName()
 82:     {
 83:         return $this->_hostName;
 84:     }
 85:     
 86:     /**
 87:      * @access protected
 88:      * @ignore
 89:      * @param string $v
 90:      * @return string
 91:      */
 92:     protected function set_hostName($v)
 93:     {
 94:         Util::validateArgCount(func_num_args(), 1);
 95:         Util::validateType($v, "string");
 96:         $this->_hostName = $v;
 97:         return $v;
 98:     }
 99:     
100:     
101:     
102:     /**
103:      * @private
104:      * @access protected
105:      * @ignore
106:      * @var string
107:      */
108:     protected $_password;
109:     
110:     /**
111:      * @access protected
112:      * @ignore
113:      * @return string
114:      */
115:     protected function get_password()
116:     {
117:         return $this->_password;
118:     }
119:     
120:     /**
121:      * @access protected
122:      * @ignore
123:      * @param string $v
124:      * @return string
125:      */
126:     protected function set_password($v)
127:     {
128:         Util::validateArgCount(func_num_args(), 1);
129:         Util::validateType($v, "string");
130:         $this->_password = $v;
131:         return $v;
132:     }
133:     
134:     
135:     
136:     /**
137:      * @private
138:      * @access protected
139:      * @ignore
140:      * @var string[]
141:      */
142:     protected $_sshKeys;
143:     
144:     /**
145:      * @access protected
146:      * @ignore
147:      * @return string[]
148:      */
149:     protected function get_sshKeys()
150:     {
151:         return $this->_sshKeys;
152:     }
153:     
154:     /**
155:      * @access protected
156:      * @ignore
157:      * @return string
158:      */
159:     protected function get_sshKey()
160:     {
161:         if ($this->_sshKeys->count() < 1) {
162:             return null;
163:         }
164:         return $this->_sshKeys[0];
165:     }
166:     
167:     /**
168:      * @access protected
169:      * @ignore
170:      * @param string $v
171:      * @return string
172:      */
173:     protected function set_sshKey($v)
174:     {
175:         Util::validateArgCount(func_num_args(), 1);
176:         Util::validateType($v, "string");
177:         if ($this->_sshKeys->count() < 1) {
178:             $this->_sshKeys->append($v);
179:         }
180:         else {
181:             $this->_sshKeys[0] = $v;
182:         }
183:         return $v;
184:     }
185:     
186:     
187:     
188:     
189:     
190:     /**
191:      * @private
192:      * @access protected
193:      * @ignore
194:      * @var string
195:      */
196:     protected $_ipAddress;
197:     
198:     /**
199:      * @access protected
200:      * @ignore
201:      * @return string
202:      */
203:     protected function get_ipAddress()
204:     {
205:         return $this->_ipAddress;
206:     }
207:     
208:     /**
209:      * @access protected
210:      * @ignore
211:      * @param string $v
212:      * @return string
213:      */
214:     protected function set_ipAddress($v)
215:     {
216:         Util::validateArgCount(func_num_args(), 1);
217:         Util::validateType($v, "string");
218:         $this->_ipAddress = $v;
219:         return $v;
220:     }
221:     
222:     
223:     
224:     /**
225:      * @private
226:      * @access protected
227:      * @ignore
228:      * @var string
229:      */
230:     protected $_defaultRoute;
231:     
232:     /**
233:      * @access protected
234:      * @ignore
235:      * @return string
236:      */
237:     protected function get_defaultRoute()
238:     {
239:         return $this->_defaultRoute;
240:     }
241:     
242:     /**
243:      * @access protected
244:      * @ignore
245:      * @param string $v
246:      * @return string
247:      */
248:     protected function set_defaultRoute($v)
249:     {
250:         Util::validateArgCount(func_num_args(), 1);
251:         Util::validateType($v, "string");
252:         $this->_defaultRoute = $v;
253:         return $v;
254:     }
255:     
256:     
257:     
258:     /**
259:      * @private
260:      * @access protected
261:      * @ignore
262:      * @var int
263:      */
264:     protected $_networkMaskLen;
265:     
266:     /**
267:      * @access protected
268:      * @ignore
269:      * @return int
270:      */
271:     protected function get_networkMaskLen()
272:     {
273:         return $this->_networkMaskLen;
274:     }
275:     
276:     /**
277:      * @access protected
278:      * @ignore
279:      * @param int|null $v
280:      * @return int
281:      */
282:     protected function set_networkMaskLen($v)
283:     {
284:         Util::validateArgCount(func_num_args(), 1);
285:         Util::validateType($v, "int");
286:         $this->_networkMaskLen = $v;
287:         return $v;
288:     }
289:     
290:     
291:     
292:     /**
293:      * @private
294:      * @access protected
295:      * @ignore
296:      * @var Script[]
297:      */
298:     protected $_scripts;
299:     
300:     /**
301:      * @access protected
302:      * @ignore
303:      * @return \Saklient\Cloud\Resources\Script[]
304:      */
305:     protected function get_scripts()
306:     {
307:         return $this->_scripts;
308:     }
309:     
310:     
311:     
312:     /**
313:      * @ignore
314:      * @access public
315:      * @param \Saklient\Cloud\Client $client
316:      * @param string $diskId
317:      */
318:     public function __construct(\Saklient\Cloud\Client $client, $diskId)
319:     {
320:         Util::validateArgCount(func_num_args(), 2);
321:         Util::validateType($client, "\\Saklient\\Cloud\\Client");
322:         Util::validateType($diskId, "string");
323:         $this->_client = $client;
324:         $this->_diskId = $diskId;
325:         $this->_hostName = null;
326:         $this->_password = null;
327:         $this->_sshKeys = new \ArrayObject([]);
328:         $this->_ipAddress = null;
329:         $this->_defaultRoute = null;
330:         $this->_networkMaskLen = null;
331:         $this->_scripts = new \ArrayObject([]);
332:     }
333:     
334:     /**
335:      * スタートアップスクリプトを追加します。
336:      * 
337:      * diskConfig.addScript(script) と diskConfig.scripts.push(script) の効果は同等です。
338:      * 
339:      * @access public
340:      * @param \Saklient\Cloud\Resources\Script $script
341:      * @return \Saklient\Cloud\Resources\DiskConfig this
342:      */
343:     public function addScript(\Saklient\Cloud\Resources\Script $script)
344:     {
345:         Util::validateArgCount(func_num_args(), 1);
346:         Util::validateType($script, "\\Saklient\\Cloud\\Resources\\Script");
347:         $this->_scripts->append($script);
348:         return $this;
349:     }
350:     
351:     /**
352:      * 修正内容を実際のディスクに書き込みます。
353:      * 
354:      * @access public
355:      * @return \Saklient\Cloud\Resources\DiskConfig this
356:      */
357:     public function write()
358:     {
359:         $q = (object)[];
360:         if ($this->_hostName != null) {
361:             Util::setByPath($q, "HostName", $this->_hostName);
362:         }
363:         if ($this->_password != null) {
364:             Util::setByPath($q, "Password", $this->_password);
365:         }
366:         if ($this->_sshKeys->count() > 0) {
367:             Util::setByPath($q, "SSHKey.PublicKey", implode("\n", (array)($this->_sshKeys)));
368:         }
369:         if ($this->_ipAddress != null) {
370:             Util::setByPath($q, "UserIPAddress", $this->_ipAddress);
371:         }
372:         if ($this->_defaultRoute != null) {
373:             Util::setByPath($q, "UserSubnet.DefaultRoute", $this->_defaultRoute);
374:         }
375:         if ($this->_networkMaskLen != null) {
376:             Util::setByPath($q, "UserSubnet.NetworkMaskLen", $this->_networkMaskLen);
377:         }
378:         if (0 < $this->_scripts->count()) {
379:             $notes = new \ArrayObject([]);
380:             foreach ($this->_scripts as $script) {
381:                 $notes->append((object)['ID' => $script->_id()]);
382:             }
383:             Util::setByPath($q, "Notes", $notes);
384:         }
385:         $path = "/disk/" . $this->_diskId . "/config";
386:         $this->_client->request("PUT", $path, $q);
387:         return $this;
388:     }
389:     
390:     /**
391:      * @ignore
392:      */
393:     public function __get($key) {
394:         switch ($key) {
395:             case "client": return $this->get_client();
396:             case "diskId": return $this->get_diskId();
397:             case "hostName": return $this->get_hostName();
398:             case "password": return $this->get_password();
399:             case "sshKey": return $this->get_sshKey();
400:             case "sshKeys": return $this->get_sshKeys();
401:             case "ipAddress": return $this->get_ipAddress();
402:             case "defaultRoute": return $this->get_defaultRoute();
403:             case "networkMaskLen": return $this->get_networkMaskLen();
404:             case "scripts": return $this->get_scripts();
405:             default: return null;
406:         }
407:     }
408:     
409:     /**
410:      * @ignore
411:      */
412:     public function __set($key, $v) {
413:         switch ($key) {
414:             case "hostName": return $this->set_hostName($v);
415:             case "password": return $this->set_password($v);
416:             case "sshKey": return $this->set_sshKey($v);
417:             case "ipAddress": return $this->set_ipAddress($v);
418:             case "defaultRoute": return $this->set_defaultRoute($v);
419:             case "networkMaskLen": return $this->set_networkMaskLen($v);
420:             default: throw new SaklientException('non_writable_field', 'Non-writable field: Saklient\\Cloud\\Resources\\DiskConfig#'.$key);
421:         }
422:     }
423: 
424: }
425: 
426: 
API documentation generated by ApiGen 2.8.0