import * as thrift from "@creditkarma/thrift-server-core" ; import * as AnnotationType from "./AnnotationType" ; import * as Endpoint from "./Endpoint" ; export interface IBinaryAnnotation { key ? : string ; value ? : Buffer ; annotation_type ? : AnnotationType . AnnotationType ; host ? : Endpoint . IEndpoint ; } export interface IBinaryAnnotationArgs { key ? : string ; value ? : string | Buffer ; annotation_type ? : AnnotationType . AnnotationType ; host ? : Endpoint . IEndpointArgs ; } export const BinaryAnnotationCodec = { encode ( args , output ) { const obj = { key : args . key , value : ( typeof args . value === "string" ? Buffer . from ( args . value ) : args . value ) , annotation_type : args . annotation_type , host : args . host } ; output . writeStructBegin ( "BinaryAnnotation" ) ; if ( obj . key != null ) { output . writeFieldBegin ( "key" , thrift . TType . STRING , 1 ) ; output . writeString ( obj . key ) ; output . writeFieldEnd ( ) ; } if ( obj . value != null ) { output . writeFieldBegin ( "value" , thrift . TType . STRING , 2 ) ; output . writeBinary ( obj . value ) ; output . writeFieldEnd ( ) ; } if ( obj . annotation_type != null ) { output . writeFieldBegin ( "annotation_type" , thrift . TType . I32 , 3 ) ; output . writeI32 ( obj . annotation_type ) ; output . writeFieldEnd ( ) ; } if ( obj . host != null ) { output . writeFieldBegin ( "host" , thrift . TType . STRUCT , 4 ) ; Endpoint . EndpointCodec . encode ( obj . host , output ) ; 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 . STRING ) { const value_1 = input . readString ( ) ; _args . key = value_1 ; } else { input . skip ( fieldType ) ; } break ; case 2 : if ( fieldType === thrift . TType . STRING ) { const value_2 = input . readBinary ( ) ; _args . value = value_2 ; } else { input . skip ( fieldType ) ; } break ; case 3 : if ( fieldType === thrift . TType . I32 ) { const value_3 = input . readI32 ( ) ; _args . annotation_type = value_3 ; } else { input . skip ( fieldType ) ; } break ; case 4 : if ( fieldType === thrift . TType . STRUCT ) { const value_4 = Endpoint . EndpointCodec . decode ( input ) ; _args . host = value_4 ; } else { input . skip ( fieldType ) ; } break ; default : { input . skip ( fieldType ) ; } } input . readFieldEnd ( ) ; } input . readStructEnd ( ) ; return { key : _args . key , value : _args . value , annotation_type : _args . annotation_type , host : _args . host } ; } } ; export class BinaryAnnotation extends thrift . StructLike implements IBinaryAnnotation { public key ? : string ; public value ? : Buffer ; public annotation_type ? : AnnotationType . AnnotationType ; public host ? : Endpoint . IEndpoint ; public readonly _annotations : thrift . IThriftAnnotations = { } ; public readonly _fieldAnnotations : thrift . IFieldAnnotations = { } ; constructor ( args = { } ) { super ( ) ; if ( args . key != null ) { const value_5 = args . key ; this . key = value_5 ; } if ( args . value != null ) { const value_6 = ( typeof args . value === "string" ? Buffer . from ( args . value ) : args . value ) ; this . value = value_6 ; } if ( args . annotation_type != null ) { const value_7 = args . annotation_type ; this . annotation_type = value_7 ; } if ( args . host != null ) { const value_8 = new Endpoint . Endpoint ( args . host ) ; this . host = value_8 ; } } public static read ( input ) { return new BinaryAnnotation ( BinaryAnnotationCodec . decode ( input ) ) ; } public static write ( args , output ) { return BinaryAnnotationCodec . encode ( args , output ) ; } public write ( output ) { return BinaryAnnotationCodec . encode ( this , output ) ; } }