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;
12:
13: use OpenCloud\OpenStack;
14: use OpenCloud\Common\Service\NovaService;
15:
16: class Service extends NovaService
17: {
18: const DEFAULT_TYPE = 'volume';
19: const DEFAULT_NAME = 'cloudBlockStorage';
20:
21: /**
22: * Returns a Volume object
23: *
24: * @api
25: * @param string $id the Volume ID
26: * @return VolumeService\Volume
27: */
28: public function volume($id = null)
29: {
30: return new Resource\Volume($this, $id);
31: }
32:
33: /**
34: * Returns a Collection of Volume objects
35: *
36: * @api
37: * @param boolean $details if TRUE, return all details
38: * @param array $filters array of filter key/value pairs
39: * @return Collection
40: */
41: public function volumeList($details = true, $filter = array())
42: {
43: $url = clone $this->getUrl(Resource\Volume::ResourceName());
44: if ($details) {
45: $url->addPath('detail');
46: }
47: return $this->collection('OpenCloud\Volume\Resource\Volume', $url);
48: }
49:
50: /**
51: * Returns a VolumeType object
52: *
53: * @api
54: * @param string $id the VolumeType ID
55: * @return VolumeService\Volume
56: */
57: public function volumeType($id = null)
58: {
59: return new Resource\VolumeType($this, $id);
60: }
61:
62: /**
63: * Returns a Collection of VolumeType objects
64: *
65: * @api
66: * @param array $filters array of filter key/value pairs
67: * @return Collection
68: */
69: public function volumeTypeList($filter = array())
70: {
71: return $this->collection('\OpenCloud\Volume\Resource\VolumeType');
72: }
73:
74: /**
75: * returns a Snapshot object associated with this volume
76: *
77: * @return Snapshot
78: */
79: public function snapshot($id = null)
80: {
81: return new Resource\Snapshot($this, $id);
82: }
83:
84: /**
85: * Returns a Collection of Snapshot objects
86: *
87: * @api
88: * @param boolean $detail TRUE to return full details
89: * @param array $filters array of filter key/value pairs
90: * @return Collection
91: */
92: public function snapshotList($filter = array())
93: {
94: return $this->collection('OpenCloud\Volume\Resource\Snapshot');
95: }
96:
97: }
98: