diff --git a/README.md b/README.md
index ea1d835d..ad77b744 100644
--- a/README.md
+++ b/README.md
@@ -1029,6 +1029,16 @@ try {
// Handle the error
}
+// Search roles
+try {
+ RoleResponse resp = rs.search(RoleSearchOptions.builder().tenantIds(Arrays.asList(tid)).build());
+ for (Role r : resp.getRoles()) {
+ // Do something
+ }
+} catch (DescopeException de) {
+ // Handle the error
+}
+
```
### Query SSO Groups
diff --git a/examples/management-cli/pom.xml b/examples/management-cli/pom.xml
index 2d542142..360cc796 100644
--- a/examples/management-cli/pom.xml
+++ b/examples/management-cli/pom.xml
@@ -19,7 +19,7 @@
com.descope
java-sdk
- 1.0.15
+ 1.0.16
info.picocli
diff --git a/pom.xml b/pom.xml
index 15d5231a..856311bd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.descope
java-sdk
4.0.0
- 1.0.15
+ 1.0.16
${project.groupId}:${project.artifactId}
Java library used to integrate with Descope.
https://github.com/descope/descope-java
diff --git a/src/main/java/com/descope/literals/Routes.java b/src/main/java/com/descope/literals/Routes.java
index fb23ce1f..1d484539 100644
--- a/src/main/java/com/descope/literals/Routes.java
+++ b/src/main/java/com/descope/literals/Routes.java
@@ -181,6 +181,7 @@ public static class ManagementEndPoints {
public static final String MANAGEMENT_ROLES_UPDATE_LINK = "/v1/mgmt/role/update";
public static final String MANAGEMENT_ROLES_DELETE_LINK = "/v1/mgmt/role/delete";
public static final String MANAGEMENT_ROLES_LOAD_ALL_LINK = "/v1/mgmt/role/all";
+ public static final String MANAGEMENT_ROLES_SEARCH_LINK = "/v1/mgmt/role/search";
// Project
public static final String MANAGEMENT_PROJECT_UPDATE_NAME = "/v1/mgmt/project/update/name";
diff --git a/src/main/java/com/descope/model/roles/RoleSearchOptions.java b/src/main/java/com/descope/model/roles/RoleSearchOptions.java
new file mode 100644
index 00000000..8c3d430a
--- /dev/null
+++ b/src/main/java/com/descope/model/roles/RoleSearchOptions.java
@@ -0,0 +1,18 @@
+package com.descope.model.roles;
+
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class RoleSearchOptions {
+ private List tenantIds;
+ private List roleNames;
+ private String roleNameLike; // match role names that contain the given string case insensitive
+ private List permissionNames;
+}
diff --git a/src/main/java/com/descope/sdk/mgmt/RolesService.java b/src/main/java/com/descope/sdk/mgmt/RolesService.java
index e9803993..3275cb9a 100644
--- a/src/main/java/com/descope/sdk/mgmt/RolesService.java
+++ b/src/main/java/com/descope/sdk/mgmt/RolesService.java
@@ -2,6 +2,7 @@
import com.descope.exception.DescopeException;
import com.descope.model.roles.RoleResponse;
+import com.descope.model.roles.RoleSearchOptions;
import java.util.List;
public interface RolesService {
@@ -20,4 +21,6 @@ void update(String name, String tenantId, String newName, String description, Li
void delete(String name, String tenantId) throws DescopeException;
RoleResponse loadAll() throws DescopeException;
+
+ RoleResponse search(RoleSearchOptions roleSearchOptions) throws DescopeException;
}
diff --git a/src/main/java/com/descope/sdk/mgmt/impl/RolesServiceImpl.java b/src/main/java/com/descope/sdk/mgmt/impl/RolesServiceImpl.java
index e7570fde..6cf41e91 100644
--- a/src/main/java/com/descope/sdk/mgmt/impl/RolesServiceImpl.java
+++ b/src/main/java/com/descope/sdk/mgmt/impl/RolesServiceImpl.java
@@ -3,6 +3,7 @@
import static com.descope.literals.Routes.ManagementEndPoints.MANAGEMENT_ROLES_CREATE_LINK;
import static com.descope.literals.Routes.ManagementEndPoints.MANAGEMENT_ROLES_DELETE_LINK;
import static com.descope.literals.Routes.ManagementEndPoints.MANAGEMENT_ROLES_LOAD_ALL_LINK;
+import static com.descope.literals.Routes.ManagementEndPoints.MANAGEMENT_ROLES_SEARCH_LINK;
import static com.descope.literals.Routes.ManagementEndPoints.MANAGEMENT_ROLES_UPDATE_LINK;
import static com.descope.utils.CollectionUtils.mapOf;
@@ -10,6 +11,7 @@
import com.descope.exception.ServerCommonException;
import com.descope.model.client.Client;
import com.descope.model.roles.RoleResponse;
+import com.descope.model.roles.RoleSearchOptions;
import com.descope.proxy.ApiProxy;
import com.descope.sdk.mgmt.RolesService;
import java.util.List;
@@ -82,4 +84,10 @@ public RoleResponse loadAll() throws DescopeException {
ApiProxy apiProxy = getApiProxy();
return apiProxy.get(getUri(MANAGEMENT_ROLES_LOAD_ALL_LINK), RoleResponse.class);
}
+
+ @Override
+ public RoleResponse search(RoleSearchOptions roleSearchOptions) throws DescopeException {
+ ApiProxy apiProxy = getApiProxy();
+ return apiProxy.post(getUri(MANAGEMENT_ROLES_SEARCH_LINK), roleSearchOptions, RoleResponse.class);
+ }
}
diff --git a/src/test/java/com/descope/sdk/mgmt/impl/RolesServiceImplTest.java b/src/test/java/com/descope/sdk/mgmt/impl/RolesServiceImplTest.java
index 828160ad..80c7af8a 100644
--- a/src/test/java/com/descope/sdk/mgmt/impl/RolesServiceImplTest.java
+++ b/src/test/java/com/descope/sdk/mgmt/impl/RolesServiceImplTest.java
@@ -19,6 +19,7 @@
import com.descope.model.mgmt.ManagementServices;
import com.descope.model.roles.Role;
import com.descope.model.roles.RoleResponse;
+import com.descope.model.roles.RoleSearchOptions;
import com.descope.proxy.ApiProxy;
import com.descope.proxy.impl.ApiProxyBuilder;
import com.descope.sdk.TestUtils;
@@ -152,7 +153,7 @@ void testFunctionalFullCycle() {
}
assertTrue(found);
rolesService.update(r1, r1 + "1", "zzz", Arrays.asList(p1));
- roles = rolesService.loadAll();
+ roles = rolesService.search(RoleSearchOptions.builder().roleNames(Arrays.asList(r1 + "1")).build());
assertThat(roles.getRoles()).isNotEmpty();
found = false;
for (Role r : roles.getRoles()) {
@@ -190,7 +191,7 @@ void testFunctionalFullCycleWithTenantId() {
}
assertTrue(found);
rolesService.update(r1, tid, r1 + "1", "zzz", Arrays.asList(p1));
- roles = rolesService.loadAll();
+ roles = rolesService.search(RoleSearchOptions.builder().tenantIds(Arrays.asList(tid)).build());
assertThat(roles.getRoles()).isNotEmpty();
found = false;
for (Role r : roles.getRoles()) {