package com.ikon.projectmanagement.api;

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 java.util.List;
import java.util.UUID;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ikon.projectmanagement.dto.request.RiskCreateRequestDto;
import com.ikon.projectmanagement.dto.response.RiskResponseDto;

@Tag(name = "Risk APIs", description = "Risk Management related APIs")
@RequestMapping("/api/v1/risks")
public interface RiskApi {

        @Operation(summary = "Create a new risk", description = "Creates a new risk and returns the created risk details.", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Risk details", required = true, content = @Content(schema = @Schema(implementation = RiskCreateRequestDto.class))), responses = {
                        @ApiResponse(responseCode = "201", description = "Risk created successfully"),
                        @ApiResponse(responseCode = "400", description = "Invalid risk data"),
                        @ApiResponse(responseCode = "401", description = "Unauthorized"),
                        @ApiResponse(responseCode = "500", description = "Internal server error")
        })
        @PostMapping
        ResponseEntity<RiskResponseDto> createRisk(
                        @RequestHeader("Authorization") String accessToken,
                        @RequestBody RiskCreateRequestDto riskCreateRequestDto);

        @Operation(summary = "Get all risks", description = "Retrieves a list of all existing risks.", responses = {
                        @ApiResponse(responseCode = "200", description = "Risks retrieved successfully"),
                        @ApiResponse(responseCode = "401", description = "Unauthorized"),
                        @ApiResponse(responseCode = "500", description = "Internal server error")
        })
        @GetMapping
        ResponseEntity<List<RiskResponseDto>> getAllRisks(
                        @RequestHeader("Authorization") String accessToken);

        @Operation(summary = "Get risk by Id", description = "Retrieves a risk by its unique risk ID.", responses = {
                        @ApiResponse(responseCode = "200", description = "Risk retrieved successfully"),
                        @ApiResponse(responseCode = "401", description = "Unauthorized"),
                        @ApiResponse(responseCode = "404", description = "Risk not found"),
                        @ApiResponse(responseCode = "500", description = "Internal server error")
        })
        @GetMapping("/{riskId}")
        ResponseEntity<RiskResponseDto> getRiskById(
                        @RequestHeader("Authorization") String accessToken,
                        @PathVariable("riskId") UUID riskId);

        @Operation(summary = "Update an existing risk", description = "Updates the details of an existing risk identified by its ID.", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated risk details", required = true, content = @Content(schema = @Schema(implementation = RiskCreateRequestDto.class))), responses = {
                        @ApiResponse(responseCode = "200", description = "Risk updated successfully"),
                        @ApiResponse(responseCode = "400", description = "Invalid risk data or ID provided"),
                        @ApiResponse(responseCode = "401", description = "Unauthorized"),
                        @ApiResponse(responseCode = "404", description = "Risk not found"),
                        @ApiResponse(responseCode = "500", description = "Internal server error")
        })
        @PutMapping("/{riskId}")
        ResponseEntity<RiskResponseDto> updateRisk(
                        @RequestHeader("Authorization") String accessToken,
                        @PathVariable("riskId") UUID riskId,
                        @RequestBody RiskCreateRequestDto riskCreateRequestDto);

        @Operation(summary = "Get all risks by project", description = "Retrieves a list of all risks associated with a specific project.", responses = {
                        @ApiResponse(responseCode = "200", description = "Risks retrieved successfully"),
                        @ApiResponse(responseCode = "401", description = "Unauthorized"),
                        @ApiResponse(responseCode = "404", description = "Project not found"),
                        @ApiResponse(responseCode = "500", description = "Internal server error")
        })
        @GetMapping("/project/{projectIdentifier}")
        ResponseEntity<List<RiskResponseDto>> getRisksByProject(
                        @RequestHeader("Authorization") String accessToken,
                        @PathVariable("projectIdentifier") String projectIdentifier);

}