Module: UU::OS::Cast

Extended by:
Cast
Included in:
Cast
Defined in:
uu_os-0.29.16/lib/uu/os/cast.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_state.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_level.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_create.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_delete.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_exists.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_direction.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_attributes.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_subject_type.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_get_cast_list.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_get_attributes.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_set_attributes.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_history_attributes.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_verify_cast_existence.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_get_cast_history_list.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_access_role_attributes.rb,
uu_os-0.29.16/lib/uu/os/cast/cast_get_access_role_cast_list.rb

Overview

Module Cast.

Defined Under Namespace

Classes: CastAccessRoleAttributes, CastAttributes, CastCreate, CastDelete, CastDirection, CastExists, CastGetAccessRoleCastList, CastGetAttributes, CastGetCastHistoryList, CastGetCastList, CastHistoryAttributes, CastLevel, CastSetAttributes, CastState, CastSubjectType, CastVerifyCastExistence

Constant Summary

PATH =

Service path

'ues/core/role/UESCast'

Instance Method Summary (collapse)

Instance Method Details

- (Object) create(subject_uri, cast = nil)

Casts a subject (role or group) to another subject (role or group). Only roles and groups from the same territory are supported at the moment (therefore it is not possible to cast across territories and form pseudo business access role relation at the moment). Cast is not an entity, it is a relation between two subjects (and these two subjects identify the relation). Note that only some combinations of subjects in a cast relation are permitted.

Examples:

# Cast a role in a group
UU::OS::Cast.create('ues:TERRITORY:GROUP',
        :casted_subject_uri => 'ues:TERRITORY:ROLE'
)

# Create a primary cast of an access role in a role
UU::OS::Cast.create('ues:TERRITORY:ROLE',
        :casted_subject_uri => 'ues:TERRITORY:ACCESS_ROLE',
        :primary => true
)

# Cast role 1 in role 2 in assistance level
UU::OS::Cast.create('ues:TERRITORY:ROLE2',
        :casted_subject_uri => 'ues:TERRITORY:ROLE1',
        :level => 'ASSISTANCE'
)

Parameters:

  • subject_uri (String, UU::OS::UESURI)

    UESURI of the subject into which another subject is casted

  • cast (CastCreate) (defaults to: nil)

    DTO containing attributes of the cast

Options Hash (cast):

  • :casted_subject_uri (String, UU::OS::UESURI)

    UESURI of the subject (role or group) which is casted to the subject identified by the command main entity. Cannot be nil.

  • :level (String, UU::OS::Cast::CastLevel)

    The level of the new cast. The attribute cannot be set at the same time as the executive attribute. If set to nil, EXECUTIVE level will be used.

  • :primary (Boolean)

    Specifies whether the cast will be the primary cast to the role. Applicable only if the subject_uri (main entity) is a role. If set to true, the cast must be visible in EXECUTIVE level. If set to nil, the cast will not become primary unless it is the first cast to the subject_uri (main entity).

  • :date_to (String)

    The date when the cast will be automatically set to the PASSIVE state. If the subject is a Role and the cast is the primary cast to the Role, then there must be either another ACTIVE visible cast with EXECUTIVE level to the Role which will become the primary cast, or no cast at all; otherwise the cast state will not be changed.

  • :visible (Boolean)

    Specifies whether the cast is visible in Show Casts use case. If set to nil, the cast will be set as visible. If set to false, the cast must not be set as primary.



59
60
61
62
63
64
65
66
# File 'uu_os-0.29.16/lib/uu/os/cast.rb', line 59

def create(subject_uri, cast = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  payload = UU::OS::Cast::CastCreate.new(cast).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('create', subject_uri, payload)
  end
end

- (Object) delete(subject_uri, cast = nil)

Deletes the cast from the system. Any change of user authorization resulting from the cast modification will take effect approximately after 15 minutes. The last active executive cast cannot be deleted when this role has an active assistance or guest cast (active casts of these types cannot exist without at least one active executive cast). The last active executive cast for this role cannot be deleted when the role is competent for at least one artifact (a role without an active cast cannot be competent for any artifacts).

Examples:

# Delete a cast
UU::OS::Cast.delete('ues:TERRITORY:ROLE2', :casted_subject_uri => 'ues:TERRITORY:ROLE1')

Parameters:

  • subject_uri (String, UU::OS::UESURI)

    UESURI of the subject to which the other is casted.

  • cast (CastDelete) (defaults to: nil)

    DTO containing UESURI of the casted subject.

Options Hash (cast):

  • :casted_subject_uri (String, UU::OS::UESURI)

    UESURI of the subject (role or group) which is casted to the subject identified by the command main entity. Cannot be nil.



196
197
198
199
200
201
202
203
# File 'uu_os-0.29.16/lib/uu/os/cast.rb', line 196

def delete(subject_uri, cast = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  payload = UU::OS::Cast::CastDelete.new(cast).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('delete', subject_uri, payload)
  end
end

- (Boolean) exists(subject_uri, cast = nil)

Checks the cast existence of a subject (access role, role or group) to another subject (role or group) specified in subject_uri. The cast subject is identified either by UESURI or by Universe ID of a user whose access role is cast to subjectUri. Only the existence of a direct cast is checked by default. The existence of an indirect cast can be checked only between an access role (identified either by UESURI or by Universe ID) and another subject (role or group).

Examples:

# Check direct cast existence (the role has cast to another role or group).
UU::OS::Cast.exists('ues:TERRITORY:GROUP', :casted_subject_uri => 'ues:TERRITORY:ROLE')

# Check indirect access role cast existence (the access role has cast to a role which has cast to another role).
UU::OS::Cast.exists('ues:TERRITORY:ROLE', :casted_subject_uri => 'ues:TERRITORY:ACCESS_ROLE', :recursive => true)

# Check direct cast existence for user with selected UID (the user has an access role cast in another role or group).
UU::OS::Cast.exists('ues:TERRITORY:ROLE', :casted_subject_universe_id => '1-1111-1')

# Check indirect cast existence for user with selected UID (the user has an access role cast to a role which is cast in another role).
UU::OS::Cast.exists('ues:TERRITORY:ROLE', :casted_subject_universe_id => '1-1111-1', :recursive => true)

Parameters:

  • subject_uri (String, UU::OS::UESURI)

    UESURI of the role (role or group) for which the uuCommand checks whether another role (role, group or access role) is casted to.

  • cast (CastExists) (defaults to: nil)

    Specific options.

Options Hash (cast):

  • :casted_subject_uri (String, UU::OS::UESURI)

    UESURI of the subject (role, group or access role) which has a cast to the subject_uri. Either casted_subject_uri or casted_subject_universe_id must be set.

  • :casted_subject_universe_id (String)

    Universe ID of a user whose access role is cast to the subjectUri. Only an active access role is taken into account. If the user has no active access role in the territory, then false is always returned. Either casted_subject_uri or casted_subject_universe_id must be set.

  • :recursive (Boolean)

    Flag indicates whether to also check an indirect cast. An indirect cast can be checked only between an access role (identified either by UESURI or by Universe ID) and another subject (role or group). The default value is false (only a direct cast is checked).

Returns:

  • (Boolean)

    True if cast exists, else false.



231
232
233
234
235
236
237
238
239
240
241
# File 'uu_os-0.29.16/lib/uu/os/cast.rb', line 231

def exists(subject_uri, cast = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  dto = UU::OS::Cast::CastExists.new(cast)
  svc.add_parameter('castedSubjectUri', dto.casted_subject_uri)
  svc.add_parameter('castedSubjectUniverseId', dto.casted_subject_universe_id)
  svc.add_parameter('recursive', dto.recursive)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('exists', subject_uri)
    return (res == 'true') || (res == '"true"')
  end
end

- (Array) get_access_role_cast_list(subject_uri, criteria = nil)

Returns list of access roles (personal access roles and uuEEs) casted directly or indirectly to the specified subject (role or group). The list is sorted by the casted subject name and subsequently by casted subject code by default.

Examples:

# Returns ordered list of casted access roles whose name starts with 'Name Prefix' and code with 'Code Prefix'
UU::OS::Cast.get_access_role_cast_list('ues:TERRITORY:ROLE_OR_GROUP',
      :query => "castedSubjectName='Name Prefix%' AND castedSubjectCode='Code Prefix%' ORDER BY castedSubjectName")

Parameters:

  • subject_uri (String, UU::OS::UESURI)

    UESURI of the subject into which the personal access roles are casted.

  • criteria (CastGetCastList) (defaults to: nil)

    Object containing paging and filtering criteria.

Options Hash (criteria):

  • :query (String)

    Query for filtering and ordering of the result list (more information in uuQuery - Guideline). It is possible to filter the result list by castedSubjectName and castedSubjectCode.

Returns:



135
136
137
138
139
140
141
142
143
144
145
# File 'uu_os-0.29.16/lib/uu/os/cast.rb', line 135

def get_access_role_cast_list(subject_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  dto = Cast::CastGetAccessRoleCastList.new(criteria)
  svc.add_parameter('pageIndex', dto.page_index)
  svc.add_parameter('pageSize', dto.page_size)
  svc.add_parameter('query', dto.query)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getAccessRoleCastList', subject_uri)
    return UU::OS::REST::ResultList.new(Cast::CastGetAccessRoleCastList, Cast::CastAccessRoleAttributes, res)
  end
end

- (CastAttributes) get_attributes(subject_uri, dto)

Returns attributes of one cast. Cast is identified by two subjects. The main entity (a subject to which the other is casted) and parameter casted_subject_uri in the DTO (the casted subject).

Examples:

# Get attributes of a cast (ROLE2 is casted in ROLE1)
attributes = UU::OS::Cast.get_attributes('ues:TERRITORY:ROLE1',
        :casted_subject_uri => 'ues:TERRITORY:ROLE2'
)

Parameters:

  • subject_uri (String, UU::OS::UESURI)

    UESURI of the subject to which the other is casted

  • dto (CastGetAttributes)

    DTO containing UESURI of the casted subject

Options Hash (dto):

  • :casted_subject_uri (String, UU::OS::UESURI)

    UESURI of the subject (role or group) which is casted to the subject identified by the command main entity. Cannot be nil.

Returns:



83
84
85
86
87
88
89
90
91
# File 'uu_os-0.29.16/lib/uu/os/cast.rb', line 83

def get_attributes(subject_uri, dto)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  get_dto = UU::OS::Cast::CastGetAttributes.new(dto)
  svc.add_parameter('castedSubjectUri', get_dto.casted_subject_uri)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getAttributes', subject_uri)
    return Cast::CastAttributes.new(res)
  end
end

- (Array) get_cast_history_list(subject_uri, criteria = nil)

Returns a cast history list in the subject and/or from the subject. Only direct casts are supported. Casts are filtered and ordered by the query criteria. By default, only casts IN the subject are returned, sorted by the castCreationStamp. Result list cannot be paged. The maximum number of casts returned is 10,000. In case of exceeding the limit, an exception is thrown. Cast strategy 1 or higher must be enabled for the territory to use this command.

Examples:

UU::OS::Cast.get_cast_history_list('ues:TERRITORY:ROLE_OR_GROUP',
      :query => "castSubjectName='Name' AND castSubjectCode='Code' ORDER BY castSubjectName")

Parameters:

  • subject_uri (String)

    The subject where the subjects are cast, identified by UESURI.

  • criteria (CastGetCastHistoryList) (defaults to: nil)

    Object containing the search criteria.

Options Hash (criteria):

  • :query (String)

    Query in uuQuery 2.0 format. Records can be filtered by all attributes of CastHistoryAttributes. If filtering by an UESURI, it must be in the canonical form ues::[ROLE_OID]. If set to nil, no filtering will be applied except for castDirection which will be set to IN value by default.

Returns:

  • (Array)

    Array of CastHistoryAttributes containing the cast history attributes. The list is sorted by the cast creation stamp.



295
296
297
298
299
300
301
302
303
304
305
# File 'uu_os-0.29.16/lib/uu/os/cast.rb', line 295

def get_cast_history_list(subject_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  dto = Cast::CastGetCastHistoryList.new(criteria)
  svc.add_parameter('pageIndex', dto.page_index)
  svc.add_parameter('pageSize', dto.page_size)
  svc.add_parameter('query', dto.query)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getCastHistoryList', subject_uri)
    return UU::OS::REST::ResultList.new(Cast::CastGetCastHistoryList, Cast::CastHistoryAttributes, res)
  end
end

- (Array) get_cast_list(subject_uri, criteria = nil)

Returns list of casts to the specified subject (role or group). The list is sorted by the date of creation of a cast by default and due to backwards compatibility are returned only casts with IN cast direction by default.

Examples:

# Returns the primary cast in the role ROLE
UU::OS::Cast.get_cast_list('ues:TERRITORY:ROLE', :query => 'castDirection=IN AND primary=true')

# Returns all executive visible casts of an access role in other roles
UU::OS::Cast.get_cast_list('ues:TERRITORY:ACCESS_ROLE', :query => 'castDirection=TO AND state=ACTIVE AND level=EXECUTIVE')

Parameters:

  • subject_uri (String, UU::OS::UESURI)

    UESURI of the subject whose casts will be listed.

  • criteria (CastGetCastList) (defaults to: nil)

    Specific options.

Options Hash (criteria):

  • :query (String)

    Query for filtering and ordering of the result list (more information in uuQuery - Guideline). It is possible to filter the result list by castedSubjectName, castedSubjectCode, dateFrom, state, level, primary and castDirection.

Returns:

  • (Array)

    An Array with the command result. Contains instances of CastAttributes.



109
110
111
112
113
114
115
116
117
118
119
# File 'uu_os-0.29.16/lib/uu/os/cast.rb', line 109

def get_cast_list(subject_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  dto = Cast::CastGetCastList.new(criteria)
  svc.add_parameter('pageIndex', dto.page_index)
  svc.add_parameter('pageSize', dto.page_size)
  svc.add_parameter('query', dto.query)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getCastList', subject_uri)
    return UU::OS::REST::ResultList.new(Cast::CastGetCastList, Cast::CastAttributes, res)
  end
end

- (Object) set_attributes(subject_uri, cast = nil)

Sets basic attributes of the cast. Cast is not an entity, it is a relation between two subjects (and these two subjects identify the relation).

Examples:

# Change an existing cast to guest
UU::OS::Cast.set_attributes('ues:TERRITORY:ROLE2',
        :casted_subject_uri => 'ues:TERRITORY:ROLE1',
        :level => UU::OS::Cast::CastLevel::GUEST
)

# Change an existing cast of role in group to passive and hidden
UU::OS::Cast.set_attributes('ues:TERRITORY:GROUP',
        :casted_subject_uri => 'ues:TERRITORY:ROLE',
        :state => 'PASSIVE',
        :visible => false
)

Parameters:

  • subject_uri (String, UU::OS::UESURI)

    UESURI of the subject into which another subject is casted

  • cast (CastSetAttributes) (defaults to: nil)

    DTO containing attributes of the cast

Options Hash (cast):

  • :casted_subject_uri (String, UU::OS::UESURI)

    UESURI of the subject (role or group) which is casted to the subject identified by the command main entity. Cannot be nil.

  • :level (String, UU::OS::Cast::CastLevel)

    The level of the cast. The attribute cannot be set at the same time as the executive attribute. If the level is changed, the value of the executive attribute will be changed as well (true for the EXECUTIVE level, false for the ASSISTENCE or GUEST level).

  • :primary (Boolean)

    Specifies whether the cast will be the primary cast to the role. Applicable only if the subject_uri (main entity) is a role. If set to true, the cast must be visible in ACTIVE state and EXECUTIVE level. If the cast is primary and it is set to false, another cast (the oldest visible cast in ACTIVE state and EXECUTIVE level) to the subject_uri (main entity) will become the primary cast. If set to nil, the primary cast will not be changed.

  • :date_to (String)

    The date when the cast will be automatically set to the PASSIVE state. If the subject is a Role and the cast is the primary cast to the Role, then there must be either another ACTIVE visible cast with EXECUTIVE level to the Role which will become the primary cast, or no cast at all; otherwise the cast state will not be changed. If set to an empty string, the date will be erased. If set to nil, the value will not be modified.

  • :state (String, UU::OS::Cast::CastState)

    Deprecated. In territories with cast strategies of 2 or higher, all casts are either ACTIVE or they do not exist at all, so if you set a cast into a PASSIVE state, the cast will be permanently deleted. In territories with a cast strategy of 1 or lower, PASSIVE casts are just ignored while only ACTIVE casts are used in cast calculations.

  • :visible (Boolean)

    Specifies whether the cast is visible in Show Casts use case. If set to nil, the value will not be modified. If set to false, the cast must not be set as primary.



172
173
174
175
176
177
178
179
# File 'uu_os-0.29.16/lib/uu/os/cast.rb', line 172

def set_attributes(subject_uri, cast = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  payload = UU::OS::Cast::CastSetAttributes.new(cast).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('setAttributes', subject_uri, payload)
  end
end

- (UU::OS::UESURI[]) verify_cast_existence(territoryUri, criteria = nil)

Verifies the cast existence of a user to a list of subjects in a given territory. The user is identified by either Universe ID or access role UESURI.

Examples:

# Gets subjects with an existing cast of an Access Role specified by UID in a given territory.
UU::OS::Cast.verify_cast_existence("ues:UU-BT:UU-BT",
  :cast_subject_universe_id => "6-6666-1",
  :subject_uris => [
    "ues:[902387469238]:[987236489734]",
    "ues:[902387469238]:[967698769878]",
    "ues:[902387469238]:[998762378232]"
])

# Gets subjects with an existing cast of an Access Role specified by UESURI in a given territory.
UU::OS::Cast.verify_cast_existence("ues:UU-BT:UU-BT",
:cast_subject_uri => "ues:UU-BT:6-6666-1",
:subject_uris => [
   "ues:[902387469238]:[987236489734]",
   "ues:[902387469238]:[967698769878]",
   "ues:[902387469238]:[998762378232]"
])

Parameters:

  • territory_uri (String, UU::OS::UESURI)

    UESURI of the territory where the subjects are located in.

  • Object (CastVerifyCastExistence)

    containing one of the user identifiers and a list of subjects.

  • criteria (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (criteria):

  • :cast_subject_uri (String, UU::OS::UESURI)

    UESURI of the user access role whose cast existence to subject_uris is verified. Either cast_subject_universe_id or cast_subject_uri must be set.

  • :cast_subject_universe_id (String)

    Universe ID of the user whose cast existence to subject_uris is verified. The user must have an active access role in the territory. If the user does not exist or has no active access role in the territory, then an empty array is returned. Either cast_subject_universe_id or cast_subject_uri must be set.

  • :subject_uris (UU::OS::UESURI[])

    List of subjects in which the user cast existence is verified. The maximum number of subjects is 10. The subjects existence is not checked (an exception is NOT thrown if some of the subjects do not exist). If the user access role is included in subject_uris, then it will not be returned when verifying by the user access role itself (by cast_subject_uri), but it will be returned when verifying by the user Universe ID (by cast_subject_universe_id).

Returns:

  • (UU::OS::UESURI[])
    • List of subjects with an existing cast. UESURI is in the normalized form (with both codes and OIDs).



272
273
274
275
276
277
278
279
280
281
282
# File 'uu_os-0.29.16/lib/uu/os/cast.rb', line 272

def verify_cast_existence(territoryUri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  dto = UU::OS::Cast::CastVerifyCastExistence.new(criteria)
  svc.add_parameter('castSubjectUri', dto.cast_subject_uri)
  svc.add_parameter('castSubjectUniverseId', dto.cast_subject_universe_id)
  svc.add_parameter('subjectUris', dto.subject_uris)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('verifyCastExistence', territoryUri)
    return JSON.parse(res)
  end
end