namespace py pangramia.yt.common
namespace java com.pangramia.yt.common

typedef string JobID
typedef string Timestamp 


/**
 * Standard error codes for service exceptions.
 */
enum ErrorCode {
    UNKNOWN = 0,
    NOT_IMPLEMENTED = 1,
    INTERNAL_ERROR = 2,
    INVALID_REQUEST = 3,
    PROXY_UNAVAILABLE = 4,
    ACCOUNT_UNAVAILABLE = 5,
    BOT_DETECTED = 6,
    BOT_DETECTION_SIGN_IN_REQUIRED = 7,
    SABR_STREAMING_DETECTED = 8
}


enum JobState {
    SUCCESS,
    FAIL, 
    BOT_FORBIDDEN_ON_URL_ACCESS,
    BOT_FORBIDDEN_ON_FILE_DOWNLOAD,
    BOT_CAPTCHA,
    BOT_AUTH_RELOGIN_REQUIRED,
    BOT_AUTH_SMS_REQUIRED,
    BOT_AUTH_DEVICE_QR_REQUIRED,    
    BOT_ACCOUNT_BANNED,
    BOT_IP_BANNED
}
 
struct JobTokenData {
    1: optional string infoJson,
    2: optional string ytdlpCommand,
    3: optional string socks,
    4: optional JobID jobId,
    5: optional string url,
    6: optional string cookiesBlob,
    7: optional string requestSummary,
    8: optional list<string> communicationLogPaths,
    9: optional string serverVersionInfo,
}


enum TokenUpdateMode {
    AUTOREFRESH_AND_REMAIN_ANONYMOUS,
    AUTOREFRESH_AND_ALLOW_AUTH,
    AUTOREFRESH_AND_ONLY_AUTH,
    CLEANUP_THEN_AUTOREFRESH_AND_ONLY_AUTH,
    CLEANUP_THEN_AUTOREFRESH_AND_REMAIN_ANONYMOUS,    
    CLEANUP_THEN_AUTOREFRESH_AND_ALLOW_AUTH,
    AUTO,//   AUTOREFRESH_AND_ONLY_AUTH,
}


struct AccountData {
    1: required string username,
    2: required string password,
    3: optional string countryCode
}

struct ProxyData {
    1: required string proxyUrl,
    2: optional string countryCode
}

 
enum AccountPairState {
    ACTIVE,
    PAUSED,
    REMOVED,
    IN_PROGRESS,
    ALL
}


struct AccountPairWithState {
    1: required string accountId,
    2: required string proxyId,
    3: optional AccountPairState accountPairState
    4: optional string machineId,
}

struct JobData {
    1: required string jobId,
    2: required string url,
    3: required string cookiesBlob,
    4: required string potoken,
    5: required string visitorId,
    6: required string ytdlpCommand,
    7: required string createdTime,
    8: required map<string,string> telemetry,
    9: required JobState state,
    10: optional string errorMessage,
    11: optional string socks5Id
}

struct RichCollectionPagination {
    1: required bool hasNext,
    2: required i32 totalCount,
    3: required i32 page,
    4: required i32 pageSize
}

struct RichCollectionJobData {
    1: required list<JobData> items,
    2: required RichCollectionPagination pagination
}

struct ProxyStatus {
    1: string proxyUrl,
    2: string status,
    3: i64 successCount,
    4: i64 failureCount,
    5: optional string lastFailureTimestamp,
    6: optional string lastSuccessTimestamp,
    7: optional string serverIdentity
}

struct AccountStatus {
    1: string accountId,
    2: string status,
    3: i64 successCount,
    4: i64 failureCount,
    5: optional string lastFailureTimestamp,
    6: optional string lastSuccessTimestamp,
    7: optional string lastUsedProxy,
    8: optional string lastUsedMachine
}

struct AirflowLogContext {
    1: optional string logS3Path,
    2: optional string dagId,
    3: optional string runId,
    4: optional string taskId,
    5: optional i32 tryNumber,
    6: optional string workerHostname,
    7: optional string queue
}

