package client

var (
	TIDB_JIRA_CUSTOM_FIELD_SET = CustomFieldSet{
		ClusterID:             "customfield_10149",
		TenantID:              "customfield_10157",
		TenantRegion:          "customfield_12841",
		TiDBCloudCluster:      "customfield_17124",
		TiDBCloudOrg:          "customfield_17125",
		OPAccoutnID:           "customfield_10097",
		OPAccountLevel:        "customfield_10098",
		TiDBCloudClusterType:  "customfield_12348",
		OnCallTier:            "customfield_10164",
		AutoOncallStatus:      "customfield_17168",
		L2Assignee:            "customfield_10053",
		EscalationSummary:     "customfield_12346",
		EscalationDescription: "customfield_12347",
		DefaultEnvironment:    "customfield_10050",
		GTOCEnvironment:       "customfield_10211",
		TCOCEnvironment:       "customfield_10146",
		DefaultSeverity:       "customfield_10076",
		GTOCSeverity:          "customfield_10158",
		AlertRequired:         "customfield_10223",
		TicketIssueKey:        "customfield_10152",
		ClusterVersion:        "customfield_10147",
	}
	SANDBOX_JIRA_CUSTOM_FIELD_SET = CustomFieldSet{
		ClusterID:             "customfield_10119",
		TenantID:              "customfield_10117",
		TenantRegion:          "customfield_12841", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		TiDBCloudCluster:      "customfield_10879",
		TiDBCloudOrg:          "customfield_10880",
		OPAccoutnID:           "customfield_10097", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		OPAccountLevel:        "customfield_10098", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		TiDBCloudClusterType:  "customfield_12348", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		OnCallTier:            "customfield_10164", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		AutoOncallStatus:      "customfield_17168", // FIXME: verify the Auto Oncall Status field in sandbox env
		L2Assignee:            "customfield_10053", // FIXME: verify the L2 assignee field in sandbox env
		EscalationSummary:     "customfield_12346", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		EscalationDescription: "customfield_12347", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		DefaultEnvironment:    "customfield_10050", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		GTOCEnvironment:       "customfield_10211", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		TCOCEnvironment:       "customfield_10146", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		DefaultSeverity:       "customfield_10076", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		GTOCSeverity:          "customfield_10158", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		AlertRequired:         "customfield_10223", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		TicketIssueKey:        "customfield_10152", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
		ClusterVersion:        "customfield_10147", // FIXME: this is the same as TIDB_JIRA_CUSTOM_FIELD_SET, but we need to verify it in sandbox env
	}
)

type CustomFieldSet struct {
	ClusterID             string
	TenantID              string
	TenantRegion          string
	TiDBCloudCluster      string
	TiDBCloudOrg          string
	OPAccoutnID           string
	OPAccountLevel        string
	TiDBCloudClusterType  string
	OnCallTier            string
	AutoOncallStatus      string
	L2Assignee            string
	EscalationSummary     string
	EscalationDescription string

	DefaultEnvironment string
	GTOCEnvironment    string
	TCOCEnvironment    string
	DefaultSeverity    string
	GTOCSeverity       string
	AlertRequired      string
	TicketIssueKey     string
	ClusterVersion     string
}

func (s CustomFieldSet) CustomerEnvironmentField(projectKey string) string {
	switch projectKey {
	case "GTOC":
		return s.GTOCEnvironment
	case "TCOC", "TCAB", "TCT":
		return s.TCOCEnvironment
	default:
		return s.DefaultEnvironment
	}
}

func (s CustomFieldSet) CustomerEnvironmentFields() []string {
	return []string{s.DefaultEnvironment, s.GTOCEnvironment, s.TCOCEnvironment}
}

func (s CustomFieldSet) IssueSeverityField(projectKey string) string {
	switch projectKey {
	case "GTOC", "TCOC", "TCT":
		return s.GTOCSeverity
	default:
		return s.DefaultSeverity
	}
}

func (s CustomFieldSet) IssueSeverityFields() []string {
	return []string{s.DefaultSeverity, s.GTOCSeverity}
}
