PHP Класс Scalr\Model\Entity\Role

С версии: 5.0 (23.07.2014)
Автор: Igor Vodiasov ([email protected])
Наследование: extends Scalr\Model\AbstractEntity, implements Scalr\DataType\ScopeInterface, implements Scalr\DataType\AccessPermissionsInterface
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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)

Свойство Тип Описание
$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

Открытые методы

Метод Описание
__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

Описание методов

__construct() публичный Метод

Constructor
public __construct ( )

fetchImagesArray() публичный Метод

Gets the list of the Images which correspond to the Role
public fetchImagesArray ( ) : array
Результат array Return array of all role's images in format: [platform][cloudLocation] = [id, architecture, type]

getAllowedEnvironments() публичный Метод

Empty array means everywhere.
public getAllowedEnvironments ( ) : array
Результат array Array of envId

getBehaviors() публичный Метод

Gets role behaviors list
public getBehaviors ( ) : string[]
Результат string[]

getBehaviorsConflicts() публичный статический Метод

Checks given set of behaviors on compatibility
public static getBehaviorsConflicts ( array $behaviors ) : array
$behaviors array Array of a Role behaviors
Результат array Returns an array of behaviors that cannot be used together

getDbMsrBehavior() публичный Метод

If role has any database behavior, it will return behavior's name
public getDbMsrBehavior ( ) : boolean | string
Результат boolean | string Name of database behavior of false

getFarmsCount() публичный Метод

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
Результат integer Returns farm's count which uses current role

getImage() публичный Метод

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
Результат RoleImage Returns the RoleImage object. It throws an exception when the RoleImage does not exist

getImages() публичный Метод

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
Результат Scalr\Model\Collections\EntityIterator Returns Images which are associated with the role

getOs() публичный Метод

Gets the Os entity which corresponds to the Role
public getOs ( ) : Os
Результат Os Returns the Os entity which corresponds to the Role. If OS has not been defined it will return NULL.

getScope() публичный Метод

См. также: Scalr\DataType\ScopeInterface::getScope()
public getScope ( )

getScripts() публичный Метод

Get scripts of the Role TODO refactor this method to new Entities
public getScripts ( ) : array
Результат array

getServersCount() публичный Метод

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
Результат integer

hasAccessPermissions() публичный Метод

См. также: Scalr\DataType\AccessPermissionsInterface::hasAccessPermissions()
public hasAccessPermissions ( $user, $environment = null, $modify = null )

hasBehavior() публичный Метод

Check if role has behavior
public hasBehavior ( string $behavior ) : boolean
$behavior string Behavior name
Результат boolean Returns true if role has behavior, false otherwise

hasDbBehavior() публичный Метод

Check if Role has database behavior
public hasDbBehavior ( ) : boolean
Результат boolean

isNameUsed() публичный статический Метод

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
Результат boolean Returns TRUE if a such name has been already used on scalr or account (or environment) scopes

isUsed() публичный Метод

Checks whether the Role is already used in some Farm
public isUsed ( ) : boolean
Результат boolean Returns TRUE if the Role is already used or FALSE otherwise

isValidName() публичный статический Метод

Validates the name
public static isValidName ( string $name ) : boolean
$name string The name of the Role
Результат boolean Returns TRUE when the name is valid or FALSE otherwise

save() публичный Метод

public save ( )

setBehaviors() публичный Метод

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

setImage() публичный Метод

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() публичный Метод

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

Описание свойств

$accountId публичное свойство

It is set when the Role is from account scope
public int $accountId
Результат integer

$added публичное свойство

The timestamp when the Role was added
public DateTime $added
Результат DateTime

$addedByEmail публичное свойство

The email address of the User who added the Role
public int $addedByEmail
Результат integer

$addedByUserId публичное свойство

The identifier of the User who added the Role
public int $addedByUserId
Результат integer

$behaviors публичное свойство

The list of the supported behaviors
public string $behaviors
Результат string

$behaviorsOverlaps защищенное статическое свойство

Rules of behavior compatibility Implies that the DB behaviors is mutually exclusive
protected static array $behaviorsOverlaps
Результат array

$catId публичное свойство

Identifier of the category
public int $catId
Результат integer

$dbBehaviors защищенное статическое свойство

List of DB behaviors It is used to generate mutually exclusive rules of behavior compatibility
protected static array $dbBehaviors
Результат array

$description публичное свойство

The description
public string $description
Результат string

$envId публичное свойство

It is set when the Role is from environment scope
public int $envId
Результат integer

$generation публичное свойство

The generation
Устаревший:
public int $generation
Результат integer

$id публичное свойство

The identifier of the Role
public int $id
Результат integer

$isDeprecated публичное свойство

Whether the role is deprecated
public bool $isDeprecated
Результат boolean

$isDevelopment публичное свойство

Whether it is development Role
public bool $isDevelopment
Результат boolean

$isQuickStart публичное свойство

Whether it is QuickStart Role
public bool $isQuickStart
Результат boolean

$isScalarized публичное свойство

Whether it is Scalarized Role
public bool $isScalarized
Результат boolean

$lastUsed публичное свойство

The timestamp when the Role was used last time
public DateTime $lastUsed
Результат DateTime

$name публичное свойство

The name of the role
public string $name
Результат string

$origin публичное свойство

Устаревший:
public string $origin
Результат string

$osId публичное свойство

The identifier of the OS
public string $osId
Результат string