package entity

import (
	"time"

	"google.golang.org/protobuf/types/known/timestamppb"

	globaldedicatedv1 "github.com/tidbcloud/tidb-management-service/api/spec/global/dedicated/v1"
)

// ClusterPausePlan
type ClusterPausePlan struct {
	*globaldedicatedv1.Cluster_PausePlan

	Id uint64
}

func EnsureScheduledResumeTime(p *ClusterPausePlan, defaultPauseScheduleDay int) *ClusterPausePlan {
	if p == nil {
		return nil
	}
	var s *timestamppb.Timestamp
	if p.GetPausePlan() == globaldedicatedv1.Cluster_PausePlan_NORMAL {
		s = timestamppb.New(p.GetPauseTime().AsTime().Add(time.Duration(defaultPauseScheduleDay) * 24 * time.Hour))
	}
	p.ScheduledResumeTime = s
	return p
}
