package models

import (
	"time"
)

type Certificate struct {
	ID            string    `json:"id" bson:"_id"`
	CommonName    string    `json:"common_name" bson:"common_name"`
//	Subject       string    `json:"subject" bson:"subject"`
	DNSNames      []string  `json:"dns_names" bson:"dns_names"`
	IPAddresses   []string  `json:"ip_addresses" bson:"ip_addresses"`
	Type          string    `json:"type" bson:"type"` // "server" or "client"
	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"`
	IssuerCAID    string    `json:"issuer_ca_id" bson:"issuer_ca_id"`
	Revoked       bool      `json:"revoked" bson:"revoked"`
	RevokedAt     time.Time `json:"revoked_at,omitempty" bson:"revoked_at"`
	RevokedReason string    `json:"revoked_reason,omitempty" bson:"revoked_reason"`
	CreatedAt     time.Time `json:"created_at" bson:"created_at"`
}

type CreateCertificateRequest struct {
	CommonName  string   `json:"common_name" binding:"required"`
	DNSNames    []string `json:"dns_names"`
	IPAddresses []string `json:"ip_addresses"`
	Type        string   `json:"type" binding:"required,oneof=server client"`
	KeySize     int      `json:"key_size" binding:"required,min=2048"`
	ValidDays   int      `json:"valid_days" binding:"required,min=1,max=365"`
	IssuerCAID  string   `json:"issuer_ca_id" binding:"required"`
}

type RevokeCertificateRequest struct {
	Reason string `json:"reason" binding:"required"`
}
