package api

import "fmt"

type Level string

const (
	LevelCritical Level = "critical"
	LevelWarning  Level = "warning"
	LevelInfo     Level = "info"
)

type Resource struct {
	Kind       string `json:"kind"`
	APIVersion string `json:"apiVersion"`
	Namespace  string `json:"namespace"`
	Name       string `json:"name"`
}

func (r Resource) String() string {
	return fmt.Sprintf("%s/%s:%s/%s", r.APIVersion, r.Kind, r.Namespace, r.Name)
}

type ViolatedRule struct {
	Name    string         `json:"name"`
	Level   Level          `json:"level"`
	Message string         `json:"message"`
	Details map[string]any `json:"details"`
}

type Violation struct {
	Resource      Resource       `json:"resource"`
	ViolatedRules []ViolatedRule `json:"violadatedRules"`
}

type Result struct {
	Target     string      `json:"target"`
	Violations []Violation `json:"violations"`
}
