-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
207 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -713,7 +713,7 @@ try { | |
// Handle the error | ||
} | ||
|
||
// Update will override all fields as is. Use carefully. | ||
// Update will override all fields as is. Use carefully. Use patch instead if providing select fields. | ||
try { | ||
us.update("[email protected]", UserRequest.builder() | ||
.email("[email protected]") | ||
|
@@ -723,7 +723,17 @@ try { | |
.tenantId("tenant-ID1") | ||
.roleNames(Arrays.asList("role-name1"), | ||
AssociatedTenant.builder() | ||
.tenantId("tenant-ID2"))))); | ||
.tenantId("tenant-ID2")))) | ||
.build()); | ||
} catch (DescopeException de) { | ||
// Handle the error | ||
} | ||
|
||
// Patch will override provided fields but will leave other fields untouched. | ||
try { | ||
us.patch("[email protected]", PatchUserRequest.builder() | ||
.name("Desmond Copeland") | ||
.build()); | ||
} catch (DescopeException de) { | ||
// Handle the error | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/com/descope/model/user/request/PatchUserRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.descope.model.user.request; | ||
|
||
import static com.descope.utils.CollectionUtils.addIfNotNull; | ||
|
||
import com.descope.model.auth.AssociatedTenant; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Data | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PatchUserRequest { | ||
String name; | ||
String givenName; | ||
String middleName; | ||
String familyName; | ||
String phone; | ||
String email; | ||
List<String> roleNames; | ||
List<AssociatedTenant> userTenants; | ||
Map<String, Object> customAttributes; | ||
String picture; | ||
Boolean verifiedEmail; | ||
Boolean verifiedPhone; | ||
List<String> ssoAppIds; | ||
|
||
public Map<String, Object> toMap() { | ||
Map<String, Object> m = new HashMap<>(); | ||
addIfNotNull(m, "email", email); | ||
addIfNotNull(m, "verifiedEmail", verifiedEmail); | ||
addIfNotNull(m, "phone", phone); | ||
addIfNotNull(m, "verifiedPhone", verifiedPhone); | ||
addIfNotNull(m, "givenName", givenName); | ||
addIfNotNull(m, "middleName", middleName); | ||
addIfNotNull(m, "familyName", familyName); | ||
addIfNotNull(m, "roleNames", roleNames); | ||
addIfNotNull(m, "userTenants", userTenants); | ||
addIfNotNull(m, "customAttributes", customAttributes); | ||
addIfNotNull(m, "picture", picture); | ||
addIfNotNull(m, "ssoAppIDs", ssoAppIds); | ||
return m; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.