package com.ikon.projectmanagement.api;

import com.ikon.projectmanagement.dto.request.ProductPSResourceAllocationRequestDto;
import com.ikon.projectmanagement.dto.response.ProductPSResourceAllocationResponseDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.UUID;

@Tag(name = "Product Resource Allocation APIs", description = "Product resource allocation management APIs")
@RequestMapping("/api/v1/products")
public interface ProductResourceAllocationApi {

    @Operation(summary = "Get product resource allocations", description = "Retrieves all resource allocations for a product.", responses = {
            @ApiResponse(responseCode = "200", description = "Allocations retrieved successfully"),
            @ApiResponse(responseCode = "401", description = "Unauthorized"),
            @ApiResponse(responseCode = "404", description = "Product not found"),
            @ApiResponse(responseCode = "500", description = "Internal server error")
    })
    @GetMapping("/{productIdentifier}/resource-allocations")
    ResponseEntity<List<ProductPSResourceAllocationResponseDto>> getResourceAllocations(
            @RequestHeader("Authorization") String accessToken,
            @PathVariable("productIdentifier") UUID productIdentifier);

    @Operation(summary = "Get resource allocation", description = "Retrieves a single resource allocation by its ID.", responses = {
            @ApiResponse(responseCode = "200", description = "Allocation retrieved successfully"),
            @ApiResponse(responseCode = "401", description = "Unauthorized"),
            @ApiResponse(responseCode = "404", description = "Allocation not found"),
            @ApiResponse(responseCode = "500", description = "Internal server error")
    })
    @GetMapping("/{productIdentifier}/resource-allocations/{allocationIdentifier}")
    ResponseEntity<ProductPSResourceAllocationResponseDto> getResourceAllocation(
            @RequestHeader("Authorization") String accessToken,
            @PathVariable("productIdentifier") UUID productIdentifier,
            @PathVariable("allocationIdentifier") UUID allocationIdentifier);

    @Operation(summary = "Create resource allocation", description = "Creates a new resource allocation for a product.", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "New allocation details", required = true, content = @Content(schema = @Schema(implementation = ProductPSResourceAllocationRequestDto.class))), responses = {
            @ApiResponse(responseCode = "201", description = "Allocation created successfully"),
            @ApiResponse(responseCode = "400", description = "Invalid allocation data"),
            @ApiResponse(responseCode = "401", description = "Unauthorized"),
            @ApiResponse(responseCode = "404", description = "Product not found"),
            @ApiResponse(responseCode = "500", description = "Internal server error")
    })
    @PostMapping("/{productIdentifier}/resource-allocations")
    ResponseEntity<ProductPSResourceAllocationResponseDto> createResourceAllocation(
            @RequestHeader("Authorization") String accessToken,
            @PathVariable("productIdentifier") UUID productIdentifier,
            @RequestBody ProductPSResourceAllocationRequestDto allocationRequestDto);

    @Operation(summary = "Update resource allocation", description = "Updates an existing resource allocation for a product.", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated allocation details", required = true, content = @Content(schema = @Schema(implementation = ProductPSResourceAllocationRequestDto.class))), responses = {
            @ApiResponse(responseCode = "200", description = "Allocation updated successfully"),
            @ApiResponse(responseCode = "400", description = "Invalid allocation data"),
            @ApiResponse(responseCode = "401", description = "Unauthorized"),
            @ApiResponse(responseCode = "404", description = "Allocation not found"),
            @ApiResponse(responseCode = "500", description = "Internal server error")
    })
    @PutMapping("/{productIdentifier}/resource-allocations/{allocationIdentifier}")
    ResponseEntity<ProductPSResourceAllocationResponseDto> updateResourceAllocation(
            @RequestHeader("Authorization") String accessToken,
            @PathVariable("productIdentifier") UUID productIdentifier,
            @PathVariable("allocationIdentifier") UUID allocationIdentifier,
            @RequestBody ProductPSResourceAllocationRequestDto allocationRequestDto);

    @Operation(summary = "Delete resource allocation", description = "Deletes a resource allocation from a product.", responses = {
            @ApiResponse(responseCode = "204", description = "Allocation deleted successfully"),
            @ApiResponse(responseCode = "401", description = "Unauthorized"),
            @ApiResponse(responseCode = "404", description = "Allocation not found"),
            @ApiResponse(responseCode = "500", description = "Internal server error")
    })
    @DeleteMapping("/{productIdentifier}/resource-allocations/{allocationIdentifier}")
    ResponseEntity<Void> deleteResourceAllocation(
            @RequestHeader("Authorization") String accessToken,
            @PathVariable("productIdentifier") UUID productIdentifier,
            @PathVariable("allocationIdentifier") UUID allocationIdentifier);
}
