com.descope.sdk.mgmt.impl.GroupServiceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-sdk Show documentation
Show all versions of java-sdk Show documentation
Java library used to integrate with Descope.
package com.descope.sdk.mgmt.impl;
import static com.descope.literals.Routes.ManagementEndPoints.GROUP_LOAD_ALL_LINK;
import static com.descope.literals.Routes.ManagementEndPoints.LOAD_ALL_FOR_GROUP_MEMBERS_LINK;
import static com.descope.literals.Routes.ManagementEndPoints.LOAD_ALL_GROUP_MEMBERS_LINK;
import static com.descope.utils.CollectionUtils.mapOf;
import com.descope.exception.DescopeException;
import com.descope.exception.ServerCommonException;
import com.descope.model.client.Client;
import com.descope.model.group.Group;
import com.descope.proxy.ApiProxy;
import com.descope.sdk.mgmt.GroupService;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
class GroupServiceImpl extends ManagementsBase implements GroupService {
GroupServiceImpl(Client client) {
super(client);
}
@Override
@SuppressWarnings("unchecked")
public List loadAllGroups(String tenantID) throws DescopeException {
if (StringUtils.isBlank(tenantID)) {
throw ServerCommonException.invalidArgument("TenantId");
}
Map request = mapOf("tenantId", tenantID);
ApiProxy apiProxy = getApiProxy();
return (List) apiProxy.post(getUri(GROUP_LOAD_ALL_LINK), request, List.class);
}
@Override
@SuppressWarnings("unchecked")
public List loadAllGroupsForMembers(
String tenantID, List userIDs, List loginIDs) throws DescopeException {
if (StringUtils.isBlank(tenantID)) {
throw ServerCommonException.invalidArgument("TenantId");
}
if (userIDs.isEmpty() && loginIDs.isEmpty()) {
throw ServerCommonException.invalidArgument("userIDs and loginIDs");
}
Map request =
mapOf("tenantId", tenantID, "loginIds", loginIDs, "userIds", userIDs);
ApiProxy apiProxy = getApiProxy();
return (List)
apiProxy.post(getUri(LOAD_ALL_FOR_GROUP_MEMBERS_LINK), request, List.class);
}
@Override
@SuppressWarnings("unchecked")
public List loadAllGroupMembers(String tenantID, String groupID) throws DescopeException {
if (StringUtils.isBlank(tenantID)) {
throw ServerCommonException.invalidArgument("TenantId");
}
if (StringUtils.isBlank(groupID)) {
throw ServerCommonException.invalidArgument("GroupID");
}
Map request = mapOf("tenantId", tenantID, "groupId", groupID);
ApiProxy apiProxy = getApiProxy();
return (List) apiProxy.post(getUri(LOAD_ALL_GROUP_MEMBERS_LINK), request, List.class);
}
}