θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion server/endpoints/api/admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -494,7 +547,6 @@ function apiAdminEndpoints(app) {
}
}
);

app.post(
"/v1/admin/workspace-chats",
[validApiKey],
Expand Down
55 changes: 54 additions & 1 deletion server/swagger/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -2336,4 +2389,4 @@
"BearerAuth": []
}
]
}
}