package platform

const (
	TypeServerless   = "ServerlessTier"
	TypeAwsDedicated = "AwsDedicatedTier"
	TypeGcpDedicated = "GcpDedicatedTier"
)
const (
	ClusterPrivateLinkExpectStatus = 3
)
const (
	DataRowsPath      = "$.data.rows"
	DataRowsCountPath = "$.data.row_count"
	DataMessagePath   = "$.data.result.message"
	ExpectMessage     = "ok"
	MessagePath       = "$.message"
	ExpectCode        = 200
	CodePath          = "$.code"
)

// dataapp scene case params
const (
	DataAPPName            = "QE_AUTO_TEST_APP"
	DataAPPStandardType    = "dataapi"
	DataAPPChat2QueryType  = "chat2query"
	DataAPPBaseUrlPath     = "$.data.app_info."
	DataAPPIdPath          = "$.data.app_info.id"
	DataEndpointIdPath     = "$.data.endpoint.id"
	EndpointIdPath         = "$.endpoint.id"
	AutoGenerateEndpointId = "$.data[0].id"
	TemplatePath           = "$.data.sql_template"
	EndpointPath           = "$.data.endpoint"
	EndpointMethodPath     = "$.data.method"
	EndpointServiceUrlPath = "$.data.service_url"
	TestEndpointLimitPath  = "$.data.result.limit"
	TestEndpointCodePath   = "$.data.result.code"
	TestEndpointRowsPath   = "$.data.rows"
	APIKeyName             = "QE_AUTO_TEST_KEY"
	APIKeyRole             = "api:dataapp:owner"
	APIKeyRateLimit        = 100
	PublicKeyPath          = "$.data.access_key"
	PrivateKeyPath         = "$.data.secret_key"
)

// endpoint params
const (
	EndpointTimeOut          = 5000
	EndpointMaxTimeOut       = 30000
	SystemEndpointMaxTimeOut = 120000
	EndpointRowsLimit        = 2
	BatchPostEndpointName    = "BatchPost"
	EndpointTag              = "QE_Tag"
	EndpointName             = "qe_auto_test_endpoint"
	EndpointDescription      = "qe auto test endpoint"
	EndpointMethod           = "GET"
	EndpointSqlDBName        = "QE_sample_data"
	EndpointSqlTableName     = "imdb_movie_ratings"
	EndpointSqlTemplate      = "use " + EndpointSqlDBName + ";\nselect * \nfrom " + EndpointSqlTableName + "\nwhere genre = ${genre};"
	EndpointArgsName         = "genre"
	EndpointArgsRequired     = 0
	EndpointArgsType         = "string"
	EndpointArgsValue        = "Drama"
	EndpointUrlPath          = "/qe/api/get_genre"
)

// chat2query system endpoint params
const (
	Chat2QueryAPIKeyRole = "api:dataapp:eda:admin"
	postDataSummaryFlag  = "/v2/dataSummariesPOST"
	getDataSummaryFlag   = "/v2/dataSummariesGET"
	v2Chat2DataFlag      = "/v2/chat2dataPOST"
	// v2ExecuteQueryFlag       = "/v2/executeQueryPOST"
	v1Chat2DataFlag          = "/v1/chat2dataPOST"
	getJobFlag               = "/v2/jobs/{job_id}GET"
	dataSummaryIdPath        = "$.result.data_summary_id"
	jobIdPath                = "$.result.job_id"
	ResultStatusPath         = "$.result.status"
	Chat2DataNaturalLanguage = "give me 3 rows of imdb"
	executeQuerySQL          = "select * from " + EndpointSqlTableName + "\n limit 3;"
	Chat2DataDataPath        = "$.result.result.task_tree[\"0\"].rows"
	executeQueryDataPath     = "$.result.rows"
)

// chat2query scene case params
const (
	warehouses           = 2
	districtPerWarehouse = 2
	customerPerDistrict  = 50
	timeFormat           = "2006-01-02 15:04:05"
	modifyCount          = 2
)
const (
	StagingServiceRegion     = "us-west-2"
	SystemSchema             = "INFORMATION_SCHEMA"
	Base_Database            = "test"
	Base_Table               = "imdb_movie_ratings"
	useSampleData            = "use sample_data;"
	FileName                 = "QE Scene Auto Test File"
	FileSQL                  = "select 'HELLO WORLD'"
	CreateTableSql_warehouse = `CREATE TABLE IF NOT EXISTS warehouse (
		w_id INT NOT NULL,
		w_name VARCHAR(10),
		w_street_1 VARCHAR(20),
		w_street_2 VARCHAR(20),
		w_city VARCHAR(20),
		w_state CHAR(2),
		w_zip CHAR(9),
		w_tax DECIMAL(4, 4),
		w_ytd DECIMAL(12, 2),
		PRIMARY KEY (w_id) /*T![clustered_index] CLUSTERED */
	)`
	CreateTableSql_district = `CREATE TABLE IF NOT EXISTS district (
		d_id INT NOT NULL,
		d_w_id INT NOT NULL,
		d_name VARCHAR(10),
		d_street_1 VARCHAR(20),
		d_street_2 VARCHAR(20),
		d_city VARCHAR(20),
		d_state CHAR(2),
		d_zip CHAR(9),
		d_tax DECIMAL(4, 4),
		d_ytd DECIMAL(12, 2),
		d_next_o_id INT,
		PRIMARY KEY (d_w_id, d_id) /*T![clustered_index] CLUSTERED */
	)`
	CreateTableSql_customer = `CREATE TABLE IF NOT EXISTS customer (
		c_id INT NOT NULL,
		c_d_id INT NOT NULL,
		c_w_id INT NOT NULL,
		c_first VARCHAR(16),
		c_middle CHAR(2),
		c_last VARCHAR(16),
		c_street_1 VARCHAR(20),
		c_street_2 VARCHAR(20),
		c_city VARCHAR(20),
		c_state CHAR(2),
		c_zip CHAR(9),
		c_phone CHAR(16),
		c_since DATETIME,
		c_credit CHAR(2),
		c_credit_lim DECIMAL(12, 2),
		c_discount DECIMAL(4,4),
		c_balance DECIMAL(12,2),
		c_ytd_payment DECIMAL(12,2),
		c_payment_cnt INT,
		c_delivery_cnt INT, 
		c_data VARCHAR(500),
		PRIMARY KEY(c_w_id, c_d_id, c_id) /*T![clustered_index] CLUSTERED */,
		INDEX idx_customer (c_w_id, c_d_id, c_last, c_first)
	)`
	CreateTableSql_imdb = "CREATE TABLE IF NOT EXISTS imdb_movie_ratings (" +
		"movie_name varchar(256) DEFAULT NULL," +
		`runtime_in_min bigint(20) DEFAULT NULL,
		genre varchar(256) DEFAULT NULL,
		metascore double DEFAULT NULL
		) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin`
	InsertSql_imdb = "INSERT INTO imdb_movie_ratings (movie_name,runtime_in_min,genre,metascore) VALUES " +
		"('The Shawshank Redemption',142,'Drama',81)," +
		"('The Godfather',175,'Crime, Drama',100)," +
		"('The Dark Knight',152,'Action, Crime, Drama',84)," +
		"('Fight Club',139,'Drama',66)," +
		"('One Flew Over the Cuckoos Nest',133,'Drama',84)"
)

var get_query_param = map[string]string{"genre": "Drama"}
var jsonHeader = map[string]string{
	"content-type": "application/json",
}
var batch_post_body = []map[string]string{
	{
		"movie_name":     "TestMovieName1",
		"runtime_in_min": "1",
		"genre":          "TestGenre1",
		"metascore":      "1",
	},
	{
		"movie_name":     "TestMovieName2",
		"runtime_in_min": "2",
		"genre":          "TestGenre2",
		"metascore":      "2",
	},
}
