An ebook/comic library service and web client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

236 lines
7.0 KiB

  1. User API
  2. ========
  3. .. http:get:: /user
  4. Get a page of users.
  5. **Example request**
  6. .. sourcecode:: http
  7. GET /user HTTP/1.1
  8. Host: example.tld
  9. Accept: application/json
  10. Authorization: Token <Base64(user:userToken)>
  11. **Example response**:
  12. .. sourcecode:: http
  13. HTTP/1.1 200 OK
  14. Vary: Accept
  15. Content-Type: application/json
  16. {
  17. "page": 1,
  18. "count": 1,
  19. "totalCount": 1,
  20. "lastPage": 1,
  21. "items" :[{
  22. "creationTime": "2018-07-29T11:58:17-05:00",
  23. "lastLoginTime": "2018-07-29T12:43:27-05:00",
  24. "name": "atheneum_administrator",
  25. "role": "ADMIN",
  26. "version": 0
  27. }]
  28. }
  29. :query int page: User page to retrieve
  30. :query int perPage: Number of records to retrieve per page (max 100)
  31. :<header Accept: Response content type depends on :mailheader:`Accept` header
  32. :<header Authorization: The encoded basic authorization
  33. :>header Content-Type: Depends on :mailheader:`Accept` header of request
  34. :>json int page: Page retrieved
  35. :>json int count: Number of items returned
  36. :>json int totalCount: Total number of items available
  37. :>json int lastPage: Last page that can be requested before 404
  38. :>json int items: List of Users
  39. :statuscode 200: Successfully retrieved the user
  40. :statuscode 400: Invalid page or perPage values
  41. :statuscode 401: Authorization failed
  42. :statuscode 404: User page doesn't exist
  43. .. http:get:: /user/(str:user_name)
  44. Find a user by name.
  45. **Example request**:
  46. .. sourcecode:: http
  47. GET /user/atheneum_administrator HTTP/1.1
  48. Host: example.tld
  49. Accept: application/json
  50. Authorization: Token <Base64(user:userToken)>
  51. **Example response**:
  52. .. sourcecode:: http
  53. HTTP/1.1 200 OK
  54. Vary: Accept
  55. Content-Type: application/json
  56. {
  57. "creationTime": "2018-07-29T11:58:17-05:00",
  58. "lastLoginTime": "2018-07-29T12:43:27-05:00",
  59. "name": "atheneum_administrator",
  60. "role": "ADMIN",
  61. "version": 0
  62. }
  63. :param string user_name: Name of the user to retrieve information about
  64. :<header Accept: Response content type depends on :mailheader:`Accept` header
  65. :<header Authorization: The encoded basic authorization
  66. :>header Content-Type: Depends on :mailheader:`Accept` header of request
  67. :>json datetime creationTime: Creation time for the user
  68. :>json datetime lastLoginTime: When the user last logged in, or was last bumped
  69. :>json string name: The user name
  70. :>json string role: The role assigned to the user
  71. :>json int version: Version information
  72. :statuscode 200: Successfully retrieved the user
  73. :statuscode 401: Authorization failed
  74. :statuscode 404: User doesn't exist
  75. .. http:patch:: /user/(str:user_name)
  76. Patch a user.
  77. **Example request**:
  78. .. sourcecode:: http
  79. PATCH /user/atheneum_administrator HTTP/1.1
  80. Host: example.tld
  81. Accept: application/json
  82. Authorization: Token <Base64(user:userToken)>
  83. Content-Type: application/json
  84. {
  85. "lastLoginTime": "2019-07-29T12:43:27-05:00",
  86. "version": 0
  87. }
  88. **Example response**:
  89. .. sourcecode:: http
  90. HTTP/1.1 200 OK
  91. Vary: Accept
  92. Content-Type: application/json
  93. {
  94. "creationTime": "2018-07-29T11:58:17-05:00",
  95. "lastLoginTime": "2019-07-29T12:43:27-05:00",
  96. "name": "atheneum_administrator",
  97. "role": "ADMIN",
  98. "version": 1
  99. }
  100. :param string user_name: Name of the user to update
  101. :<header Accept: Response content type depends on :mailheader:`Accept` header
  102. :<header Authorization: Encoded token authorization
  103. :<header Content-Type: application/json
  104. :<json datetime createDateTime: Update createDateTime (Administrator Only)
  105. :<json datetime lastLoginTime: Update lastLoginTime
  106. :<json string name: Update user name (Administrator Only)
  107. :<json string role: Update user role (Must be less than or equal to the role authenticating the action)
  108. :<json int version: Must match the latest version of the user
  109. :>header Content-Type: Depends on :mailheader:`Accept` header of request
  110. :>json datetime creationTime: Creation time for the user
  111. :>json datetime lastLoginTime: When the user last logged in, or was last bumped
  112. :>json string name: The user name
  113. :>json string role: The role assigned to the user
  114. :>json int version: Version information
  115. :statuscode 200: Successfully patched the user
  116. :statuscode 400: An issue in the payload was discovered
  117. :statuscode 401: Authorization failed
  118. :statuscode 404: User doesn't exist
  119. .. http:post:: /user
  120. Register a new user with the service.
  121. **Example request**:
  122. .. sourcecode:: http
  123. POST /user HTTP/1.1
  124. Host: example.tld
  125. Accept: application/json
  126. Authorization: Token <Base64(user:userToken)>
  127. Content-Type: application/json
  128. {
  129. "name": "test_user",
  130. "password": "JvZ9bm79",
  131. "role": "USER"
  132. }
  133. **Example response**:
  134. .. sourcecode:: http
  135. HTTP/1.1 200 OK
  136. Vary: Accept
  137. Content-Type: application/json
  138. {
  139. "creationTime": "2018-07-29T14:16:48-05:00",
  140. "name": "test_user",
  141. "role": "USER",
  142. "version": 0
  143. }
  144. :<header Accept: Response content type depends on :mailheader:`Accept` header
  145. :<header Authorization: Encoded token authorization
  146. :<header Content-Type: application/json
  147. :<json string name: Name of the user
  148. :<json string password: Password to use
  149. :<json string role: Role to assign to the user (Must be less than or equal to the role of the authenticating user)
  150. :>header Content-Type: Depends on :mailheader:`Accept` header of request
  151. :>json datetime creationTime: Datetime the user was created
  152. :>json string name: Name of the created user
  153. :>json string role: Role of the created user
  154. :>json int version: Version number of the created user
  155. :statuscode 200: Successfully registered the user
  156. :statuscode 400: An issue in the payload was discovered
  157. :statuscode 401: Authorization failed
  158. .. http:delete:: /user/(str:user_name)
  159. Register a new user with the service.
  160. **Example request**:
  161. .. sourcecode:: http
  162. DELETE /user/test_user HTTP/1.1
  163. Host: example.tld
  164. Accept: application/json
  165. Authorization: Token <Base64(user:userToken)>
  166. **Example response**:
  167. .. sourcecode:: http
  168. HTTP/1.1 200 OK
  169. Vary: Accept
  170. Content-Type: application/json
  171. {
  172. "message": "Successfully Deleted",
  173. "success": true
  174. }
  175. :param string user_name: Name of the user to delete
  176. :<header Accept: Response content type depends on :mailheader:`Accept` header
  177. :<header Authorization: Encoded token authorization
  178. :>header Content-Type: Depends on :mailheader:`Accept` header of request
  179. :>json string message: Success or failure message
  180. :>json boolean success: Action status indicator
  181. :statuscode 200: Successfully deleted the user
  182. :statuscode 401: Authorization failed
  183. :statuscode 404: User doesn't exist