package api

import (
	"context"

	planent "github.com/tidbcloud/devops/entity/k8supgradeplan"
)

type CreatePlanParam struct {
	Name            string
	CloudProvider   string
	EOSVersion      string
	EOSDate         int64
	Deadline        int64
	TriggerTime     int64
	MaxRestartTimes uint32
	SelectorType    string
	SelectorValue   string
	CreatedBy       string
}

type UpdatePlanParam struct {
	Name            *string
	Deadline        *int64
	TriggerTime     *int64
	MaxRestartTimes *uint32
	SelectorType    *string
	SelectorValue   *string
}

type ListPlansParam struct {
	CloudProviders []string
	EOSVersions    []string
	Statuses       []planent.PlanStatus
	Page           int
	PerPage        int
}

type API interface {
	CreatePlan(ctx context.Context, param CreatePlanParam) (uint64, error)
	UpdatePlan(ctx context.Context, id uint64, param UpdatePlanParam) error
	SchedulePlan(ctx context.Context, id uint64, triggerTime int64) error
	CancelPlan(ctx context.Context, id uint64) error
	GetPlan(ctx context.Context, id uint64) (*planent.PlannedUpgrade, error)
	ListPlans(ctx context.Context, param ListPlansParam) ([]*planent.PlannedUpgrade, int64, error)
	TriggerNow(ctx context.Context, id uint64) error
}
