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

  • Snapshot
  • Volume
  • VolumeType
  • 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\Volume\Resource;
12: 
13: use OpenCloud\Common\PersistentObject;
14: use OpenCloud\Common\Lang;
15: use OpenCloud\Common\Exceptions;
16: 
17: /**
18:  * The Volume class represents a single block storage volume
19:  */
20: class Volume extends PersistentObject 
21: {
22: 
23:     public $id;
24:     public $status;
25:     public $display_name;
26:     public $display_description;
27:     public $size;
28:     public $volume_type;
29:     public $metadata = array();
30:     public $availability_zone;
31:     public $snapshot_id;
32:     public $attachments = array();
33:     public $created_at;
34:     
35:     protected static $json_name = 'volume';
36:     protected static $url_resource = 'volumes';
37: 
38:     protected $createKeys = array(
39:         'snapshot_id',
40:         'display_name',
41:         'display_description',
42:         'size',
43:         'volume_type',
44:         'availability_zone'
45:     );
46: 
47:     // Normally we'd populate a sibling object when this one refreshes
48:     // but there are times (i.e. during creation) when the NAME of the VolumeType
49:     // is returned, instead of its primary key...
50:     protected $associatedResources = array(
51:         //'volume_type' => 'VolumeType'
52:     );
53:     
54:     public function update($params = array()) 
55:     {
56:         throw new Exceptions\UpdateError(
57:             Lang::translate('Block storage volumes cannot be updated')
58:         );
59:     }
60: 
61:     public function name() 
62:     {
63:         return $this->display_name;
64:     }
65: 
66:     protected function createJson() 
67:     {
68:         $element = parent::createJson();
69: 
70:         if ($this->propertyExists('volume_type') 
71:             && $this->getProperty('volume_type') instanceof VolumeType
72:         ) {
73:             $element->volume->volume_type = $this->volume_type->name();
74:         }
75: 
76:         return $element;
77:     }
78: 
79: }
80: 
PHP OpenCloud API API documentation generated by ApiGen 2.8.0