package com.devlab.app.data.api

import com.devlab.app.data.model.*
import retrofit2.http.*

interface ApiService {

    @POST("api/auth/login")
    suspend fun login(@Body request: LoginRequest): LoginResponse

    @POST("api/auth/register")
    suspend fun register(@Body request: RegisterRequest): LoginResponse

    @GET("api/profile")
    suspend fun getProfile(): ApiResponse<UserProfile>

    @PUT("api/profile")
    suspend fun updateProfile(@Body request: ProfileUpdateRequest): ApiResponse<Map<String, String>>

    @GET("api/status")
    suspend fun getStatus(): ApiResponse<DashboardStats>

    @GET("api/servers")
    suspend fun getServers(
        @Query("page") page: Int = 1,
        @Query("per_page") perPage: Int = 20,
        @Query("search") search: String? = null
    ): ApiResponse<List<Server>>

    @GET("api/servers/{id}")
    suspend fun getServerDetail(
        @Path("id") id: Int
    ): ApiResponse<ServerDetail>

    @GET("api/servers/{id}/metrics")
    suspend fun getServerMetrics(
        @Path("id") id: Int,
        @Query("hours") hours: Int = 24
    ): ApiResponse<List<MetricPoint>>

    @POST("api/servers/{id}/execute")
    suspend fun executeCommand(
        @Path("id") id: Int,
        @Body command: CommandRequest
    ): ApiResponse<CommandResult>

    @GET("api/servers/{id}/services")
    suspend fun getServerServices(@Path("id") id: Int): ApiResponse<List<ServiceInfo>>

    @POST("api/servers/{id}/reboot")
    suspend fun serverReboot(@Path("id") id: Int): ApiResponse<Map<String, String>>

    @POST("api/servers/{id}/shutdown")
    suspend fun serverShutdown(@Path("id") id: Int): ApiResponse<Map<String, String>>

    @POST("api/servers/{id}/test-connection")
    suspend fun testServerConnection(@Path("id") id: Int): ApiResponse<ConnectionResult>

    @POST("api/servers/{id}/service-action")
    suspend fun serviceAction(@Path("id") id: Int, @Body request: ServiceActionRequest): ApiResponse<ServiceActionResult>

    @GET("api/refresh-metrics")
    suspend fun refreshMetrics(): ApiResponse<Map<String, Any?>>

    @GET("api/app-version")
    suspend fun checkVersion(): ApiResponse<AppVersionResponse>

    @GET("api/notifications")
    suspend fun getNotifications(
        @Query("page") page: Int = 1,
        @Query("per_page") perPage: Int = 20
    ): NotificationListResponse

    @POST("api/notifications/{id}/read")
    suspend fun markNotificationRead(@Path("id") id: Int): ApiResponse<Map<String, Boolean>>

    @POST("api/notifications/read-all")
    suspend fun markAllNotificationsRead(): ApiResponse<Map<String, Boolean>>

    @GET("api/notifications/unread-count")
    suspend fun getUnreadCount(): UnreadCountResponse
}
