Overview

Namespaces

  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Collection
      • Constants
      • Exceptions
      • Http
        • Message
      • Identity
      • Log
      • Service
    • Compute
      • Constants
      • Exception
      • Resource
    • Database
      • Resource
    • DNS
      • Resource
    • LoadBalancer
      • Resource
    • ObjectStore
      • Constants
      • Exception
      • Resource
      • Upload
    • Orchestration
    • Queues
      • Exception
      • Resource
    • Volume
      • Resource
  • PHP

Classes

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