-
Notifications
You must be signed in to change notification settings - Fork 27
feat: add 'groups' namespace #456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8fff208
feat: add 'groups' namespace
bevzzz 217ea8a
test: relax error message checks
bevzzz 57aa3ca
feat add GroupsPermission
bevzzz 6822255
test: delete server-related assertion
bevzzz 57169d6
test: fix typo
bevzzz bc4676d
ci: disable breaking Explore test
bevzzz 9f44e94
chore: rename _groupId() -> encodeGroupId()
bevzzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
18 changes: 18 additions & 0 deletions
18
src/main/java/io/weaviate/client/v1/async/groups/Groups.java
This file contains hidden or 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,18 @@ | ||
| package io.weaviate.client.v1.async.groups; | ||
|
|
||
| import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient; | ||
|
|
||
| import io.weaviate.client.Config; | ||
| import io.weaviate.client.v1.auth.provider.AccessTokenProvider; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @RequiredArgsConstructor | ||
| public class Groups { | ||
| private final CloseableHttpAsyncClient client; | ||
| private final Config config; | ||
| private final AccessTokenProvider tokenProvider; | ||
|
|
||
| public OidcGroups oidc() { | ||
| return new OidcGroups(client, config, tokenProvider); | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/main/java/io/weaviate/client/v1/async/groups/OidcGroups.java
This file contains hidden or 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,34 @@ | ||
| package io.weaviate.client.v1.async.groups; | ||
|
|
||
| import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient; | ||
|
|
||
| import io.weaviate.client.Config; | ||
| import io.weaviate.client.v1.async.groups.api.oidc.AssignedRolesGetter; | ||
| import io.weaviate.client.v1.async.groups.api.oidc.KnownGroupNamesGetter; | ||
| import io.weaviate.client.v1.async.groups.api.oidc.RoleAssigner; | ||
| import io.weaviate.client.v1.async.groups.api.oidc.RoleRevoker; | ||
| import io.weaviate.client.v1.auth.provider.AccessTokenProvider; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @RequiredArgsConstructor | ||
| public class OidcGroups { | ||
| private final CloseableHttpAsyncClient client; | ||
| private final Config config; | ||
| private final AccessTokenProvider tokenProvider; | ||
|
|
||
| public RoleAssigner roleAssigner() { | ||
| return new RoleAssigner(client, config, tokenProvider); | ||
| } | ||
|
|
||
| public RoleRevoker roleRevoker() { | ||
| return new RoleRevoker(client, config, tokenProvider); | ||
| } | ||
|
|
||
| public AssignedRolesGetter assignedRolesGetter() { | ||
| return new AssignedRolesGetter(client, config, tokenProvider); | ||
| } | ||
|
|
||
| public KnownGroupNamesGetter knownGroupNamesGetter() { | ||
| return new KnownGroupNamesGetter(client, config, tokenProvider); | ||
| } | ||
| } |
48 changes: 48 additions & 0 deletions
48
src/main/java/io/weaviate/client/v1/async/groups/api/oidc/AssignedRolesGetter.java
This file contains hidden or 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,48 @@ | ||
| package io.weaviate.client.v1.async.groups.api.oidc; | ||
|
|
||
| import java.util.List; | ||
| import java.util.concurrent.Future; | ||
|
|
||
| import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient; | ||
| import org.apache.hc.core5.concurrent.FutureCallback; | ||
|
|
||
| import io.weaviate.client.Config; | ||
| import io.weaviate.client.base.AsyncBaseClient; | ||
| import io.weaviate.client.base.AsyncClientResult; | ||
| import io.weaviate.client.base.Result; | ||
| import io.weaviate.client.base.util.UrlEncoder; | ||
| import io.weaviate.client.v1.auth.provider.AccessTokenProvider; | ||
| import io.weaviate.client.v1.rbac.api.WeaviateRole; | ||
| import io.weaviate.client.v1.rbac.model.Role; | ||
|
|
||
| public class AssignedRolesGetter extends AsyncBaseClient<List<Role>> implements AsyncClientResult<List<Role>> { | ||
| private String groupId; | ||
| private boolean includePermissions = false; | ||
|
|
||
| public AssignedRolesGetter(CloseableHttpAsyncClient httpClient, Config config, AccessTokenProvider tokenProvider) { | ||
| super(httpClient, config, tokenProvider); | ||
| } | ||
|
|
||
| public AssignedRolesGetter withGroupId(String id) { | ||
| this.groupId = id; | ||
| return this; | ||
| } | ||
|
|
||
| public AssignedRolesGetter includePermissions(boolean include) { | ||
| this.includePermissions = include; | ||
| return this; | ||
| } | ||
|
|
||
| private String _groupId() { | ||
| return UrlEncoder.encode(this.groupId); | ||
| } | ||
|
|
||
| @Override | ||
| public Future<Result<List<Role>>> run(FutureCallback<Result<List<Role>>> callback) { | ||
| return sendGetRequest(path(), callback, Result.arrayToListParser(WeaviateRole[].class, WeaviateRole::toRole)); | ||
| } | ||
|
|
||
| private String path() { | ||
| return String.format("/authz/groups/%s/roles/oidc?includeFullRoles=%s", _groupId(), includePermissions); | ||
| } | ||
| } | ||
30 changes: 30 additions & 0 deletions
30
src/main/java/io/weaviate/client/v1/async/groups/api/oidc/KnownGroupNamesGetter.java
This file contains hidden or 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,30 @@ | ||
| package io.weaviate.client.v1.async.groups.api.oidc; | ||
|
|
||
| import java.util.List; | ||
| import java.util.concurrent.Future; | ||
|
|
||
| import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient; | ||
| import org.apache.hc.core5.concurrent.FutureCallback; | ||
|
|
||
| import io.weaviate.client.Config; | ||
| import io.weaviate.client.base.AsyncBaseClient; | ||
| import io.weaviate.client.base.AsyncClientResult; | ||
| import io.weaviate.client.base.Result; | ||
| import io.weaviate.client.v1.aliases.model.Alias; | ||
| import io.weaviate.client.v1.auth.provider.AccessTokenProvider; | ||
|
|
||
| public class KnownGroupNamesGetter extends AsyncBaseClient<List<String>> implements AsyncClientResult<List<String>> { | ||
|
|
||
| public KnownGroupNamesGetter(CloseableHttpAsyncClient httpClient, Config config, AccessTokenProvider tokenProvider) { | ||
| super(httpClient, config, tokenProvider); | ||
| } | ||
|
|
||
| static class ResponseBody { | ||
| List<Alias> aliases; | ||
| } | ||
|
|
||
| @Override | ||
| public Future<Result<List<String>>> run(FutureCallback<Result<List<String>>> callback) { | ||
| return sendGetRequest("/authz/groups/oidc", callback, Result.arrayToListParser(String[].class)); | ||
| } | ||
| } |
61 changes: 61 additions & 0 deletions
61
src/main/java/io/weaviate/client/v1/async/groups/api/oidc/RoleAssigner.java
This file contains hidden or 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,61 @@ | ||
| package io.weaviate.client.v1.async.groups.api.oidc; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.concurrent.Future; | ||
|
|
||
| import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient; | ||
| import org.apache.hc.core5.concurrent.FutureCallback; | ||
|
|
||
| import com.google.gson.annotations.SerializedName; | ||
|
|
||
| import io.weaviate.client.Config; | ||
| import io.weaviate.client.base.AsyncBaseClient; | ||
| import io.weaviate.client.base.AsyncClientResult; | ||
| import io.weaviate.client.base.Result; | ||
| import io.weaviate.client.base.util.UrlEncoder; | ||
| import io.weaviate.client.v1.auth.provider.AccessTokenProvider; | ||
| import lombok.AllArgsConstructor; | ||
|
|
||
| public class RoleAssigner extends AsyncBaseClient<Boolean> implements AsyncClientResult<Boolean> { | ||
| private String groupId; | ||
| private List<String> roles = new ArrayList<>(); | ||
|
|
||
| public RoleAssigner(CloseableHttpAsyncClient httpClient, Config config, AccessTokenProvider tokenProvider) { | ||
| super(httpClient, config, tokenProvider); | ||
| } | ||
|
|
||
| public RoleAssigner withGroupId(String id) { | ||
| this.groupId = id; | ||
| return this; | ||
| } | ||
|
|
||
| public RoleAssigner witRoles(String... roles) { | ||
| this.roles = Arrays.asList(roles); | ||
| return this; | ||
| } | ||
|
|
||
| private String _groupId() { | ||
| return UrlEncoder.encode(this.groupId); | ||
| } | ||
|
|
||
| /** The API signature for this method is { "roles": [...] } */ | ||
| @AllArgsConstructor | ||
| private class Body { | ||
| @SerializedName("roles") | ||
| final List<String> roles; | ||
| @SerializedName("groupType") | ||
| final String groupType = "oidc"; | ||
| } | ||
|
|
||
| @Override | ||
| public Future<Result<Boolean>> run(FutureCallback<Result<Boolean>> callback) { | ||
| return sendPostRequest(path(), new Body(this.roles), callback, | ||
| Result.voidToBooleanParser()); | ||
| } | ||
|
|
||
| private String path() { | ||
| return String.format("/authz/groups/%s/assign", _groupId()); | ||
| } | ||
| } |
61 changes: 61 additions & 0 deletions
61
src/main/java/io/weaviate/client/v1/async/groups/api/oidc/RoleRevoker.java
This file contains hidden or 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,61 @@ | ||
| package io.weaviate.client.v1.async.groups.api.oidc; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.concurrent.Future; | ||
|
|
||
| import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient; | ||
| import org.apache.hc.core5.concurrent.FutureCallback; | ||
|
|
||
| import com.google.gson.annotations.SerializedName; | ||
|
|
||
| import io.weaviate.client.Config; | ||
| import io.weaviate.client.base.AsyncBaseClient; | ||
| import io.weaviate.client.base.AsyncClientResult; | ||
| import io.weaviate.client.base.Result; | ||
| import io.weaviate.client.base.util.UrlEncoder; | ||
| import io.weaviate.client.v1.auth.provider.AccessTokenProvider; | ||
| import lombok.AllArgsConstructor; | ||
|
|
||
| public class RoleRevoker extends AsyncBaseClient<Boolean> implements AsyncClientResult<Boolean> { | ||
| private String groupId; | ||
| private List<String> roles = new ArrayList<>(); | ||
|
|
||
| public RoleRevoker(CloseableHttpAsyncClient httpClient, Config config, AccessTokenProvider tokenProvider) { | ||
| super(httpClient, config, tokenProvider); | ||
| } | ||
|
|
||
| public RoleRevoker withGroupId(String id) { | ||
| this.groupId = id; | ||
| return this; | ||
| } | ||
|
|
||
| public RoleRevoker witRoles(String... roles) { | ||
| this.roles = Arrays.asList(roles); | ||
| return this; | ||
| } | ||
|
|
||
| private String _groupId() { | ||
| return UrlEncoder.encode(this.groupId); | ||
| } | ||
|
|
||
| /** The API signature for this method is { "roles": [...] } */ | ||
| @AllArgsConstructor | ||
| private class Body { | ||
| @SerializedName("roles") | ||
| final List<String> roles; | ||
| @SerializedName("groupType") | ||
| final String groupType = "oidc"; | ||
| } | ||
|
|
||
| @Override | ||
| public Future<Result<Boolean>> run(FutureCallback<Result<Boolean>> callback) { | ||
| return sendPostRequest(path(), new Body(this.roles), callback, | ||
| Result.voidToBooleanParser()); | ||
| } | ||
|
|
||
| private String path() { | ||
| return String.format("/authz/groups/%s/revoke", _groupId()); | ||
| } | ||
| } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change the name just
getGroupIdorgroupIdhaving an_in method naming feels like Python / Rust codeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed in all files