PHP Class Scalr\Model\Entity\Role

Since: 5.0 (23.07.2014)
Author: Igor Vodiasov ([email protected])
Inheritance: extends Scalr\Model\AbstractEntity, implements Scalr\DataType\ScopeInterface, implements Scalr\DataType\AccessPermissionsInterface
Show file Open project: scalr/scalr Class Usage Examples

Public Properties

Property Type Description
$accountId integer It is set when the Role is from account scope
$added DateTime The timestamp when the Role was added
$addedByEmail integer The email address of the User who added the Role
$addedByUserId integer The identifier of the User who added the Role
$behaviors string The list of the supported behaviors
$catId integer Identifier of the category
$description string The description
$envId integer It is set when the Role is from environment scope
$generation integer The generation
$id integer The identifier of the Role
$isDeprecated boolean Whether the role is deprecated
$isDevelopment boolean Whether it is development Role
$isQuickStart boolean Whether it is QuickStart Role
$isScalarized boolean Whether it is Scalarized Role
$lastUsed DateTime The timestamp when the Role was used last time
$name string The name of the role
$origin string
$osId string The identifier of the OS

Protected Properties

Property Type Description
$behaviorsOverlaps array Rules of behavior compatibility Implies that the DB behaviors is mutually exclusive
$dbBehaviors array List of DB behaviors It is used to generate mutually exclusive rules of behavior compatibility

Public Methods

Method Description
__construct ( ) Constructor
fetchImagesArray ( ) : array Gets the list of the Images which correspond to the Role
getAllowedEnvironments ( ) : array Return array of environments where this role is allowed explicitly.
getBehaviors ( ) : string[] Gets role behaviors list
getBehaviorsConflicts ( array $behaviors ) : array Checks given set of behaviors on compatibility
getDbMsrBehavior ( ) : boolean | string If role has any database behavior, it will return behavior's name
getFarmsCount ( integer $accountId = null, integer $envId = null ) : integer Gets the number of Farms which are using this Role
getImage ( $platform, $cloudLocation ) : RoleImage Finds out the Image that corresponds to the Role by the specified criteria
getImages ( array $criteria = null, array $group = null, array $order = null, integer $limit = null, integer $offset = null, boolean $countRecords = null ) : EntityIterator Gets Images which are associated with the Role
getOs ( ) : Os Gets the Os entity which corresponds to the Role
getScope ( )
getScripts ( ) : array Get scripts of the Role TODO refactor this method to new Entities
getServersCount ( string $accountId = null, string $envId = null ) : integer Get the number of Servers which are using this Role
hasAccessPermissions ( $user, $environment = null, $modify = null )
hasBehavior ( string $behavior ) : boolean Check if role has behavior
hasDbBehavior ( ) : boolean Check if Role has database behavior
isNameUsed ( string $name, integer $accountId, integer $envId, integer $ignoreRoleId = null ) : boolean Check if given name is used on scalr, account or environment scopes
isUsed ( ) : boolean Checks whether the Role is already used in some Farm
isValidName ( string $name ) : boolean Validates the name
save ( )
setBehaviors ( array | JsonData $behaviors ) Sets role behaviors
setImage ( string $platform, string $cloudLocation, string $imageId, integer $userId, string $userEmail ) Add, replace or remove image in role
setScripts ( array $scripts ) Set scripts of the Role TODO refactor this method to new Entities

Method Details

__construct() public method

Constructor
public __construct ( )

fetchImagesArray() public method

Gets the list of the Images which correspond to the Role
public fetchImagesArray ( ) : array
return array Return array of all role's images in format: [platform][cloudLocation] = [id, architecture, type]

getAllowedEnvironments() public method

Empty array means everywhere.
public getAllowedEnvironments ( ) : array
return array Array of envId

getBehaviors() public method

Gets role behaviors list
public getBehaviors ( ) : string[]
return string[]

getBehaviorsConflicts() public static method

Checks given set of behaviors on compatibility
public static getBehaviorsConflicts ( array $behaviors ) : array
$behaviors array Array of a Role behaviors
return array Returns an array of behaviors that cannot be used together

getDbMsrBehavior() public method

If role has any database behavior, it will return behavior's name
public getDbMsrBehavior ( ) : boolean | string
return boolean | string Name of database behavior of false

getFarmsCount() public method

Gets the number of Farms which are using this Role
public getFarmsCount ( integer $accountId = null, integer $envId = null ) : integer
$accountId integer optional Identifier of account
$envId integer optional Identifier of environment
return integer Returns farm's count which uses current role

getImage() public method

Finds out the Image that corresponds to the Role by the specified criteria
public getImage ( $platform, $cloudLocation ) : RoleImage
$platform string The cloud platform
$cloudLocation string The cloud location
return RoleImage Returns the RoleImage object. It throws an exception when the RoleImage does not exist

getImages() public method

Gets Images which are associated with the Role
public getImages ( array $criteria = null, array $group = null, array $order = null, integer $limit = null, integer $offset = null, boolean $countRecords = null ) : EntityIterator
$criteria array optional The search criteria on the Image result set.
$group array optional The group parameter
$order array optional The results order looks like [[property1 => true|false], ...]
$limit integer optional The records limit
$offset integer optional The offset
$countRecords boolean optional True to calculate total number of the records without limit
return Scalr\Model\Collections\EntityIterator Returns Images which are associated with the role

getOs() public method

Gets the Os entity which corresponds to the Role
public getOs ( ) : Os
return Os Returns the Os entity which corresponds to the Role. If OS has not been defined it will return NULL.

getScope() public method

See also: Scalr\DataType\ScopeInterface::getScope()
public getScope ( )

getScripts() public method

Get scripts of the Role TODO refactor this method to new Entities
public getScripts ( ) : array
return array

getServersCount() public method

Get the number of Servers which are using this Role
public getServersCount ( string $accountId = null, string $envId = null ) : integer
$accountId string optional Identifier of account
$envId string optional Identifier of environment
return integer

hasAccessPermissions() public method

See also: Scalr\DataType\AccessPermissionsInterface::hasAccessPermissions()
public hasAccessPermissions ( $user, $environment = null, $modify = null )

hasBehavior() public method

Check if role has behavior
public hasBehavior ( string $behavior ) : boolean
$behavior string Behavior name
return boolean Returns true if role has behavior, false otherwise

hasDbBehavior() public method

Check if Role has database behavior
public hasDbBehavior ( ) : boolean
return boolean

isNameUsed() public static method

Check if given name is used on scalr, account or environment scopes
public static isNameUsed ( string $name, integer $accountId, integer $envId, integer $ignoreRoleId = null ) : boolean
$name string Role's name to check
$accountId integer Identifier of account
$envId integer Identifier of environment
$ignoreRoleId integer Role id to ignore
return boolean Returns TRUE if a such name has been already used on scalr or account (or environment) scopes

isUsed() public method

Checks whether the Role is already used in some Farm
public isUsed ( ) : boolean
return boolean Returns TRUE if the Role is already used or FALSE otherwise

isValidName() public static method

Validates the name
public static isValidName ( string $name ) : boolean
$name string The name of the Role
return boolean Returns TRUE when the name is valid or FALSE otherwise

save() public method

public save ( )

setBehaviors() public method

Sets role behaviors
public setBehaviors ( array | JsonData $behaviors )
$behaviors array | Scalr\UI\Request\JsonData Array of behaviors

setImage() public method

Add, replace or remove image in role
public setImage ( string $platform, string $cloudLocation, string $imageId, integer $userId, string $userEmail )
$platform string The cloud platform
$cloudLocation string The cloud location
$imageId string optional Either Identifier of the Image to add or NULL to remove
$userId integer The identifier of the User who adds the Image
$userEmail string The email address of the User who adds the Image

setScripts() public method

Set scripts of the Role TODO refactor this method to new Entities
public setScripts ( array $scripts )
$scripts array

Property Details

$accountId public property

It is set when the Role is from account scope
public int $accountId
return integer

$added public property

The timestamp when the Role was added
public DateTime $added
return DateTime

$addedByEmail public property

The email address of the User who added the Role
public int $addedByEmail
return integer

$addedByUserId public property

The identifier of the User who added the Role
public int $addedByUserId
return integer

$behaviors public property

The list of the supported behaviors
public string $behaviors
return string

$behaviorsOverlaps protected static property

Rules of behavior compatibility Implies that the DB behaviors is mutually exclusive
protected static array $behaviorsOverlaps
return array

$catId public property

Identifier of the category
public int $catId
return integer

$dbBehaviors protected static property

List of DB behaviors It is used to generate mutually exclusive rules of behavior compatibility
protected static array $dbBehaviors
return array

$description public property

The description
public string $description
return string

$envId public property

It is set when the Role is from environment scope
public int $envId
return integer

$generation public property

The generation
Deprecation:
public int $generation
return integer

$id public property

The identifier of the Role
public int $id
return integer

$isDeprecated public property

Whether the role is deprecated
public bool $isDeprecated
return boolean

$isDevelopment public property

Whether it is development Role
public bool $isDevelopment
return boolean

$isQuickStart public property

Whether it is QuickStart Role
public bool $isQuickStart
return boolean

$isScalarized public property

Whether it is Scalarized Role
public bool $isScalarized
return boolean

$lastUsed public property

The timestamp when the Role was used last time
public DateTime $lastUsed
return DateTime

$name public property

The name of the role
public string $name
return string

$origin public property

Deprecation:
public string $origin
return string

$osId public property

The identifier of the OS
public string $osId
return string