This document provides an overview of the RESTful APIs for managing S3 buckets, files, and RADOS Gateway (RGW) accounts. The APIs are built using Express.js, with middleware for authentication, request validation, and error handling, and integrate with MongoDB, PostgreSQL, Redis, RabbitMQ, and AWS S3.
- Prerequisites
- API Endpoints
- Authentication
- Request Validation
- Error Handling
- Setup Instructions
- Dependencies
- Node.js: Version 14.x or higher
- MongoDB: For storing metadata
- PostgreSQL: For queue configuration
- Redis: For caching
- RabbitMQ: For task queuing
- AWS S3 or Compatible Service: For object storage
- Environment Variables: Configure
.env
withJWT_SECRET
,PORT
,HOST
, database credentials, and S3 configurations
All endpoints require authentication via a Bearer token in the Authorization
header. The base path is /api/s3
.
-
List Buckets
- Endpoint:
GET /api/s3/list-buckets
- Description: Retrieves a list of S3 buckets for the authenticated user.
- Request Body: None
- Response:
{ "buckets": [ { "Name": "string", "CreationDate": "string", "LastModified": "string", "IsEmpty": boolean, "Error": "string" (optional) } ], "message": "Buckets listed with details" }
- Status Codes:
200
: Success400
: Missing userId or organizationId500
: Server error or failed to create S3 client
- Endpoint:
-
Create Bucket
- Endpoint:
POST /api/s3/create-bucket
- Description: Queues a task to create a new S3 bucket.
- Request Body:
{ "bucketName": "string" }
- Validation:
bucketName
: Required, 3-63 characters, lowercase, numbers, dots, or hyphens; must not already exist
- Response:
{ "taskId": "string", "message": "Create bucket task queued for {bucketName}" }
- Status Codes:
200
: Task queued successfully400
: Invalid bucket name or bucket already exists500
: Server error
- Endpoint:
-
Upload File
- Endpoint:
POST /api/s3/upload-file
- Description: Queues a task to upload one or more files to an S3 bucket.
- Request Body: Form-data with
bucketName
andfiles
(up to 10 files, max 5GB each)bucketName: string files: file(s)
- Validation:
bucketName
: Required, must exist- At least one file required
- Response:
{ "taskId": "string", "message": "File upload task queued for {n} files" }
- Status Codes:
200
: Task queued successfully400
: Invalid bucket name, bucket does not exist, or no files uploaded500
: Server error
- Endpoint:
-
Download File
- Endpoint:
POST /api/s3/download-file
- Description: Generates a pre-signed URL for downloading a file from an S3 bucket.
- Request Body:
{ "bucketName": "string", "fileName": "string" }
- Validation:
bucketName
: Required, must existfileName
: Required, must be a string
- Response:
{ "fileUrl": "string", "message": "Presigned URL generated for {fileName}" }
- Status Codes:
200
: Success400
: Missing or invalid bucketName/fileName500
: Server error or failed to create S3 client
- Endpoint:
-
Delete File
- Endpoint:
POST /api/s3/delete-file
- Description: Queues a task to delete a file from an S3 bucket.
- Request Body:
{ "bucketName": "string", "fileName": "string" }
- Validation:
bucketName
: Required, must existfileName
: Required, must be a string
- Response:
{ "taskId": "string", "message": "Delete file task queued for {fileName}" }
- Status Codes:
200
: Task queued successfully400
: Invalid bucket name or file name500
: Server error
- Endpoint:
-
List Files in Bucket
- Endpoint:
POST /api/s3/list-files
- Description: Lists all files in a specified S3 bucket.
- Request Body:
{ "bucketName": "string" }
- Validation:
bucketName
: Required, must exist
- Response:
{ "files": ["string"], "message": "Files listed successfully for bucket {bucketName}" }
- Status Codes:
200
: Success400
: Missing or invalid bucket name500
: Server error
- Endpoint:
-
Get File Metadata
- Endpoint:
POST /api/s3/file-metadata
- Description: Retrieves metadata for a specific file in an S3 bucket.
- Request Body:
{ "bucketName": "string", "fileName": "string" }
- Validation:
bucketName
: Required, must existfileName
: Required, must be a string
- Response:
{ "status": "success", "data": { "metadata": {} }, "message": "string" }
- Status Codes:
200
: Success400
: Missing or invalid bucket name/file name500
: Server error
- Endpoint:
-
Delete Bucket
- Endpoint:
POST /api/s3/delete-bucket
- Description: Queues a task to delete an empty S3 bucket.
- Request Body:
{ "bucketName": "string" }
- Validation:
bucketName
: Required, must exist and be empty
- Response:
{ "taskId": "string", "message": "Delete bucket task queued for {bucketName}" }
- Status Codes:
200
: Task queued successfully400
: Invalid bucket name or bucket not empty500
: Server error
- Endpoint:
-
Refresh Download URL
- Endpoint:
POST /api/s3/refresh-download-url
- Description: Refreshes a pre-signed URL for downloading a file (valid for 15 minutes).
- Query Parameters:
bucketName
: Required, must existfileName
: Required, must be a string
- Response:
{ "fileUrl": "string", "message": "Pre-signed URL refreshed for {fileName}" }
- Status Codes:
200
: Success400
: Missing or invalid bucket name/file name500
: Server error
- Endpoint:
Base path: /api/rgwacc
-
Create RADOS Account
-
Endpoint:
POST /api/rgwacc/create-account
-
Description: Creates a new RADOS Gateway account for the given user and organization.
-
Request Body:
{ "display_name": "string", "userId": "string", "organizationId": "string" }
-
Validation: All fields are required.
-
Response:
{ "message": "RADOS account created (mock)", "userId": "string", "subuserid": "string", "accessKey": "string", "secretKey": "string", "s3ClientEndpoint": "string", "s3ClientRegion": "string", "organizationId": "string", "display_name": "string" }
-
Status Codes:
201
: Success400
: Validation error500
: Internal error
-
-
Delete Ceph Key
-
Endpoint:
POST /api/rgwacc/delete-key
-
Description: Deletes a non-default Ceph key for the authenticated user.
-
Request Body:
{ "keyId": "string" }
-
Validation:
keyId
must be a valid non-default key. -
Response:
{ "message": "Successfully deleted Ceph key {keyId} for user {userId} in organization {organizationId}" }
-
Status Codes:
200
: Success400
: Invalid input or non-default key missing404
: Key not found500
: Server error
-
-
Get Ceph Credentials
-
Endpoint:
POST /api/rgwacc/get-credentials
-
Description: Retrieves non-default Ceph credentials for the user.
-
Request Body: None
-
Response:
{ "success": true, "data": [ { "access_key": "...", "secret_key": "...", ... } ], "message": "Successfully retrieved and synced non-default Ceph keys" }
-
Status Codes:
200
: Success500
: Retrieval error
-
-
Generate Ceph Key
-
Endpoint:
POST /api/rgwacc/generate-key
-
Description: Generates a new Ceph access key for the user (max 4).
-
Request Body: None
-
Response:
{ "success": true, "message": "Successfully generated new Ceph key", "data": { "accessKey": "string", "secretKey": "string", "uid": "string" } }
-
Status Codes:
201
: Created403
: Max key threshold reached500
: Failure to generate or store key
-
-
Delete Ceph User
-
Endpoint:
POST /api/rgwacc/delete-user
-
Description: Deletes a Ceph user and associated metadata.
-
Request Body: None
-
Response:
{ "message": "Successfully deleted Ceph user {uid} and all associated resources" }
-
Status Codes:
200
: Deleted404
: User not found500
: Server error
-
- All endpoints (except
/health
) require a Bearer token in theAuthorization
header. - The token is validated using
JWT_SECRET
and must containuserId
andorganizationId
. - Invalid or missing tokens result in a
401 Unauthorized
response.
- Requests are validated using
express-validator
for required fields, formats, and existence checks (e.g., bucket existence). - Validation errors return a
400 Bad Request
response with details:{ "errors": [{ "msg": "string" }] }
- Errors are handled by the
errorHandler
middleware, returning structured JSON responses:{ "status": "error", "error": "string", "details": "string", "code": "string" (optional) }
- Common error types:
ValidationError
: 400 (e.g., invalid input)MongoError
: 400 (e.g., duplicate key)NoSuchBucket
: 404NoSuchKey
: 404 (file not found)Redis connection error
: 503Invalid AWS credentials
: 401- Generic server errors: 500