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:

MethodEndpointDescriptionRequest BodyResponse Body
POST/createCreates a new dataset.CreateDatasetDTOResponseDetails
PUT/update/{id}Updates an existing dataset.DatasetsResponseDetails
GET/{id}Retrieves a dataset by ID.NoneDatasets or ResponseDetails
GET/allRetrieves all datasets.NoneList<Datasets>
DELETE/delete/{id}Deletes a dataset by ID.NoneResponseDetails
GET/trendingRetrieves a list of trending datasets.NoneList<Datasets>
GET/download/{id}Initiates the download of a dataset.NoneResponseDetails

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: Returns ResponseDetails indicating successful creation.

    • 400 BAD REQUEST: Returns ResponseDetails 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: Returns ResponseDetails indicating successful update.

    • 400 BAD REQUEST: Returns ResponseDetails with error message if update fails.

    • 404 NOT FOUND: Returns ResponseDetails if dataset not found.

3. Get Dataset by ID:

  • Endpoint: /{id}

  • Method: GET

  • Path Variable: id (Dataset ID)

  • Response:

    • 200 OK: Returns the Datasets object.

    • 404 NOT FOUND: Returns ResponseDetails if dataset not found.

4. Get All Datasets:

  • Endpoint: /all

  • Method: GET

  • Response: 200 OK: Returns a list of Datasets objects.

5. Delete Dataset:

  • Endpoint: /delete/{id}

  • Method: DELETE

  • Path Variable: id (Dataset ID)

  • Response:

    • 200 OK: Returns ResponseDetails indicating successful deletion.

    • 404 NOT FOUND: Returns ResponseDetails if dataset not found.

6. Get Trending Datasets:

  • Endpoint: /trending

  • Method: GET

  • Response: 200 OK: Returns a list of Datasets considered trending. The implementation details of "trending" are not specified here but reside within the DatasetsServiceImpl.

7. Download Dataset:

  • Endpoint: /download/{id}

  • Method: GET

  • Path Variable: id (Dataset ID)

  • Response:

    • 200 OK: Returns ResponseDetails indicating the download process has been initiated. The actual file download mechanism is handled within DatasetsServiceImpl.

    • 404 NOT FOUND: Returns ResponseDetails 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

--`