1 <?php
2 /**
3 * Copyright 2012-2014 Rackspace US, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 namespace OpenCloud\Common\Service;
19
20 use OpenCloud\Compute\Resource\Flavor;
21
22 /**
23 * NovaService serves as an additional abstraction for particular OpenStack services that exhibit shared functionality.
24 */
25 abstract class NovaService extends CatalogService
26 {
27 /**
28 * Returns a flavor from the service
29 *
30 * @param string|null $id
31 * @return Flavor
32 */
33 public function flavor($id = null)
34 {
35 return new Flavor($this, $id);
36 }
37
38 /**
39 * Returns a list of Flavor objects
40 *
41 * @param boolean $details Returns full details or not.
42 * @param array $filter Array for creating queries
43 * @return Collection
44 */
45 public function flavorList($details = true, array $filter = array())
46 {
47 $path = Flavor::resourceName();
48
49 if ($details === true) {
50 $path .= '/detail';
51 }
52
53 return $this->collection('OpenCloud\Compute\Resource\Flavor', $this->getUrl($path, $filter));
54 }
55
56 /**
57 * Loads the available namespaces from the /extensions resource
58 */
59 protected function loadNamespaces()
60 {
61 foreach ($this->getExtensions() as $object) {
62 $this->namespaces[] = $object->alias;
63 }
64
65 if (!empty($this->additionalNamespaces)) {
66 $this->namespaces += $this->additionalNamespaces;
67 }
68 }
69 }
70