kubecost_codecs.go 245 KB

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