kubecost_codecs.go 207 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // DO NOT MODIFY
  4. //
  5. // ┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
  6. //
  7. //
  8. // This source file was automatically generated by bingen.
  9. //
  10. ////////////////////////////////////////////////////////////////////////////////
  11. package kubecost
  12. import (
  13. "fmt"
  14. "reflect"
  15. "strings"
  16. "sync"
  17. "time"
  18. util "github.com/opencost/opencost/pkg/util"
  19. )
  20. const (
  21. // GeneratorPackageName is the package the generator is targetting
  22. GeneratorPackageName string = "kubecost"
  23. )
  24. // BinaryTags represent the formatting tag used for specific optimization features
  25. const (
  26. // BinaryTagStringTable is written and/or read prior to the existence of a string
  27. // table (where each index is encoded as a string entry in the resource
  28. BinaryTagStringTable string = "BGST"
  29. )
  30. const (
  31. // DefaultCodecVersion is used for any resources listed in the Default version set
  32. DefaultCodecVersion uint8 = 15
  33. // AssetsCodecVersion is used for any resources listed in the Assets version set
  34. AssetsCodecVersion uint8 = 15
  35. // AllocationCodecVersion is used for any resources listed in the Allocation version set
  36. AllocationCodecVersion uint8 = 15
  37. // AuditCodecVersion is used for any resources listed in the Audit version set
  38. AuditCodecVersion uint8 = 1
  39. )
  40. //--------------------------------------------------------------------------
  41. // Type Map
  42. //--------------------------------------------------------------------------
  43. // Generated type map for resolving interface implementations to
  44. // to concrete types
  45. var typeMap map[string]reflect.Type = map[string]reflect.Type{
  46. "AggAudit": reflect.TypeOf((*AggAudit)(nil)).Elem(),
  47. "Allocation": reflect.TypeOf((*Allocation)(nil)).Elem(),
  48. "AllocationProperties": reflect.TypeOf((*AllocationProperties)(nil)).Elem(),
  49. "AllocationReconciliationAudit": reflect.TypeOf((*AllocationReconciliationAudit)(nil)).Elem(),
  50. "AllocationSet": reflect.TypeOf((*AllocationSet)(nil)).Elem(),
  51. "AllocationSetRange": reflect.TypeOf((*AllocationSetRange)(nil)).Elem(),
  52. "Any": reflect.TypeOf((*Any)(nil)).Elem(),
  53. "AssetProperties": reflect.TypeOf((*AssetProperties)(nil)).Elem(),
  54. "AssetReconciliationAudit": reflect.TypeOf((*AssetReconciliationAudit)(nil)).Elem(),
  55. "AssetSet": reflect.TypeOf((*AssetSet)(nil)).Elem(),
  56. "AssetSetRange": reflect.TypeOf((*AssetSetRange)(nil)).Elem(),
  57. "AuditFloatResult": reflect.TypeOf((*AuditFloatResult)(nil)).Elem(),
  58. "AuditMissingValue": reflect.TypeOf((*AuditMissingValue)(nil)).Elem(),
  59. "AuditSet": reflect.TypeOf((*AuditSet)(nil)).Elem(),
  60. "AuditSetRange": reflect.TypeOf((*AuditSetRange)(nil)).Elem(),
  61. "Breakdown": reflect.TypeOf((*Breakdown)(nil)).Elem(),
  62. "Cloud": reflect.TypeOf((*Cloud)(nil)).Elem(),
  63. "ClusterManagement": reflect.TypeOf((*ClusterManagement)(nil)).Elem(),
  64. "Disk": reflect.TypeOf((*Disk)(nil)).Elem(),
  65. "EqualityAudit": reflect.TypeOf((*EqualityAudit)(nil)).Elem(),
  66. "LoadBalancer": reflect.TypeOf((*LoadBalancer)(nil)).Elem(),
  67. "Network": reflect.TypeOf((*Network)(nil)).Elem(),
  68. "Node": reflect.TypeOf((*Node)(nil)).Elem(),
  69. "PVAllocation": reflect.TypeOf((*PVAllocation)(nil)).Elem(),
  70. "PVKey": reflect.TypeOf((*PVKey)(nil)).Elem(),
  71. "RawAllocationOnlyData": reflect.TypeOf((*RawAllocationOnlyData)(nil)).Elem(),
  72. "SharedAsset": reflect.TypeOf((*SharedAsset)(nil)).Elem(),
  73. "TotalAudit": reflect.TypeOf((*TotalAudit)(nil)).Elem(),
  74. "Window": reflect.TypeOf((*Window)(nil)).Elem(),
  75. }
  76. //--------------------------------------------------------------------------
  77. // Type Helpers
  78. //--------------------------------------------------------------------------
  79. // isBinaryTag returns true when the first bytes in the provided binary matches the tag
  80. func isBinaryTag(data []byte, tag string) bool {
  81. return string(data[:len(tag)]) == tag
  82. }
  83. // appendBytes combines a and b into a new byte array
  84. func appendBytes(a []byte, b []byte) []byte {
  85. al := len(a)
  86. bl := len(b)
  87. tl := al + bl
  88. // allocate a new byte array for the combined
  89. // use native copy for speedy byte copying
  90. result := make([]byte, tl, tl)
  91. copy(result, a)
  92. copy(result[al:], b)
  93. return result
  94. }
  95. // typeToString determines the basic properties of the type, the qualifier, package path, and
  96. // type name, and returns the qualified type
  97. func typeToString(f interface{}) string {
  98. qual := ""
  99. t := reflect.TypeOf(f)
  100. if t.Kind() == reflect.Ptr {
  101. t = t.Elem()
  102. qual = "*"
  103. }
  104. return fmt.Sprintf("%s%s.%s", qual, t.PkgPath(), t.Name())
  105. }
  106. // resolveType uses the name of a type and returns the package, base type name, and whether
  107. // or not it's a pointer.
  108. func resolveType(t string) (pkg string, name string, isPtr bool) {
  109. isPtr = t[:1] == "*"
  110. if isPtr {
  111. t = t[1:]
  112. }
  113. slashIndex := strings.LastIndex(t, "/")
  114. if slashIndex >= 0 {
  115. t = t[slashIndex+1:]
  116. }
  117. parts := strings.Split(t, ".")
  118. if parts[0] == GeneratorPackageName {
  119. parts[0] = ""
  120. }
  121. pkg = parts[0]
  122. name = parts[1]
  123. return
  124. }
  125. //--------------------------------------------------------------------------
  126. // StringTable
  127. //--------------------------------------------------------------------------
  128. // StringTable maps strings to specific indices for encoding
  129. type StringTable struct {
  130. l *sync.Mutex
  131. indices map[string]int
  132. next int
  133. }
  134. // NewStringTable Creates a new StringTable instance with provided contents
  135. func NewStringTable(contents ...string) *StringTable {
  136. st := &StringTable{
  137. l: new(sync.Mutex),
  138. indices: make(map[string]int),
  139. next: len(contents),
  140. }
  141. for i, entry := range contents {
  142. st.indices[entry] = i
  143. }
  144. return st
  145. }
  146. // AddOrGet atomically retrieves a string entry's index if it exist. Otherwise, it will
  147. // add the entry and return the index.
  148. func (st *StringTable) AddOrGet(s string) int {
  149. st.l.Lock()
  150. defer st.l.Unlock()
  151. if ind, ok := st.indices[s]; ok {
  152. return ind
  153. }
  154. current := st.next
  155. st.next++
  156. st.indices[s] = current
  157. return current
  158. }
  159. // ToSlice Converts the contents to a string array for encoding.
  160. func (st *StringTable) ToSlice() []string {
  161. st.l.Lock()
  162. defer st.l.Unlock()
  163. if st.next == 0 {
  164. return []string{}
  165. }
  166. sl := make([]string, st.next, st.next)
  167. for s, i := range st.indices {
  168. sl[i] = s
  169. }
  170. return sl
  171. }
  172. // ToBytes Converts the contents to a binary encoded representation
  173. func (st *StringTable) ToBytes() []byte {
  174. buff := util.NewBuffer()
  175. buff.WriteBytes([]byte(BinaryTagStringTable)) // bingen table header
  176. strs := st.ToSlice()
  177. buff.WriteInt(len(strs)) // table length
  178. for _, s := range strs {
  179. buff.WriteString(s)
  180. }
  181. return buff.Bytes()
  182. }
  183. //--------------------------------------------------------------------------
  184. // Codec Context
  185. //--------------------------------------------------------------------------
  186. // EncodingContext is a context object passed to the encoders to ensure reuse of buffer
  187. // and table data
  188. type EncodingContext struct {
  189. Buffer *util.Buffer
  190. Table *StringTable
  191. }
  192. // IsStringTable returns true if the table is available
  193. func (ec *EncodingContext) IsStringTable() bool {
  194. return ec.Table != nil
  195. }
  196. // DecodingContext is a context object passed to the decoders to ensure parent objects
  197. // reuse as much data as possible
  198. type DecodingContext struct {
  199. Buffer *util.Buffer
  200. Table []string
  201. }
  202. // IsStringTable returns true if the table is available
  203. func (dc *DecodingContext) IsStringTable() bool {
  204. return len(dc.Table) > 0
  205. }
  206. //--------------------------------------------------------------------------
  207. // Binary Codec
  208. //--------------------------------------------------------------------------
  209. // BinEncoder is an encoding interface which defines a context based marshal contract.
  210. type BinEncoder interface {
  211. MarshalBinaryWithContext(*EncodingContext) error
  212. }
  213. // BinDecoder is a decoding interface which defines a context based unmarshal contract.
  214. type BinDecoder interface {
  215. UnmarshalBinaryWithContext(*DecodingContext) error
  216. }
  217. //--------------------------------------------------------------------------
  218. // AggAudit
  219. //--------------------------------------------------------------------------
  220. // MarshalBinary serializes the internal properties of this AggAudit instance
  221. // into a byte array
  222. func (target *AggAudit) MarshalBinary() (data []byte, err error) {
  223. ctx := &EncodingContext{
  224. Buffer: util.NewBuffer(),
  225. Table: nil,
  226. }
  227. e := target.MarshalBinaryWithContext(ctx)
  228. if e != nil {
  229. return nil, e
  230. }
  231. encBytes := ctx.Buffer.Bytes()
  232. return encBytes, nil
  233. }
  234. // MarshalBinaryWithContext serializes the internal properties of this AggAudit instance
  235. // into a byte array leveraging a predefined context.
  236. func (target *AggAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  237. // panics are recovered and propagated as errors
  238. defer func() {
  239. if r := recover(); r != nil {
  240. if e, ok := r.(error); ok {
  241. err = e
  242. } else if s, ok := r.(string); ok {
  243. err = fmt.Errorf("Unexpected panic: %s", s)
  244. } else {
  245. err = fmt.Errorf("Unexpected panic: %+v", r)
  246. }
  247. }
  248. }()
  249. buff := ctx.Buffer
  250. buff.WriteUInt8(AuditCodecVersion) // version
  251. // --- [begin][write][alias](AuditStatus) ---
  252. if ctx.IsStringTable() {
  253. a := ctx.Table.AddOrGet(string(target.Status))
  254. buff.WriteInt(a) // write table index
  255. } else {
  256. buff.WriteString(string(target.Status)) // write string
  257. }
  258. // --- [end][write][alias](AuditStatus) ---
  259. if ctx.IsStringTable() {
  260. b := ctx.Table.AddOrGet(target.Description)
  261. buff.WriteInt(b) // write table index
  262. } else {
  263. buff.WriteString(target.Description) // write string
  264. }
  265. // --- [begin][write][reference](time.Time) ---
  266. c, errA := target.LastRun.MarshalBinary()
  267. if errA != nil {
  268. return errA
  269. }
  270. buff.WriteInt(len(c))
  271. buff.WriteBytes(c)
  272. // --- [end][write][reference](time.Time) ---
  273. if target.Results == nil {
  274. buff.WriteUInt8(uint8(0)) // write nil byte
  275. } else {
  276. buff.WriteUInt8(uint8(1)) // write non-nil byte
  277. // --- [begin][write][map](map[string]map[string]*AuditFloatResult) ---
  278. buff.WriteInt(len(target.Results)) // map length
  279. for v, z := range target.Results {
  280. if ctx.IsStringTable() {
  281. d := ctx.Table.AddOrGet(v)
  282. buff.WriteInt(d) // write table index
  283. } else {
  284. buff.WriteString(v) // write string
  285. }
  286. if z == nil {
  287. buff.WriteUInt8(uint8(0)) // write nil byte
  288. } else {
  289. buff.WriteUInt8(uint8(1)) // write non-nil byte
  290. // --- [begin][write][map](map[string]*AuditFloatResult) ---
  291. buff.WriteInt(len(z)) // map length
  292. for vv, zz := range z {
  293. if ctx.IsStringTable() {
  294. e := ctx.Table.AddOrGet(vv)
  295. buff.WriteInt(e) // write table index
  296. } else {
  297. buff.WriteString(vv) // write string
  298. }
  299. if zz == nil {
  300. buff.WriteUInt8(uint8(0)) // write nil byte
  301. } else {
  302. buff.WriteUInt8(uint8(1)) // write non-nil byte
  303. // --- [begin][write][struct](AuditFloatResult) ---
  304. buff.WriteInt(0) // [compatibility, unused]
  305. errB := zz.MarshalBinaryWithContext(ctx)
  306. if errB != nil {
  307. return errB
  308. }
  309. // --- [end][write][struct](AuditFloatResult) ---
  310. }
  311. }
  312. // --- [end][write][map](map[string]*AuditFloatResult) ---
  313. }
  314. }
  315. // --- [end][write][map](map[string]map[string]*AuditFloatResult) ---
  316. }
  317. if target.MissingValues == nil {
  318. buff.WriteUInt8(uint8(0)) // write nil byte
  319. } else {
  320. buff.WriteUInt8(uint8(1)) // write non-nil byte
  321. // --- [begin][write][slice]([]*AuditMissingValue) ---
  322. buff.WriteInt(len(target.MissingValues)) // array length
  323. for i := 0; i < len(target.MissingValues); i++ {
  324. if target.MissingValues[i] == nil {
  325. buff.WriteUInt8(uint8(0)) // write nil byte
  326. } else {
  327. buff.WriteUInt8(uint8(1)) // write non-nil byte
  328. // --- [begin][write][struct](AuditMissingValue) ---
  329. buff.WriteInt(0) // [compatibility, unused]
  330. errC := target.MissingValues[i].MarshalBinaryWithContext(ctx)
  331. if errC != nil {
  332. return errC
  333. }
  334. // --- [end][write][struct](AuditMissingValue) ---
  335. }
  336. }
  337. // --- [end][write][slice]([]*AuditMissingValue) ---
  338. }
  339. return nil
  340. }
  341. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  342. // the AggAudit type
  343. func (target *AggAudit) UnmarshalBinary(data []byte) error {
  344. var table []string
  345. buff := util.NewBufferFromBytes(data)
  346. // string table header validation
  347. if isBinaryTag(data, BinaryTagStringTable) {
  348. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  349. tl := buff.ReadInt() // table length
  350. if tl > 0 {
  351. table = make([]string, tl, tl)
  352. for i := 0; i < tl; i++ {
  353. table[i] = buff.ReadString()
  354. }
  355. }
  356. }
  357. ctx := &DecodingContext{
  358. Buffer: buff,
  359. Table: table,
  360. }
  361. err := target.UnmarshalBinaryWithContext(ctx)
  362. if err != nil {
  363. return err
  364. }
  365. return nil
  366. }
  367. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  368. // the AggAudit type
  369. func (target *AggAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  370. // panics are recovered and propagated as errors
  371. defer func() {
  372. if r := recover(); r != nil {
  373. if e, ok := r.(error); ok {
  374. err = e
  375. } else if s, ok := r.(string); ok {
  376. err = fmt.Errorf("Unexpected panic: %s", s)
  377. } else {
  378. err = fmt.Errorf("Unexpected panic: %+v", r)
  379. }
  380. }
  381. }()
  382. buff := ctx.Buffer
  383. version := buff.ReadUInt8()
  384. if version > AuditCodecVersion {
  385. return fmt.Errorf("Invalid Version Unmarshaling AggAudit. Expected %d or less, got %d", AuditCodecVersion, version)
  386. }
  387. if uint8(0) /* field version */ <= version {
  388. // --- [begin][read][alias](AuditStatus) ---
  389. var a string
  390. var c string
  391. if ctx.IsStringTable() {
  392. d := buff.ReadInt() // read string index
  393. c = ctx.Table[d]
  394. } else {
  395. c = buff.ReadString() // read string
  396. }
  397. b := c
  398. a = b
  399. target.Status = AuditStatus(a)
  400. // --- [end][read][alias](AuditStatus) ---
  401. } else {
  402. }
  403. if uint8(0) /* field version */ <= version {
  404. var f string
  405. if ctx.IsStringTable() {
  406. g := buff.ReadInt() // read string index
  407. f = ctx.Table[g]
  408. } else {
  409. f = buff.ReadString() // read string
  410. }
  411. e := f
  412. target.Description = e
  413. } else {
  414. target.Description = "" // default
  415. }
  416. if uint8(0) /* field version */ <= version {
  417. // --- [begin][read][reference](time.Time) ---
  418. h := &time.Time{}
  419. k := buff.ReadInt() // byte array length
  420. l := buff.ReadBytes(k) // byte array
  421. errA := h.UnmarshalBinary(l)
  422. if errA != nil {
  423. return errA
  424. }
  425. target.LastRun = *h
  426. // --- [end][read][reference](time.Time) ---
  427. } else {
  428. }
  429. if uint8(0) /* field version */ <= version {
  430. if buff.ReadUInt8() == uint8(0) {
  431. target.Results = nil
  432. } else {
  433. // --- [begin][read][map](map[string]map[string]*AuditFloatResult) ---
  434. n := buff.ReadInt() // map len
  435. m := make(map[string]map[string]*AuditFloatResult, n)
  436. for i := 0; i < n; i++ {
  437. var v string
  438. var p string
  439. if ctx.IsStringTable() {
  440. q := buff.ReadInt() // read string index
  441. p = ctx.Table[q]
  442. } else {
  443. p = buff.ReadString() // read string
  444. }
  445. o := p
  446. v = o
  447. var z map[string]*AuditFloatResult
  448. if buff.ReadUInt8() == uint8(0) {
  449. z = nil
  450. } else {
  451. // --- [begin][read][map](map[string]*AuditFloatResult) ---
  452. s := buff.ReadInt() // map len
  453. r := make(map[string]*AuditFloatResult, s)
  454. for j := 0; j < s; j++ {
  455. var vv string
  456. var u string
  457. if ctx.IsStringTable() {
  458. w := buff.ReadInt() // read string index
  459. u = ctx.Table[w]
  460. } else {
  461. u = buff.ReadString() // read string
  462. }
  463. t := u
  464. vv = t
  465. var zz *AuditFloatResult
  466. if buff.ReadUInt8() == uint8(0) {
  467. zz = nil
  468. } else {
  469. // --- [begin][read][struct](AuditFloatResult) ---
  470. x := &AuditFloatResult{}
  471. buff.ReadInt() // [compatibility, unused]
  472. errB := x.UnmarshalBinaryWithContext(ctx)
  473. if errB != nil {
  474. return errB
  475. }
  476. zz = x
  477. // --- [end][read][struct](AuditFloatResult) ---
  478. }
  479. r[vv] = zz
  480. }
  481. z = r
  482. // --- [end][read][map](map[string]*AuditFloatResult) ---
  483. }
  484. m[v] = z
  485. }
  486. target.Results = m
  487. // --- [end][read][map](map[string]map[string]*AuditFloatResult) ---
  488. }
  489. } else {
  490. target.Results = nil
  491. }
  492. if uint8(0) /* field version */ <= version {
  493. if buff.ReadUInt8() == uint8(0) {
  494. target.MissingValues = nil
  495. } else {
  496. // --- [begin][read][slice]([]*AuditMissingValue) ---
  497. aa := buff.ReadInt() // array len
  498. y := make([]*AuditMissingValue, aa)
  499. for ii := 0; ii < aa; ii++ {
  500. var bb *AuditMissingValue
  501. if buff.ReadUInt8() == uint8(0) {
  502. bb = nil
  503. } else {
  504. // --- [begin][read][struct](AuditMissingValue) ---
  505. cc := &AuditMissingValue{}
  506. buff.ReadInt() // [compatibility, unused]
  507. errC := cc.UnmarshalBinaryWithContext(ctx)
  508. if errC != nil {
  509. return errC
  510. }
  511. bb = cc
  512. // --- [end][read][struct](AuditMissingValue) ---
  513. }
  514. y[ii] = bb
  515. }
  516. target.MissingValues = y
  517. // --- [end][read][slice]([]*AuditMissingValue) ---
  518. }
  519. } else {
  520. target.MissingValues = nil
  521. }
  522. return nil
  523. }
  524. //--------------------------------------------------------------------------
  525. // Allocation
  526. //--------------------------------------------------------------------------
  527. // MarshalBinary serializes the internal properties of this Allocation instance
  528. // into a byte array
  529. func (target *Allocation) MarshalBinary() (data []byte, err error) {
  530. ctx := &EncodingContext{
  531. Buffer: util.NewBuffer(),
  532. Table: nil,
  533. }
  534. e := target.MarshalBinaryWithContext(ctx)
  535. if e != nil {
  536. return nil, e
  537. }
  538. encBytes := ctx.Buffer.Bytes()
  539. return encBytes, nil
  540. }
  541. // MarshalBinaryWithContext serializes the internal properties of this Allocation instance
  542. // into a byte array leveraging a predefined context.
  543. func (target *Allocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  544. // panics are recovered and propagated as errors
  545. defer func() {
  546. if r := recover(); r != nil {
  547. if e, ok := r.(error); ok {
  548. err = e
  549. } else if s, ok := r.(string); ok {
  550. err = fmt.Errorf("Unexpected panic: %s", s)
  551. } else {
  552. err = fmt.Errorf("Unexpected panic: %+v", r)
  553. }
  554. }
  555. }()
  556. buff := ctx.Buffer
  557. buff.WriteUInt8(AllocationCodecVersion) // version
  558. if ctx.IsStringTable() {
  559. a := ctx.Table.AddOrGet(target.Name)
  560. buff.WriteInt(a) // write table index
  561. } else {
  562. buff.WriteString(target.Name) // write string
  563. }
  564. if target.Properties == nil {
  565. buff.WriteUInt8(uint8(0)) // write nil byte
  566. } else {
  567. buff.WriteUInt8(uint8(1)) // write non-nil byte
  568. // --- [begin][write][struct](AllocationProperties) ---
  569. buff.WriteInt(0) // [compatibility, unused]
  570. errA := target.Properties.MarshalBinaryWithContext(ctx)
  571. if errA != nil {
  572. return errA
  573. }
  574. // --- [end][write][struct](AllocationProperties) ---
  575. }
  576. // --- [begin][write][struct](Window) ---
  577. buff.WriteInt(0) // [compatibility, unused]
  578. errB := target.Window.MarshalBinaryWithContext(ctx)
  579. if errB != nil {
  580. return errB
  581. }
  582. // --- [end][write][struct](Window) ---
  583. // --- [begin][write][reference](time.Time) ---
  584. b, errC := target.Start.MarshalBinary()
  585. if errC != nil {
  586. return errC
  587. }
  588. buff.WriteInt(len(b))
  589. buff.WriteBytes(b)
  590. // --- [end][write][reference](time.Time) ---
  591. // --- [begin][write][reference](time.Time) ---
  592. c, errD := target.End.MarshalBinary()
  593. if errD != nil {
  594. return errD
  595. }
  596. buff.WriteInt(len(c))
  597. buff.WriteBytes(c)
  598. // --- [end][write][reference](time.Time) ---
  599. buff.WriteFloat64(target.CPUCoreHours) // write float64
  600. buff.WriteFloat64(target.CPUCoreRequestAverage) // write float64
  601. buff.WriteFloat64(target.CPUCoreUsageAverage) // write float64
  602. buff.WriteFloat64(target.CPUCost) // write float64
  603. buff.WriteFloat64(target.CPUCostAdjustment) // write float64
  604. buff.WriteFloat64(target.GPUHours) // write float64
  605. buff.WriteFloat64(target.GPUCost) // write float64
  606. buff.WriteFloat64(target.GPUCostAdjustment) // write float64
  607. buff.WriteFloat64(target.NetworkTransferBytes) // write float64
  608. buff.WriteFloat64(target.NetworkReceiveBytes) // write float64
  609. buff.WriteFloat64(target.NetworkCost) // write float64
  610. buff.WriteFloat64(target.NetworkCostAdjustment) // write float64
  611. buff.WriteFloat64(target.LoadBalancerCost) // write float64
  612. buff.WriteFloat64(target.LoadBalancerCostAdjustment) // write float64
  613. // --- [begin][write][alias](PVAllocations) ---
  614. if map[PVKey]*PVAllocation(target.PVs) == nil {
  615. buff.WriteUInt8(uint8(0)) // write nil byte
  616. } else {
  617. buff.WriteUInt8(uint8(1)) // write non-nil byte
  618. // --- [begin][write][map](map[PVKey]*PVAllocation) ---
  619. buff.WriteInt(len(map[PVKey]*PVAllocation(target.PVs))) // map length
  620. for v, z := range map[PVKey]*PVAllocation(target.PVs) {
  621. // --- [begin][write][struct](PVKey) ---
  622. buff.WriteInt(0) // [compatibility, unused]
  623. errE := v.MarshalBinaryWithContext(ctx)
  624. if errE != nil {
  625. return errE
  626. }
  627. // --- [end][write][struct](PVKey) ---
  628. if z == nil {
  629. buff.WriteUInt8(uint8(0)) // write nil byte
  630. } else {
  631. buff.WriteUInt8(uint8(1)) // write non-nil byte
  632. // --- [begin][write][struct](PVAllocation) ---
  633. buff.WriteInt(0) // [compatibility, unused]
  634. errF := z.MarshalBinaryWithContext(ctx)
  635. if errF != nil {
  636. return errF
  637. }
  638. // --- [end][write][struct](PVAllocation) ---
  639. }
  640. }
  641. // --- [end][write][map](map[PVKey]*PVAllocation) ---
  642. }
  643. // --- [end][write][alias](PVAllocations) ---
  644. buff.WriteFloat64(target.PVCostAdjustment) // write float64
  645. buff.WriteFloat64(target.RAMByteHours) // write float64
  646. buff.WriteFloat64(target.RAMBytesRequestAverage) // write float64
  647. buff.WriteFloat64(target.RAMBytesUsageAverage) // write float64
  648. buff.WriteFloat64(target.RAMCost) // write float64
  649. buff.WriteFloat64(target.RAMCostAdjustment) // write float64
  650. buff.WriteFloat64(target.SharedCost) // write float64
  651. buff.WriteFloat64(target.ExternalCost) // write float64
  652. if target.RawAllocationOnly == nil {
  653. buff.WriteUInt8(uint8(0)) // write nil byte
  654. } else {
  655. buff.WriteUInt8(uint8(1)) // write non-nil byte
  656. // --- [begin][write][struct](RawAllocationOnlyData) ---
  657. buff.WriteInt(0) // [compatibility, unused]
  658. errG := target.RawAllocationOnly.MarshalBinaryWithContext(ctx)
  659. if errG != nil {
  660. return errG
  661. }
  662. // --- [end][write][struct](RawAllocationOnlyData) ---
  663. }
  664. return nil
  665. }
  666. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  667. // the Allocation type
  668. func (target *Allocation) UnmarshalBinary(data []byte) error {
  669. var table []string
  670. buff := util.NewBufferFromBytes(data)
  671. // string table header validation
  672. if isBinaryTag(data, BinaryTagStringTable) {
  673. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  674. tl := buff.ReadInt() // table length
  675. if tl > 0 {
  676. table = make([]string, tl, tl)
  677. for i := 0; i < tl; i++ {
  678. table[i] = buff.ReadString()
  679. }
  680. }
  681. }
  682. ctx := &DecodingContext{
  683. Buffer: buff,
  684. Table: table,
  685. }
  686. err := target.UnmarshalBinaryWithContext(ctx)
  687. if err != nil {
  688. return err
  689. }
  690. return nil
  691. }
  692. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  693. // the Allocation type
  694. func (target *Allocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  695. // panics are recovered and propagated as errors
  696. defer func() {
  697. if r := recover(); r != nil {
  698. if e, ok := r.(error); ok {
  699. err = e
  700. } else if s, ok := r.(string); ok {
  701. err = fmt.Errorf("Unexpected panic: %s", s)
  702. } else {
  703. err = fmt.Errorf("Unexpected panic: %+v", r)
  704. }
  705. }
  706. }()
  707. buff := ctx.Buffer
  708. version := buff.ReadUInt8()
  709. if version > AllocationCodecVersion {
  710. return fmt.Errorf("Invalid Version Unmarshaling Allocation. Expected %d or less, got %d", AllocationCodecVersion, version)
  711. }
  712. if uint8(0) /* field version */ <= version {
  713. var b string
  714. if ctx.IsStringTable() {
  715. c := buff.ReadInt() // read string index
  716. b = ctx.Table[c]
  717. } else {
  718. b = buff.ReadString() // read string
  719. }
  720. a := b
  721. target.Name = a
  722. } else {
  723. target.Name = "" // default
  724. }
  725. if uint8(0) /* field version */ <= version {
  726. if buff.ReadUInt8() == uint8(0) {
  727. target.Properties = nil
  728. } else {
  729. // --- [begin][read][struct](AllocationProperties) ---
  730. d := &AllocationProperties{}
  731. buff.ReadInt() // [compatibility, unused]
  732. errA := d.UnmarshalBinaryWithContext(ctx)
  733. if errA != nil {
  734. return errA
  735. }
  736. target.Properties = d
  737. // --- [end][read][struct](AllocationProperties) ---
  738. }
  739. } else {
  740. target.Properties = nil
  741. }
  742. if uint8(0) /* field version */ <= version {
  743. // --- [begin][read][struct](Window) ---
  744. e := &Window{}
  745. buff.ReadInt() // [compatibility, unused]
  746. errB := e.UnmarshalBinaryWithContext(ctx)
  747. if errB != nil {
  748. return errB
  749. }
  750. target.Window = *e
  751. // --- [end][read][struct](Window) ---
  752. } else {
  753. }
  754. if uint8(0) /* field version */ <= version {
  755. // --- [begin][read][reference](time.Time) ---
  756. f := &time.Time{}
  757. g := buff.ReadInt() // byte array length
  758. h := buff.ReadBytes(g) // byte array
  759. errC := f.UnmarshalBinary(h)
  760. if errC != nil {
  761. return errC
  762. }
  763. target.Start = *f
  764. // --- [end][read][reference](time.Time) ---
  765. } else {
  766. }
  767. if uint8(0) /* field version */ <= version {
  768. // --- [begin][read][reference](time.Time) ---
  769. k := &time.Time{}
  770. l := buff.ReadInt() // byte array length
  771. m := buff.ReadBytes(l) // byte array
  772. errD := k.UnmarshalBinary(m)
  773. if errD != nil {
  774. return errD
  775. }
  776. target.End = *k
  777. // --- [end][read][reference](time.Time) ---
  778. } else {
  779. }
  780. if uint8(0) /* field version */ <= version {
  781. n := buff.ReadFloat64() // read float64
  782. target.CPUCoreHours = n
  783. } else {
  784. target.CPUCoreHours = float64(0) // default
  785. }
  786. if uint8(0) /* field version */ <= version {
  787. o := buff.ReadFloat64() // read float64
  788. target.CPUCoreRequestAverage = o
  789. } else {
  790. target.CPUCoreRequestAverage = float64(0) // default
  791. }
  792. if uint8(0) /* field version */ <= version {
  793. p := buff.ReadFloat64() // read float64
  794. target.CPUCoreUsageAverage = p
  795. } else {
  796. target.CPUCoreUsageAverage = float64(0) // default
  797. }
  798. if uint8(0) /* field version */ <= version {
  799. q := buff.ReadFloat64() // read float64
  800. target.CPUCost = q
  801. } else {
  802. target.CPUCost = float64(0) // default
  803. }
  804. if uint8(0) /* field version */ <= version {
  805. r := buff.ReadFloat64() // read float64
  806. target.CPUCostAdjustment = r
  807. } else {
  808. target.CPUCostAdjustment = float64(0) // default
  809. }
  810. if uint8(0) /* field version */ <= version {
  811. s := buff.ReadFloat64() // read float64
  812. target.GPUHours = s
  813. } else {
  814. target.GPUHours = float64(0) // default
  815. }
  816. if uint8(0) /* field version */ <= version {
  817. t := buff.ReadFloat64() // read float64
  818. target.GPUCost = t
  819. } else {
  820. target.GPUCost = float64(0) // default
  821. }
  822. if uint8(0) /* field version */ <= version {
  823. u := buff.ReadFloat64() // read float64
  824. target.GPUCostAdjustment = u
  825. } else {
  826. target.GPUCostAdjustment = float64(0) // default
  827. }
  828. if uint8(0) /* field version */ <= version {
  829. w := buff.ReadFloat64() // read float64
  830. target.NetworkTransferBytes = w
  831. } else {
  832. target.NetworkTransferBytes = float64(0) // default
  833. }
  834. if uint8(0) /* field version */ <= version {
  835. x := buff.ReadFloat64() // read float64
  836. target.NetworkReceiveBytes = x
  837. } else {
  838. target.NetworkReceiveBytes = float64(0) // default
  839. }
  840. if uint8(0) /* field version */ <= version {
  841. y := buff.ReadFloat64() // read float64
  842. target.NetworkCost = y
  843. } else {
  844. target.NetworkCost = float64(0) // default
  845. }
  846. if uint8(0) /* field version */ <= version {
  847. aa := buff.ReadFloat64() // read float64
  848. target.NetworkCostAdjustment = aa
  849. } else {
  850. target.NetworkCostAdjustment = float64(0) // default
  851. }
  852. if uint8(0) /* field version */ <= version {
  853. bb := buff.ReadFloat64() // read float64
  854. target.LoadBalancerCost = bb
  855. } else {
  856. target.LoadBalancerCost = float64(0) // default
  857. }
  858. if uint8(0) /* field version */ <= version {
  859. cc := buff.ReadFloat64() // read float64
  860. target.LoadBalancerCostAdjustment = cc
  861. } else {
  862. target.LoadBalancerCostAdjustment = float64(0) // default
  863. }
  864. if uint8(0) /* field version */ <= version {
  865. // --- [begin][read][alias](PVAllocations) ---
  866. var dd map[PVKey]*PVAllocation
  867. if buff.ReadUInt8() == uint8(0) {
  868. dd = nil
  869. } else {
  870. // --- [begin][read][map](map[PVKey]*PVAllocation) ---
  871. ff := buff.ReadInt() // map len
  872. ee := make(map[PVKey]*PVAllocation, ff)
  873. for i := 0; i < ff; i++ {
  874. // --- [begin][read][struct](PVKey) ---
  875. gg := &PVKey{}
  876. buff.ReadInt() // [compatibility, unused]
  877. errE := gg.UnmarshalBinaryWithContext(ctx)
  878. if errE != nil {
  879. return errE
  880. }
  881. v := *gg
  882. // --- [end][read][struct](PVKey) ---
  883. var z *PVAllocation
  884. if buff.ReadUInt8() == uint8(0) {
  885. z = nil
  886. } else {
  887. // --- [begin][read][struct](PVAllocation) ---
  888. hh := &PVAllocation{}
  889. buff.ReadInt() // [compatibility, unused]
  890. errF := hh.UnmarshalBinaryWithContext(ctx)
  891. if errF != nil {
  892. return errF
  893. }
  894. z = hh
  895. // --- [end][read][struct](PVAllocation) ---
  896. }
  897. ee[v] = z
  898. }
  899. dd = ee
  900. // --- [end][read][map](map[PVKey]*PVAllocation) ---
  901. }
  902. target.PVs = PVAllocations(dd)
  903. // --- [end][read][alias](PVAllocations) ---
  904. } else {
  905. }
  906. if uint8(0) /* field version */ <= version {
  907. kk := buff.ReadFloat64() // read float64
  908. target.PVCostAdjustment = kk
  909. } else {
  910. target.PVCostAdjustment = float64(0) // default
  911. }
  912. if uint8(0) /* field version */ <= version {
  913. ll := buff.ReadFloat64() // read float64
  914. target.RAMByteHours = ll
  915. } else {
  916. target.RAMByteHours = float64(0) // default
  917. }
  918. if uint8(0) /* field version */ <= version {
  919. mm := buff.ReadFloat64() // read float64
  920. target.RAMBytesRequestAverage = mm
  921. } else {
  922. target.RAMBytesRequestAverage = float64(0) // default
  923. }
  924. if uint8(0) /* field version */ <= version {
  925. nn := buff.ReadFloat64() // read float64
  926. target.RAMBytesUsageAverage = nn
  927. } else {
  928. target.RAMBytesUsageAverage = float64(0) // default
  929. }
  930. if uint8(0) /* field version */ <= version {
  931. oo := buff.ReadFloat64() // read float64
  932. target.RAMCost = oo
  933. } else {
  934. target.RAMCost = float64(0) // default
  935. }
  936. if uint8(0) /* field version */ <= version {
  937. pp := buff.ReadFloat64() // read float64
  938. target.RAMCostAdjustment = pp
  939. } else {
  940. target.RAMCostAdjustment = float64(0) // default
  941. }
  942. if uint8(0) /* field version */ <= version {
  943. qq := buff.ReadFloat64() // read float64
  944. target.SharedCost = qq
  945. } else {
  946. target.SharedCost = float64(0) // default
  947. }
  948. if uint8(0) /* field version */ <= version {
  949. rr := buff.ReadFloat64() // read float64
  950. target.ExternalCost = rr
  951. } else {
  952. target.ExternalCost = float64(0) // default
  953. }
  954. if uint8(0) /* field version */ <= version {
  955. if buff.ReadUInt8() == uint8(0) {
  956. target.RawAllocationOnly = nil
  957. } else {
  958. // --- [begin][read][struct](RawAllocationOnlyData) ---
  959. ss := &RawAllocationOnlyData{}
  960. buff.ReadInt() // [compatibility, unused]
  961. errG := ss.UnmarshalBinaryWithContext(ctx)
  962. if errG != nil {
  963. return errG
  964. }
  965. target.RawAllocationOnly = ss
  966. // --- [end][read][struct](RawAllocationOnlyData) ---
  967. }
  968. } else {
  969. target.RawAllocationOnly = nil
  970. }
  971. return nil
  972. }
  973. //--------------------------------------------------------------------------
  974. // AllocationProperties
  975. //--------------------------------------------------------------------------
  976. // MarshalBinary serializes the internal properties of this AllocationProperties instance
  977. // into a byte array
  978. func (target *AllocationProperties) MarshalBinary() (data []byte, err error) {
  979. ctx := &EncodingContext{
  980. Buffer: util.NewBuffer(),
  981. Table: nil,
  982. }
  983. e := target.MarshalBinaryWithContext(ctx)
  984. if e != nil {
  985. return nil, e
  986. }
  987. encBytes := ctx.Buffer.Bytes()
  988. return encBytes, nil
  989. }
  990. // MarshalBinaryWithContext serializes the internal properties of this AllocationProperties instance
  991. // into a byte array leveraging a predefined context.
  992. func (target *AllocationProperties) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  993. // panics are recovered and propagated as errors
  994. defer func() {
  995. if r := recover(); r != nil {
  996. if e, ok := r.(error); ok {
  997. err = e
  998. } else if s, ok := r.(string); ok {
  999. err = fmt.Errorf("Unexpected panic: %s", s)
  1000. } else {
  1001. err = fmt.Errorf("Unexpected panic: %+v", r)
  1002. }
  1003. }
  1004. }()
  1005. buff := ctx.Buffer
  1006. buff.WriteUInt8(AllocationCodecVersion) // version
  1007. if ctx.IsStringTable() {
  1008. a := ctx.Table.AddOrGet(target.Cluster)
  1009. buff.WriteInt(a) // write table index
  1010. } else {
  1011. buff.WriteString(target.Cluster) // write string
  1012. }
  1013. if ctx.IsStringTable() {
  1014. b := ctx.Table.AddOrGet(target.Node)
  1015. buff.WriteInt(b) // write table index
  1016. } else {
  1017. buff.WriteString(target.Node) // write string
  1018. }
  1019. if ctx.IsStringTable() {
  1020. c := ctx.Table.AddOrGet(target.Container)
  1021. buff.WriteInt(c) // write table index
  1022. } else {
  1023. buff.WriteString(target.Container) // write string
  1024. }
  1025. if ctx.IsStringTable() {
  1026. d := ctx.Table.AddOrGet(target.Controller)
  1027. buff.WriteInt(d) // write table index
  1028. } else {
  1029. buff.WriteString(target.Controller) // write string
  1030. }
  1031. if ctx.IsStringTable() {
  1032. e := ctx.Table.AddOrGet(target.ControllerKind)
  1033. buff.WriteInt(e) // write table index
  1034. } else {
  1035. buff.WriteString(target.ControllerKind) // write string
  1036. }
  1037. if ctx.IsStringTable() {
  1038. f := ctx.Table.AddOrGet(target.Namespace)
  1039. buff.WriteInt(f) // write table index
  1040. } else {
  1041. buff.WriteString(target.Namespace) // write string
  1042. }
  1043. if ctx.IsStringTable() {
  1044. g := ctx.Table.AddOrGet(target.Pod)
  1045. buff.WriteInt(g) // write table index
  1046. } else {
  1047. buff.WriteString(target.Pod) // write string
  1048. }
  1049. if target.Services == nil {
  1050. buff.WriteUInt8(uint8(0)) // write nil byte
  1051. } else {
  1052. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1053. // --- [begin][write][slice]([]string) ---
  1054. buff.WriteInt(len(target.Services)) // array length
  1055. for i := 0; i < len(target.Services); i++ {
  1056. if ctx.IsStringTable() {
  1057. h := ctx.Table.AddOrGet(target.Services[i])
  1058. buff.WriteInt(h) // write table index
  1059. } else {
  1060. buff.WriteString(target.Services[i]) // write string
  1061. }
  1062. }
  1063. // --- [end][write][slice]([]string) ---
  1064. }
  1065. if ctx.IsStringTable() {
  1066. k := ctx.Table.AddOrGet(target.ProviderID)
  1067. buff.WriteInt(k) // write table index
  1068. } else {
  1069. buff.WriteString(target.ProviderID) // write string
  1070. }
  1071. // --- [begin][write][alias](AllocationLabels) ---
  1072. if map[string]string(target.Labels) == nil {
  1073. buff.WriteUInt8(uint8(0)) // write nil byte
  1074. } else {
  1075. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1076. // --- [begin][write][map](map[string]string) ---
  1077. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  1078. for v, z := range map[string]string(target.Labels) {
  1079. if ctx.IsStringTable() {
  1080. l := ctx.Table.AddOrGet(v)
  1081. buff.WriteInt(l) // write table index
  1082. } else {
  1083. buff.WriteString(v) // write string
  1084. }
  1085. if ctx.IsStringTable() {
  1086. m := ctx.Table.AddOrGet(z)
  1087. buff.WriteInt(m) // write table index
  1088. } else {
  1089. buff.WriteString(z) // write string
  1090. }
  1091. }
  1092. // --- [end][write][map](map[string]string) ---
  1093. }
  1094. // --- [end][write][alias](AllocationLabels) ---
  1095. // --- [begin][write][alias](AllocationAnnotations) ---
  1096. if map[string]string(target.Annotations) == nil {
  1097. buff.WriteUInt8(uint8(0)) // write nil byte
  1098. } else {
  1099. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1100. // --- [begin][write][map](map[string]string) ---
  1101. buff.WriteInt(len(map[string]string(target.Annotations))) // map length
  1102. for vv, zz := range map[string]string(target.Annotations) {
  1103. if ctx.IsStringTable() {
  1104. n := ctx.Table.AddOrGet(vv)
  1105. buff.WriteInt(n) // write table index
  1106. } else {
  1107. buff.WriteString(vv) // write string
  1108. }
  1109. if ctx.IsStringTable() {
  1110. o := ctx.Table.AddOrGet(zz)
  1111. buff.WriteInt(o) // write table index
  1112. } else {
  1113. buff.WriteString(zz) // write string
  1114. }
  1115. }
  1116. // --- [end][write][map](map[string]string) ---
  1117. }
  1118. // --- [end][write][alias](AllocationAnnotations) ---
  1119. return nil
  1120. }
  1121. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1122. // the AllocationProperties type
  1123. func (target *AllocationProperties) UnmarshalBinary(data []byte) error {
  1124. var table []string
  1125. buff := util.NewBufferFromBytes(data)
  1126. // string table header validation
  1127. if isBinaryTag(data, BinaryTagStringTable) {
  1128. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  1129. tl := buff.ReadInt() // table length
  1130. if tl > 0 {
  1131. table = make([]string, tl, tl)
  1132. for i := 0; i < tl; i++ {
  1133. table[i] = buff.ReadString()
  1134. }
  1135. }
  1136. }
  1137. ctx := &DecodingContext{
  1138. Buffer: buff,
  1139. Table: table,
  1140. }
  1141. err := target.UnmarshalBinaryWithContext(ctx)
  1142. if err != nil {
  1143. return err
  1144. }
  1145. return nil
  1146. }
  1147. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  1148. // the AllocationProperties type
  1149. func (target *AllocationProperties) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  1150. // panics are recovered and propagated as errors
  1151. defer func() {
  1152. if r := recover(); r != nil {
  1153. if e, ok := r.(error); ok {
  1154. err = e
  1155. } else if s, ok := r.(string); ok {
  1156. err = fmt.Errorf("Unexpected panic: %s", s)
  1157. } else {
  1158. err = fmt.Errorf("Unexpected panic: %+v", r)
  1159. }
  1160. }
  1161. }()
  1162. buff := ctx.Buffer
  1163. version := buff.ReadUInt8()
  1164. if version > AllocationCodecVersion {
  1165. return fmt.Errorf("Invalid Version Unmarshaling AllocationProperties. Expected %d or less, got %d", AllocationCodecVersion, version)
  1166. }
  1167. if uint8(0) /* field version */ <= version {
  1168. var b string
  1169. if ctx.IsStringTable() {
  1170. c := buff.ReadInt() // read string index
  1171. b = ctx.Table[c]
  1172. } else {
  1173. b = buff.ReadString() // read string
  1174. }
  1175. a := b
  1176. target.Cluster = a
  1177. } else {
  1178. target.Cluster = "" // default
  1179. }
  1180. if uint8(0) /* field version */ <= version {
  1181. var e string
  1182. if ctx.IsStringTable() {
  1183. f := buff.ReadInt() // read string index
  1184. e = ctx.Table[f]
  1185. } else {
  1186. e = buff.ReadString() // read string
  1187. }
  1188. d := e
  1189. target.Node = d
  1190. } else {
  1191. target.Node = "" // default
  1192. }
  1193. if uint8(0) /* field version */ <= version {
  1194. var h string
  1195. if ctx.IsStringTable() {
  1196. k := buff.ReadInt() // read string index
  1197. h = ctx.Table[k]
  1198. } else {
  1199. h = buff.ReadString() // read string
  1200. }
  1201. g := h
  1202. target.Container = g
  1203. } else {
  1204. target.Container = "" // default
  1205. }
  1206. if uint8(0) /* field version */ <= version {
  1207. var m string
  1208. if ctx.IsStringTable() {
  1209. n := buff.ReadInt() // read string index
  1210. m = ctx.Table[n]
  1211. } else {
  1212. m = buff.ReadString() // read string
  1213. }
  1214. l := m
  1215. target.Controller = l
  1216. } else {
  1217. target.Controller = "" // default
  1218. }
  1219. if uint8(0) /* field version */ <= version {
  1220. var p string
  1221. if ctx.IsStringTable() {
  1222. q := buff.ReadInt() // read string index
  1223. p = ctx.Table[q]
  1224. } else {
  1225. p = buff.ReadString() // read string
  1226. }
  1227. o := p
  1228. target.ControllerKind = o
  1229. } else {
  1230. target.ControllerKind = "" // default
  1231. }
  1232. if uint8(0) /* field version */ <= version {
  1233. var s string
  1234. if ctx.IsStringTable() {
  1235. t := buff.ReadInt() // read string index
  1236. s = ctx.Table[t]
  1237. } else {
  1238. s = buff.ReadString() // read string
  1239. }
  1240. r := s
  1241. target.Namespace = r
  1242. } else {
  1243. target.Namespace = "" // default
  1244. }
  1245. if uint8(0) /* field version */ <= version {
  1246. var w string
  1247. if ctx.IsStringTable() {
  1248. x := buff.ReadInt() // read string index
  1249. w = ctx.Table[x]
  1250. } else {
  1251. w = buff.ReadString() // read string
  1252. }
  1253. u := w
  1254. target.Pod = u
  1255. } else {
  1256. target.Pod = "" // default
  1257. }
  1258. if uint8(0) /* field version */ <= version {
  1259. if buff.ReadUInt8() == uint8(0) {
  1260. target.Services = nil
  1261. } else {
  1262. // --- [begin][read][slice]([]string) ---
  1263. aa := buff.ReadInt() // array len
  1264. y := make([]string, aa)
  1265. for i := 0; i < aa; i++ {
  1266. var bb string
  1267. var dd string
  1268. if ctx.IsStringTable() {
  1269. ee := buff.ReadInt() // read string index
  1270. dd = ctx.Table[ee]
  1271. } else {
  1272. dd = buff.ReadString() // read string
  1273. }
  1274. cc := dd
  1275. bb = cc
  1276. y[i] = bb
  1277. }
  1278. target.Services = y
  1279. // --- [end][read][slice]([]string) ---
  1280. }
  1281. } else {
  1282. target.Services = nil
  1283. }
  1284. if uint8(0) /* field version */ <= version {
  1285. var gg string
  1286. if ctx.IsStringTable() {
  1287. hh := buff.ReadInt() // read string index
  1288. gg = ctx.Table[hh]
  1289. } else {
  1290. gg = buff.ReadString() // read string
  1291. }
  1292. ff := gg
  1293. target.ProviderID = ff
  1294. } else {
  1295. target.ProviderID = "" // default
  1296. }
  1297. if uint8(0) /* field version */ <= version {
  1298. // --- [begin][read][alias](AllocationLabels) ---
  1299. var kk map[string]string
  1300. if buff.ReadUInt8() == uint8(0) {
  1301. kk = nil
  1302. } else {
  1303. // --- [begin][read][map](map[string]string) ---
  1304. mm := buff.ReadInt() // map len
  1305. ll := make(map[string]string, mm)
  1306. for j := 0; j < mm; j++ {
  1307. var v string
  1308. var oo string
  1309. if ctx.IsStringTable() {
  1310. pp := buff.ReadInt() // read string index
  1311. oo = ctx.Table[pp]
  1312. } else {
  1313. oo = buff.ReadString() // read string
  1314. }
  1315. nn := oo
  1316. v = nn
  1317. var z string
  1318. var rr string
  1319. if ctx.IsStringTable() {
  1320. ss := buff.ReadInt() // read string index
  1321. rr = ctx.Table[ss]
  1322. } else {
  1323. rr = buff.ReadString() // read string
  1324. }
  1325. qq := rr
  1326. z = qq
  1327. ll[v] = z
  1328. }
  1329. kk = ll
  1330. // --- [end][read][map](map[string]string) ---
  1331. }
  1332. target.Labels = AllocationLabels(kk)
  1333. // --- [end][read][alias](AllocationLabels) ---
  1334. } else {
  1335. }
  1336. if uint8(0) /* field version */ <= version {
  1337. // --- [begin][read][alias](AllocationAnnotations) ---
  1338. var tt map[string]string
  1339. if buff.ReadUInt8() == uint8(0) {
  1340. tt = nil
  1341. } else {
  1342. // --- [begin][read][map](map[string]string) ---
  1343. ww := buff.ReadInt() // map len
  1344. uu := make(map[string]string, ww)
  1345. for ii := 0; ii < ww; ii++ {
  1346. var vv string
  1347. var yy string
  1348. if ctx.IsStringTable() {
  1349. aaa := buff.ReadInt() // read string index
  1350. yy = ctx.Table[aaa]
  1351. } else {
  1352. yy = buff.ReadString() // read string
  1353. }
  1354. xx := yy
  1355. vv = xx
  1356. var zz string
  1357. var ccc string
  1358. if ctx.IsStringTable() {
  1359. ddd := buff.ReadInt() // read string index
  1360. ccc = ctx.Table[ddd]
  1361. } else {
  1362. ccc = buff.ReadString() // read string
  1363. }
  1364. bbb := ccc
  1365. zz = bbb
  1366. uu[vv] = zz
  1367. }
  1368. tt = uu
  1369. // --- [end][read][map](map[string]string) ---
  1370. }
  1371. target.Annotations = AllocationAnnotations(tt)
  1372. // --- [end][read][alias](AllocationAnnotations) ---
  1373. } else {
  1374. }
  1375. return nil
  1376. }
  1377. //--------------------------------------------------------------------------
  1378. // AllocationReconciliationAudit
  1379. //--------------------------------------------------------------------------
  1380. // MarshalBinary serializes the internal properties of this AllocationReconciliationAudit instance
  1381. // into a byte array
  1382. func (target *AllocationReconciliationAudit) MarshalBinary() (data []byte, err error) {
  1383. ctx := &EncodingContext{
  1384. Buffer: util.NewBuffer(),
  1385. Table: nil,
  1386. }
  1387. e := target.MarshalBinaryWithContext(ctx)
  1388. if e != nil {
  1389. return nil, e
  1390. }
  1391. encBytes := ctx.Buffer.Bytes()
  1392. return encBytes, nil
  1393. }
  1394. // MarshalBinaryWithContext serializes the internal properties of this AllocationReconciliationAudit instance
  1395. // into a byte array leveraging a predefined context.
  1396. func (target *AllocationReconciliationAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  1397. // panics are recovered and propagated as errors
  1398. defer func() {
  1399. if r := recover(); r != nil {
  1400. if e, ok := r.(error); ok {
  1401. err = e
  1402. } else if s, ok := r.(string); ok {
  1403. err = fmt.Errorf("Unexpected panic: %s", s)
  1404. } else {
  1405. err = fmt.Errorf("Unexpected panic: %+v", r)
  1406. }
  1407. }
  1408. }()
  1409. buff := ctx.Buffer
  1410. buff.WriteUInt8(AuditCodecVersion) // version
  1411. // --- [begin][write][alias](AuditStatus) ---
  1412. if ctx.IsStringTable() {
  1413. a := ctx.Table.AddOrGet(string(target.Status))
  1414. buff.WriteInt(a) // write table index
  1415. } else {
  1416. buff.WriteString(string(target.Status)) // write string
  1417. }
  1418. // --- [end][write][alias](AuditStatus) ---
  1419. if ctx.IsStringTable() {
  1420. b := ctx.Table.AddOrGet(target.Description)
  1421. buff.WriteInt(b) // write table index
  1422. } else {
  1423. buff.WriteString(target.Description) // write string
  1424. }
  1425. // --- [begin][write][reference](time.Time) ---
  1426. c, errA := target.LastRun.MarshalBinary()
  1427. if errA != nil {
  1428. return errA
  1429. }
  1430. buff.WriteInt(len(c))
  1431. buff.WriteBytes(c)
  1432. // --- [end][write][reference](time.Time) ---
  1433. if target.Resources == nil {
  1434. buff.WriteUInt8(uint8(0)) // write nil byte
  1435. } else {
  1436. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1437. // --- [begin][write][map](map[string]map[string]*AuditFloatResult) ---
  1438. buff.WriteInt(len(target.Resources)) // map length
  1439. for v, z := range target.Resources {
  1440. if ctx.IsStringTable() {
  1441. d := ctx.Table.AddOrGet(v)
  1442. buff.WriteInt(d) // write table index
  1443. } else {
  1444. buff.WriteString(v) // write string
  1445. }
  1446. if z == nil {
  1447. buff.WriteUInt8(uint8(0)) // write nil byte
  1448. } else {
  1449. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1450. // --- [begin][write][map](map[string]*AuditFloatResult) ---
  1451. buff.WriteInt(len(z)) // map length
  1452. for vv, zz := range z {
  1453. if ctx.IsStringTable() {
  1454. e := ctx.Table.AddOrGet(vv)
  1455. buff.WriteInt(e) // write table index
  1456. } else {
  1457. buff.WriteString(vv) // write string
  1458. }
  1459. if zz == nil {
  1460. buff.WriteUInt8(uint8(0)) // write nil byte
  1461. } else {
  1462. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1463. // --- [begin][write][struct](AuditFloatResult) ---
  1464. buff.WriteInt(0) // [compatibility, unused]
  1465. errB := zz.MarshalBinaryWithContext(ctx)
  1466. if errB != nil {
  1467. return errB
  1468. }
  1469. // --- [end][write][struct](AuditFloatResult) ---
  1470. }
  1471. }
  1472. // --- [end][write][map](map[string]*AuditFloatResult) ---
  1473. }
  1474. }
  1475. // --- [end][write][map](map[string]map[string]*AuditFloatResult) ---
  1476. }
  1477. if target.MissingValues == nil {
  1478. buff.WriteUInt8(uint8(0)) // write nil byte
  1479. } else {
  1480. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1481. // --- [begin][write][slice]([]*AuditMissingValue) ---
  1482. buff.WriteInt(len(target.MissingValues)) // array length
  1483. for i := 0; i < len(target.MissingValues); i++ {
  1484. if target.MissingValues[i] == nil {
  1485. buff.WriteUInt8(uint8(0)) // write nil byte
  1486. } else {
  1487. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1488. // --- [begin][write][struct](AuditMissingValue) ---
  1489. buff.WriteInt(0) // [compatibility, unused]
  1490. errC := target.MissingValues[i].MarshalBinaryWithContext(ctx)
  1491. if errC != nil {
  1492. return errC
  1493. }
  1494. // --- [end][write][struct](AuditMissingValue) ---
  1495. }
  1496. }
  1497. // --- [end][write][slice]([]*AuditMissingValue) ---
  1498. }
  1499. return nil
  1500. }
  1501. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1502. // the AllocationReconciliationAudit type
  1503. func (target *AllocationReconciliationAudit) UnmarshalBinary(data []byte) error {
  1504. var table []string
  1505. buff := util.NewBufferFromBytes(data)
  1506. // string table header validation
  1507. if isBinaryTag(data, BinaryTagStringTable) {
  1508. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  1509. tl := buff.ReadInt() // table length
  1510. if tl > 0 {
  1511. table = make([]string, tl, tl)
  1512. for i := 0; i < tl; i++ {
  1513. table[i] = buff.ReadString()
  1514. }
  1515. }
  1516. }
  1517. ctx := &DecodingContext{
  1518. Buffer: buff,
  1519. Table: table,
  1520. }
  1521. err := target.UnmarshalBinaryWithContext(ctx)
  1522. if err != nil {
  1523. return err
  1524. }
  1525. return nil
  1526. }
  1527. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  1528. // the AllocationReconciliationAudit type
  1529. func (target *AllocationReconciliationAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  1530. // panics are recovered and propagated as errors
  1531. defer func() {
  1532. if r := recover(); r != nil {
  1533. if e, ok := r.(error); ok {
  1534. err = e
  1535. } else if s, ok := r.(string); ok {
  1536. err = fmt.Errorf("Unexpected panic: %s", s)
  1537. } else {
  1538. err = fmt.Errorf("Unexpected panic: %+v", r)
  1539. }
  1540. }
  1541. }()
  1542. buff := ctx.Buffer
  1543. version := buff.ReadUInt8()
  1544. if version > AuditCodecVersion {
  1545. return fmt.Errorf("Invalid Version Unmarshaling AllocationReconciliationAudit. Expected %d or less, got %d", AuditCodecVersion, version)
  1546. }
  1547. if uint8(0) /* field version */ <= version {
  1548. // --- [begin][read][alias](AuditStatus) ---
  1549. var a string
  1550. var c string
  1551. if ctx.IsStringTable() {
  1552. d := buff.ReadInt() // read string index
  1553. c = ctx.Table[d]
  1554. } else {
  1555. c = buff.ReadString() // read string
  1556. }
  1557. b := c
  1558. a = b
  1559. target.Status = AuditStatus(a)
  1560. // --- [end][read][alias](AuditStatus) ---
  1561. } else {
  1562. }
  1563. if uint8(0) /* field version */ <= version {
  1564. var f string
  1565. if ctx.IsStringTable() {
  1566. g := buff.ReadInt() // read string index
  1567. f = ctx.Table[g]
  1568. } else {
  1569. f = buff.ReadString() // read string
  1570. }
  1571. e := f
  1572. target.Description = e
  1573. } else {
  1574. target.Description = "" // default
  1575. }
  1576. if uint8(0) /* field version */ <= version {
  1577. // --- [begin][read][reference](time.Time) ---
  1578. h := &time.Time{}
  1579. k := buff.ReadInt() // byte array length
  1580. l := buff.ReadBytes(k) // byte array
  1581. errA := h.UnmarshalBinary(l)
  1582. if errA != nil {
  1583. return errA
  1584. }
  1585. target.LastRun = *h
  1586. // --- [end][read][reference](time.Time) ---
  1587. } else {
  1588. }
  1589. if uint8(0) /* field version */ <= version {
  1590. if buff.ReadUInt8() == uint8(0) {
  1591. target.Resources = nil
  1592. } else {
  1593. // --- [begin][read][map](map[string]map[string]*AuditFloatResult) ---
  1594. n := buff.ReadInt() // map len
  1595. m := make(map[string]map[string]*AuditFloatResult, n)
  1596. for i := 0; i < n; i++ {
  1597. var v string
  1598. var p string
  1599. if ctx.IsStringTable() {
  1600. q := buff.ReadInt() // read string index
  1601. p = ctx.Table[q]
  1602. } else {
  1603. p = buff.ReadString() // read string
  1604. }
  1605. o := p
  1606. v = o
  1607. var z map[string]*AuditFloatResult
  1608. if buff.ReadUInt8() == uint8(0) {
  1609. z = nil
  1610. } else {
  1611. // --- [begin][read][map](map[string]*AuditFloatResult) ---
  1612. s := buff.ReadInt() // map len
  1613. r := make(map[string]*AuditFloatResult, s)
  1614. for j := 0; j < s; j++ {
  1615. var vv string
  1616. var u string
  1617. if ctx.IsStringTable() {
  1618. w := buff.ReadInt() // read string index
  1619. u = ctx.Table[w]
  1620. } else {
  1621. u = buff.ReadString() // read string
  1622. }
  1623. t := u
  1624. vv = t
  1625. var zz *AuditFloatResult
  1626. if buff.ReadUInt8() == uint8(0) {
  1627. zz = nil
  1628. } else {
  1629. // --- [begin][read][struct](AuditFloatResult) ---
  1630. x := &AuditFloatResult{}
  1631. buff.ReadInt() // [compatibility, unused]
  1632. errB := x.UnmarshalBinaryWithContext(ctx)
  1633. if errB != nil {
  1634. return errB
  1635. }
  1636. zz = x
  1637. // --- [end][read][struct](AuditFloatResult) ---
  1638. }
  1639. r[vv] = zz
  1640. }
  1641. z = r
  1642. // --- [end][read][map](map[string]*AuditFloatResult) ---
  1643. }
  1644. m[v] = z
  1645. }
  1646. target.Resources = m
  1647. // --- [end][read][map](map[string]map[string]*AuditFloatResult) ---
  1648. }
  1649. } else {
  1650. target.Resources = nil
  1651. }
  1652. if uint8(0) /* field version */ <= version {
  1653. if buff.ReadUInt8() == uint8(0) {
  1654. target.MissingValues = nil
  1655. } else {
  1656. // --- [begin][read][slice]([]*AuditMissingValue) ---
  1657. aa := buff.ReadInt() // array len
  1658. y := make([]*AuditMissingValue, aa)
  1659. for ii := 0; ii < aa; ii++ {
  1660. var bb *AuditMissingValue
  1661. if buff.ReadUInt8() == uint8(0) {
  1662. bb = nil
  1663. } else {
  1664. // --- [begin][read][struct](AuditMissingValue) ---
  1665. cc := &AuditMissingValue{}
  1666. buff.ReadInt() // [compatibility, unused]
  1667. errC := cc.UnmarshalBinaryWithContext(ctx)
  1668. if errC != nil {
  1669. return errC
  1670. }
  1671. bb = cc
  1672. // --- [end][read][struct](AuditMissingValue) ---
  1673. }
  1674. y[ii] = bb
  1675. }
  1676. target.MissingValues = y
  1677. // --- [end][read][slice]([]*AuditMissingValue) ---
  1678. }
  1679. } else {
  1680. target.MissingValues = nil
  1681. }
  1682. return nil
  1683. }
  1684. //--------------------------------------------------------------------------
  1685. // AllocationSet
  1686. //--------------------------------------------------------------------------
  1687. // MarshalBinary serializes the internal properties of this AllocationSet instance
  1688. // into a byte array
  1689. func (target *AllocationSet) MarshalBinary() (data []byte, err error) {
  1690. ctx := &EncodingContext{
  1691. Buffer: util.NewBuffer(),
  1692. Table: NewStringTable(),
  1693. }
  1694. e := target.MarshalBinaryWithContext(ctx)
  1695. if e != nil {
  1696. return nil, e
  1697. }
  1698. encBytes := ctx.Buffer.Bytes()
  1699. sTableBytes := ctx.Table.ToBytes()
  1700. merged := appendBytes(sTableBytes, encBytes)
  1701. return merged, nil
  1702. }
  1703. // MarshalBinaryWithContext serializes the internal properties of this AllocationSet instance
  1704. // into a byte array leveraging a predefined context.
  1705. func (target *AllocationSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  1706. // panics are recovered and propagated as errors
  1707. defer func() {
  1708. if r := recover(); r != nil {
  1709. if e, ok := r.(error); ok {
  1710. err = e
  1711. } else if s, ok := r.(string); ok {
  1712. err = fmt.Errorf("Unexpected panic: %s", s)
  1713. } else {
  1714. err = fmt.Errorf("Unexpected panic: %+v", r)
  1715. }
  1716. }
  1717. }()
  1718. buff := ctx.Buffer
  1719. buff.WriteUInt8(AllocationCodecVersion) // version
  1720. if target.allocations == nil {
  1721. buff.WriteUInt8(uint8(0)) // write nil byte
  1722. } else {
  1723. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1724. // --- [begin][write][map](map[string]*Allocation) ---
  1725. buff.WriteInt(len(target.allocations)) // map length
  1726. for v, z := range target.allocations {
  1727. if ctx.IsStringTable() {
  1728. a := ctx.Table.AddOrGet(v)
  1729. buff.WriteInt(a) // write table index
  1730. } else {
  1731. buff.WriteString(v) // write string
  1732. }
  1733. if z == nil {
  1734. buff.WriteUInt8(uint8(0)) // write nil byte
  1735. } else {
  1736. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1737. // --- [begin][write][struct](Allocation) ---
  1738. buff.WriteInt(0) // [compatibility, unused]
  1739. errA := z.MarshalBinaryWithContext(ctx)
  1740. if errA != nil {
  1741. return errA
  1742. }
  1743. // --- [end][write][struct](Allocation) ---
  1744. }
  1745. }
  1746. // --- [end][write][map](map[string]*Allocation) ---
  1747. }
  1748. if target.externalKeys == nil {
  1749. buff.WriteUInt8(uint8(0)) // write nil byte
  1750. } else {
  1751. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1752. // --- [begin][write][map](map[string]bool) ---
  1753. buff.WriteInt(len(target.externalKeys)) // map length
  1754. for vv, zz := range target.externalKeys {
  1755. if ctx.IsStringTable() {
  1756. b := ctx.Table.AddOrGet(vv)
  1757. buff.WriteInt(b) // write table index
  1758. } else {
  1759. buff.WriteString(vv) // write string
  1760. }
  1761. buff.WriteBool(zz) // write bool
  1762. }
  1763. // --- [end][write][map](map[string]bool) ---
  1764. }
  1765. if target.idleKeys == nil {
  1766. buff.WriteUInt8(uint8(0)) // write nil byte
  1767. } else {
  1768. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1769. // --- [begin][write][map](map[string]bool) ---
  1770. buff.WriteInt(len(target.idleKeys)) // map length
  1771. for vvv, zzz := range target.idleKeys {
  1772. if ctx.IsStringTable() {
  1773. c := ctx.Table.AddOrGet(vvv)
  1774. buff.WriteInt(c) // write table index
  1775. } else {
  1776. buff.WriteString(vvv) // write string
  1777. }
  1778. buff.WriteBool(zzz) // write bool
  1779. }
  1780. // --- [end][write][map](map[string]bool) ---
  1781. }
  1782. if ctx.IsStringTable() {
  1783. d := ctx.Table.AddOrGet(target.FromSource)
  1784. buff.WriteInt(d) // write table index
  1785. } else {
  1786. buff.WriteString(target.FromSource) // write string
  1787. }
  1788. // --- [begin][write][struct](Window) ---
  1789. buff.WriteInt(0) // [compatibility, unused]
  1790. errB := target.Window.MarshalBinaryWithContext(ctx)
  1791. if errB != nil {
  1792. return errB
  1793. }
  1794. // --- [end][write][struct](Window) ---
  1795. if target.Warnings == nil {
  1796. buff.WriteUInt8(uint8(0)) // write nil byte
  1797. } else {
  1798. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1799. // --- [begin][write][slice]([]string) ---
  1800. buff.WriteInt(len(target.Warnings)) // array length
  1801. for i := 0; i < len(target.Warnings); i++ {
  1802. if ctx.IsStringTable() {
  1803. e := ctx.Table.AddOrGet(target.Warnings[i])
  1804. buff.WriteInt(e) // write table index
  1805. } else {
  1806. buff.WriteString(target.Warnings[i]) // write string
  1807. }
  1808. }
  1809. // --- [end][write][slice]([]string) ---
  1810. }
  1811. if target.Errors == nil {
  1812. buff.WriteUInt8(uint8(0)) // write nil byte
  1813. } else {
  1814. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1815. // --- [begin][write][slice]([]string) ---
  1816. buff.WriteInt(len(target.Errors)) // array length
  1817. for j := 0; j < len(target.Errors); j++ {
  1818. if ctx.IsStringTable() {
  1819. f := ctx.Table.AddOrGet(target.Errors[j])
  1820. buff.WriteInt(f) // write table index
  1821. } else {
  1822. buff.WriteString(target.Errors[j]) // write string
  1823. }
  1824. }
  1825. // --- [end][write][slice]([]string) ---
  1826. }
  1827. return nil
  1828. }
  1829. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1830. // the AllocationSet type
  1831. func (target *AllocationSet) UnmarshalBinary(data []byte) error {
  1832. var table []string
  1833. buff := util.NewBufferFromBytes(data)
  1834. // string table header validation
  1835. if isBinaryTag(data, BinaryTagStringTable) {
  1836. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  1837. tl := buff.ReadInt() // table length
  1838. if tl > 0 {
  1839. table = make([]string, tl, tl)
  1840. for i := 0; i < tl; i++ {
  1841. table[i] = buff.ReadString()
  1842. }
  1843. }
  1844. }
  1845. ctx := &DecodingContext{
  1846. Buffer: buff,
  1847. Table: table,
  1848. }
  1849. err := target.UnmarshalBinaryWithContext(ctx)
  1850. if err != nil {
  1851. return err
  1852. }
  1853. return nil
  1854. }
  1855. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  1856. // the AllocationSet type
  1857. func (target *AllocationSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  1858. // panics are recovered and propagated as errors
  1859. defer func() {
  1860. if r := recover(); r != nil {
  1861. if e, ok := r.(error); ok {
  1862. err = e
  1863. } else if s, ok := r.(string); ok {
  1864. err = fmt.Errorf("Unexpected panic: %s", s)
  1865. } else {
  1866. err = fmt.Errorf("Unexpected panic: %+v", r)
  1867. }
  1868. }
  1869. }()
  1870. buff := ctx.Buffer
  1871. version := buff.ReadUInt8()
  1872. if version > AllocationCodecVersion {
  1873. return fmt.Errorf("Invalid Version Unmarshaling AllocationSet. Expected %d or less, got %d", AllocationCodecVersion, version)
  1874. }
  1875. if uint8(0) /* field version */ <= version {
  1876. if buff.ReadUInt8() == uint8(0) {
  1877. target.allocations = nil
  1878. } else {
  1879. // --- [begin][read][map](map[string]*Allocation) ---
  1880. b := buff.ReadInt() // map len
  1881. a := make(map[string]*Allocation, b)
  1882. for i := 0; i < b; i++ {
  1883. var v string
  1884. var d string
  1885. if ctx.IsStringTable() {
  1886. e := buff.ReadInt() // read string index
  1887. d = ctx.Table[e]
  1888. } else {
  1889. d = buff.ReadString() // read string
  1890. }
  1891. c := d
  1892. v = c
  1893. var z *Allocation
  1894. if buff.ReadUInt8() == uint8(0) {
  1895. z = nil
  1896. } else {
  1897. // --- [begin][read][struct](Allocation) ---
  1898. f := &Allocation{}
  1899. buff.ReadInt() // [compatibility, unused]
  1900. errA := f.UnmarshalBinaryWithContext(ctx)
  1901. if errA != nil {
  1902. return errA
  1903. }
  1904. z = f
  1905. // --- [end][read][struct](Allocation) ---
  1906. }
  1907. a[v] = z
  1908. }
  1909. target.allocations = a
  1910. // --- [end][read][map](map[string]*Allocation) ---
  1911. }
  1912. } else {
  1913. target.allocations = nil
  1914. }
  1915. if uint8(0) /* field version */ <= version {
  1916. if buff.ReadUInt8() == uint8(0) {
  1917. target.externalKeys = nil
  1918. } else {
  1919. // --- [begin][read][map](map[string]bool) ---
  1920. h := buff.ReadInt() // map len
  1921. g := make(map[string]bool, h)
  1922. for j := 0; j < h; j++ {
  1923. var vv string
  1924. var l string
  1925. if ctx.IsStringTable() {
  1926. m := buff.ReadInt() // read string index
  1927. l = ctx.Table[m]
  1928. } else {
  1929. l = buff.ReadString() // read string
  1930. }
  1931. k := l
  1932. vv = k
  1933. var zz bool
  1934. n := buff.ReadBool() // read bool
  1935. zz = n
  1936. g[vv] = zz
  1937. }
  1938. target.externalKeys = g
  1939. // --- [end][read][map](map[string]bool) ---
  1940. }
  1941. } else {
  1942. target.externalKeys = nil
  1943. }
  1944. if uint8(0) /* field version */ <= version {
  1945. if buff.ReadUInt8() == uint8(0) {
  1946. target.idleKeys = nil
  1947. } else {
  1948. // --- [begin][read][map](map[string]bool) ---
  1949. p := buff.ReadInt() // map len
  1950. o := make(map[string]bool, p)
  1951. for ii := 0; ii < p; ii++ {
  1952. var vvv string
  1953. var r string
  1954. if ctx.IsStringTable() {
  1955. s := buff.ReadInt() // read string index
  1956. r = ctx.Table[s]
  1957. } else {
  1958. r = buff.ReadString() // read string
  1959. }
  1960. q := r
  1961. vvv = q
  1962. var zzz bool
  1963. t := buff.ReadBool() // read bool
  1964. zzz = t
  1965. o[vvv] = zzz
  1966. }
  1967. target.idleKeys = o
  1968. // --- [end][read][map](map[string]bool) ---
  1969. }
  1970. } else {
  1971. target.idleKeys = nil
  1972. }
  1973. if uint8(0) /* field version */ <= version {
  1974. var w string
  1975. if ctx.IsStringTable() {
  1976. x := buff.ReadInt() // read string index
  1977. w = ctx.Table[x]
  1978. } else {
  1979. w = buff.ReadString() // read string
  1980. }
  1981. u := w
  1982. target.FromSource = u
  1983. } else {
  1984. target.FromSource = "" // default
  1985. }
  1986. if uint8(0) /* field version */ <= version {
  1987. // --- [begin][read][struct](Window) ---
  1988. y := &Window{}
  1989. buff.ReadInt() // [compatibility, unused]
  1990. errB := y.UnmarshalBinaryWithContext(ctx)
  1991. if errB != nil {
  1992. return errB
  1993. }
  1994. target.Window = *y
  1995. // --- [end][read][struct](Window) ---
  1996. } else {
  1997. }
  1998. if uint8(0) /* field version */ <= version {
  1999. if buff.ReadUInt8() == uint8(0) {
  2000. target.Warnings = nil
  2001. } else {
  2002. // --- [begin][read][slice]([]string) ---
  2003. bb := buff.ReadInt() // array len
  2004. aa := make([]string, bb)
  2005. for jj := 0; jj < bb; jj++ {
  2006. var cc string
  2007. var ee string
  2008. if ctx.IsStringTable() {
  2009. ff := buff.ReadInt() // read string index
  2010. ee = ctx.Table[ff]
  2011. } else {
  2012. ee = buff.ReadString() // read string
  2013. }
  2014. dd := ee
  2015. cc = dd
  2016. aa[jj] = cc
  2017. }
  2018. target.Warnings = aa
  2019. // --- [end][read][slice]([]string) ---
  2020. }
  2021. } else {
  2022. target.Warnings = nil
  2023. }
  2024. if uint8(0) /* field version */ <= version {
  2025. if buff.ReadUInt8() == uint8(0) {
  2026. target.Errors = nil
  2027. } else {
  2028. // --- [begin][read][slice]([]string) ---
  2029. hh := buff.ReadInt() // array len
  2030. gg := make([]string, hh)
  2031. for iii := 0; iii < hh; iii++ {
  2032. var kk string
  2033. var mm string
  2034. if ctx.IsStringTable() {
  2035. nn := buff.ReadInt() // read string index
  2036. mm = ctx.Table[nn]
  2037. } else {
  2038. mm = buff.ReadString() // read string
  2039. }
  2040. ll := mm
  2041. kk = ll
  2042. gg[iii] = kk
  2043. }
  2044. target.Errors = gg
  2045. // --- [end][read][slice]([]string) ---
  2046. }
  2047. } else {
  2048. target.Errors = nil
  2049. }
  2050. return nil
  2051. }
  2052. //--------------------------------------------------------------------------
  2053. // AllocationSetRange
  2054. //--------------------------------------------------------------------------
  2055. // MarshalBinary serializes the internal properties of this AllocationSetRange instance
  2056. // into a byte array
  2057. func (target *AllocationSetRange) MarshalBinary() (data []byte, err error) {
  2058. ctx := &EncodingContext{
  2059. Buffer: util.NewBuffer(),
  2060. Table: nil,
  2061. }
  2062. e := target.MarshalBinaryWithContext(ctx)
  2063. if e != nil {
  2064. return nil, e
  2065. }
  2066. encBytes := ctx.Buffer.Bytes()
  2067. return encBytes, nil
  2068. }
  2069. // MarshalBinaryWithContext serializes the internal properties of this AllocationSetRange instance
  2070. // into a byte array leveraging a predefined context.
  2071. func (target *AllocationSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2072. // panics are recovered and propagated as errors
  2073. defer func() {
  2074. if r := recover(); r != nil {
  2075. if e, ok := r.(error); ok {
  2076. err = e
  2077. } else if s, ok := r.(string); ok {
  2078. err = fmt.Errorf("Unexpected panic: %s", s)
  2079. } else {
  2080. err = fmt.Errorf("Unexpected panic: %+v", r)
  2081. }
  2082. }
  2083. }()
  2084. buff := ctx.Buffer
  2085. buff.WriteUInt8(AllocationCodecVersion) // version
  2086. if target.allocations == nil {
  2087. buff.WriteUInt8(uint8(0)) // write nil byte
  2088. } else {
  2089. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2090. // --- [begin][write][slice]([]*AllocationSet) ---
  2091. buff.WriteInt(len(target.allocations)) // array length
  2092. for i := 0; i < len(target.allocations); i++ {
  2093. if target.allocations[i] == nil {
  2094. buff.WriteUInt8(uint8(0)) // write nil byte
  2095. } else {
  2096. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2097. // --- [begin][write][struct](AllocationSet) ---
  2098. buff.WriteInt(0) // [compatibility, unused]
  2099. errA := target.allocations[i].MarshalBinaryWithContext(ctx)
  2100. if errA != nil {
  2101. return errA
  2102. }
  2103. // --- [end][write][struct](AllocationSet) ---
  2104. }
  2105. }
  2106. // --- [end][write][slice]([]*AllocationSet) ---
  2107. }
  2108. if ctx.IsStringTable() {
  2109. a := ctx.Table.AddOrGet(target.FromStore)
  2110. buff.WriteInt(a) // write table index
  2111. } else {
  2112. buff.WriteString(target.FromStore) // write string
  2113. }
  2114. return nil
  2115. }
  2116. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2117. // the AllocationSetRange type
  2118. func (target *AllocationSetRange) UnmarshalBinary(data []byte) error {
  2119. var table []string
  2120. buff := util.NewBufferFromBytes(data)
  2121. // string table header validation
  2122. if isBinaryTag(data, BinaryTagStringTable) {
  2123. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  2124. tl := buff.ReadInt() // table length
  2125. if tl > 0 {
  2126. table = make([]string, tl, tl)
  2127. for i := 0; i < tl; i++ {
  2128. table[i] = buff.ReadString()
  2129. }
  2130. }
  2131. }
  2132. ctx := &DecodingContext{
  2133. Buffer: buff,
  2134. Table: table,
  2135. }
  2136. err := target.UnmarshalBinaryWithContext(ctx)
  2137. if err != nil {
  2138. return err
  2139. }
  2140. return nil
  2141. }
  2142. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2143. // the AllocationSetRange type
  2144. func (target *AllocationSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2145. // panics are recovered and propagated as errors
  2146. defer func() {
  2147. if r := recover(); r != nil {
  2148. if e, ok := r.(error); ok {
  2149. err = e
  2150. } else if s, ok := r.(string); ok {
  2151. err = fmt.Errorf("Unexpected panic: %s", s)
  2152. } else {
  2153. err = fmt.Errorf("Unexpected panic: %+v", r)
  2154. }
  2155. }
  2156. }()
  2157. buff := ctx.Buffer
  2158. version := buff.ReadUInt8()
  2159. if version > AllocationCodecVersion {
  2160. return fmt.Errorf("Invalid Version Unmarshaling AllocationSetRange. Expected %d or less, got %d", AllocationCodecVersion, version)
  2161. }
  2162. if uint8(0) /* field version */ <= version {
  2163. if buff.ReadUInt8() == uint8(0) {
  2164. target.allocations = nil
  2165. } else {
  2166. // --- [begin][read][slice]([]*AllocationSet) ---
  2167. b := buff.ReadInt() // array len
  2168. a := make([]*AllocationSet, b)
  2169. for i := 0; i < b; i++ {
  2170. var c *AllocationSet
  2171. if buff.ReadUInt8() == uint8(0) {
  2172. c = nil
  2173. } else {
  2174. // --- [begin][read][struct](AllocationSet) ---
  2175. d := &AllocationSet{}
  2176. buff.ReadInt() // [compatibility, unused]
  2177. errA := d.UnmarshalBinaryWithContext(ctx)
  2178. if errA != nil {
  2179. return errA
  2180. }
  2181. c = d
  2182. // --- [end][read][struct](AllocationSet) ---
  2183. }
  2184. a[i] = c
  2185. }
  2186. target.allocations = a
  2187. // --- [end][read][slice]([]*AllocationSet) ---
  2188. }
  2189. } else {
  2190. target.allocations = nil
  2191. }
  2192. if uint8(0) /* field version */ <= version {
  2193. var f string
  2194. if ctx.IsStringTable() {
  2195. g := buff.ReadInt() // read string index
  2196. f = ctx.Table[g]
  2197. } else {
  2198. f = buff.ReadString() // read string
  2199. }
  2200. e := f
  2201. target.FromStore = e
  2202. } else {
  2203. target.FromStore = "" // default
  2204. }
  2205. return nil
  2206. }
  2207. //--------------------------------------------------------------------------
  2208. // Any
  2209. //--------------------------------------------------------------------------
  2210. // MarshalBinary serializes the internal properties of this Any instance
  2211. // into a byte array
  2212. func (target *Any) MarshalBinary() (data []byte, err error) {
  2213. ctx := &EncodingContext{
  2214. Buffer: util.NewBuffer(),
  2215. Table: nil,
  2216. }
  2217. e := target.MarshalBinaryWithContext(ctx)
  2218. if e != nil {
  2219. return nil, e
  2220. }
  2221. encBytes := ctx.Buffer.Bytes()
  2222. return encBytes, nil
  2223. }
  2224. // MarshalBinaryWithContext serializes the internal properties of this Any instance
  2225. // into a byte array leveraging a predefined context.
  2226. func (target *Any) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2227. // panics are recovered and propagated as errors
  2228. defer func() {
  2229. if r := recover(); r != nil {
  2230. if e, ok := r.(error); ok {
  2231. err = e
  2232. } else if s, ok := r.(string); ok {
  2233. err = fmt.Errorf("Unexpected panic: %s", s)
  2234. } else {
  2235. err = fmt.Errorf("Unexpected panic: %+v", r)
  2236. }
  2237. }
  2238. }()
  2239. buff := ctx.Buffer
  2240. buff.WriteUInt8(AssetsCodecVersion) // version
  2241. // --- [begin][write][alias](AssetLabels) ---
  2242. if map[string]string(target.labels) == nil {
  2243. buff.WriteUInt8(uint8(0)) // write nil byte
  2244. } else {
  2245. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2246. // --- [begin][write][map](map[string]string) ---
  2247. buff.WriteInt(len(map[string]string(target.labels))) // map length
  2248. for v, z := range map[string]string(target.labels) {
  2249. if ctx.IsStringTable() {
  2250. a := ctx.Table.AddOrGet(v)
  2251. buff.WriteInt(a) // write table index
  2252. } else {
  2253. buff.WriteString(v) // write string
  2254. }
  2255. if ctx.IsStringTable() {
  2256. b := ctx.Table.AddOrGet(z)
  2257. buff.WriteInt(b) // write table index
  2258. } else {
  2259. buff.WriteString(z) // write string
  2260. }
  2261. }
  2262. // --- [end][write][map](map[string]string) ---
  2263. }
  2264. // --- [end][write][alias](AssetLabels) ---
  2265. if target.properties == nil {
  2266. buff.WriteUInt8(uint8(0)) // write nil byte
  2267. } else {
  2268. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2269. // --- [begin][write][struct](AssetProperties) ---
  2270. buff.WriteInt(0) // [compatibility, unused]
  2271. errA := target.properties.MarshalBinaryWithContext(ctx)
  2272. if errA != nil {
  2273. return errA
  2274. }
  2275. // --- [end][write][struct](AssetProperties) ---
  2276. }
  2277. // --- [begin][write][reference](time.Time) ---
  2278. c, errB := target.start.MarshalBinary()
  2279. if errB != nil {
  2280. return errB
  2281. }
  2282. buff.WriteInt(len(c))
  2283. buff.WriteBytes(c)
  2284. // --- [end][write][reference](time.Time) ---
  2285. // --- [begin][write][reference](time.Time) ---
  2286. d, errC := target.end.MarshalBinary()
  2287. if errC != nil {
  2288. return errC
  2289. }
  2290. buff.WriteInt(len(d))
  2291. buff.WriteBytes(d)
  2292. // --- [end][write][reference](time.Time) ---
  2293. // --- [begin][write][struct](Window) ---
  2294. buff.WriteInt(0) // [compatibility, unused]
  2295. errD := target.window.MarshalBinaryWithContext(ctx)
  2296. if errD != nil {
  2297. return errD
  2298. }
  2299. // --- [end][write][struct](Window) ---
  2300. buff.WriteFloat64(target.adjustment) // write float64
  2301. buff.WriteFloat64(target.Cost) // write float64
  2302. return nil
  2303. }
  2304. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2305. // the Any type
  2306. func (target *Any) UnmarshalBinary(data []byte) error {
  2307. var table []string
  2308. buff := util.NewBufferFromBytes(data)
  2309. // string table header validation
  2310. if isBinaryTag(data, BinaryTagStringTable) {
  2311. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  2312. tl := buff.ReadInt() // table length
  2313. if tl > 0 {
  2314. table = make([]string, tl, tl)
  2315. for i := 0; i < tl; i++ {
  2316. table[i] = buff.ReadString()
  2317. }
  2318. }
  2319. }
  2320. ctx := &DecodingContext{
  2321. Buffer: buff,
  2322. Table: table,
  2323. }
  2324. err := target.UnmarshalBinaryWithContext(ctx)
  2325. if err != nil {
  2326. return err
  2327. }
  2328. return nil
  2329. }
  2330. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2331. // the Any type
  2332. func (target *Any) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2333. // panics are recovered and propagated as errors
  2334. defer func() {
  2335. if r := recover(); r != nil {
  2336. if e, ok := r.(error); ok {
  2337. err = e
  2338. } else if s, ok := r.(string); ok {
  2339. err = fmt.Errorf("Unexpected panic: %s", s)
  2340. } else {
  2341. err = fmt.Errorf("Unexpected panic: %+v", r)
  2342. }
  2343. }
  2344. }()
  2345. buff := ctx.Buffer
  2346. version := buff.ReadUInt8()
  2347. if version > AssetsCodecVersion {
  2348. return fmt.Errorf("Invalid Version Unmarshaling Any. Expected %d or less, got %d", AssetsCodecVersion, version)
  2349. }
  2350. if uint8(0) /* field version */ <= version {
  2351. // --- [begin][read][alias](AssetLabels) ---
  2352. var a map[string]string
  2353. if buff.ReadUInt8() == uint8(0) {
  2354. a = nil
  2355. } else {
  2356. // --- [begin][read][map](map[string]string) ---
  2357. c := buff.ReadInt() // map len
  2358. b := make(map[string]string, c)
  2359. for i := 0; i < c; i++ {
  2360. var v string
  2361. var e string
  2362. if ctx.IsStringTable() {
  2363. f := buff.ReadInt() // read string index
  2364. e = ctx.Table[f]
  2365. } else {
  2366. e = buff.ReadString() // read string
  2367. }
  2368. d := e
  2369. v = d
  2370. var z string
  2371. var h string
  2372. if ctx.IsStringTable() {
  2373. k := buff.ReadInt() // read string index
  2374. h = ctx.Table[k]
  2375. } else {
  2376. h = buff.ReadString() // read string
  2377. }
  2378. g := h
  2379. z = g
  2380. b[v] = z
  2381. }
  2382. a = b
  2383. // --- [end][read][map](map[string]string) ---
  2384. }
  2385. target.labels = AssetLabels(a)
  2386. // --- [end][read][alias](AssetLabels) ---
  2387. } else {
  2388. }
  2389. if uint8(0) /* field version */ <= version {
  2390. if buff.ReadUInt8() == uint8(0) {
  2391. target.properties = nil
  2392. } else {
  2393. // --- [begin][read][struct](AssetProperties) ---
  2394. l := &AssetProperties{}
  2395. buff.ReadInt() // [compatibility, unused]
  2396. errA := l.UnmarshalBinaryWithContext(ctx)
  2397. if errA != nil {
  2398. return errA
  2399. }
  2400. target.properties = l
  2401. // --- [end][read][struct](AssetProperties) ---
  2402. }
  2403. } else {
  2404. target.properties = nil
  2405. }
  2406. if uint8(0) /* field version */ <= version {
  2407. // --- [begin][read][reference](time.Time) ---
  2408. m := &time.Time{}
  2409. n := buff.ReadInt() // byte array length
  2410. o := buff.ReadBytes(n) // byte array
  2411. errB := m.UnmarshalBinary(o)
  2412. if errB != nil {
  2413. return errB
  2414. }
  2415. target.start = *m
  2416. // --- [end][read][reference](time.Time) ---
  2417. } else {
  2418. }
  2419. if uint8(0) /* field version */ <= version {
  2420. // --- [begin][read][reference](time.Time) ---
  2421. p := &time.Time{}
  2422. q := buff.ReadInt() // byte array length
  2423. r := buff.ReadBytes(q) // byte array
  2424. errC := p.UnmarshalBinary(r)
  2425. if errC != nil {
  2426. return errC
  2427. }
  2428. target.end = *p
  2429. // --- [end][read][reference](time.Time) ---
  2430. } else {
  2431. }
  2432. if uint8(0) /* field version */ <= version {
  2433. // --- [begin][read][struct](Window) ---
  2434. s := &Window{}
  2435. buff.ReadInt() // [compatibility, unused]
  2436. errD := s.UnmarshalBinaryWithContext(ctx)
  2437. if errD != nil {
  2438. return errD
  2439. }
  2440. target.window = *s
  2441. // --- [end][read][struct](Window) ---
  2442. } else {
  2443. }
  2444. if uint8(0) /* field version */ <= version {
  2445. t := buff.ReadFloat64() // read float64
  2446. target.adjustment = t
  2447. } else {
  2448. target.adjustment = float64(0) // default
  2449. }
  2450. if uint8(0) /* field version */ <= version {
  2451. u := buff.ReadFloat64() // read float64
  2452. target.Cost = u
  2453. } else {
  2454. target.Cost = float64(0) // default
  2455. }
  2456. return nil
  2457. }
  2458. //--------------------------------------------------------------------------
  2459. // AssetProperties
  2460. //--------------------------------------------------------------------------
  2461. // MarshalBinary serializes the internal properties of this AssetProperties instance
  2462. // into a byte array
  2463. func (target *AssetProperties) MarshalBinary() (data []byte, err error) {
  2464. ctx := &EncodingContext{
  2465. Buffer: util.NewBuffer(),
  2466. Table: nil,
  2467. }
  2468. e := target.MarshalBinaryWithContext(ctx)
  2469. if e != nil {
  2470. return nil, e
  2471. }
  2472. encBytes := ctx.Buffer.Bytes()
  2473. return encBytes, nil
  2474. }
  2475. // MarshalBinaryWithContext serializes the internal properties of this AssetProperties instance
  2476. // into a byte array leveraging a predefined context.
  2477. func (target *AssetProperties) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2478. // panics are recovered and propagated as errors
  2479. defer func() {
  2480. if r := recover(); r != nil {
  2481. if e, ok := r.(error); ok {
  2482. err = e
  2483. } else if s, ok := r.(string); ok {
  2484. err = fmt.Errorf("Unexpected panic: %s", s)
  2485. } else {
  2486. err = fmt.Errorf("Unexpected panic: %+v", r)
  2487. }
  2488. }
  2489. }()
  2490. buff := ctx.Buffer
  2491. buff.WriteUInt8(AssetsCodecVersion) // version
  2492. if ctx.IsStringTable() {
  2493. a := ctx.Table.AddOrGet(target.Category)
  2494. buff.WriteInt(a) // write table index
  2495. } else {
  2496. buff.WriteString(target.Category) // write string
  2497. }
  2498. if ctx.IsStringTable() {
  2499. b := ctx.Table.AddOrGet(target.Provider)
  2500. buff.WriteInt(b) // write table index
  2501. } else {
  2502. buff.WriteString(target.Provider) // write string
  2503. }
  2504. if ctx.IsStringTable() {
  2505. c := ctx.Table.AddOrGet(target.Account)
  2506. buff.WriteInt(c) // write table index
  2507. } else {
  2508. buff.WriteString(target.Account) // write string
  2509. }
  2510. if ctx.IsStringTable() {
  2511. d := ctx.Table.AddOrGet(target.Project)
  2512. buff.WriteInt(d) // write table index
  2513. } else {
  2514. buff.WriteString(target.Project) // write string
  2515. }
  2516. if ctx.IsStringTable() {
  2517. e := ctx.Table.AddOrGet(target.Service)
  2518. buff.WriteInt(e) // write table index
  2519. } else {
  2520. buff.WriteString(target.Service) // write string
  2521. }
  2522. if ctx.IsStringTable() {
  2523. f := ctx.Table.AddOrGet(target.Cluster)
  2524. buff.WriteInt(f) // write table index
  2525. } else {
  2526. buff.WriteString(target.Cluster) // write string
  2527. }
  2528. if ctx.IsStringTable() {
  2529. g := ctx.Table.AddOrGet(target.Name)
  2530. buff.WriteInt(g) // write table index
  2531. } else {
  2532. buff.WriteString(target.Name) // write string
  2533. }
  2534. if ctx.IsStringTable() {
  2535. h := ctx.Table.AddOrGet(target.ProviderID)
  2536. buff.WriteInt(h) // write table index
  2537. } else {
  2538. buff.WriteString(target.ProviderID) // write string
  2539. }
  2540. return nil
  2541. }
  2542. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2543. // the AssetProperties type
  2544. func (target *AssetProperties) UnmarshalBinary(data []byte) error {
  2545. var table []string
  2546. buff := util.NewBufferFromBytes(data)
  2547. // string table header validation
  2548. if isBinaryTag(data, BinaryTagStringTable) {
  2549. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  2550. tl := buff.ReadInt() // table length
  2551. if tl > 0 {
  2552. table = make([]string, tl, tl)
  2553. for i := 0; i < tl; i++ {
  2554. table[i] = buff.ReadString()
  2555. }
  2556. }
  2557. }
  2558. ctx := &DecodingContext{
  2559. Buffer: buff,
  2560. Table: table,
  2561. }
  2562. err := target.UnmarshalBinaryWithContext(ctx)
  2563. if err != nil {
  2564. return err
  2565. }
  2566. return nil
  2567. }
  2568. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2569. // the AssetProperties type
  2570. func (target *AssetProperties) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2571. // panics are recovered and propagated as errors
  2572. defer func() {
  2573. if r := recover(); r != nil {
  2574. if e, ok := r.(error); ok {
  2575. err = e
  2576. } else if s, ok := r.(string); ok {
  2577. err = fmt.Errorf("Unexpected panic: %s", s)
  2578. } else {
  2579. err = fmt.Errorf("Unexpected panic: %+v", r)
  2580. }
  2581. }
  2582. }()
  2583. buff := ctx.Buffer
  2584. version := buff.ReadUInt8()
  2585. if version > AssetsCodecVersion {
  2586. return fmt.Errorf("Invalid Version Unmarshaling AssetProperties. Expected %d or less, got %d", AssetsCodecVersion, version)
  2587. }
  2588. if uint8(0) /* field version */ <= version {
  2589. var b string
  2590. if ctx.IsStringTable() {
  2591. c := buff.ReadInt() // read string index
  2592. b = ctx.Table[c]
  2593. } else {
  2594. b = buff.ReadString() // read string
  2595. }
  2596. a := b
  2597. target.Category = a
  2598. } else {
  2599. target.Category = "" // default
  2600. }
  2601. if uint8(0) /* field version */ <= version {
  2602. var e string
  2603. if ctx.IsStringTable() {
  2604. f := buff.ReadInt() // read string index
  2605. e = ctx.Table[f]
  2606. } else {
  2607. e = buff.ReadString() // read string
  2608. }
  2609. d := e
  2610. target.Provider = d
  2611. } else {
  2612. target.Provider = "" // default
  2613. }
  2614. if uint8(0) /* field version */ <= version {
  2615. var h string
  2616. if ctx.IsStringTable() {
  2617. k := buff.ReadInt() // read string index
  2618. h = ctx.Table[k]
  2619. } else {
  2620. h = buff.ReadString() // read string
  2621. }
  2622. g := h
  2623. target.Account = g
  2624. } else {
  2625. target.Account = "" // default
  2626. }
  2627. if uint8(0) /* field version */ <= version {
  2628. var m string
  2629. if ctx.IsStringTable() {
  2630. n := buff.ReadInt() // read string index
  2631. m = ctx.Table[n]
  2632. } else {
  2633. m = buff.ReadString() // read string
  2634. }
  2635. l := m
  2636. target.Project = l
  2637. } else {
  2638. target.Project = "" // default
  2639. }
  2640. if uint8(0) /* field version */ <= version {
  2641. var p string
  2642. if ctx.IsStringTable() {
  2643. q := buff.ReadInt() // read string index
  2644. p = ctx.Table[q]
  2645. } else {
  2646. p = buff.ReadString() // read string
  2647. }
  2648. o := p
  2649. target.Service = o
  2650. } else {
  2651. target.Service = "" // default
  2652. }
  2653. if uint8(0) /* field version */ <= version {
  2654. var s string
  2655. if ctx.IsStringTable() {
  2656. t := buff.ReadInt() // read string index
  2657. s = ctx.Table[t]
  2658. } else {
  2659. s = buff.ReadString() // read string
  2660. }
  2661. r := s
  2662. target.Cluster = r
  2663. } else {
  2664. target.Cluster = "" // default
  2665. }
  2666. if uint8(0) /* field version */ <= version {
  2667. var w string
  2668. if ctx.IsStringTable() {
  2669. x := buff.ReadInt() // read string index
  2670. w = ctx.Table[x]
  2671. } else {
  2672. w = buff.ReadString() // read string
  2673. }
  2674. u := w
  2675. target.Name = u
  2676. } else {
  2677. target.Name = "" // default
  2678. }
  2679. if uint8(0) /* field version */ <= version {
  2680. var aa string
  2681. if ctx.IsStringTable() {
  2682. bb := buff.ReadInt() // read string index
  2683. aa = ctx.Table[bb]
  2684. } else {
  2685. aa = buff.ReadString() // read string
  2686. }
  2687. y := aa
  2688. target.ProviderID = y
  2689. } else {
  2690. target.ProviderID = "" // default
  2691. }
  2692. return nil
  2693. }
  2694. //--------------------------------------------------------------------------
  2695. // AssetReconciliationAudit
  2696. //--------------------------------------------------------------------------
  2697. // MarshalBinary serializes the internal properties of this AssetReconciliationAudit instance
  2698. // into a byte array
  2699. func (target *AssetReconciliationAudit) MarshalBinary() (data []byte, err error) {
  2700. ctx := &EncodingContext{
  2701. Buffer: util.NewBuffer(),
  2702. Table: nil,
  2703. }
  2704. e := target.MarshalBinaryWithContext(ctx)
  2705. if e != nil {
  2706. return nil, e
  2707. }
  2708. encBytes := ctx.Buffer.Bytes()
  2709. return encBytes, nil
  2710. }
  2711. // MarshalBinaryWithContext serializes the internal properties of this AssetReconciliationAudit instance
  2712. // into a byte array leveraging a predefined context.
  2713. func (target *AssetReconciliationAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2714. // panics are recovered and propagated as errors
  2715. defer func() {
  2716. if r := recover(); r != nil {
  2717. if e, ok := r.(error); ok {
  2718. err = e
  2719. } else if s, ok := r.(string); ok {
  2720. err = fmt.Errorf("Unexpected panic: %s", s)
  2721. } else {
  2722. err = fmt.Errorf("Unexpected panic: %+v", r)
  2723. }
  2724. }
  2725. }()
  2726. buff := ctx.Buffer
  2727. buff.WriteUInt8(AuditCodecVersion) // version
  2728. // --- [begin][write][alias](AuditStatus) ---
  2729. if ctx.IsStringTable() {
  2730. a := ctx.Table.AddOrGet(string(target.Status))
  2731. buff.WriteInt(a) // write table index
  2732. } else {
  2733. buff.WriteString(string(target.Status)) // write string
  2734. }
  2735. // --- [end][write][alias](AuditStatus) ---
  2736. if ctx.IsStringTable() {
  2737. b := ctx.Table.AddOrGet(target.Description)
  2738. buff.WriteInt(b) // write table index
  2739. } else {
  2740. buff.WriteString(target.Description) // write string
  2741. }
  2742. // --- [begin][write][reference](time.Time) ---
  2743. c, errA := target.LastRun.MarshalBinary()
  2744. if errA != nil {
  2745. return errA
  2746. }
  2747. buff.WriteInt(len(c))
  2748. buff.WriteBytes(c)
  2749. // --- [end][write][reference](time.Time) ---
  2750. if target.Results == nil {
  2751. buff.WriteUInt8(uint8(0)) // write nil byte
  2752. } else {
  2753. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2754. // --- [begin][write][map](map[string]map[string]*AuditFloatResult) ---
  2755. buff.WriteInt(len(target.Results)) // map length
  2756. for v, z := range target.Results {
  2757. if ctx.IsStringTable() {
  2758. d := ctx.Table.AddOrGet(v)
  2759. buff.WriteInt(d) // write table index
  2760. } else {
  2761. buff.WriteString(v) // write string
  2762. }
  2763. if z == nil {
  2764. buff.WriteUInt8(uint8(0)) // write nil byte
  2765. } else {
  2766. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2767. // --- [begin][write][map](map[string]*AuditFloatResult) ---
  2768. buff.WriteInt(len(z)) // map length
  2769. for vv, zz := range z {
  2770. if ctx.IsStringTable() {
  2771. e := ctx.Table.AddOrGet(vv)
  2772. buff.WriteInt(e) // write table index
  2773. } else {
  2774. buff.WriteString(vv) // write string
  2775. }
  2776. if zz == nil {
  2777. buff.WriteUInt8(uint8(0)) // write nil byte
  2778. } else {
  2779. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2780. // --- [begin][write][struct](AuditFloatResult) ---
  2781. buff.WriteInt(0) // [compatibility, unused]
  2782. errB := zz.MarshalBinaryWithContext(ctx)
  2783. if errB != nil {
  2784. return errB
  2785. }
  2786. // --- [end][write][struct](AuditFloatResult) ---
  2787. }
  2788. }
  2789. // --- [end][write][map](map[string]*AuditFloatResult) ---
  2790. }
  2791. }
  2792. // --- [end][write][map](map[string]map[string]*AuditFloatResult) ---
  2793. }
  2794. if target.MissingValues == nil {
  2795. buff.WriteUInt8(uint8(0)) // write nil byte
  2796. } else {
  2797. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2798. // --- [begin][write][slice]([]*AuditMissingValue) ---
  2799. buff.WriteInt(len(target.MissingValues)) // array length
  2800. for i := 0; i < len(target.MissingValues); i++ {
  2801. if target.MissingValues[i] == nil {
  2802. buff.WriteUInt8(uint8(0)) // write nil byte
  2803. } else {
  2804. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2805. // --- [begin][write][struct](AuditMissingValue) ---
  2806. buff.WriteInt(0) // [compatibility, unused]
  2807. errC := target.MissingValues[i].MarshalBinaryWithContext(ctx)
  2808. if errC != nil {
  2809. return errC
  2810. }
  2811. // --- [end][write][struct](AuditMissingValue) ---
  2812. }
  2813. }
  2814. // --- [end][write][slice]([]*AuditMissingValue) ---
  2815. }
  2816. return nil
  2817. }
  2818. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2819. // the AssetReconciliationAudit type
  2820. func (target *AssetReconciliationAudit) UnmarshalBinary(data []byte) error {
  2821. var table []string
  2822. buff := util.NewBufferFromBytes(data)
  2823. // string table header validation
  2824. if isBinaryTag(data, BinaryTagStringTable) {
  2825. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  2826. tl := buff.ReadInt() // table length
  2827. if tl > 0 {
  2828. table = make([]string, tl, tl)
  2829. for i := 0; i < tl; i++ {
  2830. table[i] = buff.ReadString()
  2831. }
  2832. }
  2833. }
  2834. ctx := &DecodingContext{
  2835. Buffer: buff,
  2836. Table: table,
  2837. }
  2838. err := target.UnmarshalBinaryWithContext(ctx)
  2839. if err != nil {
  2840. return err
  2841. }
  2842. return nil
  2843. }
  2844. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2845. // the AssetReconciliationAudit type
  2846. func (target *AssetReconciliationAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2847. // panics are recovered and propagated as errors
  2848. defer func() {
  2849. if r := recover(); r != nil {
  2850. if e, ok := r.(error); ok {
  2851. err = e
  2852. } else if s, ok := r.(string); ok {
  2853. err = fmt.Errorf("Unexpected panic: %s", s)
  2854. } else {
  2855. err = fmt.Errorf("Unexpected panic: %+v", r)
  2856. }
  2857. }
  2858. }()
  2859. buff := ctx.Buffer
  2860. version := buff.ReadUInt8()
  2861. if version > AuditCodecVersion {
  2862. return fmt.Errorf("Invalid Version Unmarshaling AssetReconciliationAudit. Expected %d or less, got %d", AuditCodecVersion, version)
  2863. }
  2864. if uint8(0) /* field version */ <= version {
  2865. // --- [begin][read][alias](AuditStatus) ---
  2866. var a string
  2867. var c string
  2868. if ctx.IsStringTable() {
  2869. d := buff.ReadInt() // read string index
  2870. c = ctx.Table[d]
  2871. } else {
  2872. c = buff.ReadString() // read string
  2873. }
  2874. b := c
  2875. a = b
  2876. target.Status = AuditStatus(a)
  2877. // --- [end][read][alias](AuditStatus) ---
  2878. } else {
  2879. }
  2880. if uint8(0) /* field version */ <= version {
  2881. var f string
  2882. if ctx.IsStringTable() {
  2883. g := buff.ReadInt() // read string index
  2884. f = ctx.Table[g]
  2885. } else {
  2886. f = buff.ReadString() // read string
  2887. }
  2888. e := f
  2889. target.Description = e
  2890. } else {
  2891. target.Description = "" // default
  2892. }
  2893. if uint8(0) /* field version */ <= version {
  2894. // --- [begin][read][reference](time.Time) ---
  2895. h := &time.Time{}
  2896. k := buff.ReadInt() // byte array length
  2897. l := buff.ReadBytes(k) // byte array
  2898. errA := h.UnmarshalBinary(l)
  2899. if errA != nil {
  2900. return errA
  2901. }
  2902. target.LastRun = *h
  2903. // --- [end][read][reference](time.Time) ---
  2904. } else {
  2905. }
  2906. if uint8(0) /* field version */ <= version {
  2907. if buff.ReadUInt8() == uint8(0) {
  2908. target.Results = nil
  2909. } else {
  2910. // --- [begin][read][map](map[string]map[string]*AuditFloatResult) ---
  2911. n := buff.ReadInt() // map len
  2912. m := make(map[string]map[string]*AuditFloatResult, n)
  2913. for i := 0; i < n; i++ {
  2914. var v string
  2915. var p string
  2916. if ctx.IsStringTable() {
  2917. q := buff.ReadInt() // read string index
  2918. p = ctx.Table[q]
  2919. } else {
  2920. p = buff.ReadString() // read string
  2921. }
  2922. o := p
  2923. v = o
  2924. var z map[string]*AuditFloatResult
  2925. if buff.ReadUInt8() == uint8(0) {
  2926. z = nil
  2927. } else {
  2928. // --- [begin][read][map](map[string]*AuditFloatResult) ---
  2929. s := buff.ReadInt() // map len
  2930. r := make(map[string]*AuditFloatResult, s)
  2931. for j := 0; j < s; j++ {
  2932. var vv string
  2933. var u string
  2934. if ctx.IsStringTable() {
  2935. w := buff.ReadInt() // read string index
  2936. u = ctx.Table[w]
  2937. } else {
  2938. u = buff.ReadString() // read string
  2939. }
  2940. t := u
  2941. vv = t
  2942. var zz *AuditFloatResult
  2943. if buff.ReadUInt8() == uint8(0) {
  2944. zz = nil
  2945. } else {
  2946. // --- [begin][read][struct](AuditFloatResult) ---
  2947. x := &AuditFloatResult{}
  2948. buff.ReadInt() // [compatibility, unused]
  2949. errB := x.UnmarshalBinaryWithContext(ctx)
  2950. if errB != nil {
  2951. return errB
  2952. }
  2953. zz = x
  2954. // --- [end][read][struct](AuditFloatResult) ---
  2955. }
  2956. r[vv] = zz
  2957. }
  2958. z = r
  2959. // --- [end][read][map](map[string]*AuditFloatResult) ---
  2960. }
  2961. m[v] = z
  2962. }
  2963. target.Results = m
  2964. // --- [end][read][map](map[string]map[string]*AuditFloatResult) ---
  2965. }
  2966. } else {
  2967. target.Results = nil
  2968. }
  2969. if uint8(0) /* field version */ <= version {
  2970. if buff.ReadUInt8() == uint8(0) {
  2971. target.MissingValues = nil
  2972. } else {
  2973. // --- [begin][read][slice]([]*AuditMissingValue) ---
  2974. aa := buff.ReadInt() // array len
  2975. y := make([]*AuditMissingValue, aa)
  2976. for ii := 0; ii < aa; ii++ {
  2977. var bb *AuditMissingValue
  2978. if buff.ReadUInt8() == uint8(0) {
  2979. bb = nil
  2980. } else {
  2981. // --- [begin][read][struct](AuditMissingValue) ---
  2982. cc := &AuditMissingValue{}
  2983. buff.ReadInt() // [compatibility, unused]
  2984. errC := cc.UnmarshalBinaryWithContext(ctx)
  2985. if errC != nil {
  2986. return errC
  2987. }
  2988. bb = cc
  2989. // --- [end][read][struct](AuditMissingValue) ---
  2990. }
  2991. y[ii] = bb
  2992. }
  2993. target.MissingValues = y
  2994. // --- [end][read][slice]([]*AuditMissingValue) ---
  2995. }
  2996. } else {
  2997. target.MissingValues = nil
  2998. }
  2999. return nil
  3000. }
  3001. //--------------------------------------------------------------------------
  3002. // AssetSet
  3003. //--------------------------------------------------------------------------
  3004. // MarshalBinary serializes the internal properties of this AssetSet instance
  3005. // into a byte array
  3006. func (target *AssetSet) MarshalBinary() (data []byte, err error) {
  3007. ctx := &EncodingContext{
  3008. Buffer: util.NewBuffer(),
  3009. Table: NewStringTable(),
  3010. }
  3011. e := target.MarshalBinaryWithContext(ctx)
  3012. if e != nil {
  3013. return nil, e
  3014. }
  3015. encBytes := ctx.Buffer.Bytes()
  3016. sTableBytes := ctx.Table.ToBytes()
  3017. merged := appendBytes(sTableBytes, encBytes)
  3018. return merged, nil
  3019. }
  3020. // MarshalBinaryWithContext serializes the internal properties of this AssetSet instance
  3021. // into a byte array leveraging a predefined context.
  3022. func (target *AssetSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  3023. // panics are recovered and propagated as errors
  3024. defer func() {
  3025. if r := recover(); r != nil {
  3026. if e, ok := r.(error); ok {
  3027. err = e
  3028. } else if s, ok := r.(string); ok {
  3029. err = fmt.Errorf("Unexpected panic: %s", s)
  3030. } else {
  3031. err = fmt.Errorf("Unexpected panic: %+v", r)
  3032. }
  3033. }
  3034. }()
  3035. buff := ctx.Buffer
  3036. buff.WriteUInt8(AssetsCodecVersion) // version
  3037. if target.aggregateBy == nil {
  3038. buff.WriteUInt8(uint8(0)) // write nil byte
  3039. } else {
  3040. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3041. // --- [begin][write][slice]([]string) ---
  3042. buff.WriteInt(len(target.aggregateBy)) // array length
  3043. for i := 0; i < len(target.aggregateBy); i++ {
  3044. if ctx.IsStringTable() {
  3045. a := ctx.Table.AddOrGet(target.aggregateBy[i])
  3046. buff.WriteInt(a) // write table index
  3047. } else {
  3048. buff.WriteString(target.aggregateBy[i]) // write string
  3049. }
  3050. }
  3051. // --- [end][write][slice]([]string) ---
  3052. }
  3053. if target.assets == nil {
  3054. buff.WriteUInt8(uint8(0)) // write nil byte
  3055. } else {
  3056. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3057. // --- [begin][write][map](map[string]Asset) ---
  3058. buff.WriteInt(len(target.assets)) // map length
  3059. for v, z := range target.assets {
  3060. if ctx.IsStringTable() {
  3061. b := ctx.Table.AddOrGet(v)
  3062. buff.WriteInt(b) // write table index
  3063. } else {
  3064. buff.WriteString(v) // write string
  3065. }
  3066. if z == nil {
  3067. buff.WriteUInt8(uint8(0)) // write nil byte
  3068. } else {
  3069. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3070. // --- [begin][write][interface](Asset) ---
  3071. c := reflect.ValueOf(z).Interface()
  3072. d, okA := c.(BinEncoder)
  3073. if !okA {
  3074. return fmt.Errorf("Type: %s does not implement %s.BinEncoder", typeToString(z), GeneratorPackageName)
  3075. }
  3076. buff.WriteString(typeToString(z))
  3077. buff.WriteInt(0) // [compatibility, unused]
  3078. errA := d.MarshalBinaryWithContext(ctx)
  3079. if errA != nil {
  3080. return errA
  3081. }
  3082. // --- [end][write][interface](Asset) ---
  3083. }
  3084. }
  3085. // --- [end][write][map](map[string]Asset) ---
  3086. }
  3087. if ctx.IsStringTable() {
  3088. e := ctx.Table.AddOrGet(target.FromSource)
  3089. buff.WriteInt(e) // write table index
  3090. } else {
  3091. buff.WriteString(target.FromSource) // write string
  3092. }
  3093. // --- [begin][write][struct](Window) ---
  3094. buff.WriteInt(0) // [compatibility, unused]
  3095. errB := target.Window.MarshalBinaryWithContext(ctx)
  3096. if errB != nil {
  3097. return errB
  3098. }
  3099. // --- [end][write][struct](Window) ---
  3100. if target.Warnings == nil {
  3101. buff.WriteUInt8(uint8(0)) // write nil byte
  3102. } else {
  3103. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3104. // --- [begin][write][slice]([]string) ---
  3105. buff.WriteInt(len(target.Warnings)) // array length
  3106. for j := 0; j < len(target.Warnings); j++ {
  3107. if ctx.IsStringTable() {
  3108. f := ctx.Table.AddOrGet(target.Warnings[j])
  3109. buff.WriteInt(f) // write table index
  3110. } else {
  3111. buff.WriteString(target.Warnings[j]) // write string
  3112. }
  3113. }
  3114. // --- [end][write][slice]([]string) ---
  3115. }
  3116. if target.Errors == nil {
  3117. buff.WriteUInt8(uint8(0)) // write nil byte
  3118. } else {
  3119. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3120. // --- [begin][write][slice]([]string) ---
  3121. buff.WriteInt(len(target.Errors)) // array length
  3122. for ii := 0; ii < len(target.Errors); ii++ {
  3123. if ctx.IsStringTable() {
  3124. g := ctx.Table.AddOrGet(target.Errors[ii])
  3125. buff.WriteInt(g) // write table index
  3126. } else {
  3127. buff.WriteString(target.Errors[ii]) // write string
  3128. }
  3129. }
  3130. // --- [end][write][slice]([]string) ---
  3131. }
  3132. return nil
  3133. }
  3134. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  3135. // the AssetSet type
  3136. func (target *AssetSet) UnmarshalBinary(data []byte) error {
  3137. var table []string
  3138. buff := util.NewBufferFromBytes(data)
  3139. // string table header validation
  3140. if isBinaryTag(data, BinaryTagStringTable) {
  3141. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  3142. tl := buff.ReadInt() // table length
  3143. if tl > 0 {
  3144. table = make([]string, tl, tl)
  3145. for i := 0; i < tl; i++ {
  3146. table[i] = buff.ReadString()
  3147. }
  3148. }
  3149. }
  3150. ctx := &DecodingContext{
  3151. Buffer: buff,
  3152. Table: table,
  3153. }
  3154. err := target.UnmarshalBinaryWithContext(ctx)
  3155. if err != nil {
  3156. return err
  3157. }
  3158. return nil
  3159. }
  3160. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  3161. // the AssetSet type
  3162. func (target *AssetSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  3163. // panics are recovered and propagated as errors
  3164. defer func() {
  3165. if r := recover(); r != nil {
  3166. if e, ok := r.(error); ok {
  3167. err = e
  3168. } else if s, ok := r.(string); ok {
  3169. err = fmt.Errorf("Unexpected panic: %s", s)
  3170. } else {
  3171. err = fmt.Errorf("Unexpected panic: %+v", r)
  3172. }
  3173. }
  3174. }()
  3175. buff := ctx.Buffer
  3176. version := buff.ReadUInt8()
  3177. if version > AssetsCodecVersion {
  3178. return fmt.Errorf("Invalid Version Unmarshaling AssetSet. Expected %d or less, got %d", AssetsCodecVersion, version)
  3179. }
  3180. if uint8(0) /* field version */ <= version {
  3181. if buff.ReadUInt8() == uint8(0) {
  3182. target.aggregateBy = nil
  3183. } else {
  3184. // --- [begin][read][slice]([]string) ---
  3185. b := buff.ReadInt() // array len
  3186. a := make([]string, b)
  3187. for i := 0; i < b; i++ {
  3188. var c string
  3189. var e string
  3190. if ctx.IsStringTable() {
  3191. f := buff.ReadInt() // read string index
  3192. e = ctx.Table[f]
  3193. } else {
  3194. e = buff.ReadString() // read string
  3195. }
  3196. d := e
  3197. c = d
  3198. a[i] = c
  3199. }
  3200. target.aggregateBy = a
  3201. // --- [end][read][slice]([]string) ---
  3202. }
  3203. } else {
  3204. target.aggregateBy = nil
  3205. }
  3206. if uint8(0) /* field version */ <= version {
  3207. if buff.ReadUInt8() == uint8(0) {
  3208. target.assets = nil
  3209. } else {
  3210. // --- [begin][read][map](map[string]Asset) ---
  3211. h := buff.ReadInt() // map len
  3212. g := make(map[string]Asset, h)
  3213. for j := 0; j < h; j++ {
  3214. var v string
  3215. var l string
  3216. if ctx.IsStringTable() {
  3217. m := buff.ReadInt() // read string index
  3218. l = ctx.Table[m]
  3219. } else {
  3220. l = buff.ReadString() // read string
  3221. }
  3222. k := l
  3223. v = k
  3224. var z Asset
  3225. if buff.ReadUInt8() == uint8(0) {
  3226. z = nil
  3227. } else {
  3228. // --- [begin][read][interface](Asset) ---
  3229. n := buff.ReadString()
  3230. _, o, _ := resolveType(n)
  3231. if _, ok := typeMap[o]; !ok {
  3232. return fmt.Errorf("Unknown Type: %s", o)
  3233. }
  3234. p, okA := reflect.New(typeMap[o]).Interface().(BinDecoder)
  3235. if !okA {
  3236. return fmt.Errorf("Type: %s does not implement %s.BinDecoder.", o, GeneratorPackageName)
  3237. }
  3238. buff.ReadInt() // [compatibility, unused]
  3239. errA := p.UnmarshalBinaryWithContext(ctx)
  3240. if errA != nil {
  3241. return errA
  3242. }
  3243. z = p.(Asset)
  3244. // --- [end][read][interface](Asset) ---
  3245. }
  3246. g[v] = z
  3247. }
  3248. target.assets = g
  3249. // --- [end][read][map](map[string]Asset) ---
  3250. }
  3251. } else {
  3252. target.assets = nil
  3253. }
  3254. if uint8(0) /* field version */ <= version {
  3255. var r string
  3256. if ctx.IsStringTable() {
  3257. s := buff.ReadInt() // read string index
  3258. r = ctx.Table[s]
  3259. } else {
  3260. r = buff.ReadString() // read string
  3261. }
  3262. q := r
  3263. target.FromSource = q
  3264. } else {
  3265. target.FromSource = "" // default
  3266. }
  3267. if uint8(0) /* field version */ <= version {
  3268. // --- [begin][read][struct](Window) ---
  3269. t := &Window{}
  3270. buff.ReadInt() // [compatibility, unused]
  3271. errB := t.UnmarshalBinaryWithContext(ctx)
  3272. if errB != nil {
  3273. return errB
  3274. }
  3275. target.Window = *t
  3276. // --- [end][read][struct](Window) ---
  3277. } else {
  3278. }
  3279. if uint8(0) /* field version */ <= version {
  3280. if buff.ReadUInt8() == uint8(0) {
  3281. target.Warnings = nil
  3282. } else {
  3283. // --- [begin][read][slice]([]string) ---
  3284. w := buff.ReadInt() // array len
  3285. u := make([]string, w)
  3286. for ii := 0; ii < w; ii++ {
  3287. var x string
  3288. var aa string
  3289. if ctx.IsStringTable() {
  3290. bb := buff.ReadInt() // read string index
  3291. aa = ctx.Table[bb]
  3292. } else {
  3293. aa = buff.ReadString() // read string
  3294. }
  3295. y := aa
  3296. x = y
  3297. u[ii] = x
  3298. }
  3299. target.Warnings = u
  3300. // --- [end][read][slice]([]string) ---
  3301. }
  3302. } else {
  3303. target.Warnings = nil
  3304. }
  3305. if uint8(0) /* field version */ <= version {
  3306. if buff.ReadUInt8() == uint8(0) {
  3307. target.Errors = nil
  3308. } else {
  3309. // --- [begin][read][slice]([]string) ---
  3310. dd := buff.ReadInt() // array len
  3311. cc := make([]string, dd)
  3312. for jj := 0; jj < dd; jj++ {
  3313. var ee string
  3314. var gg string
  3315. if ctx.IsStringTable() {
  3316. hh := buff.ReadInt() // read string index
  3317. gg = ctx.Table[hh]
  3318. } else {
  3319. gg = buff.ReadString() // read string
  3320. }
  3321. ff := gg
  3322. ee = ff
  3323. cc[jj] = ee
  3324. }
  3325. target.Errors = cc
  3326. // --- [end][read][slice]([]string) ---
  3327. }
  3328. } else {
  3329. target.Errors = nil
  3330. }
  3331. return nil
  3332. }
  3333. //--------------------------------------------------------------------------
  3334. // AssetSetRange
  3335. //--------------------------------------------------------------------------
  3336. // MarshalBinary serializes the internal properties of this AssetSetRange instance
  3337. // into a byte array
  3338. func (target *AssetSetRange) MarshalBinary() (data []byte, err error) {
  3339. ctx := &EncodingContext{
  3340. Buffer: util.NewBuffer(),
  3341. Table: nil,
  3342. }
  3343. e := target.MarshalBinaryWithContext(ctx)
  3344. if e != nil {
  3345. return nil, e
  3346. }
  3347. encBytes := ctx.Buffer.Bytes()
  3348. return encBytes, nil
  3349. }
  3350. // MarshalBinaryWithContext serializes the internal properties of this AssetSetRange instance
  3351. // into a byte array leveraging a predefined context.
  3352. func (target *AssetSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  3353. // panics are recovered and propagated as errors
  3354. defer func() {
  3355. if r := recover(); r != nil {
  3356. if e, ok := r.(error); ok {
  3357. err = e
  3358. } else if s, ok := r.(string); ok {
  3359. err = fmt.Errorf("Unexpected panic: %s", s)
  3360. } else {
  3361. err = fmt.Errorf("Unexpected panic: %+v", r)
  3362. }
  3363. }
  3364. }()
  3365. buff := ctx.Buffer
  3366. buff.WriteUInt8(AssetsCodecVersion) // version
  3367. if target.assets == nil {
  3368. buff.WriteUInt8(uint8(0)) // write nil byte
  3369. } else {
  3370. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3371. // --- [begin][write][slice]([]*AssetSet) ---
  3372. buff.WriteInt(len(target.assets)) // array length
  3373. for i := 0; i < len(target.assets); i++ {
  3374. if target.assets[i] == nil {
  3375. buff.WriteUInt8(uint8(0)) // write nil byte
  3376. } else {
  3377. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3378. // --- [begin][write][struct](AssetSet) ---
  3379. buff.WriteInt(0) // [compatibility, unused]
  3380. errA := target.assets[i].MarshalBinaryWithContext(ctx)
  3381. if errA != nil {
  3382. return errA
  3383. }
  3384. // --- [end][write][struct](AssetSet) ---
  3385. }
  3386. }
  3387. // --- [end][write][slice]([]*AssetSet) ---
  3388. }
  3389. if ctx.IsStringTable() {
  3390. a := ctx.Table.AddOrGet(target.FromStore)
  3391. buff.WriteInt(a) // write table index
  3392. } else {
  3393. buff.WriteString(target.FromStore) // write string
  3394. }
  3395. return nil
  3396. }
  3397. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  3398. // the AssetSetRange type
  3399. func (target *AssetSetRange) UnmarshalBinary(data []byte) error {
  3400. var table []string
  3401. buff := util.NewBufferFromBytes(data)
  3402. // string table header validation
  3403. if isBinaryTag(data, BinaryTagStringTable) {
  3404. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  3405. tl := buff.ReadInt() // table length
  3406. if tl > 0 {
  3407. table = make([]string, tl, tl)
  3408. for i := 0; i < tl; i++ {
  3409. table[i] = buff.ReadString()
  3410. }
  3411. }
  3412. }
  3413. ctx := &DecodingContext{
  3414. Buffer: buff,
  3415. Table: table,
  3416. }
  3417. err := target.UnmarshalBinaryWithContext(ctx)
  3418. if err != nil {
  3419. return err
  3420. }
  3421. return nil
  3422. }
  3423. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  3424. // the AssetSetRange type
  3425. func (target *AssetSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  3426. // panics are recovered and propagated as errors
  3427. defer func() {
  3428. if r := recover(); r != nil {
  3429. if e, ok := r.(error); ok {
  3430. err = e
  3431. } else if s, ok := r.(string); ok {
  3432. err = fmt.Errorf("Unexpected panic: %s", s)
  3433. } else {
  3434. err = fmt.Errorf("Unexpected panic: %+v", r)
  3435. }
  3436. }
  3437. }()
  3438. buff := ctx.Buffer
  3439. version := buff.ReadUInt8()
  3440. if version > AssetsCodecVersion {
  3441. return fmt.Errorf("Invalid Version Unmarshaling AssetSetRange. Expected %d or less, got %d", AssetsCodecVersion, version)
  3442. }
  3443. if uint8(0) /* field version */ <= version {
  3444. if buff.ReadUInt8() == uint8(0) {
  3445. target.assets = nil
  3446. } else {
  3447. // --- [begin][read][slice]([]*AssetSet) ---
  3448. b := buff.ReadInt() // array len
  3449. a := make([]*AssetSet, b)
  3450. for i := 0; i < b; i++ {
  3451. var c *AssetSet
  3452. if buff.ReadUInt8() == uint8(0) {
  3453. c = nil
  3454. } else {
  3455. // --- [begin][read][struct](AssetSet) ---
  3456. d := &AssetSet{}
  3457. buff.ReadInt() // [compatibility, unused]
  3458. errA := d.UnmarshalBinaryWithContext(ctx)
  3459. if errA != nil {
  3460. return errA
  3461. }
  3462. c = d
  3463. // --- [end][read][struct](AssetSet) ---
  3464. }
  3465. a[i] = c
  3466. }
  3467. target.assets = a
  3468. // --- [end][read][slice]([]*AssetSet) ---
  3469. }
  3470. } else {
  3471. target.assets = nil
  3472. }
  3473. if uint8(0) /* field version */ <= version {
  3474. var f string
  3475. if ctx.IsStringTable() {
  3476. g := buff.ReadInt() // read string index
  3477. f = ctx.Table[g]
  3478. } else {
  3479. f = buff.ReadString() // read string
  3480. }
  3481. e := f
  3482. target.FromStore = e
  3483. } else {
  3484. target.FromStore = "" // default
  3485. }
  3486. return nil
  3487. }
  3488. //--------------------------------------------------------------------------
  3489. // AuditFloatResult
  3490. //--------------------------------------------------------------------------
  3491. // MarshalBinary serializes the internal properties of this AuditFloatResult instance
  3492. // into a byte array
  3493. func (target *AuditFloatResult) MarshalBinary() (data []byte, err error) {
  3494. ctx := &EncodingContext{
  3495. Buffer: util.NewBuffer(),
  3496. Table: nil,
  3497. }
  3498. e := target.MarshalBinaryWithContext(ctx)
  3499. if e != nil {
  3500. return nil, e
  3501. }
  3502. encBytes := ctx.Buffer.Bytes()
  3503. return encBytes, nil
  3504. }
  3505. // MarshalBinaryWithContext serializes the internal properties of this AuditFloatResult instance
  3506. // into a byte array leveraging a predefined context.
  3507. func (target *AuditFloatResult) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  3508. // panics are recovered and propagated as errors
  3509. defer func() {
  3510. if r := recover(); r != nil {
  3511. if e, ok := r.(error); ok {
  3512. err = e
  3513. } else if s, ok := r.(string); ok {
  3514. err = fmt.Errorf("Unexpected panic: %s", s)
  3515. } else {
  3516. err = fmt.Errorf("Unexpected panic: %+v", r)
  3517. }
  3518. }
  3519. }()
  3520. buff := ctx.Buffer
  3521. buff.WriteUInt8(AuditCodecVersion) // version
  3522. buff.WriteFloat64(target.Expected) // write float64
  3523. buff.WriteFloat64(target.Actual) // write float64
  3524. return nil
  3525. }
  3526. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  3527. // the AuditFloatResult type
  3528. func (target *AuditFloatResult) UnmarshalBinary(data []byte) error {
  3529. var table []string
  3530. buff := util.NewBufferFromBytes(data)
  3531. // string table header validation
  3532. if isBinaryTag(data, BinaryTagStringTable) {
  3533. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  3534. tl := buff.ReadInt() // table length
  3535. if tl > 0 {
  3536. table = make([]string, tl, tl)
  3537. for i := 0; i < tl; i++ {
  3538. table[i] = buff.ReadString()
  3539. }
  3540. }
  3541. }
  3542. ctx := &DecodingContext{
  3543. Buffer: buff,
  3544. Table: table,
  3545. }
  3546. err := target.UnmarshalBinaryWithContext(ctx)
  3547. if err != nil {
  3548. return err
  3549. }
  3550. return nil
  3551. }
  3552. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  3553. // the AuditFloatResult type
  3554. func (target *AuditFloatResult) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  3555. // panics are recovered and propagated as errors
  3556. defer func() {
  3557. if r := recover(); r != nil {
  3558. if e, ok := r.(error); ok {
  3559. err = e
  3560. } else if s, ok := r.(string); ok {
  3561. err = fmt.Errorf("Unexpected panic: %s", s)
  3562. } else {
  3563. err = fmt.Errorf("Unexpected panic: %+v", r)
  3564. }
  3565. }
  3566. }()
  3567. buff := ctx.Buffer
  3568. version := buff.ReadUInt8()
  3569. if version > AuditCodecVersion {
  3570. return fmt.Errorf("Invalid Version Unmarshaling AuditFloatResult. Expected %d or less, got %d", AuditCodecVersion, version)
  3571. }
  3572. if uint8(0) /* field version */ <= version {
  3573. a := buff.ReadFloat64() // read float64
  3574. target.Expected = a
  3575. } else {
  3576. target.Expected = float64(0) // default
  3577. }
  3578. if uint8(0) /* field version */ <= version {
  3579. b := buff.ReadFloat64() // read float64
  3580. target.Actual = b
  3581. } else {
  3582. target.Actual = float64(0) // default
  3583. }
  3584. return nil
  3585. }
  3586. //--------------------------------------------------------------------------
  3587. // AuditMissingValue
  3588. //--------------------------------------------------------------------------
  3589. // MarshalBinary serializes the internal properties of this AuditMissingValue instance
  3590. // into a byte array
  3591. func (target *AuditMissingValue) MarshalBinary() (data []byte, err error) {
  3592. ctx := &EncodingContext{
  3593. Buffer: util.NewBuffer(),
  3594. Table: nil,
  3595. }
  3596. e := target.MarshalBinaryWithContext(ctx)
  3597. if e != nil {
  3598. return nil, e
  3599. }
  3600. encBytes := ctx.Buffer.Bytes()
  3601. return encBytes, nil
  3602. }
  3603. // MarshalBinaryWithContext serializes the internal properties of this AuditMissingValue instance
  3604. // into a byte array leveraging a predefined context.
  3605. func (target *AuditMissingValue) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  3606. // panics are recovered and propagated as errors
  3607. defer func() {
  3608. if r := recover(); r != nil {
  3609. if e, ok := r.(error); ok {
  3610. err = e
  3611. } else if s, ok := r.(string); ok {
  3612. err = fmt.Errorf("Unexpected panic: %s", s)
  3613. } else {
  3614. err = fmt.Errorf("Unexpected panic: %+v", r)
  3615. }
  3616. }
  3617. }()
  3618. buff := ctx.Buffer
  3619. buff.WriteUInt8(AuditCodecVersion) // version
  3620. if ctx.IsStringTable() {
  3621. a := ctx.Table.AddOrGet(target.Description)
  3622. buff.WriteInt(a) // write table index
  3623. } else {
  3624. buff.WriteString(target.Description) // write string
  3625. }
  3626. if ctx.IsStringTable() {
  3627. b := ctx.Table.AddOrGet(target.Key)
  3628. buff.WriteInt(b) // write table index
  3629. } else {
  3630. buff.WriteString(target.Key) // write string
  3631. }
  3632. return nil
  3633. }
  3634. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  3635. // the AuditMissingValue type
  3636. func (target *AuditMissingValue) UnmarshalBinary(data []byte) error {
  3637. var table []string
  3638. buff := util.NewBufferFromBytes(data)
  3639. // string table header validation
  3640. if isBinaryTag(data, BinaryTagStringTable) {
  3641. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  3642. tl := buff.ReadInt() // table length
  3643. if tl > 0 {
  3644. table = make([]string, tl, tl)
  3645. for i := 0; i < tl; i++ {
  3646. table[i] = buff.ReadString()
  3647. }
  3648. }
  3649. }
  3650. ctx := &DecodingContext{
  3651. Buffer: buff,
  3652. Table: table,
  3653. }
  3654. err := target.UnmarshalBinaryWithContext(ctx)
  3655. if err != nil {
  3656. return err
  3657. }
  3658. return nil
  3659. }
  3660. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  3661. // the AuditMissingValue type
  3662. func (target *AuditMissingValue) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  3663. // panics are recovered and propagated as errors
  3664. defer func() {
  3665. if r := recover(); r != nil {
  3666. if e, ok := r.(error); ok {
  3667. err = e
  3668. } else if s, ok := r.(string); ok {
  3669. err = fmt.Errorf("Unexpected panic: %s", s)
  3670. } else {
  3671. err = fmt.Errorf("Unexpected panic: %+v", r)
  3672. }
  3673. }
  3674. }()
  3675. buff := ctx.Buffer
  3676. version := buff.ReadUInt8()
  3677. if version > AuditCodecVersion {
  3678. return fmt.Errorf("Invalid Version Unmarshaling AuditMissingValue. Expected %d or less, got %d", AuditCodecVersion, version)
  3679. }
  3680. if uint8(0) /* field version */ <= version {
  3681. var b string
  3682. if ctx.IsStringTable() {
  3683. c := buff.ReadInt() // read string index
  3684. b = ctx.Table[c]
  3685. } else {
  3686. b = buff.ReadString() // read string
  3687. }
  3688. a := b
  3689. target.Description = a
  3690. } else {
  3691. target.Description = "" // default
  3692. }
  3693. if uint8(0) /* field version */ <= version {
  3694. var e string
  3695. if ctx.IsStringTable() {
  3696. f := buff.ReadInt() // read string index
  3697. e = ctx.Table[f]
  3698. } else {
  3699. e = buff.ReadString() // read string
  3700. }
  3701. d := e
  3702. target.Key = d
  3703. } else {
  3704. target.Key = "" // default
  3705. }
  3706. return nil
  3707. }
  3708. //--------------------------------------------------------------------------
  3709. // AuditSet
  3710. //--------------------------------------------------------------------------
  3711. // MarshalBinary serializes the internal properties of this AuditSet instance
  3712. // into a byte array
  3713. func (target *AuditSet) MarshalBinary() (data []byte, err error) {
  3714. ctx := &EncodingContext{
  3715. Buffer: util.NewBuffer(),
  3716. Table: NewStringTable(),
  3717. }
  3718. e := target.MarshalBinaryWithContext(ctx)
  3719. if e != nil {
  3720. return nil, e
  3721. }
  3722. encBytes := ctx.Buffer.Bytes()
  3723. sTableBytes := ctx.Table.ToBytes()
  3724. merged := appendBytes(sTableBytes, encBytes)
  3725. return merged, nil
  3726. }
  3727. // MarshalBinaryWithContext serializes the internal properties of this AuditSet instance
  3728. // into a byte array leveraging a predefined context.
  3729. func (target *AuditSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  3730. // panics are recovered and propagated as errors
  3731. defer func() {
  3732. if r := recover(); r != nil {
  3733. if e, ok := r.(error); ok {
  3734. err = e
  3735. } else if s, ok := r.(string); ok {
  3736. err = fmt.Errorf("Unexpected panic: %s", s)
  3737. } else {
  3738. err = fmt.Errorf("Unexpected panic: %+v", r)
  3739. }
  3740. }
  3741. }()
  3742. buff := ctx.Buffer
  3743. buff.WriteUInt8(AuditCodecVersion) // version
  3744. if target.AllocationReconciliation == nil {
  3745. buff.WriteUInt8(uint8(0)) // write nil byte
  3746. } else {
  3747. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3748. // --- [begin][write][struct](AllocationReconciliationAudit) ---
  3749. buff.WriteInt(0) // [compatibility, unused]
  3750. errA := target.AllocationReconciliation.MarshalBinaryWithContext(ctx)
  3751. if errA != nil {
  3752. return errA
  3753. }
  3754. // --- [end][write][struct](AllocationReconciliationAudit) ---
  3755. }
  3756. if target.AllocationAgg == nil {
  3757. buff.WriteUInt8(uint8(0)) // write nil byte
  3758. } else {
  3759. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3760. // --- [begin][write][struct](AggAudit) ---
  3761. buff.WriteInt(0) // [compatibility, unused]
  3762. errB := target.AllocationAgg.MarshalBinaryWithContext(ctx)
  3763. if errB != nil {
  3764. return errB
  3765. }
  3766. // --- [end][write][struct](AggAudit) ---
  3767. }
  3768. if target.AllocationTotal == nil {
  3769. buff.WriteUInt8(uint8(0)) // write nil byte
  3770. } else {
  3771. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3772. // --- [begin][write][struct](TotalAudit) ---
  3773. buff.WriteInt(0) // [compatibility, unused]
  3774. errC := target.AllocationTotal.MarshalBinaryWithContext(ctx)
  3775. if errC != nil {
  3776. return errC
  3777. }
  3778. // --- [end][write][struct](TotalAudit) ---
  3779. }
  3780. if target.AssetTotal == nil {
  3781. buff.WriteUInt8(uint8(0)) // write nil byte
  3782. } else {
  3783. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3784. // --- [begin][write][struct](TotalAudit) ---
  3785. buff.WriteInt(0) // [compatibility, unused]
  3786. errD := target.AssetTotal.MarshalBinaryWithContext(ctx)
  3787. if errD != nil {
  3788. return errD
  3789. }
  3790. // --- [end][write][struct](TotalAudit) ---
  3791. }
  3792. if target.AssetReconciliation == nil {
  3793. buff.WriteUInt8(uint8(0)) // write nil byte
  3794. } else {
  3795. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3796. // --- [begin][write][struct](AssetReconciliationAudit) ---
  3797. buff.WriteInt(0) // [compatibility, unused]
  3798. errE := target.AssetReconciliation.MarshalBinaryWithContext(ctx)
  3799. if errE != nil {
  3800. return errE
  3801. }
  3802. // --- [end][write][struct](AssetReconciliationAudit) ---
  3803. }
  3804. if target.ClusterEquality == nil {
  3805. buff.WriteUInt8(uint8(0)) // write nil byte
  3806. } else {
  3807. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3808. // --- [begin][write][struct](EqualityAudit) ---
  3809. buff.WriteInt(0) // [compatibility, unused]
  3810. errF := target.ClusterEquality.MarshalBinaryWithContext(ctx)
  3811. if errF != nil {
  3812. return errF
  3813. }
  3814. // --- [end][write][struct](EqualityAudit) ---
  3815. }
  3816. // --- [begin][write][struct](Window) ---
  3817. buff.WriteInt(0) // [compatibility, unused]
  3818. errG := target.Window.MarshalBinaryWithContext(ctx)
  3819. if errG != nil {
  3820. return errG
  3821. }
  3822. // --- [end][write][struct](Window) ---
  3823. return nil
  3824. }
  3825. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  3826. // the AuditSet type
  3827. func (target *AuditSet) UnmarshalBinary(data []byte) error {
  3828. var table []string
  3829. buff := util.NewBufferFromBytes(data)
  3830. // string table header validation
  3831. if isBinaryTag(data, BinaryTagStringTable) {
  3832. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  3833. tl := buff.ReadInt() // table length
  3834. if tl > 0 {
  3835. table = make([]string, tl, tl)
  3836. for i := 0; i < tl; i++ {
  3837. table[i] = buff.ReadString()
  3838. }
  3839. }
  3840. }
  3841. ctx := &DecodingContext{
  3842. Buffer: buff,
  3843. Table: table,
  3844. }
  3845. err := target.UnmarshalBinaryWithContext(ctx)
  3846. if err != nil {
  3847. return err
  3848. }
  3849. return nil
  3850. }
  3851. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  3852. // the AuditSet type
  3853. func (target *AuditSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  3854. // panics are recovered and propagated as errors
  3855. defer func() {
  3856. if r := recover(); r != nil {
  3857. if e, ok := r.(error); ok {
  3858. err = e
  3859. } else if s, ok := r.(string); ok {
  3860. err = fmt.Errorf("Unexpected panic: %s", s)
  3861. } else {
  3862. err = fmt.Errorf("Unexpected panic: %+v", r)
  3863. }
  3864. }
  3865. }()
  3866. buff := ctx.Buffer
  3867. version := buff.ReadUInt8()
  3868. if version > AuditCodecVersion {
  3869. return fmt.Errorf("Invalid Version Unmarshaling AuditSet. Expected %d or less, got %d", AuditCodecVersion, version)
  3870. }
  3871. if uint8(0) /* field version */ <= version {
  3872. if buff.ReadUInt8() == uint8(0) {
  3873. target.AllocationReconciliation = nil
  3874. } else {
  3875. // --- [begin][read][struct](AllocationReconciliationAudit) ---
  3876. a := &AllocationReconciliationAudit{}
  3877. buff.ReadInt() // [compatibility, unused]
  3878. errA := a.UnmarshalBinaryWithContext(ctx)
  3879. if errA != nil {
  3880. return errA
  3881. }
  3882. target.AllocationReconciliation = a
  3883. // --- [end][read][struct](AllocationReconciliationAudit) ---
  3884. }
  3885. } else {
  3886. target.AllocationReconciliation = nil
  3887. }
  3888. if uint8(0) /* field version */ <= version {
  3889. if buff.ReadUInt8() == uint8(0) {
  3890. target.AllocationAgg = nil
  3891. } else {
  3892. // --- [begin][read][struct](AggAudit) ---
  3893. b := &AggAudit{}
  3894. buff.ReadInt() // [compatibility, unused]
  3895. errB := b.UnmarshalBinaryWithContext(ctx)
  3896. if errB != nil {
  3897. return errB
  3898. }
  3899. target.AllocationAgg = b
  3900. // --- [end][read][struct](AggAudit) ---
  3901. }
  3902. } else {
  3903. target.AllocationAgg = nil
  3904. }
  3905. if uint8(0) /* field version */ <= version {
  3906. if buff.ReadUInt8() == uint8(0) {
  3907. target.AllocationTotal = nil
  3908. } else {
  3909. // --- [begin][read][struct](TotalAudit) ---
  3910. c := &TotalAudit{}
  3911. buff.ReadInt() // [compatibility, unused]
  3912. errC := c.UnmarshalBinaryWithContext(ctx)
  3913. if errC != nil {
  3914. return errC
  3915. }
  3916. target.AllocationTotal = c
  3917. // --- [end][read][struct](TotalAudit) ---
  3918. }
  3919. } else {
  3920. target.AllocationTotal = nil
  3921. }
  3922. if uint8(0) /* field version */ <= version {
  3923. if buff.ReadUInt8() == uint8(0) {
  3924. target.AssetTotal = nil
  3925. } else {
  3926. // --- [begin][read][struct](TotalAudit) ---
  3927. d := &TotalAudit{}
  3928. buff.ReadInt() // [compatibility, unused]
  3929. errD := d.UnmarshalBinaryWithContext(ctx)
  3930. if errD != nil {
  3931. return errD
  3932. }
  3933. target.AssetTotal = d
  3934. // --- [end][read][struct](TotalAudit) ---
  3935. }
  3936. } else {
  3937. target.AssetTotal = nil
  3938. }
  3939. if uint8(0) /* field version */ <= version {
  3940. if buff.ReadUInt8() == uint8(0) {
  3941. target.AssetReconciliation = nil
  3942. } else {
  3943. // --- [begin][read][struct](AssetReconciliationAudit) ---
  3944. e := &AssetReconciliationAudit{}
  3945. buff.ReadInt() // [compatibility, unused]
  3946. errE := e.UnmarshalBinaryWithContext(ctx)
  3947. if errE != nil {
  3948. return errE
  3949. }
  3950. target.AssetReconciliation = e
  3951. // --- [end][read][struct](AssetReconciliationAudit) ---
  3952. }
  3953. } else {
  3954. target.AssetReconciliation = nil
  3955. }
  3956. if uint8(0) /* field version */ <= version {
  3957. if buff.ReadUInt8() == uint8(0) {
  3958. target.ClusterEquality = nil
  3959. } else {
  3960. // --- [begin][read][struct](EqualityAudit) ---
  3961. f := &EqualityAudit{}
  3962. buff.ReadInt() // [compatibility, unused]
  3963. errF := f.UnmarshalBinaryWithContext(ctx)
  3964. if errF != nil {
  3965. return errF
  3966. }
  3967. target.ClusterEquality = f
  3968. // --- [end][read][struct](EqualityAudit) ---
  3969. }
  3970. } else {
  3971. target.ClusterEquality = nil
  3972. }
  3973. if uint8(0) /* field version */ <= version {
  3974. // --- [begin][read][struct](Window) ---
  3975. g := &Window{}
  3976. buff.ReadInt() // [compatibility, unused]
  3977. errG := g.UnmarshalBinaryWithContext(ctx)
  3978. if errG != nil {
  3979. return errG
  3980. }
  3981. target.Window = *g
  3982. // --- [end][read][struct](Window) ---
  3983. } else {
  3984. }
  3985. return nil
  3986. }
  3987. //--------------------------------------------------------------------------
  3988. // AuditSetRange
  3989. //--------------------------------------------------------------------------
  3990. // MarshalBinary serializes the internal properties of this AuditSetRange instance
  3991. // into a byte array
  3992. func (target *AuditSetRange) MarshalBinary() (data []byte, err error) {
  3993. ctx := &EncodingContext{
  3994. Buffer: util.NewBuffer(),
  3995. Table: nil,
  3996. }
  3997. e := target.MarshalBinaryWithContext(ctx)
  3998. if e != nil {
  3999. return nil, e
  4000. }
  4001. encBytes := ctx.Buffer.Bytes()
  4002. return encBytes, nil
  4003. }
  4004. // MarshalBinaryWithContext serializes the internal properties of this AuditSetRange instance
  4005. // into a byte array leveraging a predefined context.
  4006. func (target *AuditSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4007. // panics are recovered and propagated as errors
  4008. defer func() {
  4009. if r := recover(); r != nil {
  4010. if e, ok := r.(error); ok {
  4011. err = e
  4012. } else if s, ok := r.(string); ok {
  4013. err = fmt.Errorf("Unexpected panic: %s", s)
  4014. } else {
  4015. err = fmt.Errorf("Unexpected panic: %+v", r)
  4016. }
  4017. }
  4018. }()
  4019. buff := ctx.Buffer
  4020. buff.WriteUInt8(AuditCodecVersion) // version
  4021. return nil
  4022. }
  4023. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4024. // the AuditSetRange type
  4025. func (target *AuditSetRange) UnmarshalBinary(data []byte) error {
  4026. var table []string
  4027. buff := util.NewBufferFromBytes(data)
  4028. // string table header validation
  4029. if isBinaryTag(data, BinaryTagStringTable) {
  4030. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4031. tl := buff.ReadInt() // table length
  4032. if tl > 0 {
  4033. table = make([]string, tl, tl)
  4034. for i := 0; i < tl; i++ {
  4035. table[i] = buff.ReadString()
  4036. }
  4037. }
  4038. }
  4039. ctx := &DecodingContext{
  4040. Buffer: buff,
  4041. Table: table,
  4042. }
  4043. err := target.UnmarshalBinaryWithContext(ctx)
  4044. if err != nil {
  4045. return err
  4046. }
  4047. return nil
  4048. }
  4049. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4050. // the AuditSetRange type
  4051. func (target *AuditSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4052. // panics are recovered and propagated as errors
  4053. defer func() {
  4054. if r := recover(); r != nil {
  4055. if e, ok := r.(error); ok {
  4056. err = e
  4057. } else if s, ok := r.(string); ok {
  4058. err = fmt.Errorf("Unexpected panic: %s", s)
  4059. } else {
  4060. err = fmt.Errorf("Unexpected panic: %+v", r)
  4061. }
  4062. }
  4063. }()
  4064. buff := ctx.Buffer
  4065. version := buff.ReadUInt8()
  4066. if version > AuditCodecVersion {
  4067. return fmt.Errorf("Invalid Version Unmarshaling AuditSetRange. Expected %d or less, got %d", AuditCodecVersion, version)
  4068. }
  4069. return nil
  4070. }
  4071. //--------------------------------------------------------------------------
  4072. // Breakdown
  4073. //--------------------------------------------------------------------------
  4074. // MarshalBinary serializes the internal properties of this Breakdown instance
  4075. // into a byte array
  4076. func (target *Breakdown) MarshalBinary() (data []byte, err error) {
  4077. ctx := &EncodingContext{
  4078. Buffer: util.NewBuffer(),
  4079. Table: nil,
  4080. }
  4081. e := target.MarshalBinaryWithContext(ctx)
  4082. if e != nil {
  4083. return nil, e
  4084. }
  4085. encBytes := ctx.Buffer.Bytes()
  4086. return encBytes, nil
  4087. }
  4088. // MarshalBinaryWithContext serializes the internal properties of this Breakdown instance
  4089. // into a byte array leveraging a predefined context.
  4090. func (target *Breakdown) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4091. // panics are recovered and propagated as errors
  4092. defer func() {
  4093. if r := recover(); r != nil {
  4094. if e, ok := r.(error); ok {
  4095. err = e
  4096. } else if s, ok := r.(string); ok {
  4097. err = fmt.Errorf("Unexpected panic: %s", s)
  4098. } else {
  4099. err = fmt.Errorf("Unexpected panic: %+v", r)
  4100. }
  4101. }
  4102. }()
  4103. buff := ctx.Buffer
  4104. buff.WriteUInt8(AssetsCodecVersion) // version
  4105. buff.WriteFloat64(target.Idle) // write float64
  4106. buff.WriteFloat64(target.Other) // write float64
  4107. buff.WriteFloat64(target.System) // write float64
  4108. buff.WriteFloat64(target.User) // write float64
  4109. return nil
  4110. }
  4111. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4112. // the Breakdown type
  4113. func (target *Breakdown) UnmarshalBinary(data []byte) error {
  4114. var table []string
  4115. buff := util.NewBufferFromBytes(data)
  4116. // string table header validation
  4117. if isBinaryTag(data, BinaryTagStringTable) {
  4118. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4119. tl := buff.ReadInt() // table length
  4120. if tl > 0 {
  4121. table = make([]string, tl, tl)
  4122. for i := 0; i < tl; i++ {
  4123. table[i] = buff.ReadString()
  4124. }
  4125. }
  4126. }
  4127. ctx := &DecodingContext{
  4128. Buffer: buff,
  4129. Table: table,
  4130. }
  4131. err := target.UnmarshalBinaryWithContext(ctx)
  4132. if err != nil {
  4133. return err
  4134. }
  4135. return nil
  4136. }
  4137. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4138. // the Breakdown type
  4139. func (target *Breakdown) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4140. // panics are recovered and propagated as errors
  4141. defer func() {
  4142. if r := recover(); r != nil {
  4143. if e, ok := r.(error); ok {
  4144. err = e
  4145. } else if s, ok := r.(string); ok {
  4146. err = fmt.Errorf("Unexpected panic: %s", s)
  4147. } else {
  4148. err = fmt.Errorf("Unexpected panic: %+v", r)
  4149. }
  4150. }
  4151. }()
  4152. buff := ctx.Buffer
  4153. version := buff.ReadUInt8()
  4154. if version > AssetsCodecVersion {
  4155. return fmt.Errorf("Invalid Version Unmarshaling Breakdown. Expected %d or less, got %d", AssetsCodecVersion, version)
  4156. }
  4157. if uint8(0) /* field version */ <= version {
  4158. a := buff.ReadFloat64() // read float64
  4159. target.Idle = a
  4160. } else {
  4161. target.Idle = float64(0) // default
  4162. }
  4163. if uint8(0) /* field version */ <= version {
  4164. b := buff.ReadFloat64() // read float64
  4165. target.Other = b
  4166. } else {
  4167. target.Other = float64(0) // default
  4168. }
  4169. if uint8(0) /* field version */ <= version {
  4170. c := buff.ReadFloat64() // read float64
  4171. target.System = c
  4172. } else {
  4173. target.System = float64(0) // default
  4174. }
  4175. if uint8(0) /* field version */ <= version {
  4176. d := buff.ReadFloat64() // read float64
  4177. target.User = d
  4178. } else {
  4179. target.User = float64(0) // default
  4180. }
  4181. return nil
  4182. }
  4183. //--------------------------------------------------------------------------
  4184. // Cloud
  4185. //--------------------------------------------------------------------------
  4186. // MarshalBinary serializes the internal properties of this Cloud instance
  4187. // into a byte array
  4188. func (target *Cloud) MarshalBinary() (data []byte, err error) {
  4189. ctx := &EncodingContext{
  4190. Buffer: util.NewBuffer(),
  4191. Table: nil,
  4192. }
  4193. e := target.MarshalBinaryWithContext(ctx)
  4194. if e != nil {
  4195. return nil, e
  4196. }
  4197. encBytes := ctx.Buffer.Bytes()
  4198. return encBytes, nil
  4199. }
  4200. // MarshalBinaryWithContext serializes the internal properties of this Cloud instance
  4201. // into a byte array leveraging a predefined context.
  4202. func (target *Cloud) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4203. // panics are recovered and propagated as errors
  4204. defer func() {
  4205. if r := recover(); r != nil {
  4206. if e, ok := r.(error); ok {
  4207. err = e
  4208. } else if s, ok := r.(string); ok {
  4209. err = fmt.Errorf("Unexpected panic: %s", s)
  4210. } else {
  4211. err = fmt.Errorf("Unexpected panic: %+v", r)
  4212. }
  4213. }
  4214. }()
  4215. buff := ctx.Buffer
  4216. buff.WriteUInt8(AssetsCodecVersion) // version
  4217. // --- [begin][write][alias](AssetLabels) ---
  4218. if map[string]string(target.labels) == nil {
  4219. buff.WriteUInt8(uint8(0)) // write nil byte
  4220. } else {
  4221. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4222. // --- [begin][write][map](map[string]string) ---
  4223. buff.WriteInt(len(map[string]string(target.labels))) // map length
  4224. for v, z := range map[string]string(target.labels) {
  4225. if ctx.IsStringTable() {
  4226. a := ctx.Table.AddOrGet(v)
  4227. buff.WriteInt(a) // write table index
  4228. } else {
  4229. buff.WriteString(v) // write string
  4230. }
  4231. if ctx.IsStringTable() {
  4232. b := ctx.Table.AddOrGet(z)
  4233. buff.WriteInt(b) // write table index
  4234. } else {
  4235. buff.WriteString(z) // write string
  4236. }
  4237. }
  4238. // --- [end][write][map](map[string]string) ---
  4239. }
  4240. // --- [end][write][alias](AssetLabels) ---
  4241. if target.properties == nil {
  4242. buff.WriteUInt8(uint8(0)) // write nil byte
  4243. } else {
  4244. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4245. // --- [begin][write][struct](AssetProperties) ---
  4246. buff.WriteInt(0) // [compatibility, unused]
  4247. errA := target.properties.MarshalBinaryWithContext(ctx)
  4248. if errA != nil {
  4249. return errA
  4250. }
  4251. // --- [end][write][struct](AssetProperties) ---
  4252. }
  4253. // --- [begin][write][reference](time.Time) ---
  4254. c, errB := target.start.MarshalBinary()
  4255. if errB != nil {
  4256. return errB
  4257. }
  4258. buff.WriteInt(len(c))
  4259. buff.WriteBytes(c)
  4260. // --- [end][write][reference](time.Time) ---
  4261. // --- [begin][write][reference](time.Time) ---
  4262. d, errC := target.end.MarshalBinary()
  4263. if errC != nil {
  4264. return errC
  4265. }
  4266. buff.WriteInt(len(d))
  4267. buff.WriteBytes(d)
  4268. // --- [end][write][reference](time.Time) ---
  4269. // --- [begin][write][struct](Window) ---
  4270. buff.WriteInt(0) // [compatibility, unused]
  4271. errD := target.window.MarshalBinaryWithContext(ctx)
  4272. if errD != nil {
  4273. return errD
  4274. }
  4275. // --- [end][write][struct](Window) ---
  4276. buff.WriteFloat64(target.adjustment) // write float64
  4277. buff.WriteFloat64(target.Cost) // write float64
  4278. buff.WriteFloat64(target.Credit) // write float64
  4279. return nil
  4280. }
  4281. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4282. // the Cloud type
  4283. func (target *Cloud) UnmarshalBinary(data []byte) error {
  4284. var table []string
  4285. buff := util.NewBufferFromBytes(data)
  4286. // string table header validation
  4287. if isBinaryTag(data, BinaryTagStringTable) {
  4288. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4289. tl := buff.ReadInt() // table length
  4290. if tl > 0 {
  4291. table = make([]string, tl, tl)
  4292. for i := 0; i < tl; i++ {
  4293. table[i] = buff.ReadString()
  4294. }
  4295. }
  4296. }
  4297. ctx := &DecodingContext{
  4298. Buffer: buff,
  4299. Table: table,
  4300. }
  4301. err := target.UnmarshalBinaryWithContext(ctx)
  4302. if err != nil {
  4303. return err
  4304. }
  4305. return nil
  4306. }
  4307. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4308. // the Cloud type
  4309. func (target *Cloud) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4310. // panics are recovered and propagated as errors
  4311. defer func() {
  4312. if r := recover(); r != nil {
  4313. if e, ok := r.(error); ok {
  4314. err = e
  4315. } else if s, ok := r.(string); ok {
  4316. err = fmt.Errorf("Unexpected panic: %s", s)
  4317. } else {
  4318. err = fmt.Errorf("Unexpected panic: %+v", r)
  4319. }
  4320. }
  4321. }()
  4322. buff := ctx.Buffer
  4323. version := buff.ReadUInt8()
  4324. if version > AssetsCodecVersion {
  4325. return fmt.Errorf("Invalid Version Unmarshaling Cloud. Expected %d or less, got %d", AssetsCodecVersion, version)
  4326. }
  4327. if uint8(0) /* field version */ <= version {
  4328. // --- [begin][read][alias](AssetLabels) ---
  4329. var a map[string]string
  4330. if buff.ReadUInt8() == uint8(0) {
  4331. a = nil
  4332. } else {
  4333. // --- [begin][read][map](map[string]string) ---
  4334. c := buff.ReadInt() // map len
  4335. b := make(map[string]string, c)
  4336. for i := 0; i < c; i++ {
  4337. var v string
  4338. var e string
  4339. if ctx.IsStringTable() {
  4340. f := buff.ReadInt() // read string index
  4341. e = ctx.Table[f]
  4342. } else {
  4343. e = buff.ReadString() // read string
  4344. }
  4345. d := e
  4346. v = d
  4347. var z string
  4348. var h string
  4349. if ctx.IsStringTable() {
  4350. k := buff.ReadInt() // read string index
  4351. h = ctx.Table[k]
  4352. } else {
  4353. h = buff.ReadString() // read string
  4354. }
  4355. g := h
  4356. z = g
  4357. b[v] = z
  4358. }
  4359. a = b
  4360. // --- [end][read][map](map[string]string) ---
  4361. }
  4362. target.labels = AssetLabels(a)
  4363. // --- [end][read][alias](AssetLabels) ---
  4364. } else {
  4365. }
  4366. if uint8(0) /* field version */ <= version {
  4367. if buff.ReadUInt8() == uint8(0) {
  4368. target.properties = nil
  4369. } else {
  4370. // --- [begin][read][struct](AssetProperties) ---
  4371. l := &AssetProperties{}
  4372. buff.ReadInt() // [compatibility, unused]
  4373. errA := l.UnmarshalBinaryWithContext(ctx)
  4374. if errA != nil {
  4375. return errA
  4376. }
  4377. target.properties = l
  4378. // --- [end][read][struct](AssetProperties) ---
  4379. }
  4380. } else {
  4381. target.properties = nil
  4382. }
  4383. if uint8(0) /* field version */ <= version {
  4384. // --- [begin][read][reference](time.Time) ---
  4385. m := &time.Time{}
  4386. n := buff.ReadInt() // byte array length
  4387. o := buff.ReadBytes(n) // byte array
  4388. errB := m.UnmarshalBinary(o)
  4389. if errB != nil {
  4390. return errB
  4391. }
  4392. target.start = *m
  4393. // --- [end][read][reference](time.Time) ---
  4394. } else {
  4395. }
  4396. if uint8(0) /* field version */ <= version {
  4397. // --- [begin][read][reference](time.Time) ---
  4398. p := &time.Time{}
  4399. q := buff.ReadInt() // byte array length
  4400. r := buff.ReadBytes(q) // byte array
  4401. errC := p.UnmarshalBinary(r)
  4402. if errC != nil {
  4403. return errC
  4404. }
  4405. target.end = *p
  4406. // --- [end][read][reference](time.Time) ---
  4407. } else {
  4408. }
  4409. if uint8(0) /* field version */ <= version {
  4410. // --- [begin][read][struct](Window) ---
  4411. s := &Window{}
  4412. buff.ReadInt() // [compatibility, unused]
  4413. errD := s.UnmarshalBinaryWithContext(ctx)
  4414. if errD != nil {
  4415. return errD
  4416. }
  4417. target.window = *s
  4418. // --- [end][read][struct](Window) ---
  4419. } else {
  4420. }
  4421. if uint8(0) /* field version */ <= version {
  4422. t := buff.ReadFloat64() // read float64
  4423. target.adjustment = t
  4424. } else {
  4425. target.adjustment = float64(0) // default
  4426. }
  4427. if uint8(0) /* field version */ <= version {
  4428. u := buff.ReadFloat64() // read float64
  4429. target.Cost = u
  4430. } else {
  4431. target.Cost = float64(0) // default
  4432. }
  4433. if uint8(0) /* field version */ <= version {
  4434. w := buff.ReadFloat64() // read float64
  4435. target.Credit = w
  4436. } else {
  4437. target.Credit = float64(0) // default
  4438. }
  4439. return nil
  4440. }
  4441. //--------------------------------------------------------------------------
  4442. // ClusterManagement
  4443. //--------------------------------------------------------------------------
  4444. // MarshalBinary serializes the internal properties of this ClusterManagement instance
  4445. // into a byte array
  4446. func (target *ClusterManagement) MarshalBinary() (data []byte, err error) {
  4447. ctx := &EncodingContext{
  4448. Buffer: util.NewBuffer(),
  4449. Table: nil,
  4450. }
  4451. e := target.MarshalBinaryWithContext(ctx)
  4452. if e != nil {
  4453. return nil, e
  4454. }
  4455. encBytes := ctx.Buffer.Bytes()
  4456. return encBytes, nil
  4457. }
  4458. // MarshalBinaryWithContext serializes the internal properties of this ClusterManagement instance
  4459. // into a byte array leveraging a predefined context.
  4460. func (target *ClusterManagement) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4461. // panics are recovered and propagated as errors
  4462. defer func() {
  4463. if r := recover(); r != nil {
  4464. if e, ok := r.(error); ok {
  4465. err = e
  4466. } else if s, ok := r.(string); ok {
  4467. err = fmt.Errorf("Unexpected panic: %s", s)
  4468. } else {
  4469. err = fmt.Errorf("Unexpected panic: %+v", r)
  4470. }
  4471. }
  4472. }()
  4473. buff := ctx.Buffer
  4474. buff.WriteUInt8(AssetsCodecVersion) // version
  4475. // --- [begin][write][alias](AssetLabels) ---
  4476. if map[string]string(target.labels) == nil {
  4477. buff.WriteUInt8(uint8(0)) // write nil byte
  4478. } else {
  4479. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4480. // --- [begin][write][map](map[string]string) ---
  4481. buff.WriteInt(len(map[string]string(target.labels))) // map length
  4482. for v, z := range map[string]string(target.labels) {
  4483. if ctx.IsStringTable() {
  4484. a := ctx.Table.AddOrGet(v)
  4485. buff.WriteInt(a) // write table index
  4486. } else {
  4487. buff.WriteString(v) // write string
  4488. }
  4489. if ctx.IsStringTable() {
  4490. b := ctx.Table.AddOrGet(z)
  4491. buff.WriteInt(b) // write table index
  4492. } else {
  4493. buff.WriteString(z) // write string
  4494. }
  4495. }
  4496. // --- [end][write][map](map[string]string) ---
  4497. }
  4498. // --- [end][write][alias](AssetLabels) ---
  4499. if target.properties == nil {
  4500. buff.WriteUInt8(uint8(0)) // write nil byte
  4501. } else {
  4502. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4503. // --- [begin][write][struct](AssetProperties) ---
  4504. buff.WriteInt(0) // [compatibility, unused]
  4505. errA := target.properties.MarshalBinaryWithContext(ctx)
  4506. if errA != nil {
  4507. return errA
  4508. }
  4509. // --- [end][write][struct](AssetProperties) ---
  4510. }
  4511. // --- [begin][write][struct](Window) ---
  4512. buff.WriteInt(0) // [compatibility, unused]
  4513. errB := target.window.MarshalBinaryWithContext(ctx)
  4514. if errB != nil {
  4515. return errB
  4516. }
  4517. // --- [end][write][struct](Window) ---
  4518. buff.WriteFloat64(target.adjustment) // write float64
  4519. buff.WriteFloat64(target.Cost) // write float64
  4520. return nil
  4521. }
  4522. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4523. // the ClusterManagement type
  4524. func (target *ClusterManagement) UnmarshalBinary(data []byte) error {
  4525. var table []string
  4526. buff := util.NewBufferFromBytes(data)
  4527. // string table header validation
  4528. if isBinaryTag(data, BinaryTagStringTable) {
  4529. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4530. tl := buff.ReadInt() // table length
  4531. if tl > 0 {
  4532. table = make([]string, tl, tl)
  4533. for i := 0; i < tl; i++ {
  4534. table[i] = buff.ReadString()
  4535. }
  4536. }
  4537. }
  4538. ctx := &DecodingContext{
  4539. Buffer: buff,
  4540. Table: table,
  4541. }
  4542. err := target.UnmarshalBinaryWithContext(ctx)
  4543. if err != nil {
  4544. return err
  4545. }
  4546. return nil
  4547. }
  4548. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4549. // the ClusterManagement type
  4550. func (target *ClusterManagement) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4551. // panics are recovered and propagated as errors
  4552. defer func() {
  4553. if r := recover(); r != nil {
  4554. if e, ok := r.(error); ok {
  4555. err = e
  4556. } else if s, ok := r.(string); ok {
  4557. err = fmt.Errorf("Unexpected panic: %s", s)
  4558. } else {
  4559. err = fmt.Errorf("Unexpected panic: %+v", r)
  4560. }
  4561. }
  4562. }()
  4563. buff := ctx.Buffer
  4564. version := buff.ReadUInt8()
  4565. if version > AssetsCodecVersion {
  4566. return fmt.Errorf("Invalid Version Unmarshaling ClusterManagement. Expected %d or less, got %d", AssetsCodecVersion, version)
  4567. }
  4568. if uint8(0) /* field version */ <= version {
  4569. // --- [begin][read][alias](AssetLabels) ---
  4570. var a map[string]string
  4571. if buff.ReadUInt8() == uint8(0) {
  4572. a = nil
  4573. } else {
  4574. // --- [begin][read][map](map[string]string) ---
  4575. c := buff.ReadInt() // map len
  4576. b := make(map[string]string, c)
  4577. for i := 0; i < c; i++ {
  4578. var v string
  4579. var e string
  4580. if ctx.IsStringTable() {
  4581. f := buff.ReadInt() // read string index
  4582. e = ctx.Table[f]
  4583. } else {
  4584. e = buff.ReadString() // read string
  4585. }
  4586. d := e
  4587. v = d
  4588. var z string
  4589. var h string
  4590. if ctx.IsStringTable() {
  4591. k := buff.ReadInt() // read string index
  4592. h = ctx.Table[k]
  4593. } else {
  4594. h = buff.ReadString() // read string
  4595. }
  4596. g := h
  4597. z = g
  4598. b[v] = z
  4599. }
  4600. a = b
  4601. // --- [end][read][map](map[string]string) ---
  4602. }
  4603. target.labels = AssetLabels(a)
  4604. // --- [end][read][alias](AssetLabels) ---
  4605. } else {
  4606. }
  4607. if uint8(0) /* field version */ <= version {
  4608. if buff.ReadUInt8() == uint8(0) {
  4609. target.properties = nil
  4610. } else {
  4611. // --- [begin][read][struct](AssetProperties) ---
  4612. l := &AssetProperties{}
  4613. buff.ReadInt() // [compatibility, unused]
  4614. errA := l.UnmarshalBinaryWithContext(ctx)
  4615. if errA != nil {
  4616. return errA
  4617. }
  4618. target.properties = l
  4619. // --- [end][read][struct](AssetProperties) ---
  4620. }
  4621. } else {
  4622. target.properties = nil
  4623. }
  4624. if uint8(0) /* field version */ <= version {
  4625. // --- [begin][read][struct](Window) ---
  4626. m := &Window{}
  4627. buff.ReadInt() // [compatibility, unused]
  4628. errB := m.UnmarshalBinaryWithContext(ctx)
  4629. if errB != nil {
  4630. return errB
  4631. }
  4632. target.window = *m
  4633. // --- [end][read][struct](Window) ---
  4634. } else {
  4635. }
  4636. if uint8(0) /* field version */ <= version {
  4637. n := buff.ReadFloat64() // read float64
  4638. target.adjustment = n
  4639. } else {
  4640. target.adjustment = float64(0) // default
  4641. }
  4642. if uint8(0) /* field version */ <= version {
  4643. o := buff.ReadFloat64() // read float64
  4644. target.Cost = o
  4645. } else {
  4646. target.Cost = float64(0) // default
  4647. }
  4648. return nil
  4649. }
  4650. //--------------------------------------------------------------------------
  4651. // Disk
  4652. //--------------------------------------------------------------------------
  4653. // MarshalBinary serializes the internal properties of this Disk instance
  4654. // into a byte array
  4655. func (target *Disk) MarshalBinary() (data []byte, err error) {
  4656. ctx := &EncodingContext{
  4657. Buffer: util.NewBuffer(),
  4658. Table: nil,
  4659. }
  4660. e := target.MarshalBinaryWithContext(ctx)
  4661. if e != nil {
  4662. return nil, e
  4663. }
  4664. encBytes := ctx.Buffer.Bytes()
  4665. return encBytes, nil
  4666. }
  4667. // MarshalBinaryWithContext serializes the internal properties of this Disk instance
  4668. // into a byte array leveraging a predefined context.
  4669. func (target *Disk) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4670. // panics are recovered and propagated as errors
  4671. defer func() {
  4672. if r := recover(); r != nil {
  4673. if e, ok := r.(error); ok {
  4674. err = e
  4675. } else if s, ok := r.(string); ok {
  4676. err = fmt.Errorf("Unexpected panic: %s", s)
  4677. } else {
  4678. err = fmt.Errorf("Unexpected panic: %+v", r)
  4679. }
  4680. }
  4681. }()
  4682. buff := ctx.Buffer
  4683. buff.WriteUInt8(AssetsCodecVersion) // version
  4684. // --- [begin][write][alias](AssetLabels) ---
  4685. if map[string]string(target.labels) == nil {
  4686. buff.WriteUInt8(uint8(0)) // write nil byte
  4687. } else {
  4688. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4689. // --- [begin][write][map](map[string]string) ---
  4690. buff.WriteInt(len(map[string]string(target.labels))) // map length
  4691. for v, z := range map[string]string(target.labels) {
  4692. if ctx.IsStringTable() {
  4693. a := ctx.Table.AddOrGet(v)
  4694. buff.WriteInt(a) // write table index
  4695. } else {
  4696. buff.WriteString(v) // write string
  4697. }
  4698. if ctx.IsStringTable() {
  4699. b := ctx.Table.AddOrGet(z)
  4700. buff.WriteInt(b) // write table index
  4701. } else {
  4702. buff.WriteString(z) // write string
  4703. }
  4704. }
  4705. // --- [end][write][map](map[string]string) ---
  4706. }
  4707. // --- [end][write][alias](AssetLabels) ---
  4708. if target.properties == nil {
  4709. buff.WriteUInt8(uint8(0)) // write nil byte
  4710. } else {
  4711. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4712. // --- [begin][write][struct](AssetProperties) ---
  4713. buff.WriteInt(0) // [compatibility, unused]
  4714. errA := target.properties.MarshalBinaryWithContext(ctx)
  4715. if errA != nil {
  4716. return errA
  4717. }
  4718. // --- [end][write][struct](AssetProperties) ---
  4719. }
  4720. // --- [begin][write][reference](time.Time) ---
  4721. c, errB := target.start.MarshalBinary()
  4722. if errB != nil {
  4723. return errB
  4724. }
  4725. buff.WriteInt(len(c))
  4726. buff.WriteBytes(c)
  4727. // --- [end][write][reference](time.Time) ---
  4728. // --- [begin][write][reference](time.Time) ---
  4729. d, errC := target.end.MarshalBinary()
  4730. if errC != nil {
  4731. return errC
  4732. }
  4733. buff.WriteInt(len(d))
  4734. buff.WriteBytes(d)
  4735. // --- [end][write][reference](time.Time) ---
  4736. // --- [begin][write][struct](Window) ---
  4737. buff.WriteInt(0) // [compatibility, unused]
  4738. errD := target.window.MarshalBinaryWithContext(ctx)
  4739. if errD != nil {
  4740. return errD
  4741. }
  4742. // --- [end][write][struct](Window) ---
  4743. buff.WriteFloat64(target.adjustment) // write float64
  4744. buff.WriteFloat64(target.Cost) // write float64
  4745. buff.WriteFloat64(target.ByteHours) // write float64
  4746. buff.WriteFloat64(target.Local) // write float64
  4747. if target.Breakdown == nil {
  4748. buff.WriteUInt8(uint8(0)) // write nil byte
  4749. } else {
  4750. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4751. // --- [begin][write][struct](Breakdown) ---
  4752. buff.WriteInt(0) // [compatibility, unused]
  4753. errE := target.Breakdown.MarshalBinaryWithContext(ctx)
  4754. if errE != nil {
  4755. return errE
  4756. }
  4757. // --- [end][write][struct](Breakdown) ---
  4758. }
  4759. return nil
  4760. }
  4761. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4762. // the Disk type
  4763. func (target *Disk) UnmarshalBinary(data []byte) error {
  4764. var table []string
  4765. buff := util.NewBufferFromBytes(data)
  4766. // string table header validation
  4767. if isBinaryTag(data, BinaryTagStringTable) {
  4768. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4769. tl := buff.ReadInt() // table length
  4770. if tl > 0 {
  4771. table = make([]string, tl, tl)
  4772. for i := 0; i < tl; i++ {
  4773. table[i] = buff.ReadString()
  4774. }
  4775. }
  4776. }
  4777. ctx := &DecodingContext{
  4778. Buffer: buff,
  4779. Table: table,
  4780. }
  4781. err := target.UnmarshalBinaryWithContext(ctx)
  4782. if err != nil {
  4783. return err
  4784. }
  4785. return nil
  4786. }
  4787. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4788. // the Disk type
  4789. func (target *Disk) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4790. // panics are recovered and propagated as errors
  4791. defer func() {
  4792. if r := recover(); r != nil {
  4793. if e, ok := r.(error); ok {
  4794. err = e
  4795. } else if s, ok := r.(string); ok {
  4796. err = fmt.Errorf("Unexpected panic: %s", s)
  4797. } else {
  4798. err = fmt.Errorf("Unexpected panic: %+v", r)
  4799. }
  4800. }
  4801. }()
  4802. buff := ctx.Buffer
  4803. version := buff.ReadUInt8()
  4804. if version > AssetsCodecVersion {
  4805. return fmt.Errorf("Invalid Version Unmarshaling Disk. Expected %d or less, got %d", AssetsCodecVersion, version)
  4806. }
  4807. if uint8(0) /* field version */ <= version {
  4808. // --- [begin][read][alias](AssetLabels) ---
  4809. var a map[string]string
  4810. if buff.ReadUInt8() == uint8(0) {
  4811. a = nil
  4812. } else {
  4813. // --- [begin][read][map](map[string]string) ---
  4814. c := buff.ReadInt() // map len
  4815. b := make(map[string]string, c)
  4816. for i := 0; i < c; i++ {
  4817. var v string
  4818. var e string
  4819. if ctx.IsStringTable() {
  4820. f := buff.ReadInt() // read string index
  4821. e = ctx.Table[f]
  4822. } else {
  4823. e = buff.ReadString() // read string
  4824. }
  4825. d := e
  4826. v = d
  4827. var z string
  4828. var h string
  4829. if ctx.IsStringTable() {
  4830. k := buff.ReadInt() // read string index
  4831. h = ctx.Table[k]
  4832. } else {
  4833. h = buff.ReadString() // read string
  4834. }
  4835. g := h
  4836. z = g
  4837. b[v] = z
  4838. }
  4839. a = b
  4840. // --- [end][read][map](map[string]string) ---
  4841. }
  4842. target.labels = AssetLabels(a)
  4843. // --- [end][read][alias](AssetLabels) ---
  4844. } else {
  4845. }
  4846. if uint8(0) /* field version */ <= version {
  4847. if buff.ReadUInt8() == uint8(0) {
  4848. target.properties = nil
  4849. } else {
  4850. // --- [begin][read][struct](AssetProperties) ---
  4851. l := &AssetProperties{}
  4852. buff.ReadInt() // [compatibility, unused]
  4853. errA := l.UnmarshalBinaryWithContext(ctx)
  4854. if errA != nil {
  4855. return errA
  4856. }
  4857. target.properties = l
  4858. // --- [end][read][struct](AssetProperties) ---
  4859. }
  4860. } else {
  4861. target.properties = nil
  4862. }
  4863. if uint8(0) /* field version */ <= version {
  4864. // --- [begin][read][reference](time.Time) ---
  4865. m := &time.Time{}
  4866. n := buff.ReadInt() // byte array length
  4867. o := buff.ReadBytes(n) // byte array
  4868. errB := m.UnmarshalBinary(o)
  4869. if errB != nil {
  4870. return errB
  4871. }
  4872. target.start = *m
  4873. // --- [end][read][reference](time.Time) ---
  4874. } else {
  4875. }
  4876. if uint8(0) /* field version */ <= version {
  4877. // --- [begin][read][reference](time.Time) ---
  4878. p := &time.Time{}
  4879. q := buff.ReadInt() // byte array length
  4880. r := buff.ReadBytes(q) // byte array
  4881. errC := p.UnmarshalBinary(r)
  4882. if errC != nil {
  4883. return errC
  4884. }
  4885. target.end = *p
  4886. // --- [end][read][reference](time.Time) ---
  4887. } else {
  4888. }
  4889. if uint8(0) /* field version */ <= version {
  4890. // --- [begin][read][struct](Window) ---
  4891. s := &Window{}
  4892. buff.ReadInt() // [compatibility, unused]
  4893. errD := s.UnmarshalBinaryWithContext(ctx)
  4894. if errD != nil {
  4895. return errD
  4896. }
  4897. target.window = *s
  4898. // --- [end][read][struct](Window) ---
  4899. } else {
  4900. }
  4901. if uint8(0) /* field version */ <= version {
  4902. t := buff.ReadFloat64() // read float64
  4903. target.adjustment = t
  4904. } else {
  4905. target.adjustment = float64(0) // default
  4906. }
  4907. if uint8(0) /* field version */ <= version {
  4908. u := buff.ReadFloat64() // read float64
  4909. target.Cost = u
  4910. } else {
  4911. target.Cost = float64(0) // default
  4912. }
  4913. if uint8(0) /* field version */ <= version {
  4914. w := buff.ReadFloat64() // read float64
  4915. target.ByteHours = w
  4916. } else {
  4917. target.ByteHours = float64(0) // default
  4918. }
  4919. if uint8(0) /* field version */ <= version {
  4920. x := buff.ReadFloat64() // read float64
  4921. target.Local = x
  4922. } else {
  4923. target.Local = float64(0) // default
  4924. }
  4925. if uint8(0) /* field version */ <= version {
  4926. if buff.ReadUInt8() == uint8(0) {
  4927. target.Breakdown = nil
  4928. } else {
  4929. // --- [begin][read][struct](Breakdown) ---
  4930. y := &Breakdown{}
  4931. buff.ReadInt() // [compatibility, unused]
  4932. errE := y.UnmarshalBinaryWithContext(ctx)
  4933. if errE != nil {
  4934. return errE
  4935. }
  4936. target.Breakdown = y
  4937. // --- [end][read][struct](Breakdown) ---
  4938. }
  4939. } else {
  4940. target.Breakdown = nil
  4941. }
  4942. return nil
  4943. }
  4944. //--------------------------------------------------------------------------
  4945. // EqualityAudit
  4946. //--------------------------------------------------------------------------
  4947. // MarshalBinary serializes the internal properties of this EqualityAudit instance
  4948. // into a byte array
  4949. func (target *EqualityAudit) MarshalBinary() (data []byte, err error) {
  4950. ctx := &EncodingContext{
  4951. Buffer: util.NewBuffer(),
  4952. Table: nil,
  4953. }
  4954. e := target.MarshalBinaryWithContext(ctx)
  4955. if e != nil {
  4956. return nil, e
  4957. }
  4958. encBytes := ctx.Buffer.Bytes()
  4959. return encBytes, nil
  4960. }
  4961. // MarshalBinaryWithContext serializes the internal properties of this EqualityAudit instance
  4962. // into a byte array leveraging a predefined context.
  4963. func (target *EqualityAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4964. // panics are recovered and propagated as errors
  4965. defer func() {
  4966. if r := recover(); r != nil {
  4967. if e, ok := r.(error); ok {
  4968. err = e
  4969. } else if s, ok := r.(string); ok {
  4970. err = fmt.Errorf("Unexpected panic: %s", s)
  4971. } else {
  4972. err = fmt.Errorf("Unexpected panic: %+v", r)
  4973. }
  4974. }
  4975. }()
  4976. buff := ctx.Buffer
  4977. buff.WriteUInt8(AuditCodecVersion) // version
  4978. // --- [begin][write][alias](AuditStatus) ---
  4979. if ctx.IsStringTable() {
  4980. a := ctx.Table.AddOrGet(string(target.Status))
  4981. buff.WriteInt(a) // write table index
  4982. } else {
  4983. buff.WriteString(string(target.Status)) // write string
  4984. }
  4985. // --- [end][write][alias](AuditStatus) ---
  4986. if ctx.IsStringTable() {
  4987. b := ctx.Table.AddOrGet(target.Description)
  4988. buff.WriteInt(b) // write table index
  4989. } else {
  4990. buff.WriteString(target.Description) // write string
  4991. }
  4992. // --- [begin][write][reference](time.Time) ---
  4993. c, errA := target.LastRun.MarshalBinary()
  4994. if errA != nil {
  4995. return errA
  4996. }
  4997. buff.WriteInt(len(c))
  4998. buff.WriteBytes(c)
  4999. // --- [end][write][reference](time.Time) ---
  5000. if target.Clusters == nil {
  5001. buff.WriteUInt8(uint8(0)) // write nil byte
  5002. } else {
  5003. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5004. // --- [begin][write][map](map[string]*AuditFloatResult) ---
  5005. buff.WriteInt(len(target.Clusters)) // map length
  5006. for v, z := range target.Clusters {
  5007. if ctx.IsStringTable() {
  5008. d := ctx.Table.AddOrGet(v)
  5009. buff.WriteInt(d) // write table index
  5010. } else {
  5011. buff.WriteString(v) // write string
  5012. }
  5013. if z == nil {
  5014. buff.WriteUInt8(uint8(0)) // write nil byte
  5015. } else {
  5016. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5017. // --- [begin][write][struct](AuditFloatResult) ---
  5018. buff.WriteInt(0) // [compatibility, unused]
  5019. errB := z.MarshalBinaryWithContext(ctx)
  5020. if errB != nil {
  5021. return errB
  5022. }
  5023. // --- [end][write][struct](AuditFloatResult) ---
  5024. }
  5025. }
  5026. // --- [end][write][map](map[string]*AuditFloatResult) ---
  5027. }
  5028. if target.MissingValues == nil {
  5029. buff.WriteUInt8(uint8(0)) // write nil byte
  5030. } else {
  5031. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5032. // --- [begin][write][slice]([]*AuditMissingValue) ---
  5033. buff.WriteInt(len(target.MissingValues)) // array length
  5034. for i := 0; i < len(target.MissingValues); i++ {
  5035. if target.MissingValues[i] == nil {
  5036. buff.WriteUInt8(uint8(0)) // write nil byte
  5037. } else {
  5038. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5039. // --- [begin][write][struct](AuditMissingValue) ---
  5040. buff.WriteInt(0) // [compatibility, unused]
  5041. errC := target.MissingValues[i].MarshalBinaryWithContext(ctx)
  5042. if errC != nil {
  5043. return errC
  5044. }
  5045. // --- [end][write][struct](AuditMissingValue) ---
  5046. }
  5047. }
  5048. // --- [end][write][slice]([]*AuditMissingValue) ---
  5049. }
  5050. return nil
  5051. }
  5052. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5053. // the EqualityAudit type
  5054. func (target *EqualityAudit) UnmarshalBinary(data []byte) error {
  5055. var table []string
  5056. buff := util.NewBufferFromBytes(data)
  5057. // string table header validation
  5058. if isBinaryTag(data, BinaryTagStringTable) {
  5059. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5060. tl := buff.ReadInt() // table length
  5061. if tl > 0 {
  5062. table = make([]string, tl, tl)
  5063. for i := 0; i < tl; i++ {
  5064. table[i] = buff.ReadString()
  5065. }
  5066. }
  5067. }
  5068. ctx := &DecodingContext{
  5069. Buffer: buff,
  5070. Table: table,
  5071. }
  5072. err := target.UnmarshalBinaryWithContext(ctx)
  5073. if err != nil {
  5074. return err
  5075. }
  5076. return nil
  5077. }
  5078. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5079. // the EqualityAudit type
  5080. func (target *EqualityAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5081. // panics are recovered and propagated as errors
  5082. defer func() {
  5083. if r := recover(); r != nil {
  5084. if e, ok := r.(error); ok {
  5085. err = e
  5086. } else if s, ok := r.(string); ok {
  5087. err = fmt.Errorf("Unexpected panic: %s", s)
  5088. } else {
  5089. err = fmt.Errorf("Unexpected panic: %+v", r)
  5090. }
  5091. }
  5092. }()
  5093. buff := ctx.Buffer
  5094. version := buff.ReadUInt8()
  5095. if version > AuditCodecVersion {
  5096. return fmt.Errorf("Invalid Version Unmarshaling EqualityAudit. Expected %d or less, got %d", AuditCodecVersion, version)
  5097. }
  5098. if uint8(0) /* field version */ <= version {
  5099. // --- [begin][read][alias](AuditStatus) ---
  5100. var a string
  5101. var c string
  5102. if ctx.IsStringTable() {
  5103. d := buff.ReadInt() // read string index
  5104. c = ctx.Table[d]
  5105. } else {
  5106. c = buff.ReadString() // read string
  5107. }
  5108. b := c
  5109. a = b
  5110. target.Status = AuditStatus(a)
  5111. // --- [end][read][alias](AuditStatus) ---
  5112. } else {
  5113. }
  5114. if uint8(0) /* field version */ <= version {
  5115. var f string
  5116. if ctx.IsStringTable() {
  5117. g := buff.ReadInt() // read string index
  5118. f = ctx.Table[g]
  5119. } else {
  5120. f = buff.ReadString() // read string
  5121. }
  5122. e := f
  5123. target.Description = e
  5124. } else {
  5125. target.Description = "" // default
  5126. }
  5127. if uint8(0) /* field version */ <= version {
  5128. // --- [begin][read][reference](time.Time) ---
  5129. h := &time.Time{}
  5130. k := buff.ReadInt() // byte array length
  5131. l := buff.ReadBytes(k) // byte array
  5132. errA := h.UnmarshalBinary(l)
  5133. if errA != nil {
  5134. return errA
  5135. }
  5136. target.LastRun = *h
  5137. // --- [end][read][reference](time.Time) ---
  5138. } else {
  5139. }
  5140. if uint8(0) /* field version */ <= version {
  5141. if buff.ReadUInt8() == uint8(0) {
  5142. target.Clusters = nil
  5143. } else {
  5144. // --- [begin][read][map](map[string]*AuditFloatResult) ---
  5145. n := buff.ReadInt() // map len
  5146. m := make(map[string]*AuditFloatResult, n)
  5147. for i := 0; i < n; i++ {
  5148. var v string
  5149. var p string
  5150. if ctx.IsStringTable() {
  5151. q := buff.ReadInt() // read string index
  5152. p = ctx.Table[q]
  5153. } else {
  5154. p = buff.ReadString() // read string
  5155. }
  5156. o := p
  5157. v = o
  5158. var z *AuditFloatResult
  5159. if buff.ReadUInt8() == uint8(0) {
  5160. z = nil
  5161. } else {
  5162. // --- [begin][read][struct](AuditFloatResult) ---
  5163. r := &AuditFloatResult{}
  5164. buff.ReadInt() // [compatibility, unused]
  5165. errB := r.UnmarshalBinaryWithContext(ctx)
  5166. if errB != nil {
  5167. return errB
  5168. }
  5169. z = r
  5170. // --- [end][read][struct](AuditFloatResult) ---
  5171. }
  5172. m[v] = z
  5173. }
  5174. target.Clusters = m
  5175. // --- [end][read][map](map[string]*AuditFloatResult) ---
  5176. }
  5177. } else {
  5178. target.Clusters = nil
  5179. }
  5180. if uint8(0) /* field version */ <= version {
  5181. if buff.ReadUInt8() == uint8(0) {
  5182. target.MissingValues = nil
  5183. } else {
  5184. // --- [begin][read][slice]([]*AuditMissingValue) ---
  5185. t := buff.ReadInt() // array len
  5186. s := make([]*AuditMissingValue, t)
  5187. for j := 0; j < t; j++ {
  5188. var u *AuditMissingValue
  5189. if buff.ReadUInt8() == uint8(0) {
  5190. u = nil
  5191. } else {
  5192. // --- [begin][read][struct](AuditMissingValue) ---
  5193. w := &AuditMissingValue{}
  5194. buff.ReadInt() // [compatibility, unused]
  5195. errC := w.UnmarshalBinaryWithContext(ctx)
  5196. if errC != nil {
  5197. return errC
  5198. }
  5199. u = w
  5200. // --- [end][read][struct](AuditMissingValue) ---
  5201. }
  5202. s[j] = u
  5203. }
  5204. target.MissingValues = s
  5205. // --- [end][read][slice]([]*AuditMissingValue) ---
  5206. }
  5207. } else {
  5208. target.MissingValues = nil
  5209. }
  5210. return nil
  5211. }
  5212. //--------------------------------------------------------------------------
  5213. // LoadBalancer
  5214. //--------------------------------------------------------------------------
  5215. // MarshalBinary serializes the internal properties of this LoadBalancer instance
  5216. // into a byte array
  5217. func (target *LoadBalancer) MarshalBinary() (data []byte, err error) {
  5218. ctx := &EncodingContext{
  5219. Buffer: util.NewBuffer(),
  5220. Table: nil,
  5221. }
  5222. e := target.MarshalBinaryWithContext(ctx)
  5223. if e != nil {
  5224. return nil, e
  5225. }
  5226. encBytes := ctx.Buffer.Bytes()
  5227. return encBytes, nil
  5228. }
  5229. // MarshalBinaryWithContext serializes the internal properties of this LoadBalancer instance
  5230. // into a byte array leveraging a predefined context.
  5231. func (target *LoadBalancer) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5232. // panics are recovered and propagated as errors
  5233. defer func() {
  5234. if r := recover(); r != nil {
  5235. if e, ok := r.(error); ok {
  5236. err = e
  5237. } else if s, ok := r.(string); ok {
  5238. err = fmt.Errorf("Unexpected panic: %s", s)
  5239. } else {
  5240. err = fmt.Errorf("Unexpected panic: %+v", r)
  5241. }
  5242. }
  5243. }()
  5244. buff := ctx.Buffer
  5245. buff.WriteUInt8(AssetsCodecVersion) // version
  5246. if target.properties == nil {
  5247. buff.WriteUInt8(uint8(0)) // write nil byte
  5248. } else {
  5249. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5250. // --- [begin][write][struct](AssetProperties) ---
  5251. buff.WriteInt(0) // [compatibility, unused]
  5252. errA := target.properties.MarshalBinaryWithContext(ctx)
  5253. if errA != nil {
  5254. return errA
  5255. }
  5256. // --- [end][write][struct](AssetProperties) ---
  5257. }
  5258. // --- [begin][write][alias](AssetLabels) ---
  5259. if map[string]string(target.labels) == nil {
  5260. buff.WriteUInt8(uint8(0)) // write nil byte
  5261. } else {
  5262. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5263. // --- [begin][write][map](map[string]string) ---
  5264. buff.WriteInt(len(map[string]string(target.labels))) // map length
  5265. for v, z := range map[string]string(target.labels) {
  5266. if ctx.IsStringTable() {
  5267. a := ctx.Table.AddOrGet(v)
  5268. buff.WriteInt(a) // write table index
  5269. } else {
  5270. buff.WriteString(v) // write string
  5271. }
  5272. if ctx.IsStringTable() {
  5273. b := ctx.Table.AddOrGet(z)
  5274. buff.WriteInt(b) // write table index
  5275. } else {
  5276. buff.WriteString(z) // write string
  5277. }
  5278. }
  5279. // --- [end][write][map](map[string]string) ---
  5280. }
  5281. // --- [end][write][alias](AssetLabels) ---
  5282. // --- [begin][write][reference](time.Time) ---
  5283. c, errB := target.start.MarshalBinary()
  5284. if errB != nil {
  5285. return errB
  5286. }
  5287. buff.WriteInt(len(c))
  5288. buff.WriteBytes(c)
  5289. // --- [end][write][reference](time.Time) ---
  5290. // --- [begin][write][reference](time.Time) ---
  5291. d, errC := target.end.MarshalBinary()
  5292. if errC != nil {
  5293. return errC
  5294. }
  5295. buff.WriteInt(len(d))
  5296. buff.WriteBytes(d)
  5297. // --- [end][write][reference](time.Time) ---
  5298. // --- [begin][write][struct](Window) ---
  5299. buff.WriteInt(0) // [compatibility, unused]
  5300. errD := target.window.MarshalBinaryWithContext(ctx)
  5301. if errD != nil {
  5302. return errD
  5303. }
  5304. // --- [end][write][struct](Window) ---
  5305. buff.WriteFloat64(target.adjustment) // write float64
  5306. buff.WriteFloat64(target.Cost) // write float64
  5307. return nil
  5308. }
  5309. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5310. // the LoadBalancer type
  5311. func (target *LoadBalancer) UnmarshalBinary(data []byte) error {
  5312. var table []string
  5313. buff := util.NewBufferFromBytes(data)
  5314. // string table header validation
  5315. if isBinaryTag(data, BinaryTagStringTable) {
  5316. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5317. tl := buff.ReadInt() // table length
  5318. if tl > 0 {
  5319. table = make([]string, tl, tl)
  5320. for i := 0; i < tl; i++ {
  5321. table[i] = buff.ReadString()
  5322. }
  5323. }
  5324. }
  5325. ctx := &DecodingContext{
  5326. Buffer: buff,
  5327. Table: table,
  5328. }
  5329. err := target.UnmarshalBinaryWithContext(ctx)
  5330. if err != nil {
  5331. return err
  5332. }
  5333. return nil
  5334. }
  5335. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5336. // the LoadBalancer type
  5337. func (target *LoadBalancer) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5338. // panics are recovered and propagated as errors
  5339. defer func() {
  5340. if r := recover(); r != nil {
  5341. if e, ok := r.(error); ok {
  5342. err = e
  5343. } else if s, ok := r.(string); ok {
  5344. err = fmt.Errorf("Unexpected panic: %s", s)
  5345. } else {
  5346. err = fmt.Errorf("Unexpected panic: %+v", r)
  5347. }
  5348. }
  5349. }()
  5350. buff := ctx.Buffer
  5351. version := buff.ReadUInt8()
  5352. if version > AssetsCodecVersion {
  5353. return fmt.Errorf("Invalid Version Unmarshaling LoadBalancer. Expected %d or less, got %d", AssetsCodecVersion, version)
  5354. }
  5355. if uint8(0) /* field version */ <= version {
  5356. if buff.ReadUInt8() == uint8(0) {
  5357. target.properties = nil
  5358. } else {
  5359. // --- [begin][read][struct](AssetProperties) ---
  5360. a := &AssetProperties{}
  5361. buff.ReadInt() // [compatibility, unused]
  5362. errA := a.UnmarshalBinaryWithContext(ctx)
  5363. if errA != nil {
  5364. return errA
  5365. }
  5366. target.properties = a
  5367. // --- [end][read][struct](AssetProperties) ---
  5368. }
  5369. } else {
  5370. target.properties = nil
  5371. }
  5372. if uint8(0) /* field version */ <= version {
  5373. // --- [begin][read][alias](AssetLabels) ---
  5374. var b map[string]string
  5375. if buff.ReadUInt8() == uint8(0) {
  5376. b = nil
  5377. } else {
  5378. // --- [begin][read][map](map[string]string) ---
  5379. d := buff.ReadInt() // map len
  5380. c := make(map[string]string, d)
  5381. for i := 0; i < d; i++ {
  5382. var v string
  5383. var f string
  5384. if ctx.IsStringTable() {
  5385. g := buff.ReadInt() // read string index
  5386. f = ctx.Table[g]
  5387. } else {
  5388. f = buff.ReadString() // read string
  5389. }
  5390. e := f
  5391. v = e
  5392. var z string
  5393. var k string
  5394. if ctx.IsStringTable() {
  5395. l := buff.ReadInt() // read string index
  5396. k = ctx.Table[l]
  5397. } else {
  5398. k = buff.ReadString() // read string
  5399. }
  5400. h := k
  5401. z = h
  5402. c[v] = z
  5403. }
  5404. b = c
  5405. // --- [end][read][map](map[string]string) ---
  5406. }
  5407. target.labels = AssetLabels(b)
  5408. // --- [end][read][alias](AssetLabels) ---
  5409. } else {
  5410. }
  5411. if uint8(0) /* field version */ <= version {
  5412. // --- [begin][read][reference](time.Time) ---
  5413. m := &time.Time{}
  5414. n := buff.ReadInt() // byte array length
  5415. o := buff.ReadBytes(n) // byte array
  5416. errB := m.UnmarshalBinary(o)
  5417. if errB != nil {
  5418. return errB
  5419. }
  5420. target.start = *m
  5421. // --- [end][read][reference](time.Time) ---
  5422. } else {
  5423. }
  5424. if uint8(0) /* field version */ <= version {
  5425. // --- [begin][read][reference](time.Time) ---
  5426. p := &time.Time{}
  5427. q := buff.ReadInt() // byte array length
  5428. r := buff.ReadBytes(q) // byte array
  5429. errC := p.UnmarshalBinary(r)
  5430. if errC != nil {
  5431. return errC
  5432. }
  5433. target.end = *p
  5434. // --- [end][read][reference](time.Time) ---
  5435. } else {
  5436. }
  5437. if uint8(0) /* field version */ <= version {
  5438. // --- [begin][read][struct](Window) ---
  5439. s := &Window{}
  5440. buff.ReadInt() // [compatibility, unused]
  5441. errD := s.UnmarshalBinaryWithContext(ctx)
  5442. if errD != nil {
  5443. return errD
  5444. }
  5445. target.window = *s
  5446. // --- [end][read][struct](Window) ---
  5447. } else {
  5448. }
  5449. if uint8(0) /* field version */ <= version {
  5450. t := buff.ReadFloat64() // read float64
  5451. target.adjustment = t
  5452. } else {
  5453. target.adjustment = float64(0) // default
  5454. }
  5455. if uint8(0) /* field version */ <= version {
  5456. u := buff.ReadFloat64() // read float64
  5457. target.Cost = u
  5458. } else {
  5459. target.Cost = float64(0) // default
  5460. }
  5461. return nil
  5462. }
  5463. //--------------------------------------------------------------------------
  5464. // Network
  5465. //--------------------------------------------------------------------------
  5466. // MarshalBinary serializes the internal properties of this Network instance
  5467. // into a byte array
  5468. func (target *Network) MarshalBinary() (data []byte, err error) {
  5469. ctx := &EncodingContext{
  5470. Buffer: util.NewBuffer(),
  5471. Table: nil,
  5472. }
  5473. e := target.MarshalBinaryWithContext(ctx)
  5474. if e != nil {
  5475. return nil, e
  5476. }
  5477. encBytes := ctx.Buffer.Bytes()
  5478. return encBytes, nil
  5479. }
  5480. // MarshalBinaryWithContext serializes the internal properties of this Network instance
  5481. // into a byte array leveraging a predefined context.
  5482. func (target *Network) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5483. // panics are recovered and propagated as errors
  5484. defer func() {
  5485. if r := recover(); r != nil {
  5486. if e, ok := r.(error); ok {
  5487. err = e
  5488. } else if s, ok := r.(string); ok {
  5489. err = fmt.Errorf("Unexpected panic: %s", s)
  5490. } else {
  5491. err = fmt.Errorf("Unexpected panic: %+v", r)
  5492. }
  5493. }
  5494. }()
  5495. buff := ctx.Buffer
  5496. buff.WriteUInt8(AssetsCodecVersion) // version
  5497. if target.properties == nil {
  5498. buff.WriteUInt8(uint8(0)) // write nil byte
  5499. } else {
  5500. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5501. // --- [begin][write][struct](AssetProperties) ---
  5502. buff.WriteInt(0) // [compatibility, unused]
  5503. errA := target.properties.MarshalBinaryWithContext(ctx)
  5504. if errA != nil {
  5505. return errA
  5506. }
  5507. // --- [end][write][struct](AssetProperties) ---
  5508. }
  5509. // --- [begin][write][alias](AssetLabels) ---
  5510. if map[string]string(target.labels) == nil {
  5511. buff.WriteUInt8(uint8(0)) // write nil byte
  5512. } else {
  5513. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5514. // --- [begin][write][map](map[string]string) ---
  5515. buff.WriteInt(len(map[string]string(target.labels))) // map length
  5516. for v, z := range map[string]string(target.labels) {
  5517. if ctx.IsStringTable() {
  5518. a := ctx.Table.AddOrGet(v)
  5519. buff.WriteInt(a) // write table index
  5520. } else {
  5521. buff.WriteString(v) // write string
  5522. }
  5523. if ctx.IsStringTable() {
  5524. b := ctx.Table.AddOrGet(z)
  5525. buff.WriteInt(b) // write table index
  5526. } else {
  5527. buff.WriteString(z) // write string
  5528. }
  5529. }
  5530. // --- [end][write][map](map[string]string) ---
  5531. }
  5532. // --- [end][write][alias](AssetLabels) ---
  5533. // --- [begin][write][reference](time.Time) ---
  5534. c, errB := target.start.MarshalBinary()
  5535. if errB != nil {
  5536. return errB
  5537. }
  5538. buff.WriteInt(len(c))
  5539. buff.WriteBytes(c)
  5540. // --- [end][write][reference](time.Time) ---
  5541. // --- [begin][write][reference](time.Time) ---
  5542. d, errC := target.end.MarshalBinary()
  5543. if errC != nil {
  5544. return errC
  5545. }
  5546. buff.WriteInt(len(d))
  5547. buff.WriteBytes(d)
  5548. // --- [end][write][reference](time.Time) ---
  5549. // --- [begin][write][struct](Window) ---
  5550. buff.WriteInt(0) // [compatibility, unused]
  5551. errD := target.window.MarshalBinaryWithContext(ctx)
  5552. if errD != nil {
  5553. return errD
  5554. }
  5555. // --- [end][write][struct](Window) ---
  5556. buff.WriteFloat64(target.adjustment) // write float64
  5557. buff.WriteFloat64(target.Cost) // write float64
  5558. return nil
  5559. }
  5560. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5561. // the Network type
  5562. func (target *Network) UnmarshalBinary(data []byte) error {
  5563. var table []string
  5564. buff := util.NewBufferFromBytes(data)
  5565. // string table header validation
  5566. if isBinaryTag(data, BinaryTagStringTable) {
  5567. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5568. tl := buff.ReadInt() // table length
  5569. if tl > 0 {
  5570. table = make([]string, tl, tl)
  5571. for i := 0; i < tl; i++ {
  5572. table[i] = buff.ReadString()
  5573. }
  5574. }
  5575. }
  5576. ctx := &DecodingContext{
  5577. Buffer: buff,
  5578. Table: table,
  5579. }
  5580. err := target.UnmarshalBinaryWithContext(ctx)
  5581. if err != nil {
  5582. return err
  5583. }
  5584. return nil
  5585. }
  5586. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5587. // the Network type
  5588. func (target *Network) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5589. // panics are recovered and propagated as errors
  5590. defer func() {
  5591. if r := recover(); r != nil {
  5592. if e, ok := r.(error); ok {
  5593. err = e
  5594. } else if s, ok := r.(string); ok {
  5595. err = fmt.Errorf("Unexpected panic: %s", s)
  5596. } else {
  5597. err = fmt.Errorf("Unexpected panic: %+v", r)
  5598. }
  5599. }
  5600. }()
  5601. buff := ctx.Buffer
  5602. version := buff.ReadUInt8()
  5603. if version > AssetsCodecVersion {
  5604. return fmt.Errorf("Invalid Version Unmarshaling Network. Expected %d or less, got %d", AssetsCodecVersion, version)
  5605. }
  5606. if uint8(0) /* field version */ <= version {
  5607. if buff.ReadUInt8() == uint8(0) {
  5608. target.properties = nil
  5609. } else {
  5610. // --- [begin][read][struct](AssetProperties) ---
  5611. a := &AssetProperties{}
  5612. buff.ReadInt() // [compatibility, unused]
  5613. errA := a.UnmarshalBinaryWithContext(ctx)
  5614. if errA != nil {
  5615. return errA
  5616. }
  5617. target.properties = a
  5618. // --- [end][read][struct](AssetProperties) ---
  5619. }
  5620. } else {
  5621. target.properties = nil
  5622. }
  5623. if uint8(0) /* field version */ <= version {
  5624. // --- [begin][read][alias](AssetLabels) ---
  5625. var b map[string]string
  5626. if buff.ReadUInt8() == uint8(0) {
  5627. b = nil
  5628. } else {
  5629. // --- [begin][read][map](map[string]string) ---
  5630. d := buff.ReadInt() // map len
  5631. c := make(map[string]string, d)
  5632. for i := 0; i < d; i++ {
  5633. var v string
  5634. var f string
  5635. if ctx.IsStringTable() {
  5636. g := buff.ReadInt() // read string index
  5637. f = ctx.Table[g]
  5638. } else {
  5639. f = buff.ReadString() // read string
  5640. }
  5641. e := f
  5642. v = e
  5643. var z string
  5644. var k string
  5645. if ctx.IsStringTable() {
  5646. l := buff.ReadInt() // read string index
  5647. k = ctx.Table[l]
  5648. } else {
  5649. k = buff.ReadString() // read string
  5650. }
  5651. h := k
  5652. z = h
  5653. c[v] = z
  5654. }
  5655. b = c
  5656. // --- [end][read][map](map[string]string) ---
  5657. }
  5658. target.labels = AssetLabels(b)
  5659. // --- [end][read][alias](AssetLabels) ---
  5660. } else {
  5661. }
  5662. if uint8(0) /* field version */ <= version {
  5663. // --- [begin][read][reference](time.Time) ---
  5664. m := &time.Time{}
  5665. n := buff.ReadInt() // byte array length
  5666. o := buff.ReadBytes(n) // byte array
  5667. errB := m.UnmarshalBinary(o)
  5668. if errB != nil {
  5669. return errB
  5670. }
  5671. target.start = *m
  5672. // --- [end][read][reference](time.Time) ---
  5673. } else {
  5674. }
  5675. if uint8(0) /* field version */ <= version {
  5676. // --- [begin][read][reference](time.Time) ---
  5677. p := &time.Time{}
  5678. q := buff.ReadInt() // byte array length
  5679. r := buff.ReadBytes(q) // byte array
  5680. errC := p.UnmarshalBinary(r)
  5681. if errC != nil {
  5682. return errC
  5683. }
  5684. target.end = *p
  5685. // --- [end][read][reference](time.Time) ---
  5686. } else {
  5687. }
  5688. if uint8(0) /* field version */ <= version {
  5689. // --- [begin][read][struct](Window) ---
  5690. s := &Window{}
  5691. buff.ReadInt() // [compatibility, unused]
  5692. errD := s.UnmarshalBinaryWithContext(ctx)
  5693. if errD != nil {
  5694. return errD
  5695. }
  5696. target.window = *s
  5697. // --- [end][read][struct](Window) ---
  5698. } else {
  5699. }
  5700. if uint8(0) /* field version */ <= version {
  5701. t := buff.ReadFloat64() // read float64
  5702. target.adjustment = t
  5703. } else {
  5704. target.adjustment = float64(0) // default
  5705. }
  5706. if uint8(0) /* field version */ <= version {
  5707. u := buff.ReadFloat64() // read float64
  5708. target.Cost = u
  5709. } else {
  5710. target.Cost = float64(0) // default
  5711. }
  5712. return nil
  5713. }
  5714. //--------------------------------------------------------------------------
  5715. // Node
  5716. //--------------------------------------------------------------------------
  5717. // MarshalBinary serializes the internal properties of this Node instance
  5718. // into a byte array
  5719. func (target *Node) MarshalBinary() (data []byte, err error) {
  5720. ctx := &EncodingContext{
  5721. Buffer: util.NewBuffer(),
  5722. Table: nil,
  5723. }
  5724. e := target.MarshalBinaryWithContext(ctx)
  5725. if e != nil {
  5726. return nil, e
  5727. }
  5728. encBytes := ctx.Buffer.Bytes()
  5729. return encBytes, nil
  5730. }
  5731. // MarshalBinaryWithContext serializes the internal properties of this Node instance
  5732. // into a byte array leveraging a predefined context.
  5733. func (target *Node) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5734. // panics are recovered and propagated as errors
  5735. defer func() {
  5736. if r := recover(); r != nil {
  5737. if e, ok := r.(error); ok {
  5738. err = e
  5739. } else if s, ok := r.(string); ok {
  5740. err = fmt.Errorf("Unexpected panic: %s", s)
  5741. } else {
  5742. err = fmt.Errorf("Unexpected panic: %+v", r)
  5743. }
  5744. }
  5745. }()
  5746. buff := ctx.Buffer
  5747. buff.WriteUInt8(AssetsCodecVersion) // version
  5748. if target.properties == nil {
  5749. buff.WriteUInt8(uint8(0)) // write nil byte
  5750. } else {
  5751. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5752. // --- [begin][write][struct](AssetProperties) ---
  5753. buff.WriteInt(0) // [compatibility, unused]
  5754. errA := target.properties.MarshalBinaryWithContext(ctx)
  5755. if errA != nil {
  5756. return errA
  5757. }
  5758. // --- [end][write][struct](AssetProperties) ---
  5759. }
  5760. // --- [begin][write][alias](AssetLabels) ---
  5761. if map[string]string(target.labels) == nil {
  5762. buff.WriteUInt8(uint8(0)) // write nil byte
  5763. } else {
  5764. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5765. // --- [begin][write][map](map[string]string) ---
  5766. buff.WriteInt(len(map[string]string(target.labels))) // map length
  5767. for v, z := range map[string]string(target.labels) {
  5768. if ctx.IsStringTable() {
  5769. a := ctx.Table.AddOrGet(v)
  5770. buff.WriteInt(a) // write table index
  5771. } else {
  5772. buff.WriteString(v) // write string
  5773. }
  5774. if ctx.IsStringTable() {
  5775. b := ctx.Table.AddOrGet(z)
  5776. buff.WriteInt(b) // write table index
  5777. } else {
  5778. buff.WriteString(z) // write string
  5779. }
  5780. }
  5781. // --- [end][write][map](map[string]string) ---
  5782. }
  5783. // --- [end][write][alias](AssetLabels) ---
  5784. // --- [begin][write][reference](time.Time) ---
  5785. c, errB := target.start.MarshalBinary()
  5786. if errB != nil {
  5787. return errB
  5788. }
  5789. buff.WriteInt(len(c))
  5790. buff.WriteBytes(c)
  5791. // --- [end][write][reference](time.Time) ---
  5792. // --- [begin][write][reference](time.Time) ---
  5793. d, errC := target.end.MarshalBinary()
  5794. if errC != nil {
  5795. return errC
  5796. }
  5797. buff.WriteInt(len(d))
  5798. buff.WriteBytes(d)
  5799. // --- [end][write][reference](time.Time) ---
  5800. // --- [begin][write][struct](Window) ---
  5801. buff.WriteInt(0) // [compatibility, unused]
  5802. errD := target.window.MarshalBinaryWithContext(ctx)
  5803. if errD != nil {
  5804. return errD
  5805. }
  5806. // --- [end][write][struct](Window) ---
  5807. buff.WriteFloat64(target.adjustment) // write float64
  5808. if ctx.IsStringTable() {
  5809. e := ctx.Table.AddOrGet(target.NodeType)
  5810. buff.WriteInt(e) // write table index
  5811. } else {
  5812. buff.WriteString(target.NodeType) // write string
  5813. }
  5814. buff.WriteFloat64(target.CPUCoreHours) // write float64
  5815. buff.WriteFloat64(target.RAMByteHours) // write float64
  5816. buff.WriteFloat64(target.GPUHours) // write float64
  5817. if target.CPUBreakdown == nil {
  5818. buff.WriteUInt8(uint8(0)) // write nil byte
  5819. } else {
  5820. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5821. // --- [begin][write][struct](Breakdown) ---
  5822. buff.WriteInt(0) // [compatibility, unused]
  5823. errE := target.CPUBreakdown.MarshalBinaryWithContext(ctx)
  5824. if errE != nil {
  5825. return errE
  5826. }
  5827. // --- [end][write][struct](Breakdown) ---
  5828. }
  5829. if target.RAMBreakdown == nil {
  5830. buff.WriteUInt8(uint8(0)) // write nil byte
  5831. } else {
  5832. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5833. // --- [begin][write][struct](Breakdown) ---
  5834. buff.WriteInt(0) // [compatibility, unused]
  5835. errF := target.RAMBreakdown.MarshalBinaryWithContext(ctx)
  5836. if errF != nil {
  5837. return errF
  5838. }
  5839. // --- [end][write][struct](Breakdown) ---
  5840. }
  5841. buff.WriteFloat64(target.CPUCost) // write float64
  5842. buff.WriteFloat64(target.GPUCost) // write float64
  5843. buff.WriteFloat64(target.GPUCount) // write float64
  5844. buff.WriteFloat64(target.RAMCost) // write float64
  5845. buff.WriteFloat64(target.Discount) // write float64
  5846. buff.WriteFloat64(target.Preemptible) // write float64
  5847. return nil
  5848. }
  5849. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5850. // the Node type
  5851. func (target *Node) UnmarshalBinary(data []byte) error {
  5852. var table []string
  5853. buff := util.NewBufferFromBytes(data)
  5854. // string table header validation
  5855. if isBinaryTag(data, BinaryTagStringTable) {
  5856. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5857. tl := buff.ReadInt() // table length
  5858. if tl > 0 {
  5859. table = make([]string, tl, tl)
  5860. for i := 0; i < tl; i++ {
  5861. table[i] = buff.ReadString()
  5862. }
  5863. }
  5864. }
  5865. ctx := &DecodingContext{
  5866. Buffer: buff,
  5867. Table: table,
  5868. }
  5869. err := target.UnmarshalBinaryWithContext(ctx)
  5870. if err != nil {
  5871. return err
  5872. }
  5873. return nil
  5874. }
  5875. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5876. // the Node type
  5877. func (target *Node) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5878. // panics are recovered and propagated as errors
  5879. defer func() {
  5880. if r := recover(); r != nil {
  5881. if e, ok := r.(error); ok {
  5882. err = e
  5883. } else if s, ok := r.(string); ok {
  5884. err = fmt.Errorf("Unexpected panic: %s", s)
  5885. } else {
  5886. err = fmt.Errorf("Unexpected panic: %+v", r)
  5887. }
  5888. }
  5889. }()
  5890. buff := ctx.Buffer
  5891. version := buff.ReadUInt8()
  5892. if version > AssetsCodecVersion {
  5893. return fmt.Errorf("Invalid Version Unmarshaling Node. Expected %d or less, got %d", AssetsCodecVersion, version)
  5894. }
  5895. if uint8(0) /* field version */ <= version {
  5896. if buff.ReadUInt8() == uint8(0) {
  5897. target.properties = nil
  5898. } else {
  5899. // --- [begin][read][struct](AssetProperties) ---
  5900. a := &AssetProperties{}
  5901. buff.ReadInt() // [compatibility, unused]
  5902. errA := a.UnmarshalBinaryWithContext(ctx)
  5903. if errA != nil {
  5904. return errA
  5905. }
  5906. target.properties = a
  5907. // --- [end][read][struct](AssetProperties) ---
  5908. }
  5909. } else {
  5910. target.properties = nil
  5911. }
  5912. if uint8(0) /* field version */ <= version {
  5913. // --- [begin][read][alias](AssetLabels) ---
  5914. var b map[string]string
  5915. if buff.ReadUInt8() == uint8(0) {
  5916. b = nil
  5917. } else {
  5918. // --- [begin][read][map](map[string]string) ---
  5919. d := buff.ReadInt() // map len
  5920. c := make(map[string]string, d)
  5921. for i := 0; i < d; i++ {
  5922. var v string
  5923. var f string
  5924. if ctx.IsStringTable() {
  5925. g := buff.ReadInt() // read string index
  5926. f = ctx.Table[g]
  5927. } else {
  5928. f = buff.ReadString() // read string
  5929. }
  5930. e := f
  5931. v = e
  5932. var z string
  5933. var k string
  5934. if ctx.IsStringTable() {
  5935. l := buff.ReadInt() // read string index
  5936. k = ctx.Table[l]
  5937. } else {
  5938. k = buff.ReadString() // read string
  5939. }
  5940. h := k
  5941. z = h
  5942. c[v] = z
  5943. }
  5944. b = c
  5945. // --- [end][read][map](map[string]string) ---
  5946. }
  5947. target.labels = AssetLabels(b)
  5948. // --- [end][read][alias](AssetLabels) ---
  5949. } else {
  5950. }
  5951. if uint8(0) /* field version */ <= version {
  5952. // --- [begin][read][reference](time.Time) ---
  5953. m := &time.Time{}
  5954. n := buff.ReadInt() // byte array length
  5955. o := buff.ReadBytes(n) // byte array
  5956. errB := m.UnmarshalBinary(o)
  5957. if errB != nil {
  5958. return errB
  5959. }
  5960. target.start = *m
  5961. // --- [end][read][reference](time.Time) ---
  5962. } else {
  5963. }
  5964. if uint8(0) /* field version */ <= version {
  5965. // --- [begin][read][reference](time.Time) ---
  5966. p := &time.Time{}
  5967. q := buff.ReadInt() // byte array length
  5968. r := buff.ReadBytes(q) // byte array
  5969. errC := p.UnmarshalBinary(r)
  5970. if errC != nil {
  5971. return errC
  5972. }
  5973. target.end = *p
  5974. // --- [end][read][reference](time.Time) ---
  5975. } else {
  5976. }
  5977. if uint8(0) /* field version */ <= version {
  5978. // --- [begin][read][struct](Window) ---
  5979. s := &Window{}
  5980. buff.ReadInt() // [compatibility, unused]
  5981. errD := s.UnmarshalBinaryWithContext(ctx)
  5982. if errD != nil {
  5983. return errD
  5984. }
  5985. target.window = *s
  5986. // --- [end][read][struct](Window) ---
  5987. } else {
  5988. }
  5989. if uint8(0) /* field version */ <= version {
  5990. t := buff.ReadFloat64() // read float64
  5991. target.adjustment = t
  5992. } else {
  5993. target.adjustment = float64(0) // default
  5994. }
  5995. if uint8(0) /* field version */ <= version {
  5996. var w string
  5997. if ctx.IsStringTable() {
  5998. x := buff.ReadInt() // read string index
  5999. w = ctx.Table[x]
  6000. } else {
  6001. w = buff.ReadString() // read string
  6002. }
  6003. u := w
  6004. target.NodeType = u
  6005. } else {
  6006. target.NodeType = "" // default
  6007. }
  6008. if uint8(0) /* field version */ <= version {
  6009. y := buff.ReadFloat64() // read float64
  6010. target.CPUCoreHours = y
  6011. } else {
  6012. target.CPUCoreHours = float64(0) // default
  6013. }
  6014. if uint8(0) /* field version */ <= version {
  6015. aa := buff.ReadFloat64() // read float64
  6016. target.RAMByteHours = aa
  6017. } else {
  6018. target.RAMByteHours = float64(0) // default
  6019. }
  6020. if uint8(0) /* field version */ <= version {
  6021. bb := buff.ReadFloat64() // read float64
  6022. target.GPUHours = bb
  6023. } else {
  6024. target.GPUHours = float64(0) // default
  6025. }
  6026. if uint8(0) /* field version */ <= version {
  6027. if buff.ReadUInt8() == uint8(0) {
  6028. target.CPUBreakdown = nil
  6029. } else {
  6030. // --- [begin][read][struct](Breakdown) ---
  6031. cc := &Breakdown{}
  6032. buff.ReadInt() // [compatibility, unused]
  6033. errE := cc.UnmarshalBinaryWithContext(ctx)
  6034. if errE != nil {
  6035. return errE
  6036. }
  6037. target.CPUBreakdown = cc
  6038. // --- [end][read][struct](Breakdown) ---
  6039. }
  6040. } else {
  6041. target.CPUBreakdown = nil
  6042. }
  6043. if uint8(0) /* field version */ <= version {
  6044. if buff.ReadUInt8() == uint8(0) {
  6045. target.RAMBreakdown = nil
  6046. } else {
  6047. // --- [begin][read][struct](Breakdown) ---
  6048. dd := &Breakdown{}
  6049. buff.ReadInt() // [compatibility, unused]
  6050. errF := dd.UnmarshalBinaryWithContext(ctx)
  6051. if errF != nil {
  6052. return errF
  6053. }
  6054. target.RAMBreakdown = dd
  6055. // --- [end][read][struct](Breakdown) ---
  6056. }
  6057. } else {
  6058. target.RAMBreakdown = nil
  6059. }
  6060. if uint8(0) /* field version */ <= version {
  6061. ee := buff.ReadFloat64() // read float64
  6062. target.CPUCost = ee
  6063. } else {
  6064. target.CPUCost = float64(0) // default
  6065. }
  6066. if uint8(0) /* field version */ <= version {
  6067. ff := buff.ReadFloat64() // read float64
  6068. target.GPUCost = ff
  6069. } else {
  6070. target.GPUCost = float64(0) // default
  6071. }
  6072. if uint8(0) /* field version */ <= version {
  6073. gg := buff.ReadFloat64() // read float64
  6074. target.GPUCount = gg
  6075. } else {
  6076. target.GPUCount = float64(0) // default
  6077. }
  6078. if uint8(0) /* field version */ <= version {
  6079. hh := buff.ReadFloat64() // read float64
  6080. target.RAMCost = hh
  6081. } else {
  6082. target.RAMCost = float64(0) // default
  6083. }
  6084. if uint8(0) /* field version */ <= version {
  6085. kk := buff.ReadFloat64() // read float64
  6086. target.Discount = kk
  6087. } else {
  6088. target.Discount = float64(0) // default
  6089. }
  6090. if uint8(0) /* field version */ <= version {
  6091. ll := buff.ReadFloat64() // read float64
  6092. target.Preemptible = ll
  6093. } else {
  6094. target.Preemptible = float64(0) // default
  6095. }
  6096. return nil
  6097. }
  6098. //--------------------------------------------------------------------------
  6099. // PVAllocation
  6100. //--------------------------------------------------------------------------
  6101. // MarshalBinary serializes the internal properties of this PVAllocation instance
  6102. // into a byte array
  6103. func (target *PVAllocation) MarshalBinary() (data []byte, err error) {
  6104. ctx := &EncodingContext{
  6105. Buffer: util.NewBuffer(),
  6106. Table: nil,
  6107. }
  6108. e := target.MarshalBinaryWithContext(ctx)
  6109. if e != nil {
  6110. return nil, e
  6111. }
  6112. encBytes := ctx.Buffer.Bytes()
  6113. return encBytes, nil
  6114. }
  6115. // MarshalBinaryWithContext serializes the internal properties of this PVAllocation instance
  6116. // into a byte array leveraging a predefined context.
  6117. func (target *PVAllocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6118. // panics are recovered and propagated as errors
  6119. defer func() {
  6120. if r := recover(); r != nil {
  6121. if e, ok := r.(error); ok {
  6122. err = e
  6123. } else if s, ok := r.(string); ok {
  6124. err = fmt.Errorf("Unexpected panic: %s", s)
  6125. } else {
  6126. err = fmt.Errorf("Unexpected panic: %+v", r)
  6127. }
  6128. }
  6129. }()
  6130. buff := ctx.Buffer
  6131. buff.WriteUInt8(AllocationCodecVersion) // version
  6132. buff.WriteFloat64(target.ByteHours) // write float64
  6133. buff.WriteFloat64(target.Cost) // write float64
  6134. return nil
  6135. }
  6136. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6137. // the PVAllocation type
  6138. func (target *PVAllocation) UnmarshalBinary(data []byte) error {
  6139. var table []string
  6140. buff := util.NewBufferFromBytes(data)
  6141. // string table header validation
  6142. if isBinaryTag(data, BinaryTagStringTable) {
  6143. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6144. tl := buff.ReadInt() // table length
  6145. if tl > 0 {
  6146. table = make([]string, tl, tl)
  6147. for i := 0; i < tl; i++ {
  6148. table[i] = buff.ReadString()
  6149. }
  6150. }
  6151. }
  6152. ctx := &DecodingContext{
  6153. Buffer: buff,
  6154. Table: table,
  6155. }
  6156. err := target.UnmarshalBinaryWithContext(ctx)
  6157. if err != nil {
  6158. return err
  6159. }
  6160. return nil
  6161. }
  6162. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6163. // the PVAllocation type
  6164. func (target *PVAllocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6165. // panics are recovered and propagated as errors
  6166. defer func() {
  6167. if r := recover(); r != nil {
  6168. if e, ok := r.(error); ok {
  6169. err = e
  6170. } else if s, ok := r.(string); ok {
  6171. err = fmt.Errorf("Unexpected panic: %s", s)
  6172. } else {
  6173. err = fmt.Errorf("Unexpected panic: %+v", r)
  6174. }
  6175. }
  6176. }()
  6177. buff := ctx.Buffer
  6178. version := buff.ReadUInt8()
  6179. if version > AllocationCodecVersion {
  6180. return fmt.Errorf("Invalid Version Unmarshaling PVAllocation. Expected %d or less, got %d", AllocationCodecVersion, version)
  6181. }
  6182. if uint8(0) /* field version */ <= version {
  6183. a := buff.ReadFloat64() // read float64
  6184. target.ByteHours = a
  6185. } else {
  6186. target.ByteHours = float64(0) // default
  6187. }
  6188. if uint8(0) /* field version */ <= version {
  6189. b := buff.ReadFloat64() // read float64
  6190. target.Cost = b
  6191. } else {
  6192. target.Cost = float64(0) // default
  6193. }
  6194. return nil
  6195. }
  6196. //--------------------------------------------------------------------------
  6197. // PVKey
  6198. //--------------------------------------------------------------------------
  6199. // MarshalBinary serializes the internal properties of this PVKey instance
  6200. // into a byte array
  6201. func (target *PVKey) MarshalBinary() (data []byte, err error) {
  6202. ctx := &EncodingContext{
  6203. Buffer: util.NewBuffer(),
  6204. Table: nil,
  6205. }
  6206. e := target.MarshalBinaryWithContext(ctx)
  6207. if e != nil {
  6208. return nil, e
  6209. }
  6210. encBytes := ctx.Buffer.Bytes()
  6211. return encBytes, nil
  6212. }
  6213. // MarshalBinaryWithContext serializes the internal properties of this PVKey instance
  6214. // into a byte array leveraging a predefined context.
  6215. func (target *PVKey) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6216. // panics are recovered and propagated as errors
  6217. defer func() {
  6218. if r := recover(); r != nil {
  6219. if e, ok := r.(error); ok {
  6220. err = e
  6221. } else if s, ok := r.(string); ok {
  6222. err = fmt.Errorf("Unexpected panic: %s", s)
  6223. } else {
  6224. err = fmt.Errorf("Unexpected panic: %+v", r)
  6225. }
  6226. }
  6227. }()
  6228. buff := ctx.Buffer
  6229. buff.WriteUInt8(AllocationCodecVersion) // version
  6230. if ctx.IsStringTable() {
  6231. a := ctx.Table.AddOrGet(target.Cluster)
  6232. buff.WriteInt(a) // write table index
  6233. } else {
  6234. buff.WriteString(target.Cluster) // write string
  6235. }
  6236. if ctx.IsStringTable() {
  6237. b := ctx.Table.AddOrGet(target.Name)
  6238. buff.WriteInt(b) // write table index
  6239. } else {
  6240. buff.WriteString(target.Name) // write string
  6241. }
  6242. return nil
  6243. }
  6244. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6245. // the PVKey type
  6246. func (target *PVKey) UnmarshalBinary(data []byte) error {
  6247. var table []string
  6248. buff := util.NewBufferFromBytes(data)
  6249. // string table header validation
  6250. if isBinaryTag(data, BinaryTagStringTable) {
  6251. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6252. tl := buff.ReadInt() // table length
  6253. if tl > 0 {
  6254. table = make([]string, tl, tl)
  6255. for i := 0; i < tl; i++ {
  6256. table[i] = buff.ReadString()
  6257. }
  6258. }
  6259. }
  6260. ctx := &DecodingContext{
  6261. Buffer: buff,
  6262. Table: table,
  6263. }
  6264. err := target.UnmarshalBinaryWithContext(ctx)
  6265. if err != nil {
  6266. return err
  6267. }
  6268. return nil
  6269. }
  6270. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6271. // the PVKey type
  6272. func (target *PVKey) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6273. // panics are recovered and propagated as errors
  6274. defer func() {
  6275. if r := recover(); r != nil {
  6276. if e, ok := r.(error); ok {
  6277. err = e
  6278. } else if s, ok := r.(string); ok {
  6279. err = fmt.Errorf("Unexpected panic: %s", s)
  6280. } else {
  6281. err = fmt.Errorf("Unexpected panic: %+v", r)
  6282. }
  6283. }
  6284. }()
  6285. buff := ctx.Buffer
  6286. version := buff.ReadUInt8()
  6287. if version > AllocationCodecVersion {
  6288. return fmt.Errorf("Invalid Version Unmarshaling PVKey. Expected %d or less, got %d", AllocationCodecVersion, version)
  6289. }
  6290. if uint8(0) /* field version */ <= version {
  6291. var b string
  6292. if ctx.IsStringTable() {
  6293. c := buff.ReadInt() // read string index
  6294. b = ctx.Table[c]
  6295. } else {
  6296. b = buff.ReadString() // read string
  6297. }
  6298. a := b
  6299. target.Cluster = a
  6300. } else {
  6301. target.Cluster = "" // default
  6302. }
  6303. if uint8(0) /* field version */ <= version {
  6304. var e string
  6305. if ctx.IsStringTable() {
  6306. f := buff.ReadInt() // read string index
  6307. e = ctx.Table[f]
  6308. } else {
  6309. e = buff.ReadString() // read string
  6310. }
  6311. d := e
  6312. target.Name = d
  6313. } else {
  6314. target.Name = "" // default
  6315. }
  6316. return nil
  6317. }
  6318. //--------------------------------------------------------------------------
  6319. // RawAllocationOnlyData
  6320. //--------------------------------------------------------------------------
  6321. // MarshalBinary serializes the internal properties of this RawAllocationOnlyData instance
  6322. // into a byte array
  6323. func (target *RawAllocationOnlyData) MarshalBinary() (data []byte, err error) {
  6324. ctx := &EncodingContext{
  6325. Buffer: util.NewBuffer(),
  6326. Table: nil,
  6327. }
  6328. e := target.MarshalBinaryWithContext(ctx)
  6329. if e != nil {
  6330. return nil, e
  6331. }
  6332. encBytes := ctx.Buffer.Bytes()
  6333. return encBytes, nil
  6334. }
  6335. // MarshalBinaryWithContext serializes the internal properties of this RawAllocationOnlyData instance
  6336. // into a byte array leveraging a predefined context.
  6337. func (target *RawAllocationOnlyData) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6338. // panics are recovered and propagated as errors
  6339. defer func() {
  6340. if r := recover(); r != nil {
  6341. if e, ok := r.(error); ok {
  6342. err = e
  6343. } else if s, ok := r.(string); ok {
  6344. err = fmt.Errorf("Unexpected panic: %s", s)
  6345. } else {
  6346. err = fmt.Errorf("Unexpected panic: %+v", r)
  6347. }
  6348. }
  6349. }()
  6350. buff := ctx.Buffer
  6351. buff.WriteUInt8(AllocationCodecVersion) // version
  6352. buff.WriteFloat64(target.CPUCoreUsageMax) // write float64
  6353. buff.WriteFloat64(target.RAMBytesUsageMax) // write float64
  6354. return nil
  6355. }
  6356. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6357. // the RawAllocationOnlyData type
  6358. func (target *RawAllocationOnlyData) UnmarshalBinary(data []byte) error {
  6359. var table []string
  6360. buff := util.NewBufferFromBytes(data)
  6361. // string table header validation
  6362. if isBinaryTag(data, BinaryTagStringTable) {
  6363. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6364. tl := buff.ReadInt() // table length
  6365. if tl > 0 {
  6366. table = make([]string, tl, tl)
  6367. for i := 0; i < tl; i++ {
  6368. table[i] = buff.ReadString()
  6369. }
  6370. }
  6371. }
  6372. ctx := &DecodingContext{
  6373. Buffer: buff,
  6374. Table: table,
  6375. }
  6376. err := target.UnmarshalBinaryWithContext(ctx)
  6377. if err != nil {
  6378. return err
  6379. }
  6380. return nil
  6381. }
  6382. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6383. // the RawAllocationOnlyData type
  6384. func (target *RawAllocationOnlyData) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6385. // panics are recovered and propagated as errors
  6386. defer func() {
  6387. if r := recover(); r != nil {
  6388. if e, ok := r.(error); ok {
  6389. err = e
  6390. } else if s, ok := r.(string); ok {
  6391. err = fmt.Errorf("Unexpected panic: %s", s)
  6392. } else {
  6393. err = fmt.Errorf("Unexpected panic: %+v", r)
  6394. }
  6395. }
  6396. }()
  6397. buff := ctx.Buffer
  6398. version := buff.ReadUInt8()
  6399. if version > AllocationCodecVersion {
  6400. return fmt.Errorf("Invalid Version Unmarshaling RawAllocationOnlyData. Expected %d or less, got %d", AllocationCodecVersion, version)
  6401. }
  6402. if uint8(0) /* field version */ <= version {
  6403. a := buff.ReadFloat64() // read float64
  6404. target.CPUCoreUsageMax = a
  6405. } else {
  6406. target.CPUCoreUsageMax = float64(0) // default
  6407. }
  6408. if uint8(0) /* field version */ <= version {
  6409. b := buff.ReadFloat64() // read float64
  6410. target.RAMBytesUsageMax = b
  6411. } else {
  6412. target.RAMBytesUsageMax = float64(0) // default
  6413. }
  6414. return nil
  6415. }
  6416. //--------------------------------------------------------------------------
  6417. // SharedAsset
  6418. //--------------------------------------------------------------------------
  6419. // MarshalBinary serializes the internal properties of this SharedAsset instance
  6420. // into a byte array
  6421. func (target *SharedAsset) MarshalBinary() (data []byte, err error) {
  6422. ctx := &EncodingContext{
  6423. Buffer: util.NewBuffer(),
  6424. Table: nil,
  6425. }
  6426. e := target.MarshalBinaryWithContext(ctx)
  6427. if e != nil {
  6428. return nil, e
  6429. }
  6430. encBytes := ctx.Buffer.Bytes()
  6431. return encBytes, nil
  6432. }
  6433. // MarshalBinaryWithContext serializes the internal properties of this SharedAsset instance
  6434. // into a byte array leveraging a predefined context.
  6435. func (target *SharedAsset) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6436. // panics are recovered and propagated as errors
  6437. defer func() {
  6438. if r := recover(); r != nil {
  6439. if e, ok := r.(error); ok {
  6440. err = e
  6441. } else if s, ok := r.(string); ok {
  6442. err = fmt.Errorf("Unexpected panic: %s", s)
  6443. } else {
  6444. err = fmt.Errorf("Unexpected panic: %+v", r)
  6445. }
  6446. }
  6447. }()
  6448. buff := ctx.Buffer
  6449. buff.WriteUInt8(AssetsCodecVersion) // version
  6450. if target.properties == nil {
  6451. buff.WriteUInt8(uint8(0)) // write nil byte
  6452. } else {
  6453. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6454. // --- [begin][write][struct](AssetProperties) ---
  6455. buff.WriteInt(0) // [compatibility, unused]
  6456. errA := target.properties.MarshalBinaryWithContext(ctx)
  6457. if errA != nil {
  6458. return errA
  6459. }
  6460. // --- [end][write][struct](AssetProperties) ---
  6461. }
  6462. // --- [begin][write][alias](AssetLabels) ---
  6463. if map[string]string(target.labels) == nil {
  6464. buff.WriteUInt8(uint8(0)) // write nil byte
  6465. } else {
  6466. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6467. // --- [begin][write][map](map[string]string) ---
  6468. buff.WriteInt(len(map[string]string(target.labels))) // map length
  6469. for v, z := range map[string]string(target.labels) {
  6470. if ctx.IsStringTable() {
  6471. a := ctx.Table.AddOrGet(v)
  6472. buff.WriteInt(a) // write table index
  6473. } else {
  6474. buff.WriteString(v) // write string
  6475. }
  6476. if ctx.IsStringTable() {
  6477. b := ctx.Table.AddOrGet(z)
  6478. buff.WriteInt(b) // write table index
  6479. } else {
  6480. buff.WriteString(z) // write string
  6481. }
  6482. }
  6483. // --- [end][write][map](map[string]string) ---
  6484. }
  6485. // --- [end][write][alias](AssetLabels) ---
  6486. // --- [begin][write][struct](Window) ---
  6487. buff.WriteInt(0) // [compatibility, unused]
  6488. errB := target.window.MarshalBinaryWithContext(ctx)
  6489. if errB != nil {
  6490. return errB
  6491. }
  6492. // --- [end][write][struct](Window) ---
  6493. buff.WriteFloat64(target.Cost) // write float64
  6494. return nil
  6495. }
  6496. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6497. // the SharedAsset type
  6498. func (target *SharedAsset) UnmarshalBinary(data []byte) error {
  6499. var table []string
  6500. buff := util.NewBufferFromBytes(data)
  6501. // string table header validation
  6502. if isBinaryTag(data, BinaryTagStringTable) {
  6503. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6504. tl := buff.ReadInt() // table length
  6505. if tl > 0 {
  6506. table = make([]string, tl, tl)
  6507. for i := 0; i < tl; i++ {
  6508. table[i] = buff.ReadString()
  6509. }
  6510. }
  6511. }
  6512. ctx := &DecodingContext{
  6513. Buffer: buff,
  6514. Table: table,
  6515. }
  6516. err := target.UnmarshalBinaryWithContext(ctx)
  6517. if err != nil {
  6518. return err
  6519. }
  6520. return nil
  6521. }
  6522. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6523. // the SharedAsset type
  6524. func (target *SharedAsset) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6525. // panics are recovered and propagated as errors
  6526. defer func() {
  6527. if r := recover(); r != nil {
  6528. if e, ok := r.(error); ok {
  6529. err = e
  6530. } else if s, ok := r.(string); ok {
  6531. err = fmt.Errorf("Unexpected panic: %s", s)
  6532. } else {
  6533. err = fmt.Errorf("Unexpected panic: %+v", r)
  6534. }
  6535. }
  6536. }()
  6537. buff := ctx.Buffer
  6538. version := buff.ReadUInt8()
  6539. if version > AssetsCodecVersion {
  6540. return fmt.Errorf("Invalid Version Unmarshaling SharedAsset. Expected %d or less, got %d", AssetsCodecVersion, version)
  6541. }
  6542. if uint8(0) /* field version */ <= version {
  6543. if buff.ReadUInt8() == uint8(0) {
  6544. target.properties = nil
  6545. } else {
  6546. // --- [begin][read][struct](AssetProperties) ---
  6547. a := &AssetProperties{}
  6548. buff.ReadInt() // [compatibility, unused]
  6549. errA := a.UnmarshalBinaryWithContext(ctx)
  6550. if errA != nil {
  6551. return errA
  6552. }
  6553. target.properties = a
  6554. // --- [end][read][struct](AssetProperties) ---
  6555. }
  6556. } else {
  6557. target.properties = nil
  6558. }
  6559. if uint8(0) /* field version */ <= version {
  6560. // --- [begin][read][alias](AssetLabels) ---
  6561. var b map[string]string
  6562. if buff.ReadUInt8() == uint8(0) {
  6563. b = nil
  6564. } else {
  6565. // --- [begin][read][map](map[string]string) ---
  6566. d := buff.ReadInt() // map len
  6567. c := make(map[string]string, d)
  6568. for i := 0; i < d; i++ {
  6569. var v string
  6570. var f string
  6571. if ctx.IsStringTable() {
  6572. g := buff.ReadInt() // read string index
  6573. f = ctx.Table[g]
  6574. } else {
  6575. f = buff.ReadString() // read string
  6576. }
  6577. e := f
  6578. v = e
  6579. var z string
  6580. var k string
  6581. if ctx.IsStringTable() {
  6582. l := buff.ReadInt() // read string index
  6583. k = ctx.Table[l]
  6584. } else {
  6585. k = buff.ReadString() // read string
  6586. }
  6587. h := k
  6588. z = h
  6589. c[v] = z
  6590. }
  6591. b = c
  6592. // --- [end][read][map](map[string]string) ---
  6593. }
  6594. target.labels = AssetLabels(b)
  6595. // --- [end][read][alias](AssetLabels) ---
  6596. } else {
  6597. }
  6598. if uint8(0) /* field version */ <= version {
  6599. // --- [begin][read][struct](Window) ---
  6600. m := &Window{}
  6601. buff.ReadInt() // [compatibility, unused]
  6602. errB := m.UnmarshalBinaryWithContext(ctx)
  6603. if errB != nil {
  6604. return errB
  6605. }
  6606. target.window = *m
  6607. // --- [end][read][struct](Window) ---
  6608. } else {
  6609. }
  6610. if uint8(0) /* field version */ <= version {
  6611. n := buff.ReadFloat64() // read float64
  6612. target.Cost = n
  6613. } else {
  6614. target.Cost = float64(0) // default
  6615. }
  6616. return nil
  6617. }
  6618. //--------------------------------------------------------------------------
  6619. // TotalAudit
  6620. //--------------------------------------------------------------------------
  6621. // MarshalBinary serializes the internal properties of this TotalAudit instance
  6622. // into a byte array
  6623. func (target *TotalAudit) MarshalBinary() (data []byte, err error) {
  6624. ctx := &EncodingContext{
  6625. Buffer: util.NewBuffer(),
  6626. Table: nil,
  6627. }
  6628. e := target.MarshalBinaryWithContext(ctx)
  6629. if e != nil {
  6630. return nil, e
  6631. }
  6632. encBytes := ctx.Buffer.Bytes()
  6633. return encBytes, nil
  6634. }
  6635. // MarshalBinaryWithContext serializes the internal properties of this TotalAudit instance
  6636. // into a byte array leveraging a predefined context.
  6637. func (target *TotalAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6638. // panics are recovered and propagated as errors
  6639. defer func() {
  6640. if r := recover(); r != nil {
  6641. if e, ok := r.(error); ok {
  6642. err = e
  6643. } else if s, ok := r.(string); ok {
  6644. err = fmt.Errorf("Unexpected panic: %s", s)
  6645. } else {
  6646. err = fmt.Errorf("Unexpected panic: %+v", r)
  6647. }
  6648. }
  6649. }()
  6650. buff := ctx.Buffer
  6651. buff.WriteUInt8(AuditCodecVersion) // version
  6652. // --- [begin][write][alias](AuditStatus) ---
  6653. if ctx.IsStringTable() {
  6654. a := ctx.Table.AddOrGet(string(target.Status))
  6655. buff.WriteInt(a) // write table index
  6656. } else {
  6657. buff.WriteString(string(target.Status)) // write string
  6658. }
  6659. // --- [end][write][alias](AuditStatus) ---
  6660. if ctx.IsStringTable() {
  6661. b := ctx.Table.AddOrGet(target.Description)
  6662. buff.WriteInt(b) // write table index
  6663. } else {
  6664. buff.WriteString(target.Description) // write string
  6665. }
  6666. // --- [begin][write][reference](time.Time) ---
  6667. c, errA := target.LastRun.MarshalBinary()
  6668. if errA != nil {
  6669. return errA
  6670. }
  6671. buff.WriteInt(len(c))
  6672. buff.WriteBytes(c)
  6673. // --- [end][write][reference](time.Time) ---
  6674. if target.TotalByNode == nil {
  6675. buff.WriteUInt8(uint8(0)) // write nil byte
  6676. } else {
  6677. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6678. // --- [begin][write][map](map[string]*AuditFloatResult) ---
  6679. buff.WriteInt(len(target.TotalByNode)) // map length
  6680. for v, z := range target.TotalByNode {
  6681. if ctx.IsStringTable() {
  6682. d := ctx.Table.AddOrGet(v)
  6683. buff.WriteInt(d) // write table index
  6684. } else {
  6685. buff.WriteString(v) // write string
  6686. }
  6687. if z == nil {
  6688. buff.WriteUInt8(uint8(0)) // write nil byte
  6689. } else {
  6690. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6691. // --- [begin][write][struct](AuditFloatResult) ---
  6692. buff.WriteInt(0) // [compatibility, unused]
  6693. errB := z.MarshalBinaryWithContext(ctx)
  6694. if errB != nil {
  6695. return errB
  6696. }
  6697. // --- [end][write][struct](AuditFloatResult) ---
  6698. }
  6699. }
  6700. // --- [end][write][map](map[string]*AuditFloatResult) ---
  6701. }
  6702. if target.TotalByCluster == nil {
  6703. buff.WriteUInt8(uint8(0)) // write nil byte
  6704. } else {
  6705. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6706. // --- [begin][write][map](map[string]*AuditFloatResult) ---
  6707. buff.WriteInt(len(target.TotalByCluster)) // map length
  6708. for vv, zz := range target.TotalByCluster {
  6709. if ctx.IsStringTable() {
  6710. e := ctx.Table.AddOrGet(vv)
  6711. buff.WriteInt(e) // write table index
  6712. } else {
  6713. buff.WriteString(vv) // write string
  6714. }
  6715. if zz == nil {
  6716. buff.WriteUInt8(uint8(0)) // write nil byte
  6717. } else {
  6718. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6719. // --- [begin][write][struct](AuditFloatResult) ---
  6720. buff.WriteInt(0) // [compatibility, unused]
  6721. errC := zz.MarshalBinaryWithContext(ctx)
  6722. if errC != nil {
  6723. return errC
  6724. }
  6725. // --- [end][write][struct](AuditFloatResult) ---
  6726. }
  6727. }
  6728. // --- [end][write][map](map[string]*AuditFloatResult) ---
  6729. }
  6730. if target.MissingValues == nil {
  6731. buff.WriteUInt8(uint8(0)) // write nil byte
  6732. } else {
  6733. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6734. // --- [begin][write][slice]([]*AuditMissingValue) ---
  6735. buff.WriteInt(len(target.MissingValues)) // array length
  6736. for i := 0; i < len(target.MissingValues); i++ {
  6737. if target.MissingValues[i] == nil {
  6738. buff.WriteUInt8(uint8(0)) // write nil byte
  6739. } else {
  6740. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6741. // --- [begin][write][struct](AuditMissingValue) ---
  6742. buff.WriteInt(0) // [compatibility, unused]
  6743. errD := target.MissingValues[i].MarshalBinaryWithContext(ctx)
  6744. if errD != nil {
  6745. return errD
  6746. }
  6747. // --- [end][write][struct](AuditMissingValue) ---
  6748. }
  6749. }
  6750. // --- [end][write][slice]([]*AuditMissingValue) ---
  6751. }
  6752. return nil
  6753. }
  6754. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6755. // the TotalAudit type
  6756. func (target *TotalAudit) UnmarshalBinary(data []byte) error {
  6757. var table []string
  6758. buff := util.NewBufferFromBytes(data)
  6759. // string table header validation
  6760. if isBinaryTag(data, BinaryTagStringTable) {
  6761. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6762. tl := buff.ReadInt() // table length
  6763. if tl > 0 {
  6764. table = make([]string, tl, tl)
  6765. for i := 0; i < tl; i++ {
  6766. table[i] = buff.ReadString()
  6767. }
  6768. }
  6769. }
  6770. ctx := &DecodingContext{
  6771. Buffer: buff,
  6772. Table: table,
  6773. }
  6774. err := target.UnmarshalBinaryWithContext(ctx)
  6775. if err != nil {
  6776. return err
  6777. }
  6778. return nil
  6779. }
  6780. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6781. // the TotalAudit type
  6782. func (target *TotalAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6783. // panics are recovered and propagated as errors
  6784. defer func() {
  6785. if r := recover(); r != nil {
  6786. if e, ok := r.(error); ok {
  6787. err = e
  6788. } else if s, ok := r.(string); ok {
  6789. err = fmt.Errorf("Unexpected panic: %s", s)
  6790. } else {
  6791. err = fmt.Errorf("Unexpected panic: %+v", r)
  6792. }
  6793. }
  6794. }()
  6795. buff := ctx.Buffer
  6796. version := buff.ReadUInt8()
  6797. if version > AuditCodecVersion {
  6798. return fmt.Errorf("Invalid Version Unmarshaling TotalAudit. Expected %d or less, got %d", AuditCodecVersion, version)
  6799. }
  6800. if uint8(0) /* field version */ <= version {
  6801. // --- [begin][read][alias](AuditStatus) ---
  6802. var a string
  6803. var c string
  6804. if ctx.IsStringTable() {
  6805. d := buff.ReadInt() // read string index
  6806. c = ctx.Table[d]
  6807. } else {
  6808. c = buff.ReadString() // read string
  6809. }
  6810. b := c
  6811. a = b
  6812. target.Status = AuditStatus(a)
  6813. // --- [end][read][alias](AuditStatus) ---
  6814. } else {
  6815. }
  6816. if uint8(0) /* field version */ <= version {
  6817. var f string
  6818. if ctx.IsStringTable() {
  6819. g := buff.ReadInt() // read string index
  6820. f = ctx.Table[g]
  6821. } else {
  6822. f = buff.ReadString() // read string
  6823. }
  6824. e := f
  6825. target.Description = e
  6826. } else {
  6827. target.Description = "" // default
  6828. }
  6829. if uint8(0) /* field version */ <= version {
  6830. // --- [begin][read][reference](time.Time) ---
  6831. h := &time.Time{}
  6832. k := buff.ReadInt() // byte array length
  6833. l := buff.ReadBytes(k) // byte array
  6834. errA := h.UnmarshalBinary(l)
  6835. if errA != nil {
  6836. return errA
  6837. }
  6838. target.LastRun = *h
  6839. // --- [end][read][reference](time.Time) ---
  6840. } else {
  6841. }
  6842. if uint8(0) /* field version */ <= version {
  6843. if buff.ReadUInt8() == uint8(0) {
  6844. target.TotalByNode = nil
  6845. } else {
  6846. // --- [begin][read][map](map[string]*AuditFloatResult) ---
  6847. n := buff.ReadInt() // map len
  6848. m := make(map[string]*AuditFloatResult, n)
  6849. for i := 0; i < n; i++ {
  6850. var v string
  6851. var p string
  6852. if ctx.IsStringTable() {
  6853. q := buff.ReadInt() // read string index
  6854. p = ctx.Table[q]
  6855. } else {
  6856. p = buff.ReadString() // read string
  6857. }
  6858. o := p
  6859. v = o
  6860. var z *AuditFloatResult
  6861. if buff.ReadUInt8() == uint8(0) {
  6862. z = nil
  6863. } else {
  6864. // --- [begin][read][struct](AuditFloatResult) ---
  6865. r := &AuditFloatResult{}
  6866. buff.ReadInt() // [compatibility, unused]
  6867. errB := r.UnmarshalBinaryWithContext(ctx)
  6868. if errB != nil {
  6869. return errB
  6870. }
  6871. z = r
  6872. // --- [end][read][struct](AuditFloatResult) ---
  6873. }
  6874. m[v] = z
  6875. }
  6876. target.TotalByNode = m
  6877. // --- [end][read][map](map[string]*AuditFloatResult) ---
  6878. }
  6879. } else {
  6880. target.TotalByNode = nil
  6881. }
  6882. if uint8(0) /* field version */ <= version {
  6883. if buff.ReadUInt8() == uint8(0) {
  6884. target.TotalByCluster = nil
  6885. } else {
  6886. // --- [begin][read][map](map[string]*AuditFloatResult) ---
  6887. t := buff.ReadInt() // map len
  6888. s := make(map[string]*AuditFloatResult, t)
  6889. for j := 0; j < t; j++ {
  6890. var vv string
  6891. var w string
  6892. if ctx.IsStringTable() {
  6893. x := buff.ReadInt() // read string index
  6894. w = ctx.Table[x]
  6895. } else {
  6896. w = buff.ReadString() // read string
  6897. }
  6898. u := w
  6899. vv = u
  6900. var zz *AuditFloatResult
  6901. if buff.ReadUInt8() == uint8(0) {
  6902. zz = nil
  6903. } else {
  6904. // --- [begin][read][struct](AuditFloatResult) ---
  6905. y := &AuditFloatResult{}
  6906. buff.ReadInt() // [compatibility, unused]
  6907. errC := y.UnmarshalBinaryWithContext(ctx)
  6908. if errC != nil {
  6909. return errC
  6910. }
  6911. zz = y
  6912. // --- [end][read][struct](AuditFloatResult) ---
  6913. }
  6914. s[vv] = zz
  6915. }
  6916. target.TotalByCluster = s
  6917. // --- [end][read][map](map[string]*AuditFloatResult) ---
  6918. }
  6919. } else {
  6920. target.TotalByCluster = nil
  6921. }
  6922. if uint8(0) /* field version */ <= version {
  6923. if buff.ReadUInt8() == uint8(0) {
  6924. target.MissingValues = nil
  6925. } else {
  6926. // --- [begin][read][slice]([]*AuditMissingValue) ---
  6927. bb := buff.ReadInt() // array len
  6928. aa := make([]*AuditMissingValue, bb)
  6929. for ii := 0; ii < bb; ii++ {
  6930. var cc *AuditMissingValue
  6931. if buff.ReadUInt8() == uint8(0) {
  6932. cc = nil
  6933. } else {
  6934. // --- [begin][read][struct](AuditMissingValue) ---
  6935. dd := &AuditMissingValue{}
  6936. buff.ReadInt() // [compatibility, unused]
  6937. errD := dd.UnmarshalBinaryWithContext(ctx)
  6938. if errD != nil {
  6939. return errD
  6940. }
  6941. cc = dd
  6942. // --- [end][read][struct](AuditMissingValue) ---
  6943. }
  6944. aa[ii] = cc
  6945. }
  6946. target.MissingValues = aa
  6947. // --- [end][read][slice]([]*AuditMissingValue) ---
  6948. }
  6949. } else {
  6950. target.MissingValues = nil
  6951. }
  6952. return nil
  6953. }
  6954. //--------------------------------------------------------------------------
  6955. // Window
  6956. //--------------------------------------------------------------------------
  6957. // MarshalBinary serializes the internal properties of this Window instance
  6958. // into a byte array
  6959. func (target *Window) MarshalBinary() (data []byte, err error) {
  6960. ctx := &EncodingContext{
  6961. Buffer: util.NewBuffer(),
  6962. Table: nil,
  6963. }
  6964. e := target.MarshalBinaryWithContext(ctx)
  6965. if e != nil {
  6966. return nil, e
  6967. }
  6968. encBytes := ctx.Buffer.Bytes()
  6969. return encBytes, nil
  6970. }
  6971. // MarshalBinaryWithContext serializes the internal properties of this Window instance
  6972. // into a byte array leveraging a predefined context.
  6973. func (target *Window) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6974. // panics are recovered and propagated as errors
  6975. defer func() {
  6976. if r := recover(); r != nil {
  6977. if e, ok := r.(error); ok {
  6978. err = e
  6979. } else if s, ok := r.(string); ok {
  6980. err = fmt.Errorf("Unexpected panic: %s", s)
  6981. } else {
  6982. err = fmt.Errorf("Unexpected panic: %+v", r)
  6983. }
  6984. }
  6985. }()
  6986. buff := ctx.Buffer
  6987. buff.WriteUInt8(DefaultCodecVersion) // version
  6988. if target.start == nil {
  6989. buff.WriteUInt8(uint8(0)) // write nil byte
  6990. } else {
  6991. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6992. // --- [begin][write][reference](time.Time) ---
  6993. a, errA := target.start.MarshalBinary()
  6994. if errA != nil {
  6995. return errA
  6996. }
  6997. buff.WriteInt(len(a))
  6998. buff.WriteBytes(a)
  6999. // --- [end][write][reference](time.Time) ---
  7000. }
  7001. if target.end == nil {
  7002. buff.WriteUInt8(uint8(0)) // write nil byte
  7003. } else {
  7004. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7005. // --- [begin][write][reference](time.Time) ---
  7006. b, errB := target.end.MarshalBinary()
  7007. if errB != nil {
  7008. return errB
  7009. }
  7010. buff.WriteInt(len(b))
  7011. buff.WriteBytes(b)
  7012. // --- [end][write][reference](time.Time) ---
  7013. }
  7014. return nil
  7015. }
  7016. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7017. // the Window type
  7018. func (target *Window) UnmarshalBinary(data []byte) error {
  7019. var table []string
  7020. buff := util.NewBufferFromBytes(data)
  7021. // string table header validation
  7022. if isBinaryTag(data, BinaryTagStringTable) {
  7023. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  7024. tl := buff.ReadInt() // table length
  7025. if tl > 0 {
  7026. table = make([]string, tl, tl)
  7027. for i := 0; i < tl; i++ {
  7028. table[i] = buff.ReadString()
  7029. }
  7030. }
  7031. }
  7032. ctx := &DecodingContext{
  7033. Buffer: buff,
  7034. Table: table,
  7035. }
  7036. err := target.UnmarshalBinaryWithContext(ctx)
  7037. if err != nil {
  7038. return err
  7039. }
  7040. return nil
  7041. }
  7042. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7043. // the Window type
  7044. func (target *Window) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7045. // panics are recovered and propagated as errors
  7046. defer func() {
  7047. if r := recover(); r != nil {
  7048. if e, ok := r.(error); ok {
  7049. err = e
  7050. } else if s, ok := r.(string); ok {
  7051. err = fmt.Errorf("Unexpected panic: %s", s)
  7052. } else {
  7053. err = fmt.Errorf("Unexpected panic: %+v", r)
  7054. }
  7055. }
  7056. }()
  7057. buff := ctx.Buffer
  7058. version := buff.ReadUInt8()
  7059. if version > DefaultCodecVersion {
  7060. return fmt.Errorf("Invalid Version Unmarshaling Window. Expected %d or less, got %d", DefaultCodecVersion, version)
  7061. }
  7062. if uint8(0) /* field version */ <= version {
  7063. if buff.ReadUInt8() == uint8(0) {
  7064. target.start = nil
  7065. } else {
  7066. // --- [begin][read][reference](time.Time) ---
  7067. a := &time.Time{}
  7068. b := buff.ReadInt() // byte array length
  7069. c := buff.ReadBytes(b) // byte array
  7070. errA := a.UnmarshalBinary(c)
  7071. if errA != nil {
  7072. return errA
  7073. }
  7074. target.start = a
  7075. // --- [end][read][reference](time.Time) ---
  7076. }
  7077. } else {
  7078. target.start = nil
  7079. }
  7080. if uint8(0) /* field version */ <= version {
  7081. if buff.ReadUInt8() == uint8(0) {
  7082. target.end = nil
  7083. } else {
  7084. // --- [begin][read][reference](time.Time) ---
  7085. d := &time.Time{}
  7086. e := buff.ReadInt() // byte array length
  7087. f := buff.ReadBytes(e) // byte array
  7088. errB := d.UnmarshalBinary(f)
  7089. if errB != nil {
  7090. return errB
  7091. }
  7092. target.end = d
  7093. // --- [end][read][reference](time.Time) ---
  7094. }
  7095. } else {
  7096. target.end = nil
  7097. }
  7098. return nil
  7099. }