package com.sankofa.phoenix.data

import com.apollographql.apollo3.ApolloClient
import com.apollographql.apollo3.api.ApolloResponse
import kotlinx.coroutines.flow.Flow

class GraphQLService {
    private val apolloClient = ApolloClient.Builder()
        .serverUrl("https://api.sankofa.nexus/graphql")
        .build()

    suspend fun fetchResources(): Flow<ApolloResponse<ResourcesQuery.Data>> {
        // GraphQL query implementation using Apollo Kotlin
        return apolloClient.query(ResourcesQuery()).toFlow()
    }

    suspend fun fetchSystemHealth(): Flow<ApolloResponse<SystemHealthQuery.Data>> {
        return apolloClient.query(SystemHealthQuery()).toFlow()
    }

    suspend fun fetchCostOverview(): Flow<ApolloResponse<CostOverviewQuery.Data>> {
        return apolloClient.query(CostOverviewQuery()).toFlow()
    }
}

data class Resource(
    val id: String,
    val name: String,
    val type: String,
    val status: String
)

data class SystemHealth(
    val regions: HealthMetrics,
    val clusters: HealthMetrics,
    val nodes: HealthMetrics
)

data class HealthMetrics(
    val total: Int,
    val healthy: Int,
    val warning: Int,
    val critical: Int
)

data class CostOverview(
    val currentMonth: Double,
    val lastMonth: Double,
    val trend: String,
    val percentageChange: Double
)

