kubecost_codecs.go 244 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // DO NOT MODIFY
  4. //
  5. // ┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
  6. //
  7. //
  8. // This source file was automatically generated by bingen.
  9. //
  10. ////////////////////////////////////////////////////////////////////////////////
  11. package kubecost
  12. import (
  13. "fmt"
  14. "reflect"
  15. "strings"
  16. "sync"
  17. "time"
  18. util "github.com/opencost/opencost/pkg/util"
  19. )
  20. const (
  21. // GeneratorPackageName is the package the generator is targetting
  22. GeneratorPackageName string = "kubecost"
  23. )
  24. // BinaryTags represent the formatting tag used for specific optimization features
  25. const (
  26. // BinaryTagStringTable is written and/or read prior to the existence of a string
  27. // table (where each index is encoded as a string entry in the resource
  28. BinaryTagStringTable string = "BGST"
  29. )
  30. const (
  31. // DefaultCodecVersion is used for any resources listed in the Default version set
  32. DefaultCodecVersion uint8 = 17
  33. // AssetsCodecVersion is used for any resources listed in the Assets version set
  34. AssetsCodecVersion uint8 = 19
  35. // AllocationCodecVersion is used for any resources listed in the Allocation version set
  36. AllocationCodecVersion uint8 = 17
  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(17) <= 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. return nil
  6397. }
  6398. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6399. // the LbAllocation type
  6400. func (target *LbAllocation) UnmarshalBinary(data []byte) error {
  6401. var table []string
  6402. buff := util.NewBufferFromBytes(data)
  6403. // string table header validation
  6404. if isBinaryTag(data, BinaryTagStringTable) {
  6405. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6406. tl := buff.ReadInt() // table length
  6407. if tl > 0 {
  6408. table = make([]string, tl, tl)
  6409. for i := 0; i < tl; i++ {
  6410. table[i] = buff.ReadString()
  6411. }
  6412. }
  6413. }
  6414. ctx := &DecodingContext{
  6415. Buffer: buff,
  6416. Table: table,
  6417. }
  6418. err := target.UnmarshalBinaryWithContext(ctx)
  6419. if err != nil {
  6420. return err
  6421. }
  6422. return nil
  6423. }
  6424. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6425. // the LbAllocation type
  6426. func (target *LbAllocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6427. // panics are recovered and propagated as errors
  6428. defer func() {
  6429. if r := recover(); r != nil {
  6430. if e, ok := r.(error); ok {
  6431. err = e
  6432. } else if s, ok := r.(string); ok {
  6433. err = fmt.Errorf("Unexpected panic: %s", s)
  6434. } else {
  6435. err = fmt.Errorf("Unexpected panic: %+v", r)
  6436. }
  6437. }
  6438. }()
  6439. buff := ctx.Buffer
  6440. version := buff.ReadUInt8()
  6441. if version > AllocationCodecVersion {
  6442. return fmt.Errorf("Invalid Version Unmarshaling LbAllocation. Expected %d or less, got %d", AllocationCodecVersion, version)
  6443. }
  6444. var b string
  6445. if ctx.IsStringTable() {
  6446. c := buff.ReadInt() // read string index
  6447. b = ctx.Table[c]
  6448. } else {
  6449. b = buff.ReadString() // read string
  6450. }
  6451. a := b
  6452. target.Service = a
  6453. d := buff.ReadFloat64() // read float64
  6454. target.Cost = d
  6455. return nil
  6456. }
  6457. //--------------------------------------------------------------------------
  6458. // LoadBalancer
  6459. //--------------------------------------------------------------------------
  6460. // MarshalBinary serializes the internal properties of this LoadBalancer instance
  6461. // into a byte array
  6462. func (target *LoadBalancer) MarshalBinary() (data []byte, err error) {
  6463. ctx := &EncodingContext{
  6464. Buffer: util.NewBuffer(),
  6465. Table: nil,
  6466. }
  6467. e := target.MarshalBinaryWithContext(ctx)
  6468. if e != nil {
  6469. return nil, e
  6470. }
  6471. encBytes := ctx.Buffer.Bytes()
  6472. return encBytes, nil
  6473. }
  6474. // MarshalBinaryWithContext serializes the internal properties of this LoadBalancer instance
  6475. // into a byte array leveraging a predefined context.
  6476. func (target *LoadBalancer) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6477. // panics are recovered and propagated as errors
  6478. defer func() {
  6479. if r := recover(); r != nil {
  6480. if e, ok := r.(error); ok {
  6481. err = e
  6482. } else if s, ok := r.(string); ok {
  6483. err = fmt.Errorf("Unexpected panic: %s", s)
  6484. } else {
  6485. err = fmt.Errorf("Unexpected panic: %+v", r)
  6486. }
  6487. }
  6488. }()
  6489. buff := ctx.Buffer
  6490. buff.WriteUInt8(AssetsCodecVersion) // version
  6491. if target.Properties == nil {
  6492. buff.WriteUInt8(uint8(0)) // write nil byte
  6493. } else {
  6494. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6495. // --- [begin][write][struct](AssetProperties) ---
  6496. buff.WriteInt(0) // [compatibility, unused]
  6497. errA := target.Properties.MarshalBinaryWithContext(ctx)
  6498. if errA != nil {
  6499. return errA
  6500. }
  6501. // --- [end][write][struct](AssetProperties) ---
  6502. }
  6503. // --- [begin][write][alias](AssetLabels) ---
  6504. if map[string]string(target.Labels) == nil {
  6505. buff.WriteUInt8(uint8(0)) // write nil byte
  6506. } else {
  6507. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6508. // --- [begin][write][map](map[string]string) ---
  6509. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  6510. for v, z := range map[string]string(target.Labels) {
  6511. if ctx.IsStringTable() {
  6512. a := ctx.Table.AddOrGet(v)
  6513. buff.WriteInt(a) // write table index
  6514. } else {
  6515. buff.WriteString(v) // write string
  6516. }
  6517. if ctx.IsStringTable() {
  6518. b := ctx.Table.AddOrGet(z)
  6519. buff.WriteInt(b) // write table index
  6520. } else {
  6521. buff.WriteString(z) // write string
  6522. }
  6523. }
  6524. // --- [end][write][map](map[string]string) ---
  6525. }
  6526. // --- [end][write][alias](AssetLabels) ---
  6527. // --- [begin][write][reference](time.Time) ---
  6528. c, errB := target.Start.MarshalBinary()
  6529. if errB != nil {
  6530. return errB
  6531. }
  6532. buff.WriteInt(len(c))
  6533. buff.WriteBytes(c)
  6534. // --- [end][write][reference](time.Time) ---
  6535. // --- [begin][write][reference](time.Time) ---
  6536. d, errC := target.End.MarshalBinary()
  6537. if errC != nil {
  6538. return errC
  6539. }
  6540. buff.WriteInt(len(d))
  6541. buff.WriteBytes(d)
  6542. // --- [end][write][reference](time.Time) ---
  6543. // --- [begin][write][struct](Window) ---
  6544. buff.WriteInt(0) // [compatibility, unused]
  6545. errD := target.Window.MarshalBinaryWithContext(ctx)
  6546. if errD != nil {
  6547. return errD
  6548. }
  6549. // --- [end][write][struct](Window) ---
  6550. buff.WriteFloat64(target.Adjustment) // write float64
  6551. buff.WriteFloat64(target.Cost) // write float64
  6552. return nil
  6553. }
  6554. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6555. // the LoadBalancer type
  6556. func (target *LoadBalancer) UnmarshalBinary(data []byte) error {
  6557. var table []string
  6558. buff := util.NewBufferFromBytes(data)
  6559. // string table header validation
  6560. if isBinaryTag(data, BinaryTagStringTable) {
  6561. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6562. tl := buff.ReadInt() // table length
  6563. if tl > 0 {
  6564. table = make([]string, tl, tl)
  6565. for i := 0; i < tl; i++ {
  6566. table[i] = buff.ReadString()
  6567. }
  6568. }
  6569. }
  6570. ctx := &DecodingContext{
  6571. Buffer: buff,
  6572. Table: table,
  6573. }
  6574. err := target.UnmarshalBinaryWithContext(ctx)
  6575. if err != nil {
  6576. return err
  6577. }
  6578. return nil
  6579. }
  6580. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6581. // the LoadBalancer type
  6582. func (target *LoadBalancer) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6583. // panics are recovered and propagated as errors
  6584. defer func() {
  6585. if r := recover(); r != nil {
  6586. if e, ok := r.(error); ok {
  6587. err = e
  6588. } else if s, ok := r.(string); ok {
  6589. err = fmt.Errorf("Unexpected panic: %s", s)
  6590. } else {
  6591. err = fmt.Errorf("Unexpected panic: %+v", r)
  6592. }
  6593. }
  6594. }()
  6595. buff := ctx.Buffer
  6596. version := buff.ReadUInt8()
  6597. if version > AssetsCodecVersion {
  6598. return fmt.Errorf("Invalid Version Unmarshaling LoadBalancer. Expected %d or less, got %d", AssetsCodecVersion, version)
  6599. }
  6600. if buff.ReadUInt8() == uint8(0) {
  6601. target.Properties = nil
  6602. } else {
  6603. // --- [begin][read][struct](AssetProperties) ---
  6604. a := &AssetProperties{}
  6605. buff.ReadInt() // [compatibility, unused]
  6606. errA := a.UnmarshalBinaryWithContext(ctx)
  6607. if errA != nil {
  6608. return errA
  6609. }
  6610. target.Properties = a
  6611. // --- [end][read][struct](AssetProperties) ---
  6612. }
  6613. // --- [begin][read][alias](AssetLabels) ---
  6614. var b map[string]string
  6615. if buff.ReadUInt8() == uint8(0) {
  6616. b = nil
  6617. } else {
  6618. // --- [begin][read][map](map[string]string) ---
  6619. d := buff.ReadInt() // map len
  6620. c := make(map[string]string, d)
  6621. for i := 0; i < d; i++ {
  6622. var v string
  6623. var f string
  6624. if ctx.IsStringTable() {
  6625. g := buff.ReadInt() // read string index
  6626. f = ctx.Table[g]
  6627. } else {
  6628. f = buff.ReadString() // read string
  6629. }
  6630. e := f
  6631. v = e
  6632. var z string
  6633. var k string
  6634. if ctx.IsStringTable() {
  6635. l := buff.ReadInt() // read string index
  6636. k = ctx.Table[l]
  6637. } else {
  6638. k = buff.ReadString() // read string
  6639. }
  6640. h := k
  6641. z = h
  6642. c[v] = z
  6643. }
  6644. b = c
  6645. // --- [end][read][map](map[string]string) ---
  6646. }
  6647. target.Labels = AssetLabels(b)
  6648. // --- [end][read][alias](AssetLabels) ---
  6649. // --- [begin][read][reference](time.Time) ---
  6650. m := &time.Time{}
  6651. n := buff.ReadInt() // byte array length
  6652. o := buff.ReadBytes(n) // byte array
  6653. errB := m.UnmarshalBinary(o)
  6654. if errB != nil {
  6655. return errB
  6656. }
  6657. target.Start = *m
  6658. // --- [end][read][reference](time.Time) ---
  6659. // --- [begin][read][reference](time.Time) ---
  6660. p := &time.Time{}
  6661. q := buff.ReadInt() // byte array length
  6662. r := buff.ReadBytes(q) // byte array
  6663. errC := p.UnmarshalBinary(r)
  6664. if errC != nil {
  6665. return errC
  6666. }
  6667. target.End = *p
  6668. // --- [end][read][reference](time.Time) ---
  6669. // --- [begin][read][struct](Window) ---
  6670. s := &Window{}
  6671. buff.ReadInt() // [compatibility, unused]
  6672. errD := s.UnmarshalBinaryWithContext(ctx)
  6673. if errD != nil {
  6674. return errD
  6675. }
  6676. target.Window = *s
  6677. // --- [end][read][struct](Window) ---
  6678. t := buff.ReadFloat64() // read float64
  6679. target.Adjustment = t
  6680. u := buff.ReadFloat64() // read float64
  6681. target.Cost = u
  6682. return nil
  6683. }
  6684. //--------------------------------------------------------------------------
  6685. // Network
  6686. //--------------------------------------------------------------------------
  6687. // MarshalBinary serializes the internal properties of this Network instance
  6688. // into a byte array
  6689. func (target *Network) MarshalBinary() (data []byte, err error) {
  6690. ctx := &EncodingContext{
  6691. Buffer: util.NewBuffer(),
  6692. Table: nil,
  6693. }
  6694. e := target.MarshalBinaryWithContext(ctx)
  6695. if e != nil {
  6696. return nil, e
  6697. }
  6698. encBytes := ctx.Buffer.Bytes()
  6699. return encBytes, nil
  6700. }
  6701. // MarshalBinaryWithContext serializes the internal properties of this Network instance
  6702. // into a byte array leveraging a predefined context.
  6703. func (target *Network) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6704. // panics are recovered and propagated as errors
  6705. defer func() {
  6706. if r := recover(); r != nil {
  6707. if e, ok := r.(error); ok {
  6708. err = e
  6709. } else if s, ok := r.(string); ok {
  6710. err = fmt.Errorf("Unexpected panic: %s", s)
  6711. } else {
  6712. err = fmt.Errorf("Unexpected panic: %+v", r)
  6713. }
  6714. }
  6715. }()
  6716. buff := ctx.Buffer
  6717. buff.WriteUInt8(AssetsCodecVersion) // version
  6718. if target.Properties == nil {
  6719. buff.WriteUInt8(uint8(0)) // write nil byte
  6720. } else {
  6721. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6722. // --- [begin][write][struct](AssetProperties) ---
  6723. buff.WriteInt(0) // [compatibility, unused]
  6724. errA := target.Properties.MarshalBinaryWithContext(ctx)
  6725. if errA != nil {
  6726. return errA
  6727. }
  6728. // --- [end][write][struct](AssetProperties) ---
  6729. }
  6730. // --- [begin][write][alias](AssetLabels) ---
  6731. if map[string]string(target.Labels) == nil {
  6732. buff.WriteUInt8(uint8(0)) // write nil byte
  6733. } else {
  6734. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6735. // --- [begin][write][map](map[string]string) ---
  6736. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  6737. for v, z := range map[string]string(target.Labels) {
  6738. if ctx.IsStringTable() {
  6739. a := ctx.Table.AddOrGet(v)
  6740. buff.WriteInt(a) // write table index
  6741. } else {
  6742. buff.WriteString(v) // write string
  6743. }
  6744. if ctx.IsStringTable() {
  6745. b := ctx.Table.AddOrGet(z)
  6746. buff.WriteInt(b) // write table index
  6747. } else {
  6748. buff.WriteString(z) // write string
  6749. }
  6750. }
  6751. // --- [end][write][map](map[string]string) ---
  6752. }
  6753. // --- [end][write][alias](AssetLabels) ---
  6754. // --- [begin][write][reference](time.Time) ---
  6755. c, errB := target.Start.MarshalBinary()
  6756. if errB != nil {
  6757. return errB
  6758. }
  6759. buff.WriteInt(len(c))
  6760. buff.WriteBytes(c)
  6761. // --- [end][write][reference](time.Time) ---
  6762. // --- [begin][write][reference](time.Time) ---
  6763. d, errC := target.End.MarshalBinary()
  6764. if errC != nil {
  6765. return errC
  6766. }
  6767. buff.WriteInt(len(d))
  6768. buff.WriteBytes(d)
  6769. // --- [end][write][reference](time.Time) ---
  6770. // --- [begin][write][struct](Window) ---
  6771. buff.WriteInt(0) // [compatibility, unused]
  6772. errD := target.Window.MarshalBinaryWithContext(ctx)
  6773. if errD != nil {
  6774. return errD
  6775. }
  6776. // --- [end][write][struct](Window) ---
  6777. buff.WriteFloat64(target.Adjustment) // write float64
  6778. buff.WriteFloat64(target.Cost) // write float64
  6779. return nil
  6780. }
  6781. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6782. // the Network type
  6783. func (target *Network) UnmarshalBinary(data []byte) error {
  6784. var table []string
  6785. buff := util.NewBufferFromBytes(data)
  6786. // string table header validation
  6787. if isBinaryTag(data, BinaryTagStringTable) {
  6788. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6789. tl := buff.ReadInt() // table length
  6790. if tl > 0 {
  6791. table = make([]string, tl, tl)
  6792. for i := 0; i < tl; i++ {
  6793. table[i] = buff.ReadString()
  6794. }
  6795. }
  6796. }
  6797. ctx := &DecodingContext{
  6798. Buffer: buff,
  6799. Table: table,
  6800. }
  6801. err := target.UnmarshalBinaryWithContext(ctx)
  6802. if err != nil {
  6803. return err
  6804. }
  6805. return nil
  6806. }
  6807. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6808. // the Network type
  6809. func (target *Network) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6810. // panics are recovered and propagated as errors
  6811. defer func() {
  6812. if r := recover(); r != nil {
  6813. if e, ok := r.(error); ok {
  6814. err = e
  6815. } else if s, ok := r.(string); ok {
  6816. err = fmt.Errorf("Unexpected panic: %s", s)
  6817. } else {
  6818. err = fmt.Errorf("Unexpected panic: %+v", r)
  6819. }
  6820. }
  6821. }()
  6822. buff := ctx.Buffer
  6823. version := buff.ReadUInt8()
  6824. if version > AssetsCodecVersion {
  6825. return fmt.Errorf("Invalid Version Unmarshaling Network. Expected %d or less, got %d", AssetsCodecVersion, version)
  6826. }
  6827. if buff.ReadUInt8() == uint8(0) {
  6828. target.Properties = nil
  6829. } else {
  6830. // --- [begin][read][struct](AssetProperties) ---
  6831. a := &AssetProperties{}
  6832. buff.ReadInt() // [compatibility, unused]
  6833. errA := a.UnmarshalBinaryWithContext(ctx)
  6834. if errA != nil {
  6835. return errA
  6836. }
  6837. target.Properties = a
  6838. // --- [end][read][struct](AssetProperties) ---
  6839. }
  6840. // --- [begin][read][alias](AssetLabels) ---
  6841. var b map[string]string
  6842. if buff.ReadUInt8() == uint8(0) {
  6843. b = nil
  6844. } else {
  6845. // --- [begin][read][map](map[string]string) ---
  6846. d := buff.ReadInt() // map len
  6847. c := make(map[string]string, d)
  6848. for i := 0; i < d; i++ {
  6849. var v string
  6850. var f string
  6851. if ctx.IsStringTable() {
  6852. g := buff.ReadInt() // read string index
  6853. f = ctx.Table[g]
  6854. } else {
  6855. f = buff.ReadString() // read string
  6856. }
  6857. e := f
  6858. v = e
  6859. var z string
  6860. var k string
  6861. if ctx.IsStringTable() {
  6862. l := buff.ReadInt() // read string index
  6863. k = ctx.Table[l]
  6864. } else {
  6865. k = buff.ReadString() // read string
  6866. }
  6867. h := k
  6868. z = h
  6869. c[v] = z
  6870. }
  6871. b = c
  6872. // --- [end][read][map](map[string]string) ---
  6873. }
  6874. target.Labels = AssetLabels(b)
  6875. // --- [end][read][alias](AssetLabels) ---
  6876. // --- [begin][read][reference](time.Time) ---
  6877. m := &time.Time{}
  6878. n := buff.ReadInt() // byte array length
  6879. o := buff.ReadBytes(n) // byte array
  6880. errB := m.UnmarshalBinary(o)
  6881. if errB != nil {
  6882. return errB
  6883. }
  6884. target.Start = *m
  6885. // --- [end][read][reference](time.Time) ---
  6886. // --- [begin][read][reference](time.Time) ---
  6887. p := &time.Time{}
  6888. q := buff.ReadInt() // byte array length
  6889. r := buff.ReadBytes(q) // byte array
  6890. errC := p.UnmarshalBinary(r)
  6891. if errC != nil {
  6892. return errC
  6893. }
  6894. target.End = *p
  6895. // --- [end][read][reference](time.Time) ---
  6896. // --- [begin][read][struct](Window) ---
  6897. s := &Window{}
  6898. buff.ReadInt() // [compatibility, unused]
  6899. errD := s.UnmarshalBinaryWithContext(ctx)
  6900. if errD != nil {
  6901. return errD
  6902. }
  6903. target.Window = *s
  6904. // --- [end][read][struct](Window) ---
  6905. t := buff.ReadFloat64() // read float64
  6906. target.Adjustment = t
  6907. u := buff.ReadFloat64() // read float64
  6908. target.Cost = u
  6909. return nil
  6910. }
  6911. //--------------------------------------------------------------------------
  6912. // Node
  6913. //--------------------------------------------------------------------------
  6914. // MarshalBinary serializes the internal properties of this Node instance
  6915. // into a byte array
  6916. func (target *Node) MarshalBinary() (data []byte, err error) {
  6917. ctx := &EncodingContext{
  6918. Buffer: util.NewBuffer(),
  6919. Table: nil,
  6920. }
  6921. e := target.MarshalBinaryWithContext(ctx)
  6922. if e != nil {
  6923. return nil, e
  6924. }
  6925. encBytes := ctx.Buffer.Bytes()
  6926. return encBytes, nil
  6927. }
  6928. // MarshalBinaryWithContext serializes the internal properties of this Node instance
  6929. // into a byte array leveraging a predefined context.
  6930. func (target *Node) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6931. // panics are recovered and propagated as errors
  6932. defer func() {
  6933. if r := recover(); r != nil {
  6934. if e, ok := r.(error); ok {
  6935. err = e
  6936. } else if s, ok := r.(string); ok {
  6937. err = fmt.Errorf("Unexpected panic: %s", s)
  6938. } else {
  6939. err = fmt.Errorf("Unexpected panic: %+v", r)
  6940. }
  6941. }
  6942. }()
  6943. buff := ctx.Buffer
  6944. buff.WriteUInt8(AssetsCodecVersion) // version
  6945. if target.Properties == nil {
  6946. buff.WriteUInt8(uint8(0)) // write nil byte
  6947. } else {
  6948. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6949. // --- [begin][write][struct](AssetProperties) ---
  6950. buff.WriteInt(0) // [compatibility, unused]
  6951. errA := target.Properties.MarshalBinaryWithContext(ctx)
  6952. if errA != nil {
  6953. return errA
  6954. }
  6955. // --- [end][write][struct](AssetProperties) ---
  6956. }
  6957. // --- [begin][write][alias](AssetLabels) ---
  6958. if map[string]string(target.Labels) == nil {
  6959. buff.WriteUInt8(uint8(0)) // write nil byte
  6960. } else {
  6961. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6962. // --- [begin][write][map](map[string]string) ---
  6963. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  6964. for v, z := range map[string]string(target.Labels) {
  6965. if ctx.IsStringTable() {
  6966. a := ctx.Table.AddOrGet(v)
  6967. buff.WriteInt(a) // write table index
  6968. } else {
  6969. buff.WriteString(v) // write string
  6970. }
  6971. if ctx.IsStringTable() {
  6972. b := ctx.Table.AddOrGet(z)
  6973. buff.WriteInt(b) // write table index
  6974. } else {
  6975. buff.WriteString(z) // write string
  6976. }
  6977. }
  6978. // --- [end][write][map](map[string]string) ---
  6979. }
  6980. // --- [end][write][alias](AssetLabels) ---
  6981. // --- [begin][write][reference](time.Time) ---
  6982. c, errB := target.Start.MarshalBinary()
  6983. if errB != nil {
  6984. return errB
  6985. }
  6986. buff.WriteInt(len(c))
  6987. buff.WriteBytes(c)
  6988. // --- [end][write][reference](time.Time) ---
  6989. // --- [begin][write][reference](time.Time) ---
  6990. d, errC := target.End.MarshalBinary()
  6991. if errC != nil {
  6992. return errC
  6993. }
  6994. buff.WriteInt(len(d))
  6995. buff.WriteBytes(d)
  6996. // --- [end][write][reference](time.Time) ---
  6997. // --- [begin][write][struct](Window) ---
  6998. buff.WriteInt(0) // [compatibility, unused]
  6999. errD := target.Window.MarshalBinaryWithContext(ctx)
  7000. if errD != nil {
  7001. return errD
  7002. }
  7003. // --- [end][write][struct](Window) ---
  7004. buff.WriteFloat64(target.Adjustment) // write float64
  7005. if ctx.IsStringTable() {
  7006. e := ctx.Table.AddOrGet(target.NodeType)
  7007. buff.WriteInt(e) // write table index
  7008. } else {
  7009. buff.WriteString(target.NodeType) // write string
  7010. }
  7011. buff.WriteFloat64(target.CPUCoreHours) // write float64
  7012. buff.WriteFloat64(target.RAMByteHours) // write float64
  7013. buff.WriteFloat64(target.GPUHours) // write float64
  7014. if target.CPUBreakdown == nil {
  7015. buff.WriteUInt8(uint8(0)) // write nil byte
  7016. } else {
  7017. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7018. // --- [begin][write][struct](Breakdown) ---
  7019. buff.WriteInt(0) // [compatibility, unused]
  7020. errE := target.CPUBreakdown.MarshalBinaryWithContext(ctx)
  7021. if errE != nil {
  7022. return errE
  7023. }
  7024. // --- [end][write][struct](Breakdown) ---
  7025. }
  7026. if target.RAMBreakdown == nil {
  7027. buff.WriteUInt8(uint8(0)) // write nil byte
  7028. } else {
  7029. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7030. // --- [begin][write][struct](Breakdown) ---
  7031. buff.WriteInt(0) // [compatibility, unused]
  7032. errF := target.RAMBreakdown.MarshalBinaryWithContext(ctx)
  7033. if errF != nil {
  7034. return errF
  7035. }
  7036. // --- [end][write][struct](Breakdown) ---
  7037. }
  7038. buff.WriteFloat64(target.CPUCost) // write float64
  7039. buff.WriteFloat64(target.GPUCost) // write float64
  7040. buff.WriteFloat64(target.GPUCount) // write float64
  7041. buff.WriteFloat64(target.RAMCost) // write float64
  7042. buff.WriteFloat64(target.Discount) // write float64
  7043. buff.WriteFloat64(target.Preemptible) // write float64
  7044. if target.Overhead == nil {
  7045. buff.WriteUInt8(uint8(0)) // write nil byte
  7046. } else {
  7047. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7048. // --- [begin][write][struct](NodeOverhead) ---
  7049. buff.WriteInt(0) // [compatibility, unused]
  7050. errG := target.Overhead.MarshalBinaryWithContext(ctx)
  7051. if errG != nil {
  7052. return errG
  7053. }
  7054. // --- [end][write][struct](NodeOverhead) ---
  7055. }
  7056. return nil
  7057. }
  7058. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7059. // the Node type
  7060. func (target *Node) UnmarshalBinary(data []byte) error {
  7061. var table []string
  7062. buff := util.NewBufferFromBytes(data)
  7063. // string table header validation
  7064. if isBinaryTag(data, BinaryTagStringTable) {
  7065. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  7066. tl := buff.ReadInt() // table length
  7067. if tl > 0 {
  7068. table = make([]string, tl, tl)
  7069. for i := 0; i < tl; i++ {
  7070. table[i] = buff.ReadString()
  7071. }
  7072. }
  7073. }
  7074. ctx := &DecodingContext{
  7075. Buffer: buff,
  7076. Table: table,
  7077. }
  7078. err := target.UnmarshalBinaryWithContext(ctx)
  7079. if err != nil {
  7080. return err
  7081. }
  7082. return nil
  7083. }
  7084. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7085. // the Node type
  7086. func (target *Node) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7087. // panics are recovered and propagated as errors
  7088. defer func() {
  7089. if r := recover(); r != nil {
  7090. if e, ok := r.(error); ok {
  7091. err = e
  7092. } else if s, ok := r.(string); ok {
  7093. err = fmt.Errorf("Unexpected panic: %s", s)
  7094. } else {
  7095. err = fmt.Errorf("Unexpected panic: %+v", r)
  7096. }
  7097. }
  7098. }()
  7099. buff := ctx.Buffer
  7100. version := buff.ReadUInt8()
  7101. if version > AssetsCodecVersion {
  7102. return fmt.Errorf("Invalid Version Unmarshaling Node. Expected %d or less, got %d", AssetsCodecVersion, version)
  7103. }
  7104. if buff.ReadUInt8() == uint8(0) {
  7105. target.Properties = nil
  7106. } else {
  7107. // --- [begin][read][struct](AssetProperties) ---
  7108. a := &AssetProperties{}
  7109. buff.ReadInt() // [compatibility, unused]
  7110. errA := a.UnmarshalBinaryWithContext(ctx)
  7111. if errA != nil {
  7112. return errA
  7113. }
  7114. target.Properties = a
  7115. // --- [end][read][struct](AssetProperties) ---
  7116. }
  7117. // --- [begin][read][alias](AssetLabels) ---
  7118. var b map[string]string
  7119. if buff.ReadUInt8() == uint8(0) {
  7120. b = nil
  7121. } else {
  7122. // --- [begin][read][map](map[string]string) ---
  7123. d := buff.ReadInt() // map len
  7124. c := make(map[string]string, d)
  7125. for i := 0; i < d; i++ {
  7126. var v string
  7127. var f string
  7128. if ctx.IsStringTable() {
  7129. g := buff.ReadInt() // read string index
  7130. f = ctx.Table[g]
  7131. } else {
  7132. f = buff.ReadString() // read string
  7133. }
  7134. e := f
  7135. v = e
  7136. var z string
  7137. var k string
  7138. if ctx.IsStringTable() {
  7139. l := buff.ReadInt() // read string index
  7140. k = ctx.Table[l]
  7141. } else {
  7142. k = buff.ReadString() // read string
  7143. }
  7144. h := k
  7145. z = h
  7146. c[v] = z
  7147. }
  7148. b = c
  7149. // --- [end][read][map](map[string]string) ---
  7150. }
  7151. target.Labels = AssetLabels(b)
  7152. // --- [end][read][alias](AssetLabels) ---
  7153. // --- [begin][read][reference](time.Time) ---
  7154. m := &time.Time{}
  7155. n := buff.ReadInt() // byte array length
  7156. o := buff.ReadBytes(n) // byte array
  7157. errB := m.UnmarshalBinary(o)
  7158. if errB != nil {
  7159. return errB
  7160. }
  7161. target.Start = *m
  7162. // --- [end][read][reference](time.Time) ---
  7163. // --- [begin][read][reference](time.Time) ---
  7164. p := &time.Time{}
  7165. q := buff.ReadInt() // byte array length
  7166. r := buff.ReadBytes(q) // byte array
  7167. errC := p.UnmarshalBinary(r)
  7168. if errC != nil {
  7169. return errC
  7170. }
  7171. target.End = *p
  7172. // --- [end][read][reference](time.Time) ---
  7173. // --- [begin][read][struct](Window) ---
  7174. s := &Window{}
  7175. buff.ReadInt() // [compatibility, unused]
  7176. errD := s.UnmarshalBinaryWithContext(ctx)
  7177. if errD != nil {
  7178. return errD
  7179. }
  7180. target.Window = *s
  7181. // --- [end][read][struct](Window) ---
  7182. t := buff.ReadFloat64() // read float64
  7183. target.Adjustment = t
  7184. var w string
  7185. if ctx.IsStringTable() {
  7186. x := buff.ReadInt() // read string index
  7187. w = ctx.Table[x]
  7188. } else {
  7189. w = buff.ReadString() // read string
  7190. }
  7191. u := w
  7192. target.NodeType = u
  7193. y := buff.ReadFloat64() // read float64
  7194. target.CPUCoreHours = y
  7195. aa := buff.ReadFloat64() // read float64
  7196. target.RAMByteHours = aa
  7197. bb := buff.ReadFloat64() // read float64
  7198. target.GPUHours = bb
  7199. if buff.ReadUInt8() == uint8(0) {
  7200. target.CPUBreakdown = nil
  7201. } else {
  7202. // --- [begin][read][struct](Breakdown) ---
  7203. cc := &Breakdown{}
  7204. buff.ReadInt() // [compatibility, unused]
  7205. errE := cc.UnmarshalBinaryWithContext(ctx)
  7206. if errE != nil {
  7207. return errE
  7208. }
  7209. target.CPUBreakdown = cc
  7210. // --- [end][read][struct](Breakdown) ---
  7211. }
  7212. if buff.ReadUInt8() == uint8(0) {
  7213. target.RAMBreakdown = nil
  7214. } else {
  7215. // --- [begin][read][struct](Breakdown) ---
  7216. dd := &Breakdown{}
  7217. buff.ReadInt() // [compatibility, unused]
  7218. errF := dd.UnmarshalBinaryWithContext(ctx)
  7219. if errF != nil {
  7220. return errF
  7221. }
  7222. target.RAMBreakdown = dd
  7223. // --- [end][read][struct](Breakdown) ---
  7224. }
  7225. ee := buff.ReadFloat64() // read float64
  7226. target.CPUCost = ee
  7227. ff := buff.ReadFloat64() // read float64
  7228. target.GPUCost = ff
  7229. gg := buff.ReadFloat64() // read float64
  7230. target.GPUCount = gg
  7231. hh := buff.ReadFloat64() // read float64
  7232. target.RAMCost = hh
  7233. kk := buff.ReadFloat64() // read float64
  7234. target.Discount = kk
  7235. ll := buff.ReadFloat64() // read float64
  7236. target.Preemptible = ll
  7237. // field version check
  7238. if uint8(19) <= version {
  7239. if buff.ReadUInt8() == uint8(0) {
  7240. target.Overhead = nil
  7241. } else {
  7242. // --- [begin][read][struct](NodeOverhead) ---
  7243. mm := &NodeOverhead{}
  7244. buff.ReadInt() // [compatibility, unused]
  7245. errG := mm.UnmarshalBinaryWithContext(ctx)
  7246. if errG != nil {
  7247. return errG
  7248. }
  7249. target.Overhead = mm
  7250. // --- [end][read][struct](NodeOverhead) ---
  7251. }
  7252. } else {
  7253. target.Overhead = nil
  7254. }
  7255. return nil
  7256. }
  7257. //--------------------------------------------------------------------------
  7258. // NodeOverhead
  7259. //--------------------------------------------------------------------------
  7260. // MarshalBinary serializes the internal properties of this NodeOverhead instance
  7261. // into a byte array
  7262. func (target *NodeOverhead) MarshalBinary() (data []byte, err error) {
  7263. ctx := &EncodingContext{
  7264. Buffer: util.NewBuffer(),
  7265. Table: nil,
  7266. }
  7267. e := target.MarshalBinaryWithContext(ctx)
  7268. if e != nil {
  7269. return nil, e
  7270. }
  7271. encBytes := ctx.Buffer.Bytes()
  7272. return encBytes, nil
  7273. }
  7274. // MarshalBinaryWithContext serializes the internal properties of this NodeOverhead instance
  7275. // into a byte array leveraging a predefined context.
  7276. func (target *NodeOverhead) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7277. // panics are recovered and propagated as errors
  7278. defer func() {
  7279. if r := recover(); r != nil {
  7280. if e, ok := r.(error); ok {
  7281. err = e
  7282. } else if s, ok := r.(string); ok {
  7283. err = fmt.Errorf("Unexpected panic: %s", s)
  7284. } else {
  7285. err = fmt.Errorf("Unexpected panic: %+v", r)
  7286. }
  7287. }
  7288. }()
  7289. buff := ctx.Buffer
  7290. buff.WriteUInt8(AssetsCodecVersion) // version
  7291. buff.WriteFloat64(target.CpuOverheadFraction) // write float64
  7292. buff.WriteFloat64(target.RamOverheadFraction) // write float64
  7293. buff.WriteFloat64(target.OverheadCostFraction) // write float64
  7294. return nil
  7295. }
  7296. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7297. // the NodeOverhead type
  7298. func (target *NodeOverhead) UnmarshalBinary(data []byte) error {
  7299. var table []string
  7300. buff := util.NewBufferFromBytes(data)
  7301. // string table header validation
  7302. if isBinaryTag(data, BinaryTagStringTable) {
  7303. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  7304. tl := buff.ReadInt() // table length
  7305. if tl > 0 {
  7306. table = make([]string, tl, tl)
  7307. for i := 0; i < tl; i++ {
  7308. table[i] = buff.ReadString()
  7309. }
  7310. }
  7311. }
  7312. ctx := &DecodingContext{
  7313. Buffer: buff,
  7314. Table: table,
  7315. }
  7316. err := target.UnmarshalBinaryWithContext(ctx)
  7317. if err != nil {
  7318. return err
  7319. }
  7320. return nil
  7321. }
  7322. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7323. // the NodeOverhead type
  7324. func (target *NodeOverhead) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7325. // panics are recovered and propagated as errors
  7326. defer func() {
  7327. if r := recover(); r != nil {
  7328. if e, ok := r.(error); ok {
  7329. err = e
  7330. } else if s, ok := r.(string); ok {
  7331. err = fmt.Errorf("Unexpected panic: %s", s)
  7332. } else {
  7333. err = fmt.Errorf("Unexpected panic: %+v", r)
  7334. }
  7335. }
  7336. }()
  7337. buff := ctx.Buffer
  7338. version := buff.ReadUInt8()
  7339. if version > AssetsCodecVersion {
  7340. return fmt.Errorf("Invalid Version Unmarshaling NodeOverhead. Expected %d or less, got %d", AssetsCodecVersion, version)
  7341. }
  7342. a := buff.ReadFloat64() // read float64
  7343. target.CpuOverheadFraction = a
  7344. b := buff.ReadFloat64() // read float64
  7345. target.RamOverheadFraction = b
  7346. c := buff.ReadFloat64() // read float64
  7347. target.OverheadCostFraction = c
  7348. return nil
  7349. }
  7350. //--------------------------------------------------------------------------
  7351. // PVAllocation
  7352. //--------------------------------------------------------------------------
  7353. // MarshalBinary serializes the internal properties of this PVAllocation instance
  7354. // into a byte array
  7355. func (target *PVAllocation) MarshalBinary() (data []byte, err error) {
  7356. ctx := &EncodingContext{
  7357. Buffer: util.NewBuffer(),
  7358. Table: nil,
  7359. }
  7360. e := target.MarshalBinaryWithContext(ctx)
  7361. if e != nil {
  7362. return nil, e
  7363. }
  7364. encBytes := ctx.Buffer.Bytes()
  7365. return encBytes, nil
  7366. }
  7367. // MarshalBinaryWithContext serializes the internal properties of this PVAllocation instance
  7368. // into a byte array leveraging a predefined context.
  7369. func (target *PVAllocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7370. // panics are recovered and propagated as errors
  7371. defer func() {
  7372. if r := recover(); r != nil {
  7373. if e, ok := r.(error); ok {
  7374. err = e
  7375. } else if s, ok := r.(string); ok {
  7376. err = fmt.Errorf("Unexpected panic: %s", s)
  7377. } else {
  7378. err = fmt.Errorf("Unexpected panic: %+v", r)
  7379. }
  7380. }
  7381. }()
  7382. buff := ctx.Buffer
  7383. buff.WriteUInt8(AllocationCodecVersion) // version
  7384. buff.WriteFloat64(target.ByteHours) // write float64
  7385. buff.WriteFloat64(target.Cost) // write float64
  7386. return nil
  7387. }
  7388. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7389. // the PVAllocation type
  7390. func (target *PVAllocation) UnmarshalBinary(data []byte) error {
  7391. var table []string
  7392. buff := util.NewBufferFromBytes(data)
  7393. // string table header validation
  7394. if isBinaryTag(data, BinaryTagStringTable) {
  7395. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  7396. tl := buff.ReadInt() // table length
  7397. if tl > 0 {
  7398. table = make([]string, tl, tl)
  7399. for i := 0; i < tl; i++ {
  7400. table[i] = buff.ReadString()
  7401. }
  7402. }
  7403. }
  7404. ctx := &DecodingContext{
  7405. Buffer: buff,
  7406. Table: table,
  7407. }
  7408. err := target.UnmarshalBinaryWithContext(ctx)
  7409. if err != nil {
  7410. return err
  7411. }
  7412. return nil
  7413. }
  7414. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7415. // the PVAllocation type
  7416. func (target *PVAllocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7417. // panics are recovered and propagated as errors
  7418. defer func() {
  7419. if r := recover(); r != nil {
  7420. if e, ok := r.(error); ok {
  7421. err = e
  7422. } else if s, ok := r.(string); ok {
  7423. err = fmt.Errorf("Unexpected panic: %s", s)
  7424. } else {
  7425. err = fmt.Errorf("Unexpected panic: %+v", r)
  7426. }
  7427. }
  7428. }()
  7429. buff := ctx.Buffer
  7430. version := buff.ReadUInt8()
  7431. if version > AllocationCodecVersion {
  7432. return fmt.Errorf("Invalid Version Unmarshaling PVAllocation. Expected %d or less, got %d", AllocationCodecVersion, version)
  7433. }
  7434. a := buff.ReadFloat64() // read float64
  7435. target.ByteHours = a
  7436. b := buff.ReadFloat64() // read float64
  7437. target.Cost = b
  7438. return nil
  7439. }
  7440. //--------------------------------------------------------------------------
  7441. // PVKey
  7442. //--------------------------------------------------------------------------
  7443. // MarshalBinary serializes the internal properties of this PVKey instance
  7444. // into a byte array
  7445. func (target *PVKey) MarshalBinary() (data []byte, err error) {
  7446. ctx := &EncodingContext{
  7447. Buffer: util.NewBuffer(),
  7448. Table: nil,
  7449. }
  7450. e := target.MarshalBinaryWithContext(ctx)
  7451. if e != nil {
  7452. return nil, e
  7453. }
  7454. encBytes := ctx.Buffer.Bytes()
  7455. return encBytes, nil
  7456. }
  7457. // MarshalBinaryWithContext serializes the internal properties of this PVKey instance
  7458. // into a byte array leveraging a predefined context.
  7459. func (target *PVKey) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7460. // panics are recovered and propagated as errors
  7461. defer func() {
  7462. if r := recover(); r != nil {
  7463. if e, ok := r.(error); ok {
  7464. err = e
  7465. } else if s, ok := r.(string); ok {
  7466. err = fmt.Errorf("Unexpected panic: %s", s)
  7467. } else {
  7468. err = fmt.Errorf("Unexpected panic: %+v", r)
  7469. }
  7470. }
  7471. }()
  7472. buff := ctx.Buffer
  7473. buff.WriteUInt8(AllocationCodecVersion) // version
  7474. if ctx.IsStringTable() {
  7475. a := ctx.Table.AddOrGet(target.Cluster)
  7476. buff.WriteInt(a) // write table index
  7477. } else {
  7478. buff.WriteString(target.Cluster) // write string
  7479. }
  7480. if ctx.IsStringTable() {
  7481. b := ctx.Table.AddOrGet(target.Name)
  7482. buff.WriteInt(b) // write table index
  7483. } else {
  7484. buff.WriteString(target.Name) // write string
  7485. }
  7486. return nil
  7487. }
  7488. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7489. // the PVKey type
  7490. func (target *PVKey) UnmarshalBinary(data []byte) error {
  7491. var table []string
  7492. buff := util.NewBufferFromBytes(data)
  7493. // string table header validation
  7494. if isBinaryTag(data, BinaryTagStringTable) {
  7495. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  7496. tl := buff.ReadInt() // table length
  7497. if tl > 0 {
  7498. table = make([]string, tl, tl)
  7499. for i := 0; i < tl; i++ {
  7500. table[i] = buff.ReadString()
  7501. }
  7502. }
  7503. }
  7504. ctx := &DecodingContext{
  7505. Buffer: buff,
  7506. Table: table,
  7507. }
  7508. err := target.UnmarshalBinaryWithContext(ctx)
  7509. if err != nil {
  7510. return err
  7511. }
  7512. return nil
  7513. }
  7514. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7515. // the PVKey type
  7516. func (target *PVKey) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7517. // panics are recovered and propagated as errors
  7518. defer func() {
  7519. if r := recover(); r != nil {
  7520. if e, ok := r.(error); ok {
  7521. err = e
  7522. } else if s, ok := r.(string); ok {
  7523. err = fmt.Errorf("Unexpected panic: %s", s)
  7524. } else {
  7525. err = fmt.Errorf("Unexpected panic: %+v", r)
  7526. }
  7527. }
  7528. }()
  7529. buff := ctx.Buffer
  7530. version := buff.ReadUInt8()
  7531. if version > AllocationCodecVersion {
  7532. return fmt.Errorf("Invalid Version Unmarshaling PVKey. Expected %d or less, got %d", AllocationCodecVersion, version)
  7533. }
  7534. var b string
  7535. if ctx.IsStringTable() {
  7536. c := buff.ReadInt() // read string index
  7537. b = ctx.Table[c]
  7538. } else {
  7539. b = buff.ReadString() // read string
  7540. }
  7541. a := b
  7542. target.Cluster = a
  7543. var e string
  7544. if ctx.IsStringTable() {
  7545. f := buff.ReadInt() // read string index
  7546. e = ctx.Table[f]
  7547. } else {
  7548. e = buff.ReadString() // read string
  7549. }
  7550. d := e
  7551. target.Name = d
  7552. return nil
  7553. }
  7554. //--------------------------------------------------------------------------
  7555. // RawAllocationOnlyData
  7556. //--------------------------------------------------------------------------
  7557. // MarshalBinary serializes the internal properties of this RawAllocationOnlyData instance
  7558. // into a byte array
  7559. func (target *RawAllocationOnlyData) MarshalBinary() (data []byte, err error) {
  7560. ctx := &EncodingContext{
  7561. Buffer: util.NewBuffer(),
  7562. Table: nil,
  7563. }
  7564. e := target.MarshalBinaryWithContext(ctx)
  7565. if e != nil {
  7566. return nil, e
  7567. }
  7568. encBytes := ctx.Buffer.Bytes()
  7569. return encBytes, nil
  7570. }
  7571. // MarshalBinaryWithContext serializes the internal properties of this RawAllocationOnlyData instance
  7572. // into a byte array leveraging a predefined context.
  7573. func (target *RawAllocationOnlyData) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7574. // panics are recovered and propagated as errors
  7575. defer func() {
  7576. if r := recover(); r != nil {
  7577. if e, ok := r.(error); ok {
  7578. err = e
  7579. } else if s, ok := r.(string); ok {
  7580. err = fmt.Errorf("Unexpected panic: %s", s)
  7581. } else {
  7582. err = fmt.Errorf("Unexpected panic: %+v", r)
  7583. }
  7584. }
  7585. }()
  7586. buff := ctx.Buffer
  7587. buff.WriteUInt8(AllocationCodecVersion) // version
  7588. buff.WriteFloat64(target.CPUCoreUsageMax) // write float64
  7589. buff.WriteFloat64(target.RAMBytesUsageMax) // write float64
  7590. return nil
  7591. }
  7592. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7593. // the RawAllocationOnlyData type
  7594. func (target *RawAllocationOnlyData) UnmarshalBinary(data []byte) error {
  7595. var table []string
  7596. buff := util.NewBufferFromBytes(data)
  7597. // string table header validation
  7598. if isBinaryTag(data, BinaryTagStringTable) {
  7599. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  7600. tl := buff.ReadInt() // table length
  7601. if tl > 0 {
  7602. table = make([]string, tl, tl)
  7603. for i := 0; i < tl; i++ {
  7604. table[i] = buff.ReadString()
  7605. }
  7606. }
  7607. }
  7608. ctx := &DecodingContext{
  7609. Buffer: buff,
  7610. Table: table,
  7611. }
  7612. err := target.UnmarshalBinaryWithContext(ctx)
  7613. if err != nil {
  7614. return err
  7615. }
  7616. return nil
  7617. }
  7618. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7619. // the RawAllocationOnlyData type
  7620. func (target *RawAllocationOnlyData) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7621. // panics are recovered and propagated as errors
  7622. defer func() {
  7623. if r := recover(); r != nil {
  7624. if e, ok := r.(error); ok {
  7625. err = e
  7626. } else if s, ok := r.(string); ok {
  7627. err = fmt.Errorf("Unexpected panic: %s", s)
  7628. } else {
  7629. err = fmt.Errorf("Unexpected panic: %+v", r)
  7630. }
  7631. }
  7632. }()
  7633. buff := ctx.Buffer
  7634. version := buff.ReadUInt8()
  7635. if version > AllocationCodecVersion {
  7636. return fmt.Errorf("Invalid Version Unmarshaling RawAllocationOnlyData. Expected %d or less, got %d", AllocationCodecVersion, version)
  7637. }
  7638. a := buff.ReadFloat64() // read float64
  7639. target.CPUCoreUsageMax = a
  7640. b := buff.ReadFloat64() // read float64
  7641. target.RAMBytesUsageMax = b
  7642. return nil
  7643. }
  7644. //--------------------------------------------------------------------------
  7645. // SharedAsset
  7646. //--------------------------------------------------------------------------
  7647. // MarshalBinary serializes the internal properties of this SharedAsset instance
  7648. // into a byte array
  7649. func (target *SharedAsset) MarshalBinary() (data []byte, err error) {
  7650. ctx := &EncodingContext{
  7651. Buffer: util.NewBuffer(),
  7652. Table: nil,
  7653. }
  7654. e := target.MarshalBinaryWithContext(ctx)
  7655. if e != nil {
  7656. return nil, e
  7657. }
  7658. encBytes := ctx.Buffer.Bytes()
  7659. return encBytes, nil
  7660. }
  7661. // MarshalBinaryWithContext serializes the internal properties of this SharedAsset instance
  7662. // into a byte array leveraging a predefined context.
  7663. func (target *SharedAsset) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7664. // panics are recovered and propagated as errors
  7665. defer func() {
  7666. if r := recover(); r != nil {
  7667. if e, ok := r.(error); ok {
  7668. err = e
  7669. } else if s, ok := r.(string); ok {
  7670. err = fmt.Errorf("Unexpected panic: %s", s)
  7671. } else {
  7672. err = fmt.Errorf("Unexpected panic: %+v", r)
  7673. }
  7674. }
  7675. }()
  7676. buff := ctx.Buffer
  7677. buff.WriteUInt8(AssetsCodecVersion) // version
  7678. if target.Properties == nil {
  7679. buff.WriteUInt8(uint8(0)) // write nil byte
  7680. } else {
  7681. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7682. // --- [begin][write][struct](AssetProperties) ---
  7683. buff.WriteInt(0) // [compatibility, unused]
  7684. errA := target.Properties.MarshalBinaryWithContext(ctx)
  7685. if errA != nil {
  7686. return errA
  7687. }
  7688. // --- [end][write][struct](AssetProperties) ---
  7689. }
  7690. // --- [begin][write][alias](AssetLabels) ---
  7691. if map[string]string(target.Labels) == nil {
  7692. buff.WriteUInt8(uint8(0)) // write nil byte
  7693. } else {
  7694. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7695. // --- [begin][write][map](map[string]string) ---
  7696. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  7697. for v, z := range map[string]string(target.Labels) {
  7698. if ctx.IsStringTable() {
  7699. a := ctx.Table.AddOrGet(v)
  7700. buff.WriteInt(a) // write table index
  7701. } else {
  7702. buff.WriteString(v) // write string
  7703. }
  7704. if ctx.IsStringTable() {
  7705. b := ctx.Table.AddOrGet(z)
  7706. buff.WriteInt(b) // write table index
  7707. } else {
  7708. buff.WriteString(z) // write string
  7709. }
  7710. }
  7711. // --- [end][write][map](map[string]string) ---
  7712. }
  7713. // --- [end][write][alias](AssetLabels) ---
  7714. // --- [begin][write][struct](Window) ---
  7715. buff.WriteInt(0) // [compatibility, unused]
  7716. errB := target.Window.MarshalBinaryWithContext(ctx)
  7717. if errB != nil {
  7718. return errB
  7719. }
  7720. // --- [end][write][struct](Window) ---
  7721. buff.WriteFloat64(target.Cost) // write float64
  7722. return nil
  7723. }
  7724. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7725. // the SharedAsset type
  7726. func (target *SharedAsset) UnmarshalBinary(data []byte) error {
  7727. var table []string
  7728. buff := util.NewBufferFromBytes(data)
  7729. // string table header validation
  7730. if isBinaryTag(data, BinaryTagStringTable) {
  7731. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  7732. tl := buff.ReadInt() // table length
  7733. if tl > 0 {
  7734. table = make([]string, tl, tl)
  7735. for i := 0; i < tl; i++ {
  7736. table[i] = buff.ReadString()
  7737. }
  7738. }
  7739. }
  7740. ctx := &DecodingContext{
  7741. Buffer: buff,
  7742. Table: table,
  7743. }
  7744. err := target.UnmarshalBinaryWithContext(ctx)
  7745. if err != nil {
  7746. return err
  7747. }
  7748. return nil
  7749. }
  7750. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7751. // the SharedAsset type
  7752. func (target *SharedAsset) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7753. // panics are recovered and propagated as errors
  7754. defer func() {
  7755. if r := recover(); r != nil {
  7756. if e, ok := r.(error); ok {
  7757. err = e
  7758. } else if s, ok := r.(string); ok {
  7759. err = fmt.Errorf("Unexpected panic: %s", s)
  7760. } else {
  7761. err = fmt.Errorf("Unexpected panic: %+v", r)
  7762. }
  7763. }
  7764. }()
  7765. buff := ctx.Buffer
  7766. version := buff.ReadUInt8()
  7767. if version > AssetsCodecVersion {
  7768. return fmt.Errorf("Invalid Version Unmarshaling SharedAsset. Expected %d or less, got %d", AssetsCodecVersion, version)
  7769. }
  7770. if buff.ReadUInt8() == uint8(0) {
  7771. target.Properties = nil
  7772. } else {
  7773. // --- [begin][read][struct](AssetProperties) ---
  7774. a := &AssetProperties{}
  7775. buff.ReadInt() // [compatibility, unused]
  7776. errA := a.UnmarshalBinaryWithContext(ctx)
  7777. if errA != nil {
  7778. return errA
  7779. }
  7780. target.Properties = a
  7781. // --- [end][read][struct](AssetProperties) ---
  7782. }
  7783. // --- [begin][read][alias](AssetLabels) ---
  7784. var b map[string]string
  7785. if buff.ReadUInt8() == uint8(0) {
  7786. b = nil
  7787. } else {
  7788. // --- [begin][read][map](map[string]string) ---
  7789. d := buff.ReadInt() // map len
  7790. c := make(map[string]string, d)
  7791. for i := 0; i < d; i++ {
  7792. var v string
  7793. var f string
  7794. if ctx.IsStringTable() {
  7795. g := buff.ReadInt() // read string index
  7796. f = ctx.Table[g]
  7797. } else {
  7798. f = buff.ReadString() // read string
  7799. }
  7800. e := f
  7801. v = e
  7802. var z string
  7803. var k string
  7804. if ctx.IsStringTable() {
  7805. l := buff.ReadInt() // read string index
  7806. k = ctx.Table[l]
  7807. } else {
  7808. k = buff.ReadString() // read string
  7809. }
  7810. h := k
  7811. z = h
  7812. c[v] = z
  7813. }
  7814. b = c
  7815. // --- [end][read][map](map[string]string) ---
  7816. }
  7817. target.Labels = AssetLabels(b)
  7818. // --- [end][read][alias](AssetLabels) ---
  7819. // --- [begin][read][struct](Window) ---
  7820. m := &Window{}
  7821. buff.ReadInt() // [compatibility, unused]
  7822. errB := m.UnmarshalBinaryWithContext(ctx)
  7823. if errB != nil {
  7824. return errB
  7825. }
  7826. target.Window = *m
  7827. // --- [end][read][struct](Window) ---
  7828. n := buff.ReadFloat64() // read float64
  7829. target.Cost = n
  7830. return nil
  7831. }
  7832. //--------------------------------------------------------------------------
  7833. // TotalAudit
  7834. //--------------------------------------------------------------------------
  7835. // MarshalBinary serializes the internal properties of this TotalAudit instance
  7836. // into a byte array
  7837. func (target *TotalAudit) MarshalBinary() (data []byte, err error) {
  7838. ctx := &EncodingContext{
  7839. Buffer: util.NewBuffer(),
  7840. Table: nil,
  7841. }
  7842. e := target.MarshalBinaryWithContext(ctx)
  7843. if e != nil {
  7844. return nil, e
  7845. }
  7846. encBytes := ctx.Buffer.Bytes()
  7847. return encBytes, nil
  7848. }
  7849. // MarshalBinaryWithContext serializes the internal properties of this TotalAudit instance
  7850. // into a byte array leveraging a predefined context.
  7851. func (target *TotalAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7852. // panics are recovered and propagated as errors
  7853. defer func() {
  7854. if r := recover(); r != nil {
  7855. if e, ok := r.(error); ok {
  7856. err = e
  7857. } else if s, ok := r.(string); ok {
  7858. err = fmt.Errorf("Unexpected panic: %s", s)
  7859. } else {
  7860. err = fmt.Errorf("Unexpected panic: %+v", r)
  7861. }
  7862. }
  7863. }()
  7864. buff := ctx.Buffer
  7865. buff.WriteUInt8(AuditCodecVersion) // version
  7866. // --- [begin][write][alias](AuditStatus) ---
  7867. if ctx.IsStringTable() {
  7868. a := ctx.Table.AddOrGet(string(target.Status))
  7869. buff.WriteInt(a) // write table index
  7870. } else {
  7871. buff.WriteString(string(target.Status)) // write string
  7872. }
  7873. // --- [end][write][alias](AuditStatus) ---
  7874. if ctx.IsStringTable() {
  7875. b := ctx.Table.AddOrGet(target.Description)
  7876. buff.WriteInt(b) // write table index
  7877. } else {
  7878. buff.WriteString(target.Description) // write string
  7879. }
  7880. // --- [begin][write][reference](time.Time) ---
  7881. c, errA := target.LastRun.MarshalBinary()
  7882. if errA != nil {
  7883. return errA
  7884. }
  7885. buff.WriteInt(len(c))
  7886. buff.WriteBytes(c)
  7887. // --- [end][write][reference](time.Time) ---
  7888. if target.TotalByNode == nil {
  7889. buff.WriteUInt8(uint8(0)) // write nil byte
  7890. } else {
  7891. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7892. // --- [begin][write][map](map[string]*AuditFloatResult) ---
  7893. buff.WriteInt(len(target.TotalByNode)) // map length
  7894. for v, z := range target.TotalByNode {
  7895. if ctx.IsStringTable() {
  7896. d := ctx.Table.AddOrGet(v)
  7897. buff.WriteInt(d) // write table index
  7898. } else {
  7899. buff.WriteString(v) // write string
  7900. }
  7901. if z == nil {
  7902. buff.WriteUInt8(uint8(0)) // write nil byte
  7903. } else {
  7904. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7905. // --- [begin][write][struct](AuditFloatResult) ---
  7906. buff.WriteInt(0) // [compatibility, unused]
  7907. errB := z.MarshalBinaryWithContext(ctx)
  7908. if errB != nil {
  7909. return errB
  7910. }
  7911. // --- [end][write][struct](AuditFloatResult) ---
  7912. }
  7913. }
  7914. // --- [end][write][map](map[string]*AuditFloatResult) ---
  7915. }
  7916. if target.TotalByCluster == nil {
  7917. buff.WriteUInt8(uint8(0)) // write nil byte
  7918. } else {
  7919. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7920. // --- [begin][write][map](map[string]*AuditFloatResult) ---
  7921. buff.WriteInt(len(target.TotalByCluster)) // map length
  7922. for vv, zz := range target.TotalByCluster {
  7923. if ctx.IsStringTable() {
  7924. e := ctx.Table.AddOrGet(vv)
  7925. buff.WriteInt(e) // write table index
  7926. } else {
  7927. buff.WriteString(vv) // write string
  7928. }
  7929. if zz == nil {
  7930. buff.WriteUInt8(uint8(0)) // write nil byte
  7931. } else {
  7932. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7933. // --- [begin][write][struct](AuditFloatResult) ---
  7934. buff.WriteInt(0) // [compatibility, unused]
  7935. errC := zz.MarshalBinaryWithContext(ctx)
  7936. if errC != nil {
  7937. return errC
  7938. }
  7939. // --- [end][write][struct](AuditFloatResult) ---
  7940. }
  7941. }
  7942. // --- [end][write][map](map[string]*AuditFloatResult) ---
  7943. }
  7944. if target.MissingValues == nil {
  7945. buff.WriteUInt8(uint8(0)) // write nil byte
  7946. } else {
  7947. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7948. // --- [begin][write][slice]([]*AuditMissingValue) ---
  7949. buff.WriteInt(len(target.MissingValues)) // array length
  7950. for i := 0; i < len(target.MissingValues); i++ {
  7951. if target.MissingValues[i] == nil {
  7952. buff.WriteUInt8(uint8(0)) // write nil byte
  7953. } else {
  7954. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7955. // --- [begin][write][struct](AuditMissingValue) ---
  7956. buff.WriteInt(0) // [compatibility, unused]
  7957. errD := target.MissingValues[i].MarshalBinaryWithContext(ctx)
  7958. if errD != nil {
  7959. return errD
  7960. }
  7961. // --- [end][write][struct](AuditMissingValue) ---
  7962. }
  7963. }
  7964. // --- [end][write][slice]([]*AuditMissingValue) ---
  7965. }
  7966. return nil
  7967. }
  7968. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7969. // the TotalAudit type
  7970. func (target *TotalAudit) UnmarshalBinary(data []byte) error {
  7971. var table []string
  7972. buff := util.NewBufferFromBytes(data)
  7973. // string table header validation
  7974. if isBinaryTag(data, BinaryTagStringTable) {
  7975. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  7976. tl := buff.ReadInt() // table length
  7977. if tl > 0 {
  7978. table = make([]string, tl, tl)
  7979. for i := 0; i < tl; i++ {
  7980. table[i] = buff.ReadString()
  7981. }
  7982. }
  7983. }
  7984. ctx := &DecodingContext{
  7985. Buffer: buff,
  7986. Table: table,
  7987. }
  7988. err := target.UnmarshalBinaryWithContext(ctx)
  7989. if err != nil {
  7990. return err
  7991. }
  7992. return nil
  7993. }
  7994. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7995. // the TotalAudit type
  7996. func (target *TotalAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7997. // panics are recovered and propagated as errors
  7998. defer func() {
  7999. if r := recover(); r != nil {
  8000. if e, ok := r.(error); ok {
  8001. err = e
  8002. } else if s, ok := r.(string); ok {
  8003. err = fmt.Errorf("Unexpected panic: %s", s)
  8004. } else {
  8005. err = fmt.Errorf("Unexpected panic: %+v", r)
  8006. }
  8007. }
  8008. }()
  8009. buff := ctx.Buffer
  8010. version := buff.ReadUInt8()
  8011. if version > AuditCodecVersion {
  8012. return fmt.Errorf("Invalid Version Unmarshaling TotalAudit. Expected %d or less, got %d", AuditCodecVersion, version)
  8013. }
  8014. // --- [begin][read][alias](AuditStatus) ---
  8015. var a string
  8016. var c string
  8017. if ctx.IsStringTable() {
  8018. d := buff.ReadInt() // read string index
  8019. c = ctx.Table[d]
  8020. } else {
  8021. c = buff.ReadString() // read string
  8022. }
  8023. b := c
  8024. a = b
  8025. target.Status = AuditStatus(a)
  8026. // --- [end][read][alias](AuditStatus) ---
  8027. var f string
  8028. if ctx.IsStringTable() {
  8029. g := buff.ReadInt() // read string index
  8030. f = ctx.Table[g]
  8031. } else {
  8032. f = buff.ReadString() // read string
  8033. }
  8034. e := f
  8035. target.Description = e
  8036. // --- [begin][read][reference](time.Time) ---
  8037. h := &time.Time{}
  8038. k := buff.ReadInt() // byte array length
  8039. l := buff.ReadBytes(k) // byte array
  8040. errA := h.UnmarshalBinary(l)
  8041. if errA != nil {
  8042. return errA
  8043. }
  8044. target.LastRun = *h
  8045. // --- [end][read][reference](time.Time) ---
  8046. if buff.ReadUInt8() == uint8(0) {
  8047. target.TotalByNode = nil
  8048. } else {
  8049. // --- [begin][read][map](map[string]*AuditFloatResult) ---
  8050. n := buff.ReadInt() // map len
  8051. m := make(map[string]*AuditFloatResult, n)
  8052. for i := 0; i < n; i++ {
  8053. var v string
  8054. var p string
  8055. if ctx.IsStringTable() {
  8056. q := buff.ReadInt() // read string index
  8057. p = ctx.Table[q]
  8058. } else {
  8059. p = buff.ReadString() // read string
  8060. }
  8061. o := p
  8062. v = o
  8063. var z *AuditFloatResult
  8064. if buff.ReadUInt8() == uint8(0) {
  8065. z = nil
  8066. } else {
  8067. // --- [begin][read][struct](AuditFloatResult) ---
  8068. r := &AuditFloatResult{}
  8069. buff.ReadInt() // [compatibility, unused]
  8070. errB := r.UnmarshalBinaryWithContext(ctx)
  8071. if errB != nil {
  8072. return errB
  8073. }
  8074. z = r
  8075. // --- [end][read][struct](AuditFloatResult) ---
  8076. }
  8077. m[v] = z
  8078. }
  8079. target.TotalByNode = m
  8080. // --- [end][read][map](map[string]*AuditFloatResult) ---
  8081. }
  8082. if buff.ReadUInt8() == uint8(0) {
  8083. target.TotalByCluster = nil
  8084. } else {
  8085. // --- [begin][read][map](map[string]*AuditFloatResult) ---
  8086. t := buff.ReadInt() // map len
  8087. s := make(map[string]*AuditFloatResult, t)
  8088. for j := 0; j < t; j++ {
  8089. var vv string
  8090. var w string
  8091. if ctx.IsStringTable() {
  8092. x := buff.ReadInt() // read string index
  8093. w = ctx.Table[x]
  8094. } else {
  8095. w = buff.ReadString() // read string
  8096. }
  8097. u := w
  8098. vv = u
  8099. var zz *AuditFloatResult
  8100. if buff.ReadUInt8() == uint8(0) {
  8101. zz = nil
  8102. } else {
  8103. // --- [begin][read][struct](AuditFloatResult) ---
  8104. y := &AuditFloatResult{}
  8105. buff.ReadInt() // [compatibility, unused]
  8106. errC := y.UnmarshalBinaryWithContext(ctx)
  8107. if errC != nil {
  8108. return errC
  8109. }
  8110. zz = y
  8111. // --- [end][read][struct](AuditFloatResult) ---
  8112. }
  8113. s[vv] = zz
  8114. }
  8115. target.TotalByCluster = s
  8116. // --- [end][read][map](map[string]*AuditFloatResult) ---
  8117. }
  8118. if buff.ReadUInt8() == uint8(0) {
  8119. target.MissingValues = nil
  8120. } else {
  8121. // --- [begin][read][slice]([]*AuditMissingValue) ---
  8122. bb := buff.ReadInt() // array len
  8123. aa := make([]*AuditMissingValue, bb)
  8124. for ii := 0; ii < bb; ii++ {
  8125. var cc *AuditMissingValue
  8126. if buff.ReadUInt8() == uint8(0) {
  8127. cc = nil
  8128. } else {
  8129. // --- [begin][read][struct](AuditMissingValue) ---
  8130. dd := &AuditMissingValue{}
  8131. buff.ReadInt() // [compatibility, unused]
  8132. errD := dd.UnmarshalBinaryWithContext(ctx)
  8133. if errD != nil {
  8134. return errD
  8135. }
  8136. cc = dd
  8137. // --- [end][read][struct](AuditMissingValue) ---
  8138. }
  8139. aa[ii] = cc
  8140. }
  8141. target.MissingValues = aa
  8142. // --- [end][read][slice]([]*AuditMissingValue) ---
  8143. }
  8144. return nil
  8145. }
  8146. //--------------------------------------------------------------------------
  8147. // Window
  8148. //--------------------------------------------------------------------------
  8149. // MarshalBinary serializes the internal properties of this Window instance
  8150. // into a byte array
  8151. func (target *Window) MarshalBinary() (data []byte, err error) {
  8152. ctx := &EncodingContext{
  8153. Buffer: util.NewBuffer(),
  8154. Table: nil,
  8155. }
  8156. e := target.MarshalBinaryWithContext(ctx)
  8157. if e != nil {
  8158. return nil, e
  8159. }
  8160. encBytes := ctx.Buffer.Bytes()
  8161. return encBytes, nil
  8162. }
  8163. // MarshalBinaryWithContext serializes the internal properties of this Window instance
  8164. // into a byte array leveraging a predefined context.
  8165. func (target *Window) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  8166. // panics are recovered and propagated as errors
  8167. defer func() {
  8168. if r := recover(); r != nil {
  8169. if e, ok := r.(error); ok {
  8170. err = e
  8171. } else if s, ok := r.(string); ok {
  8172. err = fmt.Errorf("Unexpected panic: %s", s)
  8173. } else {
  8174. err = fmt.Errorf("Unexpected panic: %+v", r)
  8175. }
  8176. }
  8177. }()
  8178. buff := ctx.Buffer
  8179. buff.WriteUInt8(DefaultCodecVersion) // version
  8180. if target.start == nil {
  8181. buff.WriteUInt8(uint8(0)) // write nil byte
  8182. } else {
  8183. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8184. // --- [begin][write][reference](time.Time) ---
  8185. a, errA := target.start.MarshalBinary()
  8186. if errA != nil {
  8187. return errA
  8188. }
  8189. buff.WriteInt(len(a))
  8190. buff.WriteBytes(a)
  8191. // --- [end][write][reference](time.Time) ---
  8192. }
  8193. if target.end == nil {
  8194. buff.WriteUInt8(uint8(0)) // write nil byte
  8195. } else {
  8196. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8197. // --- [begin][write][reference](time.Time) ---
  8198. b, errB := target.end.MarshalBinary()
  8199. if errB != nil {
  8200. return errB
  8201. }
  8202. buff.WriteInt(len(b))
  8203. buff.WriteBytes(b)
  8204. // --- [end][write][reference](time.Time) ---
  8205. }
  8206. return nil
  8207. }
  8208. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  8209. // the Window type
  8210. func (target *Window) UnmarshalBinary(data []byte) error {
  8211. var table []string
  8212. buff := util.NewBufferFromBytes(data)
  8213. // string table header validation
  8214. if isBinaryTag(data, BinaryTagStringTable) {
  8215. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  8216. tl := buff.ReadInt() // table length
  8217. if tl > 0 {
  8218. table = make([]string, tl, tl)
  8219. for i := 0; i < tl; i++ {
  8220. table[i] = buff.ReadString()
  8221. }
  8222. }
  8223. }
  8224. ctx := &DecodingContext{
  8225. Buffer: buff,
  8226. Table: table,
  8227. }
  8228. err := target.UnmarshalBinaryWithContext(ctx)
  8229. if err != nil {
  8230. return err
  8231. }
  8232. return nil
  8233. }
  8234. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  8235. // the Window type
  8236. func (target *Window) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  8237. // panics are recovered and propagated as errors
  8238. defer func() {
  8239. if r := recover(); r != nil {
  8240. if e, ok := r.(error); ok {
  8241. err = e
  8242. } else if s, ok := r.(string); ok {
  8243. err = fmt.Errorf("Unexpected panic: %s", s)
  8244. } else {
  8245. err = fmt.Errorf("Unexpected panic: %+v", r)
  8246. }
  8247. }
  8248. }()
  8249. buff := ctx.Buffer
  8250. version := buff.ReadUInt8()
  8251. if version > DefaultCodecVersion {
  8252. return fmt.Errorf("Invalid Version Unmarshaling Window. Expected %d or less, got %d", DefaultCodecVersion, version)
  8253. }
  8254. if buff.ReadUInt8() == uint8(0) {
  8255. target.start = nil
  8256. } else {
  8257. // --- [begin][read][reference](time.Time) ---
  8258. a := &time.Time{}
  8259. b := buff.ReadInt() // byte array length
  8260. c := buff.ReadBytes(b) // byte array
  8261. errA := a.UnmarshalBinary(c)
  8262. if errA != nil {
  8263. return errA
  8264. }
  8265. target.start = a
  8266. // --- [end][read][reference](time.Time) ---
  8267. }
  8268. if buff.ReadUInt8() == uint8(0) {
  8269. target.end = nil
  8270. } else {
  8271. // --- [begin][read][reference](time.Time) ---
  8272. d := &time.Time{}
  8273. e := buff.ReadInt() // byte array length
  8274. f := buff.ReadBytes(e) // byte array
  8275. errB := d.UnmarshalBinary(f)
  8276. if errB != nil {
  8277. return errB
  8278. }
  8279. target.end = d
  8280. // --- [end][read][reference](time.Time) ---
  8281. }
  8282. return nil
  8283. }