From 62d49350e5ec1a141f916d047303e6beb1086213 Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Tue, 1 Aug 2023 21:47:37 -0300 Subject: [PATCH] API Updates (#24105) * fix missing /api/v4 prefix for commands autocomplete suggestion * document /api/v4/ldap/users/{user_id}/group_sync_memberships * document /api/v4/groups/{group_id}/restore * fix /files/{file_id}/public actually at root * document /api/v4/users/invalid_emails --- api/v4/source/commands.yaml | 2 +- api/v4/source/files.yaml | 2 +- api/v4/source/groups.yaml | 37 +++++++++++++++++++++++++++++ api/v4/source/ldap.yaml | 35 ++++++++++++++++++++++++++++ api/v4/source/users.yaml | 44 +++++++++++++++++++++++++++++++++++ server/channels/api4/group.go | 2 +- 6 files changed, 119 insertions(+), 3 deletions(-) diff --git a/api/v4/source/commands.yaml b/api/v4/source/commands.yaml index 7a811cf457..5badff8cf7 100644 --- a/api/v4/source/commands.yaml +++ b/api/v4/source/commands.yaml @@ -169,7 +169,7 @@ // ListAutocompleteCommands listCommands, resp := Client.ListAutocompleteCommands() - '/teams/{team_id}/commands/autocomplete_suggestions': + '/api/v4/teams/{team_id}/commands/autocomplete_suggestions': get: tags: - commands diff --git a/api/v4/source/files.yaml b/api/v4/source/files.yaml index a3721787a8..6914e336d5 100644 --- a/api/v4/source/files.yaml +++ b/api/v4/source/files.yaml @@ -380,7 +380,7 @@ fileID := "4xp9fdt77pncbef59f4k1qe83o" info, resp := Client.GetFileInfo(fileID) - "/api/v4/files/{file_id}/public": + "/files/{file_id}/public": get: tags: - files diff --git a/api/v4/source/groups.yaml b/api/v4/source/groups.yaml index 91c8030d08..de8aea6bd9 100644 --- a/api/v4/source/groups.yaml +++ b/api/v4/source/groups.yaml @@ -275,6 +275,43 @@ $ref: "#/components/responses/Forbidden" "501": $ref: "#/components/responses/NotImplemented" + "/api/v4/groups/{group_id}/restore": + post: + tags: + - groups + summary: Restore a previously deleted group. + description: > + Restores a previously deleted custom group, allowing it to be used normally. + + May not be used with LDAP groups. + + ##### Permissions + Must have `restore_custom_group` permission for the given group. + + __Minimum server version__: 7.7 + operationId: RestoreGroup + parameters: + - name: group_id + in: path + description: Group GUID + required: true + schema: + type: string + responses: + "200": + description: Group restored successfully + content: + application/json: + schema: + $ref: "#/components/schemas/StatusOK" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "403": + $ref: "#/components/responses/Forbidden" + "501": + $ref: "#/components/responses/NotImplemented" "/api/v4/groups/{group_id}/teams/{team_id}/link": post: tags: diff --git a/api/v4/source/ldap.yaml b/api/v4/source/ldap.yaml index f61f4a9e3f..f1dce0da47 100644 --- a/api/v4/source/ldap.yaml +++ b/api/v4/source/ldap.yaml @@ -325,3 +325,38 @@ $ref: "#/components/responses/Forbidden" "501": $ref: "#/components/responses/NotImplemented" + /api/v4/ldap/users/{user_id}/group_sync_memberships: + post: + tags: + - LDAP + summary: Create memberships for LDAP configured channels and teams for this user + description: > + Add the user to each channel and team configured for each LDAP group of whicht the user is + a member. + + ##### Permissions + + Must have `sysconsole_write_user_management_groups` permission. + operationId: AddUserToGroupSyncables + parameters: + - name: user_id + in: path + description: User Id + required: true + schema: + type: string + responses: + "200": + description: Channel and team memberships created as needed. + content: + application/json: + schema: + $ref: "#/components/schemas/StatusOK" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "403": + $ref: "#/components/responses/Forbidden" + "501": + $ref: "#/components/responses/NotImplemented" diff --git a/api/v4/source/users.yaml b/api/v4/source/users.yaml index 58032ce57c..9c86431ac7 100644 --- a/api/v4/source/users.yaml +++ b/api/v4/source/users.yaml @@ -5263,3 +5263,47 @@ $ref: "#/components/responses/InternalServerError" "501": $ref: "#/components/responses/NotImplemented" + /api/v4/users/invalid_emails: + get: + tags: + - users + summary: Get users with invalid emails + description: > + Get users whose emails are considered invalid. + + It is an error to invoke this API if your team settings enable an open server. + + ##### Permissions + + Requires `sysconsole_read_user_management_users`. + + operationId: GetUsersWithInvalidEmails + parameters: + - name: page + in: query + description: The page to select. + schema: + type: integer + default: 0 + - name: per_page + in: query + description: The number of users per page. There is a maximum limit of 200 users + per page. + schema: + type: integer + default: 60 + responses: + "200": + description: User page retrieval successful + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/User" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "403": + $ref: "#/components/responses/Forbidden" diff --git a/server/channels/api4/group.go b/server/channels/api4/group.go index 621d6f1c88..8f923476fe 100644 --- a/server/channels/api4/group.go +++ b/server/channels/api4/group.go @@ -84,7 +84,7 @@ func (api *API) InitGroup() { api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}", api.APISessionRequired(deleteGroup)).Methods("DELETE") - // GET /api/v4/groups/:group_id + // POST /api/v4/groups/:group_id api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/restore", api.APISessionRequired(restoreGroup)).Methods("POST")