class Operation

This class represents an OpenStack API operation. It encapsulates most aspects of the REST operation: its HTTP method, the URL path, its top-level JSON key, and all of its {see Parameter} objects.

An operation not only represents a remote operation, but it also provides the mechanism for executing it over HTTP. To do this, it uses a {see ClientInterface} that allows a {see GuzzleHttp\Message\Request} to be created from the user values provided. Once this request is assembled, it is then sent to the remote API and the response is returned to whoever first invoked the Operation class.

Methods

__construct (array $definition)

No description

getPath () : string

No description

getMethod () : string

No description

hasParam (string $key) : bool

Indicates whether this operation supports a parameter.

getParam (string $name) : Parameter

No description

getJsonKey () : string

No description

toParamArray (array $data) : static array

A convenience method that will take a generic array of data and convert it into an array of {see Parameter} objects.

validate (array $userValues) : bool

This method will validate all of the user-provided values and throw an exception if any failures are detected. This is useful for basic sanity-checking before a request is serialized and sent to the API.

Details

__construct(array $definition)

Parameters

$definition array The data definition (in array form) that will populate this operation. Usually this is retrieved from an {see ApiInterface} object method.

Example code

$operation->__construct($definition);

getPath()

Return value

string

Example code

$string = $operation->getPath();

getMethod()

Return value

string

Example code

$string = $operation->getMethod();

hasParam(string $key)

Indicates whether this operation supports a parameter.

Parameters

$key string The name of a parameter

Return value

bool

Example code

$bool = $operation->hasParam($key);

getParam(string $name)

Parameters

$name string

Return value

Parameter

Example code

$parameter = $operation->getParam($name);

getJsonKey()

Return value

string

Example code

$string = $operation->getJsonKey();

static toParamArray(array $data)

A convenience method that will take a generic array of data and convert it into an array of {see Parameter} objects.

Parameters

$data array A generic data array

Return value

array

Example code

$array = $operation->toParamArray($data);

validate(array $userValues)

This method will validate all of the user-provided values and throw an exception if any failures are detected. This is useful for basic sanity-checking before a request is serialized and sent to the API.

Parameters

$userValues array The user-defined values

Return value

bool TRUE if validation passes

Exceptions

Exception If validate fails

Example code

$bool = $operation->validate($userValues);