import * as thrift from "@creditkarma/thrift-server-core" ; import * as ClientId from "./ClientId" ; import * as RequestContext from "./RequestContext" ; import * as Delegation from "./Delegation" ; export interface IRequestHeader { trace_id ? : thrift . Int64 ; span_id ? : thrift . Int64 ; parent_span_id ? : thrift . Int64 ; sampled ? : boolean ; client_id ? : ClientId . IClientId ; flags ? : thrift . Int64 ; contexts ? : Array < RequestContext . IRequestContext > ; dest ? : string ; delegations ? : Array < Delegation . IDelegation > ; } export interface IRequestHeaderArgs { trace_id ? : number | string | thrift . Int64 ; span_id ? : number | string | thrift . Int64 ; parent_span_id ? : number | string | thrift . Int64 ; sampled ? : boolean ; client_id ? : ClientId . IClientIdArgs ; flags ? : number | string | thrift . Int64 ; contexts ? : Array < RequestContext . IRequestContextArgs > ; dest ? : string ; delegations ? : Array < Delegation . IDelegationArgs > ; } export const RequestHeaderCodec = { encode ( args , output ) { const obj = { trace_id : ( typeof args . trace_id === "number" ? new thrift . Int64 ( args . trace_id ) : typeof args . trace_id === "string" ? thrift . Int64 . fromDecimalString ( args . trace_id ) : args . trace_id ) , span_id : ( typeof args . span_id === "number" ? new thrift . Int64 ( args . span_id ) : typeof args . span_id === "string" ? thrift . Int64 . fromDecimalString ( args . span_id ) : args . span_id ) , parent_span_id : ( typeof args . parent_span_id === "number" ? new thrift . Int64 ( args . parent_span_id ) : typeof args . parent_span_id === "string" ? thrift . Int64 . fromDecimalString ( args . parent_span_id ) : args . parent_span_id ) , sampled : args . sampled , client_id : args . client_id , flags : ( typeof args . flags === "number" ? new thrift . Int64 ( args . flags ) : typeof args . flags === "string" ? thrift . Int64 . fromDecimalString ( args . flags ) : args . flags ) , contexts : args . contexts , dest : args . dest , delegations : args . delegations } ; output . writeStructBegin ( "RequestHeader" ) ; if ( obj . trace_id != null ) { output . writeFieldBegin ( "trace_id" , thrift . TType . I64 , 1 ) ; output . writeI64 ( ( typeof obj . trace_id === "number" ? new thrift . Int64 ( obj . trace_id ) : typeof obj . trace_id === "string" ? thrift . Int64 . fromDecimalString ( obj . trace_id ) : obj . trace_id ) ) ; output . writeFieldEnd ( ) ; } if ( obj . span_id != null ) { output . writeFieldBegin ( "span_id" , thrift . TType . I64 , 2 ) ; output . writeI64 ( ( typeof obj . span_id === "number" ? new thrift . Int64 ( obj . span_id ) : typeof obj . span_id === "string" ? thrift . Int64 . fromDecimalString ( obj . span_id ) : obj . span_id ) ) ; output . writeFieldEnd ( ) ; } if ( obj . parent_span_id != null ) { output . writeFieldBegin ( "parent_span_id" , thrift . TType . I64 , 3 ) ; output . writeI64 ( ( typeof obj . parent_span_id === "number" ? new thrift . Int64 ( obj . parent_span_id ) : typeof obj . parent_span_id === "string" ? thrift . Int64 . fromDecimalString ( obj . parent_span_id ) : obj . parent_span_id ) ) ; output . writeFieldEnd ( ) ; } if ( obj . sampled != null ) { output . writeFieldBegin ( "sampled" , thrift . TType . BOOL , 5 ) ; output . writeBool ( obj . sampled ) ; output . writeFieldEnd ( ) ; } if ( obj . client_id != null ) { output . writeFieldBegin ( "client_id" , thrift . TType . STRUCT , 6 ) ; ClientId . ClientIdCodec . encode ( obj . client_id , output ) ; output . writeFieldEnd ( ) ; } if ( obj . flags != null ) { output . writeFieldBegin ( "flags" , thrift . TType . I64 , 7 ) ; output . writeI64 ( ( typeof obj . flags === "number" ? new thrift . Int64 ( obj . flags ) : typeof obj . flags === "string" ? thrift . Int64 . fromDecimalString ( obj . flags ) : obj . flags ) ) ; output . writeFieldEnd ( ) ; } if ( obj . contexts != null ) { output . writeFieldBegin ( "contexts" , thrift . TType . LIST , 8 ) ; output . writeListBegin ( thrift . TType . STRUCT , obj . contexts . length ) ; obj . contexts . forEach ( ( value_1 ) : void => { RequestContext . RequestContextCodec . encode ( value_1 , output ) ; } ) ; output . writeListEnd ( ) ; output . writeFieldEnd ( ) ; } if ( obj . dest != null ) { output . writeFieldBegin ( "dest" , thrift . TType . STRING , 9 ) ; output . writeString ( obj . dest ) ; output . writeFieldEnd ( ) ; } if ( obj . delegations != null ) { output . writeFieldBegin ( "delegations" , thrift . TType . LIST , 10 ) ; output . writeListBegin ( thrift . TType . STRUCT , obj . delegations . length ) ; obj . delegations . forEach ( ( value_2 ) : void => { Delegation . DelegationCodec . encode ( value_2 , output ) ; } ) ; output . writeListEnd ( ) ; output . writeFieldEnd ( ) ; } output . writeFieldStop ( ) ; output . writeStructEnd ( ) ; return ; } , decode ( input ) { let _args = { } ; input . readStructBegin ( ) ; while ( true ) { const ret = input . readFieldBegin ( ) ; const fieldType = ret . fieldType ; const fieldId = ret . fieldId ; if ( fieldType === thrift . TType . STOP ) { break ; } switch ( fieldId ) { case 1 : if ( fieldType === thrift . TType . I64 ) { const value_3 = input . readI64 ( ) ; _args . trace_id = value_3 ; } else { input . skip ( fieldType ) ; } break ; case 2 : if ( fieldType === thrift . TType . I64 ) { const value_4 = input . readI64 ( ) ; _args . span_id = value_4 ; } else { input . skip ( fieldType ) ; } break ; case 3 : if ( fieldType === thrift . TType . I64 ) { const value_5 = input . readI64 ( ) ; _args . parent_span_id = value_5 ; } else { input . skip ( fieldType ) ; } break ; case 5 : if ( fieldType === thrift . TType . BOOL ) { const value_6 = input . readBool ( ) ; _args . sampled = value_6 ; } else { input . skip ( fieldType ) ; } break ; case 6 : if ( fieldType === thrift . TType . STRUCT ) { const value_7 = ClientId . ClientIdCodec . decode ( input ) ; _args . client_id = value_7 ; } else { input . skip ( fieldType ) ; } break ; case 7 : if ( fieldType === thrift . TType . I64 ) { const value_8 = input . readI64 ( ) ; _args . flags = value_8 ; } else { input . skip ( fieldType ) ; } break ; case 8 : if ( fieldType === thrift . TType . LIST ) { const value_9 = new Array < RequestContext . IRequestContext > ( ) ; const metadata_1 = input . readListBegin ( ) ; const size_1 = metadata_1 . size ; for ( let i_1 = 0 ; i_1 < size_1 ; i_1 ++ ) { const value_10 = RequestContext . RequestContextCodec . decode ( input ) ; value_9 . push ( value_10 ) ; } input . readListEnd ( ) ; _args . contexts = value_9 ; } else { input . skip ( fieldType ) ; } break ; case 9 : if ( fieldType === thrift . TType . STRING ) { const value_11 = input . readString ( ) ; _args . dest = value_11 ; } else { input . skip ( fieldType ) ; } break ; case 10 : if ( fieldType === thrift . TType . LIST ) { const value_12 = new Array < Delegation . IDelegation > ( ) ; const metadata_2 = input . readListBegin ( ) ; const size_2 = metadata_2 . size ; for ( let i_2 = 0 ; i_2 < size_2 ; i_2 ++ ) { const value_13 = Delegation . DelegationCodec . decode ( input ) ; value_12 . push ( value_13 ) ; } input . readListEnd ( ) ; _args . delegations = value_12 ; } else { input . skip ( fieldType ) ; } break ; default : { input . skip ( fieldType ) ; } } input . readFieldEnd ( ) ; } input . readStructEnd ( ) ; return { trace_id : _args . trace_id , span_id : _args . span_id , parent_span_id : _args . parent_span_id , sampled : _args . sampled , client_id : _args . client_id , flags : _args . flags , contexts : _args . contexts , dest : _args . dest , delegations : _args . delegations } ; } } ; export class RequestHeader extends thrift . StructLike implements IRequestHeader { public trace_id ? : thrift . Int64 ; public span_id ? : thrift . Int64 ; public parent_span_id ? : thrift . Int64 ; public sampled ? : boolean ; public client_id ? : ClientId . IClientId ; public flags ? : thrift . Int64 ; public contexts ? : Array < RequestContext . IRequestContext > ; public dest ? : string ; public delegations ? : Array < Delegation . IDelegation > ; public readonly _annotations : thrift . IThriftAnnotations = { } ; public readonly _fieldAnnotations : thrift . IFieldAnnotations = { } ; constructor ( args = { } ) { super ( ) ; if ( args . trace_id != null ) { const value_14 = ( typeof args . trace_id === "number" ? new thrift . Int64 ( args . trace_id ) : typeof args . trace_id === "string" ? thrift . Int64 . fromDecimalString ( args . trace_id ) : args . trace_id ) ; this . trace_id = value_14 ; } if ( args . span_id != null ) { const value_15 = ( typeof args . span_id === "number" ? new thrift . Int64 ( args . span_id ) : typeof args . span_id === "string" ? thrift . Int64 . fromDecimalString ( args . span_id ) : args . span_id ) ; this . span_id = value_15 ; } if ( args . parent_span_id != null ) { const value_16 = ( typeof args . parent_span_id === "number" ? new thrift . Int64 ( args . parent_span_id ) : typeof args . parent_span_id === "string" ? thrift . Int64 . fromDecimalString ( args . parent_span_id ) : args . parent_span_id ) ; this . parent_span_id = value_16 ; } if ( args . sampled != null ) { const value_17 = args . sampled ; this . sampled = value_17 ; } if ( args . client_id != null ) { const value_18 = new ClientId . ClientId ( args . client_id ) ; this . client_id = value_18 ; } if ( args . flags != null ) { const value_19 = ( typeof args . flags === "number" ? new thrift . Int64 ( args . flags ) : typeof args . flags === "string" ? thrift . Int64 . fromDecimalString ( args . flags ) : args . flags ) ; this . flags = value_19 ; } if ( args . contexts != null ) { const value_20 = new Array < RequestContext . IRequestContext > ( ) ; args . contexts . forEach ( ( value_23 ) : void => { const value_24 = new RequestContext . RequestContext ( value_23 ) ; value_20 . push ( value_24 ) ; } ) ; this . contexts = value_20 ; } if ( args . dest != null ) { const value_21 = args . dest ; this . dest = value_21 ; } if ( args . delegations != null ) { const value_22 = new Array < Delegation . IDelegation > ( ) ; args . delegations . forEach ( ( value_25 ) : void => { const value_26 = new Delegation . Delegation ( value_25 ) ; value_22 . push ( value_26 ) ; } ) ; this . delegations = value_22 ; } } public static read ( input ) { return new RequestHeader ( RequestHeaderCodec . decode ( input ) ) ; } public static write ( args , output ) { return RequestHeaderCodec . encode ( args , output ) ; } public write ( output ) { return RequestHeaderCodec . encode ( this , output ) ; } }