     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:     /**
    29:      * Returns a flavor from the service
    30:      *
    31:      * @param string|null $id
    32:      * @return Flavor
    33:      */
    34:     public function flavor($id = null)
    35:     {
    36:         return new Flavor($this, $id);
    37:     }
    38:
    39:     /**
    40:      * Returns a list of Flavor objects
    41:      *
    42:      * @param boolean $details Returns full details or not.
    43:      * @param array   $filter  Array for creating queries
    44:      * @return Collection
    45:      */
    46:     public function flavorList($details = true, array $filter = array())
    47:     {
    48:         $path = Flavor::resourceName();
    49:
    50:         if ($details === true) {
    51:             $path .= '/detail';
    52:         }
    53:
    54:         return $this->collection('OpenCloud\Compute\Resource\Flavor', $this->getUrl($path, $filter));
    55:     }
    56:
    57:     /**
    58:      * Loads the available namespaces from the /extensions resource
    59:      */
    60:     protected function loadNamespaces()
    61:     {
    62:         foreach ($this->getExtensions() as $object) {
    63:             $this->namespaces[] = $object->alias;
    64:         }
    65:
    66:         if (!empty($this->additionalNamespaces)) {
    67:             $this->namespaces += $this->additionalNamespaces;
    68:         }
    69:     }
    70: }
    71: