project_import.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. exports.paths = {
  101. '/projects/{project_id}/import': { post: importSnapshot },
  102. '/projects/{project_id}/legacy_import': { post: importSnapshot },
  103. '/projects/{project_id}/changes': { post: importChanges },
  104. '/projects/{project_id}/legacy_changes': { post: importChanges },
  105. }