Overview
  • Namespace
  • Class

Namespaces

  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Collection
      • Exception
      • Resource
    • Common
      • Collection
      • Constants
      • Exceptions
      • Http
        • Message
      • Log
      • Resource
      • Service
    • Compute
      • Constants
      • Exception
      • Resource
    • Database
      • Resource
    • DNS
      • Collection
      • Resource
    • Identity
      • Constants
      • Resource
    • Image
      • Enum
      • Resource
        • JsonPatch
        • Schema
    • LoadBalancer
      • Collection
      • Enum
      • Resource
    • Networking
      • Resource
    • ObjectStore
      • Constants
      • Exception
      • Resource
      • Upload
    • Orchestration
      • Resource
    • Queues
      • Collection
      • Exception
      • Resource
    • Volume
      • Resource

Classes

  • OpenCloud\Volume\Resource\Snapshot
  • OpenCloud\Volume\Resource\Volume
  • OpenCloud\Volume\Resource\VolumeType
 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\Orchestration\Resource;
19 
20 use OpenCloud\Common\Http\Message\Formatter;
21 use OpenCloud\Common\Resource\ReadOnlyResource;
22 
23 /**
24  * Class that represents a resource in a stack.
25  * @see http://developer.openstack.org/api-ref-orchestration-v1.html#stack-resources
26  *
27  * @package OpenCloud\Orchestration\Resource
28  */
29 class Resource extends ReadOnlyResource
30 {
31     protected static $url_resource = 'resources';
32     protected static $json_name = 'resource';
33 
34     protected $name;
35     protected $description;
36     protected $status;
37     protected $statusReason;
38     protected $logicalId;
39     protected $physicalId;
40     protected $requiredBy;
41     protected $updatedTime;
42     protected $type;
43     protected $links;
44 
45     protected $aliases = array(
46         'resource_name'          => 'name',
47         'resource_status'        => 'status',
48         'resource_status_reason' => 'statusReason',
49         'logical_resource_id'    => 'logicalId',
50         'physical_resource_id'   => 'physicalId',
51         'required_by'            => 'requiredBy',
52         'updated_time'           => 'updatedTime',
53         'resource_type'          => 'type'
54     );
55 
56     public function primaryKeyField()
57     {
58         return 'name';
59     }
60 
61     /**
62      * Returns metadata properties associated with this Resource
63      *
64      * @return \stdClass
65      */
66     public function getMetadata()
67     {
68         $url = clone $this->getUrl();
69         $url->addPath('metadata');
70 
71         $response = $this->getClient()->get($url)->send();
72         $json = Formatter::decode($response);
73 
74         return $json->metadata;
75     }
76 
77     /**
78      * Returns a list of Events associated with this Resource
79      *
80      * @param array $params
81      * @return \OpenCloud\Common\Collection\PaginatedIterator
82      */
83     public function listEvents(array $params = array())
84     {
85         $url = clone $this->getUrl();
86         $url->addPath(Event::resourceName())->setQuery($params);
87 
88         return $this->getService()->resourceList('Event', $url, $this);
89     }
90 
91     public function getEvent($id)
92     {
93         return $this->getService()->resource('Event', $id, $this);
94     }
95 }
96 
API documentation generated by ApiGen