mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-10 17:00:11 +01:00
1693 get workspace users api (#1694)
* Enhance API - add GET for users with access to workspace Adds GET request endpoint for retrieving a list of users with permissions to access the specified workspace * Update Swagger for users with access to workspace Adds swagger docs for the endpoint used to retrieve users with access to workspace. "v1/admin/workspaces/:workspaceId/users"
This commit is contained in:
parent
65093d99d8
commit
38441f4b21
@ -426,7 +426,60 @@ function apiAdminEndpoints(app) {
|
||||
}
|
||||
}
|
||||
);
|
||||
app.get(
|
||||
"/v1/admin/workspaces/:workspaceId/users",
|
||||
[validApiKey],
|
||||
async (request, response) => {
|
||||
/*
|
||||
#swagger.tags = ['Admin']
|
||||
#swagger.path = '/v1/admin/workspaces/{workspaceId}/users'
|
||||
#swagger.parameters['workspaceId'] = {
|
||||
in: 'path',
|
||||
description: 'id of the workspace.',
|
||||
required: true,
|
||||
type: 'string'
|
||||
}
|
||||
#swagger.description = 'Retrieve a list of users with permissions to access the specified workspace.'
|
||||
#swagger.responses[200] = {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
type: 'object',
|
||||
example: {
|
||||
users: [
|
||||
{"userId": 1, "role": "admin"},
|
||||
{"userId": 2, "role": "member"}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#swagger.responses[403] = {
|
||||
schema: {
|
||||
"$ref": "#/definitions/InvalidAPIKey"
|
||||
}
|
||||
}
|
||||
#swagger.responses[401] = {
|
||||
description: "Instance is not in Multi-User mode. Method denied",
|
||||
}
|
||||
*/
|
||||
|
||||
try {
|
||||
if (!multiUserMode(response)) {
|
||||
response.sendStatus(401).end();
|
||||
return;
|
||||
}
|
||||
|
||||
const workspaceId = request.params.workspaceId;
|
||||
const users = await Workspace.workspaceUsers(workspaceId);
|
||||
|
||||
response.status(200).json({ users });
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
response.sendStatus(500).end();
|
||||
}
|
||||
});
|
||||
app.post(
|
||||
"/v1/admin/workspaces/:workspaceId/update-users",
|
||||
[validApiKey],
|
||||
@ -494,7 +547,6 @@ function apiAdminEndpoints(app) {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
app.post(
|
||||
"/v1/admin/workspace-chats",
|
||||
[validApiKey],
|
||||
|
@ -502,6 +502,59 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/admin/workspaces/:workspaceId/users": {
|
||||
"get": {
|
||||
"tags": ["Admin"],
|
||||
"description": "Retrieve a list of users for the given workspace.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "workspaceId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "The ID of the workspace whose users are to be retrieved."
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK, successful operation. Returns a list of user IDs for the given workspace.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized, not authorized to access resources in multi-user mode.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/InvalidAPIKey"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {"type": "string"}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/admin/workspaces/{workspaceId}/update-users": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@ -2336,4 +2389,4 @@
|
||||
"BearerAuth": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user