class Parameter

Represents an individual request parameter in a RESTful operation. A parameter can take on many forms: in a URL path, in a URL query, in a JSON body, and in a HTTP header. It is worth documenting brifly each variety of parameter:

  • Header parameters are those which populate a HTTP header in a request. Header parameters can have aliases; for example, a user-facing name of "Foo" can be sent over the wire as "X-Foo_Bar", as defined by sentAs. Prefixes can also be used.

  • Query parameters are those which populate a URL query parameter. The value is therefore usually confined to a string.

  • JSON parameters are those which populate a JSON request body. These are the most complex variety of Parameter, since there are so many different ways a JSON document can be constructed. The SDK supports deep-nesting according to a XPath syntax; for more information, see {see \OpenStack\Common\JsonPath}. Nested object and array properties are also supported since JSON is a recursive data type. What this means is that a Parameter can have an assortment of child Parameters, one for each object property or array element.

  • Raw parameters are those which populate a non-JSON request body. This is typically used for uploading payloads (such as Swift object data) to a remote API.

  • Path parameters are those which populate a URL path. They are serialized according to URL placeholders.

Traits

Represents common functionality for populating, or "hydrating", an object with arbitrary data.

Constants

DEFAULT_LOCATION

Methods

__construct (array $data)

No description

getName () : string

Retrieve the name that will be used over the wire.

isRequired () : bool

Indicates whether the user must provide a value for this parameter.

validate ($userValues) : bool

Validates a given user value and checks whether it passes basic sanity checking, such as types.

isArray () : bool

Indicates whether this parameter represents an array type

isObject () : bool

Indicates whether this parameter represents an object type

No description

hasLocation ($value) : bool

Verifies whether the given location matches the parameter's location.

getPath () : string|null

Retrieves the parameter's path.

Retrieves the common schema that an array parameter applies to all its child elements.

setName (string $name)

Sets the name of the parameter to a new value

getProperty (string $name) : null|Parameter

Retrieves the child parameter for an object parameter.

getPrefix () : string|null

Retrieves the prefix for a parameter, if any.

No description

Details

__construct(array $data)

Parameters

$data array

Example code

$parameter->__construct($data);

getName()

Retrieve the name that will be used over the wire.

Return value

string

Example code

$string = $parameter->getName();

isRequired()

Indicates whether the user must provide a value for this parameter.

Return value

bool

Example code

$bool = $parameter->isRequired();

validate($userValues)

Validates a given user value and checks whether it passes basic sanity checking, such as types.

Parameters

$userValues The value provided by the user

Return value

bool TRUE if the validation passes

Exceptions

Exception If validation fails

Example code

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

isArray()

Indicates whether this parameter represents an array type

Return value

bool

Example code

$bool = $parameter->isArray();

isObject()

Indicates whether this parameter represents an object type

Return value

bool

Example code

$bool = $parameter->isObject();

getLocation()

Example code

$parameter->getLocation();

hasLocation($value)

Verifies whether the given location matches the parameter's location.

Parameters

$value

Return value

bool

Example code

$bool = $parameter->hasLocation($value);

getPath()

Retrieves the parameter's path.

Return value

string|null

Example code

$response = $parameter->getPath();

getItemSchema()

Retrieves the common schema that an array parameter applies to all its child elements.

Return value

Parameter|null

Example code

$response = $parameter->getItemSchema();

setName(string $name)

Sets the name of the parameter to a new value

Parameters

$name string

Example code

$parameter->setName($name);

getProperty(string $name)

Retrieves the child parameter for an object parameter.

Parameters

$name string The name of the child property

Return value

null|Parameter

Example code

$response = $parameter->getProperty($name);

getPrefix()

Retrieves the prefix for a parameter, if any.

Return value

string|null

Example code

$response = $parameter->getPrefix();

getPrefixedName()

Example code

$parameter->getPrefixedName();