User
extends PersistentObject
in package
User class which encapsulates functionality for a user.
A user is a digital representation of a person, system, or service who consumes cloud services. Users have credentials and may be assigned tokens; based on these credentials and tokens, the authentication service validates that incoming requests are being made by the user who claims to be making the request, and that the user has the right to access the requested resources. Users may be directly assigned to a particular tenant and behave as if they are contained within that tenant.
Table of Contents
- PATCH_CONTENT_TYPE = OpenCloudCommonConstantsMime::JSON_PATCH
- $aliases : mixed
- $createKeys : mixed
- $json_name : mixed
- $metadata : Metadata
- $parent : BaseResource
- $service : ServiceInterface
- $updateKeys : mixed
- $url_resource : mixed
- $defaultRegion : string
- $domainId : string
- $email : string
- $enabled : bool
- $id : int
- $logger : LoggerInterface
- The logger instance
- $password : string
- $properties : array<string|int, mixed>
- Holds all the properties added by overloading.
- $username : string
- __call() : mixed
- Intercept non-existent method calls for dynamic getter/setter functionality.
- __construct() : mixed
- addRole() : Response
- Add a role, specified by its ID, to a user.
- checkExtension() : bool
- Check whether an extension is valid
- checkJsonError() : mixed
- Checks the most recent JSON operation for errors.
- create() : Response
- Create a new resource
- createJson() : mixed
- createUrl() : Url
- delete() : Response
- Delete this resource
- findLink() : bool
- Find a resource link based on a type
- generateUuid() : mixed
- getApiKey() : string|null
- Get the API key for this user.
- getClient() : ClientInterface
- Convenience method to return the service's client
- getDefaultRegion() : string
- getDomainId() : string
- getEmail() : string
- getEnabled() : bool
- getId() : int
- getInstance() : static
- getLogger() : LoggerInterface
- Returns the Logger object.
- getMetadata() : Metadata
- getOtherCredentials() : array<string|int, mixed>|null
- This operation lists a user's non-password credentials for all authentication methods available to the user.
- getParent() : mixed
- getPassword() : string
- getRoles() : PaginatedIterator
- Get all the roles for which this user is associated with.
- getService() : ServiceInterface
- getUrl() : mixed
- Get this resource's URL
- getUsername() : string
- hasLogger() : bool
- id() : mixed
- isEnabled() : bool
- 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
- Populates the current object based on an unknown data type.
- primaryKeyField() : string
- refresh() : Response
- Refresh the state of a resource
- refreshFromLocationUrl() : mixed
- Given a `location` URL, refresh this resource
- region() : mixed
- removeRole() : Response
- Remove a role, specified by its ID, from a user.
- resetApiKey() : string|null
- Reset the API key for this user to a new arbitrary value (which is returned).
- resourceName() : mixed
- Returns the URI path for this resource
- setDefaultRegion() : mixed
- setDomainId() : mixed
- setEmail() : mixed
- setEnabled() : mixed
- setId() : mixed
- setLogger() : $this
- Sets the logger.
- setMetadata() : $this
- setParent() : self
- setPassword() : mixed
- setService() : PersistentObject
- setUsername() : mixed
- status() : string
- stripNamespace() : mixed
- toCamel() : mixed
- Convert a string to camelCase format.
- toUnderscores() : mixed
- Convert string to underscore format.
- update() : mixed
- updateJson() : mixed
- updatePassword() : Response
- This operation will set the user's password to a new value.
- url() : mixed
- waitFor() : mixed
- A method to repeatedly poll the API resource, waiting for an eventual state change
- 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
- 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:
- 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?)
Constants
PATCH_CONTENT_TYPE
public
mixed
PATCH_CONTENT_TYPE
= OpenCloudCommonConstantsMime::JSON_PATCH
Properties
$aliases
protected
mixed
$aliases
= array('name' => 'username', 'RAX-AUTH:defaultRegion' => 'defaultRegion', 'RAX-AUTH:domainId' => 'domainId', 'OS-KSADM:password' => 'password')
$createKeys
protected
mixed
$createKeys
= array('username', 'email', 'enabled', 'password')
$json_name
protected
static mixed
$json_name
= 'user'
$metadata
protected
Metadata
$metadata
$parent
protected
BaseResource
$parent
$service
protected
ServiceInterface
$service
$updateKeys
protected
mixed
$updateKeys
= array('username', 'email', 'enabled', 'RAX-AUTH:defaultRegion', 'RAX-AUTH:domainId', 'id')
$url_resource
protected
static mixed
$url_resource
= 'users'
$defaultRegion
private
string
$defaultRegion
The default region for this region. Can be ORD, DFW, IAD, LON, HKG or SYD
$domainId
private
string
$domainId
private
string
$email
The email address of this user
$enabled
private
bool
$enabled
Whether or not this user is enabled or not
$id
private
int
$id
The ID of this user
$logger
The logger instance
private
LoggerInterface
$logger
$password
private
string
$password
The string password for this user
$properties
Holds all the properties added by overloading.
private
array<string|int, mixed>
$properties
= array()
$username
private
string
$username
The username of this user
Methods
__call()
Intercept non-existent method calls for dynamic getter/setter functionality.
public
__call( $method, $args) : mixed
Parameters
Tags
Return values
mixed —__construct()
public
__construct(ServiceInterface $service[, $data = null ]) : mixed
Parameters
- $service : ServiceInterface
-
The service that this resource belongs to
- $data : = null
-
$data
Return values
mixed —addRole()
Add a role, specified by its ID, to a user.
public
addRole( $roleId) : Response
Parameters
Return values
Response —checkExtension()
Check whether an extension is valid
public
checkExtension(mixed $alias) : bool
Parameters
- $alias : mixed
-
The extension name
Tags
Return values
bool —checkJsonError()
Checks the most recent JSON operation for errors.
public
static checkJsonError() : mixed
Tags
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 —createJson()
public
createJson() : mixed
Return values
mixed —createUrl()
public
createUrl() : Url
Tags
Return values
Url —delete()
Delete this resource
public
delete() : Response
Return values
Response —findLink()
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 —getApiKey()
Get the API key for this user.
public
getApiKey() : string|null
Return values
string|null —getClient()
Convenience method to return the service's client
public
getClient() : ClientInterface
Return values
ClientInterface —getDefaultRegion()
public
getDefaultRegion() : string
Return values
string —Get the default region
getDomainId()
public
getDomainId() : string
Return values
string —Get the domain ID
getEmail()
public
getEmail() : string
Return values
string —Get the email
getEnabled()
public
getEnabled() : bool
Return values
bool —Get the enabled flag
getId()
public
getId() : int
Return values
int —Get the ID
getInstance()
public
static getInstance() : static
Return values
static —getLogger()
Returns the Logger object.
public
getLogger() : LoggerInterface
Return values
LoggerInterface —getMetadata()
public
getMetadata() : Metadata
Return values
Metadata —getOtherCredentials()
This operation lists a user's non-password credentials for all authentication methods available to the user.
public
getOtherCredentials() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —getParent()
public
getParent() : mixed
Return values
mixed —getPassword()
public
getPassword() : string
Return values
string —Get the password
getRoles()
Get all the roles for which this user is associated with.
public
getRoles() : PaginatedIterator
Return values
PaginatedIterator —getService()
public
getService() : ServiceInterface
Tags
Return values
ServiceInterface —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 —getUsername()
public
getUsername() : string
Return values
string —Get the username
hasLogger()
public
hasLogger() : bool
Return values
bool —id()
public
id() : mixed
Tags
Return values
mixed —isEnabled()
public
isEnabled() : bool
Return values
bool —Check whether this user is enabled or not
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
Return values
mixed —makeResourceIteratorOptions()
public
makeResourceIteratorOptions(mixed $resource) : mixed
Parameters
- $resource : mixed
Return values
mixed —name()
public
name() : string
Tags
Return values
string —parseResponse()
Parse a HTTP response for the required content
public
parseResponse(Response $response) : mixed
Parameters
- $response : Response
Return values
mixed —populate()
Populates the current object based on an unknown data type.
public
populate(mixed $info[, mixed $setObjects = true ]) : mixed
Parameters
- $info : mixed
- $setObjects : mixed = true
Tags
Return values
mixed —primaryKeyField()
public
primaryKeyField() : string
Return values
string —refresh()
Refresh the state of a resource
public
refresh([null $id = null ][, null $url = null ]) : Response
Parameters
- $id : null = null
- $url : null = null
Tags
Return values
Response —refreshFromLocationUrl()
Given a `location` URL, refresh this resource
public
refreshFromLocationUrl( $url) : mixed
Parameters
Return values
mixed —region()
public
region() : mixed
Tags
Return values
mixed —removeRole()
Remove a role, specified by its ID, from a user.
public
removeRole( $roleId) : Response
Parameters
Return values
Response —resetApiKey()
Reset the API key for this user to a new arbitrary value (which is returned).
public
resetApiKey() : string|null
Return values
string|null —resourceName()
Returns the URI path for this resource
public
static resourceName() : mixed
Tags
Return values
mixed —setDefaultRegion()
public
setDefaultRegion( $region) : mixed
Parameters
Return values
mixed —setDomainId()
public
setDomainId( $domainId) : mixed
Parameters
Return values
mixed —setEmail()
public
setEmail( $email) : mixed
Parameters
Return values
mixed —setEnabled()
public
setEnabled( $enabled) : mixed
Parameters
Return values
mixed —setId()
public
setId( $id) : mixed
Parameters
Return values
mixed —setLogger()
Sets the logger.
public
setLogger([LoggerInterface $logger = null ]) : $this
Parameters
- $logger : LoggerInterface = null
Return values
$this —setMetadata()
public
setMetadata(mixed $data) : $this
Parameters
- $data : mixed
Return values
$this —setParent()
public
setParent(BaseResource $parent) : self
Parameters
- $parent : BaseResource
Return values
self —setPassword()
public
setPassword( $password) : mixed
Parameters
Return values
mixed —setService()
public
setService(ServiceInterface $service) : PersistentObject
Parameters
- $service : ServiceInterface
Return values
PersistentObject —setUsername()
public
setUsername( $username) : mixed
Parameters
Return values
mixed —status()
public
status() : string
Tags
Return values
string —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
Return values
mixed —toUnderscores()
Convert string to underscore format.
public
toUnderscores( $string) : mixed
Parameters
Return values
mixed —update()
public
update([mixed $params = array() ]) : mixed
Parameters
- $params : mixed = array()
Return values
mixed —updateJson()
public
updateJson([mixed $params = array() ]) : mixed
Parameters
- $params : mixed = array()
Return values
mixed —updatePassword()
This operation will set the user's password to a new value.
public
updatePassword( $newPassword) : Response
Parameters
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
Return values
mixed —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 —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 —noCreate()
protected
noCreate() : mixed
Tags
Return values
mixed —noDelete()
protected
noDelete() : mixed
Tags
Return values
mixed —noUpdate()
protected
noUpdate() : mixed
Tags
Return values
mixed —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
- If it has a concrete setter: setProperty()
- If the property exists
- If the property name's prefix is in an approved list
Parameters
- $property : mixed
- $value : mixed
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