@@ -55,26 +55,74 @@ export interface Users extends UsersBase {
55
55
/** Operations supported for namespaced 'db' users.*/
56
56
export interface DBUsers extends UsersBase {
57
57
/**
58
- * Retrieve the roles assigned to a user.
58
+ * Retrieve the roles assigned to a 'db_user' user.
59
59
*
60
60
* @param {string } userId The ID of the user to retrieve the assigned roles for.
61
61
* @returns {Promise<Record<string, Role>> } A map of role names to their respective roles.
62
62
*/
63
63
getAssignedRoles : ( userId : string , opts ?: GetAssignedRolesOptions ) => Promise < Record < string , Role > > ;
64
64
65
+ /** Create a new 'db_user' user.
66
+ *
67
+ * @param {string } userId The ID of the user to create. Must consist of valid URL characters only.
68
+ * @returns {Promise<string> } API key for the newly created user.
69
+ */
65
70
create : ( userId : string ) => Promise < string > ;
71
+
72
+ /**
73
+ * Delete a 'db_user' user. It is not possible to delete 'db_env_user' users programmatically.
74
+ *
75
+ * @param {string } userId The ID of the user to delete.
76
+ * @returns {Promise<boolean> } `true` if the user has been successfully deleted.
77
+ */
66
78
delete : ( userId : string ) => Promise < boolean > ;
79
+
80
+ /**
81
+ * Rotate the API key of a 'db_user' user. The old API key becomes invalid.
82
+ * API keys of 'db_env_user' users are defined in the server's environment
83
+ * and cannot be modified programmatically.
84
+ *
85
+ * @param {string } userId The ID of the user to create a new API key for.
86
+ * @returns {Promise<string> } New API key for the user.
87
+ */
67
88
rotateKey : ( userId : string ) => Promise < string > ;
89
+
90
+ /**
91
+ * Activate 'db_user' user.
92
+ *
93
+ * @param {string } userId The ID of the user to activate.
94
+ * @returns {Promise<boolean> } `true` if the user has been successfully activated.
95
+ */
68
96
activate : ( userId : string ) => Promise < boolean > ;
97
+
98
+ /**
99
+ * Deactivate 'db_user' user.
100
+ *
101
+ * @param {string } userId The ID of the user to deactivate.
102
+ * @returns {Promise<boolean> } `true` if the user has been successfully deactivated.
103
+ */
69
104
deactivate : ( userId : string ) => Promise < boolean > ;
105
+
106
+ /**
107
+ * Retrieve information about the 'db_user' / 'db_env_user' user.
108
+ *
109
+ * @param {string } userId The ID of the user to get.
110
+ * @returns {Promise<UserDB> } ID, status, and assigned roles of a 'db_*' user.
111
+ */
70
112
byName : ( userId : string ) => Promise < UserDB > ;
113
+
114
+ /**
115
+ * List all 'db_user' / 'db_env_user' users.
116
+ *
117
+ * @returns {Promise<UserDB[]> } ID, status, and assigned roles for each 'db_*' user.
118
+ */
71
119
listAll : ( ) => Promise < UserDB [ ] > ;
72
120
}
73
121
74
122
/** Operations supported for namespaced 'oidc' users.*/
75
123
export interface OIDCUsers extends UsersBase {
76
124
/**
77
- * Retrieve the roles assigned to a user.
125
+ * Retrieve the roles assigned to an 'oidc' user.
78
126
*
79
127
* @param {string } userId The ID of the user to retrieve the assigned roles for.
80
128
* @returns {Promise<Record<string, Role>> } A map of role names to their respective roles.
@@ -167,6 +215,7 @@ interface NamespacedUsers {
167
215
revokeRoles : ( roleNames : string | string [ ] , userId : string , opts ?: AssignRevokeOptions ) => Promise < void > ;
168
216
}
169
217
218
+ /** Implementation of the operations common to 'db', 'oidc', and legacy users. */
170
219
const baseUsers = ( connection : ConnectionREST ) : UsersBase => {
171
220
const ns = namespacedUsers ( connection ) ;
172
221
return {
@@ -175,13 +224,13 @@ const baseUsers = (connection: ConnectionREST): UsersBase => {
175
224
} ;
176
225
} ;
177
226
227
+ /** Implementation of the operations common to 'db' and 'oidc' users. */
178
228
const namespacedUsers = ( connection : ConnectionREST ) : NamespacedUsers => {
179
229
return {
180
230
getAssignedRoles : ( userType : UserTypeInternal , userId : string , opts ?: GetAssignedRolesOptions ) =>
181
231
connection
182
232
. get < WeaviateRole [ ] > (
183
- `/authz/users/${ userId } /roles/${ userType } ${
184
- opts ?. includePermissions ? '?&includeFullRoles=true' : ''
233
+ `/authz/users/${ userId } /roles/${ userType } ${ opts ?. includePermissions ? '?&includeFullRoles=true' : ''
185
234
} `
186
235
)
187
236
. then ( Map . roles ) ,
0 commit comments