package Ġtools . observation . client Ċ Ċ import Ġcom . google . protobuf . Message Ċ import Ġcom . google . protobuf . Timestamp Ċ import Ġjava . time . Duration Ċ import Ġjava . time . Instant Ċ import Ġjava . util .* Ċ Ċ fun ĠMessage . to Base 6 4 (): ĠString Ġ{ ĊĠĠĠ Ġreturn ĠBase 6 4 . get Encoder (). encode ToString ( toByteArray ()) Ċ } Ċ Ċ fun Ġ< T Ġ: ĠMessage > ĠString . base 6 4 To Proto ( proto : ĠT ): ĠT Ġ{ ĊĠĠĠ Ġ@ Suppress (" UN CHECK ED _ CAST ") ĊĠĠĠ Ġreturn Ġproto . parser ForType . parseFrom ( Base 6 4 . get Decoder (). decode ( this )) Ġas ĠT Ċ } Ċ Ċ fun ĠMessage . to Base 6 4 Url Safe (): ĠString Ġ{ ĊĠĠĠ Ġreturn ĠBase 6 4 . getUrl Encoder (). encode ToString ( toByteArray ()) Ċ } Ċ Ċ fun Ġ< T Ġ: ĠMessage > ĠString . base 6 4 Url Safe To Proto ( proto : ĠT ): ĠT Ġ{ ĊĠĠĠ Ġ@ Suppress (" UN CHECK ED _ CAST ") ĊĠĠĠ Ġreturn Ġproto . parser ForType . parseFrom ( Base 6 4 . getUrl Decoder (). decode ( this )) Ġas ĠT Ċ Ċ } Ċ Ċ fun ĠTimestamp . to Instant (): ĠInstant Ġ{ ĊĠĠĠ Ġreturn ĠInstant . of Epoch Second ( seconds , Ġnan os . to Long ()) Ċ } Ċ Ċ fun ĠInstant . to Proto (): ĠTimestamp Ġ{ ĊĠĠĠ Ġreturn ĠTimestamp . newBuilder (). set Seconds ( epoch Second ). set Nan os ( nano ). build () Ċ } Ċ Ċ fun Ġcom . google . protobuf . Duration . to Java (): ĠDuration Ġ{ ĊĠĠĠ Ġreturn ĠDuration . of Seconds ( seconds ) Ċ } Ċ Ċ fun ĠDuration . to Proto (): Ġcom . google . protobuf . Duration Ġ{ ĊĠĠĠ Ġreturn Ġcom . google . protobuf . Duration . newBuilder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Seconds ( seconds ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Nan os ( nano ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () Ċ } Ċ