Skip to content

Commit

Permalink
Merge pull request #423 from permitio/update-java-sdk-page
Browse files Browse the repository at this point in the history
update java sdk page
  • Loading branch information
gideonsmila authored Sep 22, 2024
2 parents fc7b3b2 + d6a1b28 commit c1921cb
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion docs/sdk/java/user/create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You will later pass this ID to the `permit.check()` API. You can use anything fo
`first_name` - **optional** - First name of the user.<br/>
`last_name` - **optional** - Last name of the user.<br/>
`attributes` - **optional** - Arbitraty user attributes that will be used to enforce attribute-based access control policies.<br/>

`role_assignments` - **optional** - List of roles to assign to the user in the environment.<br/>

### Implementation

Expand All @@ -36,3 +36,28 @@ UserRead user = permit.api.users.create(
.withAttributes(userAttributes)
);
```

### Implementation(with roles assignment)

```java
import io.permit.sdk.openapi.models.UserCreate;
import io.permit.sdk.openapi.models.UserRead;

// optional attributes for attribute-based access control
HashMap<String, Object> userAttributes = new HashMap<>();
userAttributes.put("age", Integer.valueOf(50));
userAttributes.put("fav_color", "red");

final List<UserRoleCreate> roleAssignments = Arrays.asList(
new UserRoleCreate("editor", "default")
);

UserRead user = permit.api.users.create(
(new UserCreate("auth0|elon"))
.withEmail("elonmusk@tesla.com")
.withFirstName("Elon")
.withLastName("Musk")
.withAttributes(userAttributes)
.withRoleAssignments(roleAssignments);
);
```

0 comments on commit c1921cb

Please sign in to comment.