kubecost_codecs.go 191 KB

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