namespace py pangramia.yt.tokens_ops
namespace java com.pangramia.yt.tokens_ops

include "../data/common.thrift"
include "../data/exceptions.thrift"
include "yt_management.thrift"

// The unified service that combines token operations and management functions.
// The server implementation will decide which functions are active based on its role.
service YTTokenOpService extends yt_management.YTManagementService {

    common.JobTokenData      getOrRefreshTokenWithReport ( 1: string accountId,
                                                           2: string oldUrl, 
                                                           3: common.JobState status, 
                                                           4: optional string details, 
                                                           5: optional string jobId,
                                                           6: optional common.TokenUpdateMode updateType = common.TokenUpdateMode.AUTO,
                                                           7: optional string url,
                                                           8: optional string clients,
                                                           9: optional common.AirflowLogContext airflowLogContext,
                                                           10: optional string requestParamsJson) throws (1: exceptions.PBServiceException serviceExp,
                                                                                               2: exceptions.PBUserException userExp)

    common.JobTokenData      getOrRefreshToken ( 1: string accountId,
                                                 2: optional common.TokenUpdateMode updateType = common.TokenUpdateMode.AUTO,
                                                 3: optional string url,
                                                 4: optional string clients,
                                                 5: optional string machineId,
                                                 6: optional common.AirflowLogContext airflowLogContext,
                                                 7: optional string requestParamsJson,
                                                 8: optional string assignedProxyUrl) throws (1: exceptions.PBServiceException serviceExp,
                                                                                       2: exceptions.PBUserException userExp)

    common.JobTokenData      getLatestToken (1: string accountId) throws (1: exceptions.PBServiceException serviceExp,
                                                                          2: exceptions.PBUserException userExp),
    common.JobTokenData      refreshToken ( 1: string accountId,
                                            2: optional common.TokenUpdateMode updateType = common.TokenUpdateMode.AUTO,
                                            3: optional string url ) throws (1: exceptions.PBServiceException serviceExp,
                                                                             2: exceptions.PBUserException userExp)
    bool reportState(  1: string url, 
                       2: common.JobState status, 
                       3: optional string details, 
                       4: optional string jobId) throws (1: exceptions.PBServiceException serviceExp,
                                                         2: exceptions.PBUserException userExp)

    // New method for direct info.json generation, bypassing Node.js token generation.
    common.JobTokenData getInfoJsonDirect(1: string url, 
                                          2: optional string clients) throws (1: exceptions.PBServiceException serviceExp, 
                                                                              2: exceptions.PBUserException userExp)
}
