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.

158 lines
4.0 KiB

  1. User API
  2. ========
  3. .. http:get:: /user/(str:user_name)
  4. Find a user by name.
  5. **Example request**:
  6. .. sourcecode:: http
  7. GET /user/atheneum_administrator 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. "creationTime": "2018-07-29T11:58:17-05:00",
  18. "lastLoginTime": "2018-07-29T12:43:27-05:00",
  19. "name": "atheneum_administrator",
  20. "role": "ADMIN",
  21. "version": 0
  22. }
  23. :reqheader Accept: the response content type depends on :mailheader:`Accept` header
  24. :reqheader Authorization: The encoded basic authorization
  25. :resheader Content-Type: this depends on :mailheader:`Accept` header of request
  26. :statuscode 200: user successfully logged in
  27. :statuscode 401: authorization failed
  28. :statuscode 404: user doesn't exist
  29. .. http:patch:: /user/(str:user_name)
  30. Patch a user.
  31. **Example request**:
  32. .. sourcecode:: http
  33. PATCH /user/atheneum_administrator HTTP/1.1
  34. Host: example.tld
  35. Accept: application/json
  36. Authorization: Token <Base64(user:userToken)>
  37. Content-Type: application/json
  38. {
  39. "lastLoginTime": "2019-07-29T12:43:27-05:00",
  40. "version": 0
  41. }
  42. **Example response**:
  43. .. sourcecode:: http
  44. HTTP/1.1 200 OK
  45. Vary: Accept
  46. Content-Type: application/json
  47. {
  48. "creationTime": "2018-07-29T11:58:17-05:00",
  49. "lastLoginTime": "2019-07-29T12:43:27-05:00",
  50. "name": "atheneum_administrator",
  51. "role": "ADMIN",
  52. "version": 1
  53. }
  54. :reqheader Accept: the response content type depends on :mailheader:`Accept` header
  55. :reqheader Authorization: The encoded basic authorization
  56. :reqheader Content-Type: application/json
  57. :resheader Content-Type: this depends on :mailheader:`Accept` header of request
  58. :statuscode 200: user successfully logged in
  59. :statuscode 400: an issue in the payload was discovered
  60. :statuscode 401: authorization failed
  61. :statuscode 404: user doesn't exist
  62. .. http:post:: /user/
  63. Register a new user with the service.
  64. **Example request**:
  65. .. sourcecode:: http
  66. POST /user/ HTTP/1.1
  67. Host: example.tld
  68. Accept: application/json
  69. Authorization: Token <Base64(user:userToken)>
  70. Content-Type: application/json
  71. {
  72. "name": "test_user",
  73. "password": "JvZ9bm79",
  74. "role": "USER"
  75. }
  76. **Example response**:
  77. .. sourcecode:: http
  78. HTTP/1.1 200 OK
  79. Vary: Accept
  80. Content-Type: application/json
  81. {
  82. "creationTime": "2018-07-29T14:16:48-05:00",
  83. "name": "test_user",
  84. "role": "USER",
  85. "version": 0
  86. }
  87. :reqheader Accept: the response content type depends on :mailheader:`Accept` header
  88. :reqheader Authorization: The encoded basic authorization
  89. :reqheader Content-Type: application/json
  90. :resheader Content-Type: this depends on :mailheader:`Accept` header of request
  91. :statuscode 200: user successfully logged in
  92. :statuscode 400: an issue in the payload was discovered
  93. :statuscode 401: authorization failed
  94. .. http:delete:: /user/(str:user_name)
  95. Register a new user with the service.
  96. **Example request**:
  97. .. sourcecode:: http
  98. DELETE /user/test_user HTTP/1.1
  99. Host: example.tld
  100. Accept: application/json
  101. Authorization: Token <Base64(user:userToken)>
  102. **Example response**:
  103. .. sourcecode:: http
  104. HTTP/1.1 200 OK
  105. Vary: Accept
  106. Content-Type: application/json
  107. {
  108. "message": "Successfully Deleted",
  109. "success": true
  110. }
  111. :reqheader Accept: the response content type depends on :mailheader:`Accept` header
  112. :reqheader Authorization: The encoded basic authorization
  113. :resheader Content-Type: this depends on :mailheader:`Accept` header of request
  114. :statuscode 200: user successfully logged in
  115. :statuscode 401: authorization failed
  116. :statuscode 404: user doesn't exist