package k8supgradeplan

import (
	"github.com/tidbcloud/devops/api"
	planent "github.com/tidbcloud/devops/entity/k8supgradeplan"
)

type ListPlansFilter struct {
	CloudProviders []string `form:"cloud_providers" json:"cloud_providers"`
	EOSVersions    []string `form:"eos_versions" json:"eos_versions"`
	Statuses       []string `form:"statuses" json:"statuses"`
}

type ListPlansReq struct {
	api.PaginationReq
	ListPlansFilter
}

type ListPlansResp struct {
	api.BaseResp `json:",inline"`
	Total        int64                     `json:"total"`
	Items        []*planent.PlannedUpgrade `json:"items"`
}

type CreatePlanReq struct {
	Name            string `json:"name" binding:"required"`
	CloudProvider   string `json:"cloud_provider" binding:"required"`
	EOSVersion      string `json:"eos_version" binding:"required"`
	EOSDate         int64  `json:"eos_date" binding:"required"`
	Deadline        int64  `json:"deadline" binding:"required"`
	TriggerTime     int64  `json:"trigger_time"`
	MaxRestartTimes uint32 `json:"max_restart_times"`
	SelectorType    string `json:"selector_type"`
	SelectorValue   string `json:"selector_value"`
}

type CreatePlanResp struct {
	api.BaseResp `json:",inline"`
	ID           uint64 `json:"id"`
}

type UpdatePlanReq struct {
	Name            *string `json:"name"`
	Deadline        *int64  `json:"deadline"`
	TriggerTime     *int64  `json:"trigger_time"`
	MaxRestartTimes *uint32 `json:"max_restart_times"`
	SelectorType    *string `json:"selector_type"`
	SelectorValue   *string `json:"selector_value"`
}

type SchedulePlanReq struct {
	TriggerTime int64 `json:"trigger_time" binding:"required"`
}

type GetPlanResp struct {
	planent.PlannedUpgrade `json:",inline"`
}
