add missing group role APIs (#6057)

* add missing group role apis

* add missing "assign" and "remove" api
This commit is contained in:
Denys Vuika
2020-08-24 15:37:02 +01:00
committed by GitHub
parent b0ec6041c0
commit 0f11094b1e

View File

@@ -60,6 +60,50 @@ export class IdentityGroupService {
return this.oAuth2Service.get({ url });
}
/**
* Gets assigned roles
* @param groupId Id of the group.
* @returns Array of available roles
*/
getAssignedRoles(groupId: string): Observable<IdentityRoleModel[]> {
const url = `${this.identityHost}/groups/${groupId}/role-mappings/realm`;
return this.oAuth2Service.get({ url });
}
/**
* Assigns roles to the group
* @param groupId The ID of the group
* @param roles Array of roles to assign
*/
assignRoles(groupId: string, roles: IdentityRoleModel[]): Observable<any> {
const url = `${this.identityHost}/groups/${groupId}/role-mappings/realm`;
const bodyParam = JSON.stringify(roles);
return this.oAuth2Service.post({ url, bodyParam });
}
/**
* Removes roles from the group
* @param groupId The ID of the group
* @param roles Array of roles to remove
*/
removeRoles(groupId: string, roles: IdentityRoleModel[]): Observable<any> {
const url = `${this.identityHost}/groups/${groupId}/role-mappings/realm`;
const bodyParam = JSON.stringify(roles);
return this.oAuth2Service.delete({ url, bodyParam });
}
/**
* Get effective roles
* @param groupId Id of the group
* @returns Array of effective roles
*/
getEffectiveRoles(groupId: string): Observable<IdentityRoleModel[]> {
const url = `${this.identityHost}/groups/${groupId}/role-mappings/realm/composite`;
return this.oAuth2Service.get({ url });
}
/**
* Queries groups.
* @returns Array of user information objects