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.

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