Class PersistentObject
Represents an object that can be retrieved, created, updated and deleted.
This class abstracts much of the common functionality between:
* Nova servers; * Swift containers and objects; * DBAAS instances; * Cinder
volumes; * and various other objects that: * have a URL; * can be created,
updated, deleted, or retrieved; * use a standard JSON format with a top-level
element followed by a child object with attributes.
In general, you can create a persistent object class by subclassing this
class and defining some protected, static variables:
* $url_resource - the sub-resource value in the URL of the parent. For example,
if the parent URL is http://something/parent
, then setting this
value to "another" would result in a URL for the persistent object of
http://something/parent/another
.
* $json_name - the top-level JSON object name. For example, if the persistent
object is represented by {"foo": {"attr":value, ...}}
, then set
$json_name to "foo".
* $json_collection_name - optional; this value is the name of a collection of
the persistent objects. If not provided, it defaults to json_name
with an appended "s" (e.g., if json_name
is "foo", then
json_collection_name
would be "foos"). Set this value if the
collection name doesn't follow this pattern.
* $json_collection_element - the common pattern for a collection is:
{"collection": [{"attr":"value",...}, {"attr":"value",...}, ...]}
That is, each element of the array is a \stdClass object containing the object's
attributes. In rare instances, the objects in the array are named, and
json_collection_element
contains the name of the collection
objects. For example, in this JSON response:
{"allowedDomain":[{"allowedDomain":{"name":"foo"}}]}
,
json_collection_element
would be set to "allowedDomain".
The PersistentObject class supports the standard CRUD methods; if these are
not needed (i.e. not supported by the service), the subclass should redefine
these to call the noCreate
, noUpdate
, or
noDelete
methods, which will trigger an appropriate exception. For
example, if an object cannot be created:
function create($params = array()) { $this->noCreate(); }
- OpenCloud\Common\Base
-
OpenCloud\Common\PersistentObject
Direct known subclasses
OpenCloud\Autoscale\Resource\AbstractResource, OpenCloud\CloudMonitoring\Resource\AbstractResource, OpenCloud\Database\Resource\User, OpenCloud\DNS\Resource\AsyncResponse, OpenCloud\DNS\Resource\Object, OpenCloud\LoadBalancer\Resource\LoadBalancer, OpenCloud\LoadBalancer\Resource\Node, OpenCloud\LoadBalancer\Resource\SubResource, OpenCloud\Queues\Resource\Claim, OpenCloud\Queues\Resource\Message, OpenCloud\Queues\Resource\Queue, OpenCloud\Volume\Resource\Snapshot, OpenCloud\Compute\Resource\Flavor, OpenCloud\Volume\Resource\Volume, OpenCloud\Volume\Resource\VolumeType, OpenCloud\Compute\Resource\Image, OpenCloud\Compute\Resource\KeyPair, OpenCloud\Compute\Resource\Network, OpenCloud\Compute\Resource\Server, OpenCloud\Compute\Resource\VolumeAttachment, OpenCloud\Database\Resource\Database, OpenCloud\Database\Resource\InstanceIndirect known subclasses
OpenCloud\Autoscale\Resource\Group, OpenCloud\Autoscale\Resource\GroupConfiguration, OpenCloud\CloudMonitoring\Resource\NotificationPlan, OpenCloud\CloudMonitoring\Resource\ReadonlyResource, OpenCloud\DNS\Resource\Domain, OpenCloud\DNS\Resource\PtrRecord, OpenCloud\DNS\Resource\Record, OpenCloud\DNS\Resource\Subdomain, OpenCloud\LoadBalancer\Resource\Access, OpenCloud\LoadBalancer\Resource\Algorithm, OpenCloud\LoadBalancer\Resource\AllowedDomain, OpenCloud\LoadBalancer\Resource\BillableLoadBalancer, OpenCloud\Autoscale\Resource\LaunchConfiguration, OpenCloud\LoadBalancer\Resource\ConnectionLogging, OpenCloud\LoadBalancer\Resource\ConnectionThrottle, OpenCloud\LoadBalancer\Resource\ContentCaching, OpenCloud\LoadBalancer\Resource\ErrorPage, OpenCloud\LoadBalancer\Resource\HealthMonitor, OpenCloud\LoadBalancer\Resource\Metadata, OpenCloud\LoadBalancer\Resource\NodeEvent, OpenCloud\LoadBalancer\Resource\Protocol, OpenCloud\LoadBalancer\Resource\Readonly, OpenCloud\LoadBalancer\Resource\SessionPersistence, OpenCloud\Autoscale\Resource\ScalingPolicy, OpenCloud\LoadBalancer\Resource\SSLTermination, OpenCloud\LoadBalancer\Resource\Stats, OpenCloud\LoadBalancer\Resource\Usage, OpenCloud\LoadBalancer\Resource\VirtualIp, OpenCloud\Autoscale\Resource\Webhook, OpenCloud\CloudMonitoring\Resource\AgentToken, OpenCloud\CloudMonitoring\Resource\Alarm, OpenCloud\CloudMonitoring\Resource\Check, OpenCloud\CloudMonitoring\Resource\Entity, OpenCloud\CloudMonitoring\Resource\Notification
public
|
#
__construct( mixed $service = null, mixed $info = null )
Retrieves the instance from persistent storage |
public
|
#
setService(
Sets the service associated with this resource object. |
public
|
#
getService( )
Returns the service object for this resource; required for making requests, etc. because it has direct access to the Connection. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
HttpResponse
|
|
public
|
|
public
HttpResponse
|
|
public
|
|
public
HttpResponse
|
|
public
string
|
|
public
|
|
public
|
|
protected
|
|
protected
|
|
protected
|
#
updateJson( mixed $params = array() )
Returns an object for the Update() method JSON Must be overridden in a child class. |
protected
|
|
protected
|
|
protected
|
|
public
string
|
|
public
string
|
|
public
string
|
|
public
|
|
public
|
|
public
string
|
|
public
string
|
|
protected
string
|
|
public static
|
|
public static
string
|
|
public static
string
|
|
public static
|
#
resourceName( )
Returns the resource name for the URL of the object; must be overridden in child classes |
public
|
protected
mixed
|
$metadata |
|