|
22 | 22 |
|
23 | 23 | import io.weaviate.client6.v1.api.rbac.NodesPermission.Verbosity; |
24 | 24 | import io.weaviate.client6.v1.api.rbac.RolesPermission.Scope; |
| 25 | +import io.weaviate.client6.v1.api.rbac.groups.GroupType; |
25 | 26 | import io.weaviate.client6.v1.internal.json.JsonEnum; |
26 | 27 |
|
27 | 28 | public interface Permission { |
@@ -106,7 +107,7 @@ public static DataPermission data(String collection, DataPermission.Action... ac |
106 | 107 | /** |
107 | 108 | * Create permissions for managing RBAC groups. |
108 | 109 | */ |
109 | | - public static GroupsPermission groups(String groupId, String groupType, GroupsPermission.Action... actions) { |
| 110 | + public static GroupsPermission groups(String groupId, GroupType groupType, GroupsPermission.Action... actions) { |
110 | 111 | checkDeprecation(actions); |
111 | 112 | return new GroupsPermission(groupId, groupType, actions); |
112 | 113 | } |
@@ -147,9 +148,9 @@ public static TenantsPermission tenants(String collection, String tenant, Tenant |
147 | 148 | /** |
148 | 149 | * Create {@link UsersPermission}. |
149 | 150 | */ |
150 | | - public static UsersPermission users(String user, UsersPermission.Action... actions) { |
| 151 | + public static UsersPermission users(String userId, UsersPermission.Action... actions) { |
151 | 152 | checkDeprecation(actions); |
152 | | - return new UsersPermission(user, actions); |
| 153 | + return new UsersPermission(userId, actions); |
153 | 154 | } |
154 | 155 |
|
155 | 156 | /** |
@@ -243,24 +244,24 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { |
243 | 244 |
|
244 | 245 | @Override |
245 | 246 | public void write(JsonWriter out, Permission value) throws IOException { |
246 | | - out.beginObject(); |
247 | | - |
248 | | - if (!value.actions().isEmpty()) { |
249 | | - // User might not have provided any actions by mistake |
250 | | - var action = (RbacAction<?>) value.actions().get(0); |
| 247 | + for (RbacAction<?> action : value.actions()) { |
| 248 | + out.beginObject(); |
| 249 | + // User might not have provided many actions by mistake |
251 | 250 | out.name("action"); |
252 | 251 | out.value(action.jsonValue()); |
253 | | - } |
254 | 252 |
|
255 | | - if (value.self() != null) { |
256 | | - var permission = writeAdapter.toJsonTree((T) value.self()); |
257 | | - // Some permission types do not have a body |
258 | | - permission.getAsJsonObject().remove("actions"); |
259 | | - out.name(value._kind().jsonValue()); |
260 | | - Streams.write(permission, out); |
261 | | - } |
| 253 | + if (value.self() != null) { |
| 254 | + var permission = writeAdapter.toJsonTree((T) value.self()); |
| 255 | + permission.getAsJsonObject().remove("actions"); |
262 | 256 |
|
263 | | - out.endObject(); |
| 257 | + // Some permission types do not have a body |
| 258 | + if (!permission.getAsJsonObject().keySet().isEmpty()) { |
| 259 | + out.name(value._kind().jsonValue()); |
| 260 | + Streams.write(permission, out); |
| 261 | + } |
| 262 | + } |
| 263 | + out.endObject(); |
| 264 | + } |
264 | 265 | } |
265 | 266 |
|
266 | 267 | @Override |
|
0 commit comments