package com.cameleer.server.app.dto;

import com.cameleer.server.core.security.OidcConfig;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;

import java.util.List;

@Schema(description = "OIDC configuration for admin management")
public record OidcAdminConfigResponse(
        boolean configured,
        boolean enabled,
        String issuerUri,
        String clientId,
        boolean clientSecretSet,
        String rolesClaim,
        List<String> defaultRoles,
        boolean autoSignup,
        String displayNameClaim,
        String userIdClaim,
        String audience,
        List<String> additionalScopes
) {
    public static OidcAdminConfigResponse unconfigured() {
        return new OidcAdminConfigResponse(false, false, null, null, false, null, null, false, null, null, null, null);
    }

    public static OidcAdminConfigResponse from(OidcConfig config) {
        return new OidcAdminConfigResponse(
                true, config.enabled(), config.issuerUri(), config.clientId(),
                !config.clientSecret().isBlank(), config.rolesClaim(),
                config.defaultRoles(), config.autoSignup(), config.displayNameClaim(),
                config.userIdClaim(), config.audience(), config.additionalScopes()
        );
    }
}
