Overview

Namespaces

  • None
  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Exceptions
      • Log
      • Request
        • Response
    • Compute
    • Database
    • DNS
    • LoadBalancer
      • Resources
    • ObjectStore
      • Resource
    • Orchestration
    • Volume
  • PHP

Classes

  • Flavor
  • Image
  • Network
  • Server
  • ServerMetadata
  • Service
  • VolumeAttachment
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
 1: <?php
 2: /**
 3:  * PHP OpenCloud library.
 4:  * 
 5:  * @copyright Copyright 2013 Rackspace US, Inc. See COPYING for licensing information.
 6:  * @license   https://www.apache.org/licenses/LICENSE-2.0 Apache 2.0
 7:  * @version   1.6.0
 8:  * @author    Glen Campbell <glen.campbell@rackspace.com>
 9:  * @author    Jamie Hannaford <jamie.hannaford@rackspace.com>
10:  */
11: 
12: namespace OpenCloud\Compute;
13: 
14: use OpenCloud\Common\Lang;
15: use OpenCloud\Common\Exceptions;
16: use OpenCloud\Common\PersistentObject;
17: 
18: /**
19:  * The VolumeAttachment class represents a volume that is attached to a server.
20:  */
21: class VolumeAttachment extends PersistentObject 
22: {
23: 
24:     public $id;
25:     public $device;
26:     public $serverId;
27:     public $volumeId;
28: 
29:     public static $json_name = 'volumeAttachment';
30:     public static $url_resource = 'os-volume_attachments';
31: 
32:     private $createKeys = array('volumeId', 'device');
33: 
34:     /**
35:      * updates are not permitted
36:      *
37:      * @throws OpenCloud\UpdateError always
38:      */
39:     public function update($params = array()) 
40:     {
41:         throw new Exceptions\UpdateError(Lang::translate('Updates are not permitted'));
42:     }
43: 
44:     /**
45:      * returns a readable name for the attachment
46:      *
47:      * Since there is no 'name' attribute, we'll hardcode something
48:      *
49:      * @api
50:      * @return string
51:      */
52:     public function name() 
53:     {
54:         return sprintf('Attachment [%s]', $this->volumeId ?: 'N/A');
55:     }
56: 
57:     /**
58:      * returns the JSON object for Create()
59:      *
60:      * @return stdClass
61:      */
62:     protected function createJson() 
63:     {
64:         $object = new \stdClass;
65:         
66:         foreach($this->createKeys as $key) {
67:             if (isset($this->$key)) {
68:                 $object->$key = $this->$key;
69:             }
70:         }
71: 
72:         return (object) array(
73:             $this->jsonName() => $object
74:         );
75:     }
76: 
77: }
78: 
PHP OpenCloud API API documentation generated by ApiGen 2.8.0