kubecost_codecs.go 193 KB

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