Class AdminEndpoint

java.lang.Object
io.levysworks.endpoints.AdminEndpoint

@Path("/api/v1/secured") public class AdminEndpoint extends Object
Endpoint reserved for admin actions
  • Constructor Details

    • AdminEndpoint

      public AdminEndpoint()
  • Method Details

    • handleRequestAction

      @PATCH @Path("/requests/{id}") @Consumes("application/json") public jakarta.ws.rs.core.Response handleRequestAction(@PathParam("id") Integer id, ActionRequest body) throws SQLException, NoSuchAlgorithmException
      Handles PATCH request

      Approves or declines a user request based on what the request body contains

      Parameters:
      id - ID of the request to work on
      body - The body containing the action
      Returns:
      a Response with 204 No Content if successful, or an appropriate error code
      Throws:
      SQLException - if a database access error occurs
      NoSuchAlgorithmException - in case the DatabaseManager.addActiveKey(java.lang.String, java.lang.String, java.lang.String) fails to fingerprint the public key
    • handleRemoveRequest

      @DELETE @Path("/remove/{uid}") public jakarta.ws.rs.core.Response handleRemoveRequest(@PathParam("uid") String uid, @QueryParam("agent") String agent) throws SQLException, TimeoutException
      Handles DELETE request

      Revokes the key with matching uid from the matching agent

      Parameters:
      uid - The UID of the key
      agent - Name of the agent
      Returns:
      a Response with 204 No Content if successful, or an appropriate error code
      Throws:
      SQLException - if a database access error occurs
      TimeoutException - if the RabbitMQ request times out
    • handleUserAction

      @PATCH @Path("/users/{uuid}") @Consumes("application/json") public jakarta.ws.rs.core.Response handleUserAction(@PathParam("uuid") String uuid, UserRequest body) throws SQLException
      Handles PATCH request

      Updates the user identified by uuid with data from the UserRequest

      Parameters:
      uuid - The UUID of the updatable user
      body - A UserRequest object containing the information to update the user to
      Returns:
      a Response with 204 No Content if successful, or an appropriate error code
      Throws:
      SQLException - if a database access error occurs
    • handleCreateUserAction

      @POST @Path("/users/create") @Consumes("application/json") public jakarta.ws.rs.core.Response handleCreateUserAction(UserRequest body) throws SQLException
      Handles POST request

      Creates a new user with data from the UserRequest

      Parameters:
      body - A UserRequest object containing the information to create the user from
      Returns:
      a Response with 204 No Content if successful, or an appropriate error code
      Throws:
      SQLException - if a database access error occurs
    • handleRemoveUserAction

      @DELETE @Path("/users/delete") @Consumes("application/json") public jakarta.ws.rs.core.Response handleRemoveUserAction(@QueryParam("uuid") String uuid) throws SQLException
      Handles DELETE request

      Deletes the user with a matching uuid

      Parameters:
      uuid - UUID of the user to delete
      Returns:
      a Response with 204 No Content if successful, or an appropriate error code
      Throws:
      SQLException - if a database access error occurs