kubecost_codecs.go 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403
  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. "encoding"
  14. "fmt"
  15. util "github.com/kubecost/cost-model/pkg/util"
  16. "reflect"
  17. "strings"
  18. "time"
  19. )
  20. const (
  21. // GeneratorPackageName is the package the generator is targetting
  22. GeneratorPackageName string = "kubecost"
  23. // CodecVersion is the version passed into the generator
  24. CodecVersion uint8 = 13
  25. )
  26. //--------------------------------------------------------------------------
  27. // Type Map
  28. //--------------------------------------------------------------------------
  29. // Generated type map for resolving interface implementations to
  30. // to concrete types
  31. var typeMap map[string]reflect.Type = map[string]reflect.Type{
  32. "Allocation": reflect.TypeOf((*Allocation)(nil)).Elem(),
  33. "AllocationProperties": reflect.TypeOf((*AllocationProperties)(nil)).Elem(),
  34. "AllocationSet": reflect.TypeOf((*AllocationSet)(nil)).Elem(),
  35. "AllocationSetRange": reflect.TypeOf((*AllocationSetRange)(nil)).Elem(),
  36. "Any": reflect.TypeOf((*Any)(nil)).Elem(),
  37. "AssetProperties": reflect.TypeOf((*AssetProperties)(nil)).Elem(),
  38. "AssetSet": reflect.TypeOf((*AssetSet)(nil)).Elem(),
  39. "AssetSetRange": reflect.TypeOf((*AssetSetRange)(nil)).Elem(),
  40. "Breakdown": reflect.TypeOf((*Breakdown)(nil)).Elem(),
  41. "Cloud": reflect.TypeOf((*Cloud)(nil)).Elem(),
  42. "ClusterManagement": reflect.TypeOf((*ClusterManagement)(nil)).Elem(),
  43. "Disk": reflect.TypeOf((*Disk)(nil)).Elem(),
  44. "LoadBalancer": reflect.TypeOf((*LoadBalancer)(nil)).Elem(),
  45. "Network": reflect.TypeOf((*Network)(nil)).Elem(),
  46. "Node": reflect.TypeOf((*Node)(nil)).Elem(),
  47. "PVAllocation": reflect.TypeOf((*PVAllocation)(nil)).Elem(),
  48. "PVKey": reflect.TypeOf((*PVKey)(nil)).Elem(),
  49. "RawAllocationOnlyData": reflect.TypeOf((*RawAllocationOnlyData)(nil)).Elem(),
  50. "SharedAsset": reflect.TypeOf((*SharedAsset)(nil)).Elem(),
  51. "Window": reflect.TypeOf((*Window)(nil)).Elem(),
  52. }
  53. //--------------------------------------------------------------------------
  54. // Type Helpers
  55. //--------------------------------------------------------------------------
  56. // typeToString determines the basic properties of the type, the qualifier, package path, and
  57. // type name, and returns the qualified type
  58. func typeToString(f interface{}) string {
  59. qual := ""
  60. t := reflect.TypeOf(f)
  61. if t.Kind() == reflect.Ptr {
  62. t = t.Elem()
  63. qual = "*"
  64. }
  65. return fmt.Sprintf("%s%s.%s", qual, t.PkgPath(), t.Name())
  66. }
  67. // resolveType uses the name of a type and returns the package, base type name, and whether
  68. // or not it's a pointer.
  69. func resolveType(t string) (pkg string, name string, isPtr bool) {
  70. isPtr = t[:1] == "*"
  71. if isPtr {
  72. t = t[1:]
  73. }
  74. slashIndex := strings.LastIndex(t, "/")
  75. if slashIndex >= 0 {
  76. t = t[slashIndex+1:]
  77. }
  78. parts := strings.Split(t, ".")
  79. if parts[0] == GeneratorPackageName {
  80. parts[0] = ""
  81. }
  82. pkg = parts[0]
  83. name = parts[1]
  84. return
  85. }
  86. //--------------------------------------------------------------------------
  87. // Allocation
  88. //--------------------------------------------------------------------------
  89. // MarshalBinary serializes the internal properties of this Allocation instance
  90. // into a byte array
  91. func (target *Allocation) MarshalBinary() (data []byte, err error) {
  92. // panics are recovered and propagated as errors
  93. defer func() {
  94. if r := recover(); r != nil {
  95. if e, ok := r.(error); ok {
  96. err = e
  97. } else if s, ok := r.(string); ok {
  98. err = fmt.Errorf("Unexpected panic: %s", s)
  99. } else {
  100. err = fmt.Errorf("Unexpected panic: %+v", r)
  101. }
  102. }
  103. }()
  104. buff := util.NewBuffer()
  105. buff.WriteUInt8(CodecVersion) // version
  106. buff.WriteString(target.Name) // write string
  107. if target.Properties == nil {
  108. buff.WriteUInt8(uint8(0)) // write nil byte
  109. } else {
  110. buff.WriteUInt8(uint8(1)) // write non-nil byte
  111. // --- [begin][write][struct](AllocationProperties) ---
  112. a, errA := target.Properties.MarshalBinary()
  113. if errA != nil {
  114. return nil, errA
  115. }
  116. buff.WriteInt(len(a))
  117. buff.WriteBytes(a)
  118. // --- [end][write][struct](AllocationProperties) ---
  119. }
  120. // --- [begin][write][struct](Window) ---
  121. b, errB := target.Window.MarshalBinary()
  122. if errB != nil {
  123. return nil, errB
  124. }
  125. buff.WriteInt(len(b))
  126. buff.WriteBytes(b)
  127. // --- [end][write][struct](Window) ---
  128. // --- [begin][write][reference](time.Time) ---
  129. c, errC := target.Start.MarshalBinary()
  130. if errC != nil {
  131. return nil, errC
  132. }
  133. buff.WriteInt(len(c))
  134. buff.WriteBytes(c)
  135. // --- [end][write][reference](time.Time) ---
  136. // --- [begin][write][reference](time.Time) ---
  137. d, errD := target.End.MarshalBinary()
  138. if errD != nil {
  139. return nil, errD
  140. }
  141. buff.WriteInt(len(d))
  142. buff.WriteBytes(d)
  143. // --- [end][write][reference](time.Time) ---
  144. buff.WriteFloat64(target.CPUCoreHours) // write float64
  145. buff.WriteFloat64(target.CPUCoreRequestAverage) // write float64
  146. buff.WriteFloat64(target.CPUCoreUsageAverage) // write float64
  147. buff.WriteFloat64(target.CPUCost) // write float64
  148. buff.WriteFloat64(target.CPUCostAdjustment) // write float64
  149. buff.WriteFloat64(target.GPUHours) // write float64
  150. buff.WriteFloat64(target.GPUCost) // write float64
  151. buff.WriteFloat64(target.GPUCostAdjustment) // write float64
  152. buff.WriteFloat64(target.NetworkCost) // write float64
  153. buff.WriteFloat64(target.LoadBalancerCost) // write float64
  154. // --- [begin][write][alias](PVAllocations) ---
  155. if map[PVKey]*PVAllocation(target.PVs) == nil {
  156. buff.WriteUInt8(uint8(0)) // write nil byte
  157. } else {
  158. buff.WriteUInt8(uint8(1)) // write non-nil byte
  159. // --- [begin][write][map](map[PVKey]*PVAllocation) ---
  160. buff.WriteInt(len(map[PVKey]*PVAllocation(target.PVs))) // map length
  161. for v, z := range map[PVKey]*PVAllocation(target.PVs) {
  162. // --- [begin][write][struct](PVKey) ---
  163. e, errE := v.MarshalBinary()
  164. if errE != nil {
  165. return nil, errE
  166. }
  167. buff.WriteInt(len(e))
  168. buff.WriteBytes(e)
  169. // --- [end][write][struct](PVKey) ---
  170. if z == nil {
  171. buff.WriteUInt8(uint8(0)) // write nil byte
  172. } else {
  173. buff.WriteUInt8(uint8(1)) // write non-nil byte
  174. // --- [begin][write][struct](PVAllocation) ---
  175. f, errF := z.MarshalBinary()
  176. if errF != nil {
  177. return nil, errF
  178. }
  179. buff.WriteInt(len(f))
  180. buff.WriteBytes(f)
  181. // --- [end][write][struct](PVAllocation) ---
  182. }
  183. }
  184. // --- [end][write][map](map[PVKey]*PVAllocation) ---
  185. }
  186. // --- [end][write][alias](PVAllocations) ---
  187. buff.WriteFloat64(target.PVCostAdjustment) // write float64
  188. buff.WriteFloat64(target.RAMByteHours) // write float64
  189. buff.WriteFloat64(target.RAMBytesRequestAverage) // write float64
  190. buff.WriteFloat64(target.RAMBytesUsageAverage) // write float64
  191. buff.WriteFloat64(target.RAMCost) // write float64
  192. buff.WriteFloat64(target.RAMCostAdjustment) // write float64
  193. buff.WriteFloat64(target.SharedCost) // write float64
  194. buff.WriteFloat64(target.ExternalCost) // write float64
  195. if target.RawAllocationOnly == nil {
  196. buff.WriteUInt8(uint8(0)) // write nil byte
  197. } else {
  198. buff.WriteUInt8(uint8(1)) // write non-nil byte
  199. // --- [begin][write][struct](RawAllocationOnlyData) ---
  200. g, errG := target.RawAllocationOnly.MarshalBinary()
  201. if errG != nil {
  202. return nil, errG
  203. }
  204. buff.WriteInt(len(g))
  205. buff.WriteBytes(g)
  206. // --- [end][write][struct](RawAllocationOnlyData) ---
  207. }
  208. return buff.Bytes(), nil
  209. }
  210. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  211. // the Allocation type
  212. func (target *Allocation) UnmarshalBinary(data []byte) (err error) {
  213. // panics are recovered and propagated as errors
  214. defer func() {
  215. if r := recover(); r != nil {
  216. if e, ok := r.(error); ok {
  217. err = e
  218. } else if s, ok := r.(string); ok {
  219. err = fmt.Errorf("Unexpected panic: %s", s)
  220. } else {
  221. err = fmt.Errorf("Unexpected panic: %+v", r)
  222. }
  223. }
  224. }()
  225. buff := util.NewBufferFromBytes(data)
  226. // Codec Version Check
  227. version := buff.ReadUInt8()
  228. if version != CodecVersion {
  229. return fmt.Errorf("Invalid Version Unmarshaling Allocation. Expected %d, got %d", CodecVersion, version)
  230. }
  231. a := buff.ReadString() // read string
  232. target.Name = a
  233. if buff.ReadUInt8() == uint8(0) {
  234. target.Properties = nil
  235. } else {
  236. // --- [begin][read][struct](AllocationProperties) ---
  237. b := &AllocationProperties{}
  238. c := buff.ReadInt() // byte array length
  239. d := buff.ReadBytes(c) // byte array
  240. errA := b.UnmarshalBinary(d)
  241. if errA != nil {
  242. return errA
  243. }
  244. target.Properties = b
  245. // --- [end][read][struct](AllocationProperties) ---
  246. }
  247. // --- [begin][read][struct](Window) ---
  248. e := &Window{}
  249. f := buff.ReadInt() // byte array length
  250. g := buff.ReadBytes(f) // byte array
  251. errB := e.UnmarshalBinary(g)
  252. if errB != nil {
  253. return errB
  254. }
  255. target.Window = *e
  256. // --- [end][read][struct](Window) ---
  257. // --- [begin][read][reference](time.Time) ---
  258. h := &time.Time{}
  259. k := buff.ReadInt() // byte array length
  260. l := buff.ReadBytes(k) // byte array
  261. errC := h.UnmarshalBinary(l)
  262. if errC != nil {
  263. return errC
  264. }
  265. target.Start = *h
  266. // --- [end][read][reference](time.Time) ---
  267. // --- [begin][read][reference](time.Time) ---
  268. m := &time.Time{}
  269. n := buff.ReadInt() // byte array length
  270. o := buff.ReadBytes(n) // byte array
  271. errD := m.UnmarshalBinary(o)
  272. if errD != nil {
  273. return errD
  274. }
  275. target.End = *m
  276. // --- [end][read][reference](time.Time) ---
  277. p := buff.ReadFloat64() // read float64
  278. target.CPUCoreHours = p
  279. q := buff.ReadFloat64() // read float64
  280. target.CPUCoreRequestAverage = q
  281. r := buff.ReadFloat64() // read float64
  282. target.CPUCoreUsageAverage = r
  283. s := buff.ReadFloat64() // read float64
  284. target.CPUCost = s
  285. t := buff.ReadFloat64() // read float64
  286. target.CPUCostAdjustment = t
  287. u := buff.ReadFloat64() // read float64
  288. target.GPUHours = u
  289. w := buff.ReadFloat64() // read float64
  290. target.GPUCost = w
  291. x := buff.ReadFloat64() // read float64
  292. target.GPUCostAdjustment = x
  293. y := buff.ReadFloat64() // read float64
  294. target.NetworkCost = y
  295. aa := buff.ReadFloat64() // read float64
  296. target.LoadBalancerCost = aa
  297. // --- [begin][read][alias](PVAllocations) ---
  298. var bb map[PVKey]*PVAllocation
  299. if buff.ReadUInt8() == uint8(0) {
  300. bb = nil
  301. } else {
  302. // --- [begin][read][map](map[PVKey]*PVAllocation) ---
  303. dd := buff.ReadInt() // map len
  304. cc := make(map[PVKey]*PVAllocation, dd)
  305. for i := 0; i < dd; i++ {
  306. // --- [begin][read][struct](PVKey) ---
  307. ee := &PVKey{}
  308. ff := buff.ReadInt() // byte array length
  309. gg := buff.ReadBytes(ff) // byte array
  310. errE := ee.UnmarshalBinary(gg)
  311. if errE != nil {
  312. return errE
  313. }
  314. v := *ee
  315. // --- [end][read][struct](PVKey) ---
  316. var z *PVAllocation
  317. if buff.ReadUInt8() == uint8(0) {
  318. z = nil
  319. } else {
  320. // --- [begin][read][struct](PVAllocation) ---
  321. hh := &PVAllocation{}
  322. kk := buff.ReadInt() // byte array length
  323. ll := buff.ReadBytes(kk) // byte array
  324. errF := hh.UnmarshalBinary(ll)
  325. if errF != nil {
  326. return errF
  327. }
  328. z = hh
  329. // --- [end][read][struct](PVAllocation) ---
  330. }
  331. cc[v] = z
  332. }
  333. bb = cc
  334. // --- [end][read][map](map[PVKey]*PVAllocation) ---
  335. }
  336. target.PVs = PVAllocations(bb)
  337. // --- [end][read][alias](PVAllocations) ---
  338. mm := buff.ReadFloat64() // read float64
  339. target.PVCostAdjustment = mm
  340. nn := buff.ReadFloat64() // read float64
  341. target.RAMByteHours = nn
  342. oo := buff.ReadFloat64() // read float64
  343. target.RAMBytesRequestAverage = oo
  344. pp := buff.ReadFloat64() // read float64
  345. target.RAMBytesUsageAverage = pp
  346. qq := buff.ReadFloat64() // read float64
  347. target.RAMCost = qq
  348. rr := buff.ReadFloat64() // read float64
  349. target.RAMCostAdjustment = rr
  350. ss := buff.ReadFloat64() // read float64
  351. target.SharedCost = ss
  352. tt := buff.ReadFloat64() // read float64
  353. target.ExternalCost = tt
  354. if buff.ReadUInt8() == uint8(0) {
  355. target.RawAllocationOnly = nil
  356. } else {
  357. // --- [begin][read][struct](RawAllocationOnlyData) ---
  358. uu := &RawAllocationOnlyData{}
  359. ww := buff.ReadInt() // byte array length
  360. xx := buff.ReadBytes(ww) // byte array
  361. errG := uu.UnmarshalBinary(xx)
  362. if errG != nil {
  363. return errG
  364. }
  365. target.RawAllocationOnly = uu
  366. // --- [end][read][struct](RawAllocationOnlyData) ---
  367. }
  368. return nil
  369. }
  370. //--------------------------------------------------------------------------
  371. // AllocationProperties
  372. //--------------------------------------------------------------------------
  373. // MarshalBinary serializes the internal properties of this AllocationProperties instance
  374. // into a byte array
  375. func (target *AllocationProperties) MarshalBinary() (data []byte, err error) {
  376. // panics are recovered and propagated as errors
  377. defer func() {
  378. if r := recover(); r != nil {
  379. if e, ok := r.(error); ok {
  380. err = e
  381. } else if s, ok := r.(string); ok {
  382. err = fmt.Errorf("Unexpected panic: %s", s)
  383. } else {
  384. err = fmt.Errorf("Unexpected panic: %+v", r)
  385. }
  386. }
  387. }()
  388. buff := util.NewBuffer()
  389. buff.WriteUInt8(CodecVersion) // version
  390. buff.WriteString(target.Cluster) // write string
  391. buff.WriteString(target.Node) // write string
  392. buff.WriteString(target.Container) // write string
  393. buff.WriteString(target.Controller) // write string
  394. buff.WriteString(target.ControllerKind) // write string
  395. buff.WriteString(target.Namespace) // write string
  396. buff.WriteString(target.Pod) // write string
  397. if target.Services == nil {
  398. buff.WriteUInt8(uint8(0)) // write nil byte
  399. } else {
  400. buff.WriteUInt8(uint8(1)) // write non-nil byte
  401. // --- [begin][write][slice]([]string) ---
  402. buff.WriteInt(len(target.Services)) // array length
  403. for i := 0; i < len(target.Services); i++ {
  404. buff.WriteString(target.Services[i]) // write string
  405. }
  406. // --- [end][write][slice]([]string) ---
  407. }
  408. buff.WriteString(target.ProviderID) // write string
  409. // --- [begin][write][alias](AllocationLabels) ---
  410. if map[string]string(target.Labels) == nil {
  411. buff.WriteUInt8(uint8(0)) // write nil byte
  412. } else {
  413. buff.WriteUInt8(uint8(1)) // write non-nil byte
  414. // --- [begin][write][map](map[string]string) ---
  415. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  416. for v, z := range map[string]string(target.Labels) {
  417. buff.WriteString(v) // write string
  418. buff.WriteString(z) // write string
  419. }
  420. // --- [end][write][map](map[string]string) ---
  421. }
  422. // --- [end][write][alias](AllocationLabels) ---
  423. // --- [begin][write][alias](AllocationAnnotations) ---
  424. if map[string]string(target.Annotations) == nil {
  425. buff.WriteUInt8(uint8(0)) // write nil byte
  426. } else {
  427. buff.WriteUInt8(uint8(1)) // write non-nil byte
  428. // --- [begin][write][map](map[string]string) ---
  429. buff.WriteInt(len(map[string]string(target.Annotations))) // map length
  430. for vv, zz := range map[string]string(target.Annotations) {
  431. buff.WriteString(vv) // write string
  432. buff.WriteString(zz) // write string
  433. }
  434. // --- [end][write][map](map[string]string) ---
  435. }
  436. // --- [end][write][alias](AllocationAnnotations) ---
  437. return buff.Bytes(), nil
  438. }
  439. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  440. // the AllocationProperties type
  441. func (target *AllocationProperties) UnmarshalBinary(data []byte) (err error) {
  442. // panics are recovered and propagated as errors
  443. defer func() {
  444. if r := recover(); r != nil {
  445. if e, ok := r.(error); ok {
  446. err = e
  447. } else if s, ok := r.(string); ok {
  448. err = fmt.Errorf("Unexpected panic: %s", s)
  449. } else {
  450. err = fmt.Errorf("Unexpected panic: %+v", r)
  451. }
  452. }
  453. }()
  454. buff := util.NewBufferFromBytes(data)
  455. // Codec Version Check
  456. version := buff.ReadUInt8()
  457. if version != CodecVersion {
  458. return fmt.Errorf("Invalid Version Unmarshaling AllocationProperties. Expected %d, got %d", CodecVersion, version)
  459. }
  460. a := buff.ReadString() // read string
  461. target.Cluster = a
  462. b := buff.ReadString() // read string
  463. target.Node = b
  464. c := buff.ReadString() // read string
  465. target.Container = c
  466. d := buff.ReadString() // read string
  467. target.Controller = d
  468. e := buff.ReadString() // read string
  469. target.ControllerKind = e
  470. f := buff.ReadString() // read string
  471. target.Namespace = f
  472. g := buff.ReadString() // read string
  473. target.Pod = g
  474. if buff.ReadUInt8() == uint8(0) {
  475. target.Services = nil
  476. } else {
  477. // --- [begin][read][slice]([]string) ---
  478. k := buff.ReadInt() // array len
  479. h := make([]string, k)
  480. for i := 0; i < k; i++ {
  481. var l string
  482. m := buff.ReadString() // read string
  483. l = m
  484. h[i] = l
  485. }
  486. target.Services = h
  487. // --- [end][read][slice]([]string) ---
  488. }
  489. n := buff.ReadString() // read string
  490. target.ProviderID = n
  491. // --- [begin][read][alias](AllocationLabels) ---
  492. var o map[string]string
  493. if buff.ReadUInt8() == uint8(0) {
  494. o = nil
  495. } else {
  496. // --- [begin][read][map](map[string]string) ---
  497. q := buff.ReadInt() // map len
  498. p := make(map[string]string, q)
  499. for j := 0; j < q; j++ {
  500. var v string
  501. r := buff.ReadString() // read string
  502. v = r
  503. var z string
  504. s := buff.ReadString() // read string
  505. z = s
  506. p[v] = z
  507. }
  508. o = p
  509. // --- [end][read][map](map[string]string) ---
  510. }
  511. target.Labels = AllocationLabels(o)
  512. // --- [end][read][alias](AllocationLabels) ---
  513. // --- [begin][read][alias](AllocationAnnotations) ---
  514. var t map[string]string
  515. if buff.ReadUInt8() == uint8(0) {
  516. t = nil
  517. } else {
  518. // --- [begin][read][map](map[string]string) ---
  519. w := buff.ReadInt() // map len
  520. u := make(map[string]string, w)
  521. for ii := 0; ii < w; ii++ {
  522. var vv string
  523. x := buff.ReadString() // read string
  524. vv = x
  525. var zz string
  526. y := buff.ReadString() // read string
  527. zz = y
  528. u[vv] = zz
  529. }
  530. t = u
  531. // --- [end][read][map](map[string]string) ---
  532. }
  533. target.Annotations = AllocationAnnotations(t)
  534. // --- [end][read][alias](AllocationAnnotations) ---
  535. return nil
  536. }
  537. //--------------------------------------------------------------------------
  538. // AllocationSet
  539. //--------------------------------------------------------------------------
  540. // MarshalBinary serializes the internal properties of this AllocationSet instance
  541. // into a byte array
  542. func (target *AllocationSet) MarshalBinary() (data []byte, err error) {
  543. // panics are recovered and propagated as errors
  544. defer func() {
  545. if r := recover(); r != nil {
  546. if e, ok := r.(error); ok {
  547. err = e
  548. } else if s, ok := r.(string); ok {
  549. err = fmt.Errorf("Unexpected panic: %s", s)
  550. } else {
  551. err = fmt.Errorf("Unexpected panic: %+v", r)
  552. }
  553. }
  554. }()
  555. buff := util.NewBuffer()
  556. buff.WriteUInt8(CodecVersion) // version
  557. if target.allocations == nil {
  558. buff.WriteUInt8(uint8(0)) // write nil byte
  559. } else {
  560. buff.WriteUInt8(uint8(1)) // write non-nil byte
  561. // --- [begin][write][map](map[string]*Allocation) ---
  562. buff.WriteInt(len(target.allocations)) // map length
  563. for v, z := range target.allocations {
  564. buff.WriteString(v) // write string
  565. if z == nil {
  566. buff.WriteUInt8(uint8(0)) // write nil byte
  567. } else {
  568. buff.WriteUInt8(uint8(1)) // write non-nil byte
  569. // --- [begin][write][struct](Allocation) ---
  570. a, errA := z.MarshalBinary()
  571. if errA != nil {
  572. return nil, errA
  573. }
  574. buff.WriteInt(len(a))
  575. buff.WriteBytes(a)
  576. // --- [end][write][struct](Allocation) ---
  577. }
  578. }
  579. // --- [end][write][map](map[string]*Allocation) ---
  580. }
  581. if target.externalKeys == nil {
  582. buff.WriteUInt8(uint8(0)) // write nil byte
  583. } else {
  584. buff.WriteUInt8(uint8(1)) // write non-nil byte
  585. // --- [begin][write][map](map[string]bool) ---
  586. buff.WriteInt(len(target.externalKeys)) // map length
  587. for vv, zz := range target.externalKeys {
  588. buff.WriteString(vv) // write string
  589. buff.WriteBool(zz) // write bool
  590. }
  591. // --- [end][write][map](map[string]bool) ---
  592. }
  593. if target.idleKeys == nil {
  594. buff.WriteUInt8(uint8(0)) // write nil byte
  595. } else {
  596. buff.WriteUInt8(uint8(1)) // write non-nil byte
  597. // --- [begin][write][map](map[string]bool) ---
  598. buff.WriteInt(len(target.idleKeys)) // map length
  599. for vvv, zzz := range target.idleKeys {
  600. buff.WriteString(vvv) // write string
  601. buff.WriteBool(zzz) // write bool
  602. }
  603. // --- [end][write][map](map[string]bool) ---
  604. }
  605. // --- [begin][write][struct](Window) ---
  606. b, errB := target.Window.MarshalBinary()
  607. if errB != nil {
  608. return nil, errB
  609. }
  610. buff.WriteInt(len(b))
  611. buff.WriteBytes(b)
  612. // --- [end][write][struct](Window) ---
  613. if target.Warnings == nil {
  614. buff.WriteUInt8(uint8(0)) // write nil byte
  615. } else {
  616. buff.WriteUInt8(uint8(1)) // write non-nil byte
  617. // --- [begin][write][slice]([]string) ---
  618. buff.WriteInt(len(target.Warnings)) // array length
  619. for i := 0; i < len(target.Warnings); i++ {
  620. buff.WriteString(target.Warnings[i]) // write string
  621. }
  622. // --- [end][write][slice]([]string) ---
  623. }
  624. if target.Errors == nil {
  625. buff.WriteUInt8(uint8(0)) // write nil byte
  626. } else {
  627. buff.WriteUInt8(uint8(1)) // write non-nil byte
  628. // --- [begin][write][slice]([]string) ---
  629. buff.WriteInt(len(target.Errors)) // array length
  630. for j := 0; j < len(target.Errors); j++ {
  631. buff.WriteString(target.Errors[j]) // write string
  632. }
  633. // --- [end][write][slice]([]string) ---
  634. }
  635. return buff.Bytes(), nil
  636. }
  637. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  638. // the AllocationSet type
  639. func (target *AllocationSet) UnmarshalBinary(data []byte) (err error) {
  640. // panics are recovered and propagated as errors
  641. defer func() {
  642. if r := recover(); r != nil {
  643. if e, ok := r.(error); ok {
  644. err = e
  645. } else if s, ok := r.(string); ok {
  646. err = fmt.Errorf("Unexpected panic: %s", s)
  647. } else {
  648. err = fmt.Errorf("Unexpected panic: %+v", r)
  649. }
  650. }
  651. }()
  652. buff := util.NewBufferFromBytes(data)
  653. // Codec Version Check
  654. version := buff.ReadUInt8()
  655. if version != CodecVersion {
  656. return fmt.Errorf("Invalid Version Unmarshaling AllocationSet. Expected %d, got %d", CodecVersion, version)
  657. }
  658. if buff.ReadUInt8() == uint8(0) {
  659. target.allocations = nil
  660. } else {
  661. // --- [begin][read][map](map[string]*Allocation) ---
  662. b := buff.ReadInt() // map len
  663. a := make(map[string]*Allocation, b)
  664. for i := 0; i < b; i++ {
  665. var v string
  666. c := buff.ReadString() // read string
  667. v = c
  668. var z *Allocation
  669. if buff.ReadUInt8() == uint8(0) {
  670. z = nil
  671. } else {
  672. // --- [begin][read][struct](Allocation) ---
  673. d := &Allocation{}
  674. e := buff.ReadInt() // byte array length
  675. f := buff.ReadBytes(e) // byte array
  676. errA := d.UnmarshalBinary(f)
  677. if errA != nil {
  678. return errA
  679. }
  680. z = d
  681. // --- [end][read][struct](Allocation) ---
  682. }
  683. a[v] = z
  684. }
  685. target.allocations = a
  686. // --- [end][read][map](map[string]*Allocation) ---
  687. }
  688. if buff.ReadUInt8() == uint8(0) {
  689. target.externalKeys = nil
  690. } else {
  691. // --- [begin][read][map](map[string]bool) ---
  692. h := buff.ReadInt() // map len
  693. g := make(map[string]bool, h)
  694. for j := 0; j < h; j++ {
  695. var vv string
  696. k := buff.ReadString() // read string
  697. vv = k
  698. var zz bool
  699. l := buff.ReadBool() // read bool
  700. zz = l
  701. g[vv] = zz
  702. }
  703. target.externalKeys = g
  704. // --- [end][read][map](map[string]bool) ---
  705. }
  706. if buff.ReadUInt8() == uint8(0) {
  707. target.idleKeys = nil
  708. } else {
  709. // --- [begin][read][map](map[string]bool) ---
  710. n := buff.ReadInt() // map len
  711. m := make(map[string]bool, n)
  712. for ii := 0; ii < n; ii++ {
  713. var vvv string
  714. o := buff.ReadString() // read string
  715. vvv = o
  716. var zzz bool
  717. p := buff.ReadBool() // read bool
  718. zzz = p
  719. m[vvv] = zzz
  720. }
  721. target.idleKeys = m
  722. // --- [end][read][map](map[string]bool) ---
  723. }
  724. // --- [begin][read][struct](Window) ---
  725. q := &Window{}
  726. r := buff.ReadInt() // byte array length
  727. s := buff.ReadBytes(r) // byte array
  728. errB := q.UnmarshalBinary(s)
  729. if errB != nil {
  730. return errB
  731. }
  732. target.Window = *q
  733. // --- [end][read][struct](Window) ---
  734. if buff.ReadUInt8() == uint8(0) {
  735. target.Warnings = nil
  736. } else {
  737. // --- [begin][read][slice]([]string) ---
  738. u := buff.ReadInt() // array len
  739. t := make([]string, u)
  740. for jj := 0; jj < u; jj++ {
  741. var w string
  742. x := buff.ReadString() // read string
  743. w = x
  744. t[jj] = w
  745. }
  746. target.Warnings = t
  747. // --- [end][read][slice]([]string) ---
  748. }
  749. if buff.ReadUInt8() == uint8(0) {
  750. target.Errors = nil
  751. } else {
  752. // --- [begin][read][slice]([]string) ---
  753. aa := buff.ReadInt() // array len
  754. y := make([]string, aa)
  755. for iii := 0; iii < aa; iii++ {
  756. var bb string
  757. cc := buff.ReadString() // read string
  758. bb = cc
  759. y[iii] = bb
  760. }
  761. target.Errors = y
  762. // --- [end][read][slice]([]string) ---
  763. }
  764. return nil
  765. }
  766. //--------------------------------------------------------------------------
  767. // AllocationSetRange
  768. //--------------------------------------------------------------------------
  769. // MarshalBinary serializes the internal properties of this AllocationSetRange instance
  770. // into a byte array
  771. func (target *AllocationSetRange) MarshalBinary() (data []byte, err error) {
  772. // panics are recovered and propagated as errors
  773. defer func() {
  774. if r := recover(); r != nil {
  775. if e, ok := r.(error); ok {
  776. err = e
  777. } else if s, ok := r.(string); ok {
  778. err = fmt.Errorf("Unexpected panic: %s", s)
  779. } else {
  780. err = fmt.Errorf("Unexpected panic: %+v", r)
  781. }
  782. }
  783. }()
  784. buff := util.NewBuffer()
  785. buff.WriteUInt8(CodecVersion) // version
  786. if target.allocations == nil {
  787. buff.WriteUInt8(uint8(0)) // write nil byte
  788. } else {
  789. buff.WriteUInt8(uint8(1)) // write non-nil byte
  790. // --- [begin][write][slice]([]*AllocationSet) ---
  791. buff.WriteInt(len(target.allocations)) // array length
  792. for i := 0; i < len(target.allocations); i++ {
  793. if target.allocations[i] == nil {
  794. buff.WriteUInt8(uint8(0)) // write nil byte
  795. } else {
  796. buff.WriteUInt8(uint8(1)) // write non-nil byte
  797. // --- [begin][write][struct](AllocationSet) ---
  798. a, errA := target.allocations[i].MarshalBinary()
  799. if errA != nil {
  800. return nil, errA
  801. }
  802. buff.WriteInt(len(a))
  803. buff.WriteBytes(a)
  804. // --- [end][write][struct](AllocationSet) ---
  805. }
  806. }
  807. // --- [end][write][slice]([]*AllocationSet) ---
  808. }
  809. return buff.Bytes(), nil
  810. }
  811. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  812. // the AllocationSetRange type
  813. func (target *AllocationSetRange) UnmarshalBinary(data []byte) (err error) {
  814. // panics are recovered and propagated as errors
  815. defer func() {
  816. if r := recover(); r != nil {
  817. if e, ok := r.(error); ok {
  818. err = e
  819. } else if s, ok := r.(string); ok {
  820. err = fmt.Errorf("Unexpected panic: %s", s)
  821. } else {
  822. err = fmt.Errorf("Unexpected panic: %+v", r)
  823. }
  824. }
  825. }()
  826. buff := util.NewBufferFromBytes(data)
  827. // Codec Version Check
  828. version := buff.ReadUInt8()
  829. if version != CodecVersion {
  830. return fmt.Errorf("Invalid Version Unmarshaling AllocationSetRange. Expected %d, got %d", CodecVersion, version)
  831. }
  832. if buff.ReadUInt8() == uint8(0) {
  833. target.allocations = nil
  834. } else {
  835. // --- [begin][read][slice]([]*AllocationSet) ---
  836. b := buff.ReadInt() // array len
  837. a := make([]*AllocationSet, b)
  838. for i := 0; i < b; i++ {
  839. var c *AllocationSet
  840. if buff.ReadUInt8() == uint8(0) {
  841. c = nil
  842. } else {
  843. // --- [begin][read][struct](AllocationSet) ---
  844. d := &AllocationSet{}
  845. e := buff.ReadInt() // byte array length
  846. f := buff.ReadBytes(e) // byte array
  847. errA := d.UnmarshalBinary(f)
  848. if errA != nil {
  849. return errA
  850. }
  851. c = d
  852. // --- [end][read][struct](AllocationSet) ---
  853. }
  854. a[i] = c
  855. }
  856. target.allocations = a
  857. // --- [end][read][slice]([]*AllocationSet) ---
  858. }
  859. return nil
  860. }
  861. //--------------------------------------------------------------------------
  862. // Any
  863. //--------------------------------------------------------------------------
  864. // MarshalBinary serializes the internal properties of this Any instance
  865. // into a byte array
  866. func (target *Any) MarshalBinary() (data []byte, err error) {
  867. // panics are recovered and propagated as errors
  868. defer func() {
  869. if r := recover(); r != nil {
  870. if e, ok := r.(error); ok {
  871. err = e
  872. } else if s, ok := r.(string); ok {
  873. err = fmt.Errorf("Unexpected panic: %s", s)
  874. } else {
  875. err = fmt.Errorf("Unexpected panic: %+v", r)
  876. }
  877. }
  878. }()
  879. buff := util.NewBuffer()
  880. buff.WriteUInt8(CodecVersion) // version
  881. // --- [begin][write][alias](AssetLabels) ---
  882. if map[string]string(target.labels) == nil {
  883. buff.WriteUInt8(uint8(0)) // write nil byte
  884. } else {
  885. buff.WriteUInt8(uint8(1)) // write non-nil byte
  886. // --- [begin][write][map](map[string]string) ---
  887. buff.WriteInt(len(map[string]string(target.labels))) // map length
  888. for v, z := range map[string]string(target.labels) {
  889. buff.WriteString(v) // write string
  890. buff.WriteString(z) // write string
  891. }
  892. // --- [end][write][map](map[string]string) ---
  893. }
  894. // --- [end][write][alias](AssetLabels) ---
  895. if target.properties == nil {
  896. buff.WriteUInt8(uint8(0)) // write nil byte
  897. } else {
  898. buff.WriteUInt8(uint8(1)) // write non-nil byte
  899. // --- [begin][write][struct](AssetProperties) ---
  900. a, errA := target.properties.MarshalBinary()
  901. if errA != nil {
  902. return nil, errA
  903. }
  904. buff.WriteInt(len(a))
  905. buff.WriteBytes(a)
  906. // --- [end][write][struct](AssetProperties) ---
  907. }
  908. // --- [begin][write][reference](time.Time) ---
  909. b, errB := target.start.MarshalBinary()
  910. if errB != nil {
  911. return nil, errB
  912. }
  913. buff.WriteInt(len(b))
  914. buff.WriteBytes(b)
  915. // --- [end][write][reference](time.Time) ---
  916. // --- [begin][write][reference](time.Time) ---
  917. c, errC := target.end.MarshalBinary()
  918. if errC != nil {
  919. return nil, errC
  920. }
  921. buff.WriteInt(len(c))
  922. buff.WriteBytes(c)
  923. // --- [end][write][reference](time.Time) ---
  924. // --- [begin][write][struct](Window) ---
  925. d, errD := target.window.MarshalBinary()
  926. if errD != nil {
  927. return nil, errD
  928. }
  929. buff.WriteInt(len(d))
  930. buff.WriteBytes(d)
  931. // --- [end][write][struct](Window) ---
  932. buff.WriteFloat64(target.adjustment) // write float64
  933. buff.WriteFloat64(target.Cost) // write float64
  934. return buff.Bytes(), nil
  935. }
  936. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  937. // the Any type
  938. func (target *Any) UnmarshalBinary(data []byte) (err error) {
  939. // panics are recovered and propagated as errors
  940. defer func() {
  941. if r := recover(); r != nil {
  942. if e, ok := r.(error); ok {
  943. err = e
  944. } else if s, ok := r.(string); ok {
  945. err = fmt.Errorf("Unexpected panic: %s", s)
  946. } else {
  947. err = fmt.Errorf("Unexpected panic: %+v", r)
  948. }
  949. }
  950. }()
  951. buff := util.NewBufferFromBytes(data)
  952. // Codec Version Check
  953. version := buff.ReadUInt8()
  954. if version != CodecVersion {
  955. return fmt.Errorf("Invalid Version Unmarshaling Any. Expected %d, got %d", CodecVersion, version)
  956. }
  957. // --- [begin][read][alias](AssetLabels) ---
  958. var a map[string]string
  959. if buff.ReadUInt8() == uint8(0) {
  960. a = nil
  961. } else {
  962. // --- [begin][read][map](map[string]string) ---
  963. c := buff.ReadInt() // map len
  964. b := make(map[string]string, c)
  965. for i := 0; i < c; i++ {
  966. var v string
  967. d := buff.ReadString() // read string
  968. v = d
  969. var z string
  970. e := buff.ReadString() // read string
  971. z = e
  972. b[v] = z
  973. }
  974. a = b
  975. // --- [end][read][map](map[string]string) ---
  976. }
  977. target.labels = AssetLabels(a)
  978. // --- [end][read][alias](AssetLabels) ---
  979. if buff.ReadUInt8() == uint8(0) {
  980. target.properties = nil
  981. } else {
  982. // --- [begin][read][struct](AssetProperties) ---
  983. f := &AssetProperties{}
  984. g := buff.ReadInt() // byte array length
  985. h := buff.ReadBytes(g) // byte array
  986. errA := f.UnmarshalBinary(h)
  987. if errA != nil {
  988. return errA
  989. }
  990. target.properties = f
  991. // --- [end][read][struct](AssetProperties) ---
  992. }
  993. // --- [begin][read][reference](time.Time) ---
  994. k := &time.Time{}
  995. l := buff.ReadInt() // byte array length
  996. m := buff.ReadBytes(l) // byte array
  997. errB := k.UnmarshalBinary(m)
  998. if errB != nil {
  999. return errB
  1000. }
  1001. target.start = *k
  1002. // --- [end][read][reference](time.Time) ---
  1003. // --- [begin][read][reference](time.Time) ---
  1004. n := &time.Time{}
  1005. o := buff.ReadInt() // byte array length
  1006. p := buff.ReadBytes(o) // byte array
  1007. errC := n.UnmarshalBinary(p)
  1008. if errC != nil {
  1009. return errC
  1010. }
  1011. target.end = *n
  1012. // --- [end][read][reference](time.Time) ---
  1013. // --- [begin][read][struct](Window) ---
  1014. q := &Window{}
  1015. r := buff.ReadInt() // byte array length
  1016. s := buff.ReadBytes(r) // byte array
  1017. errD := q.UnmarshalBinary(s)
  1018. if errD != nil {
  1019. return errD
  1020. }
  1021. target.window = *q
  1022. // --- [end][read][struct](Window) ---
  1023. t := buff.ReadFloat64() // read float64
  1024. target.adjustment = t
  1025. u := buff.ReadFloat64() // read float64
  1026. target.Cost = u
  1027. return nil
  1028. }
  1029. //--------------------------------------------------------------------------
  1030. // AssetProperties
  1031. //--------------------------------------------------------------------------
  1032. // MarshalBinary serializes the internal properties of this AssetProperties instance
  1033. // into a byte array
  1034. func (target *AssetProperties) MarshalBinary() (data []byte, err error) {
  1035. // panics are recovered and propagated as errors
  1036. defer func() {
  1037. if r := recover(); r != nil {
  1038. if e, ok := r.(error); ok {
  1039. err = e
  1040. } else if s, ok := r.(string); ok {
  1041. err = fmt.Errorf("Unexpected panic: %s", s)
  1042. } else {
  1043. err = fmt.Errorf("Unexpected panic: %+v", r)
  1044. }
  1045. }
  1046. }()
  1047. buff := util.NewBuffer()
  1048. buff.WriteUInt8(CodecVersion) // version
  1049. buff.WriteString(target.Category) // write string
  1050. buff.WriteString(target.Provider) // write string
  1051. buff.WriteString(target.Account) // write string
  1052. buff.WriteString(target.Project) // write string
  1053. buff.WriteString(target.Service) // write string
  1054. buff.WriteString(target.Cluster) // write string
  1055. buff.WriteString(target.Name) // write string
  1056. buff.WriteString(target.ProviderID) // write string
  1057. return buff.Bytes(), nil
  1058. }
  1059. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1060. // the AssetProperties type
  1061. func (target *AssetProperties) UnmarshalBinary(data []byte) (err error) {
  1062. // panics are recovered and propagated as errors
  1063. defer func() {
  1064. if r := recover(); r != nil {
  1065. if e, ok := r.(error); ok {
  1066. err = e
  1067. } else if s, ok := r.(string); ok {
  1068. err = fmt.Errorf("Unexpected panic: %s", s)
  1069. } else {
  1070. err = fmt.Errorf("Unexpected panic: %+v", r)
  1071. }
  1072. }
  1073. }()
  1074. buff := util.NewBufferFromBytes(data)
  1075. // Codec Version Check
  1076. version := buff.ReadUInt8()
  1077. if version != CodecVersion {
  1078. return fmt.Errorf("Invalid Version Unmarshaling AssetProperties. Expected %d, got %d", CodecVersion, version)
  1079. }
  1080. a := buff.ReadString() // read string
  1081. target.Category = a
  1082. b := buff.ReadString() // read string
  1083. target.Provider = b
  1084. c := buff.ReadString() // read string
  1085. target.Account = c
  1086. d := buff.ReadString() // read string
  1087. target.Project = d
  1088. e := buff.ReadString() // read string
  1089. target.Service = e
  1090. f := buff.ReadString() // read string
  1091. target.Cluster = f
  1092. g := buff.ReadString() // read string
  1093. target.Name = g
  1094. h := buff.ReadString() // read string
  1095. target.ProviderID = h
  1096. return nil
  1097. }
  1098. //--------------------------------------------------------------------------
  1099. // AssetSet
  1100. //--------------------------------------------------------------------------
  1101. // MarshalBinary serializes the internal properties of this AssetSet instance
  1102. // into a byte array
  1103. func (target *AssetSet) MarshalBinary() (data []byte, err error) {
  1104. // panics are recovered and propagated as errors
  1105. defer func() {
  1106. if r := recover(); r != nil {
  1107. if e, ok := r.(error); ok {
  1108. err = e
  1109. } else if s, ok := r.(string); ok {
  1110. err = fmt.Errorf("Unexpected panic: %s", s)
  1111. } else {
  1112. err = fmt.Errorf("Unexpected panic: %+v", r)
  1113. }
  1114. }
  1115. }()
  1116. buff := util.NewBuffer()
  1117. buff.WriteUInt8(CodecVersion) // version
  1118. if target.aggregateBy == nil {
  1119. buff.WriteUInt8(uint8(0)) // write nil byte
  1120. } else {
  1121. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1122. // --- [begin][write][slice]([]string) ---
  1123. buff.WriteInt(len(target.aggregateBy)) // array length
  1124. for i := 0; i < len(target.aggregateBy); i++ {
  1125. buff.WriteString(target.aggregateBy[i]) // write string
  1126. }
  1127. // --- [end][write][slice]([]string) ---
  1128. }
  1129. if target.assets == nil {
  1130. buff.WriteUInt8(uint8(0)) // write nil byte
  1131. } else {
  1132. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1133. // --- [begin][write][map](map[string]Asset) ---
  1134. buff.WriteInt(len(target.assets)) // map length
  1135. for v, z := range target.assets {
  1136. buff.WriteString(v) // write string
  1137. if z == nil {
  1138. buff.WriteUInt8(uint8(0)) // write nil byte
  1139. } else {
  1140. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1141. // --- [begin][write][interface](Asset) ---
  1142. a := reflect.ValueOf(z).Interface()
  1143. b, okA := a.(encoding.BinaryMarshaler)
  1144. if !okA {
  1145. return nil, fmt.Errorf("Type: %s does not implement encoding.BinaryMarshaler", typeToString(z))
  1146. }
  1147. c, errA := b.MarshalBinary()
  1148. if errA != nil {
  1149. return nil, errA
  1150. }
  1151. buff.WriteString(typeToString(z))
  1152. buff.WriteInt(len(c))
  1153. buff.WriteBytes(c)
  1154. // --- [end][write][interface](Asset) ---
  1155. }
  1156. }
  1157. // --- [end][write][map](map[string]Asset) ---
  1158. }
  1159. // --- [begin][write][struct](Window) ---
  1160. d, errB := target.Window.MarshalBinary()
  1161. if errB != nil {
  1162. return nil, errB
  1163. }
  1164. buff.WriteInt(len(d))
  1165. buff.WriteBytes(d)
  1166. // --- [end][write][struct](Window) ---
  1167. if target.Warnings == nil {
  1168. buff.WriteUInt8(uint8(0)) // write nil byte
  1169. } else {
  1170. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1171. // --- [begin][write][slice]([]string) ---
  1172. buff.WriteInt(len(target.Warnings)) // array length
  1173. for j := 0; j < len(target.Warnings); j++ {
  1174. buff.WriteString(target.Warnings[j]) // write string
  1175. }
  1176. // --- [end][write][slice]([]string) ---
  1177. }
  1178. if target.Errors == nil {
  1179. buff.WriteUInt8(uint8(0)) // write nil byte
  1180. } else {
  1181. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1182. // --- [begin][write][slice]([]string) ---
  1183. buff.WriteInt(len(target.Errors)) // array length
  1184. for ii := 0; ii < len(target.Errors); ii++ {
  1185. buff.WriteString(target.Errors[ii]) // write string
  1186. }
  1187. // --- [end][write][slice]([]string) ---
  1188. }
  1189. return buff.Bytes(), nil
  1190. }
  1191. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1192. // the AssetSet type
  1193. func (target *AssetSet) UnmarshalBinary(data []byte) (err error) {
  1194. // panics are recovered and propagated as errors
  1195. defer func() {
  1196. if r := recover(); r != nil {
  1197. if e, ok := r.(error); ok {
  1198. err = e
  1199. } else if s, ok := r.(string); ok {
  1200. err = fmt.Errorf("Unexpected panic: %s", s)
  1201. } else {
  1202. err = fmt.Errorf("Unexpected panic: %+v", r)
  1203. }
  1204. }
  1205. }()
  1206. buff := util.NewBufferFromBytes(data)
  1207. // Codec Version Check
  1208. version := buff.ReadUInt8()
  1209. if version != CodecVersion {
  1210. return fmt.Errorf("Invalid Version Unmarshaling AssetSet. Expected %d, got %d", CodecVersion, version)
  1211. }
  1212. if buff.ReadUInt8() == uint8(0) {
  1213. target.aggregateBy = nil
  1214. } else {
  1215. // --- [begin][read][slice]([]string) ---
  1216. b := buff.ReadInt() // array len
  1217. a := make([]string, b)
  1218. for i := 0; i < b; i++ {
  1219. var c string
  1220. d := buff.ReadString() // read string
  1221. c = d
  1222. a[i] = c
  1223. }
  1224. target.aggregateBy = a
  1225. // --- [end][read][slice]([]string) ---
  1226. }
  1227. if buff.ReadUInt8() == uint8(0) {
  1228. target.assets = nil
  1229. } else {
  1230. // --- [begin][read][map](map[string]Asset) ---
  1231. f := buff.ReadInt() // map len
  1232. e := make(map[string]Asset, f)
  1233. for j := 0; j < f; j++ {
  1234. var v string
  1235. g := buff.ReadString() // read string
  1236. v = g
  1237. var z Asset
  1238. if buff.ReadUInt8() == uint8(0) {
  1239. z = nil
  1240. } else {
  1241. // --- [begin][read][interface](Asset) ---
  1242. h := buff.ReadString()
  1243. _, k, _ := resolveType(h)
  1244. if _, ok := typeMap[k]; !ok {
  1245. return fmt.Errorf("Unknown Type: %s", k)
  1246. }
  1247. l, okA := reflect.New(typeMap[k]).Interface().(interface{ UnmarshalBinary([]byte) error })
  1248. if !okA {
  1249. return fmt.Errorf("Type: %s does not implement UnmarshalBinary([]byte) error", k)
  1250. }
  1251. m := buff.ReadInt() // byte array length
  1252. n := buff.ReadBytes(m) // byte array
  1253. errA := l.UnmarshalBinary(n)
  1254. if errA != nil {
  1255. return errA
  1256. }
  1257. z = l.(Asset)
  1258. // --- [end][read][interface](Asset) ---
  1259. }
  1260. e[v] = z
  1261. }
  1262. target.assets = e
  1263. // --- [end][read][map](map[string]Asset) ---
  1264. }
  1265. // --- [begin][read][struct](Window) ---
  1266. o := &Window{}
  1267. p := buff.ReadInt() // byte array length
  1268. q := buff.ReadBytes(p) // byte array
  1269. errB := o.UnmarshalBinary(q)
  1270. if errB != nil {
  1271. return errB
  1272. }
  1273. target.Window = *o
  1274. // --- [end][read][struct](Window) ---
  1275. if buff.ReadUInt8() == uint8(0) {
  1276. target.Warnings = nil
  1277. } else {
  1278. // --- [begin][read][slice]([]string) ---
  1279. s := buff.ReadInt() // array len
  1280. r := make([]string, s)
  1281. for ii := 0; ii < s; ii++ {
  1282. var t string
  1283. u := buff.ReadString() // read string
  1284. t = u
  1285. r[ii] = t
  1286. }
  1287. target.Warnings = r
  1288. // --- [end][read][slice]([]string) ---
  1289. }
  1290. if buff.ReadUInt8() == uint8(0) {
  1291. target.Errors = nil
  1292. } else {
  1293. // --- [begin][read][slice]([]string) ---
  1294. x := buff.ReadInt() // array len
  1295. w := make([]string, x)
  1296. for jj := 0; jj < x; jj++ {
  1297. var y string
  1298. aa := buff.ReadString() // read string
  1299. y = aa
  1300. w[jj] = y
  1301. }
  1302. target.Errors = w
  1303. // --- [end][read][slice]([]string) ---
  1304. }
  1305. return nil
  1306. }
  1307. //--------------------------------------------------------------------------
  1308. // AssetSetRange
  1309. //--------------------------------------------------------------------------
  1310. // MarshalBinary serializes the internal properties of this AssetSetRange instance
  1311. // into a byte array
  1312. func (target *AssetSetRange) MarshalBinary() (data []byte, err error) {
  1313. // panics are recovered and propagated as errors
  1314. defer func() {
  1315. if r := recover(); r != nil {
  1316. if e, ok := r.(error); ok {
  1317. err = e
  1318. } else if s, ok := r.(string); ok {
  1319. err = fmt.Errorf("Unexpected panic: %s", s)
  1320. } else {
  1321. err = fmt.Errorf("Unexpected panic: %+v", r)
  1322. }
  1323. }
  1324. }()
  1325. buff := util.NewBuffer()
  1326. buff.WriteUInt8(CodecVersion) // version
  1327. if target.assets == nil {
  1328. buff.WriteUInt8(uint8(0)) // write nil byte
  1329. } else {
  1330. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1331. // --- [begin][write][slice]([]*AssetSet) ---
  1332. buff.WriteInt(len(target.assets)) // array length
  1333. for i := 0; i < len(target.assets); i++ {
  1334. if target.assets[i] == nil {
  1335. buff.WriteUInt8(uint8(0)) // write nil byte
  1336. } else {
  1337. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1338. // --- [begin][write][struct](AssetSet) ---
  1339. a, errA := target.assets[i].MarshalBinary()
  1340. if errA != nil {
  1341. return nil, errA
  1342. }
  1343. buff.WriteInt(len(a))
  1344. buff.WriteBytes(a)
  1345. // --- [end][write][struct](AssetSet) ---
  1346. }
  1347. }
  1348. // --- [end][write][slice]([]*AssetSet) ---
  1349. }
  1350. return buff.Bytes(), nil
  1351. }
  1352. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1353. // the AssetSetRange type
  1354. func (target *AssetSetRange) UnmarshalBinary(data []byte) (err error) {
  1355. // panics are recovered and propagated as errors
  1356. defer func() {
  1357. if r := recover(); r != nil {
  1358. if e, ok := r.(error); ok {
  1359. err = e
  1360. } else if s, ok := r.(string); ok {
  1361. err = fmt.Errorf("Unexpected panic: %s", s)
  1362. } else {
  1363. err = fmt.Errorf("Unexpected panic: %+v", r)
  1364. }
  1365. }
  1366. }()
  1367. buff := util.NewBufferFromBytes(data)
  1368. // Codec Version Check
  1369. version := buff.ReadUInt8()
  1370. if version != CodecVersion {
  1371. return fmt.Errorf("Invalid Version Unmarshaling AssetSetRange. Expected %d, got %d", CodecVersion, version)
  1372. }
  1373. if buff.ReadUInt8() == uint8(0) {
  1374. target.assets = nil
  1375. } else {
  1376. // --- [begin][read][slice]([]*AssetSet) ---
  1377. b := buff.ReadInt() // array len
  1378. a := make([]*AssetSet, b)
  1379. for i := 0; i < b; i++ {
  1380. var c *AssetSet
  1381. if buff.ReadUInt8() == uint8(0) {
  1382. c = nil
  1383. } else {
  1384. // --- [begin][read][struct](AssetSet) ---
  1385. d := &AssetSet{}
  1386. e := buff.ReadInt() // byte array length
  1387. f := buff.ReadBytes(e) // byte array
  1388. errA := d.UnmarshalBinary(f)
  1389. if errA != nil {
  1390. return errA
  1391. }
  1392. c = d
  1393. // --- [end][read][struct](AssetSet) ---
  1394. }
  1395. a[i] = c
  1396. }
  1397. target.assets = a
  1398. // --- [end][read][slice]([]*AssetSet) ---
  1399. }
  1400. return nil
  1401. }
  1402. //--------------------------------------------------------------------------
  1403. // Breakdown
  1404. //--------------------------------------------------------------------------
  1405. // MarshalBinary serializes the internal properties of this Breakdown instance
  1406. // into a byte array
  1407. func (target *Breakdown) MarshalBinary() (data []byte, err error) {
  1408. // panics are recovered and propagated as errors
  1409. defer func() {
  1410. if r := recover(); r != nil {
  1411. if e, ok := r.(error); ok {
  1412. err = e
  1413. } else if s, ok := r.(string); ok {
  1414. err = fmt.Errorf("Unexpected panic: %s", s)
  1415. } else {
  1416. err = fmt.Errorf("Unexpected panic: %+v", r)
  1417. }
  1418. }
  1419. }()
  1420. buff := util.NewBuffer()
  1421. buff.WriteUInt8(CodecVersion) // version
  1422. buff.WriteFloat64(target.Idle) // write float64
  1423. buff.WriteFloat64(target.Other) // write float64
  1424. buff.WriteFloat64(target.System) // write float64
  1425. buff.WriteFloat64(target.User) // write float64
  1426. return buff.Bytes(), nil
  1427. }
  1428. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1429. // the Breakdown type
  1430. func (target *Breakdown) UnmarshalBinary(data []byte) (err error) {
  1431. // panics are recovered and propagated as errors
  1432. defer func() {
  1433. if r := recover(); r != nil {
  1434. if e, ok := r.(error); ok {
  1435. err = e
  1436. } else if s, ok := r.(string); ok {
  1437. err = fmt.Errorf("Unexpected panic: %s", s)
  1438. } else {
  1439. err = fmt.Errorf("Unexpected panic: %+v", r)
  1440. }
  1441. }
  1442. }()
  1443. buff := util.NewBufferFromBytes(data)
  1444. // Codec Version Check
  1445. version := buff.ReadUInt8()
  1446. if version != CodecVersion {
  1447. return fmt.Errorf("Invalid Version Unmarshaling Breakdown. Expected %d, got %d", CodecVersion, version)
  1448. }
  1449. a := buff.ReadFloat64() // read float64
  1450. target.Idle = a
  1451. b := buff.ReadFloat64() // read float64
  1452. target.Other = b
  1453. c := buff.ReadFloat64() // read float64
  1454. target.System = c
  1455. d := buff.ReadFloat64() // read float64
  1456. target.User = d
  1457. return nil
  1458. }
  1459. //--------------------------------------------------------------------------
  1460. // Cloud
  1461. //--------------------------------------------------------------------------
  1462. // MarshalBinary serializes the internal properties of this Cloud instance
  1463. // into a byte array
  1464. func (target *Cloud) MarshalBinary() (data []byte, err error) {
  1465. // panics are recovered and propagated as errors
  1466. defer func() {
  1467. if r := recover(); r != nil {
  1468. if e, ok := r.(error); ok {
  1469. err = e
  1470. } else if s, ok := r.(string); ok {
  1471. err = fmt.Errorf("Unexpected panic: %s", s)
  1472. } else {
  1473. err = fmt.Errorf("Unexpected panic: %+v", r)
  1474. }
  1475. }
  1476. }()
  1477. buff := util.NewBuffer()
  1478. buff.WriteUInt8(CodecVersion) // version
  1479. // --- [begin][write][alias](AssetLabels) ---
  1480. if map[string]string(target.labels) == nil {
  1481. buff.WriteUInt8(uint8(0)) // write nil byte
  1482. } else {
  1483. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1484. // --- [begin][write][map](map[string]string) ---
  1485. buff.WriteInt(len(map[string]string(target.labels))) // map length
  1486. for v, z := range map[string]string(target.labels) {
  1487. buff.WriteString(v) // write string
  1488. buff.WriteString(z) // write string
  1489. }
  1490. // --- [end][write][map](map[string]string) ---
  1491. }
  1492. // --- [end][write][alias](AssetLabels) ---
  1493. if target.properties == nil {
  1494. buff.WriteUInt8(uint8(0)) // write nil byte
  1495. } else {
  1496. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1497. // --- [begin][write][struct](AssetProperties) ---
  1498. a, errA := target.properties.MarshalBinary()
  1499. if errA != nil {
  1500. return nil, errA
  1501. }
  1502. buff.WriteInt(len(a))
  1503. buff.WriteBytes(a)
  1504. // --- [end][write][struct](AssetProperties) ---
  1505. }
  1506. // --- [begin][write][reference](time.Time) ---
  1507. b, errB := target.start.MarshalBinary()
  1508. if errB != nil {
  1509. return nil, errB
  1510. }
  1511. buff.WriteInt(len(b))
  1512. buff.WriteBytes(b)
  1513. // --- [end][write][reference](time.Time) ---
  1514. // --- [begin][write][reference](time.Time) ---
  1515. c, errC := target.end.MarshalBinary()
  1516. if errC != nil {
  1517. return nil, errC
  1518. }
  1519. buff.WriteInt(len(c))
  1520. buff.WriteBytes(c)
  1521. // --- [end][write][reference](time.Time) ---
  1522. // --- [begin][write][struct](Window) ---
  1523. d, errD := target.window.MarshalBinary()
  1524. if errD != nil {
  1525. return nil, errD
  1526. }
  1527. buff.WriteInt(len(d))
  1528. buff.WriteBytes(d)
  1529. // --- [end][write][struct](Window) ---
  1530. buff.WriteFloat64(target.adjustment) // write float64
  1531. buff.WriteFloat64(target.Cost) // write float64
  1532. buff.WriteFloat64(target.Credit) // write float64
  1533. return buff.Bytes(), nil
  1534. }
  1535. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1536. // the Cloud type
  1537. func (target *Cloud) UnmarshalBinary(data []byte) (err error) {
  1538. // panics are recovered and propagated as errors
  1539. defer func() {
  1540. if r := recover(); r != nil {
  1541. if e, ok := r.(error); ok {
  1542. err = e
  1543. } else if s, ok := r.(string); ok {
  1544. err = fmt.Errorf("Unexpected panic: %s", s)
  1545. } else {
  1546. err = fmt.Errorf("Unexpected panic: %+v", r)
  1547. }
  1548. }
  1549. }()
  1550. buff := util.NewBufferFromBytes(data)
  1551. // Codec Version Check
  1552. version := buff.ReadUInt8()
  1553. if version != CodecVersion {
  1554. return fmt.Errorf("Invalid Version Unmarshaling Cloud. Expected %d, got %d", CodecVersion, version)
  1555. }
  1556. // --- [begin][read][alias](AssetLabels) ---
  1557. var a map[string]string
  1558. if buff.ReadUInt8() == uint8(0) {
  1559. a = nil
  1560. } else {
  1561. // --- [begin][read][map](map[string]string) ---
  1562. c := buff.ReadInt() // map len
  1563. b := make(map[string]string, c)
  1564. for i := 0; i < c; i++ {
  1565. var v string
  1566. d := buff.ReadString() // read string
  1567. v = d
  1568. var z string
  1569. e := buff.ReadString() // read string
  1570. z = e
  1571. b[v] = z
  1572. }
  1573. a = b
  1574. // --- [end][read][map](map[string]string) ---
  1575. }
  1576. target.labels = AssetLabels(a)
  1577. // --- [end][read][alias](AssetLabels) ---
  1578. if buff.ReadUInt8() == uint8(0) {
  1579. target.properties = nil
  1580. } else {
  1581. // --- [begin][read][struct](AssetProperties) ---
  1582. f := &AssetProperties{}
  1583. g := buff.ReadInt() // byte array length
  1584. h := buff.ReadBytes(g) // byte array
  1585. errA := f.UnmarshalBinary(h)
  1586. if errA != nil {
  1587. return errA
  1588. }
  1589. target.properties = f
  1590. // --- [end][read][struct](AssetProperties) ---
  1591. }
  1592. // --- [begin][read][reference](time.Time) ---
  1593. k := &time.Time{}
  1594. l := buff.ReadInt() // byte array length
  1595. m := buff.ReadBytes(l) // byte array
  1596. errB := k.UnmarshalBinary(m)
  1597. if errB != nil {
  1598. return errB
  1599. }
  1600. target.start = *k
  1601. // --- [end][read][reference](time.Time) ---
  1602. // --- [begin][read][reference](time.Time) ---
  1603. n := &time.Time{}
  1604. o := buff.ReadInt() // byte array length
  1605. p := buff.ReadBytes(o) // byte array
  1606. errC := n.UnmarshalBinary(p)
  1607. if errC != nil {
  1608. return errC
  1609. }
  1610. target.end = *n
  1611. // --- [end][read][reference](time.Time) ---
  1612. // --- [begin][read][struct](Window) ---
  1613. q := &Window{}
  1614. r := buff.ReadInt() // byte array length
  1615. s := buff.ReadBytes(r) // byte array
  1616. errD := q.UnmarshalBinary(s)
  1617. if errD != nil {
  1618. return errD
  1619. }
  1620. target.window = *q
  1621. // --- [end][read][struct](Window) ---
  1622. t := buff.ReadFloat64() // read float64
  1623. target.adjustment = t
  1624. u := buff.ReadFloat64() // read float64
  1625. target.Cost = u
  1626. w := buff.ReadFloat64() // read float64
  1627. target.Credit = w
  1628. return nil
  1629. }
  1630. //--------------------------------------------------------------------------
  1631. // ClusterManagement
  1632. //--------------------------------------------------------------------------
  1633. // MarshalBinary serializes the internal properties of this ClusterManagement instance
  1634. // into a byte array
  1635. func (target *ClusterManagement) MarshalBinary() (data []byte, err error) {
  1636. // panics are recovered and propagated as errors
  1637. defer func() {
  1638. if r := recover(); r != nil {
  1639. if e, ok := r.(error); ok {
  1640. err = e
  1641. } else if s, ok := r.(string); ok {
  1642. err = fmt.Errorf("Unexpected panic: %s", s)
  1643. } else {
  1644. err = fmt.Errorf("Unexpected panic: %+v", r)
  1645. }
  1646. }
  1647. }()
  1648. buff := util.NewBuffer()
  1649. buff.WriteUInt8(CodecVersion) // version
  1650. // --- [begin][write][alias](AssetLabels) ---
  1651. if map[string]string(target.labels) == nil {
  1652. buff.WriteUInt8(uint8(0)) // write nil byte
  1653. } else {
  1654. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1655. // --- [begin][write][map](map[string]string) ---
  1656. buff.WriteInt(len(map[string]string(target.labels))) // map length
  1657. for v, z := range map[string]string(target.labels) {
  1658. buff.WriteString(v) // write string
  1659. buff.WriteString(z) // write string
  1660. }
  1661. // --- [end][write][map](map[string]string) ---
  1662. }
  1663. // --- [end][write][alias](AssetLabels) ---
  1664. if target.properties == nil {
  1665. buff.WriteUInt8(uint8(0)) // write nil byte
  1666. } else {
  1667. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1668. // --- [begin][write][struct](AssetProperties) ---
  1669. a, errA := target.properties.MarshalBinary()
  1670. if errA != nil {
  1671. return nil, errA
  1672. }
  1673. buff.WriteInt(len(a))
  1674. buff.WriteBytes(a)
  1675. // --- [end][write][struct](AssetProperties) ---
  1676. }
  1677. // --- [begin][write][struct](Window) ---
  1678. b, errB := target.window.MarshalBinary()
  1679. if errB != nil {
  1680. return nil, errB
  1681. }
  1682. buff.WriteInt(len(b))
  1683. buff.WriteBytes(b)
  1684. // --- [end][write][struct](Window) ---
  1685. buff.WriteFloat64(target.Cost) // write float64
  1686. return buff.Bytes(), nil
  1687. }
  1688. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1689. // the ClusterManagement type
  1690. func (target *ClusterManagement) UnmarshalBinary(data []byte) (err error) {
  1691. // panics are recovered and propagated as errors
  1692. defer func() {
  1693. if r := recover(); r != nil {
  1694. if e, ok := r.(error); ok {
  1695. err = e
  1696. } else if s, ok := r.(string); ok {
  1697. err = fmt.Errorf("Unexpected panic: %s", s)
  1698. } else {
  1699. err = fmt.Errorf("Unexpected panic: %+v", r)
  1700. }
  1701. }
  1702. }()
  1703. buff := util.NewBufferFromBytes(data)
  1704. // Codec Version Check
  1705. version := buff.ReadUInt8()
  1706. if version != CodecVersion {
  1707. return fmt.Errorf("Invalid Version Unmarshaling ClusterManagement. Expected %d, got %d", CodecVersion, version)
  1708. }
  1709. // --- [begin][read][alias](AssetLabels) ---
  1710. var a map[string]string
  1711. if buff.ReadUInt8() == uint8(0) {
  1712. a = nil
  1713. } else {
  1714. // --- [begin][read][map](map[string]string) ---
  1715. c := buff.ReadInt() // map len
  1716. b := make(map[string]string, c)
  1717. for i := 0; i < c; i++ {
  1718. var v string
  1719. d := buff.ReadString() // read string
  1720. v = d
  1721. var z string
  1722. e := buff.ReadString() // read string
  1723. z = e
  1724. b[v] = z
  1725. }
  1726. a = b
  1727. // --- [end][read][map](map[string]string) ---
  1728. }
  1729. target.labels = AssetLabels(a)
  1730. // --- [end][read][alias](AssetLabels) ---
  1731. if buff.ReadUInt8() == uint8(0) {
  1732. target.properties = nil
  1733. } else {
  1734. // --- [begin][read][struct](AssetProperties) ---
  1735. f := &AssetProperties{}
  1736. g := buff.ReadInt() // byte array length
  1737. h := buff.ReadBytes(g) // byte array
  1738. errA := f.UnmarshalBinary(h)
  1739. if errA != nil {
  1740. return errA
  1741. }
  1742. target.properties = f
  1743. // --- [end][read][struct](AssetProperties) ---
  1744. }
  1745. // --- [begin][read][struct](Window) ---
  1746. k := &Window{}
  1747. l := buff.ReadInt() // byte array length
  1748. m := buff.ReadBytes(l) // byte array
  1749. errB := k.UnmarshalBinary(m)
  1750. if errB != nil {
  1751. return errB
  1752. }
  1753. target.window = *k
  1754. // --- [end][read][struct](Window) ---
  1755. n := buff.ReadFloat64() // read float64
  1756. target.Cost = n
  1757. return nil
  1758. }
  1759. //--------------------------------------------------------------------------
  1760. // Disk
  1761. //--------------------------------------------------------------------------
  1762. // MarshalBinary serializes the internal properties of this Disk instance
  1763. // into a byte array
  1764. func (target *Disk) MarshalBinary() (data []byte, err error) {
  1765. // panics are recovered and propagated as errors
  1766. defer func() {
  1767. if r := recover(); r != nil {
  1768. if e, ok := r.(error); ok {
  1769. err = e
  1770. } else if s, ok := r.(string); ok {
  1771. err = fmt.Errorf("Unexpected panic: %s", s)
  1772. } else {
  1773. err = fmt.Errorf("Unexpected panic: %+v", r)
  1774. }
  1775. }
  1776. }()
  1777. buff := util.NewBuffer()
  1778. buff.WriteUInt8(CodecVersion) // version
  1779. // --- [begin][write][alias](AssetLabels) ---
  1780. if map[string]string(target.labels) == nil {
  1781. buff.WriteUInt8(uint8(0)) // write nil byte
  1782. } else {
  1783. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1784. // --- [begin][write][map](map[string]string) ---
  1785. buff.WriteInt(len(map[string]string(target.labels))) // map length
  1786. for v, z := range map[string]string(target.labels) {
  1787. buff.WriteString(v) // write string
  1788. buff.WriteString(z) // write string
  1789. }
  1790. // --- [end][write][map](map[string]string) ---
  1791. }
  1792. // --- [end][write][alias](AssetLabels) ---
  1793. if target.properties == nil {
  1794. buff.WriteUInt8(uint8(0)) // write nil byte
  1795. } else {
  1796. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1797. // --- [begin][write][struct](AssetProperties) ---
  1798. a, errA := target.properties.MarshalBinary()
  1799. if errA != nil {
  1800. return nil, errA
  1801. }
  1802. buff.WriteInt(len(a))
  1803. buff.WriteBytes(a)
  1804. // --- [end][write][struct](AssetProperties) ---
  1805. }
  1806. // --- [begin][write][reference](time.Time) ---
  1807. b, errB := target.start.MarshalBinary()
  1808. if errB != nil {
  1809. return nil, errB
  1810. }
  1811. buff.WriteInt(len(b))
  1812. buff.WriteBytes(b)
  1813. // --- [end][write][reference](time.Time) ---
  1814. // --- [begin][write][reference](time.Time) ---
  1815. c, errC := target.end.MarshalBinary()
  1816. if errC != nil {
  1817. return nil, errC
  1818. }
  1819. buff.WriteInt(len(c))
  1820. buff.WriteBytes(c)
  1821. // --- [end][write][reference](time.Time) ---
  1822. // --- [begin][write][struct](Window) ---
  1823. d, errD := target.window.MarshalBinary()
  1824. if errD != nil {
  1825. return nil, errD
  1826. }
  1827. buff.WriteInt(len(d))
  1828. buff.WriteBytes(d)
  1829. // --- [end][write][struct](Window) ---
  1830. buff.WriteFloat64(target.adjustment) // write float64
  1831. buff.WriteFloat64(target.Cost) // write float64
  1832. buff.WriteFloat64(target.ByteHours) // write float64
  1833. buff.WriteFloat64(target.Local) // write float64
  1834. if target.Breakdown == nil {
  1835. buff.WriteUInt8(uint8(0)) // write nil byte
  1836. } else {
  1837. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1838. // --- [begin][write][struct](Breakdown) ---
  1839. e, errE := target.Breakdown.MarshalBinary()
  1840. if errE != nil {
  1841. return nil, errE
  1842. }
  1843. buff.WriteInt(len(e))
  1844. buff.WriteBytes(e)
  1845. // --- [end][write][struct](Breakdown) ---
  1846. }
  1847. return buff.Bytes(), nil
  1848. }
  1849. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1850. // the Disk type
  1851. func (target *Disk) UnmarshalBinary(data []byte) (err error) {
  1852. // panics are recovered and propagated as errors
  1853. defer func() {
  1854. if r := recover(); r != nil {
  1855. if e, ok := r.(error); ok {
  1856. err = e
  1857. } else if s, ok := r.(string); ok {
  1858. err = fmt.Errorf("Unexpected panic: %s", s)
  1859. } else {
  1860. err = fmt.Errorf("Unexpected panic: %+v", r)
  1861. }
  1862. }
  1863. }()
  1864. buff := util.NewBufferFromBytes(data)
  1865. // Codec Version Check
  1866. version := buff.ReadUInt8()
  1867. if version != CodecVersion {
  1868. return fmt.Errorf("Invalid Version Unmarshaling Disk. Expected %d, got %d", CodecVersion, version)
  1869. }
  1870. // --- [begin][read][alias](AssetLabels) ---
  1871. var a map[string]string
  1872. if buff.ReadUInt8() == uint8(0) {
  1873. a = nil
  1874. } else {
  1875. // --- [begin][read][map](map[string]string) ---
  1876. c := buff.ReadInt() // map len
  1877. b := make(map[string]string, c)
  1878. for i := 0; i < c; i++ {
  1879. var v string
  1880. d := buff.ReadString() // read string
  1881. v = d
  1882. var z string
  1883. e := buff.ReadString() // read string
  1884. z = e
  1885. b[v] = z
  1886. }
  1887. a = b
  1888. // --- [end][read][map](map[string]string) ---
  1889. }
  1890. target.labels = AssetLabels(a)
  1891. // --- [end][read][alias](AssetLabels) ---
  1892. if buff.ReadUInt8() == uint8(0) {
  1893. target.properties = nil
  1894. } else {
  1895. // --- [begin][read][struct](AssetProperties) ---
  1896. f := &AssetProperties{}
  1897. g := buff.ReadInt() // byte array length
  1898. h := buff.ReadBytes(g) // byte array
  1899. errA := f.UnmarshalBinary(h)
  1900. if errA != nil {
  1901. return errA
  1902. }
  1903. target.properties = f
  1904. // --- [end][read][struct](AssetProperties) ---
  1905. }
  1906. // --- [begin][read][reference](time.Time) ---
  1907. k := &time.Time{}
  1908. l := buff.ReadInt() // byte array length
  1909. m := buff.ReadBytes(l) // byte array
  1910. errB := k.UnmarshalBinary(m)
  1911. if errB != nil {
  1912. return errB
  1913. }
  1914. target.start = *k
  1915. // --- [end][read][reference](time.Time) ---
  1916. // --- [begin][read][reference](time.Time) ---
  1917. n := &time.Time{}
  1918. o := buff.ReadInt() // byte array length
  1919. p := buff.ReadBytes(o) // byte array
  1920. errC := n.UnmarshalBinary(p)
  1921. if errC != nil {
  1922. return errC
  1923. }
  1924. target.end = *n
  1925. // --- [end][read][reference](time.Time) ---
  1926. // --- [begin][read][struct](Window) ---
  1927. q := &Window{}
  1928. r := buff.ReadInt() // byte array length
  1929. s := buff.ReadBytes(r) // byte array
  1930. errD := q.UnmarshalBinary(s)
  1931. if errD != nil {
  1932. return errD
  1933. }
  1934. target.window = *q
  1935. // --- [end][read][struct](Window) ---
  1936. t := buff.ReadFloat64() // read float64
  1937. target.adjustment = t
  1938. u := buff.ReadFloat64() // read float64
  1939. target.Cost = u
  1940. w := buff.ReadFloat64() // read float64
  1941. target.ByteHours = w
  1942. x := buff.ReadFloat64() // read float64
  1943. target.Local = x
  1944. if buff.ReadUInt8() == uint8(0) {
  1945. target.Breakdown = nil
  1946. } else {
  1947. // --- [begin][read][struct](Breakdown) ---
  1948. y := &Breakdown{}
  1949. aa := buff.ReadInt() // byte array length
  1950. bb := buff.ReadBytes(aa) // byte array
  1951. errE := y.UnmarshalBinary(bb)
  1952. if errE != nil {
  1953. return errE
  1954. }
  1955. target.Breakdown = y
  1956. // --- [end][read][struct](Breakdown) ---
  1957. }
  1958. return nil
  1959. }
  1960. //--------------------------------------------------------------------------
  1961. // LoadBalancer
  1962. //--------------------------------------------------------------------------
  1963. // MarshalBinary serializes the internal properties of this LoadBalancer instance
  1964. // into a byte array
  1965. func (target *LoadBalancer) MarshalBinary() (data []byte, 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 := util.NewBuffer()
  1979. buff.WriteUInt8(CodecVersion) // version
  1980. if target.properties == nil {
  1981. buff.WriteUInt8(uint8(0)) // write nil byte
  1982. } else {
  1983. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1984. // --- [begin][write][struct](AssetProperties) ---
  1985. a, errA := target.properties.MarshalBinary()
  1986. if errA != nil {
  1987. return nil, errA
  1988. }
  1989. buff.WriteInt(len(a))
  1990. buff.WriteBytes(a)
  1991. // --- [end][write][struct](AssetProperties) ---
  1992. }
  1993. // --- [begin][write][alias](AssetLabels) ---
  1994. if map[string]string(target.labels) == nil {
  1995. buff.WriteUInt8(uint8(0)) // write nil byte
  1996. } else {
  1997. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1998. // --- [begin][write][map](map[string]string) ---
  1999. buff.WriteInt(len(map[string]string(target.labels))) // map length
  2000. for v, z := range map[string]string(target.labels) {
  2001. buff.WriteString(v) // write string
  2002. buff.WriteString(z) // write string
  2003. }
  2004. // --- [end][write][map](map[string]string) ---
  2005. }
  2006. // --- [end][write][alias](AssetLabels) ---
  2007. // --- [begin][write][reference](time.Time) ---
  2008. b, errB := target.start.MarshalBinary()
  2009. if errB != nil {
  2010. return nil, errB
  2011. }
  2012. buff.WriteInt(len(b))
  2013. buff.WriteBytes(b)
  2014. // --- [end][write][reference](time.Time) ---
  2015. // --- [begin][write][reference](time.Time) ---
  2016. c, errC := target.end.MarshalBinary()
  2017. if errC != nil {
  2018. return nil, errC
  2019. }
  2020. buff.WriteInt(len(c))
  2021. buff.WriteBytes(c)
  2022. // --- [end][write][reference](time.Time) ---
  2023. // --- [begin][write][struct](Window) ---
  2024. d, errD := target.window.MarshalBinary()
  2025. if errD != nil {
  2026. return nil, errD
  2027. }
  2028. buff.WriteInt(len(d))
  2029. buff.WriteBytes(d)
  2030. // --- [end][write][struct](Window) ---
  2031. buff.WriteFloat64(target.adjustment) // write float64
  2032. buff.WriteFloat64(target.Cost) // write float64
  2033. return buff.Bytes(), nil
  2034. }
  2035. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2036. // the LoadBalancer type
  2037. func (target *LoadBalancer) UnmarshalBinary(data []byte) (err error) {
  2038. // panics are recovered and propagated as errors
  2039. defer func() {
  2040. if r := recover(); r != nil {
  2041. if e, ok := r.(error); ok {
  2042. err = e
  2043. } else if s, ok := r.(string); ok {
  2044. err = fmt.Errorf("Unexpected panic: %s", s)
  2045. } else {
  2046. err = fmt.Errorf("Unexpected panic: %+v", r)
  2047. }
  2048. }
  2049. }()
  2050. buff := util.NewBufferFromBytes(data)
  2051. // Codec Version Check
  2052. version := buff.ReadUInt8()
  2053. if version != CodecVersion {
  2054. return fmt.Errorf("Invalid Version Unmarshaling LoadBalancer. Expected %d, got %d", CodecVersion, version)
  2055. }
  2056. if buff.ReadUInt8() == uint8(0) {
  2057. target.properties = nil
  2058. } else {
  2059. // --- [begin][read][struct](AssetProperties) ---
  2060. a := &AssetProperties{}
  2061. b := buff.ReadInt() // byte array length
  2062. c := buff.ReadBytes(b) // byte array
  2063. errA := a.UnmarshalBinary(c)
  2064. if errA != nil {
  2065. return errA
  2066. }
  2067. target.properties = a
  2068. // --- [end][read][struct](AssetProperties) ---
  2069. }
  2070. // --- [begin][read][alias](AssetLabels) ---
  2071. var d map[string]string
  2072. if buff.ReadUInt8() == uint8(0) {
  2073. d = nil
  2074. } else {
  2075. // --- [begin][read][map](map[string]string) ---
  2076. f := buff.ReadInt() // map len
  2077. e := make(map[string]string, f)
  2078. for i := 0; i < f; i++ {
  2079. var v string
  2080. g := buff.ReadString() // read string
  2081. v = g
  2082. var z string
  2083. h := buff.ReadString() // read string
  2084. z = h
  2085. e[v] = z
  2086. }
  2087. d = e
  2088. // --- [end][read][map](map[string]string) ---
  2089. }
  2090. target.labels = AssetLabels(d)
  2091. // --- [end][read][alias](AssetLabels) ---
  2092. // --- [begin][read][reference](time.Time) ---
  2093. k := &time.Time{}
  2094. l := buff.ReadInt() // byte array length
  2095. m := buff.ReadBytes(l) // byte array
  2096. errB := k.UnmarshalBinary(m)
  2097. if errB != nil {
  2098. return errB
  2099. }
  2100. target.start = *k
  2101. // --- [end][read][reference](time.Time) ---
  2102. // --- [begin][read][reference](time.Time) ---
  2103. n := &time.Time{}
  2104. o := buff.ReadInt() // byte array length
  2105. p := buff.ReadBytes(o) // byte array
  2106. errC := n.UnmarshalBinary(p)
  2107. if errC != nil {
  2108. return errC
  2109. }
  2110. target.end = *n
  2111. // --- [end][read][reference](time.Time) ---
  2112. // --- [begin][read][struct](Window) ---
  2113. q := &Window{}
  2114. r := buff.ReadInt() // byte array length
  2115. s := buff.ReadBytes(r) // byte array
  2116. errD := q.UnmarshalBinary(s)
  2117. if errD != nil {
  2118. return errD
  2119. }
  2120. target.window = *q
  2121. // --- [end][read][struct](Window) ---
  2122. t := buff.ReadFloat64() // read float64
  2123. target.adjustment = t
  2124. u := buff.ReadFloat64() // read float64
  2125. target.Cost = u
  2126. return nil
  2127. }
  2128. //--------------------------------------------------------------------------
  2129. // Network
  2130. //--------------------------------------------------------------------------
  2131. // MarshalBinary serializes the internal properties of this Network instance
  2132. // into a byte array
  2133. func (target *Network) MarshalBinary() (data []byte, err error) {
  2134. // panics are recovered and propagated as errors
  2135. defer func() {
  2136. if r := recover(); r != nil {
  2137. if e, ok := r.(error); ok {
  2138. err = e
  2139. } else if s, ok := r.(string); ok {
  2140. err = fmt.Errorf("Unexpected panic: %s", s)
  2141. } else {
  2142. err = fmt.Errorf("Unexpected panic: %+v", r)
  2143. }
  2144. }
  2145. }()
  2146. buff := util.NewBuffer()
  2147. buff.WriteUInt8(CodecVersion) // version
  2148. if target.properties == nil {
  2149. buff.WriteUInt8(uint8(0)) // write nil byte
  2150. } else {
  2151. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2152. // --- [begin][write][struct](AssetProperties) ---
  2153. a, errA := target.properties.MarshalBinary()
  2154. if errA != nil {
  2155. return nil, errA
  2156. }
  2157. buff.WriteInt(len(a))
  2158. buff.WriteBytes(a)
  2159. // --- [end][write][struct](AssetProperties) ---
  2160. }
  2161. // --- [begin][write][alias](AssetLabels) ---
  2162. if map[string]string(target.labels) == nil {
  2163. buff.WriteUInt8(uint8(0)) // write nil byte
  2164. } else {
  2165. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2166. // --- [begin][write][map](map[string]string) ---
  2167. buff.WriteInt(len(map[string]string(target.labels))) // map length
  2168. for v, z := range map[string]string(target.labels) {
  2169. buff.WriteString(v) // write string
  2170. buff.WriteString(z) // write string
  2171. }
  2172. // --- [end][write][map](map[string]string) ---
  2173. }
  2174. // --- [end][write][alias](AssetLabels) ---
  2175. // --- [begin][write][reference](time.Time) ---
  2176. b, errB := target.start.MarshalBinary()
  2177. if errB != nil {
  2178. return nil, errB
  2179. }
  2180. buff.WriteInt(len(b))
  2181. buff.WriteBytes(b)
  2182. // --- [end][write][reference](time.Time) ---
  2183. // --- [begin][write][reference](time.Time) ---
  2184. c, errC := target.end.MarshalBinary()
  2185. if errC != nil {
  2186. return nil, errC
  2187. }
  2188. buff.WriteInt(len(c))
  2189. buff.WriteBytes(c)
  2190. // --- [end][write][reference](time.Time) ---
  2191. // --- [begin][write][struct](Window) ---
  2192. d, errD := target.window.MarshalBinary()
  2193. if errD != nil {
  2194. return nil, errD
  2195. }
  2196. buff.WriteInt(len(d))
  2197. buff.WriteBytes(d)
  2198. // --- [end][write][struct](Window) ---
  2199. buff.WriteFloat64(target.adjustment) // write float64
  2200. buff.WriteFloat64(target.Cost) // write float64
  2201. return buff.Bytes(), nil
  2202. }
  2203. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2204. // the Network type
  2205. func (target *Network) UnmarshalBinary(data []byte) (err error) {
  2206. // panics are recovered and propagated as errors
  2207. defer func() {
  2208. if r := recover(); r != nil {
  2209. if e, ok := r.(error); ok {
  2210. err = e
  2211. } else if s, ok := r.(string); ok {
  2212. err = fmt.Errorf("Unexpected panic: %s", s)
  2213. } else {
  2214. err = fmt.Errorf("Unexpected panic: %+v", r)
  2215. }
  2216. }
  2217. }()
  2218. buff := util.NewBufferFromBytes(data)
  2219. // Codec Version Check
  2220. version := buff.ReadUInt8()
  2221. if version != CodecVersion {
  2222. return fmt.Errorf("Invalid Version Unmarshaling Network. Expected %d, got %d", CodecVersion, version)
  2223. }
  2224. if buff.ReadUInt8() == uint8(0) {
  2225. target.properties = nil
  2226. } else {
  2227. // --- [begin][read][struct](AssetProperties) ---
  2228. a := &AssetProperties{}
  2229. b := buff.ReadInt() // byte array length
  2230. c := buff.ReadBytes(b) // byte array
  2231. errA := a.UnmarshalBinary(c)
  2232. if errA != nil {
  2233. return errA
  2234. }
  2235. target.properties = a
  2236. // --- [end][read][struct](AssetProperties) ---
  2237. }
  2238. // --- [begin][read][alias](AssetLabels) ---
  2239. var d map[string]string
  2240. if buff.ReadUInt8() == uint8(0) {
  2241. d = nil
  2242. } else {
  2243. // --- [begin][read][map](map[string]string) ---
  2244. f := buff.ReadInt() // map len
  2245. e := make(map[string]string, f)
  2246. for i := 0; i < f; i++ {
  2247. var v string
  2248. g := buff.ReadString() // read string
  2249. v = g
  2250. var z string
  2251. h := buff.ReadString() // read string
  2252. z = h
  2253. e[v] = z
  2254. }
  2255. d = e
  2256. // --- [end][read][map](map[string]string) ---
  2257. }
  2258. target.labels = AssetLabels(d)
  2259. // --- [end][read][alias](AssetLabels) ---
  2260. // --- [begin][read][reference](time.Time) ---
  2261. k := &time.Time{}
  2262. l := buff.ReadInt() // byte array length
  2263. m := buff.ReadBytes(l) // byte array
  2264. errB := k.UnmarshalBinary(m)
  2265. if errB != nil {
  2266. return errB
  2267. }
  2268. target.start = *k
  2269. // --- [end][read][reference](time.Time) ---
  2270. // --- [begin][read][reference](time.Time) ---
  2271. n := &time.Time{}
  2272. o := buff.ReadInt() // byte array length
  2273. p := buff.ReadBytes(o) // byte array
  2274. errC := n.UnmarshalBinary(p)
  2275. if errC != nil {
  2276. return errC
  2277. }
  2278. target.end = *n
  2279. // --- [end][read][reference](time.Time) ---
  2280. // --- [begin][read][struct](Window) ---
  2281. q := &Window{}
  2282. r := buff.ReadInt() // byte array length
  2283. s := buff.ReadBytes(r) // byte array
  2284. errD := q.UnmarshalBinary(s)
  2285. if errD != nil {
  2286. return errD
  2287. }
  2288. target.window = *q
  2289. // --- [end][read][struct](Window) ---
  2290. t := buff.ReadFloat64() // read float64
  2291. target.adjustment = t
  2292. u := buff.ReadFloat64() // read float64
  2293. target.Cost = u
  2294. return nil
  2295. }
  2296. //--------------------------------------------------------------------------
  2297. // Node
  2298. //--------------------------------------------------------------------------
  2299. // MarshalBinary serializes the internal properties of this Node instance
  2300. // into a byte array
  2301. func (target *Node) MarshalBinary() (data []byte, err error) {
  2302. // panics are recovered and propagated as errors
  2303. defer func() {
  2304. if r := recover(); r != nil {
  2305. if e, ok := r.(error); ok {
  2306. err = e
  2307. } else if s, ok := r.(string); ok {
  2308. err = fmt.Errorf("Unexpected panic: %s", s)
  2309. } else {
  2310. err = fmt.Errorf("Unexpected panic: %+v", r)
  2311. }
  2312. }
  2313. }()
  2314. buff := util.NewBuffer()
  2315. buff.WriteUInt8(CodecVersion) // version
  2316. if target.properties == nil {
  2317. buff.WriteUInt8(uint8(0)) // write nil byte
  2318. } else {
  2319. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2320. // --- [begin][write][struct](AssetProperties) ---
  2321. a, errA := target.properties.MarshalBinary()
  2322. if errA != nil {
  2323. return nil, errA
  2324. }
  2325. buff.WriteInt(len(a))
  2326. buff.WriteBytes(a)
  2327. // --- [end][write][struct](AssetProperties) ---
  2328. }
  2329. // --- [begin][write][alias](AssetLabels) ---
  2330. if map[string]string(target.labels) == nil {
  2331. buff.WriteUInt8(uint8(0)) // write nil byte
  2332. } else {
  2333. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2334. // --- [begin][write][map](map[string]string) ---
  2335. buff.WriteInt(len(map[string]string(target.labels))) // map length
  2336. for v, z := range map[string]string(target.labels) {
  2337. buff.WriteString(v) // write string
  2338. buff.WriteString(z) // write string
  2339. }
  2340. // --- [end][write][map](map[string]string) ---
  2341. }
  2342. // --- [end][write][alias](AssetLabels) ---
  2343. // --- [begin][write][reference](time.Time) ---
  2344. b, errB := target.start.MarshalBinary()
  2345. if errB != nil {
  2346. return nil, errB
  2347. }
  2348. buff.WriteInt(len(b))
  2349. buff.WriteBytes(b)
  2350. // --- [end][write][reference](time.Time) ---
  2351. // --- [begin][write][reference](time.Time) ---
  2352. c, errC := target.end.MarshalBinary()
  2353. if errC != nil {
  2354. return nil, errC
  2355. }
  2356. buff.WriteInt(len(c))
  2357. buff.WriteBytes(c)
  2358. // --- [end][write][reference](time.Time) ---
  2359. // --- [begin][write][struct](Window) ---
  2360. d, errD := target.window.MarshalBinary()
  2361. if errD != nil {
  2362. return nil, errD
  2363. }
  2364. buff.WriteInt(len(d))
  2365. buff.WriteBytes(d)
  2366. // --- [end][write][struct](Window) ---
  2367. buff.WriteFloat64(target.adjustment) // write float64
  2368. buff.WriteString(target.NodeType) // write string
  2369. buff.WriteFloat64(target.CPUCoreHours) // write float64
  2370. buff.WriteFloat64(target.RAMByteHours) // write float64
  2371. buff.WriteFloat64(target.GPUHours) // write float64
  2372. if target.CPUBreakdown == nil {
  2373. buff.WriteUInt8(uint8(0)) // write nil byte
  2374. } else {
  2375. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2376. // --- [begin][write][struct](Breakdown) ---
  2377. e, errE := target.CPUBreakdown.MarshalBinary()
  2378. if errE != nil {
  2379. return nil, errE
  2380. }
  2381. buff.WriteInt(len(e))
  2382. buff.WriteBytes(e)
  2383. // --- [end][write][struct](Breakdown) ---
  2384. }
  2385. if target.RAMBreakdown == nil {
  2386. buff.WriteUInt8(uint8(0)) // write nil byte
  2387. } else {
  2388. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2389. // --- [begin][write][struct](Breakdown) ---
  2390. f, errF := target.RAMBreakdown.MarshalBinary()
  2391. if errF != nil {
  2392. return nil, errF
  2393. }
  2394. buff.WriteInt(len(f))
  2395. buff.WriteBytes(f)
  2396. // --- [end][write][struct](Breakdown) ---
  2397. }
  2398. buff.WriteFloat64(target.CPUCost) // write float64
  2399. buff.WriteFloat64(target.GPUCost) // write float64
  2400. buff.WriteFloat64(target.GPUCount) // write float64
  2401. buff.WriteFloat64(target.RAMCost) // write float64
  2402. buff.WriteFloat64(target.Discount) // write float64
  2403. buff.WriteFloat64(target.Preemptible) // write float64
  2404. return buff.Bytes(), nil
  2405. }
  2406. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2407. // the Node type
  2408. func (target *Node) UnmarshalBinary(data []byte) (err error) {
  2409. // panics are recovered and propagated as errors
  2410. defer func() {
  2411. if r := recover(); r != nil {
  2412. if e, ok := r.(error); ok {
  2413. err = e
  2414. } else if s, ok := r.(string); ok {
  2415. err = fmt.Errorf("Unexpected panic: %s", s)
  2416. } else {
  2417. err = fmt.Errorf("Unexpected panic: %+v", r)
  2418. }
  2419. }
  2420. }()
  2421. buff := util.NewBufferFromBytes(data)
  2422. // Codec Version Check
  2423. version := buff.ReadUInt8()
  2424. if version != CodecVersion {
  2425. return fmt.Errorf("Invalid Version Unmarshaling Node. Expected %d, got %d", CodecVersion, version)
  2426. }
  2427. if buff.ReadUInt8() == uint8(0) {
  2428. target.properties = nil
  2429. } else {
  2430. // --- [begin][read][struct](AssetProperties) ---
  2431. a := &AssetProperties{}
  2432. b := buff.ReadInt() // byte array length
  2433. c := buff.ReadBytes(b) // byte array
  2434. errA := a.UnmarshalBinary(c)
  2435. if errA != nil {
  2436. return errA
  2437. }
  2438. target.properties = a
  2439. // --- [end][read][struct](AssetProperties) ---
  2440. }
  2441. // --- [begin][read][alias](AssetLabels) ---
  2442. var d map[string]string
  2443. if buff.ReadUInt8() == uint8(0) {
  2444. d = nil
  2445. } else {
  2446. // --- [begin][read][map](map[string]string) ---
  2447. f := buff.ReadInt() // map len
  2448. e := make(map[string]string, f)
  2449. for i := 0; i < f; i++ {
  2450. var v string
  2451. g := buff.ReadString() // read string
  2452. v = g
  2453. var z string
  2454. h := buff.ReadString() // read string
  2455. z = h
  2456. e[v] = z
  2457. }
  2458. d = e
  2459. // --- [end][read][map](map[string]string) ---
  2460. }
  2461. target.labels = AssetLabels(d)
  2462. // --- [end][read][alias](AssetLabels) ---
  2463. // --- [begin][read][reference](time.Time) ---
  2464. k := &time.Time{}
  2465. l := buff.ReadInt() // byte array length
  2466. m := buff.ReadBytes(l) // byte array
  2467. errB := k.UnmarshalBinary(m)
  2468. if errB != nil {
  2469. return errB
  2470. }
  2471. target.start = *k
  2472. // --- [end][read][reference](time.Time) ---
  2473. // --- [begin][read][reference](time.Time) ---
  2474. n := &time.Time{}
  2475. o := buff.ReadInt() // byte array length
  2476. p := buff.ReadBytes(o) // byte array
  2477. errC := n.UnmarshalBinary(p)
  2478. if errC != nil {
  2479. return errC
  2480. }
  2481. target.end = *n
  2482. // --- [end][read][reference](time.Time) ---
  2483. // --- [begin][read][struct](Window) ---
  2484. q := &Window{}
  2485. r := buff.ReadInt() // byte array length
  2486. s := buff.ReadBytes(r) // byte array
  2487. errD := q.UnmarshalBinary(s)
  2488. if errD != nil {
  2489. return errD
  2490. }
  2491. target.window = *q
  2492. // --- [end][read][struct](Window) ---
  2493. t := buff.ReadFloat64() // read float64
  2494. target.adjustment = t
  2495. u := buff.ReadString() // read string
  2496. target.NodeType = u
  2497. w := buff.ReadFloat64() // read float64
  2498. target.CPUCoreHours = w
  2499. x := buff.ReadFloat64() // read float64
  2500. target.RAMByteHours = x
  2501. y := buff.ReadFloat64() // read float64
  2502. target.GPUHours = y
  2503. if buff.ReadUInt8() == uint8(0) {
  2504. target.CPUBreakdown = nil
  2505. } else {
  2506. // --- [begin][read][struct](Breakdown) ---
  2507. aa := &Breakdown{}
  2508. bb := buff.ReadInt() // byte array length
  2509. cc := buff.ReadBytes(bb) // byte array
  2510. errE := aa.UnmarshalBinary(cc)
  2511. if errE != nil {
  2512. return errE
  2513. }
  2514. target.CPUBreakdown = aa
  2515. // --- [end][read][struct](Breakdown) ---
  2516. }
  2517. if buff.ReadUInt8() == uint8(0) {
  2518. target.RAMBreakdown = nil
  2519. } else {
  2520. // --- [begin][read][struct](Breakdown) ---
  2521. dd := &Breakdown{}
  2522. ee := buff.ReadInt() // byte array length
  2523. ff := buff.ReadBytes(ee) // byte array
  2524. errF := dd.UnmarshalBinary(ff)
  2525. if errF != nil {
  2526. return errF
  2527. }
  2528. target.RAMBreakdown = dd
  2529. // --- [end][read][struct](Breakdown) ---
  2530. }
  2531. gg := buff.ReadFloat64() // read float64
  2532. target.CPUCost = gg
  2533. hh := buff.ReadFloat64() // read float64
  2534. target.GPUCost = hh
  2535. kk := buff.ReadFloat64() // read float64
  2536. target.GPUCount = kk
  2537. ll := buff.ReadFloat64() // read float64
  2538. target.RAMCost = ll
  2539. mm := buff.ReadFloat64() // read float64
  2540. target.Discount = mm
  2541. nn := buff.ReadFloat64() // read float64
  2542. target.Preemptible = nn
  2543. return nil
  2544. }
  2545. //--------------------------------------------------------------------------
  2546. // PVAllocation
  2547. //--------------------------------------------------------------------------
  2548. // MarshalBinary serializes the internal properties of this PVAllocation instance
  2549. // into a byte array
  2550. func (target *PVAllocation) MarshalBinary() (data []byte, err error) {
  2551. // panics are recovered and propagated as errors
  2552. defer func() {
  2553. if r := recover(); r != nil {
  2554. if e, ok := r.(error); ok {
  2555. err = e
  2556. } else if s, ok := r.(string); ok {
  2557. err = fmt.Errorf("Unexpected panic: %s", s)
  2558. } else {
  2559. err = fmt.Errorf("Unexpected panic: %+v", r)
  2560. }
  2561. }
  2562. }()
  2563. buff := util.NewBuffer()
  2564. buff.WriteUInt8(CodecVersion) // version
  2565. buff.WriteFloat64(target.ByteHours) // write float64
  2566. buff.WriteFloat64(target.Cost) // write float64
  2567. return buff.Bytes(), nil
  2568. }
  2569. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2570. // the PVAllocation type
  2571. func (target *PVAllocation) UnmarshalBinary(data []byte) (err error) {
  2572. // panics are recovered and propagated as errors
  2573. defer func() {
  2574. if r := recover(); r != nil {
  2575. if e, ok := r.(error); ok {
  2576. err = e
  2577. } else if s, ok := r.(string); ok {
  2578. err = fmt.Errorf("Unexpected panic: %s", s)
  2579. } else {
  2580. err = fmt.Errorf("Unexpected panic: %+v", r)
  2581. }
  2582. }
  2583. }()
  2584. buff := util.NewBufferFromBytes(data)
  2585. // Codec Version Check
  2586. version := buff.ReadUInt8()
  2587. if version != CodecVersion {
  2588. return fmt.Errorf("Invalid Version Unmarshaling PVAllocation. Expected %d, got %d", CodecVersion, version)
  2589. }
  2590. a := buff.ReadFloat64() // read float64
  2591. target.ByteHours = a
  2592. b := buff.ReadFloat64() // read float64
  2593. target.Cost = b
  2594. return nil
  2595. }
  2596. //--------------------------------------------------------------------------
  2597. // PVKey
  2598. //--------------------------------------------------------------------------
  2599. // MarshalBinary serializes the internal properties of this PVKey instance
  2600. // into a byte array
  2601. func (target *PVKey) MarshalBinary() (data []byte, err error) {
  2602. // panics are recovered and propagated as errors
  2603. defer func() {
  2604. if r := recover(); r != nil {
  2605. if e, ok := r.(error); ok {
  2606. err = e
  2607. } else if s, ok := r.(string); ok {
  2608. err = fmt.Errorf("Unexpected panic: %s", s)
  2609. } else {
  2610. err = fmt.Errorf("Unexpected panic: %+v", r)
  2611. }
  2612. }
  2613. }()
  2614. buff := util.NewBuffer()
  2615. buff.WriteUInt8(CodecVersion) // version
  2616. buff.WriteString(target.Cluster) // write string
  2617. buff.WriteString(target.Name) // write string
  2618. return buff.Bytes(), nil
  2619. }
  2620. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2621. // the PVKey type
  2622. func (target *PVKey) UnmarshalBinary(data []byte) (err error) {
  2623. // panics are recovered and propagated as errors
  2624. defer func() {
  2625. if r := recover(); r != nil {
  2626. if e, ok := r.(error); ok {
  2627. err = e
  2628. } else if s, ok := r.(string); ok {
  2629. err = fmt.Errorf("Unexpected panic: %s", s)
  2630. } else {
  2631. err = fmt.Errorf("Unexpected panic: %+v", r)
  2632. }
  2633. }
  2634. }()
  2635. buff := util.NewBufferFromBytes(data)
  2636. // Codec Version Check
  2637. version := buff.ReadUInt8()
  2638. if version != CodecVersion {
  2639. return fmt.Errorf("Invalid Version Unmarshaling PVKey. Expected %d, got %d", CodecVersion, version)
  2640. }
  2641. a := buff.ReadString() // read string
  2642. target.Cluster = a
  2643. b := buff.ReadString() // read string
  2644. target.Name = b
  2645. return nil
  2646. }
  2647. //--------------------------------------------------------------------------
  2648. // RawAllocationOnlyData
  2649. //--------------------------------------------------------------------------
  2650. // MarshalBinary serializes the internal properties of this RawAllocationOnlyData instance
  2651. // into a byte array
  2652. func (target *RawAllocationOnlyData) MarshalBinary() (data []byte, err error) {
  2653. // panics are recovered and propagated as errors
  2654. defer func() {
  2655. if r := recover(); r != nil {
  2656. if e, ok := r.(error); ok {
  2657. err = e
  2658. } else if s, ok := r.(string); ok {
  2659. err = fmt.Errorf("Unexpected panic: %s", s)
  2660. } else {
  2661. err = fmt.Errorf("Unexpected panic: %+v", r)
  2662. }
  2663. }
  2664. }()
  2665. buff := util.NewBuffer()
  2666. buff.WriteUInt8(CodecVersion) // version
  2667. buff.WriteFloat64(target.CPUCoreUsageMax) // write float64
  2668. buff.WriteFloat64(target.RAMBytesUsageMax) // write float64
  2669. return buff.Bytes(), nil
  2670. }
  2671. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2672. // the RawAllocationOnlyData type
  2673. func (target *RawAllocationOnlyData) UnmarshalBinary(data []byte) (err error) {
  2674. // panics are recovered and propagated as errors
  2675. defer func() {
  2676. if r := recover(); r != nil {
  2677. if e, ok := r.(error); ok {
  2678. err = e
  2679. } else if s, ok := r.(string); ok {
  2680. err = fmt.Errorf("Unexpected panic: %s", s)
  2681. } else {
  2682. err = fmt.Errorf("Unexpected panic: %+v", r)
  2683. }
  2684. }
  2685. }()
  2686. buff := util.NewBufferFromBytes(data)
  2687. // Codec Version Check
  2688. version := buff.ReadUInt8()
  2689. if version != CodecVersion {
  2690. return fmt.Errorf("Invalid Version Unmarshaling RawAllocationOnlyData. Expected %d, got %d", CodecVersion, version)
  2691. }
  2692. a := buff.ReadFloat64() // read float64
  2693. target.CPUCoreUsageMax = a
  2694. b := buff.ReadFloat64() // read float64
  2695. target.RAMBytesUsageMax = b
  2696. return nil
  2697. }
  2698. //--------------------------------------------------------------------------
  2699. // SharedAsset
  2700. //--------------------------------------------------------------------------
  2701. // MarshalBinary serializes the internal properties of this SharedAsset instance
  2702. // into a byte array
  2703. func (target *SharedAsset) MarshalBinary() (data []byte, err error) {
  2704. // panics are recovered and propagated as errors
  2705. defer func() {
  2706. if r := recover(); r != nil {
  2707. if e, ok := r.(error); ok {
  2708. err = e
  2709. } else if s, ok := r.(string); ok {
  2710. err = fmt.Errorf("Unexpected panic: %s", s)
  2711. } else {
  2712. err = fmt.Errorf("Unexpected panic: %+v", r)
  2713. }
  2714. }
  2715. }()
  2716. buff := util.NewBuffer()
  2717. buff.WriteUInt8(CodecVersion) // version
  2718. if target.properties == nil {
  2719. buff.WriteUInt8(uint8(0)) // write nil byte
  2720. } else {
  2721. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2722. // --- [begin][write][struct](AssetProperties) ---
  2723. a, errA := target.properties.MarshalBinary()
  2724. if errA != nil {
  2725. return nil, errA
  2726. }
  2727. buff.WriteInt(len(a))
  2728. buff.WriteBytes(a)
  2729. // --- [end][write][struct](AssetProperties) ---
  2730. }
  2731. // --- [begin][write][alias](AssetLabels) ---
  2732. if map[string]string(target.labels) == nil {
  2733. buff.WriteUInt8(uint8(0)) // write nil byte
  2734. } else {
  2735. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2736. // --- [begin][write][map](map[string]string) ---
  2737. buff.WriteInt(len(map[string]string(target.labels))) // map length
  2738. for v, z := range map[string]string(target.labels) {
  2739. buff.WriteString(v) // write string
  2740. buff.WriteString(z) // write string
  2741. }
  2742. // --- [end][write][map](map[string]string) ---
  2743. }
  2744. // --- [end][write][alias](AssetLabels) ---
  2745. // --- [begin][write][struct](Window) ---
  2746. b, errB := target.window.MarshalBinary()
  2747. if errB != nil {
  2748. return nil, errB
  2749. }
  2750. buff.WriteInt(len(b))
  2751. buff.WriteBytes(b)
  2752. // --- [end][write][struct](Window) ---
  2753. buff.WriteFloat64(target.Cost) // write float64
  2754. return buff.Bytes(), nil
  2755. }
  2756. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2757. // the SharedAsset type
  2758. func (target *SharedAsset) UnmarshalBinary(data []byte) (err error) {
  2759. // panics are recovered and propagated as errors
  2760. defer func() {
  2761. if r := recover(); r != nil {
  2762. if e, ok := r.(error); ok {
  2763. err = e
  2764. } else if s, ok := r.(string); ok {
  2765. err = fmt.Errorf("Unexpected panic: %s", s)
  2766. } else {
  2767. err = fmt.Errorf("Unexpected panic: %+v", r)
  2768. }
  2769. }
  2770. }()
  2771. buff := util.NewBufferFromBytes(data)
  2772. // Codec Version Check
  2773. version := buff.ReadUInt8()
  2774. if version != CodecVersion {
  2775. return fmt.Errorf("Invalid Version Unmarshaling SharedAsset. Expected %d, got %d", CodecVersion, version)
  2776. }
  2777. if buff.ReadUInt8() == uint8(0) {
  2778. target.properties = nil
  2779. } else {
  2780. // --- [begin][read][struct](AssetProperties) ---
  2781. a := &AssetProperties{}
  2782. b := buff.ReadInt() // byte array length
  2783. c := buff.ReadBytes(b) // byte array
  2784. errA := a.UnmarshalBinary(c)
  2785. if errA != nil {
  2786. return errA
  2787. }
  2788. target.properties = a
  2789. // --- [end][read][struct](AssetProperties) ---
  2790. }
  2791. // --- [begin][read][alias](AssetLabels) ---
  2792. var d map[string]string
  2793. if buff.ReadUInt8() == uint8(0) {
  2794. d = nil
  2795. } else {
  2796. // --- [begin][read][map](map[string]string) ---
  2797. f := buff.ReadInt() // map len
  2798. e := make(map[string]string, f)
  2799. for i := 0; i < f; i++ {
  2800. var v string
  2801. g := buff.ReadString() // read string
  2802. v = g
  2803. var z string
  2804. h := buff.ReadString() // read string
  2805. z = h
  2806. e[v] = z
  2807. }
  2808. d = e
  2809. // --- [end][read][map](map[string]string) ---
  2810. }
  2811. target.labels = AssetLabels(d)
  2812. // --- [end][read][alias](AssetLabels) ---
  2813. // --- [begin][read][struct](Window) ---
  2814. k := &Window{}
  2815. l := buff.ReadInt() // byte array length
  2816. m := buff.ReadBytes(l) // byte array
  2817. errB := k.UnmarshalBinary(m)
  2818. if errB != nil {
  2819. return errB
  2820. }
  2821. target.window = *k
  2822. // --- [end][read][struct](Window) ---
  2823. n := buff.ReadFloat64() // read float64
  2824. target.Cost = n
  2825. return nil
  2826. }
  2827. //--------------------------------------------------------------------------
  2828. // Window
  2829. //--------------------------------------------------------------------------
  2830. // MarshalBinary serializes the internal properties of this Window instance
  2831. // into a byte array
  2832. func (target *Window) MarshalBinary() (data []byte, err error) {
  2833. // panics are recovered and propagated as errors
  2834. defer func() {
  2835. if r := recover(); r != nil {
  2836. if e, ok := r.(error); ok {
  2837. err = e
  2838. } else if s, ok := r.(string); ok {
  2839. err = fmt.Errorf("Unexpected panic: %s", s)
  2840. } else {
  2841. err = fmt.Errorf("Unexpected panic: %+v", r)
  2842. }
  2843. }
  2844. }()
  2845. buff := util.NewBuffer()
  2846. buff.WriteUInt8(CodecVersion) // version
  2847. if target.start == nil {
  2848. buff.WriteUInt8(uint8(0)) // write nil byte
  2849. } else {
  2850. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2851. // --- [begin][write][reference](time.Time) ---
  2852. a, errA := target.start.MarshalBinary()
  2853. if errA != nil {
  2854. return nil, errA
  2855. }
  2856. buff.WriteInt(len(a))
  2857. buff.WriteBytes(a)
  2858. // --- [end][write][reference](time.Time) ---
  2859. }
  2860. if target.end == nil {
  2861. buff.WriteUInt8(uint8(0)) // write nil byte
  2862. } else {
  2863. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2864. // --- [begin][write][reference](time.Time) ---
  2865. b, errB := target.end.MarshalBinary()
  2866. if errB != nil {
  2867. return nil, errB
  2868. }
  2869. buff.WriteInt(len(b))
  2870. buff.WriteBytes(b)
  2871. // --- [end][write][reference](time.Time) ---
  2872. }
  2873. return buff.Bytes(), nil
  2874. }
  2875. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2876. // the Window type
  2877. func (target *Window) UnmarshalBinary(data []byte) (err error) {
  2878. // panics are recovered and propagated as errors
  2879. defer func() {
  2880. if r := recover(); r != nil {
  2881. if e, ok := r.(error); ok {
  2882. err = e
  2883. } else if s, ok := r.(string); ok {
  2884. err = fmt.Errorf("Unexpected panic: %s", s)
  2885. } else {
  2886. err = fmt.Errorf("Unexpected panic: %+v", r)
  2887. }
  2888. }
  2889. }()
  2890. buff := util.NewBufferFromBytes(data)
  2891. // Codec Version Check
  2892. version := buff.ReadUInt8()
  2893. if version != CodecVersion {
  2894. return fmt.Errorf("Invalid Version Unmarshaling Window. Expected %d, got %d", CodecVersion, version)
  2895. }
  2896. if buff.ReadUInt8() == uint8(0) {
  2897. target.start = nil
  2898. } else {
  2899. // --- [begin][read][reference](time.Time) ---
  2900. a := &time.Time{}
  2901. b := buff.ReadInt() // byte array length
  2902. c := buff.ReadBytes(b) // byte array
  2903. errA := a.UnmarshalBinary(c)
  2904. if errA != nil {
  2905. return errA
  2906. }
  2907. target.start = a
  2908. // --- [end][read][reference](time.Time) ---
  2909. }
  2910. if buff.ReadUInt8() == uint8(0) {
  2911. target.end = nil
  2912. } else {
  2913. // --- [begin][read][reference](time.Time) ---
  2914. d := &time.Time{}
  2915. e := buff.ReadInt() // byte array length
  2916. f := buff.ReadBytes(e) // byte array
  2917. errB := d.UnmarshalBinary(f)
  2918. if errB != nil {
  2919. return errB
  2920. }
  2921. target.end = d
  2922. // --- [end][read][reference](time.Time) ---
  2923. }
  2924. return nil
  2925. }