Module: UU::OS::Friend

Extended by:
Friend
Included in:
Friend
Defined in:
uu_os-0.29.16/lib/uu/os/friend.rb,
uu_os-0.29.16/lib/uu/os/friend/friend_create.rb,
uu_os-0.29.16/lib/uu/os/friend/friend_attributes.rb,
uu_os-0.29.16/lib/uu/os/friend/friend_set_attributes.rb

Overview

Friend service

Defined Under Namespace

Classes: FriendAttributes, FriendCreate, FriendSetAttributes

Constant Summary

PATH =

Service path for the REST API

'ues/myterritory/person/UESFriend'

Instance Method Summary (collapse)

Instance Method Details

- (Object) activate_access(friend_uri)

Activates a friend. The friend will be again with access to the territory where is located.

Examples:

# Activate access of a friend
UU::OS::Friend.activate_access('ues:TERRITORY:FRIEND')

Parameters:

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

    UESURI of a friend that the access will be reactivated



122
123
124
125
126
127
# File 'uu_os-0.29.16/lib/uu/os/friend.rb', line 122

def activate_access(friend_uri)
  svc = UU::OS::REST::RemoteClient.new(Friend)
  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('activateAccess', friend_uri)
  end
end

- (UU::OS::UESURI) create(personal_territory_uri, criteria = nil)

Creates a new friend. The command creates a new friend in a specified personal territory. At the very least meta artifact must be specified in FriendCreate DTO.

Examples:

# Create a new friend (using only required attributes)
UU::OS::Friend.create('ues:PERSONAL_TERRITORY:PERSONAL_TERRITORY',
    :meta_artifact_uri => 'ues:TERRITORY:META_ARTIFACT',
    :universe_id => '1234-56789-1'
)

# Create a new friend (and set most of its attributes)
UU::OS::Friend.create('ues:PERSONAL_TERRITORY:PERSONAL_TERRITORY',
    :meta_artifact_uri => 'ues:TERRITORY:META_ARTIFACT',
    :universe_id => '1234-56789-1',
    :first_name => 'John',
    :surname => 'Smith',
    :code => 'FRIEND_JOHN_SMITH',
    :description => 'Description of John Smith',
    :security_level => UU::OS::Artifact::SecurityLevel::NO_CONFIDENTIALITY,
    :icon_uri => 'ues:#{system}:#{ues_v5.core_v1.codetable_v1.base_v1.CodeTable_Icons}:#{ART_322}',
    :message => 'I am your classmate'
)

Parameters:

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

    UESURI of the personal territory where a new friend will be created

  • criteria (FriendCreate) (defaults to: nil)

    DTO containing attributes of the new friend

Options Hash (criteria):

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

    UESURI of the meta artifact. Only a meta artifact with the template class of Friend (not its descendants) can be used. If the rights does not permit to create a new friend from the meta artifact, the create command fails.

  • :universe_id (String)

    Universe identifier of the friend. If it is not specified, the create command fails.

  • :first_name (String)

    First name of the new friend. If it is not specified, the value is used from friend’s personal role (but if it is not specified and the attribute surname is not nil, the command fails).

  • :surname (String)

    Surname of the new friend. If it is not specified, the value is used from friend’s personal role (but If it is not specified and the attribute name is not nil, the command fails).

  • :code (String)

    Code of the new friend. If it is not specified, the code is generated automatically using the system sequence. The code must be unique in the given territory, otherwise the create command fails.

  • :description (String)

    Description of the new friend. If it is not specified, tDescription from meta artifact is used if set, otherwise no description is set on the new friend.

  • :security_level (String, UU::OS::Artifact::SecurityLevel)

    Security level of the new friend. If it is not specified, security level is taken from the meta artifact tSecurityLevel. If the meta artifact tSecurityLevel is higher than the user’s security clearance, the create command fails.

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

    URI of the friend’s icon. If it is not specified, the friend uses icon from meta artifact. An example of icon URI: ‘ues:#{system}:#{ues_v5.core_v1.codetable_v1.base_v1.CodeTable_Icons}:#{ART_077}’.

  • :message (String)

    Personal message for the friend. The message is used in friendship confirmation activity.

Returns:



105
106
107
108
109
110
111
112
113
# File 'uu_os-0.29.16/lib/uu/os/friend.rb', line 105

def create(personal_territory_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Friend)
  payload = UU::OS::Friend::FriendCreate.new(criteria).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('create', personal_territory_uri, payload)
    return UU::OS::UESURI.new(res)
  end
end

- (Object) deactivate_access(friend_uri)

Deactivates a friend. The friend will be without access to the territory where is located.

Examples:

# Deactivate access of a friend
UU::OS::Friend.deactivate_access('ues:TERRITORY:FRIEND')

Parameters:

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

    UESURI of a friend that the access will be canceled



136
137
138
139
140
141
# File 'uu_os-0.29.16/lib/uu/os/friend.rb', line 136

def deactivate_access(friend_uri)
  svc = UU::OS::REST::RemoteClient.new(Friend)
  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('deactivateAccess', friend_uri)
  end
end

- (FriendAttributes) get_attributes(friend_uri)

Returns attributes representing the friend specified by the friend_uri parameter. The command does not change the state of the friend in the system.

Examples:

# Get attributes of a friend
UU::OS::Friend.get_attributes('ues:TERRITORY:FRIEND')

Parameters:

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

    UESURI of the friend whose attributes are returned

Returns:



29
30
31
32
33
34
35
# File 'uu_os-0.29.16/lib/uu/os/friend.rb', line 29

def get_attributes(friend_uri)
  svc = UU::OS::REST::RemoteClient.new(Friend)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getAttributes', friend_uri)
    return Friend::FriendAttributes.new(res)
  end
end

- (UU::OS::UESURI) set_attributes(friend_uri, criteria = nil)

Command for setting attributes of a friend. The command can't modify references to objects like location, competent role and so on.

Examples:

# Set a few attributes of a friend
UU::OS::Friend.set_attributes('ues:TERRITORY:FRIEND',
    :surname => 'New Surname',
    :code => 'NEW_CODE',
    :security_level => UU::OS::Artifact::SecurityLevel::CONFIDENTIAL
)

Parameters:

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

    UESURI of the friend whose attributes are to be changed

  • criteria (FriendSetAttributes) (defaults to: nil)

    DTO containing new attributes of the friend

Options Hash (criteria):

  • :first_name (String)

    The new name of the role. If nil is set, the name is not modified. Note that the role name is automatically extended by the name of casted access roles names, when this attribute is not nil. Therefore the name attribute returned by the set_attributes command contains different string.

  • :surname (String)

    The new code of the role. If nil is set, the code is not modified. The code must be unique in a given territory, otherwise the set_attributes command fails.

  • :code (String)

    The new description of the role. If nil is set, the description is not modified.

  • :description (String)

    The new description of the role. If nil is set, the description is not modified.

  • :security_level (String, UU::OS::Artifact::SecurityLevel)

    The new description of the role. If nil is set, the description is not modified.

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

    of the friend’s icon. If nil is set, the icon is not modified. If nil URI (‘ues:[-1]:[-1]:’) is set, the friend’s icon is removed and the friend uses icon from meta artifact. An example of icon URI: ‘ues:#{system}:#{ues_v5.core_v1.codetable_v1.base_v1.CodeTable_Icons}:#{ART_077}’.

Returns:



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

def set_attributes(friend_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Friend)
  payload = UU::OS::Friend::FriendSetAttributes.new(criteria).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('setAttributes', friend_uri, payload)
    return UU::OS::UESURI.new(res)
  end
end