Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UserGroupService

description

This service allows for managing user groups.

Hierarchy

Index

Constructors

constructor

Methods

addRoleToGroup

  • Assign role to user group.

    example
    
       const userGroupId: number = 1;
       const roleResource: string = "[URL to the Role resource]";
    
       (async () => {
         const {data, res} = await userGroupService.addRoleToGroup(userGroupId, roleResource);
      })();
    

    When role is assigned to user, suitable audit record is created with type 'User' and activity 'User updated'.

    Parameters

    • entityOrId: string | number | Partial<IUserGroup>

      User group's id or user group object.

    • childEntityOrSelf: string | Partial<ISource>

      Url to role resource or IRoleReference object.

    Returns Promise<IResult<IIdentified>>

    Returns promise object that is resolved with the IRoleReference wrapped by IResult.

addUserToGroup

  • Assign user to user group.

    example
    
       const userGroupId: number = 1;
       const userResource: string = "[URL to the User resource]";
    
       (async () => {
         const {data, res} = await userGroupService.addUserToGroup(userGroupId, userResource);
      })();
    

    When user is added to group, suitable audit record is created with type 'User' and activity 'User updated'.

    Parameters

    • entityOrId: string | number | Partial<IUserGroup>

      User group's id or user group object.

    • childEntityOrSelf: string | Partial<ISource>

      Url to user resource or IUserReference object.

    Returns Promise<IResult<IIdentified>>

    Returns promise object that is resolved with the IUserReference wrapped by IResult.

create

  • Creates a new user group.

    example
    
     const userGroupObject: IUserGroup = {
       name: "new user group"
     };
    
     (async () => {
       const {data, res} = await userGroupService.create(userGroupObject);
     })();
    

    Parameters

    Returns Promise<IResult<IUserGroup>>

    Returns promise object that is resolved with the details of newly created user group.

delete

  • Removes user group.

    example
    
       const userGroupId: number = 1;
    
       (async () => {
         const {data, res} = await userGroupService.delete(userGroupId);
      })();
    

    When group is removed, suitable audit records are created with type 'User' and activity 'User updated' with information that user has been removed from group.

    Please, note that the ADMINS and DEVICES groups can not be deleted.

    Parameters

    • entityOrId: number | IIdentified

      User group's id or user group object.

    Returns Promise<IResult<null>>

    Returns promise object that is resolved with the IResult of null.

detail

  • Gets the details of given user group.

    example
    
       const groupId: number = 1;
    
       (async () => {
         const {data, res} = await userGroupService.detail(roleId);
      })();
    

    Parameters

    • entityOrId: string | number | IUserGroup

      Group's id or role object.

    Returns Promise<IResult<IUserGroup>>

    Returns promise object that is resolved with the IUserGroup wrapped by IResult.

list

  • Gets the list of user groups filtered by parameters.

    example
    
     const filter: object = {
        severity: Severity.MAJOR,
        pageSize: 100,
        withTotalPages: true
      };
    
      (async () => {
        const {data, res, paging} = await userGroupService.list(filter);
      })();
    

    Parameters

    • Default value filter: object = {}

      Object containing filters for querying User Groups.

    Returns Promise<IResultList<IUserGroup>>

    Returns promise object that is resolved with the IUserGroup wrapped by IResultList.

removeRoleFromGroup

  • removeRoleFromGroup(entityOrId: string | number | Partial<IUserGroup>, childEntityOrSelf: string | Partial<ISource>): Promise<IResult<null>>
  • Unassign role from user

    example
    
       const userGroupId: number = 1;
       const userResource: string = "[URL to the Role resource]";
    
       (async () => {
         const {data, res} = await userGroupService.removeRoleFromGroup(userGroupId, userResource);
      })();
    

    Parameters

    • entityOrId: string | number | Partial<IUserGroup>

      User group's id or user group object.

    • childEntityOrSelf: string | Partial<ISource>

      Url to user resource or IRoleReference object.

    Returns Promise<IResult<null>>

    Returns promise object that is resolved with the IResult of null.

removeUserFromGroup

  • removeUserFromGroup(entityOrId: string | number | Partial<IUserGroup>, childEntityOrSelf: string | Partial<ISource>): Promise<IResult<null>>
  • Remove user from a group

    example
    
       const userGroupId: number = 1;
       const userResource: string = "[URL to the User resource]";
    
       (async () => {
         const {data, res} = await userGroupService.removeUserFromGroup(userGroupId, userResource);
      })();
    

    When user is removed from group, suitable audit record is created with type 'User' and activity 'User updated'.

    Parameters

    • entityOrId: string | number | Partial<IUserGroup>

      User group's id or user group object.

    • childEntityOrSelf: string | Partial<ISource>

      Url to user resource or IUserReference object.

    Returns Promise<IResult<null>>

    Returns promise object that is resolved with the IResult of null.

update

  • Updates user group data.

    example
    
     const partialUpdateObject: Partial<IUserGroup> = {
        "id" : 1,
        "self" : "[URL to this resource]",
        "name" : "PlatformAdministrators",
        ...
      }
    
     (async () => {
       const {data, res} = await userGroupService.update(partialUpdateObject);
     })();
    

    Parameters

    • entity: Partial<IUserGroup>

      User group is partially updatable.

    Returns Promise<IResult<IUserGroup>>

    Returns promise object that is resolved with the saved user group object.

Generated using TypeDoc