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\Common\Service;
12:
13: use OpenCloud\OpenStack;
14: use OpenCloud\Common\Lang;
15: use OpenCloud\Compute\Resource\Flavor;
16:
17: /**
18: * NovaService serves as an additional abstraction for particular OpenStack services that exhibit shared functionality.
19: */
20: abstract class NovaService extends AbstractService
21: {
22:
23: /**
24: * Returns a flavor from the service
25: *
26: * @param string|null $id
27: * @return Flavor
28: */
29: public function flavor($id = null)
30: {
31: return new Flavor($this, $id);
32: }
33:
34: /**
35: * Returns a list of Flavor objects
36: *
37: * @param boolean $details Returns full details or not.
38: * @param array $filter Array for creating queries
39: * @return Collection
40: */
41: public function flavorList($details = true, array $filter = array())
42: {
43: $path = Flavor::resourceName();
44:
45: if ($details === true) {
46: $path .= '/detail';
47: }
48:
49: return $this->collection('OpenCloud\Compute\Resource\Flavor', $this->getUrl($path, $filter));
50: }
51:
52: /**
53: * Loads the available namespaces from the /extensions resource
54: */
55: protected function loadNamespaces()
56: {
57: foreach ($this->getExtensions() as $object) {
58: $this->namespaces[] = $object->alias;
59: }
60:
61: if (!empty($this->additionalNamespaces)) {
62: $this->namespaces += $this->additionalNamespaces;
63: }
64: }
65:
66: }
67: