Dataset API Documentation
I am Okoroafor Kelechi Divine, In 2020 I decided to help solve many problems in the world through innovation and modern-day designs with software engineering and technical writing as my tool.
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:
/createMethod:
POSTRequest Body:
CreateDatasetDTO(contains necessary dataset information). Validation using@Validensures data integrity.Response:
201 CREATED: ReturnsResponseDetailsindicating successful creation.400 BAD REQUEST: ReturnsResponseDetailswith error message if creation fails.
2. Update Dataset:
Endpoint:
/update/{id}Method:
PUTPath Variable:
id(Dataset ID)Request Body:
Datasetsobject with updated data.@Validensures data integrity.Response:
200 OK: ReturnsResponseDetailsindicating successful update.400 BAD REQUEST: ReturnsResponseDetailswith error message if update fails.404 NOT FOUND: ReturnsResponseDetailsif dataset not found.
3. Get Dataset by ID:
Endpoint:
/{id}Method:
GETPath Variable:
id(Dataset ID)Response:
200 OK: Returns theDatasetsobject.404 NOT FOUND: ReturnsResponseDetailsif dataset not found.
4. Get All Datasets:
Endpoint:
/allMethod:
GETResponse:
200 OK: Returns a list ofDatasetsobjects.
5. Delete Dataset:
Endpoint:
/delete/{id}Method:
DELETEPath Variable:
id(Dataset ID)Response:
200 OK: ReturnsResponseDetailsindicating successful deletion.404 NOT FOUND: ReturnsResponseDetailsif dataset not found.
6. Get Trending Datasets:
Endpoint:
/trendingMethod:
GETResponse:
200 OK: Returns a list ofDatasetsconsidered trending. The implementation details of "trending" are not specified here but reside within theDatasetsServiceImpl.
7. Download Dataset:
Endpoint:
/download/{id}Method:
GETPath Variable:
id(Dataset ID)Response:
200 OK: ReturnsResponseDetailsindicating the download process has been initiated. The actual file download mechanism is handled withinDatasetsServiceImpl.404 NOT FOUND: ReturnsResponseDetailsif 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
--`