kubecost_codecs.go 193 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528
  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. if target.ByteHoursUsed == nil {
  4340. buff.WriteUInt8(uint8(0)) // write nil byte
  4341. } else {
  4342. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4343. buff.WriteFloat64(*target.ByteHoursUsed) // write float64
  4344. }
  4345. if target.ByteUsageMax == nil {
  4346. buff.WriteUInt8(uint8(0)) // write nil byte
  4347. } else {
  4348. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4349. buff.WriteFloat64(*target.ByteUsageMax) // write float64
  4350. }
  4351. if ctx.IsStringTable() {
  4352. f := ctx.Table.AddOrGet(target.VolumeName)
  4353. buff.WriteInt(f) // write table index
  4354. } else {
  4355. buff.WriteString(target.VolumeName) // write string
  4356. }
  4357. if ctx.IsStringTable() {
  4358. g := ctx.Table.AddOrGet(target.ClaimName)
  4359. buff.WriteInt(g) // write table index
  4360. } else {
  4361. buff.WriteString(target.ClaimName) // write string
  4362. }
  4363. if ctx.IsStringTable() {
  4364. h := ctx.Table.AddOrGet(target.ClaimNamespace)
  4365. buff.WriteInt(h) // write table index
  4366. } else {
  4367. buff.WriteString(target.ClaimNamespace) // write string
  4368. }
  4369. return nil
  4370. }
  4371. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4372. // the Disk type
  4373. func (target *Disk) UnmarshalBinary(data []byte) error {
  4374. var table []string
  4375. buff := util.NewBufferFromBytes(data)
  4376. // string table header validation
  4377. if isBinaryTag(data, BinaryTagStringTable) {
  4378. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4379. tl := buff.ReadInt() // table length
  4380. if tl > 0 {
  4381. table = make([]string, tl, tl)
  4382. for i := 0; i < tl; i++ {
  4383. table[i] = buff.ReadString()
  4384. }
  4385. }
  4386. }
  4387. ctx := &DecodingContext{
  4388. Buffer: buff,
  4389. Table: table,
  4390. }
  4391. err := target.UnmarshalBinaryWithContext(ctx)
  4392. if err != nil {
  4393. return err
  4394. }
  4395. return nil
  4396. }
  4397. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4398. // the Disk type
  4399. func (target *Disk) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4400. // panics are recovered and propagated as errors
  4401. defer func() {
  4402. if r := recover(); r != nil {
  4403. if e, ok := r.(error); ok {
  4404. err = e
  4405. } else if s, ok := r.(string); ok {
  4406. err = fmt.Errorf("Unexpected panic: %s", s)
  4407. } else {
  4408. err = fmt.Errorf("Unexpected panic: %+v", r)
  4409. }
  4410. }
  4411. }()
  4412. buff := ctx.Buffer
  4413. version := buff.ReadUInt8()
  4414. if version > AssetsCodecVersion {
  4415. return fmt.Errorf("Invalid Version Unmarshaling Disk. Expected %d or less, got %d", AssetsCodecVersion, version)
  4416. }
  4417. // --- [begin][read][alias](AssetLabels) ---
  4418. var a map[string]string
  4419. if buff.ReadUInt8() == uint8(0) {
  4420. a = nil
  4421. } else {
  4422. // --- [begin][read][map](map[string]string) ---
  4423. c := buff.ReadInt() // map len
  4424. b := make(map[string]string, c)
  4425. for i := 0; i < c; i++ {
  4426. var v string
  4427. var e string
  4428. if ctx.IsStringTable() {
  4429. f := buff.ReadInt() // read string index
  4430. e = ctx.Table[f]
  4431. } else {
  4432. e = buff.ReadString() // read string
  4433. }
  4434. d := e
  4435. v = d
  4436. var z string
  4437. var h string
  4438. if ctx.IsStringTable() {
  4439. k := buff.ReadInt() // read string index
  4440. h = ctx.Table[k]
  4441. } else {
  4442. h = buff.ReadString() // read string
  4443. }
  4444. g := h
  4445. z = g
  4446. b[v] = z
  4447. }
  4448. a = b
  4449. // --- [end][read][map](map[string]string) ---
  4450. }
  4451. target.Labels = AssetLabels(a)
  4452. // --- [end][read][alias](AssetLabels) ---
  4453. if buff.ReadUInt8() == uint8(0) {
  4454. target.Properties = nil
  4455. } else {
  4456. // --- [begin][read][struct](AssetProperties) ---
  4457. l := &AssetProperties{}
  4458. buff.ReadInt() // [compatibility, unused]
  4459. errA := l.UnmarshalBinaryWithContext(ctx)
  4460. if errA != nil {
  4461. return errA
  4462. }
  4463. target.Properties = l
  4464. // --- [end][read][struct](AssetProperties) ---
  4465. }
  4466. // --- [begin][read][reference](time.Time) ---
  4467. m := &time.Time{}
  4468. n := buff.ReadInt() // byte array length
  4469. o := buff.ReadBytes(n) // byte array
  4470. errB := m.UnmarshalBinary(o)
  4471. if errB != nil {
  4472. return errB
  4473. }
  4474. target.Start = *m
  4475. // --- [end][read][reference](time.Time) ---
  4476. // --- [begin][read][reference](time.Time) ---
  4477. p := &time.Time{}
  4478. q := buff.ReadInt() // byte array length
  4479. r := buff.ReadBytes(q) // byte array
  4480. errC := p.UnmarshalBinary(r)
  4481. if errC != nil {
  4482. return errC
  4483. }
  4484. target.End = *p
  4485. // --- [end][read][reference](time.Time) ---
  4486. // --- [begin][read][struct](Window) ---
  4487. s := &Window{}
  4488. buff.ReadInt() // [compatibility, unused]
  4489. errD := s.UnmarshalBinaryWithContext(ctx)
  4490. if errD != nil {
  4491. return errD
  4492. }
  4493. target.Window = *s
  4494. // --- [end][read][struct](Window) ---
  4495. t := buff.ReadFloat64() // read float64
  4496. target.Adjustment = t
  4497. u := buff.ReadFloat64() // read float64
  4498. target.Cost = u
  4499. w := buff.ReadFloat64() // read float64
  4500. target.ByteHours = w
  4501. x := buff.ReadFloat64() // read float64
  4502. target.Local = x
  4503. if buff.ReadUInt8() == uint8(0) {
  4504. target.Breakdown = nil
  4505. } else {
  4506. // --- [begin][read][struct](Breakdown) ---
  4507. y := &Breakdown{}
  4508. buff.ReadInt() // [compatibility, unused]
  4509. errE := y.UnmarshalBinaryWithContext(ctx)
  4510. if errE != nil {
  4511. return errE
  4512. }
  4513. target.Breakdown = y
  4514. // --- [end][read][struct](Breakdown) ---
  4515. }
  4516. // field version check
  4517. if uint8(17) <= version {
  4518. var bb string
  4519. if ctx.IsStringTable() {
  4520. cc := buff.ReadInt() // read string index
  4521. bb = ctx.Table[cc]
  4522. } else {
  4523. bb = buff.ReadString() // read string
  4524. }
  4525. aa := bb
  4526. target.StorageClass = aa
  4527. } else {
  4528. target.StorageClass = "" // default
  4529. }
  4530. // field version check
  4531. if uint8(18) <= version {
  4532. if buff.ReadUInt8() == uint8(0) {
  4533. target.ByteHoursUsed = nil
  4534. } else {
  4535. dd := buff.ReadFloat64() // read float64
  4536. target.ByteHoursUsed = &dd
  4537. }
  4538. } else {
  4539. target.ByteHoursUsed = nil
  4540. }
  4541. // field version check
  4542. if uint8(18) <= version {
  4543. if buff.ReadUInt8() == uint8(0) {
  4544. target.ByteUsageMax = nil
  4545. } else {
  4546. ee := buff.ReadFloat64() // read float64
  4547. target.ByteUsageMax = &ee
  4548. }
  4549. } else {
  4550. target.ByteUsageMax = nil
  4551. }
  4552. // field version check
  4553. if uint8(18) <= version {
  4554. var gg string
  4555. if ctx.IsStringTable() {
  4556. hh := buff.ReadInt() // read string index
  4557. gg = ctx.Table[hh]
  4558. } else {
  4559. gg = buff.ReadString() // read string
  4560. }
  4561. ff := gg
  4562. target.VolumeName = ff
  4563. } else {
  4564. target.VolumeName = "" // default
  4565. }
  4566. // field version check
  4567. if uint8(18) <= version {
  4568. var ll string
  4569. if ctx.IsStringTable() {
  4570. mm := buff.ReadInt() // read string index
  4571. ll = ctx.Table[mm]
  4572. } else {
  4573. ll = buff.ReadString() // read string
  4574. }
  4575. kk := ll
  4576. target.ClaimName = kk
  4577. } else {
  4578. target.ClaimName = "" // default
  4579. }
  4580. // field version check
  4581. if uint8(18) <= version {
  4582. var oo string
  4583. if ctx.IsStringTable() {
  4584. pp := buff.ReadInt() // read string index
  4585. oo = ctx.Table[pp]
  4586. } else {
  4587. oo = buff.ReadString() // read string
  4588. }
  4589. nn := oo
  4590. target.ClaimNamespace = nn
  4591. } else {
  4592. target.ClaimNamespace = "" // default
  4593. }
  4594. return nil
  4595. }
  4596. //--------------------------------------------------------------------------
  4597. // EqualityAudit
  4598. //--------------------------------------------------------------------------
  4599. // MarshalBinary serializes the internal properties of this EqualityAudit instance
  4600. // into a byte array
  4601. func (target *EqualityAudit) MarshalBinary() (data []byte, err error) {
  4602. ctx := &EncodingContext{
  4603. Buffer: util.NewBuffer(),
  4604. Table: nil,
  4605. }
  4606. e := target.MarshalBinaryWithContext(ctx)
  4607. if e != nil {
  4608. return nil, e
  4609. }
  4610. encBytes := ctx.Buffer.Bytes()
  4611. return encBytes, nil
  4612. }
  4613. // MarshalBinaryWithContext serializes the internal properties of this EqualityAudit instance
  4614. // into a byte array leveraging a predefined context.
  4615. func (target *EqualityAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4616. // panics are recovered and propagated as errors
  4617. defer func() {
  4618. if r := recover(); r != nil {
  4619. if e, ok := r.(error); ok {
  4620. err = e
  4621. } else if s, ok := r.(string); ok {
  4622. err = fmt.Errorf("Unexpected panic: %s", s)
  4623. } else {
  4624. err = fmt.Errorf("Unexpected panic: %+v", r)
  4625. }
  4626. }
  4627. }()
  4628. buff := ctx.Buffer
  4629. buff.WriteUInt8(AuditCodecVersion) // version
  4630. // --- [begin][write][alias](AuditStatus) ---
  4631. if ctx.IsStringTable() {
  4632. a := ctx.Table.AddOrGet(string(target.Status))
  4633. buff.WriteInt(a) // write table index
  4634. } else {
  4635. buff.WriteString(string(target.Status)) // write string
  4636. }
  4637. // --- [end][write][alias](AuditStatus) ---
  4638. if ctx.IsStringTable() {
  4639. b := ctx.Table.AddOrGet(target.Description)
  4640. buff.WriteInt(b) // write table index
  4641. } else {
  4642. buff.WriteString(target.Description) // write string
  4643. }
  4644. // --- [begin][write][reference](time.Time) ---
  4645. c, errA := target.LastRun.MarshalBinary()
  4646. if errA != nil {
  4647. return errA
  4648. }
  4649. buff.WriteInt(len(c))
  4650. buff.WriteBytes(c)
  4651. // --- [end][write][reference](time.Time) ---
  4652. if target.Clusters == nil {
  4653. buff.WriteUInt8(uint8(0)) // write nil byte
  4654. } else {
  4655. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4656. // --- [begin][write][map](map[string]*AuditFloatResult) ---
  4657. buff.WriteInt(len(target.Clusters)) // map length
  4658. for v, z := range target.Clusters {
  4659. if ctx.IsStringTable() {
  4660. d := ctx.Table.AddOrGet(v)
  4661. buff.WriteInt(d) // write table index
  4662. } else {
  4663. buff.WriteString(v) // write string
  4664. }
  4665. if z == nil {
  4666. buff.WriteUInt8(uint8(0)) // write nil byte
  4667. } else {
  4668. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4669. // --- [begin][write][struct](AuditFloatResult) ---
  4670. buff.WriteInt(0) // [compatibility, unused]
  4671. errB := z.MarshalBinaryWithContext(ctx)
  4672. if errB != nil {
  4673. return errB
  4674. }
  4675. // --- [end][write][struct](AuditFloatResult) ---
  4676. }
  4677. }
  4678. // --- [end][write][map](map[string]*AuditFloatResult) ---
  4679. }
  4680. if target.MissingValues == nil {
  4681. buff.WriteUInt8(uint8(0)) // write nil byte
  4682. } else {
  4683. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4684. // --- [begin][write][slice]([]*AuditMissingValue) ---
  4685. buff.WriteInt(len(target.MissingValues)) // array length
  4686. for i := 0; i < len(target.MissingValues); i++ {
  4687. if target.MissingValues[i] == nil {
  4688. buff.WriteUInt8(uint8(0)) // write nil byte
  4689. } else {
  4690. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4691. // --- [begin][write][struct](AuditMissingValue) ---
  4692. buff.WriteInt(0) // [compatibility, unused]
  4693. errC := target.MissingValues[i].MarshalBinaryWithContext(ctx)
  4694. if errC != nil {
  4695. return errC
  4696. }
  4697. // --- [end][write][struct](AuditMissingValue) ---
  4698. }
  4699. }
  4700. // --- [end][write][slice]([]*AuditMissingValue) ---
  4701. }
  4702. return nil
  4703. }
  4704. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4705. // the EqualityAudit type
  4706. func (target *EqualityAudit) UnmarshalBinary(data []byte) error {
  4707. var table []string
  4708. buff := util.NewBufferFromBytes(data)
  4709. // string table header validation
  4710. if isBinaryTag(data, BinaryTagStringTable) {
  4711. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4712. tl := buff.ReadInt() // table length
  4713. if tl > 0 {
  4714. table = make([]string, tl, tl)
  4715. for i := 0; i < tl; i++ {
  4716. table[i] = buff.ReadString()
  4717. }
  4718. }
  4719. }
  4720. ctx := &DecodingContext{
  4721. Buffer: buff,
  4722. Table: table,
  4723. }
  4724. err := target.UnmarshalBinaryWithContext(ctx)
  4725. if err != nil {
  4726. return err
  4727. }
  4728. return nil
  4729. }
  4730. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4731. // the EqualityAudit type
  4732. func (target *EqualityAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4733. // panics are recovered and propagated as errors
  4734. defer func() {
  4735. if r := recover(); r != nil {
  4736. if e, ok := r.(error); ok {
  4737. err = e
  4738. } else if s, ok := r.(string); ok {
  4739. err = fmt.Errorf("Unexpected panic: %s", s)
  4740. } else {
  4741. err = fmt.Errorf("Unexpected panic: %+v", r)
  4742. }
  4743. }
  4744. }()
  4745. buff := ctx.Buffer
  4746. version := buff.ReadUInt8()
  4747. if version > AuditCodecVersion {
  4748. return fmt.Errorf("Invalid Version Unmarshaling EqualityAudit. Expected %d or less, got %d", AuditCodecVersion, version)
  4749. }
  4750. // --- [begin][read][alias](AuditStatus) ---
  4751. var a string
  4752. var c string
  4753. if ctx.IsStringTable() {
  4754. d := buff.ReadInt() // read string index
  4755. c = ctx.Table[d]
  4756. } else {
  4757. c = buff.ReadString() // read string
  4758. }
  4759. b := c
  4760. a = b
  4761. target.Status = AuditStatus(a)
  4762. // --- [end][read][alias](AuditStatus) ---
  4763. var f string
  4764. if ctx.IsStringTable() {
  4765. g := buff.ReadInt() // read string index
  4766. f = ctx.Table[g]
  4767. } else {
  4768. f = buff.ReadString() // read string
  4769. }
  4770. e := f
  4771. target.Description = e
  4772. // --- [begin][read][reference](time.Time) ---
  4773. h := &time.Time{}
  4774. k := buff.ReadInt() // byte array length
  4775. l := buff.ReadBytes(k) // byte array
  4776. errA := h.UnmarshalBinary(l)
  4777. if errA != nil {
  4778. return errA
  4779. }
  4780. target.LastRun = *h
  4781. // --- [end][read][reference](time.Time) ---
  4782. if buff.ReadUInt8() == uint8(0) {
  4783. target.Clusters = nil
  4784. } else {
  4785. // --- [begin][read][map](map[string]*AuditFloatResult) ---
  4786. n := buff.ReadInt() // map len
  4787. m := make(map[string]*AuditFloatResult, n)
  4788. for i := 0; i < n; i++ {
  4789. var v string
  4790. var p string
  4791. if ctx.IsStringTable() {
  4792. q := buff.ReadInt() // read string index
  4793. p = ctx.Table[q]
  4794. } else {
  4795. p = buff.ReadString() // read string
  4796. }
  4797. o := p
  4798. v = o
  4799. var z *AuditFloatResult
  4800. if buff.ReadUInt8() == uint8(0) {
  4801. z = nil
  4802. } else {
  4803. // --- [begin][read][struct](AuditFloatResult) ---
  4804. r := &AuditFloatResult{}
  4805. buff.ReadInt() // [compatibility, unused]
  4806. errB := r.UnmarshalBinaryWithContext(ctx)
  4807. if errB != nil {
  4808. return errB
  4809. }
  4810. z = r
  4811. // --- [end][read][struct](AuditFloatResult) ---
  4812. }
  4813. m[v] = z
  4814. }
  4815. target.Clusters = m
  4816. // --- [end][read][map](map[string]*AuditFloatResult) ---
  4817. }
  4818. if buff.ReadUInt8() == uint8(0) {
  4819. target.MissingValues = nil
  4820. } else {
  4821. // --- [begin][read][slice]([]*AuditMissingValue) ---
  4822. t := buff.ReadInt() // array len
  4823. s := make([]*AuditMissingValue, t)
  4824. for j := 0; j < t; j++ {
  4825. var u *AuditMissingValue
  4826. if buff.ReadUInt8() == uint8(0) {
  4827. u = nil
  4828. } else {
  4829. // --- [begin][read][struct](AuditMissingValue) ---
  4830. w := &AuditMissingValue{}
  4831. buff.ReadInt() // [compatibility, unused]
  4832. errC := w.UnmarshalBinaryWithContext(ctx)
  4833. if errC != nil {
  4834. return errC
  4835. }
  4836. u = w
  4837. // --- [end][read][struct](AuditMissingValue) ---
  4838. }
  4839. s[j] = u
  4840. }
  4841. target.MissingValues = s
  4842. // --- [end][read][slice]([]*AuditMissingValue) ---
  4843. }
  4844. return nil
  4845. }
  4846. //--------------------------------------------------------------------------
  4847. // LoadBalancer
  4848. //--------------------------------------------------------------------------
  4849. // MarshalBinary serializes the internal properties of this LoadBalancer instance
  4850. // into a byte array
  4851. func (target *LoadBalancer) MarshalBinary() (data []byte, err error) {
  4852. ctx := &EncodingContext{
  4853. Buffer: util.NewBuffer(),
  4854. Table: nil,
  4855. }
  4856. e := target.MarshalBinaryWithContext(ctx)
  4857. if e != nil {
  4858. return nil, e
  4859. }
  4860. encBytes := ctx.Buffer.Bytes()
  4861. return encBytes, nil
  4862. }
  4863. // MarshalBinaryWithContext serializes the internal properties of this LoadBalancer instance
  4864. // into a byte array leveraging a predefined context.
  4865. func (target *LoadBalancer) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4866. // panics are recovered and propagated as errors
  4867. defer func() {
  4868. if r := recover(); r != nil {
  4869. if e, ok := r.(error); ok {
  4870. err = e
  4871. } else if s, ok := r.(string); ok {
  4872. err = fmt.Errorf("Unexpected panic: %s", s)
  4873. } else {
  4874. err = fmt.Errorf("Unexpected panic: %+v", r)
  4875. }
  4876. }
  4877. }()
  4878. buff := ctx.Buffer
  4879. buff.WriteUInt8(AssetsCodecVersion) // version
  4880. if target.Properties == nil {
  4881. buff.WriteUInt8(uint8(0)) // write nil byte
  4882. } else {
  4883. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4884. // --- [begin][write][struct](AssetProperties) ---
  4885. buff.WriteInt(0) // [compatibility, unused]
  4886. errA := target.Properties.MarshalBinaryWithContext(ctx)
  4887. if errA != nil {
  4888. return errA
  4889. }
  4890. // --- [end][write][struct](AssetProperties) ---
  4891. }
  4892. // --- [begin][write][alias](AssetLabels) ---
  4893. if map[string]string(target.Labels) == nil {
  4894. buff.WriteUInt8(uint8(0)) // write nil byte
  4895. } else {
  4896. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4897. // --- [begin][write][map](map[string]string) ---
  4898. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  4899. for v, z := range map[string]string(target.Labels) {
  4900. if ctx.IsStringTable() {
  4901. a := ctx.Table.AddOrGet(v)
  4902. buff.WriteInt(a) // write table index
  4903. } else {
  4904. buff.WriteString(v) // write string
  4905. }
  4906. if ctx.IsStringTable() {
  4907. b := ctx.Table.AddOrGet(z)
  4908. buff.WriteInt(b) // write table index
  4909. } else {
  4910. buff.WriteString(z) // write string
  4911. }
  4912. }
  4913. // --- [end][write][map](map[string]string) ---
  4914. }
  4915. // --- [end][write][alias](AssetLabels) ---
  4916. // --- [begin][write][reference](time.Time) ---
  4917. c, errB := target.Start.MarshalBinary()
  4918. if errB != nil {
  4919. return errB
  4920. }
  4921. buff.WriteInt(len(c))
  4922. buff.WriteBytes(c)
  4923. // --- [end][write][reference](time.Time) ---
  4924. // --- [begin][write][reference](time.Time) ---
  4925. d, errC := target.End.MarshalBinary()
  4926. if errC != nil {
  4927. return errC
  4928. }
  4929. buff.WriteInt(len(d))
  4930. buff.WriteBytes(d)
  4931. // --- [end][write][reference](time.Time) ---
  4932. // --- [begin][write][struct](Window) ---
  4933. buff.WriteInt(0) // [compatibility, unused]
  4934. errD := target.Window.MarshalBinaryWithContext(ctx)
  4935. if errD != nil {
  4936. return errD
  4937. }
  4938. // --- [end][write][struct](Window) ---
  4939. buff.WriteFloat64(target.Adjustment) // write float64
  4940. buff.WriteFloat64(target.Cost) // write float64
  4941. return nil
  4942. }
  4943. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4944. // the LoadBalancer type
  4945. func (target *LoadBalancer) UnmarshalBinary(data []byte) error {
  4946. var table []string
  4947. buff := util.NewBufferFromBytes(data)
  4948. // string table header validation
  4949. if isBinaryTag(data, BinaryTagStringTable) {
  4950. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4951. tl := buff.ReadInt() // table length
  4952. if tl > 0 {
  4953. table = make([]string, tl, tl)
  4954. for i := 0; i < tl; i++ {
  4955. table[i] = buff.ReadString()
  4956. }
  4957. }
  4958. }
  4959. ctx := &DecodingContext{
  4960. Buffer: buff,
  4961. Table: table,
  4962. }
  4963. err := target.UnmarshalBinaryWithContext(ctx)
  4964. if err != nil {
  4965. return err
  4966. }
  4967. return nil
  4968. }
  4969. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4970. // the LoadBalancer type
  4971. func (target *LoadBalancer) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4972. // panics are recovered and propagated as errors
  4973. defer func() {
  4974. if r := recover(); r != nil {
  4975. if e, ok := r.(error); ok {
  4976. err = e
  4977. } else if s, ok := r.(string); ok {
  4978. err = fmt.Errorf("Unexpected panic: %s", s)
  4979. } else {
  4980. err = fmt.Errorf("Unexpected panic: %+v", r)
  4981. }
  4982. }
  4983. }()
  4984. buff := ctx.Buffer
  4985. version := buff.ReadUInt8()
  4986. if version > AssetsCodecVersion {
  4987. return fmt.Errorf("Invalid Version Unmarshaling LoadBalancer. Expected %d or less, got %d", AssetsCodecVersion, version)
  4988. }
  4989. if buff.ReadUInt8() == uint8(0) {
  4990. target.Properties = nil
  4991. } else {
  4992. // --- [begin][read][struct](AssetProperties) ---
  4993. a := &AssetProperties{}
  4994. buff.ReadInt() // [compatibility, unused]
  4995. errA := a.UnmarshalBinaryWithContext(ctx)
  4996. if errA != nil {
  4997. return errA
  4998. }
  4999. target.Properties = a
  5000. // --- [end][read][struct](AssetProperties) ---
  5001. }
  5002. // --- [begin][read][alias](AssetLabels) ---
  5003. var b map[string]string
  5004. if buff.ReadUInt8() == uint8(0) {
  5005. b = nil
  5006. } else {
  5007. // --- [begin][read][map](map[string]string) ---
  5008. d := buff.ReadInt() // map len
  5009. c := make(map[string]string, d)
  5010. for i := 0; i < d; i++ {
  5011. var v string
  5012. var f string
  5013. if ctx.IsStringTable() {
  5014. g := buff.ReadInt() // read string index
  5015. f = ctx.Table[g]
  5016. } else {
  5017. f = buff.ReadString() // read string
  5018. }
  5019. e := f
  5020. v = e
  5021. var z string
  5022. var k string
  5023. if ctx.IsStringTable() {
  5024. l := buff.ReadInt() // read string index
  5025. k = ctx.Table[l]
  5026. } else {
  5027. k = buff.ReadString() // read string
  5028. }
  5029. h := k
  5030. z = h
  5031. c[v] = z
  5032. }
  5033. b = c
  5034. // --- [end][read][map](map[string]string) ---
  5035. }
  5036. target.Labels = AssetLabels(b)
  5037. // --- [end][read][alias](AssetLabels) ---
  5038. // --- [begin][read][reference](time.Time) ---
  5039. m := &time.Time{}
  5040. n := buff.ReadInt() // byte array length
  5041. o := buff.ReadBytes(n) // byte array
  5042. errB := m.UnmarshalBinary(o)
  5043. if errB != nil {
  5044. return errB
  5045. }
  5046. target.Start = *m
  5047. // --- [end][read][reference](time.Time) ---
  5048. // --- [begin][read][reference](time.Time) ---
  5049. p := &time.Time{}
  5050. q := buff.ReadInt() // byte array length
  5051. r := buff.ReadBytes(q) // byte array
  5052. errC := p.UnmarshalBinary(r)
  5053. if errC != nil {
  5054. return errC
  5055. }
  5056. target.End = *p
  5057. // --- [end][read][reference](time.Time) ---
  5058. // --- [begin][read][struct](Window) ---
  5059. s := &Window{}
  5060. buff.ReadInt() // [compatibility, unused]
  5061. errD := s.UnmarshalBinaryWithContext(ctx)
  5062. if errD != nil {
  5063. return errD
  5064. }
  5065. target.Window = *s
  5066. // --- [end][read][struct](Window) ---
  5067. t := buff.ReadFloat64() // read float64
  5068. target.Adjustment = t
  5069. u := buff.ReadFloat64() // read float64
  5070. target.Cost = u
  5071. return nil
  5072. }
  5073. //--------------------------------------------------------------------------
  5074. // Network
  5075. //--------------------------------------------------------------------------
  5076. // MarshalBinary serializes the internal properties of this Network instance
  5077. // into a byte array
  5078. func (target *Network) MarshalBinary() (data []byte, err error) {
  5079. ctx := &EncodingContext{
  5080. Buffer: util.NewBuffer(),
  5081. Table: nil,
  5082. }
  5083. e := target.MarshalBinaryWithContext(ctx)
  5084. if e != nil {
  5085. return nil, e
  5086. }
  5087. encBytes := ctx.Buffer.Bytes()
  5088. return encBytes, nil
  5089. }
  5090. // MarshalBinaryWithContext serializes the internal properties of this Network instance
  5091. // into a byte array leveraging a predefined context.
  5092. func (target *Network) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5093. // panics are recovered and propagated as errors
  5094. defer func() {
  5095. if r := recover(); r != nil {
  5096. if e, ok := r.(error); ok {
  5097. err = e
  5098. } else if s, ok := r.(string); ok {
  5099. err = fmt.Errorf("Unexpected panic: %s", s)
  5100. } else {
  5101. err = fmt.Errorf("Unexpected panic: %+v", r)
  5102. }
  5103. }
  5104. }()
  5105. buff := ctx.Buffer
  5106. buff.WriteUInt8(AssetsCodecVersion) // version
  5107. if target.Properties == nil {
  5108. buff.WriteUInt8(uint8(0)) // write nil byte
  5109. } else {
  5110. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5111. // --- [begin][write][struct](AssetProperties) ---
  5112. buff.WriteInt(0) // [compatibility, unused]
  5113. errA := target.Properties.MarshalBinaryWithContext(ctx)
  5114. if errA != nil {
  5115. return errA
  5116. }
  5117. // --- [end][write][struct](AssetProperties) ---
  5118. }
  5119. // --- [begin][write][alias](AssetLabels) ---
  5120. if map[string]string(target.Labels) == nil {
  5121. buff.WriteUInt8(uint8(0)) // write nil byte
  5122. } else {
  5123. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5124. // --- [begin][write][map](map[string]string) ---
  5125. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  5126. for v, z := range map[string]string(target.Labels) {
  5127. if ctx.IsStringTable() {
  5128. a := ctx.Table.AddOrGet(v)
  5129. buff.WriteInt(a) // write table index
  5130. } else {
  5131. buff.WriteString(v) // write string
  5132. }
  5133. if ctx.IsStringTable() {
  5134. b := ctx.Table.AddOrGet(z)
  5135. buff.WriteInt(b) // write table index
  5136. } else {
  5137. buff.WriteString(z) // write string
  5138. }
  5139. }
  5140. // --- [end][write][map](map[string]string) ---
  5141. }
  5142. // --- [end][write][alias](AssetLabels) ---
  5143. // --- [begin][write][reference](time.Time) ---
  5144. c, errB := target.Start.MarshalBinary()
  5145. if errB != nil {
  5146. return errB
  5147. }
  5148. buff.WriteInt(len(c))
  5149. buff.WriteBytes(c)
  5150. // --- [end][write][reference](time.Time) ---
  5151. // --- [begin][write][reference](time.Time) ---
  5152. d, errC := target.End.MarshalBinary()
  5153. if errC != nil {
  5154. return errC
  5155. }
  5156. buff.WriteInt(len(d))
  5157. buff.WriteBytes(d)
  5158. // --- [end][write][reference](time.Time) ---
  5159. // --- [begin][write][struct](Window) ---
  5160. buff.WriteInt(0) // [compatibility, unused]
  5161. errD := target.Window.MarshalBinaryWithContext(ctx)
  5162. if errD != nil {
  5163. return errD
  5164. }
  5165. // --- [end][write][struct](Window) ---
  5166. buff.WriteFloat64(target.Adjustment) // write float64
  5167. buff.WriteFloat64(target.Cost) // write float64
  5168. return nil
  5169. }
  5170. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5171. // the Network type
  5172. func (target *Network) UnmarshalBinary(data []byte) error {
  5173. var table []string
  5174. buff := util.NewBufferFromBytes(data)
  5175. // string table header validation
  5176. if isBinaryTag(data, BinaryTagStringTable) {
  5177. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5178. tl := buff.ReadInt() // table length
  5179. if tl > 0 {
  5180. table = make([]string, tl, tl)
  5181. for i := 0; i < tl; i++ {
  5182. table[i] = buff.ReadString()
  5183. }
  5184. }
  5185. }
  5186. ctx := &DecodingContext{
  5187. Buffer: buff,
  5188. Table: table,
  5189. }
  5190. err := target.UnmarshalBinaryWithContext(ctx)
  5191. if err != nil {
  5192. return err
  5193. }
  5194. return nil
  5195. }
  5196. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5197. // the Network type
  5198. func (target *Network) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5199. // panics are recovered and propagated as errors
  5200. defer func() {
  5201. if r := recover(); r != nil {
  5202. if e, ok := r.(error); ok {
  5203. err = e
  5204. } else if s, ok := r.(string); ok {
  5205. err = fmt.Errorf("Unexpected panic: %s", s)
  5206. } else {
  5207. err = fmt.Errorf("Unexpected panic: %+v", r)
  5208. }
  5209. }
  5210. }()
  5211. buff := ctx.Buffer
  5212. version := buff.ReadUInt8()
  5213. if version > AssetsCodecVersion {
  5214. return fmt.Errorf("Invalid Version Unmarshaling Network. Expected %d or less, got %d", AssetsCodecVersion, version)
  5215. }
  5216. if buff.ReadUInt8() == uint8(0) {
  5217. target.Properties = nil
  5218. } else {
  5219. // --- [begin][read][struct](AssetProperties) ---
  5220. a := &AssetProperties{}
  5221. buff.ReadInt() // [compatibility, unused]
  5222. errA := a.UnmarshalBinaryWithContext(ctx)
  5223. if errA != nil {
  5224. return errA
  5225. }
  5226. target.Properties = a
  5227. // --- [end][read][struct](AssetProperties) ---
  5228. }
  5229. // --- [begin][read][alias](AssetLabels) ---
  5230. var b map[string]string
  5231. if buff.ReadUInt8() == uint8(0) {
  5232. b = nil
  5233. } else {
  5234. // --- [begin][read][map](map[string]string) ---
  5235. d := buff.ReadInt() // map len
  5236. c := make(map[string]string, d)
  5237. for i := 0; i < d; i++ {
  5238. var v string
  5239. var f string
  5240. if ctx.IsStringTable() {
  5241. g := buff.ReadInt() // read string index
  5242. f = ctx.Table[g]
  5243. } else {
  5244. f = buff.ReadString() // read string
  5245. }
  5246. e := f
  5247. v = e
  5248. var z string
  5249. var k string
  5250. if ctx.IsStringTable() {
  5251. l := buff.ReadInt() // read string index
  5252. k = ctx.Table[l]
  5253. } else {
  5254. k = buff.ReadString() // read string
  5255. }
  5256. h := k
  5257. z = h
  5258. c[v] = z
  5259. }
  5260. b = c
  5261. // --- [end][read][map](map[string]string) ---
  5262. }
  5263. target.Labels = AssetLabels(b)
  5264. // --- [end][read][alias](AssetLabels) ---
  5265. // --- [begin][read][reference](time.Time) ---
  5266. m := &time.Time{}
  5267. n := buff.ReadInt() // byte array length
  5268. o := buff.ReadBytes(n) // byte array
  5269. errB := m.UnmarshalBinary(o)
  5270. if errB != nil {
  5271. return errB
  5272. }
  5273. target.Start = *m
  5274. // --- [end][read][reference](time.Time) ---
  5275. // --- [begin][read][reference](time.Time) ---
  5276. p := &time.Time{}
  5277. q := buff.ReadInt() // byte array length
  5278. r := buff.ReadBytes(q) // byte array
  5279. errC := p.UnmarshalBinary(r)
  5280. if errC != nil {
  5281. return errC
  5282. }
  5283. target.End = *p
  5284. // --- [end][read][reference](time.Time) ---
  5285. // --- [begin][read][struct](Window) ---
  5286. s := &Window{}
  5287. buff.ReadInt() // [compatibility, unused]
  5288. errD := s.UnmarshalBinaryWithContext(ctx)
  5289. if errD != nil {
  5290. return errD
  5291. }
  5292. target.Window = *s
  5293. // --- [end][read][struct](Window) ---
  5294. t := buff.ReadFloat64() // read float64
  5295. target.Adjustment = t
  5296. u := buff.ReadFloat64() // read float64
  5297. target.Cost = u
  5298. return nil
  5299. }
  5300. //--------------------------------------------------------------------------
  5301. // Node
  5302. //--------------------------------------------------------------------------
  5303. // MarshalBinary serializes the internal properties of this Node instance
  5304. // into a byte array
  5305. func (target *Node) MarshalBinary() (data []byte, err error) {
  5306. ctx := &EncodingContext{
  5307. Buffer: util.NewBuffer(),
  5308. Table: nil,
  5309. }
  5310. e := target.MarshalBinaryWithContext(ctx)
  5311. if e != nil {
  5312. return nil, e
  5313. }
  5314. encBytes := ctx.Buffer.Bytes()
  5315. return encBytes, nil
  5316. }
  5317. // MarshalBinaryWithContext serializes the internal properties of this Node instance
  5318. // into a byte array leveraging a predefined context.
  5319. func (target *Node) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5320. // panics are recovered and propagated as errors
  5321. defer func() {
  5322. if r := recover(); r != nil {
  5323. if e, ok := r.(error); ok {
  5324. err = e
  5325. } else if s, ok := r.(string); ok {
  5326. err = fmt.Errorf("Unexpected panic: %s", s)
  5327. } else {
  5328. err = fmt.Errorf("Unexpected panic: %+v", r)
  5329. }
  5330. }
  5331. }()
  5332. buff := ctx.Buffer
  5333. buff.WriteUInt8(AssetsCodecVersion) // version
  5334. if target.Properties == nil {
  5335. buff.WriteUInt8(uint8(0)) // write nil byte
  5336. } else {
  5337. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5338. // --- [begin][write][struct](AssetProperties) ---
  5339. buff.WriteInt(0) // [compatibility, unused]
  5340. errA := target.Properties.MarshalBinaryWithContext(ctx)
  5341. if errA != nil {
  5342. return errA
  5343. }
  5344. // --- [end][write][struct](AssetProperties) ---
  5345. }
  5346. // --- [begin][write][alias](AssetLabels) ---
  5347. if map[string]string(target.Labels) == nil {
  5348. buff.WriteUInt8(uint8(0)) // write nil byte
  5349. } else {
  5350. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5351. // --- [begin][write][map](map[string]string) ---
  5352. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  5353. for v, z := range map[string]string(target.Labels) {
  5354. if ctx.IsStringTable() {
  5355. a := ctx.Table.AddOrGet(v)
  5356. buff.WriteInt(a) // write table index
  5357. } else {
  5358. buff.WriteString(v) // write string
  5359. }
  5360. if ctx.IsStringTable() {
  5361. b := ctx.Table.AddOrGet(z)
  5362. buff.WriteInt(b) // write table index
  5363. } else {
  5364. buff.WriteString(z) // write string
  5365. }
  5366. }
  5367. // --- [end][write][map](map[string]string) ---
  5368. }
  5369. // --- [end][write][alias](AssetLabels) ---
  5370. // --- [begin][write][reference](time.Time) ---
  5371. c, errB := target.Start.MarshalBinary()
  5372. if errB != nil {
  5373. return errB
  5374. }
  5375. buff.WriteInt(len(c))
  5376. buff.WriteBytes(c)
  5377. // --- [end][write][reference](time.Time) ---
  5378. // --- [begin][write][reference](time.Time) ---
  5379. d, errC := target.End.MarshalBinary()
  5380. if errC != nil {
  5381. return errC
  5382. }
  5383. buff.WriteInt(len(d))
  5384. buff.WriteBytes(d)
  5385. // --- [end][write][reference](time.Time) ---
  5386. // --- [begin][write][struct](Window) ---
  5387. buff.WriteInt(0) // [compatibility, unused]
  5388. errD := target.Window.MarshalBinaryWithContext(ctx)
  5389. if errD != nil {
  5390. return errD
  5391. }
  5392. // --- [end][write][struct](Window) ---
  5393. buff.WriteFloat64(target.Adjustment) // write float64
  5394. if ctx.IsStringTable() {
  5395. e := ctx.Table.AddOrGet(target.NodeType)
  5396. buff.WriteInt(e) // write table index
  5397. } else {
  5398. buff.WriteString(target.NodeType) // write string
  5399. }
  5400. buff.WriteFloat64(target.CPUCoreHours) // write float64
  5401. buff.WriteFloat64(target.RAMByteHours) // write float64
  5402. buff.WriteFloat64(target.GPUHours) // write float64
  5403. if target.CPUBreakdown == nil {
  5404. buff.WriteUInt8(uint8(0)) // write nil byte
  5405. } else {
  5406. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5407. // --- [begin][write][struct](Breakdown) ---
  5408. buff.WriteInt(0) // [compatibility, unused]
  5409. errE := target.CPUBreakdown.MarshalBinaryWithContext(ctx)
  5410. if errE != nil {
  5411. return errE
  5412. }
  5413. // --- [end][write][struct](Breakdown) ---
  5414. }
  5415. if target.RAMBreakdown == nil {
  5416. buff.WriteUInt8(uint8(0)) // write nil byte
  5417. } else {
  5418. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5419. // --- [begin][write][struct](Breakdown) ---
  5420. buff.WriteInt(0) // [compatibility, unused]
  5421. errF := target.RAMBreakdown.MarshalBinaryWithContext(ctx)
  5422. if errF != nil {
  5423. return errF
  5424. }
  5425. // --- [end][write][struct](Breakdown) ---
  5426. }
  5427. buff.WriteFloat64(target.CPUCost) // write float64
  5428. buff.WriteFloat64(target.GPUCost) // write float64
  5429. buff.WriteFloat64(target.GPUCount) // write float64
  5430. buff.WriteFloat64(target.RAMCost) // write float64
  5431. buff.WriteFloat64(target.Discount) // write float64
  5432. buff.WriteFloat64(target.Preemptible) // write float64
  5433. return nil
  5434. }
  5435. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5436. // the Node type
  5437. func (target *Node) UnmarshalBinary(data []byte) error {
  5438. var table []string
  5439. buff := util.NewBufferFromBytes(data)
  5440. // string table header validation
  5441. if isBinaryTag(data, BinaryTagStringTable) {
  5442. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5443. tl := buff.ReadInt() // table length
  5444. if tl > 0 {
  5445. table = make([]string, tl, tl)
  5446. for i := 0; i < tl; i++ {
  5447. table[i] = buff.ReadString()
  5448. }
  5449. }
  5450. }
  5451. ctx := &DecodingContext{
  5452. Buffer: buff,
  5453. Table: table,
  5454. }
  5455. err := target.UnmarshalBinaryWithContext(ctx)
  5456. if err != nil {
  5457. return err
  5458. }
  5459. return nil
  5460. }
  5461. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5462. // the Node type
  5463. func (target *Node) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5464. // panics are recovered and propagated as errors
  5465. defer func() {
  5466. if r := recover(); r != nil {
  5467. if e, ok := r.(error); ok {
  5468. err = e
  5469. } else if s, ok := r.(string); ok {
  5470. err = fmt.Errorf("Unexpected panic: %s", s)
  5471. } else {
  5472. err = fmt.Errorf("Unexpected panic: %+v", r)
  5473. }
  5474. }
  5475. }()
  5476. buff := ctx.Buffer
  5477. version := buff.ReadUInt8()
  5478. if version > AssetsCodecVersion {
  5479. return fmt.Errorf("Invalid Version Unmarshaling Node. Expected %d or less, got %d", AssetsCodecVersion, version)
  5480. }
  5481. if buff.ReadUInt8() == uint8(0) {
  5482. target.Properties = nil
  5483. } else {
  5484. // --- [begin][read][struct](AssetProperties) ---
  5485. a := &AssetProperties{}
  5486. buff.ReadInt() // [compatibility, unused]
  5487. errA := a.UnmarshalBinaryWithContext(ctx)
  5488. if errA != nil {
  5489. return errA
  5490. }
  5491. target.Properties = a
  5492. // --- [end][read][struct](AssetProperties) ---
  5493. }
  5494. // --- [begin][read][alias](AssetLabels) ---
  5495. var b map[string]string
  5496. if buff.ReadUInt8() == uint8(0) {
  5497. b = nil
  5498. } else {
  5499. // --- [begin][read][map](map[string]string) ---
  5500. d := buff.ReadInt() // map len
  5501. c := make(map[string]string, d)
  5502. for i := 0; i < d; i++ {
  5503. var v string
  5504. var f string
  5505. if ctx.IsStringTable() {
  5506. g := buff.ReadInt() // read string index
  5507. f = ctx.Table[g]
  5508. } else {
  5509. f = buff.ReadString() // read string
  5510. }
  5511. e := f
  5512. v = e
  5513. var z string
  5514. var k string
  5515. if ctx.IsStringTable() {
  5516. l := buff.ReadInt() // read string index
  5517. k = ctx.Table[l]
  5518. } else {
  5519. k = buff.ReadString() // read string
  5520. }
  5521. h := k
  5522. z = h
  5523. c[v] = z
  5524. }
  5525. b = c
  5526. // --- [end][read][map](map[string]string) ---
  5527. }
  5528. target.Labels = AssetLabels(b)
  5529. // --- [end][read][alias](AssetLabels) ---
  5530. // --- [begin][read][reference](time.Time) ---
  5531. m := &time.Time{}
  5532. n := buff.ReadInt() // byte array length
  5533. o := buff.ReadBytes(n) // byte array
  5534. errB := m.UnmarshalBinary(o)
  5535. if errB != nil {
  5536. return errB
  5537. }
  5538. target.Start = *m
  5539. // --- [end][read][reference](time.Time) ---
  5540. // --- [begin][read][reference](time.Time) ---
  5541. p := &time.Time{}
  5542. q := buff.ReadInt() // byte array length
  5543. r := buff.ReadBytes(q) // byte array
  5544. errC := p.UnmarshalBinary(r)
  5545. if errC != nil {
  5546. return errC
  5547. }
  5548. target.End = *p
  5549. // --- [end][read][reference](time.Time) ---
  5550. // --- [begin][read][struct](Window) ---
  5551. s := &Window{}
  5552. buff.ReadInt() // [compatibility, unused]
  5553. errD := s.UnmarshalBinaryWithContext(ctx)
  5554. if errD != nil {
  5555. return errD
  5556. }
  5557. target.Window = *s
  5558. // --- [end][read][struct](Window) ---
  5559. t := buff.ReadFloat64() // read float64
  5560. target.Adjustment = t
  5561. var w string
  5562. if ctx.IsStringTable() {
  5563. x := buff.ReadInt() // read string index
  5564. w = ctx.Table[x]
  5565. } else {
  5566. w = buff.ReadString() // read string
  5567. }
  5568. u := w
  5569. target.NodeType = u
  5570. y := buff.ReadFloat64() // read float64
  5571. target.CPUCoreHours = y
  5572. aa := buff.ReadFloat64() // read float64
  5573. target.RAMByteHours = aa
  5574. bb := buff.ReadFloat64() // read float64
  5575. target.GPUHours = bb
  5576. if buff.ReadUInt8() == uint8(0) {
  5577. target.CPUBreakdown = nil
  5578. } else {
  5579. // --- [begin][read][struct](Breakdown) ---
  5580. cc := &Breakdown{}
  5581. buff.ReadInt() // [compatibility, unused]
  5582. errE := cc.UnmarshalBinaryWithContext(ctx)
  5583. if errE != nil {
  5584. return errE
  5585. }
  5586. target.CPUBreakdown = cc
  5587. // --- [end][read][struct](Breakdown) ---
  5588. }
  5589. if buff.ReadUInt8() == uint8(0) {
  5590. target.RAMBreakdown = nil
  5591. } else {
  5592. // --- [begin][read][struct](Breakdown) ---
  5593. dd := &Breakdown{}
  5594. buff.ReadInt() // [compatibility, unused]
  5595. errF := dd.UnmarshalBinaryWithContext(ctx)
  5596. if errF != nil {
  5597. return errF
  5598. }
  5599. target.RAMBreakdown = dd
  5600. // --- [end][read][struct](Breakdown) ---
  5601. }
  5602. ee := buff.ReadFloat64() // read float64
  5603. target.CPUCost = ee
  5604. ff := buff.ReadFloat64() // read float64
  5605. target.GPUCost = ff
  5606. gg := buff.ReadFloat64() // read float64
  5607. target.GPUCount = gg
  5608. hh := buff.ReadFloat64() // read float64
  5609. target.RAMCost = hh
  5610. kk := buff.ReadFloat64() // read float64
  5611. target.Discount = kk
  5612. ll := buff.ReadFloat64() // read float64
  5613. target.Preemptible = ll
  5614. return nil
  5615. }
  5616. //--------------------------------------------------------------------------
  5617. // PVAllocation
  5618. //--------------------------------------------------------------------------
  5619. // MarshalBinary serializes the internal properties of this PVAllocation instance
  5620. // into a byte array
  5621. func (target *PVAllocation) MarshalBinary() (data []byte, err error) {
  5622. ctx := &EncodingContext{
  5623. Buffer: util.NewBuffer(),
  5624. Table: nil,
  5625. }
  5626. e := target.MarshalBinaryWithContext(ctx)
  5627. if e != nil {
  5628. return nil, e
  5629. }
  5630. encBytes := ctx.Buffer.Bytes()
  5631. return encBytes, nil
  5632. }
  5633. // MarshalBinaryWithContext serializes the internal properties of this PVAllocation instance
  5634. // into a byte array leveraging a predefined context.
  5635. func (target *PVAllocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5636. // panics are recovered and propagated as errors
  5637. defer func() {
  5638. if r := recover(); r != nil {
  5639. if e, ok := r.(error); ok {
  5640. err = e
  5641. } else if s, ok := r.(string); ok {
  5642. err = fmt.Errorf("Unexpected panic: %s", s)
  5643. } else {
  5644. err = fmt.Errorf("Unexpected panic: %+v", r)
  5645. }
  5646. }
  5647. }()
  5648. buff := ctx.Buffer
  5649. buff.WriteUInt8(AllocationCodecVersion) // version
  5650. buff.WriteFloat64(target.ByteHours) // write float64
  5651. buff.WriteFloat64(target.Cost) // write float64
  5652. return nil
  5653. }
  5654. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5655. // the PVAllocation type
  5656. func (target *PVAllocation) UnmarshalBinary(data []byte) error {
  5657. var table []string
  5658. buff := util.NewBufferFromBytes(data)
  5659. // string table header validation
  5660. if isBinaryTag(data, BinaryTagStringTable) {
  5661. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5662. tl := buff.ReadInt() // table length
  5663. if tl > 0 {
  5664. table = make([]string, tl, tl)
  5665. for i := 0; i < tl; i++ {
  5666. table[i] = buff.ReadString()
  5667. }
  5668. }
  5669. }
  5670. ctx := &DecodingContext{
  5671. Buffer: buff,
  5672. Table: table,
  5673. }
  5674. err := target.UnmarshalBinaryWithContext(ctx)
  5675. if err != nil {
  5676. return err
  5677. }
  5678. return nil
  5679. }
  5680. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5681. // the PVAllocation type
  5682. func (target *PVAllocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5683. // panics are recovered and propagated as errors
  5684. defer func() {
  5685. if r := recover(); r != nil {
  5686. if e, ok := r.(error); ok {
  5687. err = e
  5688. } else if s, ok := r.(string); ok {
  5689. err = fmt.Errorf("Unexpected panic: %s", s)
  5690. } else {
  5691. err = fmt.Errorf("Unexpected panic: %+v", r)
  5692. }
  5693. }
  5694. }()
  5695. buff := ctx.Buffer
  5696. version := buff.ReadUInt8()
  5697. if version > AllocationCodecVersion {
  5698. return fmt.Errorf("Invalid Version Unmarshaling PVAllocation. Expected %d or less, got %d", AllocationCodecVersion, version)
  5699. }
  5700. a := buff.ReadFloat64() // read float64
  5701. target.ByteHours = a
  5702. b := buff.ReadFloat64() // read float64
  5703. target.Cost = b
  5704. return nil
  5705. }
  5706. //--------------------------------------------------------------------------
  5707. // PVKey
  5708. //--------------------------------------------------------------------------
  5709. // MarshalBinary serializes the internal properties of this PVKey instance
  5710. // into a byte array
  5711. func (target *PVKey) MarshalBinary() (data []byte, err error) {
  5712. ctx := &EncodingContext{
  5713. Buffer: util.NewBuffer(),
  5714. Table: nil,
  5715. }
  5716. e := target.MarshalBinaryWithContext(ctx)
  5717. if e != nil {
  5718. return nil, e
  5719. }
  5720. encBytes := ctx.Buffer.Bytes()
  5721. return encBytes, nil
  5722. }
  5723. // MarshalBinaryWithContext serializes the internal properties of this PVKey instance
  5724. // into a byte array leveraging a predefined context.
  5725. func (target *PVKey) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5726. // panics are recovered and propagated as errors
  5727. defer func() {
  5728. if r := recover(); r != nil {
  5729. if e, ok := r.(error); ok {
  5730. err = e
  5731. } else if s, ok := r.(string); ok {
  5732. err = fmt.Errorf("Unexpected panic: %s", s)
  5733. } else {
  5734. err = fmt.Errorf("Unexpected panic: %+v", r)
  5735. }
  5736. }
  5737. }()
  5738. buff := ctx.Buffer
  5739. buff.WriteUInt8(AllocationCodecVersion) // version
  5740. if ctx.IsStringTable() {
  5741. a := ctx.Table.AddOrGet(target.Cluster)
  5742. buff.WriteInt(a) // write table index
  5743. } else {
  5744. buff.WriteString(target.Cluster) // write string
  5745. }
  5746. if ctx.IsStringTable() {
  5747. b := ctx.Table.AddOrGet(target.Name)
  5748. buff.WriteInt(b) // write table index
  5749. } else {
  5750. buff.WriteString(target.Name) // write string
  5751. }
  5752. return nil
  5753. }
  5754. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5755. // the PVKey type
  5756. func (target *PVKey) UnmarshalBinary(data []byte) error {
  5757. var table []string
  5758. buff := util.NewBufferFromBytes(data)
  5759. // string table header validation
  5760. if isBinaryTag(data, BinaryTagStringTable) {
  5761. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5762. tl := buff.ReadInt() // table length
  5763. if tl > 0 {
  5764. table = make([]string, tl, tl)
  5765. for i := 0; i < tl; i++ {
  5766. table[i] = buff.ReadString()
  5767. }
  5768. }
  5769. }
  5770. ctx := &DecodingContext{
  5771. Buffer: buff,
  5772. Table: table,
  5773. }
  5774. err := target.UnmarshalBinaryWithContext(ctx)
  5775. if err != nil {
  5776. return err
  5777. }
  5778. return nil
  5779. }
  5780. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5781. // the PVKey type
  5782. func (target *PVKey) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5783. // panics are recovered and propagated as errors
  5784. defer func() {
  5785. if r := recover(); r != nil {
  5786. if e, ok := r.(error); ok {
  5787. err = e
  5788. } else if s, ok := r.(string); ok {
  5789. err = fmt.Errorf("Unexpected panic: %s", s)
  5790. } else {
  5791. err = fmt.Errorf("Unexpected panic: %+v", r)
  5792. }
  5793. }
  5794. }()
  5795. buff := ctx.Buffer
  5796. version := buff.ReadUInt8()
  5797. if version > AllocationCodecVersion {
  5798. return fmt.Errorf("Invalid Version Unmarshaling PVKey. Expected %d or less, got %d", AllocationCodecVersion, version)
  5799. }
  5800. var b string
  5801. if ctx.IsStringTable() {
  5802. c := buff.ReadInt() // read string index
  5803. b = ctx.Table[c]
  5804. } else {
  5805. b = buff.ReadString() // read string
  5806. }
  5807. a := b
  5808. target.Cluster = a
  5809. var e string
  5810. if ctx.IsStringTable() {
  5811. f := buff.ReadInt() // read string index
  5812. e = ctx.Table[f]
  5813. } else {
  5814. e = buff.ReadString() // read string
  5815. }
  5816. d := e
  5817. target.Name = d
  5818. return nil
  5819. }
  5820. //--------------------------------------------------------------------------
  5821. // RawAllocationOnlyData
  5822. //--------------------------------------------------------------------------
  5823. // MarshalBinary serializes the internal properties of this RawAllocationOnlyData instance
  5824. // into a byte array
  5825. func (target *RawAllocationOnlyData) MarshalBinary() (data []byte, err error) {
  5826. ctx := &EncodingContext{
  5827. Buffer: util.NewBuffer(),
  5828. Table: nil,
  5829. }
  5830. e := target.MarshalBinaryWithContext(ctx)
  5831. if e != nil {
  5832. return nil, e
  5833. }
  5834. encBytes := ctx.Buffer.Bytes()
  5835. return encBytes, nil
  5836. }
  5837. // MarshalBinaryWithContext serializes the internal properties of this RawAllocationOnlyData instance
  5838. // into a byte array leveraging a predefined context.
  5839. func (target *RawAllocationOnlyData) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5840. // panics are recovered and propagated as errors
  5841. defer func() {
  5842. if r := recover(); r != nil {
  5843. if e, ok := r.(error); ok {
  5844. err = e
  5845. } else if s, ok := r.(string); ok {
  5846. err = fmt.Errorf("Unexpected panic: %s", s)
  5847. } else {
  5848. err = fmt.Errorf("Unexpected panic: %+v", r)
  5849. }
  5850. }
  5851. }()
  5852. buff := ctx.Buffer
  5853. buff.WriteUInt8(AllocationCodecVersion) // version
  5854. buff.WriteFloat64(target.CPUCoreUsageMax) // write float64
  5855. buff.WriteFloat64(target.RAMBytesUsageMax) // write float64
  5856. return nil
  5857. }
  5858. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5859. // the RawAllocationOnlyData type
  5860. func (target *RawAllocationOnlyData) UnmarshalBinary(data []byte) error {
  5861. var table []string
  5862. buff := util.NewBufferFromBytes(data)
  5863. // string table header validation
  5864. if isBinaryTag(data, BinaryTagStringTable) {
  5865. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5866. tl := buff.ReadInt() // table length
  5867. if tl > 0 {
  5868. table = make([]string, tl, tl)
  5869. for i := 0; i < tl; i++ {
  5870. table[i] = buff.ReadString()
  5871. }
  5872. }
  5873. }
  5874. ctx := &DecodingContext{
  5875. Buffer: buff,
  5876. Table: table,
  5877. }
  5878. err := target.UnmarshalBinaryWithContext(ctx)
  5879. if err != nil {
  5880. return err
  5881. }
  5882. return nil
  5883. }
  5884. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5885. // the RawAllocationOnlyData type
  5886. func (target *RawAllocationOnlyData) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5887. // panics are recovered and propagated as errors
  5888. defer func() {
  5889. if r := recover(); r != nil {
  5890. if e, ok := r.(error); ok {
  5891. err = e
  5892. } else if s, ok := r.(string); ok {
  5893. err = fmt.Errorf("Unexpected panic: %s", s)
  5894. } else {
  5895. err = fmt.Errorf("Unexpected panic: %+v", r)
  5896. }
  5897. }
  5898. }()
  5899. buff := ctx.Buffer
  5900. version := buff.ReadUInt8()
  5901. if version > AllocationCodecVersion {
  5902. return fmt.Errorf("Invalid Version Unmarshaling RawAllocationOnlyData. Expected %d or less, got %d", AllocationCodecVersion, version)
  5903. }
  5904. a := buff.ReadFloat64() // read float64
  5905. target.CPUCoreUsageMax = a
  5906. b := buff.ReadFloat64() // read float64
  5907. target.RAMBytesUsageMax = b
  5908. return nil
  5909. }
  5910. //--------------------------------------------------------------------------
  5911. // SharedAsset
  5912. //--------------------------------------------------------------------------
  5913. // MarshalBinary serializes the internal properties of this SharedAsset instance
  5914. // into a byte array
  5915. func (target *SharedAsset) MarshalBinary() (data []byte, err error) {
  5916. ctx := &EncodingContext{
  5917. Buffer: util.NewBuffer(),
  5918. Table: nil,
  5919. }
  5920. e := target.MarshalBinaryWithContext(ctx)
  5921. if e != nil {
  5922. return nil, e
  5923. }
  5924. encBytes := ctx.Buffer.Bytes()
  5925. return encBytes, nil
  5926. }
  5927. // MarshalBinaryWithContext serializes the internal properties of this SharedAsset instance
  5928. // into a byte array leveraging a predefined context.
  5929. func (target *SharedAsset) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5930. // panics are recovered and propagated as errors
  5931. defer func() {
  5932. if r := recover(); r != nil {
  5933. if e, ok := r.(error); ok {
  5934. err = e
  5935. } else if s, ok := r.(string); ok {
  5936. err = fmt.Errorf("Unexpected panic: %s", s)
  5937. } else {
  5938. err = fmt.Errorf("Unexpected panic: %+v", r)
  5939. }
  5940. }
  5941. }()
  5942. buff := ctx.Buffer
  5943. buff.WriteUInt8(AssetsCodecVersion) // version
  5944. if target.Properties == nil {
  5945. buff.WriteUInt8(uint8(0)) // write nil byte
  5946. } else {
  5947. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5948. // --- [begin][write][struct](AssetProperties) ---
  5949. buff.WriteInt(0) // [compatibility, unused]
  5950. errA := target.Properties.MarshalBinaryWithContext(ctx)
  5951. if errA != nil {
  5952. return errA
  5953. }
  5954. // --- [end][write][struct](AssetProperties) ---
  5955. }
  5956. // --- [begin][write][alias](AssetLabels) ---
  5957. if map[string]string(target.Labels) == nil {
  5958. buff.WriteUInt8(uint8(0)) // write nil byte
  5959. } else {
  5960. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5961. // --- [begin][write][map](map[string]string) ---
  5962. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  5963. for v, z := range map[string]string(target.Labels) {
  5964. if ctx.IsStringTable() {
  5965. a := ctx.Table.AddOrGet(v)
  5966. buff.WriteInt(a) // write table index
  5967. } else {
  5968. buff.WriteString(v) // write string
  5969. }
  5970. if ctx.IsStringTable() {
  5971. b := ctx.Table.AddOrGet(z)
  5972. buff.WriteInt(b) // write table index
  5973. } else {
  5974. buff.WriteString(z) // write string
  5975. }
  5976. }
  5977. // --- [end][write][map](map[string]string) ---
  5978. }
  5979. // --- [end][write][alias](AssetLabels) ---
  5980. // --- [begin][write][struct](Window) ---
  5981. buff.WriteInt(0) // [compatibility, unused]
  5982. errB := target.Window.MarshalBinaryWithContext(ctx)
  5983. if errB != nil {
  5984. return errB
  5985. }
  5986. // --- [end][write][struct](Window) ---
  5987. buff.WriteFloat64(target.Cost) // write float64
  5988. return nil
  5989. }
  5990. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5991. // the SharedAsset type
  5992. func (target *SharedAsset) UnmarshalBinary(data []byte) error {
  5993. var table []string
  5994. buff := util.NewBufferFromBytes(data)
  5995. // string table header validation
  5996. if isBinaryTag(data, BinaryTagStringTable) {
  5997. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5998. tl := buff.ReadInt() // table length
  5999. if tl > 0 {
  6000. table = make([]string, tl, tl)
  6001. for i := 0; i < tl; i++ {
  6002. table[i] = buff.ReadString()
  6003. }
  6004. }
  6005. }
  6006. ctx := &DecodingContext{
  6007. Buffer: buff,
  6008. Table: table,
  6009. }
  6010. err := target.UnmarshalBinaryWithContext(ctx)
  6011. if err != nil {
  6012. return err
  6013. }
  6014. return nil
  6015. }
  6016. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6017. // the SharedAsset type
  6018. func (target *SharedAsset) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6019. // panics are recovered and propagated as errors
  6020. defer func() {
  6021. if r := recover(); r != nil {
  6022. if e, ok := r.(error); ok {
  6023. err = e
  6024. } else if s, ok := r.(string); ok {
  6025. err = fmt.Errorf("Unexpected panic: %s", s)
  6026. } else {
  6027. err = fmt.Errorf("Unexpected panic: %+v", r)
  6028. }
  6029. }
  6030. }()
  6031. buff := ctx.Buffer
  6032. version := buff.ReadUInt8()
  6033. if version > AssetsCodecVersion {
  6034. return fmt.Errorf("Invalid Version Unmarshaling SharedAsset. Expected %d or less, got %d", AssetsCodecVersion, version)
  6035. }
  6036. if buff.ReadUInt8() == uint8(0) {
  6037. target.Properties = nil
  6038. } else {
  6039. // --- [begin][read][struct](AssetProperties) ---
  6040. a := &AssetProperties{}
  6041. buff.ReadInt() // [compatibility, unused]
  6042. errA := a.UnmarshalBinaryWithContext(ctx)
  6043. if errA != nil {
  6044. return errA
  6045. }
  6046. target.Properties = a
  6047. // --- [end][read][struct](AssetProperties) ---
  6048. }
  6049. // --- [begin][read][alias](AssetLabels) ---
  6050. var b map[string]string
  6051. if buff.ReadUInt8() == uint8(0) {
  6052. b = nil
  6053. } else {
  6054. // --- [begin][read][map](map[string]string) ---
  6055. d := buff.ReadInt() // map len
  6056. c := make(map[string]string, d)
  6057. for i := 0; i < d; i++ {
  6058. var v string
  6059. var f string
  6060. if ctx.IsStringTable() {
  6061. g := buff.ReadInt() // read string index
  6062. f = ctx.Table[g]
  6063. } else {
  6064. f = buff.ReadString() // read string
  6065. }
  6066. e := f
  6067. v = e
  6068. var z string
  6069. var k string
  6070. if ctx.IsStringTable() {
  6071. l := buff.ReadInt() // read string index
  6072. k = ctx.Table[l]
  6073. } else {
  6074. k = buff.ReadString() // read string
  6075. }
  6076. h := k
  6077. z = h
  6078. c[v] = z
  6079. }
  6080. b = c
  6081. // --- [end][read][map](map[string]string) ---
  6082. }
  6083. target.Labels = AssetLabels(b)
  6084. // --- [end][read][alias](AssetLabels) ---
  6085. // --- [begin][read][struct](Window) ---
  6086. m := &Window{}
  6087. buff.ReadInt() // [compatibility, unused]
  6088. errB := m.UnmarshalBinaryWithContext(ctx)
  6089. if errB != nil {
  6090. return errB
  6091. }
  6092. target.Window = *m
  6093. // --- [end][read][struct](Window) ---
  6094. n := buff.ReadFloat64() // read float64
  6095. target.Cost = n
  6096. return nil
  6097. }
  6098. //--------------------------------------------------------------------------
  6099. // TotalAudit
  6100. //--------------------------------------------------------------------------
  6101. // MarshalBinary serializes the internal properties of this TotalAudit instance
  6102. // into a byte array
  6103. func (target *TotalAudit) MarshalBinary() (data []byte, err error) {
  6104. ctx := &EncodingContext{
  6105. Buffer: util.NewBuffer(),
  6106. Table: nil,
  6107. }
  6108. e := target.MarshalBinaryWithContext(ctx)
  6109. if e != nil {
  6110. return nil, e
  6111. }
  6112. encBytes := ctx.Buffer.Bytes()
  6113. return encBytes, nil
  6114. }
  6115. // MarshalBinaryWithContext serializes the internal properties of this TotalAudit instance
  6116. // into a byte array leveraging a predefined context.
  6117. func (target *TotalAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6118. // panics are recovered and propagated as errors
  6119. defer func() {
  6120. if r := recover(); r != nil {
  6121. if e, ok := r.(error); ok {
  6122. err = e
  6123. } else if s, ok := r.(string); ok {
  6124. err = fmt.Errorf("Unexpected panic: %s", s)
  6125. } else {
  6126. err = fmt.Errorf("Unexpected panic: %+v", r)
  6127. }
  6128. }
  6129. }()
  6130. buff := ctx.Buffer
  6131. buff.WriteUInt8(AuditCodecVersion) // version
  6132. // --- [begin][write][alias](AuditStatus) ---
  6133. if ctx.IsStringTable() {
  6134. a := ctx.Table.AddOrGet(string(target.Status))
  6135. buff.WriteInt(a) // write table index
  6136. } else {
  6137. buff.WriteString(string(target.Status)) // write string
  6138. }
  6139. // --- [end][write][alias](AuditStatus) ---
  6140. if ctx.IsStringTable() {
  6141. b := ctx.Table.AddOrGet(target.Description)
  6142. buff.WriteInt(b) // write table index
  6143. } else {
  6144. buff.WriteString(target.Description) // write string
  6145. }
  6146. // --- [begin][write][reference](time.Time) ---
  6147. c, errA := target.LastRun.MarshalBinary()
  6148. if errA != nil {
  6149. return errA
  6150. }
  6151. buff.WriteInt(len(c))
  6152. buff.WriteBytes(c)
  6153. // --- [end][write][reference](time.Time) ---
  6154. if target.TotalByNode == nil {
  6155. buff.WriteUInt8(uint8(0)) // write nil byte
  6156. } else {
  6157. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6158. // --- [begin][write][map](map[string]*AuditFloatResult) ---
  6159. buff.WriteInt(len(target.TotalByNode)) // map length
  6160. for v, z := range target.TotalByNode {
  6161. if ctx.IsStringTable() {
  6162. d := ctx.Table.AddOrGet(v)
  6163. buff.WriteInt(d) // write table index
  6164. } else {
  6165. buff.WriteString(v) // write string
  6166. }
  6167. if z == nil {
  6168. buff.WriteUInt8(uint8(0)) // write nil byte
  6169. } else {
  6170. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6171. // --- [begin][write][struct](AuditFloatResult) ---
  6172. buff.WriteInt(0) // [compatibility, unused]
  6173. errB := z.MarshalBinaryWithContext(ctx)
  6174. if errB != nil {
  6175. return errB
  6176. }
  6177. // --- [end][write][struct](AuditFloatResult) ---
  6178. }
  6179. }
  6180. // --- [end][write][map](map[string]*AuditFloatResult) ---
  6181. }
  6182. if target.TotalByCluster == nil {
  6183. buff.WriteUInt8(uint8(0)) // write nil byte
  6184. } else {
  6185. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6186. // --- [begin][write][map](map[string]*AuditFloatResult) ---
  6187. buff.WriteInt(len(target.TotalByCluster)) // map length
  6188. for vv, zz := range target.TotalByCluster {
  6189. if ctx.IsStringTable() {
  6190. e := ctx.Table.AddOrGet(vv)
  6191. buff.WriteInt(e) // write table index
  6192. } else {
  6193. buff.WriteString(vv) // write string
  6194. }
  6195. if zz == nil {
  6196. buff.WriteUInt8(uint8(0)) // write nil byte
  6197. } else {
  6198. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6199. // --- [begin][write][struct](AuditFloatResult) ---
  6200. buff.WriteInt(0) // [compatibility, unused]
  6201. errC := zz.MarshalBinaryWithContext(ctx)
  6202. if errC != nil {
  6203. return errC
  6204. }
  6205. // --- [end][write][struct](AuditFloatResult) ---
  6206. }
  6207. }
  6208. // --- [end][write][map](map[string]*AuditFloatResult) ---
  6209. }
  6210. if target.MissingValues == nil {
  6211. buff.WriteUInt8(uint8(0)) // write nil byte
  6212. } else {
  6213. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6214. // --- [begin][write][slice]([]*AuditMissingValue) ---
  6215. buff.WriteInt(len(target.MissingValues)) // array length
  6216. for i := 0; i < len(target.MissingValues); i++ {
  6217. if target.MissingValues[i] == nil {
  6218. buff.WriteUInt8(uint8(0)) // write nil byte
  6219. } else {
  6220. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6221. // --- [begin][write][struct](AuditMissingValue) ---
  6222. buff.WriteInt(0) // [compatibility, unused]
  6223. errD := target.MissingValues[i].MarshalBinaryWithContext(ctx)
  6224. if errD != nil {
  6225. return errD
  6226. }
  6227. // --- [end][write][struct](AuditMissingValue) ---
  6228. }
  6229. }
  6230. // --- [end][write][slice]([]*AuditMissingValue) ---
  6231. }
  6232. return nil
  6233. }
  6234. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6235. // the TotalAudit type
  6236. func (target *TotalAudit) UnmarshalBinary(data []byte) error {
  6237. var table []string
  6238. buff := util.NewBufferFromBytes(data)
  6239. // string table header validation
  6240. if isBinaryTag(data, BinaryTagStringTable) {
  6241. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6242. tl := buff.ReadInt() // table length
  6243. if tl > 0 {
  6244. table = make([]string, tl, tl)
  6245. for i := 0; i < tl; i++ {
  6246. table[i] = buff.ReadString()
  6247. }
  6248. }
  6249. }
  6250. ctx := &DecodingContext{
  6251. Buffer: buff,
  6252. Table: table,
  6253. }
  6254. err := target.UnmarshalBinaryWithContext(ctx)
  6255. if err != nil {
  6256. return err
  6257. }
  6258. return nil
  6259. }
  6260. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6261. // the TotalAudit type
  6262. func (target *TotalAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6263. // panics are recovered and propagated as errors
  6264. defer func() {
  6265. if r := recover(); r != nil {
  6266. if e, ok := r.(error); ok {
  6267. err = e
  6268. } else if s, ok := r.(string); ok {
  6269. err = fmt.Errorf("Unexpected panic: %s", s)
  6270. } else {
  6271. err = fmt.Errorf("Unexpected panic: %+v", r)
  6272. }
  6273. }
  6274. }()
  6275. buff := ctx.Buffer
  6276. version := buff.ReadUInt8()
  6277. if version > AuditCodecVersion {
  6278. return fmt.Errorf("Invalid Version Unmarshaling TotalAudit. Expected %d or less, got %d", AuditCodecVersion, version)
  6279. }
  6280. // --- [begin][read][alias](AuditStatus) ---
  6281. var a string
  6282. var c string
  6283. if ctx.IsStringTable() {
  6284. d := buff.ReadInt() // read string index
  6285. c = ctx.Table[d]
  6286. } else {
  6287. c = buff.ReadString() // read string
  6288. }
  6289. b := c
  6290. a = b
  6291. target.Status = AuditStatus(a)
  6292. // --- [end][read][alias](AuditStatus) ---
  6293. var f string
  6294. if ctx.IsStringTable() {
  6295. g := buff.ReadInt() // read string index
  6296. f = ctx.Table[g]
  6297. } else {
  6298. f = buff.ReadString() // read string
  6299. }
  6300. e := f
  6301. target.Description = e
  6302. // --- [begin][read][reference](time.Time) ---
  6303. h := &time.Time{}
  6304. k := buff.ReadInt() // byte array length
  6305. l := buff.ReadBytes(k) // byte array
  6306. errA := h.UnmarshalBinary(l)
  6307. if errA != nil {
  6308. return errA
  6309. }
  6310. target.LastRun = *h
  6311. // --- [end][read][reference](time.Time) ---
  6312. if buff.ReadUInt8() == uint8(0) {
  6313. target.TotalByNode = nil
  6314. } else {
  6315. // --- [begin][read][map](map[string]*AuditFloatResult) ---
  6316. n := buff.ReadInt() // map len
  6317. m := make(map[string]*AuditFloatResult, n)
  6318. for i := 0; i < n; i++ {
  6319. var v string
  6320. var p string
  6321. if ctx.IsStringTable() {
  6322. q := buff.ReadInt() // read string index
  6323. p = ctx.Table[q]
  6324. } else {
  6325. p = buff.ReadString() // read string
  6326. }
  6327. o := p
  6328. v = o
  6329. var z *AuditFloatResult
  6330. if buff.ReadUInt8() == uint8(0) {
  6331. z = nil
  6332. } else {
  6333. // --- [begin][read][struct](AuditFloatResult) ---
  6334. r := &AuditFloatResult{}
  6335. buff.ReadInt() // [compatibility, unused]
  6336. errB := r.UnmarshalBinaryWithContext(ctx)
  6337. if errB != nil {
  6338. return errB
  6339. }
  6340. z = r
  6341. // --- [end][read][struct](AuditFloatResult) ---
  6342. }
  6343. m[v] = z
  6344. }
  6345. target.TotalByNode = m
  6346. // --- [end][read][map](map[string]*AuditFloatResult) ---
  6347. }
  6348. if buff.ReadUInt8() == uint8(0) {
  6349. target.TotalByCluster = nil
  6350. } else {
  6351. // --- [begin][read][map](map[string]*AuditFloatResult) ---
  6352. t := buff.ReadInt() // map len
  6353. s := make(map[string]*AuditFloatResult, t)
  6354. for j := 0; j < t; j++ {
  6355. var vv string
  6356. var w string
  6357. if ctx.IsStringTable() {
  6358. x := buff.ReadInt() // read string index
  6359. w = ctx.Table[x]
  6360. } else {
  6361. w = buff.ReadString() // read string
  6362. }
  6363. u := w
  6364. vv = u
  6365. var zz *AuditFloatResult
  6366. if buff.ReadUInt8() == uint8(0) {
  6367. zz = nil
  6368. } else {
  6369. // --- [begin][read][struct](AuditFloatResult) ---
  6370. y := &AuditFloatResult{}
  6371. buff.ReadInt() // [compatibility, unused]
  6372. errC := y.UnmarshalBinaryWithContext(ctx)
  6373. if errC != nil {
  6374. return errC
  6375. }
  6376. zz = y
  6377. // --- [end][read][struct](AuditFloatResult) ---
  6378. }
  6379. s[vv] = zz
  6380. }
  6381. target.TotalByCluster = s
  6382. // --- [end][read][map](map[string]*AuditFloatResult) ---
  6383. }
  6384. if buff.ReadUInt8() == uint8(0) {
  6385. target.MissingValues = nil
  6386. } else {
  6387. // --- [begin][read][slice]([]*AuditMissingValue) ---
  6388. bb := buff.ReadInt() // array len
  6389. aa := make([]*AuditMissingValue, bb)
  6390. for ii := 0; ii < bb; ii++ {
  6391. var cc *AuditMissingValue
  6392. if buff.ReadUInt8() == uint8(0) {
  6393. cc = nil
  6394. } else {
  6395. // --- [begin][read][struct](AuditMissingValue) ---
  6396. dd := &AuditMissingValue{}
  6397. buff.ReadInt() // [compatibility, unused]
  6398. errD := dd.UnmarshalBinaryWithContext(ctx)
  6399. if errD != nil {
  6400. return errD
  6401. }
  6402. cc = dd
  6403. // --- [end][read][struct](AuditMissingValue) ---
  6404. }
  6405. aa[ii] = cc
  6406. }
  6407. target.MissingValues = aa
  6408. // --- [end][read][slice]([]*AuditMissingValue) ---
  6409. }
  6410. return nil
  6411. }
  6412. //--------------------------------------------------------------------------
  6413. // Window
  6414. //--------------------------------------------------------------------------
  6415. // MarshalBinary serializes the internal properties of this Window instance
  6416. // into a byte array
  6417. func (target *Window) MarshalBinary() (data []byte, err error) {
  6418. ctx := &EncodingContext{
  6419. Buffer: util.NewBuffer(),
  6420. Table: nil,
  6421. }
  6422. e := target.MarshalBinaryWithContext(ctx)
  6423. if e != nil {
  6424. return nil, e
  6425. }
  6426. encBytes := ctx.Buffer.Bytes()
  6427. return encBytes, nil
  6428. }
  6429. // MarshalBinaryWithContext serializes the internal properties of this Window instance
  6430. // into a byte array leveraging a predefined context.
  6431. func (target *Window) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6432. // panics are recovered and propagated as errors
  6433. defer func() {
  6434. if r := recover(); r != nil {
  6435. if e, ok := r.(error); ok {
  6436. err = e
  6437. } else if s, ok := r.(string); ok {
  6438. err = fmt.Errorf("Unexpected panic: %s", s)
  6439. } else {
  6440. err = fmt.Errorf("Unexpected panic: %+v", r)
  6441. }
  6442. }
  6443. }()
  6444. buff := ctx.Buffer
  6445. buff.WriteUInt8(DefaultCodecVersion) // version
  6446. if target.start == nil {
  6447. buff.WriteUInt8(uint8(0)) // write nil byte
  6448. } else {
  6449. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6450. // --- [begin][write][reference](time.Time) ---
  6451. a, errA := target.start.MarshalBinary()
  6452. if errA != nil {
  6453. return errA
  6454. }
  6455. buff.WriteInt(len(a))
  6456. buff.WriteBytes(a)
  6457. // --- [end][write][reference](time.Time) ---
  6458. }
  6459. if target.end == nil {
  6460. buff.WriteUInt8(uint8(0)) // write nil byte
  6461. } else {
  6462. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6463. // --- [begin][write][reference](time.Time) ---
  6464. b, errB := target.end.MarshalBinary()
  6465. if errB != nil {
  6466. return errB
  6467. }
  6468. buff.WriteInt(len(b))
  6469. buff.WriteBytes(b)
  6470. // --- [end][write][reference](time.Time) ---
  6471. }
  6472. return nil
  6473. }
  6474. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6475. // the Window type
  6476. func (target *Window) UnmarshalBinary(data []byte) error {
  6477. var table []string
  6478. buff := util.NewBufferFromBytes(data)
  6479. // string table header validation
  6480. if isBinaryTag(data, BinaryTagStringTable) {
  6481. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6482. tl := buff.ReadInt() // table length
  6483. if tl > 0 {
  6484. table = make([]string, tl, tl)
  6485. for i := 0; i < tl; i++ {
  6486. table[i] = buff.ReadString()
  6487. }
  6488. }
  6489. }
  6490. ctx := &DecodingContext{
  6491. Buffer: buff,
  6492. Table: table,
  6493. }
  6494. err := target.UnmarshalBinaryWithContext(ctx)
  6495. if err != nil {
  6496. return err
  6497. }
  6498. return nil
  6499. }
  6500. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6501. // the Window type
  6502. func (target *Window) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6503. // panics are recovered and propagated as errors
  6504. defer func() {
  6505. if r := recover(); r != nil {
  6506. if e, ok := r.(error); ok {
  6507. err = e
  6508. } else if s, ok := r.(string); ok {
  6509. err = fmt.Errorf("Unexpected panic: %s", s)
  6510. } else {
  6511. err = fmt.Errorf("Unexpected panic: %+v", r)
  6512. }
  6513. }
  6514. }()
  6515. buff := ctx.Buffer
  6516. version := buff.ReadUInt8()
  6517. if version > DefaultCodecVersion {
  6518. return fmt.Errorf("Invalid Version Unmarshaling Window. Expected %d or less, got %d", DefaultCodecVersion, version)
  6519. }
  6520. if buff.ReadUInt8() == uint8(0) {
  6521. target.start = nil
  6522. } else {
  6523. // --- [begin][read][reference](time.Time) ---
  6524. a := &time.Time{}
  6525. b := buff.ReadInt() // byte array length
  6526. c := buff.ReadBytes(b) // byte array
  6527. errA := a.UnmarshalBinary(c)
  6528. if errA != nil {
  6529. return errA
  6530. }
  6531. target.start = a
  6532. // --- [end][read][reference](time.Time) ---
  6533. }
  6534. if buff.ReadUInt8() == uint8(0) {
  6535. target.end = nil
  6536. } else {
  6537. // --- [begin][read][reference](time.Time) ---
  6538. d := &time.Time{}
  6539. e := buff.ReadInt() // byte array length
  6540. f := buff.ReadBytes(e) // byte array
  6541. errB := d.UnmarshalBinary(f)
  6542. if errB != nil {
  6543. return errB
  6544. }
  6545. target.end = d
  6546. // --- [end][read][reference](time.Time) ---
  6547. }
  6548. return nil
  6549. }