package v1alpha1

//go:generate controller-gen object paths=$GOFILE

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

type TLS struct {
	SecretName string `json:"secretName"`
}

type ResponseForwarding struct {
	FlushInterval string `json:"flushInterval"`
}

type Cookie struct {
	HttpOnly bool   `json:"httpOnly"`
	Name     string `json:"name"`
	Secure   bool   `json:"secure"`
}

type Sticky struct {
	Cookie Cookie `json:"cookie"`
}

type Service struct {
	Kind               string             `json:"kind"`
	Name               string             `json:"name"`
	Namespace          string             `json:"namespace"`
	PassHostHeader     bool               `json:"passHostHeader"`
	Port               int                `json:"port"`
	ResponseForwarding ResponseForwarding `json:"responseForwarding"`
	Scheme             string             `json:"scheme"`
	Sticky             Sticky             `json:"sticky"`
	Strategy           string             `json:"strategy"`
	Weight             int                `json:"weight"`
}

type Observability struct {
	AccessLogs bool `json:"accessLogs"`
	Metrics    bool `json:"metrics"`
	Tracing    bool `json:"tracing"`
}

type Middleware struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
}

type Route struct {
	Kind          string        `json:"kind"`
	Match         string        `json:"match"`
	Middlewares   []Middleware  `json:"middlewares"`
	Observability Observability `json:"observability"`
	Priority      int           `json:"priority"`
	Services      []Service     `json:"services"`
}

type IngressRouteSpec struct {
	EntryPoints []string `json:"entryPoints"`
	Routes      []Route  `json:"routes"`
	TLS         TLS      `json:"tls"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type IngressRoute struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec IngressRouteSpec `json:"spec"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type IngressRouteList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`

	Items []IngressRoute `json:"items"`
}
