@c8y/client
Version:
Client application programming interface to access the Cumulocity IoT-Platform REST services.
208 lines • 7.71 kB
TypeScript
import { Service, IIdentified, IResult, ISource, IResultList } from '../core/index.js';
import { IUserGroup } from './IUserGroup.js';
import { IRoleReference } from '../user-role/index.js';
import { IUserReference } from '../user/index.js';
/**
* @description
* This service allows for managing user groups.
*/
export declare class UserGroupService extends Service<IUserGroup> {
protected baseUrl: string;
protected propertyName: string;
protected get listUrl(): string;
/**
* Gets the details of given user group.
*
* @param {string|number|IUserGroup} entityOrId Group's id or role object.
*
* @returns Returns promise object that is resolved with the IUserGroup wrapped by IResult.
*
* **Example**
* ```typescript
*
* const groupId: number = 1;
*
* (async () => {
* const {data, res} = await userGroupService.detail(roleId);
* })();
* ```
*/
detail(entityOrId: string | number | IUserGroup): Promise<IResult<IUserGroup>>;
/**
* Creates a new user group.
*
* @param {IUserGroup} entity User Group object.
*
* @returns {IResult<IUserGroup>} Returns promise object that is resolved with
* the details of newly created user group.
*
* **Example**
* ```typescript
*
* const userGroupObject: IUserGroup = {
* name: "new user group"
* };
*
* (async () => {
* const {data, res} = await userGroupService.create(userGroupObject);
* })();
* ```
*/
create(entity: Partial<IUserGroup>): Promise<IResult<IUserGroup>>;
/**
* Updates user group data.
*
* @param {Partial<IUserGroup>} entity User group is partially updatable.
*
* @returns {IResult<IUserGroup>} Returns promise object that is resolved with the saved user group object.
*
* **Example**
* ```typescript
*
* const partialUpdateObject: Partial<IUserGroup> = {
* "id" : 1,
* "self" : "[URL to this resource]",
* "name" : "PlatformAdministrators",
* ...
* }
*
* (async () => {
* const {data, res} = await userGroupService.update(partialUpdateObject);
* })();
* ```
*/
update(entity: Partial<IUserGroup>): Promise<IResult<IUserGroup>>;
/**
* Gets the list of user groups filtered by parameters.
*
* @param {object} filter Object containing filters for querying User Groups.
*
* @returns Returns promise object that is resolved with the IUserGroup wrapped by IResultList.
*
* **Example**
* ```typescript
*
* const filter: object = {
* severity: Severity.MAJOR,
* pageSize: 100,
* withTotalPages: true
* };
*
* (async () => {
* const {data, res, paging} = await userGroupService.list(filter);
* })();
* ```
*/
list(filter?: object): Promise<IResultList<IUserGroup>>;
/**
* Removes user group.
*
* @param {number | IIdentified} entityOrId User group's id or user group object.
*
* @returns Returns promise object that is resolved with the IResult of null.
*
* **Example**
* ```typescript
*
* 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.
*/
delete(entityOrId: number | IIdentified): Promise<IResult<null>>;
/**
* Assign role to user group.
*
* @param {string | number | Partial<IUserGroup>} entityOrId User group's id or user group object.
* @param {string | Partial<ISource>} childEntityOrSelf Url to role resource or IRoleReference object.
*
* @returns Returns promise object that is resolved with the IRoleReference wrapped by IResult.
*
* **Example**
* ```typescript
*
* 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'.
*/
addRoleToGroup(entityOrId: string | number | Partial<IUserGroup>, childEntityOrSelf: string | Partial<ISource>): Promise<IResult<IRoleReference>>;
/**
* Unassign role from user
*
* @param {string | number | Partial<IUserGroup>} entityOrId User group's id or user group object.
* @param {string | Partial<ISource>} childEntityOrSelf Url to user resource or IRoleReference object.
*
* @returns Returns promise object that is resolved with the IResult of null.
*
* **Example**
* ```typescript
*
* const userGroupId: number = 1;
* const userResource: string = "[URL to the Role resource]";
*
* (async () => {
* const {data, res} = await userGroupService.removeRoleFromGroup(userGroupId, userResource);
* })();
* ```
*/
removeRoleFromGroup(entityOrId: string | number | Partial<IUserGroup>, childEntityOrSelf: string | Partial<ISource>): Promise<IResult<null>>;
/**
* Assign user to user group.
*
* @param {string | number | Partial<IUserGroup>} entityOrId User group's id or user group object.
* @param {string | Partial<ISource>} childEntityOrSelf Url to user resource or IUserReference object.
*
* @returns Returns promise object that is resolved with the IUserReference wrapped by IResult.
*
* **Example**
* ```typescript
*
* 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'.
*/
addUserToGroup(entityOrId: string | number | Partial<IUserGroup>, childEntityOrSelf: string | Partial<ISource>): Promise<IResult<IUserReference>>;
/**
* Remove user from a group
*
* @param {string | number | Partial<IUserGroup>} entityOrId User group's id or user group object.
* @param {string | Partial<ISource>} childEntityOrSelf Url to user resource or IUserReference object.
*
* @returns Returns promise object that is resolved with the IResult of null.
*
* **Example**
* ```typescript
*
* 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'.
*/
removeUserFromGroup(entityOrId: string | number | Partial<IUserGroup>, childEntityOrSelf: string | Partial<ISource>): Promise<IResult<null>>;
protected getSelf(childReference: string | Partial<ISource>): string;
private getChildUrl;
private getChildReferenceAsBody;
private addChild;
private removeChild;
}
//# sourceMappingURL=UserGroupService.d.ts.map