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
Afficher le fichier Open project: scalr/scalr Class Usage Examples

Méthodes publiques

Свойство 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

Свойство 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

Méthodes publiques

Méthode 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 méthode

Constructor
public __construct ( )

fetchImagesArray() public méthode

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

getAllowedEnvironments() public méthode

Empty array means everywhere.
public getAllowedEnvironments ( ) : array
Résultat array Array of envId

getBehaviors() public méthode

Gets role behaviors list
public getBehaviors ( ) : string[]
Résultat string[]

getBehaviorsConflicts() public static méthode

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

getDbMsrBehavior() public méthode

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

getFarmsCount() public méthode

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
Résultat integer Returns farm's count which uses current role

getImage() public méthode

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
Résultat RoleImage Returns the RoleImage object. It throws an exception when the RoleImage does not exist

getImages() public méthode

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
Résultat Scalr\Model\Collections\EntityIterator Returns Images which are associated with the role

getOs() public méthode

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

getScope() public méthode

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

getScripts() public méthode

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

getServersCount() public méthode

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
Résultat integer

hasAccessPermissions() public méthode

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

hasBehavior() public méthode

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

hasDbBehavior() public méthode

Check if Role has database behavior
public hasDbBehavior ( ) : boolean
Résultat boolean

isNameUsed() public static méthode

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
Résultat boolean Returns TRUE if a such name has been already used on scalr or account (or environment) scopes

isUsed() public méthode

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

isValidName() public static méthode

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

save() public méthode

public save ( )

setBehaviors() public méthode

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

setImage() public méthode

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 méthode

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

Property Details

$accountId public_oe property

It is set when the Role is from account scope
public int $accountId
Résultat integer

$added public_oe property

The timestamp when the Role was added
public DateTime $added
Résultat DateTime

$addedByEmail public_oe property

The email address of the User who added the Role
public int $addedByEmail
Résultat integer

$addedByUserId public_oe property

The identifier of the User who added the Role
public int $addedByUserId
Résultat integer

$behaviors public_oe property

The list of the supported behaviors
public string $behaviors
Résultat string

$behaviorsOverlaps protected_oe static_oe property

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

$catId public_oe property

Identifier of the category
public int $catId
Résultat integer

$dbBehaviors protected_oe static_oe property

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

$description public_oe property

The description
public string $description
Résultat string

$envId public_oe property

It is set when the Role is from environment scope
public int $envId
Résultat integer

$generation public_oe property

The generation
Deprecation:
public int $generation
Résultat integer

$id public_oe property

The identifier of the Role
public int $id
Résultat integer

$isDeprecated public_oe property

Whether the role is deprecated
public bool $isDeprecated
Résultat boolean

$isDevelopment public_oe property

Whether it is development Role
public bool $isDevelopment
Résultat boolean

$isQuickStart public_oe property

Whether it is QuickStart Role
public bool $isQuickStart
Résultat boolean

$isScalarized public_oe property

Whether it is Scalarized Role
public bool $isScalarized
Résultat boolean

$lastUsed public_oe property

The timestamp when the Role was used last time
public DateTime $lastUsed
Résultat DateTime

$name public_oe property

The name of the role
public string $name
Résultat string

$origin public_oe property

Deprecation:
public string $origin
Résultat string

$osId public_oe property

The identifier of the OS
public string $osId
Résultat string