kubecost_codecs.go 81 KB

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