OpenCloud/CloudMonitoring/Resource/AbstractResource.php

Classes

AbstractResource

Properties

 
 
 
 
Yes 
No 

Description

Abstract AbstractResource class.
This class abstracts much of the common functionality between Nova servers, Swift containers and objects, DBAAS instances, Cinder volumes, and various other objects that (a) have a URL, (b) can be created, updated, deleted, or retrieved, and (c) 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 = '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"` by default). 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 an anonymous object containing the object's attributes. In (very) rare instances, the objects in the array are named, and `json_collection_element` contains the name of the collection objects. For example, in this: `{"allowedDomain":[{"allowedDomain":{"name":"foo"}}]}`, then `json_collection_element` would be set to `'allowedDomain'`. The PersistentObject class supports the standard `Create()`, `Update()`, and `Delete()` 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($parm=array()) { $this->NoCreate(); } This will cause any call to the `Create()` method to fail with an exception.

Methods

CreateJson, Delete, Parent, Request, Service, Update, UpdateJson, Url, __construct, getProperty, listAll, refresh, setParent, setService, test, testExisting, updateUrl,

CreateJson( ) : void

Description

Procedure for JSON create object.

Return value

Type Description
void

Tags

Name Description
access protected

Delete( ) : void

Description

Delete object.

Return value

Type Description
void

Tags

Name Description
access public

Parent( ) : void

Description

Retrieve parent object.

Return value

Type Description
void

Tags

Name Description
access public

Request( mixed   $url, string   $method = 'GET', array   $headers = array(), mixed   $body = null, ) : void

Description

Request function.

Arguments

Name Type Description Default
$url mixed
$method string

(default: 'GET')

'GET'
$headers array

(default: array())

array()
$body mixed

(default: null)

null

Return value

Type Description
void

Tags

Name Description
access protected

Service( ) : n/a

Return value

Type Description
n/a n/a

Update( array   $params = array(), ) : void

Description

Update object.

Arguments

Name Type Description Default
$params array

(default: array())

array()

Return value

Type Description
void

Tags

Name Description
access public

UpdateJson(   $params = array(), ) : void

Description

Procedure for JSON update object.

Arguments

Name Type Description Default
$params n/a array()

Return value

Type Description
void

Tags

Name Description
access protected

Url( string   $subresource = '',   $query = array(), ) : void

Description

Url function.

Arguments

Name Type Description Default
$subresource string

(default: '')

''
$query n/a array()

Return value

Type Description
void

Tags

Name Description
access public

__construct( mixed   $service, mixed   $info, ) : void

Description

__construct function.

Arguments

Name Type Description Default
$service mixed
$info mixed

Return value

Type Description
void

Tags

Name Description
access public

getProperty( mixed   $haystack, mixed   $needle, ) : void

Description

Retrieve property from array/object.

Arguments

Name Type Description Default
$haystack mixed
$needle mixed

Return value

Type Description
void

Tags

Name Description
access public

listAll( ) : void

Description

Retrieves a collection of resource objects.

Return value

Type Description
void

Tags

Name Description
access public

refresh(   $id = null,   $url = null, ) : n/a

Arguments

Name Type Description Default
$id n/a null
$url n/a null

Return value

Type Description
n/a n/a

setParent( mixed   $parent, ) : void

Description

Set parent object.

Arguments

Name Type Description Default
$parent mixed

Return value

Type Description
void

Tags

Name Description
access public

setService( mixed   $service, ) : void

Description

Set main service object.

Arguments

Name Type Description Default
$service mixed

Return value

Type Description
void

Tags

Name Description
access public

test( array   $params = array(), bool   $debug = false, ) : void

Description

Test the validity of certain parameters for the resource.

Arguments

Name Type Description Default
$params array

(default: array())

array()
$debug bool

(default: false)

false

Return value

Type Description
void

Tags

Name Description
access public

testExisting( bool   $debug = false, ) : void

Description

Test the validity of an existing resource.

Arguments

Name Type Description Default
$debug bool

(default: false)

false

Return value

Type Description
void

Tags

Name Description
access public

updateUrl( ) : n/a

Return value

Type Description
n/a n/a

Properties

$id, $name, $parent, $service,

mixed  public  $id =

Unique identifier


mixed  public  $name =

Name


mixed  public  $parent =

Parent object


mixed  public  $service =

Service object


Documentation was generated by phpDocumentor 2.0.0b6 .

Namespaces

Packages