project_import.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. 'use strict'
  2. const importSnapshot = {
  3. 'x-swagger-router-controller': 'project_import',
  4. operationId: 'importSnapshot',
  5. tags: ['ProjectImport'],
  6. description: 'Import a snapshot from the current rails app.',
  7. consumes: ['application/json'],
  8. parameters: [
  9. {
  10. name: 'project_id',
  11. in: 'path',
  12. description: 'project id',
  13. required: true,
  14. type: 'string',
  15. },
  16. {
  17. name: 'snapshot',
  18. in: 'body',
  19. description: 'Snapshot to import.',
  20. required: true,
  21. schema: {
  22. $ref: '#/definitions/Snapshot',
  23. },
  24. },
  25. ],
  26. responses: {
  27. 200: {
  28. description: 'Imported',
  29. },
  30. 409: {
  31. description: 'Conflict: project already initialized',
  32. },
  33. 404: {
  34. description: 'No such project exists',
  35. },
  36. },
  37. security: [
  38. {
  39. basic: [],
  40. },
  41. ],
  42. }
  43. const importChanges = {
  44. 'x-swagger-router-controller': 'project_import',
  45. operationId: 'importChanges',
  46. tags: ['ProjectImport'],
  47. description: 'Import changes for a project from the current rails app.',
  48. consumes: ['application/json'],
  49. parameters: [
  50. {
  51. name: 'project_id',
  52. in: 'path',
  53. description: 'project id',
  54. required: true,
  55. type: 'string',
  56. },
  57. {
  58. name: 'end_version',
  59. description: 'end_version of latest persisted chunk',
  60. in: 'query',
  61. required: true,
  62. type: 'number',
  63. },
  64. {
  65. name: 'return_snapshot',
  66. description:
  67. 'optionally, return a snapshot with the latest hashed content',
  68. in: 'query',
  69. required: false,
  70. type: 'string',
  71. enum: ['hashed', 'none'],
  72. },
  73. {
  74. name: 'changes',
  75. in: 'body',
  76. description: 'changes to be imported',
  77. required: true,
  78. schema: {
  79. type: 'array',
  80. items: {
  81. $ref: '#/definitions/Change',
  82. },
  83. },
  84. },
  85. ],
  86. responses: {
  87. 201: {
  88. description: 'Created',
  89. schema: {
  90. $ref: '#/definitions/Snapshot',
  91. },
  92. },
  93. },
  94. security: [
  95. {
  96. basic: [],
  97. },
  98. ],
  99. }
  100. const getChanges = {
  101. 'x-swagger-router-controller': 'projects',
  102. operationId: 'getChanges',
  103. tags: ['Project'],
  104. description: 'Get changes applied to a project',
  105. parameters: [
  106. {
  107. name: 'project_id',
  108. in: 'path',
  109. description: 'project id',
  110. required: true,
  111. type: 'string',
  112. },
  113. {
  114. name: 'since',
  115. in: 'query',
  116. description: 'start version',
  117. required: false,
  118. type: 'number',
  119. },
  120. ],
  121. responses: {
  122. 200: {
  123. description: 'Success',
  124. schema: {
  125. type: 'array',
  126. items: {
  127. $ref: '#/definitions/Change',
  128. },
  129. },
  130. },
  131. },
  132. security: [
  133. {
  134. basic: [],
  135. },
  136. ],
  137. }
  138. const flushChanges = {
  139. 'x-swagger-router-controller': 'project_import',
  140. operationId: 'flushChanges',
  141. tags: ['ProjectImport'],
  142. description: 'Flush project changes from buffer to the chunk store.',
  143. parameters: [
  144. {
  145. name: 'project_id',
  146. in: 'path',
  147. description: 'project id',
  148. required: true,
  149. type: 'string',
  150. },
  151. ],
  152. responses: {
  153. 200: {
  154. description: 'Success',
  155. schema: {
  156. $ref: '#/definitions/Project',
  157. },
  158. },
  159. 404: {
  160. description: 'Not Found',
  161. schema: {
  162. $ref: '#/definitions/Error',
  163. },
  164. },
  165. },
  166. security: [
  167. {
  168. basic: [],
  169. },
  170. ],
  171. }
  172. const expireProject = {
  173. 'x-swagger-router-controller': 'project_import',
  174. operationId: 'expireProject',
  175. tags: ['ProjectImport'],
  176. description: 'Expire project changes from buffer.',
  177. parameters: [
  178. {
  179. name: 'project_id',
  180. in: 'path',
  181. description: 'project id',
  182. required: true,
  183. type: 'string',
  184. },
  185. ],
  186. responses: {
  187. 200: {
  188. description: 'Success',
  189. schema: {
  190. $ref: '#/definitions/Project',
  191. },
  192. },
  193. 404: {
  194. description: 'Not Found',
  195. schema: {
  196. $ref: '#/definitions/Error',
  197. },
  198. },
  199. },
  200. security: [
  201. {
  202. basic: [],
  203. },
  204. ],
  205. }
  206. exports.paths = {
  207. '/projects/{project_id}/import': { post: importSnapshot },
  208. '/projects/{project_id}/legacy_import': { post: importSnapshot },
  209. '/projects/{project_id}/changes': { get: getChanges, post: importChanges },
  210. '/projects/{project_id}/legacy_changes': { post: importChanges },
  211. '/projects/{project_id}/flush': { post: flushChanges },
  212. '/projects/{project_id}/expire': { post: expireProject },
  213. }