kubecost_codecs.go 245 KB

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