package userbehavior

import "github.com/tidbcloud/devops/entity"

type Subscription struct {
	ID                   uint64                       `json:"id"  binding:"required"`
	Name                 string                       `json:"name"`
	SubscribeType        SubscribeTp                  `json:"subscribe_type"`
	LarkChats            []*entity.LarkChatSimplified `json:"lark_chats"`
	EventType            UBEventTp                    `json:"event_type"`
	Template             string                       `json:"template"`
	Selector             SelectorTp                   `json:"selector"`
	Creator              string                       `json:"creator"` // Creator email
	Available            bool                         `json:"available"`
	OnlyPaidTenant       bool                         `json:"only_paid_tenant"`
	OnlyExternalTenant   bool                         `json:"only_external_tenant"`
	OnlyDedicatedCluster bool                         `json:"only_dedicated_cluster"`
	DetailLink           *string                      `json:"detail_link"`
	TextFilter           string                       `json:"text_filter"`
} // @name userbehavior.Subscription

type SelectorTp struct {
	RegionSelectors []RegionSelectorTp `json:"region_selectors"`
	TenantSelectors []TenantSelectorTp `json:"tenant_selectors"`
}

type (
	RegionSelectorTp string
	TenantSelectorTp string
)

const (
	RegionSelectorNA   RegionSelectorTp = "na"
	RegionSelectorAPAC RegionSelectorTp = "apac"
	RegionSelectorEMEA RegionSelectorTp = "emea"
	RegionSelectorJP   RegionSelectorTp = "jp"
)

func ToRegionSelectorTp(s string) RegionSelectorTp {
	if s == "japan" {
		return RegionSelectorJP
	}
	return RegionSelectorTp(s)
}

func ToTenantSelectorTp(s string) TenantSelectorTp {
	return TenantSelectorTp(s)
}

type (
	UBEventTp string
)

const (
	UBEventTenant  UBEventTp = "tenant" // tenant creation, deletion and plan change
	UBEventCluster UBEventTp = "cluster"
	UBEventImport  UBEventTp = "import"
	UBEventBackup  UBEventTp = "backup"
	UBEventRestore UBEventTp = "restore"
	UBEventCDC     UBEventTp = "cdc"
	UBEventDMJob   UBEventTp = "dmjob"
	UBEventStartup UBEventTp = "startup" // monitor new startup company tenants
)

type (
	SubscribeTp string
)

const (
	SubscribeByChat SubscribeTp = "by_chat"
)
