Skip to content

Commit b4278cf

Browse files
authored
Expose create and Delete csutom attributes (#207)
+ tests fixes descope/etc#11122
1 parent 6c69f75 commit b4278cf

12 files changed

Lines changed: 309 additions & 1 deletion

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>com.descope</groupId>
66
<artifactId>java-sdk</artifactId>
77
<modelVersion>4.0.0</modelVersion>
8-
<version>1.0.44</version>
8+
<version>1.0.45</version>
99
<name>${project.groupId}:${project.artifactId}</name>
1010
<description>Java library used to integrate with Descope.</description>
1111
<url>https://github.com/descope/descope-java</url>

src/main/java/com/descope/literals/Routes.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ public static class ManagementEndPoints {
218218
// Password settings
219219
public static final String MANAGEMENT_PASSWORD_SETTINGS = "/v1/mgmt/password/settings";
220220

221+
// custom attributes
222+
public static final String MANAGEMENT_GET_USER_CUSTOM_ATTRIBUTES = "/v1/mgmt/user/customattributes";
223+
public static final String MANAGEMENT_CREATE_USER_CUSTOM_ATTRIBUTES = "/v1/mgmt/user/customattribute/create";
224+
public static final String MANAGEMENT_DELETE_USER_CUSTOM_ATTRIBUTES = "/v1/mgmt/user/customattribute/delete";
225+
221226
// Outbound
222227
public static final String MANAGEMENT_FETCH_OUTBOUND_APP_USER_TOKEN = "/v1/mgmt/outbound/app/user/token";
223228
public static final String MANAGEMENT_DELETE_OUTBOUND_APP_USER_TOKEN_BY_ID = "/v1/mgmt/outbound/token";
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.descope.model.customattributes;
2+
3+
import java.util.List;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
9+
@Data
10+
@Builder
11+
@AllArgsConstructor
12+
@NoArgsConstructor
13+
public class CreateCustomAttributesRequest {
14+
private List<CustomAttribute> attributes;
15+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.descope.model.customattributes;
2+
3+
import java.util.List;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
9+
@Data
10+
@Builder
11+
@AllArgsConstructor
12+
@NoArgsConstructor
13+
public class CustomAttribute {
14+
private String name;
15+
private int type;
16+
private List<CustomAttributeOption> options;
17+
private String displayName;
18+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.descope.model.customattributes;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
@Data
9+
@Builder
10+
@AllArgsConstructor
11+
@NoArgsConstructor
12+
public class CustomAttributeOption {
13+
private String value;
14+
private String label;
15+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.descope.model.customattributes;
2+
3+
import java.util.List;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
9+
@Data
10+
@Builder
11+
@AllArgsConstructor
12+
@NoArgsConstructor
13+
public class CustomAttributesResponse {
14+
private List<CustomAttribute> data;
15+
private int total;
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.descope.model.customattributes;
2+
3+
import java.util.List;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
9+
10+
11+
@Data
12+
@Builder
13+
@AllArgsConstructor
14+
@NoArgsConstructor
15+
public class DeleteCustomAttributesRequest {
16+
private List<String> names;
17+
}

src/main/java/com/descope/model/mgmt/ManagementServices.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.descope.sdk.mgmt.SsoApplicationService;
1616
import com.descope.sdk.mgmt.SsoService;
1717
import com.descope.sdk.mgmt.TenantService;
18+
import com.descope.sdk.mgmt.UserCustomAttributesService;
1819
import com.descope.sdk.mgmt.UserService;
1920
import lombok.Builder;
2021
import lombok.Getter;
@@ -38,4 +39,5 @@ public class ManagementServices {
3839
PasswordSettingsService passwordSettingsService;
3940
OutboundAppsService outboundAppsService;
4041
InboundAppsService inboundAppsService;
42+
UserCustomAttributesService userCustomAttributesService;
4143
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.descope.sdk.mgmt;
2+
3+
import com.descope.exception.DescopeException;
4+
import com.descope.model.customattributes.CreateCustomAttributesRequest;
5+
import com.descope.model.customattributes.CustomAttributesResponse;
6+
import com.descope.model.customattributes.DeleteCustomAttributesRequest;
7+
8+
/** Provides audit records search capabilities. */
9+
public interface UserCustomAttributesService {
10+
11+
/**
12+
* Get all user custom attributes.
13+
*
14+
* @return {@link CustomAttributesResponse}
15+
* @throws DescopeException If there occurs any exception, a subtype of this exception will be thrown.
16+
*/
17+
CustomAttributesResponse getCustomAttributes() throws DescopeException;
18+
19+
/**
20+
* Create custom attributes.
21+
*
22+
* @param request the custom attribtues (1 or more) to create
23+
* @return {@link CustomAttributesResponse}
24+
* @throws DescopeException If there occurs any exception, a subtype of this exception will be thrown.
25+
*/
26+
CustomAttributesResponse createCustomAttributes(CreateCustomAttributesRequest request) throws DescopeException;
27+
28+
/**
29+
* Delete custom attributes.
30+
*
31+
* @param request the names of the attributes to delete
32+
* @return {@link CustomAttributesResponse}
33+
* @throws DescopeException If there occurs any exception, a subtype of this exception will be thrown.
34+
*/
35+
CustomAttributesResponse deleteCustomAttributes(DeleteCustomAttributesRequest request) throws DescopeException;
36+
}

src/main/java/com/descope/sdk/mgmt/impl/ManagementServiceBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public static ManagementServices buildServices(Client client) {
2424
.ssoApplicationService(new SsoApplicationServiceImpl(client))
2525
.outboundAppsService(new OutboundAppsServiceImpl(client))
2626
.inboundAppsService(new InboundAppsServiceImpl(client))
27+
.userCustomAttributesService(new UserCustomAttributesServiceImpl(client))
2728
.build();
2829
}
2930
}

0 commit comments

Comments
 (0)