Documentation

Instance extends NovaResource
in package

Instance represents an instance of DbService, similar to a Server in a Compute service

Table of Contents

PATCH_CONTENT_TYPE  = OpenCloudCommonConstantsMime::JSON_PATCH
$backupRef  : mixed
$created  : mixed
$flavor  : mixed
$hostname  : mixed
$id  : mixed
$links  : mixed
$name  : mixed
$status  : mixed
$updated  : mixed
$volume  : mixed
$aliases  : array<string|int, mixed>
The aliases configure for the properties of the instance.
$json_name  : mixed
$metadata  : Metadata
$parent  : BaseResource
$service  : ServiceInterface
$url_resource  : mixed
$_databases  : mixed
$_users  : mixed
$logger  : LoggerInterface
The logger instance
$properties  : array<string|int, mixed>
Holds all the properties added by overloading.
__call()  : mixed
Intercept non-existent method calls for dynamic getter/setter functionality.
__construct()  : mixed
Creates a new instance object
backupList()  : PaginatedIterator
Returns a Collection of all backups for the instance
checkExtension()  : bool
Check whether an extension is valid
checkJsonError()  : mixed
Checks the most recent JSON operation for errors.
create()  : Response
Create a new resource
createBackup()  : Backup
Creates a backup for the given instance
createUrl()  : Url
database()  : Database
Returns a new Database object
databaseList()  : PaginatedIterator
Returns a Collection of all databases in the instance
delete()  : Response
Delete this resource
enableRootUser()  : User
Enables the root user for the instance
findLink()  : bool
Find a resource link based on a type
generateUuid()  : mixed
getClient()  : ClientInterface
Convenience method to return the service's client
getInstance()  : static
getLogger()  : LoggerInterface
Returns the Logger object.
getMetadata()  : Metadata
getParent()  : mixed
getService()  : ServiceInterface
getUrl()  : mixed
Get this resource's URL
hasLogger()  : bool
id()  : mixed
isRootEnabled()  : bool
Returns TRUE if the root user is enabled
jsonCollectionElement()  : string
Returns the nested keys that could (rarely) prefix collection items. For example:
jsonCollectionName()  : string
Returns the top-level key for collection responses
jsonName()  : mixed
Returns the top-level key for the returned response JSON document
makeResourceIteratorOptions()  : mixed
name()  : string
parseResponse()  : mixed
Parse a HTTP response for the required content
populate()  : mixed
refresh()  : Response
Refresh the state of a resource
refreshFromLocationUrl()  : mixed
Given a `location` URL, refresh this resource
region()  : mixed
resize()  : mixed
Resizes the database instance (sets RAM)
resizeVolume()  : HttpResponse
Resizes the volume associated with the database instance (disk space)
resourceName()  : mixed
Returns the URI path for this resource
restart()  : mixed
Restarts the database instance
setLogger()  : $this
Sets the logger.
setMetadata()  : $this
setParent()  : self
setService()  : PersistentObject
status()  : string
stripNamespace()  : mixed
toCamel()  : mixed
Convert a string to camelCase format.
toUnderscores()  : mixed
Convert string to underscore format.
update()  : Response
Update a resource
url()  : mixed
user()  : User
Returns a new User object
userList()  : PaginatedIterator
Returns a Collection of all users in the instance
waitFor()  : mixed
A method to repeatedly poll the API resource, waiting for an eventual state change
action()  : Response
This method is used for many purposes, such as rebooting server, etc.
createJson()  : stdClass
Generates the JSON string for Create()
generateJsonPatch()  : string
Generates a JSON Patch representation and return its
getAlias()  : string
Returns the alias configured for the given key. If no alias exists it returns the original key.
getJsonHeader()  : mixed
getPatchHeaders()  : mixed
getProperty()  : mixed
Grab value out of the data array.
getUpdateablePropertiesAsArray()  : mixed
Returns the object's properties as an array
noCreate()  : mixed
noDelete()  : mixed
noUpdate()  : mixed
primaryKeyField()  : string
Returns the primary key field for the object
propertyExists()  : bool
Basic check to see whether property exists.
recursivelyAliasPropertyValue()  : mixed
Returns the given property value's alias, if configured; Else, the unchanged property value is returned. If the given property value is an array or an instance of \stdClass, it is aliases recursively.
refreshFromParent()  : mixed
Causes resource to refresh based on parent's URL
setProperty()  : mixed
We can set a property under three conditions:
updateJson()  : mixed
Generates the JSON string for update()
checkAttributePrefix()  : bool
Checks the attribute $property and only permits it if the prefix is in the specified $prefixes array
isAccessible()  : bool
Does the property exist in the object variable list (i.e. does it have public or protected visibility?)
resizeJson()  : mixed
Generates the JSON object for Resize
resizeVolumeJson()  : mixed
Generates the JSON object for ResizeVolume
restartJson()  : mixed
Generates the JSON object for Restart

Constants

PATCH_CONTENT_TYPE

public mixed PATCH_CONTENT_TYPE = OpenCloudCommonConstantsMime::JSON_PATCH

Properties

$aliases

The aliases configure for the properties of the instance.

protected array<string|int, mixed> $aliases = array()

$json_name

protected static mixed $json_name = 'instance'

$url_resource

protected static mixed $url_resource = 'instances'

$properties

Holds all the properties added by overloading.

private array<string|int, mixed> $properties = array()

Methods

__call()

Intercept non-existent method calls for dynamic getter/setter functionality.

public __call( $method,  $args) : mixed
Parameters
$method :
$args :
Tags
throws
RuntimeException
Return values
mixed —

__construct()

Creates a new instance object

public __construct(DbService $service[, mixed $info = null ]) : mixed

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

Parameters
$service : DbService

the DbService object associated with this

$info : mixed = null

the ID or array of info for the object

Return values
mixed —

backupList()

Returns a Collection of all backups for the instance

public backupList() : PaginatedIterator
Return values
PaginatedIterator —

checkJsonError()

Checks the most recent JSON operation for errors.

public static checkJsonError() : mixed
Tags
throws
JsonError
codeCoverageIgnore
Return values
mixed —

create()

Create a new resource

public create([array<string|int, mixed> $params = array() ]) : Response
Parameters
$params : array<string|int, mixed> = array()
Return values
Response —

createBackup()

Creates a backup for the given instance

public createBackup([array<string|int, mixed> $params = array() ]) : Backup
Parameters
$params : array<string|int, mixed> = array()
  • an associate array of key/value pairs name is required description is optional
Return values
Backup —

database()

Returns a new Database object

public database([string $name = '' ]) : Database
Parameters
$name : string = ''

the database name

Return values
Database —

databaseList()

Returns a Collection of all databases in the instance

public databaseList() : PaginatedIterator
Return values
PaginatedIterator —

enableRootUser()

Enables the root user for the instance

public enableRootUser() : User
Tags
throws
InstanceError

if HTTP response is not Success

Return values
User —

the root user, including name and password

Find a resource link based on a type

public findLink([string $type = 'self' ]) : bool
Parameters
$type : string = 'self'
Return values
bool —

generateUuid()

public static generateUuid() : mixed
Return values
mixed —

getInstance()

public static getInstance() : static
Return values
static —

getParent()

public getParent() : mixed
Return values
mixed —

getUrl()

Get this resource's URL

public getUrl([null $path = null ][, array<string|int, mixed> $query = array() ]) : mixed
Parameters
$path : null = null

URI path to add on

$query : array<string|int, mixed> = array()

Query to add on

Return values
mixed —

hasLogger()

public hasLogger() : bool
Return values
bool —

isRootEnabled()

Returns TRUE if the root user is enabled

public isRootEnabled() : bool
Tags
throws
InstanceError

if HTTP status is not Success

Return values
bool —

TRUE if the root user is enabled; FALSE otherwise

jsonCollectionElement()

Returns the nested keys that could (rarely) prefix collection items. For example:

public static jsonCollectionElement() : string

{ "keypairs": [ { "keypair": { "fingerprint": "...", "name": "key1", "public_key": "..." } }, { "keypair": { "fingerprint": "...", "name": "key2", "public_key": "..." } } ] }

In the above example, "keypairs" would be the $json_collection_name and "keypair" would be the $json_collection_element

Return values
string —

jsonCollectionName()

Returns the top-level key for collection responses

public static jsonCollectionName() : string
Return values
string —

jsonName()

Returns the top-level key for the returned response JSON document

public static jsonName() : mixed
Tags
throws
DocumentError
Return values
mixed —

makeResourceIteratorOptions()

public makeResourceIteratorOptions(mixed $resource) : mixed
Parameters
$resource : mixed
Return values
mixed —

parseResponse()

Parse a HTTP response for the required content

public parseResponse(Response $response) : mixed
Parameters
$response : Response
Return values
mixed —

populate()

public populate(mixed $info[, mixed $setObjects = true ]) : mixed
Parameters
$info : mixed
$setObjects : mixed = true
Return values
mixed —

refreshFromLocationUrl()

Given a `location` URL, refresh this resource

public refreshFromLocationUrl( $url) : mixed
Parameters
$url :
Return values
mixed —

resize()

Resizes the database instance (sets RAM)

public resize(Flavor $flavor) : mixed
Parameters
$flavor : Flavor

a flavor object

Tags
returns

\OpenCloud\HttpResponse

Return values
mixed —

resizeVolume()

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

public resizeVolume(int $newvolumesize) : HttpResponse
Parameters
$newvolumesize : int

the size of the new volume, in gigabytes

Return values
HttpResponse —

resourceName()

Returns the URI path for this resource

public static resourceName() : mixed
Tags
throws
UrlError
Return values
mixed —

restart()

Restarts the database instance

public restart() : mixed
Tags
returns

\OpenCloud\HttpResponse

Return values
mixed —

setMetadata()

public setMetadata(mixed $data) : $this
Parameters
$data : mixed
Return values
$this —

stripNamespace()

public stripNamespace(mixed $namespace) : mixed
Parameters
$namespace : mixed
Return values
mixed —

toCamel()

Convert a string to camelCase format.

public toCamel( $string[, bool $capitalise = true ]) : mixed
Parameters
$string :
$capitalise : bool = true

Optional flag which allows for word capitalization.

Return values
mixed —

toUnderscores()

Convert string to underscore format.

public toUnderscores( $string) : mixed
Parameters
$string :
Return values
mixed —

update()

Update a resource

public update([array<string|int, mixed> $params = array() ]) : Response
Parameters
$params : array<string|int, mixed> = array()
Return values
Response —

url()

public url([mixed $path = null ][, array<string|int, mixed> $query = array() ]) : mixed
Parameters
$path : mixed = null
$query : array<string|int, mixed> = array()
Tags
deprecated
Return values
mixed —

user()

Returns a new User object

public user([string $name = '' ][, array<string|int, mixed> $databases = array() ]) : User
Parameters
$name : string = ''

the user name

$databases : array<string|int, mixed> = array()

a simple array of database names

Return values
User —

userList()

Returns a Collection of all users in the instance

public userList() : PaginatedIterator
Return values
PaginatedIterator —

waitFor()

A method to repeatedly poll the API resource, waiting for an eventual state change

public waitFor([null $state = null ][, null $timeout = null ][, null $callback = null ][, null $interval = null ]) : mixed
Parameters
$state : null = null

The expected state of the resource

$timeout : null = null

The maximum timeout to wait

$callback : null = null

The callback to use to check the state

$interval : null = null

How long between each refresh request

Return values
mixed —

action()

This method is used for many purposes, such as rebooting server, etc.

protected action( $object) : Response
Parameters
$object :
Tags
throws
RuntimeException
throws
InvalidArgumentException
Return values
Response —

createJson()

Generates the JSON string for Create()

protected createJson() : stdClass
Return values
stdClass —

generateJsonPatch()

Generates a JSON Patch representation and return its

protected generateJsonPatch(mixed $updatedProperties) : string
Parameters
$updatedProperties : mixed

Properties of the resource to update

Return values
string —

JSON Patch representation for updates

getAlias()

Returns the alias configured for the given key. If no alias exists it returns the original key.

protected getAlias(string $key) : string
Parameters
$key : string
Return values
string —

getJsonHeader()

protected static getJsonHeader() : mixed
Return values
mixed —

getPatchHeaders()

protected static getPatchHeaders() : mixed
Return values
mixed —

getProperty()

Grab value out of the data array.

protected getProperty(string $property) : mixed
Parameters
$property : string
Return values
mixed —

getUpdateablePropertiesAsArray()

Returns the object's properties as an array

protected getUpdateablePropertiesAsArray() : mixed
Return values
mixed —

primaryKeyField()

Returns the primary key field for the object

protected primaryKeyField() : string
Return values
string —

propertyExists()

Basic check to see whether property exists.

protected propertyExists(string $property[, bool $allowRetry = true ]) : bool
Parameters
$property : string

The property name being investigated.

$allowRetry : bool = true

If set to TRUE, the check will try to format the name in underscores because there are sometimes discrepancies between camelCaseNames and underscore_names.

Return values
bool —

recursivelyAliasPropertyValue()

Returns the given property value's alias, if configured; Else, the unchanged property value is returned. If the given property value is an array or an instance of \stdClass, it is aliases recursively.

protected recursivelyAliasPropertyValue(mixed $propertyValue) : mixed
Parameters
$propertyValue : mixed

Array or \stdClass instance to alias

Return values
mixed —

Property value, aliased recursively

refreshFromParent()

Causes resource to refresh based on parent's URL

protected refreshFromParent() : mixed
Return values
mixed —

setProperty()

We can set a property under three conditions:

protected setProperty(mixed $property, mixed $value) : mixed
  1. If it has a concrete setter: setProperty()
  2. If the property exists
  3. If the property name's prefix is in an approved list
Parameters
$property : mixed
$value : mixed
Return values
mixed —

updateJson()

Generates the JSON string for update()

protected updateJson([mixed $params = array() ]) : mixed
Parameters
$params : mixed = array()
Return values
mixed —

checkAttributePrefix()

Checks the attribute $property and only permits it if the prefix is in the specified $prefixes array

private checkAttributePrefix(string $property) : bool

This is to support extension namespaces in some services.

Parameters
$property : string

the name of the attribute

Return values
bool —

isAccessible()

Does the property exist in the object variable list (i.e. does it have public or protected visibility?)

private isAccessible( $property) : bool
Parameters
$property :
Return values
bool —

resizeJson()

Generates the JSON object for Resize

private resizeJson(mixed $flavorRef) : mixed
Parameters
$flavorRef : mixed
Return values
mixed —

resizeVolumeJson()

Generates the JSON object for ResizeVolume

private resizeVolumeJson(mixed $size) : mixed
Parameters
$size : mixed
Return values
mixed —

restartJson()

Generates the JSON object for Restart

private restartJson() : mixed
Return values
mixed —

Search results