kubecost_codecs.go 246 KB

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