package v1alpha1

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

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=regionserver
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="PHASE",type="string",JSONPath=".status.phase"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
type Key struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata"`

	Spec   KeySpec   `json:"spec"`
	Status KeyStatus `json:"status,omitempty"`
}

type KeySpec struct {
	Provider          string           `json:"provider"`
	Region            string           `json:"region"`
	TrustedDataplanes []string         `json:"trustedDataplanes,omitempty"`
	AccountRef        AccountReference `json:"accountRef"`
	// Tags are the tags to be attached to the Key.
	Tags map[string]string `json:"tags,omitempty"`
}

type KeyStatus struct {
	// +optional
	ID string `json:"id,omitempty"`

	// +optional
	Phase KeyPhase `json:"phase,omitempty"`
}

type KeyPhase string

const (
	KeyPhaseCreating KeyPhase = "Creating"
	KeyPhaseActive   KeyPhase = "Active"
	KeyPhaseDeleting KeyPhase = "Deleting"
	KeyPhaseFailed   KeyPhase = "Failed"
)

// +kubebuilder:object:root=true
type KeyList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata"`
	Items           []Key `json:"items"`
}

func init() {
	SchemeBuilder.Register(&Key{}, &KeyList{})
}
