Dataset API Documentation
Explanation
DatasetController API Documentation
This document details the API endpoints exposed by the DatasetController
class for managing datasets. The controller utilizes Spring Boot and handles requests related to creating, updating, retrieving, and deleting datasets. All endpoints are prefixed with /api/datasets
.
Dependencies:
genum.dataset.DTO.CreateDatasetDTO
: Data Transfer Object for creating datasets.genum.dataset.model.Datasets
: Model representing a dataset.genum.serviceimplementation.datasets.DatasetsServiceImpl
: Service layer for dataset operations.genum.shared.data.data
.DTO.response.ResponseDetails
: DTO for standardized API responses.Lombok
@Slf4j
: For simplified logging.Spring Boot dependencies for REST controllers, validation, and data binding.
Error Handling:
All endpoints employ consistent error handling. Exceptions are caught, and a ResponseDetails
object is returned containing a timestamp, error message, and HTTP status code. Common status codes include:
200 OK
: Successful operation.201 CREATED
: Successful dataset creation.400 BAD REQUEST
: Invalid input data or other client-side errors.404 NOT FOUND
: Dataset not found.
Endpoints:
Method | Endpoint | Description | Request Body | Response Body |
POST | /create | Creates a new dataset. | CreateDatasetDTO | ResponseDetails |
PUT | /update/{id} | Updates an existing dataset. | Datasets | ResponseDetails |
GET | /{id} | Retrieves a dataset by ID. | None | Datasets or ResponseDetails |
GET | /all | Retrieves all datasets. | None | List<Datasets> |
DELETE | /delete/{id} | Deletes a dataset by ID. | None | ResponseDetails |
GET | /trending | Retrieves a list of trending datasets. | None | List<Datasets> |
GET | /download/{id} | Initiates the download of a dataset. | None | ResponseDetails |
Detailed Endpoint Descriptions:
1. Create Dataset:
Endpoint:
/create
Method:
POST
Request Body:
CreateDatasetDTO
(contains necessary dataset information). Validation using@Valid
ensures data integrity.Response:
201 CREATED
: ReturnsResponseDetails
indicating successful creation.400 BAD REQUEST
: ReturnsResponseDetails
with error message if creation fails.
2. Update Dataset:
Endpoint:
/update/{id}
Method:
PUT
Path Variable:
id
(Dataset ID)Request Body:
Datasets
object with updated data.@Valid
ensures data integrity.Response:
200 OK
: ReturnsResponseDetails
indicating successful update.400 BAD REQUEST
: ReturnsResponseDetails
with error message if update fails.404 NOT FOUND
: ReturnsResponseDetails
if dataset not found.
3. Get Dataset by ID:
Endpoint:
/{id}
Method:
GET
Path Variable:
id
(Dataset ID)Response:
200 OK
: Returns theDatasets
object.404 NOT FOUND
: ReturnsResponseDetails
if dataset not found.
4. Get All Datasets:
Endpoint:
/all
Method:
GET
Response:
200 OK
: Returns a list ofDatasets
objects.
5. Delete Dataset:
Endpoint:
/delete/{id}
Method:
DELETE
Path Variable:
id
(Dataset ID)Response:
200 OK
: ReturnsResponseDetails
indicating successful deletion.404 NOT FOUND
: ReturnsResponseDetails
if dataset not found.
6. Get Trending Datasets:
Endpoint:
/trending
Method:
GET
Response:
200 OK
: Returns a list ofDatasets
considered trending. The implementation details of "trending" are not specified here but reside within theDatasetsServiceImpl
.
7. Download Dataset:
Endpoint:
/download/{id}
Method:
GET
Path Variable:
id
(Dataset ID)Response:
200 OK
: ReturnsResponseDetails
indicating the download process has been initiated. The actual file download mechanism is handled withinDatasetsServiceImpl
.404 NOT FOUND
: ReturnsResponseDetails
if dataset not found.
Note: The specific implementation details of data validation, dataset storage, and the "trending" algorithm are not described in this document but are assumed to be handled correctly within the DatasetsServiceImpl
and related classes. This documentation focuses on the API contract presented by the DatasetController
.
Class: DatasetController
- Variable: datasetsService
--`