diff --git a/lib/core/services/identity-group.service.ts b/lib/core/services/identity-group.service.ts index ba3702bb49..9bf90a04f1 100644 --- a/lib/core/services/identity-group.service.ts +++ b/lib/core/services/identity-group.service.ts @@ -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 { + 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 { + 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 { + 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 { + const url = `${this.identityHost}/groups/${groupId}/role-mappings/realm/composite`; + return this.oAuth2Service.get({ url }); + } + /** * Queries groups. * @returns Array of user information objects