import api from './api';

const BASE = '/entra';

const entraService = {
    getUsers:         async ()               => { const r = await api.get(`${BASE}/users`);                   return r.data.data; },
    getUserGroups:    async (userId)         => { const r = await api.get(`${BASE}/users/${userId}/groups`);  return r.data.data; },
    getGroups:        async ()               => { const r = await api.get(`${BASE}/groups`);                  return r.data.data; },
    getGroupMembers:  async (groupId)        => { const r = await api.get(`${BASE}/groups/${groupId}/members`); return r.data.data; },
    addGroupMember:   async (groupId, userId)         => { const r = await api.post(`${BASE}/groups/${groupId}/members`, { userId }); return r.data; },
    removeGroupMember: async (groupId, userId)        => { const r = await api.delete(`${BASE}/groups/${groupId}/members/${userId}`); return r.data; },
    getRoles:         async ()               => { const r = await api.get(`${BASE}/roles`);                   return r.data.data; },
};

export default entraService;
