nextcloud/forms

Reorganize API endpoints and deprecate current endpoints

Chartman123 opened this issue · 7 comments

Based on the comment by @susnux, here's the proposal on how to reorganize our API endpoints:

Forms endpoints

What Current New
Get forms GET /forms ✅ GET /forms -> Parameter: type = owned
Get shared forms GET /shared_forms ❓ GET /forms -> Parameter: type = shared
New form POST /form ✅ POST /forms
Get form GET /form/:id: ✅ GET /forms/:id: -> Parameter: partial = false
Get partial form GET /partial_form/:hash: ❓ GET /forms/:id: -> Parameter: partial = true
Clone form POST /form/clone/:id: ✅ POST /forms/:id:/clone
Update form PATCH /form/update ✅ PATCH /forms/:id:
Transfer ownership POST /form/transfer ✅ - (just use patch/update)
Delete form DELETE /form/:id: ✅ DELETE /forms/:id:
Link file to form POST /form/link/:fileformat: ✅ - (just use patch/update)
Unlink file POST /form/unlink ✅ - (just use patch/update)

Questions endpoints

What Current New
Get questions - ❓ GET /questions
Get question - ❓ GET /questions/:id:
New question POST /question ❓ POST /questions
Update question PATCH /question ❓ PATCH /questions/:id:
Reorder questions PUT /question/reorder ❓ PUT /questions/reorder
Clone question POST /questioin/clone/:id: ❓ POST /questions/:id:/clone
Delete question DELETE /question/:id: ❓ DELETE /questions/:id:

Options endpoints

What Current New
Get options - ❓ GET /options
Get option - ❓ GET /options/:id:
New option POST /option ❓ POST /options
Update option PATCH /option/update ❓ PATCH /options/:id:
Reorder options - ❓ PUT /options/reorder
Clone option - ❓ POST /options/:id:/clone
Delete option DELETE /option/:id: ❓ DELETE /options/:id:

Sharing endpoints

What Current New
Get shares - ❓ GET /shares
Get share - ❓ GET /shares/:id:
New share POST /share ❓ POST /shares
Update share PATCH /share/update ❓ PATCH /shares/:id:
Delete share DELETE /share/:id: ❓ DELETE /shares/:id:

Submission endpoints

What Current New
Get submissions GET `/submissions/:formhash: ❓ GET /submissions
Get submission - ❓ GET /submissions/:id:
Download submissions GET /submissions/export/:formhash:?:fileformat: ❓ GET /submissions -> Parameters download, filetype
Export submissions to cloud POST /submissions/export ❓ POST /submissions-> Parameters fileformat, path
New submission POST /submission/insert ❓ POST /submissions
Update submission - ❓ PATCH /submissions/:id:
Delete submissions DELETE /submissions/:formid: ❓ DELETE /submissions
Delete submission DELETE `/submission/:id: ❓ DELETE /submissions/:id:

❓ GET /forms/:id: -> Parameter: partial = true

I do not think we need this, either we have permissions on that form -> get all information, or we do not have (e.g. just shared for submit) -> get only partial

✅ POST /forms/:id:/clone

Or maybe same as creating a new and POST /forms and content: { id: 1234567 }.
I searched for similar APIs, sometimes it is also something like POST /forms?fromId=1234.

But more important: Do we want logical nesting?
E.g.:

  • POST /forms/{form-id}/questions vs POST /questions
  • DELETE /forms/{form-id}/questions/{question-id} vs POST /questions/{question-id}

I personally think it makes sense for forms, as we always need to query the form to check access to question / option etc.

But I am not sure about shares, because they are also bound to forms, like:

  • POST /forms/{form-id}/shares makes sense to create a new share for that form

But we also need /shares to fetch shares for the current user. EXCEPT if we include that in our /forms endpoint.