API Docs - HyggeHalcyon/FP-DevOps GitHub Wiki
Welcome to the FP-DevOps wiki!
Desc: register a user
Authorization: None
example request body:
{
"username":"test",
"password":"test"
}
example response body:
{
"status": true,
"message": "success register user",
"data": {
"id": "cc90c2ff-6ed2-4aeb-a87e-349de2e801b7",
"username": "test"
}
}
Desc: login
Authorization: None
example request body:
{
"password": "password",
"username": "admin"
}
example response body:
{
"status": true,
"message": "success login",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.<REDACTED>.FUBqzmGBy-SodcIa0L40oA-UWe9vw_Nv2764ZZhzBCs",
"username": "admin"
}
}
Desc: return the current user's information
Constraint: user already logged in and token is valid
Authorization: Bearer Token
example response body:
{
"status": true,
"message": "success get user",
"data": {
"id": "d7698c0f-a978-4b76-96f7-aa9cf0304bff",
"username": "admin"
}
}
Desc: gets a paginated list of files data
Constraint: data returned only belongs to the current user
Authorization: Bearer Token
example response body:
{
"status": true,
"message": "success get file",
"data": [
{
"id": "cc951a19-b86e-4839-bf4b-0aba371431d3",
"filename": "test.pdf",
"size": 206506,
"mime_type": "application/pdf",
"shareable": true
},
{
"id": "e9240ee9-6985-461f-b83f-0b437e0540e0",
"filename": "test.pdf",
"size": 206506,
"mime_type": "application/pdf",
"shareable": true
}
],
"meta": {
"page": 1,
"per_page": 10,
"max_page": 1,
"count": 2
}
}
Desc: uploads a file
Constraint: only to registered and logged in users and files are bounded to them
Authorization: Bearer Token
example request body: form-data of a file.
example response body:
{
"status": true,
"message": "success create file",
"data": {
"id": "e9240ee9-6985-461f-b83f-0b437e0540e0",
"filename": "test.pdf",
"size": 206506,
"mime_type": "application/pdf",
"shareable": false
}
}
Desc: edit the filename or the shareable boolean of the file
Constraint: can only edit files that belongs to them
Authorization: Bearer Token
example request body:
{
"filename":"test2.pdf",
"shareable": true
}
example response body:
{
"status": true,
"message": "success update file",
"data": {
"id": "7cf1e902-4e98-45cd-86fe-5b31dce4ad87",
"filename": "test2.pdf",
"size": 206506,
"mime_type": "application/pdf",
"shareable": true
}
}
Desc: delete the file from both the database and the disk
Constraint: can only delete files that are belong to them
Authorization: Bearer Token
example request body: None
example response body:
{
"status": true,
"message": "success delete file"
}
Desc: get the actual file
Constraint: can only get files that belongs to them unless shareable flag are enabled. use ?view=true
to render the file in the browser else it will automatically downloads.
Authorization: Bearer Token (Optional with no token can only access shareable files)
example request body: None
example response body: bytes of the files
example error response body
{
"status": false,
"message": "failed get file",
"error": "unauthorized file access, you can only access your own files"
}
upon all errors, the api will return in the following error format
{
"status": false,
"message": "failed delete file",
"error": "file not found"
}