1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
<?php
namespace OpenCloud\Orchestration\Resource;
use OpenCloud\Common\Http\Message\Formatter;
use OpenCloud\Common\Resource\ReadOnlyResource;
class Resource extends ReadOnlyResource
{
protected static $url_resource = 'resources';
protected static $json_name = 'resource';
protected $name;
protected $description;
protected $status;
protected $statusReason;
protected $logicalId;
protected $physicalId;
protected $requiredBy;
protected $updatedTime;
protected $type;
protected $links;
protected $aliases = array(
'resource_name' => 'name',
'resource_status' => 'status',
'resource_status_reason' => 'statusReason',
'logical_resource_id' => 'logicalId',
'physical_resource_id' => 'physicalId',
'required_by' => 'requiredBy',
'updated_time' => 'updatedTime',
'resource_type' => 'type'
);
public function primaryKeyField()
{
return 'name';
}
public function getMetadata()
{
$url = clone $this->getUrl();
$url->addPath('metadata');
$response = $this->getClient()->get($url)->send();
$json = Formatter::decode($response);
return $json->metadata;
}
public function listEvents(array $params = array())
{
$url = clone $this->getUrl();
$url->addPath(Event::resourceName())->setQuery($params);
return $this->getService()->resourceList('Event', $url, $this);
}
public function getEvent($id)
{
return $this->getService()->resource('Event', $id, $this);
}
}