package api

// Protocol constants for WebSocket binary protocol
// All handlers use [api_key_hash:16] as the first 16 bytes of every payload
const (
	// Auth header size (present in all payloads)
	ProtocolAPIKeyHashLen = 16

	// Commit ID size (20 bytes hex = 40 char string)
	ProtocolCommitIDLen = 20

	// Minimum payload sizes for each operation
	ProtocolMinStatusRequest        = ProtocolAPIKeyHashLen      // [api_key_hash:16]
	ProtocolMinCancelJob            = ProtocolAPIKeyHashLen + 1  // [api_key_hash:16][job_name_len:1]
	ProtocolMinPrune                = ProtocolAPIKeyHashLen + 5  // [api_key_hash:16][prune_type:1][value:4]
	ProtocolMinDatasetList          = ProtocolAPIKeyHashLen      // [api_key_hash:16]
	ProtocolMinDatasetRegister      = ProtocolAPIKeyHashLen + 3  // [api_key_hash:16][name_len:1][url_len:2]
	ProtocolMinDatasetInfo          = ProtocolAPIKeyHashLen + 1  // [api_key_hash:16][name_len:1]
	ProtocolMinDatasetSearch        = ProtocolAPIKeyHashLen + 1  // [api_key_hash:16][term_len:1]
	ProtocolMinLogMetric            = ProtocolAPIKeyHashLen + 25 // [api_key_hash:16][commit_id:20][step:4][value:8][name_len:1]
	ProtocolMinGetExperiment        = ProtocolAPIKeyHashLen + 20 // [api_key_hash:16][commit_id:20]
	ProtocolMinQueueJob             = ProtocolAPIKeyHashLen + 21 // [api_key_hash:16][commit_id:20][priority:1][job_name_len:1]
	ProtocolMinQueueJobWithSnapshot = ProtocolAPIKeyHashLen + 23 // [api_key_hash:16][commit_id:20][priority:1][job_name_len:1][snap_id_len:1]
	ProtocolMinQueueJobWithTracking = ProtocolAPIKeyHashLen + 23 // [api_key_hash:16][commit_id:20][priority:1][job_name_len:1][tracking_len:2]
	ProtocolMinQueueJobWithNote     = ProtocolAPIKeyHashLen + 26 // [api_key_hash:16][commit_id:20][priority:1][job_name_len:1][args_len:2][note_len:2][force:1]
	ProtocolMinQueueJobWithArgs     = ProtocolAPIKeyHashLen + 24 // [api_key_hash:16][commit_id:20][priority:1][job_name_len:1][args_len:2][force:1]
	ProtocolMinAnnotateRun          = ProtocolAPIKeyHashLen + 20 // [api_key_hash:16][job_name_len:1][author_len:1][note_len:2]
	ProtocolMinSetRunNarrative      = ProtocolAPIKeyHashLen + 20 // [api_key_hash:16][job_name_len:1][patch_len:2]

	// Logs and debug minimum payload sizes
	ProtocolMinGetLogs     = ProtocolAPIKeyHashLen + 1 // [api_key_hash:16][target_id_len:1]
	ProtocolMinStreamLogs  = ProtocolAPIKeyHashLen + 1 // [api_key_hash:16][target_id_len:1]
	ProtocolMinAttachDebug = ProtocolAPIKeyHashLen + 1 // [api_key_hash:16][target_id_len:1]

	// Permission constants
	PermJobsCreate     = "jobs:create"
	PermJobsRead       = "jobs:read"
	PermJobsUpdate     = "jobs:update"
	PermDatasetsRead   = "datasets:read"
	PermDatasetsCreate = "datasets:create"
	PermJupyterManage  = "jupyter:manage"
	PermJupyterRead    = "jupyter:read"
)
