OpenCloud/Database/Instance.php

Properties

Description

A Cloud Databases instance (similar to a Compute Server)

Classes

Instance

Properties

 
 
No 
No 

Description

Instance represents an instance of DbService, similar to a Server in a Compute service
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, Database, DatabaseList, EnableRootUser, IsRootEnabled, Resize, ResizeJson, ResizeVolume, ResizeVolumeJson, Restart, RestartJson, Update, User, UserList, __construct,

CreateJson( ) : \stdClass

Description

Generates the JSON string for Create()

Return value

Type Description
\stdClass

Database( string   $name = '', ) : \OpenCloud\Database\Database

Description

Returns a new Database object

Arguments

Name Type Description Default
$name string

the database name

''

Return value

Type Description
\OpenCloud\Database\Database

DatabaseList( ) : \OpenCloud\Common\Collection

Description

Returns a Collection of all databases in the instance

Return value

Type Description
\OpenCloud\Common\Collection

Tags

Name Description
throws if HTTP status is not Success

EnableRootUser( ) : \OpenCloud\Database\User

Description

Enables the root user for the instance

Return value

Type Description
\OpenCloud\Database\User the root user, including name and password

Tags

Name Description
api
throws if HTTP response is not Success

IsRootEnabled( ) : boolean

Description

Returns TRUE if the root user is enabled

Return value

Type Description
boolean TRUE if the root user is enabled; FALSE otherwise

Tags

Name Description
api
throws if HTTP status is not Success

Resize( \OpenCloud\Compute\Flavor   $flavor, ) : n/a

Description

Resizes the database instance (sets RAM)

Arguments

Name Type Description Default
$flavor \OpenCloud\Compute\Flavor

a flavor object

Return value

Type Description
n/a n/a

Tags

Name Description
api
returns \OpenCloud\HttpResponse

ResizeJson(   $flavorRef, ) : n/a

Description

Generates the JSON object for Resize

Arguments

Name Type Description Default
$flavorRef n/a

Return value

Type Description
n/a n/a

ResizeVolume( integer   $newvolumesize, ) : \OpenCloud\HttpResponse

Description

Resizes the volume associated with the database instance (disk space)

Arguments

Name Type Description Default
$newvolumesize integer

the size of the new volume, in gigabytes

Return value

Type Description
\OpenCloud\HttpResponse

Tags

Name Description
api

ResizeVolumeJson(   $size, ) : n/a

Description

Generates the JSON object for ResizeVolume

Arguments

Name Type Description Default
$size n/a

Return value

Type Description
n/a n/a

Restart( ) : n/a

Description

Restarts the database instance

Return value

Type Description
n/a n/a

Tags

Name Description
api
returns \OpenCloud\HttpResponse

RestartJson( ) : n/a

Description

Generates the JSON object for Restart

Return value

Type Description
n/a n/a

Update(   $params = array(), ) : n/a

Description

Updates a database instance (not permitted)
Update() is not supported by database instances; thus, this always throws an exception.

Arguments

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

Return value

Type Description
n/a n/a

Tags

Name Description
throws always

User( string   $name = '', array   $databases = array(), ) : \OpenCloud\Database\User

Description

Returns a new User object

Arguments

Name Type Description Default
$name string

the user name

''
$databases array

a simple array of database names

array()

Return value

Type Description
\OpenCloud\Database\User

UserList( ) : \OpenCloud\Common\Collection

Description

Returns a Collection of all users in the instance

Return value

Type Description
\OpenCloud\Common\Collection

Tags

Name Description
throws if HTTP status is not Success

__construct( \OpenCloud\DbService   $service, mixed   $info = null, ) : n/a

Description

Creates a new instance object
This could use the default constructor, but we want to make sure that the volume attribute is an object.

Arguments

Name Type Description Default
$service \OpenCloud\DbService

the DbService object associated with this

$info mixed

the ID or array of info for the object

null

Return value

Type Description
n/a n/a

Properties

$_databases, $_users, $created, $flavor, $hostname, $id, $json_name, $links, $name, $status, $updated, $url_resource, $volume,

  private  $_databases =




  private  $_users =




  public  $created =




  public  $flavor =




  public  $hostname =




  public  $id =




  protected  static $json_name = 'instance'




  public  $links =




  public  $name =




  public  $status =




  public  $updated =




  protected  static $url_resource = 'instances'




  public  $volume =




Documentation was generated by phpDocumentor 2.0.0b6 .

Namespaces

Packages