Week 7
Goals for the week
Sl. No. | Initial Goals | Completed |
---|---|---|
1. | Solve requested changes on existing PRs | Done |
2. | Write the API docs for POST /users in openapi.yaml | Done |
3. | Design the API for changing the upload permissions | Done |
API Docs (POST /users
)
I completed writing the docs for the /users
POST route in the swagger openapi.yaml
file and it looked like mentioned below ---
/users:
post:
operationId: createUser
tags:
- User
- Admin
summary: Create a new user
description: >
Create a new user
requestBody:
required: true
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/User'
- type: object
properties:
user_pass:
type: string
defaultVisibility:
type: string
enum:
- public
- protected
- private
required:
- name
application/x-www-form-urlencoded:
schema:
allOf:
- $ref: '#/components/schemas/User'
- type: object
properties:
user_pass:
type: string
defaultVisibility:
type: string
enum:
- public
- protected
- private
required:
- name
responses:
'201':
description: User created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Info'
'409':
description: User with the same email or username already exists
content:
application/json:
schema:
$ref: '#/components/schemas/Info'
'500':
description: Internal server error with details
content:
application/json:
schema:
$ref: '#/components/schemas/Info'
default:
$ref: '#/components/responses/defaultResponse'
Exploring upload-permissions plugin and designing the API
-
I took some time to understand the functionality of the
upload-permssions
plugin's methods and explored the existing functionalities. -
I realised how the format of the request body should be by monitoring the network logs
mod: upload_permissions
folder: 1
upload: 3
alluploadsperm: 0
newperm: 0
newgroup: 5 -
So if we observe the parameters, we see that we need the
folderId
,uploadId
,allUploadsPermission
for setting a common permision for every upload in a folder,newperm
for setting up the new permission for the upload andnewGroup
which is the group Id for which the permissons are being set. -
Keeping the above factors in mind, the API design comes out to be something like mentioned below.
/uploads/{id}/permissions:
parameters:
- name: id
required: true
description: Enter any upload id
in: path
schema:
type: integer
put:
operationId: setUploadPermissions
tags:
- Upload
summary: Set permissions for a upload in a folder for different groups
description: >
Set permissions for a upload in a folder for different groups
requestBody:
content:
application/json:
schema:
type: object
properties:
folderId:
type: integer
description: Enter a folder id
allUploadsPermission:
type: boolean
enum:
- true
- false
description: Apply same permissions to all uploads in this folder
groupId:
type: integer
description: Enter the id of the group you want to add or edit permission for this upload
newPermission:
type: string
enum:
- none
- read_only
- read_write
- clearing_admin
- admin
description: Select the permission for selected group
publicPermission:
type: string
enum:
- none
- read_only
- read_write
- clearing_admin
- admin
description: Select the public permission for this upload
required:
- allUploadsPermission
responses:
'202':
description: Permissions updated successfully
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Info'
'400':
description: Bad Request
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Info'
'404':
description: Upload does not exist
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Info'
'503':
description: Scheduler is not running
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Info'
default:
$ref: '#/components/responses/defaultResponse'
Conclusions and further plans
- Get the API design approved by the mentors and start working on the implementation.
- Study the UI behaviour of the
upload-permissions
page and realise the requirements of the UI implementaion in react.