Skip to content

Commit

Permalink
feat: topic/k1ch/ introduce API / GET/clients/{id}/permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
k1ch committed Dec 20, 2024
1 parent cd53fa6 commit 3b169f7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
21 changes: 21 additions & 0 deletions server/src/api_endpoints/clients/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@ const createPermission = async (req, res, next) => {
}
}

/**
* HTTP Request handler
* Get a list of permissions for a client
*
* @param {Object} req - The request object
* @param {Object} res - The response object to send a 200 status code and the list of permissions
* @param {Function} next - The next middleware function
* @returns {Promise<void>} - A Promise that resolves to void when permissions are retrieved
*/
const getClientPermissions = async (req, res, next) => {
try {
const { client_id: clientId } = req.params
await checkClientExists(clientId)
const permissions = await dbAdminPermission.getPermissions({ clientId })
res.status(200).send(permissions)
} catch ({ httpStatusCode = 500, message }) {
return next(createError(httpStatusCode, { message }))
}
}

module.exports = {
createPermission,
getClientPermissions,
}
33 changes: 33 additions & 0 deletions server/the-usher-openapi-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,39 @@ paths:
$ref: '#/components/responses/InternalError'
503:
$ref: '#/components/responses/ServiceUnavailableError'
get:
'x-swagger-router-controller': 'clients/permissions'
operationId: getClientPermissions
summary: Get a list of permissions for a client
tags:
- Client Admin APIs
security:
- bearerAdminAuth: []
- bearerClientAdminAuth: []
responses:
200:
description: List of permissions for a client
content:
application/json:
schema:
type: array
items:
allOf:
- $ref: '#/components/schemas/PermissionObject'
- type: object
properties:
client_id:
type: string
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/InternalError'
503:
$ref: '#/components/responses/ServiceUnavailableError'

/sessions:
delete:
Expand Down

0 comments on commit 3b169f7

Please sign in to comment.