MethodsReuse
Module with shared REST-server methods that are reused by the various Methods-files.
use MethodsReuse;
Collection of shared REST-server methods that are reused by the various Methods-files.
Deletes a given entity
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: id, type. Id is entity ID from the AURORA database. Type is the textual entity type that the entity Id must fulfill in order to be allowed to delete. It is also used to check the TYPE_DELETE-permission on the entity.
Returns a HASH-reference with the success/data from the method as any other REST-method.
Enumerate entities of a given type.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: type, perm. Type is the textual entity type of the entity-types you want to enumerate. Perm is the permission that the user in the userid-input above must fulfill on the entities being enumerated.
Returns a HASH-reference with the success/data from the method as any other REST-method.
Enumerate permission types for a given entity type.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: type. Type is the entity type to enumerate the permission types for.
Returns a HASH-reference with the success/data from the method as any other REST-method.
Get entities by permission- and type.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: root, perm, permtype, entitytype. Root is the entity id of where to start in the entity tree to find entities. Perm is the LIST-reference of textual permission types to match. Permtype is the logical operator to use on the Perm-parameter - either "ANY" (logical OR) or "ALL" (logical AND).
Returns a HASH-reference with the success/data from the method as any other REST-method.
Get an entity's aggregated permissions.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: id, user, type, Id is the entity to get the aggregated perms on. User is the user entity id from the AURORA database that the we want the aggregated permissions to be valid for. If none is given or the user id is invalid, it will default to the id in userid (logged in user in the REST-server). Type is the texatual entity type to get permissions on (used for checking type, messages etc.).
Returns a HASH-reference with the success/data from the method as any other REST-method.
Get members of an entity.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: id, type. Id is the entity ID from the AURORA database to get the members of. Type is the textual entity type that the Id is to conform to (used for checking type, messages etc).
Returns a HASH-reference with the success/data from the method as any other REST-method.
Get an entity's metadata if permission is fulfilled.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: id, perm, permtype. Id is the entity ID from the AURORA database to get the metadata of. Perm is a LIST-reference of the permission(s) that must be fulfilled by the userid-input for metadata to be returned. Permtype is the logical operator to use on the permission(s) set in the Perm-parameter. It defaults to "ALL". Valid values are "ALL" (logical AND) or "ANY" (logical OR).
Returns a HASH-reference with the success/data from the method as any other REST-method.
Get an entity's display name.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: id, type. Id is the entity ID from the AURORA database that one wants to get the display name of. Type is the textual entity type that the Id-parameter must fulfill (used for checking, messages etc.).
Returns a HASH-reference with the success/data from the method as any other REST-method.
Get a users permissions on an entity.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: id, user, type. Id is the entity ID from the AURORA database that one wants to get the permissions on. User is the entity ID from the AURORA database that one wants to check the permissions of. If not specified or invalid, it will default to the userid-input (logged on user in the REST-server. Type is the textual entity type that the Id-parameter must fulfill (used for checking, messages etc.).
Returns a HASH-reference with the success/data from the method as any other REST-method. The returned permission(s) are in the keys "grant" and "deny".
Get entities permission(s) on an object.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: id, type. Id is the entity ID from the AURORA database that one wants to get the permission(s) of (object). Type is the textual entity type that the Id-parameter must fulfill (used for checking, messages etc.). This method returns all permission of an object on all entities that have permission(s) set on it.
Returns a HASH-reference with the success/data from the method as any other REST-method.
The return structure comes in the sub-hash called "perms" as follows:
perms => (
entityid1 => {
inherit => ["PERMISSIONa" .. "PERMISSIONz"],
grant => ["PERMISSIONa" .. "PERMISSIONz"],
deny => ["PERMISSIONa" .. "PERMISSIONz"],
perm => ["PERMISSIONa" .. "PERMISSIONz"]
},
.
.
entityidN => { .. }
)
Get task assignments of a given entity on COMPUTER-entities.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: id, type. Id is the entity ID from the AURORA database that one wants to get the assignments on. Type is the textual entity type that the Id-parameter must fulfill (used for checking, messages etc.).
Returns a HASH-reference with the success/data from the method as any other REST-method.
The return structure has the following format:
assignments => (
COMPUTERID1 => [TASKIDa .. TASKIDz]
.
.
COMPUTERIDN => [TASKIDa .. TASKIDz]
)
Move an entity in the entity tree.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: id, parent, type, parenttype. Id is the entity ID from the AURORA database that one wants to move. Parent is the entity ID from the AURORA database which is to be the new parent of the entity. Type is the textual entity type that the Id-parameter must fulfill (used for checking, messages etc.). Parenttype is the textual entity type that the parent-parameter must fulfill (used for checking, messages etc.).
In order for this method to success the user in userid must have the [type]_MOVE-permission on the current parent and the [parenttype]_CREATE-permission on the new parent that the entity is being moved to.
Returns a HASH-reference with the success/data from the method as any other REST-method. Returns 1 upon success, 0 upon failure (err).
Remove member(s) from a given entity.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: object, subject, type. Object is the entity id from the AURORA database of which to remove member(s) from. Subject is the LIST-reference of entity(ies) Id from the AURORA database to remove as members of the given object. Type is textual type that the object must meet (used for checking, messages etc.).
In order for the method to work, the user in userid needs to have the [type]_MEMBER_ADD-permission on the object-entity.
Returns a HASH-reference with the success/data from the method as any other REST-method. Returns 1 upon success, 0 upon failure (err).
Sets the entity's display name.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: id, type, name, duplicates. Id is the entity id from the AURORA database of which one wants to set the display name of. Type is the textual entity type that the entity id must fulfill (used for checking, messages etc.). Name is the display name that one wants to set on the entity. Duplicates decides if it is allowed with duplicate names on the given entity type. Valid values for duplicates are undef (no duplicates in entire tree), 0 (no duplicates within same group) or 1 (duplicates ok).
Returns a HASH-reference with the success/data from the method as any other REST-method. Returns 1 upon success, 0 upon failure (err). The new and cleaned name is returned in the "name" key.
Sets an entity's permissions.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: id, user, grant, deny, operation, type. Id is the entity id from the AURORA database of which one wants to set the permissions on (object). User is the entity id of the subject of which to set the permission(s) for. If invalid or none is specified, it will default to userid (logged in user of the REST-server). Grant is a LIST-reference of the textual permission(s) to grant. Deny is a LIST-reference of the textual permission(s) to deny. Operation is applying logic to use when setting the permission(s). Valid values are: replace, append or remove. Append is default. Type is the textual entity type of the entity to set the permissions on (used for checking, messages etc.)
In order for the method to succeed the user needs to have the [type]_PERM_SET-permission on the entity in question and he needs to have all the permissions that he is trying to set himself on that entity (either directly or through inheritance). One can only give away what one oneself has.
Returns a HASH-reference with the success/data from the method as any other REST-method. Returns 1 upon success, 0 upon failure (err). The resulting permissions set are returned in the keys "grant" and "deny" as LIST-references of textual permissions.
Set assignments of tasks on computers for a given entity.
Accepts the following input: content, query, db, userid, cfg, log (these comes from the REST-server and are just passed on by the caller).
This method uses these parameters from query input: id, type, assigns. Id is the entity id from the AURORA database of which one wants to set the task assignments of. Type is the textual entity type that the entity must fulfill (for checking, message etc.). Assigns is a HASH-reference of task assignments for computers to set on the given entity. See the getEntityTaskAssignments()-method for its structure.
In order for the method to succeed the user in userid needs to have the [type]_CHANGE-permission on the entity in question. Please also note that this method is destructive and all existing assignments are replaced with the new one(s).
Returns a HASH-reference with the success/data from the method as any other REST-method. Returns 1 upon success, 0 upon failure (err). The set assignments are returned in the key "assignments".