package models

import (
	"time"
)

type SubCA struct {
	ID           string    `json:"id" bson:"_id"`
	Name         string    `json:"name" bson:"name"`
	CommonName   string    `json:"common_name" bson:"common_name"`
	Organization string    `json:"organization" bson:"organization"`
	OrganizationalUnit string `json:"organization_unit" bson:"organization_unit"`
	Country      string    `json:"country" bson:"country"`
	Province     string    `json:"province" bson:"province"`
	Locality     string    `json:"locality" bson:"locality"`
	Email        string    `json:"email" bson:"email"`
	PrivateKey   string    `json:"private_key,omitempty" bson:"private_key"`
	Certificate  string    `json:"certificate" bson:"certificate"`
	SerialNumber string    `json:"serial_number" bson:"serial_number"`
	ValidFrom    time.Time `json:"valid_from" bson:"valid_from"`
	ValidTo      time.Time `json:"valid_to" bson:"valid_to"`
	ParentCAID   string    `json:"parent_ca_id" bson:"parent_ca_id"`
	CreatedAt    time.Time `json:"created_at" bson:"created_at"`
	UpdatedAt    time.Time `json:"updated_at" bson:"updated_at"`
}

type CreateSubCARequest struct {
	Name         string `json:"name" binding:"required"`
	CommonName   string `json:"common_name" binding:"required"`
	Organization string `json:"organization" binding:"required"`
	OrganizationalUnit string `json:"organization_unit" binding:"required"`
	Country      string `json:"country" binding:"required"`
	Province     string `json:"province"`
	Locality     string `json:"locality"`
	Email        string `json:"email" binding:"omitempty,email"` // omitempty permet les chaînes vides
	KeySize      int    `json:"key_size" binding:"required,min=2048"`
	ValidYears   int    `json:"valid_years" binding:"required,min=1,max=10"`
	ParentCAID   string `json:"parent_ca_id" binding:"required"`
}

type UpdateSubCARequest struct {
	Name         string `json:"name"`
	Organization string `json:"organization"`
	OrganizationalUnit string `json:"organization_unit"`
	Email        string `json:"email"`
}
