Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8fff208

Browse files
committed
feat: add 'groups' namespace
1 parent606c518 commit8fff208

File tree

29 files changed

+880
-14
lines changed

29 files changed

+880
-14
lines changed

‎pom.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
<artifactId>maven-surefire-plugin</artifactId>
240240
<version>2.22.2</version>
241241
<configuration>
242+
<trimStackTrace>false</trimStackTrace>
242243
<argLine>
243244
<!--
244245
Gson (used for JSON serialization) utilizes reflection and needs to be able to access private fields of

‎src/main/java/io/weaviate/client/WeaviateClient.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
importio.weaviate.client.v1.contextionary.Contextionary;
1919
importio.weaviate.client.v1.data.Data;
2020
importio.weaviate.client.v1.graphql.GraphQL;
21+
importio.weaviate.client.v1.groups.Groups;
2122
importio.weaviate.client.v1.grpc.GRPC;
2223
importio.weaviate.client.v1.misc.Misc;
2324
importio.weaviate.client.v1.misc.api.MetaGetter;
@@ -112,6 +113,10 @@ public Users users() {
112113
returnnewUsers(httpClient,config);
113114
}
114115

116+
publicGroupsgroups() {
117+
returnnewGroups(httpClient,config);
118+
}
119+
115120
publicAliasesalias() {
116121
returnnewAliases(httpClient,config);
117122
}

‎src/main/java/io/weaviate/client/base/Result.java‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,14 @@ public Result<R> parse(HttpResponse response, String body, ContentType contentTy
134134
* }</pre>
135135
*/
136136
publicstatic <T>Result<List<T>>toList(Response<T[]>response) {
137-
returnnewResult<>(response,Arrays.asList(response.getBody()));
137+
returntoList(response,Function.identity());
138+
}
139+
140+
publicstatic <T,R>Result<List<R>>toList(Response<T[]>response,Function<?superT, ?extendsR>mapper) {
141+
List<R>mapped =Optional.ofNullable(response.getBody())
142+
.map(Arrays::asList).orElse(newArrayList<>())
143+
.stream().map(mapper).collect(Collectors.toList());
144+
returnnewResult<>(response,mapped);
138145
}
139146

140147
/**
@@ -243,10 +250,10 @@ public static <T, R> ResponseParser<List<R>> arrayToListParser(Class<T[]> cls,
243250
@Override
244251
publicResult<List<R>>parse(HttpResponseresponse,Stringbody,ContentTypecontentType) {
245252
Response<T[]>resp =this.serializer.toResponse(response.getCode(),body,cls);
246-
List<R>roles =Optional.ofNullable(resp.getBody())
253+
List<R>mapped =Optional.ofNullable(resp.getBody())
247254
.map(Arrays::asList).orElse(newArrayList<>())
248255
.stream().map(mapper).collect(Collectors.toList());
249-
returnnewResult<>(resp.getStatusCode(),roles,resp.getErrors());
256+
returnnewResult<>(resp.getStatusCode(),mapped,resp.getErrors());
250257
}
251258
};
252259
}

‎src/main/java/io/weaviate/client/v1/async/WeaviateAsyncClient.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
importio.weaviate.client.v1.async.cluster.Cluster;
2020
importio.weaviate.client.v1.async.data.Data;
2121
importio.weaviate.client.v1.async.graphql.GraphQL;
22+
importio.weaviate.client.v1.async.groups.Groups;
2223
importio.weaviate.client.v1.async.misc.Misc;
2324
importio.weaviate.client.v1.async.rbac.Roles;
2425
importio.weaviate.client.v1.async.schema.Schema;
@@ -85,6 +86,10 @@ public Users users() {
8586
returnnewUsers(client,config,tokenProvider);
8687
}
8788

89+
publicGroupsgroups() {
90+
returnnewGroups(client,config,tokenProvider);
91+
}
92+
8893
publicAliasesalias() {
8994
returnnewAliases(client,config,tokenProvider);
9095
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
packageio.weaviate.client.v1.async.groups;
2+
3+
importorg.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
4+
5+
importio.weaviate.client.Config;
6+
importio.weaviate.client.v1.auth.provider.AccessTokenProvider;
7+
importlombok.RequiredArgsConstructor;
8+
9+
@RequiredArgsConstructor
10+
publicclassGroups {
11+
privatefinalCloseableHttpAsyncClientclient;
12+
privatefinalConfigconfig;
13+
privatefinalAccessTokenProvidertokenProvider;
14+
15+
publicOidcGroupsoidc() {
16+
returnnewOidcGroups(client,config,tokenProvider);
17+
}
18+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
packageio.weaviate.client.v1.async.groups;
2+
3+
importorg.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
4+
5+
importio.weaviate.client.Config;
6+
importio.weaviate.client.v1.async.groups.api.oidc.AssignedRolesGetter;
7+
importio.weaviate.client.v1.async.groups.api.oidc.KnownGroupNamesGetter;
8+
importio.weaviate.client.v1.async.groups.api.oidc.RoleAssigner;
9+
importio.weaviate.client.v1.async.groups.api.oidc.RoleRevoker;
10+
importio.weaviate.client.v1.auth.provider.AccessTokenProvider;
11+
importlombok.RequiredArgsConstructor;
12+
13+
@RequiredArgsConstructor
14+
publicclassOidcGroups {
15+
privatefinalCloseableHttpAsyncClientclient;
16+
privatefinalConfigconfig;
17+
privatefinalAccessTokenProvidertokenProvider;
18+
19+
publicRoleAssignerroleAssigner() {
20+
returnnewRoleAssigner(client,config,tokenProvider);
21+
}
22+
23+
publicRoleRevokerroleRevoker() {
24+
returnnewRoleRevoker(client,config,tokenProvider);
25+
}
26+
27+
publicAssignedRolesGetterassignedRolesGetter() {
28+
returnnewAssignedRolesGetter(client,config,tokenProvider);
29+
}
30+
31+
publicKnownGroupNamesGetterknownGroupNamesGetter() {
32+
returnnewKnownGroupNamesGetter(client,config,tokenProvider);
33+
}
34+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
packageio.weaviate.client.v1.async.groups.api.oidc;
2+
3+
importjava.util.List;
4+
importjava.util.concurrent.Future;
5+
6+
importorg.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
7+
importorg.apache.hc.core5.concurrent.FutureCallback;
8+
9+
importio.weaviate.client.Config;
10+
importio.weaviate.client.base.AsyncBaseClient;
11+
importio.weaviate.client.base.AsyncClientResult;
12+
importio.weaviate.client.base.Result;
13+
importio.weaviate.client.base.util.UrlEncoder;
14+
importio.weaviate.client.v1.auth.provider.AccessTokenProvider;
15+
importio.weaviate.client.v1.rbac.api.WeaviateRole;
16+
importio.weaviate.client.v1.rbac.model.Role;
17+
18+
publicclassAssignedRolesGetterextendsAsyncBaseClient<List<Role>>implementsAsyncClientResult<List<Role>> {
19+
privateStringgroupId;
20+
privatebooleanincludePermissions =false;
21+
22+
publicAssignedRolesGetter(CloseableHttpAsyncClienthttpClient,Configconfig,AccessTokenProvidertokenProvider) {
23+
super(httpClient,config,tokenProvider);
24+
}
25+
26+
publicAssignedRolesGetterwithGroupId(Stringid) {
27+
this.groupId =id;
28+
returnthis;
29+
}
30+
31+
publicAssignedRolesGetterincludePermissions(booleaninclude) {
32+
this.includePermissions =include;
33+
returnthis;
34+
}
35+
36+
privateString_groupId() {
37+
returnUrlEncoder.encode(this.groupId);
38+
}
39+
40+
@Override
41+
publicFuture<Result<List<Role>>>run(FutureCallback<Result<List<Role>>>callback) {
42+
returnsendGetRequest(path(),callback,Result.arrayToListParser(WeaviateRole[].class,WeaviateRole::toRole));
43+
}
44+
45+
privateStringpath() {
46+
returnString.format("/authz/groups/%s/roles/oidc?includeFullRoles=%s",_groupId(),includePermissions);
47+
}
48+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
packageio.weaviate.client.v1.async.groups.api.oidc;
2+
3+
importjava.util.List;
4+
importjava.util.concurrent.Future;
5+
6+
importorg.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
7+
importorg.apache.hc.core5.concurrent.FutureCallback;
8+
9+
importio.weaviate.client.Config;
10+
importio.weaviate.client.base.AsyncBaseClient;
11+
importio.weaviate.client.base.AsyncClientResult;
12+
importio.weaviate.client.base.Result;
13+
importio.weaviate.client.v1.aliases.model.Alias;
14+
importio.weaviate.client.v1.auth.provider.AccessTokenProvider;
15+
16+
publicclassKnownGroupNamesGetterextendsAsyncBaseClient<List<String>>implementsAsyncClientResult<List<String>> {
17+
18+
publicKnownGroupNamesGetter(CloseableHttpAsyncClienthttpClient,Configconfig,AccessTokenProvidertokenProvider) {
19+
super(httpClient,config,tokenProvider);
20+
}
21+
22+
staticclassResponseBody {
23+
List<Alias>aliases;
24+
}
25+
26+
@Override
27+
publicFuture<Result<List<String>>>run(FutureCallback<Result<List<String>>>callback) {
28+
returnsendGetRequest("/authz/groups/oidc",callback,Result.arrayToListParser(String[].class));
29+
}
30+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
packageio.weaviate.client.v1.async.groups.api.oidc;
2+
3+
importjava.util.ArrayList;
4+
importjava.util.Arrays;
5+
importjava.util.List;
6+
importjava.util.concurrent.Future;
7+
8+
importorg.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
9+
importorg.apache.hc.core5.concurrent.FutureCallback;
10+
11+
importcom.google.gson.annotations.SerializedName;
12+
13+
importio.weaviate.client.Config;
14+
importio.weaviate.client.base.AsyncBaseClient;
15+
importio.weaviate.client.base.AsyncClientResult;
16+
importio.weaviate.client.base.Result;
17+
importio.weaviate.client.base.util.UrlEncoder;
18+
importio.weaviate.client.v1.auth.provider.AccessTokenProvider;
19+
importlombok.AllArgsConstructor;
20+
21+
publicclassRoleAssignerextendsAsyncBaseClient<Boolean>implementsAsyncClientResult<Boolean> {
22+
privateStringgroupId;
23+
privateList<String>roles =newArrayList<>();
24+
25+
publicRoleAssigner(CloseableHttpAsyncClienthttpClient,Configconfig,AccessTokenProvidertokenProvider) {
26+
super(httpClient,config,tokenProvider);
27+
}
28+
29+
publicRoleAssignerwithGroupId(Stringid) {
30+
this.groupId =id;
31+
returnthis;
32+
}
33+
34+
publicRoleAssignerwitRoles(String...roles) {
35+
this.roles =Arrays.asList(roles);
36+
returnthis;
37+
}
38+
39+
privateString_groupId() {
40+
returnUrlEncoder.encode(this.groupId);
41+
}
42+
43+
/** The API signature for this method is { "roles": [...] } */
44+
@AllArgsConstructor
45+
privateclassBody {
46+
@SerializedName("roles")
47+
finalList<String>roles;
48+
@SerializedName("groupType")
49+
finalStringgroupType ="oidc";
50+
}
51+
52+
@Override
53+
publicFuture<Result<Boolean>>run(FutureCallback<Result<Boolean>>callback) {
54+
returnsendPostRequest(path(),newBody(this.roles),callback,
55+
Result.voidToBooleanParser());
56+
}
57+
58+
privateStringpath() {
59+
returnString.format("/authz/groups/%s/assign",_groupId());
60+
}
61+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
packageio.weaviate.client.v1.async.groups.api.oidc;
2+
3+
importjava.util.ArrayList;
4+
importjava.util.Arrays;
5+
importjava.util.List;
6+
importjava.util.concurrent.Future;
7+
8+
importorg.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
9+
importorg.apache.hc.core5.concurrent.FutureCallback;
10+
11+
importcom.google.gson.annotations.SerializedName;
12+
13+
importio.weaviate.client.Config;
14+
importio.weaviate.client.base.AsyncBaseClient;
15+
importio.weaviate.client.base.AsyncClientResult;
16+
importio.weaviate.client.base.Result;
17+
importio.weaviate.client.base.util.UrlEncoder;
18+
importio.weaviate.client.v1.auth.provider.AccessTokenProvider;
19+
importlombok.AllArgsConstructor;
20+
21+
publicclassRoleRevokerextendsAsyncBaseClient<Boolean>implementsAsyncClientResult<Boolean> {
22+
privateStringgroupId;
23+
privateList<String>roles =newArrayList<>();
24+
25+
publicRoleRevoker(CloseableHttpAsyncClienthttpClient,Configconfig,AccessTokenProvidertokenProvider) {
26+
super(httpClient,config,tokenProvider);
27+
}
28+
29+
publicRoleRevokerwithGroupId(Stringid) {
30+
this.groupId =id;
31+
returnthis;
32+
}
33+
34+
publicRoleRevokerwitRoles(String...roles) {
35+
this.roles =Arrays.asList(roles);
36+
returnthis;
37+
}
38+
39+
privateString_groupId() {
40+
returnUrlEncoder.encode(this.groupId);
41+
}
42+
43+
/** The API signature for this method is { "roles": [...] } */
44+
@AllArgsConstructor
45+
privateclassBody {
46+
@SerializedName("roles")
47+
finalList<String>roles;
48+
@SerializedName("groupType")
49+
finalStringgroupType ="oidc";
50+
}
51+
52+
@Override
53+
publicFuture<Result<Boolean>>run(FutureCallback<Result<Boolean>>callback) {
54+
returnsendPostRequest(path(),newBody(this.roles),callback,
55+
Result.voidToBooleanParser());
56+
}
57+
58+
privateStringpath() {
59+
returnString.format("/authz/groups/%s/revoke",_groupId());
60+
}
61+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp