kubecost_codecs.go 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424
  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. "reflect"
  16. "strings"
  17. "time"
  18. util "github.com/kubecost/cost-model/pkg/util"
  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 = 4
  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. "AllocationSet": reflect.TypeOf((*AllocationSet)(nil)).Elem(),
  34. "AllocationSetRange": reflect.TypeOf((*AllocationSetRange)(nil)).Elem(),
  35. "Any": reflect.TypeOf((*Any)(nil)).Elem(),
  36. "AssetProperties": reflect.TypeOf((*AssetProperties)(nil)).Elem(),
  37. "AssetSet": reflect.TypeOf((*AssetSet)(nil)).Elem(),
  38. "AssetSetRange": reflect.TypeOf((*AssetSetRange)(nil)).Elem(),
  39. "Breakdown": reflect.TypeOf((*Breakdown)(nil)).Elem(),
  40. "Cloud": reflect.TypeOf((*Cloud)(nil)).Elem(),
  41. "ClusterManagement": reflect.TypeOf((*ClusterManagement)(nil)).Elem(),
  42. "Disk": reflect.TypeOf((*Disk)(nil)).Elem(),
  43. "LoadBalancer": reflect.TypeOf((*LoadBalancer)(nil)).Elem(),
  44. "Network": reflect.TypeOf((*Network)(nil)).Elem(),
  45. "Node": reflect.TypeOf((*Node)(nil)).Elem(),
  46. "SharedAsset": reflect.TypeOf((*SharedAsset)(nil)).Elem(),
  47. "Window": reflect.TypeOf((*Window)(nil)).Elem(),
  48. }
  49. //--------------------------------------------------------------------------
  50. // Type Helpers
  51. //--------------------------------------------------------------------------
  52. // typeToString determines the basic properties of the type, the qualifier, package path, and
  53. // type name, and returns the qualified type
  54. func typeToString(f interface{}) string {
  55. qual := ""
  56. t := reflect.TypeOf(f)
  57. if t.Kind() == reflect.Ptr {
  58. t = t.Elem()
  59. qual = "*"
  60. }
  61. return fmt.Sprintf("%s%s.%s", qual, t.PkgPath(), t.Name())
  62. }
  63. // resolveType uses the name of a type and returns the package, base type name, and whether
  64. // or not it's a pointer.
  65. func resolveType(t string) (pkg string, name string, isPtr bool) {
  66. isPtr = t[:1] == "*"
  67. if isPtr {
  68. t = t[1:]
  69. }
  70. slashIndex := strings.LastIndex(t, "/")
  71. if slashIndex >= 0 {
  72. t = t[slashIndex+1:]
  73. }
  74. parts := strings.Split(t, ".")
  75. if parts[0] == GeneratorPackageName {
  76. parts[0] = ""
  77. }
  78. pkg = parts[0]
  79. name = parts[1]
  80. return
  81. }
  82. //--------------------------------------------------------------------------
  83. // Allocation
  84. //--------------------------------------------------------------------------
  85. // MarshalBinary serializes the internal properties of this Allocation instance
  86. // into a byte array
  87. func (target *Allocation) MarshalBinary() (data []byte, err error) {
  88. buff := util.NewBuffer()
  89. buff.WriteUInt8(CodecVersion) // version
  90. buff.WriteString(target.Name) // write string
  91. // --- [begin][write][reference](Properties) ---
  92. a, errA := target.Properties.MarshalBinary()
  93. if errA != nil {
  94. return nil, errA
  95. }
  96. buff.WriteInt(len(a))
  97. buff.WriteBytes(a)
  98. // --- [end][write][reference](Properties) ---
  99. // --- [begin][write][reference](time.Time) ---
  100. b, errB := target.Start.MarshalBinary()
  101. if errB != nil {
  102. return nil, errB
  103. }
  104. buff.WriteInt(len(b))
  105. buff.WriteBytes(b)
  106. // --- [end][write][reference](time.Time) ---
  107. // --- [begin][write][reference](time.Time) ---
  108. c, errC := target.End.MarshalBinary()
  109. if errC != nil {
  110. return nil, errC
  111. }
  112. buff.WriteInt(len(c))
  113. buff.WriteBytes(c)
  114. // --- [end][write][reference](time.Time) ---
  115. buff.WriteFloat64(target.Minutes) // write float64
  116. // --- [begin][write][reference](time.Time) ---
  117. d, errD := target.ActiveStart.MarshalBinary()
  118. if errD != nil {
  119. return nil, errD
  120. }
  121. buff.WriteInt(len(d))
  122. buff.WriteBytes(d)
  123. // --- [end][write][reference](time.Time) ---
  124. buff.WriteFloat64(target.CPUCoreHours) // write float64
  125. buff.WriteFloat64(target.CPUCost) // write float64
  126. buff.WriteFloat64(target.CPUEfficiency) // write float64
  127. buff.WriteFloat64(target.GPUHours) // write float64
  128. buff.WriteFloat64(target.GPUCost) // write float64
  129. buff.WriteFloat64(target.NetworkCost) // write float64
  130. buff.WriteFloat64(target.PVByteHours) // write float64
  131. buff.WriteFloat64(target.PVCost) // write float64
  132. buff.WriteFloat64(target.RAMByteHours) // write float64
  133. buff.WriteFloat64(target.RAMCost) // write float64
  134. buff.WriteFloat64(target.RAMEfficiency) // write float64
  135. buff.WriteFloat64(target.SharedCost) // write float64
  136. buff.WriteFloat64(target.TotalCost) // write float64
  137. buff.WriteFloat64(target.TotalEfficiency) // write float64
  138. return buff.Bytes(), nil
  139. }
  140. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  141. // the Allocation type
  142. func (target *Allocation) UnmarshalBinary(data []byte) error {
  143. buff := util.NewBufferFromBytes(data)
  144. // Codec Version Check
  145. version := buff.ReadUInt8()
  146. if version != CodecVersion {
  147. return fmt.Errorf("Invalid Version Unmarshaling Allocation. Expected %d, got %d", CodecVersion, version)
  148. }
  149. a := buff.ReadString() // read string
  150. target.Name = a
  151. // --- [begin][read][reference](Properties) ---
  152. b := &Properties{}
  153. c := buff.ReadInt() // byte array length
  154. d := buff.ReadBytes(c) // byte array
  155. errA := b.UnmarshalBinary(d)
  156. if errA != nil {
  157. return errA
  158. }
  159. target.Properties = *b
  160. // --- [end][read][reference](Properties) ---
  161. // --- [begin][read][reference](time.Time) ---
  162. e := &time.Time{}
  163. f := buff.ReadInt() // byte array length
  164. g := buff.ReadBytes(f) // byte array
  165. errB := e.UnmarshalBinary(g)
  166. if errB != nil {
  167. return errB
  168. }
  169. target.Start = *e
  170. // --- [end][read][reference](time.Time) ---
  171. // --- [begin][read][reference](time.Time) ---
  172. h := &time.Time{}
  173. l := buff.ReadInt() // byte array length
  174. m := buff.ReadBytes(l) // byte array
  175. errC := h.UnmarshalBinary(m)
  176. if errC != nil {
  177. return errC
  178. }
  179. target.End = *h
  180. // --- [end][read][reference](time.Time) ---
  181. n := buff.ReadFloat64() // read float64
  182. target.Minutes = n
  183. // --- [begin][read][reference](time.Time) ---
  184. o := &time.Time{}
  185. p := buff.ReadInt() // byte array length
  186. q := buff.ReadBytes(p) // byte array
  187. errD := o.UnmarshalBinary(q)
  188. if errD != nil {
  189. return errD
  190. }
  191. target.ActiveStart = *o
  192. // --- [end][read][reference](time.Time) ---
  193. r := buff.ReadFloat64() // read float64
  194. target.CPUCoreHours = r
  195. s := buff.ReadFloat64() // read float64
  196. target.CPUCost = s
  197. t := buff.ReadFloat64() // read float64
  198. target.CPUEfficiency = t
  199. u := buff.ReadFloat64() // read float64
  200. target.GPUHours = u
  201. w := buff.ReadFloat64() // read float64
  202. target.GPUCost = w
  203. x := buff.ReadFloat64() // read float64
  204. target.NetworkCost = x
  205. y := buff.ReadFloat64() // read float64
  206. target.PVByteHours = y
  207. z := buff.ReadFloat64() // read float64
  208. target.PVCost = z
  209. aa := buff.ReadFloat64() // read float64
  210. target.RAMByteHours = aa
  211. bb := buff.ReadFloat64() // read float64
  212. target.RAMCost = bb
  213. cc := buff.ReadFloat64() // read float64
  214. target.RAMEfficiency = cc
  215. dd := buff.ReadFloat64() // read float64
  216. target.SharedCost = dd
  217. ee := buff.ReadFloat64() // read float64
  218. target.TotalCost = ee
  219. ff := buff.ReadFloat64() // read float64
  220. target.TotalEfficiency = ff
  221. return nil
  222. }
  223. //--------------------------------------------------------------------------
  224. // AllocationSet
  225. //--------------------------------------------------------------------------
  226. // MarshalBinary serializes the internal properties of this AllocationSet instance
  227. // into a byte array
  228. func (target *AllocationSet) MarshalBinary() (data []byte, err error) {
  229. buff := util.NewBuffer()
  230. buff.WriteUInt8(CodecVersion) // version
  231. if target.allocations == nil {
  232. buff.WriteUInt8(uint8(0)) // write nil byte
  233. } else {
  234. buff.WriteUInt8(uint8(1)) // write non-nil byte
  235. // --- [begin][write][map](map[string]*Allocation) ---
  236. buff.WriteInt(len(target.allocations)) // map length
  237. for k, v := range target.allocations {
  238. buff.WriteString(k) // write string
  239. if v == nil {
  240. buff.WriteUInt8(uint8(0)) // write nil byte
  241. } else {
  242. buff.WriteUInt8(uint8(1)) // write non-nil byte
  243. // --- [begin][write][struct](Allocation) ---
  244. a, errA := v.MarshalBinary()
  245. if errA != nil {
  246. return nil, errA
  247. }
  248. buff.WriteInt(len(a))
  249. buff.WriteBytes(a)
  250. // --- [end][write][struct](Allocation) ---
  251. }
  252. }
  253. // --- [end][write][map](map[string]*Allocation) ---
  254. }
  255. if target.idleKeys == nil {
  256. buff.WriteUInt8(uint8(0)) // write nil byte
  257. } else {
  258. buff.WriteUInt8(uint8(1)) // write non-nil byte
  259. // --- [begin][write][map](map[string]bool) ---
  260. buff.WriteInt(len(target.idleKeys)) // map length
  261. for kk, vv := range target.idleKeys {
  262. buff.WriteString(kk) // write string
  263. buff.WriteBool(vv) // write bool
  264. }
  265. // --- [end][write][map](map[string]bool) ---
  266. }
  267. // --- [begin][write][struct](Window) ---
  268. b, errB := target.Window.MarshalBinary()
  269. if errB != nil {
  270. return nil, errB
  271. }
  272. buff.WriteInt(len(b))
  273. buff.WriteBytes(b)
  274. // --- [end][write][struct](Window) ---
  275. if target.Warnings == nil {
  276. buff.WriteUInt8(uint8(0)) // write nil byte
  277. } else {
  278. buff.WriteUInt8(uint8(1)) // write non-nil byte
  279. // --- [begin][write][slice]([]string) ---
  280. buff.WriteInt(len(target.Warnings)) // array length
  281. for i := 0; i < len(target.Warnings); i++ {
  282. buff.WriteString(target.Warnings[i]) // write string
  283. }
  284. // --- [end][write][slice]([]string) ---
  285. }
  286. if target.Errors == nil {
  287. buff.WriteUInt8(uint8(0)) // write nil byte
  288. } else {
  289. buff.WriteUInt8(uint8(1)) // write non-nil byte
  290. // --- [begin][write][slice]([]string) ---
  291. buff.WriteInt(len(target.Errors)) // array length
  292. for j := 0; j < len(target.Errors); j++ {
  293. buff.WriteString(target.Errors[j]) // write string
  294. }
  295. // --- [end][write][slice]([]string) ---
  296. }
  297. return buff.Bytes(), nil
  298. }
  299. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  300. // the AllocationSet type
  301. func (target *AllocationSet) UnmarshalBinary(data []byte) error {
  302. buff := util.NewBufferFromBytes(data)
  303. // Codec Version Check
  304. version := buff.ReadUInt8()
  305. if version != CodecVersion {
  306. return fmt.Errorf("Invalid Version Unmarshaling AllocationSet. Expected %d, got %d", CodecVersion, version)
  307. }
  308. if buff.ReadUInt8() == uint8(0) {
  309. target.allocations = nil
  310. } else {
  311. // --- [begin][read][map](map[string]*Allocation) ---
  312. a := make(map[string]*Allocation)
  313. b := buff.ReadInt() // map len
  314. for i := 0; i < b; i++ {
  315. var k string
  316. c := buff.ReadString() // read string
  317. k = c
  318. var v *Allocation
  319. if buff.ReadUInt8() == uint8(0) {
  320. v = nil
  321. } else {
  322. // --- [begin][read][struct](Allocation) ---
  323. d := &Allocation{}
  324. e := buff.ReadInt() // byte array length
  325. f := buff.ReadBytes(e) // byte array
  326. errA := d.UnmarshalBinary(f)
  327. if errA != nil {
  328. return errA
  329. }
  330. v = d
  331. // --- [end][read][struct](Allocation) ---
  332. }
  333. a[k] = v
  334. }
  335. target.allocations = a
  336. // --- [end][read][map](map[string]*Allocation) ---
  337. }
  338. if buff.ReadUInt8() == uint8(0) {
  339. target.idleKeys = nil
  340. } else {
  341. // --- [begin][read][map](map[string]bool) ---
  342. g := make(map[string]bool)
  343. h := buff.ReadInt() // map len
  344. for j := 0; j < h; j++ {
  345. var kk string
  346. l := buff.ReadString() // read string
  347. kk = l
  348. var vv bool
  349. m := buff.ReadBool() // read bool
  350. vv = m
  351. g[kk] = vv
  352. }
  353. target.idleKeys = g
  354. // --- [end][read][map](map[string]bool) ---
  355. }
  356. // --- [begin][read][struct](Window) ---
  357. n := &Window{}
  358. o := buff.ReadInt() // byte array length
  359. p := buff.ReadBytes(o) // byte array
  360. errB := n.UnmarshalBinary(p)
  361. if errB != nil {
  362. return errB
  363. }
  364. target.Window = *n
  365. // --- [end][read][struct](Window) ---
  366. if buff.ReadUInt8() == uint8(0) {
  367. target.Warnings = nil
  368. } else {
  369. // --- [begin][read][slice]([]string) ---
  370. r := buff.ReadInt() // array len
  371. q := make([]string, r)
  372. for ii := 0; ii < r; ii++ {
  373. var s string
  374. t := buff.ReadString() // read string
  375. s = t
  376. q[ii] = s
  377. }
  378. target.Warnings = q
  379. // --- [end][read][slice]([]string) ---
  380. }
  381. if buff.ReadUInt8() == uint8(0) {
  382. target.Errors = nil
  383. } else {
  384. // --- [begin][read][slice]([]string) ---
  385. w := buff.ReadInt() // array len
  386. u := make([]string, w)
  387. for jj := 0; jj < w; jj++ {
  388. var x string
  389. y := buff.ReadString() // read string
  390. x = y
  391. u[jj] = x
  392. }
  393. target.Errors = u
  394. // --- [end][read][slice]([]string) ---
  395. }
  396. return nil
  397. }
  398. //--------------------------------------------------------------------------
  399. // AllocationSetRange
  400. //--------------------------------------------------------------------------
  401. // MarshalBinary serializes the internal properties of this AllocationSetRange instance
  402. // into a byte array
  403. func (target *AllocationSetRange) MarshalBinary() (data []byte, err error) {
  404. buff := util.NewBuffer()
  405. buff.WriteUInt8(CodecVersion) // version
  406. if target.allocations == nil {
  407. buff.WriteUInt8(uint8(0)) // write nil byte
  408. } else {
  409. buff.WriteUInt8(uint8(1)) // write non-nil byte
  410. // --- [begin][write][slice]([]*AllocationSet) ---
  411. buff.WriteInt(len(target.allocations)) // array length
  412. for i := 0; i < len(target.allocations); i++ {
  413. if target.allocations[i] == nil {
  414. buff.WriteUInt8(uint8(0)) // write nil byte
  415. } else {
  416. buff.WriteUInt8(uint8(1)) // write non-nil byte
  417. // --- [begin][write][struct](AllocationSet) ---
  418. a, errA := target.allocations[i].MarshalBinary()
  419. if errA != nil {
  420. return nil, errA
  421. }
  422. buff.WriteInt(len(a))
  423. buff.WriteBytes(a)
  424. // --- [end][write][struct](AllocationSet) ---
  425. }
  426. }
  427. // --- [end][write][slice]([]*AllocationSet) ---
  428. }
  429. return buff.Bytes(), nil
  430. }
  431. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  432. // the AllocationSetRange type
  433. func (target *AllocationSetRange) UnmarshalBinary(data []byte) error {
  434. buff := util.NewBufferFromBytes(data)
  435. // Codec Version Check
  436. version := buff.ReadUInt8()
  437. if version != CodecVersion {
  438. return fmt.Errorf("Invalid Version Unmarshaling AllocationSetRange. Expected %d, got %d", CodecVersion, version)
  439. }
  440. if buff.ReadUInt8() == uint8(0) {
  441. target.allocations = nil
  442. } else {
  443. // --- [begin][read][slice]([]*AllocationSet) ---
  444. b := buff.ReadInt() // array len
  445. a := make([]*AllocationSet, b)
  446. for i := 0; i < b; i++ {
  447. var c *AllocationSet
  448. if buff.ReadUInt8() == uint8(0) {
  449. c = nil
  450. } else {
  451. // --- [begin][read][struct](AllocationSet) ---
  452. d := &AllocationSet{}
  453. e := buff.ReadInt() // byte array length
  454. f := buff.ReadBytes(e) // byte array
  455. errA := d.UnmarshalBinary(f)
  456. if errA != nil {
  457. return errA
  458. }
  459. c = d
  460. // --- [end][read][struct](AllocationSet) ---
  461. }
  462. a[i] = c
  463. }
  464. target.allocations = a
  465. // --- [end][read][slice]([]*AllocationSet) ---
  466. }
  467. return nil
  468. }
  469. //--------------------------------------------------------------------------
  470. // Any
  471. //--------------------------------------------------------------------------
  472. // MarshalBinary serializes the internal properties of this Any instance
  473. // into a byte array
  474. func (target *Any) MarshalBinary() (data []byte, err error) {
  475. buff := util.NewBuffer()
  476. buff.WriteUInt8(CodecVersion) // version
  477. // --- [begin][write][alias](AssetLabels) ---
  478. if map[string]string(target.labels) == nil {
  479. buff.WriteUInt8(uint8(0)) // write nil byte
  480. } else {
  481. buff.WriteUInt8(uint8(1)) // write non-nil byte
  482. // --- [begin][write][map](map[string]string) ---
  483. buff.WriteInt(len(map[string]string(target.labels))) // map length
  484. for k, v := range map[string]string(target.labels) {
  485. buff.WriteString(k) // write string
  486. buff.WriteString(v) // write string
  487. }
  488. // --- [end][write][map](map[string]string) ---
  489. }
  490. // --- [end][write][alias](AssetLabels) ---
  491. if target.properties == nil {
  492. buff.WriteUInt8(uint8(0)) // write nil byte
  493. } else {
  494. buff.WriteUInt8(uint8(1)) // write non-nil byte
  495. // --- [begin][write][struct](AssetProperties) ---
  496. a, errA := target.properties.MarshalBinary()
  497. if errA != nil {
  498. return nil, errA
  499. }
  500. buff.WriteInt(len(a))
  501. buff.WriteBytes(a)
  502. // --- [end][write][struct](AssetProperties) ---
  503. }
  504. // --- [begin][write][reference](time.Time) ---
  505. b, errB := target.start.MarshalBinary()
  506. if errB != nil {
  507. return nil, errB
  508. }
  509. buff.WriteInt(len(b))
  510. buff.WriteBytes(b)
  511. // --- [end][write][reference](time.Time) ---
  512. // --- [begin][write][reference](time.Time) ---
  513. c, errC := target.end.MarshalBinary()
  514. if errC != nil {
  515. return nil, errC
  516. }
  517. buff.WriteInt(len(c))
  518. buff.WriteBytes(c)
  519. // --- [end][write][reference](time.Time) ---
  520. // --- [begin][write][struct](Window) ---
  521. d, errD := target.window.MarshalBinary()
  522. if errD != nil {
  523. return nil, errD
  524. }
  525. buff.WriteInt(len(d))
  526. buff.WriteBytes(d)
  527. // --- [end][write][struct](Window) ---
  528. buff.WriteFloat64(target.adjustment) // write float64
  529. buff.WriteFloat64(target.Cost) // write float64
  530. return buff.Bytes(), nil
  531. }
  532. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  533. // the Any type
  534. func (target *Any) UnmarshalBinary(data []byte) error {
  535. buff := util.NewBufferFromBytes(data)
  536. // Codec Version Check
  537. version := buff.ReadUInt8()
  538. if version != CodecVersion {
  539. return fmt.Errorf("Invalid Version Unmarshaling Any. Expected %d, got %d", CodecVersion, version)
  540. }
  541. // --- [begin][read][alias](AssetLabels) ---
  542. var a map[string]string
  543. if buff.ReadUInt8() == uint8(0) {
  544. a = nil
  545. } else {
  546. // --- [begin][read][map](map[string]string) ---
  547. b := make(map[string]string)
  548. c := buff.ReadInt() // map len
  549. for i := 0; i < c; i++ {
  550. var k string
  551. d := buff.ReadString() // read string
  552. k = d
  553. var v string
  554. e := buff.ReadString() // read string
  555. v = e
  556. b[k] = v
  557. }
  558. a = b
  559. // --- [end][read][map](map[string]string) ---
  560. }
  561. target.labels = AssetLabels(a)
  562. // --- [end][read][alias](AssetLabels) ---
  563. if buff.ReadUInt8() == uint8(0) {
  564. target.properties = nil
  565. } else {
  566. // --- [begin][read][struct](AssetProperties) ---
  567. f := &AssetProperties{}
  568. g := buff.ReadInt() // byte array length
  569. h := buff.ReadBytes(g) // byte array
  570. errA := f.UnmarshalBinary(h)
  571. if errA != nil {
  572. return errA
  573. }
  574. target.properties = f
  575. // --- [end][read][struct](AssetProperties) ---
  576. }
  577. // --- [begin][read][reference](time.Time) ---
  578. l := &time.Time{}
  579. m := buff.ReadInt() // byte array length
  580. n := buff.ReadBytes(m) // byte array
  581. errB := l.UnmarshalBinary(n)
  582. if errB != nil {
  583. return errB
  584. }
  585. target.start = *l
  586. // --- [end][read][reference](time.Time) ---
  587. // --- [begin][read][reference](time.Time) ---
  588. o := &time.Time{}
  589. p := buff.ReadInt() // byte array length
  590. q := buff.ReadBytes(p) // byte array
  591. errC := o.UnmarshalBinary(q)
  592. if errC != nil {
  593. return errC
  594. }
  595. target.end = *o
  596. // --- [end][read][reference](time.Time) ---
  597. // --- [begin][read][struct](Window) ---
  598. r := &Window{}
  599. s := buff.ReadInt() // byte array length
  600. t := buff.ReadBytes(s) // byte array
  601. errD := r.UnmarshalBinary(t)
  602. if errD != nil {
  603. return errD
  604. }
  605. target.window = *r
  606. // --- [end][read][struct](Window) ---
  607. u := buff.ReadFloat64() // read float64
  608. target.adjustment = u
  609. w := buff.ReadFloat64() // read float64
  610. target.Cost = w
  611. return nil
  612. }
  613. //--------------------------------------------------------------------------
  614. // AssetProperties
  615. //--------------------------------------------------------------------------
  616. // MarshalBinary serializes the internal properties of this AssetProperties instance
  617. // into a byte array
  618. func (target *AssetProperties) MarshalBinary() (data []byte, err error) {
  619. buff := util.NewBuffer()
  620. buff.WriteUInt8(CodecVersion) // version
  621. buff.WriteString(target.Category) // write string
  622. buff.WriteString(target.Provider) // write string
  623. buff.WriteString(target.Account) // write string
  624. buff.WriteString(target.Project) // write string
  625. buff.WriteString(target.Service) // write string
  626. buff.WriteString(target.Cluster) // write string
  627. buff.WriteString(target.Name) // write string
  628. buff.WriteString(target.ProviderID) // write string
  629. return buff.Bytes(), nil
  630. }
  631. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  632. // the AssetProperties type
  633. func (target *AssetProperties) UnmarshalBinary(data []byte) error {
  634. buff := util.NewBufferFromBytes(data)
  635. // Codec Version Check
  636. version := buff.ReadUInt8()
  637. if version != CodecVersion {
  638. return fmt.Errorf("Invalid Version Unmarshaling AssetProperties. Expected %d, got %d", CodecVersion, version)
  639. }
  640. a := buff.ReadString() // read string
  641. target.Category = a
  642. b := buff.ReadString() // read string
  643. target.Provider = b
  644. c := buff.ReadString() // read string
  645. target.Account = c
  646. d := buff.ReadString() // read string
  647. target.Project = d
  648. e := buff.ReadString() // read string
  649. target.Service = e
  650. f := buff.ReadString() // read string
  651. target.Cluster = f
  652. g := buff.ReadString() // read string
  653. target.Name = g
  654. h := buff.ReadString() // read string
  655. target.ProviderID = h
  656. return nil
  657. }
  658. //--------------------------------------------------------------------------
  659. // AssetSet
  660. //--------------------------------------------------------------------------
  661. // MarshalBinary serializes the internal properties of this AssetSet instance
  662. // into a byte array
  663. func (target *AssetSet) MarshalBinary() (data []byte, err error) {
  664. buff := util.NewBuffer()
  665. buff.WriteUInt8(CodecVersion) // version
  666. if target.assets == nil {
  667. buff.WriteUInt8(uint8(0)) // write nil byte
  668. } else {
  669. buff.WriteUInt8(uint8(1)) // write non-nil byte
  670. // --- [begin][write][map](map[string]Asset) ---
  671. buff.WriteInt(len(target.assets)) // map length
  672. for k, v := range target.assets {
  673. buff.WriteString(k) // write string
  674. if v == nil {
  675. buff.WriteUInt8(uint8(0)) // write nil byte
  676. } else {
  677. buff.WriteUInt8(uint8(1)) // write non-nil byte
  678. // --- [begin][write][interface](Asset) ---
  679. a := reflect.ValueOf(v).Interface()
  680. b, okA := a.(encoding.BinaryMarshaler)
  681. if !okA {
  682. return nil, fmt.Errorf("Type: %s does not implement encoding.BinaryMarshaler", typeToString(v))
  683. }
  684. c, errA := b.MarshalBinary()
  685. if errA != nil {
  686. return nil, errA
  687. }
  688. buff.WriteString(typeToString(v))
  689. buff.WriteInt(len(c))
  690. buff.WriteBytes(c)
  691. // --- [end][write][interface](Asset) ---
  692. }
  693. }
  694. // --- [end][write][map](map[string]Asset) ---
  695. }
  696. if target.props == nil {
  697. buff.WriteUInt8(uint8(0)) // write nil byte
  698. } else {
  699. buff.WriteUInt8(uint8(1)) // write non-nil byte
  700. // --- [begin][write][slice]([]AssetProperty) ---
  701. buff.WriteInt(len(target.props)) // array length
  702. for i := 0; i < len(target.props); i++ {
  703. // --- [begin][write][alias](AssetProperty) ---
  704. buff.WriteString(string(target.props[i])) // write string
  705. // --- [end][write][alias](AssetProperty) ---
  706. }
  707. // --- [end][write][slice]([]AssetProperty) ---
  708. }
  709. // --- [begin][write][struct](Window) ---
  710. d, errB := target.Window.MarshalBinary()
  711. if errB != nil {
  712. return nil, errB
  713. }
  714. buff.WriteInt(len(d))
  715. buff.WriteBytes(d)
  716. // --- [end][write][struct](Window) ---
  717. if target.Warnings == nil {
  718. buff.WriteUInt8(uint8(0)) // write nil byte
  719. } else {
  720. buff.WriteUInt8(uint8(1)) // write non-nil byte
  721. // --- [begin][write][slice]([]string) ---
  722. buff.WriteInt(len(target.Warnings)) // array length
  723. for j := 0; j < len(target.Warnings); j++ {
  724. buff.WriteString(target.Warnings[j]) // write string
  725. }
  726. // --- [end][write][slice]([]string) ---
  727. }
  728. if target.Errors == nil {
  729. buff.WriteUInt8(uint8(0)) // write nil byte
  730. } else {
  731. buff.WriteUInt8(uint8(1)) // write non-nil byte
  732. // --- [begin][write][slice]([]string) ---
  733. buff.WriteInt(len(target.Errors)) // array length
  734. for ii := 0; ii < len(target.Errors); ii++ {
  735. buff.WriteString(target.Errors[ii]) // write string
  736. }
  737. // --- [end][write][slice]([]string) ---
  738. }
  739. return buff.Bytes(), nil
  740. }
  741. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  742. // the AssetSet type
  743. func (target *AssetSet) UnmarshalBinary(data []byte) error {
  744. buff := util.NewBufferFromBytes(data)
  745. // Codec Version Check
  746. version := buff.ReadUInt8()
  747. if version != CodecVersion {
  748. return fmt.Errorf("Invalid Version Unmarshaling AssetSet. Expected %d, got %d", CodecVersion, version)
  749. }
  750. if buff.ReadUInt8() == uint8(0) {
  751. target.assets = nil
  752. } else {
  753. // --- [begin][read][map](map[string]Asset) ---
  754. a := make(map[string]Asset)
  755. b := buff.ReadInt() // map len
  756. for i := 0; i < b; i++ {
  757. var k string
  758. c := buff.ReadString() // read string
  759. k = c
  760. var v Asset
  761. if buff.ReadUInt8() == uint8(0) {
  762. v = nil
  763. } else {
  764. // --- [begin][read][interface](Asset) ---
  765. d := buff.ReadString()
  766. _, e, _ := resolveType(d)
  767. if _, ok := typeMap[e]; !ok {
  768. return fmt.Errorf("Unknown Type: %s", e)
  769. }
  770. f, okA := reflect.New(typeMap[e]).Interface().(interface{ UnmarshalBinary([]byte) error })
  771. if !okA {
  772. return fmt.Errorf("Type: %s does not implement UnmarshalBinary([]byte) error", e)
  773. }
  774. g := buff.ReadInt() // byte array length
  775. h := buff.ReadBytes(g) // byte array
  776. errA := f.UnmarshalBinary(h)
  777. if errA != nil {
  778. return errA
  779. }
  780. v = f.(Asset)
  781. // --- [end][read][interface](Asset) ---
  782. }
  783. a[k] = v
  784. }
  785. target.assets = a
  786. // --- [end][read][map](map[string]Asset) ---
  787. }
  788. if buff.ReadUInt8() == uint8(0) {
  789. target.props = nil
  790. } else {
  791. // --- [begin][read][slice]([]AssetProperty) ---
  792. m := buff.ReadInt() // array len
  793. l := make([]AssetProperty, m)
  794. for j := 0; j < m; j++ {
  795. // --- [begin][read][alias](AssetProperty) ---
  796. var o string
  797. p := buff.ReadString() // read string
  798. o = p
  799. n := AssetProperty(o)
  800. // --- [end][read][alias](AssetProperty) ---
  801. l[j] = n
  802. }
  803. target.props = l
  804. // --- [end][read][slice]([]AssetProperty) ---
  805. }
  806. // --- [begin][read][struct](Window) ---
  807. q := &Window{}
  808. r := buff.ReadInt() // byte array length
  809. s := buff.ReadBytes(r) // byte array
  810. errB := q.UnmarshalBinary(s)
  811. if errB != nil {
  812. return errB
  813. }
  814. target.Window = *q
  815. // --- [end][read][struct](Window) ---
  816. if buff.ReadUInt8() == uint8(0) {
  817. target.Warnings = nil
  818. } else {
  819. // --- [begin][read][slice]([]string) ---
  820. u := buff.ReadInt() // array len
  821. t := make([]string, u)
  822. for ii := 0; ii < u; ii++ {
  823. var w string
  824. x := buff.ReadString() // read string
  825. w = x
  826. t[ii] = w
  827. }
  828. target.Warnings = t
  829. // --- [end][read][slice]([]string) ---
  830. }
  831. if buff.ReadUInt8() == uint8(0) {
  832. target.Errors = nil
  833. } else {
  834. // --- [begin][read][slice]([]string) ---
  835. z := buff.ReadInt() // array len
  836. y := make([]string, z)
  837. for jj := 0; jj < z; jj++ {
  838. var aa string
  839. bb := buff.ReadString() // read string
  840. aa = bb
  841. y[jj] = aa
  842. }
  843. target.Errors = y
  844. // --- [end][read][slice]([]string) ---
  845. }
  846. return nil
  847. }
  848. //--------------------------------------------------------------------------
  849. // AssetSetRange
  850. //--------------------------------------------------------------------------
  851. // MarshalBinary serializes the internal properties of this AssetSetRange instance
  852. // into a byte array
  853. func (target *AssetSetRange) MarshalBinary() (data []byte, err error) {
  854. buff := util.NewBuffer()
  855. buff.WriteUInt8(CodecVersion) // version
  856. if target.assets == nil {
  857. buff.WriteUInt8(uint8(0)) // write nil byte
  858. } else {
  859. buff.WriteUInt8(uint8(1)) // write non-nil byte
  860. // --- [begin][write][slice]([]*AssetSet) ---
  861. buff.WriteInt(len(target.assets)) // array length
  862. for i := 0; i < len(target.assets); i++ {
  863. if target.assets[i] == nil {
  864. buff.WriteUInt8(uint8(0)) // write nil byte
  865. } else {
  866. buff.WriteUInt8(uint8(1)) // write non-nil byte
  867. // --- [begin][write][struct](AssetSet) ---
  868. a, errA := target.assets[i].MarshalBinary()
  869. if errA != nil {
  870. return nil, errA
  871. }
  872. buff.WriteInt(len(a))
  873. buff.WriteBytes(a)
  874. // --- [end][write][struct](AssetSet) ---
  875. }
  876. }
  877. // --- [end][write][slice]([]*AssetSet) ---
  878. }
  879. return buff.Bytes(), nil
  880. }
  881. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  882. // the AssetSetRange type
  883. func (target *AssetSetRange) UnmarshalBinary(data []byte) error {
  884. buff := util.NewBufferFromBytes(data)
  885. // Codec Version Check
  886. version := buff.ReadUInt8()
  887. if version != CodecVersion {
  888. return fmt.Errorf("Invalid Version Unmarshaling AssetSetRange. Expected %d, got %d", CodecVersion, version)
  889. }
  890. if buff.ReadUInt8() == uint8(0) {
  891. target.assets = nil
  892. } else {
  893. // --- [begin][read][slice]([]*AssetSet) ---
  894. b := buff.ReadInt() // array len
  895. a := make([]*AssetSet, b)
  896. for i := 0; i < b; i++ {
  897. var c *AssetSet
  898. if buff.ReadUInt8() == uint8(0) {
  899. c = nil
  900. } else {
  901. // --- [begin][read][struct](AssetSet) ---
  902. d := &AssetSet{}
  903. e := buff.ReadInt() // byte array length
  904. f := buff.ReadBytes(e) // byte array
  905. errA := d.UnmarshalBinary(f)
  906. if errA != nil {
  907. return errA
  908. }
  909. c = d
  910. // --- [end][read][struct](AssetSet) ---
  911. }
  912. a[i] = c
  913. }
  914. target.assets = a
  915. // --- [end][read][slice]([]*AssetSet) ---
  916. }
  917. return nil
  918. }
  919. //--------------------------------------------------------------------------
  920. // Breakdown
  921. //--------------------------------------------------------------------------
  922. // MarshalBinary serializes the internal properties of this Breakdown instance
  923. // into a byte array
  924. func (target *Breakdown) MarshalBinary() (data []byte, err error) {
  925. buff := util.NewBuffer()
  926. buff.WriteUInt8(CodecVersion) // version
  927. buff.WriteFloat64(target.Idle) // write float64
  928. buff.WriteFloat64(target.Other) // write float64
  929. buff.WriteFloat64(target.System) // write float64
  930. buff.WriteFloat64(target.User) // write float64
  931. return buff.Bytes(), nil
  932. }
  933. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  934. // the Breakdown type
  935. func (target *Breakdown) UnmarshalBinary(data []byte) error {
  936. buff := util.NewBufferFromBytes(data)
  937. // Codec Version Check
  938. version := buff.ReadUInt8()
  939. if version != CodecVersion {
  940. return fmt.Errorf("Invalid Version Unmarshaling Breakdown. Expected %d, got %d", CodecVersion, version)
  941. }
  942. a := buff.ReadFloat64() // read float64
  943. target.Idle = a
  944. b := buff.ReadFloat64() // read float64
  945. target.Other = b
  946. c := buff.ReadFloat64() // read float64
  947. target.System = c
  948. d := buff.ReadFloat64() // read float64
  949. target.User = d
  950. return nil
  951. }
  952. //--------------------------------------------------------------------------
  953. // Cloud
  954. //--------------------------------------------------------------------------
  955. // MarshalBinary serializes the internal properties of this Cloud instance
  956. // into a byte array
  957. func (target *Cloud) MarshalBinary() (data []byte, err error) {
  958. buff := util.NewBuffer()
  959. buff.WriteUInt8(CodecVersion) // version
  960. // --- [begin][write][alias](AssetLabels) ---
  961. if map[string]string(target.labels) == nil {
  962. buff.WriteUInt8(uint8(0)) // write nil byte
  963. } else {
  964. buff.WriteUInt8(uint8(1)) // write non-nil byte
  965. // --- [begin][write][map](map[string]string) ---
  966. buff.WriteInt(len(map[string]string(target.labels))) // map length
  967. for k, v := range map[string]string(target.labels) {
  968. buff.WriteString(k) // write string
  969. buff.WriteString(v) // write string
  970. }
  971. // --- [end][write][map](map[string]string) ---
  972. }
  973. // --- [end][write][alias](AssetLabels) ---
  974. if target.properties == nil {
  975. buff.WriteUInt8(uint8(0)) // write nil byte
  976. } else {
  977. buff.WriteUInt8(uint8(1)) // write non-nil byte
  978. // --- [begin][write][struct](AssetProperties) ---
  979. a, errA := target.properties.MarshalBinary()
  980. if errA != nil {
  981. return nil, errA
  982. }
  983. buff.WriteInt(len(a))
  984. buff.WriteBytes(a)
  985. // --- [end][write][struct](AssetProperties) ---
  986. }
  987. // --- [begin][write][reference](time.Time) ---
  988. b, errB := target.start.MarshalBinary()
  989. if errB != nil {
  990. return nil, errB
  991. }
  992. buff.WriteInt(len(b))
  993. buff.WriteBytes(b)
  994. // --- [end][write][reference](time.Time) ---
  995. // --- [begin][write][reference](time.Time) ---
  996. c, errC := target.end.MarshalBinary()
  997. if errC != nil {
  998. return nil, errC
  999. }
  1000. buff.WriteInt(len(c))
  1001. buff.WriteBytes(c)
  1002. // --- [end][write][reference](time.Time) ---
  1003. // --- [begin][write][struct](Window) ---
  1004. d, errD := target.window.MarshalBinary()
  1005. if errD != nil {
  1006. return nil, errD
  1007. }
  1008. buff.WriteInt(len(d))
  1009. buff.WriteBytes(d)
  1010. // --- [end][write][struct](Window) ---
  1011. buff.WriteFloat64(target.adjustment) // write float64
  1012. buff.WriteFloat64(target.Cost) // write float64
  1013. return buff.Bytes(), nil
  1014. }
  1015. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1016. // the Cloud type
  1017. func (target *Cloud) UnmarshalBinary(data []byte) error {
  1018. buff := util.NewBufferFromBytes(data)
  1019. // Codec Version Check
  1020. version := buff.ReadUInt8()
  1021. if version != CodecVersion {
  1022. return fmt.Errorf("Invalid Version Unmarshaling Cloud. Expected %d, got %d", CodecVersion, version)
  1023. }
  1024. // --- [begin][read][alias](AssetLabels) ---
  1025. var a map[string]string
  1026. if buff.ReadUInt8() == uint8(0) {
  1027. a = nil
  1028. } else {
  1029. // --- [begin][read][map](map[string]string) ---
  1030. b := make(map[string]string)
  1031. c := buff.ReadInt() // map len
  1032. for i := 0; i < c; i++ {
  1033. var k string
  1034. d := buff.ReadString() // read string
  1035. k = d
  1036. var v string
  1037. e := buff.ReadString() // read string
  1038. v = e
  1039. b[k] = v
  1040. }
  1041. a = b
  1042. // --- [end][read][map](map[string]string) ---
  1043. }
  1044. target.labels = AssetLabels(a)
  1045. // --- [end][read][alias](AssetLabels) ---
  1046. if buff.ReadUInt8() == uint8(0) {
  1047. target.properties = nil
  1048. } else {
  1049. // --- [begin][read][struct](AssetProperties) ---
  1050. f := &AssetProperties{}
  1051. g := buff.ReadInt() // byte array length
  1052. h := buff.ReadBytes(g) // byte array
  1053. errA := f.UnmarshalBinary(h)
  1054. if errA != nil {
  1055. return errA
  1056. }
  1057. target.properties = f
  1058. // --- [end][read][struct](AssetProperties) ---
  1059. }
  1060. // --- [begin][read][reference](time.Time) ---
  1061. l := &time.Time{}
  1062. m := buff.ReadInt() // byte array length
  1063. n := buff.ReadBytes(m) // byte array
  1064. errB := l.UnmarshalBinary(n)
  1065. if errB != nil {
  1066. return errB
  1067. }
  1068. target.start = *l
  1069. // --- [end][read][reference](time.Time) ---
  1070. // --- [begin][read][reference](time.Time) ---
  1071. o := &time.Time{}
  1072. p := buff.ReadInt() // byte array length
  1073. q := buff.ReadBytes(p) // byte array
  1074. errC := o.UnmarshalBinary(q)
  1075. if errC != nil {
  1076. return errC
  1077. }
  1078. target.end = *o
  1079. // --- [end][read][reference](time.Time) ---
  1080. // --- [begin][read][struct](Window) ---
  1081. r := &Window{}
  1082. s := buff.ReadInt() // byte array length
  1083. t := buff.ReadBytes(s) // byte array
  1084. errD := r.UnmarshalBinary(t)
  1085. if errD != nil {
  1086. return errD
  1087. }
  1088. target.window = *r
  1089. // --- [end][read][struct](Window) ---
  1090. u := buff.ReadFloat64() // read float64
  1091. target.adjustment = u
  1092. w := buff.ReadFloat64() // read float64
  1093. target.Cost = w
  1094. return nil
  1095. }
  1096. //--------------------------------------------------------------------------
  1097. // ClusterManagement
  1098. //--------------------------------------------------------------------------
  1099. // MarshalBinary serializes the internal properties of this ClusterManagement instance
  1100. // into a byte array
  1101. func (target *ClusterManagement) MarshalBinary() (data []byte, err error) {
  1102. buff := util.NewBuffer()
  1103. buff.WriteUInt8(CodecVersion) // version
  1104. // --- [begin][write][alias](AssetLabels) ---
  1105. if map[string]string(target.labels) == nil {
  1106. buff.WriteUInt8(uint8(0)) // write nil byte
  1107. } else {
  1108. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1109. // --- [begin][write][map](map[string]string) ---
  1110. buff.WriteInt(len(map[string]string(target.labels))) // map length
  1111. for k, v := range map[string]string(target.labels) {
  1112. buff.WriteString(k) // write string
  1113. buff.WriteString(v) // write string
  1114. }
  1115. // --- [end][write][map](map[string]string) ---
  1116. }
  1117. // --- [end][write][alias](AssetLabels) ---
  1118. if target.properties == nil {
  1119. buff.WriteUInt8(uint8(0)) // write nil byte
  1120. } else {
  1121. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1122. // --- [begin][write][struct](AssetProperties) ---
  1123. a, errA := target.properties.MarshalBinary()
  1124. if errA != nil {
  1125. return nil, errA
  1126. }
  1127. buff.WriteInt(len(a))
  1128. buff.WriteBytes(a)
  1129. // --- [end][write][struct](AssetProperties) ---
  1130. }
  1131. // --- [begin][write][struct](Window) ---
  1132. b, errB := target.window.MarshalBinary()
  1133. if errB != nil {
  1134. return nil, errB
  1135. }
  1136. buff.WriteInt(len(b))
  1137. buff.WriteBytes(b)
  1138. // --- [end][write][struct](Window) ---
  1139. buff.WriteFloat64(target.Cost) // write float64
  1140. return buff.Bytes(), nil
  1141. }
  1142. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1143. // the ClusterManagement type
  1144. func (target *ClusterManagement) UnmarshalBinary(data []byte) error {
  1145. buff := util.NewBufferFromBytes(data)
  1146. // Codec Version Check
  1147. version := buff.ReadUInt8()
  1148. if version != CodecVersion {
  1149. return fmt.Errorf("Invalid Version Unmarshaling ClusterManagement. Expected %d, got %d", CodecVersion, version)
  1150. }
  1151. // --- [begin][read][alias](AssetLabels) ---
  1152. var a map[string]string
  1153. if buff.ReadUInt8() == uint8(0) {
  1154. a = nil
  1155. } else {
  1156. // --- [begin][read][map](map[string]string) ---
  1157. b := make(map[string]string)
  1158. c := buff.ReadInt() // map len
  1159. for i := 0; i < c; i++ {
  1160. var k string
  1161. d := buff.ReadString() // read string
  1162. k = d
  1163. var v string
  1164. e := buff.ReadString() // read string
  1165. v = e
  1166. b[k] = v
  1167. }
  1168. a = b
  1169. // --- [end][read][map](map[string]string) ---
  1170. }
  1171. target.labels = AssetLabels(a)
  1172. // --- [end][read][alias](AssetLabels) ---
  1173. if buff.ReadUInt8() == uint8(0) {
  1174. target.properties = nil
  1175. } else {
  1176. // --- [begin][read][struct](AssetProperties) ---
  1177. f := &AssetProperties{}
  1178. g := buff.ReadInt() // byte array length
  1179. h := buff.ReadBytes(g) // byte array
  1180. errA := f.UnmarshalBinary(h)
  1181. if errA != nil {
  1182. return errA
  1183. }
  1184. target.properties = f
  1185. // --- [end][read][struct](AssetProperties) ---
  1186. }
  1187. // --- [begin][read][struct](Window) ---
  1188. l := &Window{}
  1189. m := buff.ReadInt() // byte array length
  1190. n := buff.ReadBytes(m) // byte array
  1191. errB := l.UnmarshalBinary(n)
  1192. if errB != nil {
  1193. return errB
  1194. }
  1195. target.window = *l
  1196. // --- [end][read][struct](Window) ---
  1197. o := buff.ReadFloat64() // read float64
  1198. target.Cost = o
  1199. return nil
  1200. }
  1201. //--------------------------------------------------------------------------
  1202. // Disk
  1203. //--------------------------------------------------------------------------
  1204. // MarshalBinary serializes the internal properties of this Disk instance
  1205. // into a byte array
  1206. func (target *Disk) MarshalBinary() (data []byte, err error) {
  1207. buff := util.NewBuffer()
  1208. buff.WriteUInt8(CodecVersion) // version
  1209. // --- [begin][write][alias](AssetLabels) ---
  1210. if map[string]string(target.labels) == nil {
  1211. buff.WriteUInt8(uint8(0)) // write nil byte
  1212. } else {
  1213. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1214. // --- [begin][write][map](map[string]string) ---
  1215. buff.WriteInt(len(map[string]string(target.labels))) // map length
  1216. for k, v := range map[string]string(target.labels) {
  1217. buff.WriteString(k) // write string
  1218. buff.WriteString(v) // write string
  1219. }
  1220. // --- [end][write][map](map[string]string) ---
  1221. }
  1222. // --- [end][write][alias](AssetLabels) ---
  1223. if target.properties == nil {
  1224. buff.WriteUInt8(uint8(0)) // write nil byte
  1225. } else {
  1226. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1227. // --- [begin][write][struct](AssetProperties) ---
  1228. a, errA := target.properties.MarshalBinary()
  1229. if errA != nil {
  1230. return nil, errA
  1231. }
  1232. buff.WriteInt(len(a))
  1233. buff.WriteBytes(a)
  1234. // --- [end][write][struct](AssetProperties) ---
  1235. }
  1236. // --- [begin][write][reference](time.Time) ---
  1237. b, errB := target.start.MarshalBinary()
  1238. if errB != nil {
  1239. return nil, errB
  1240. }
  1241. buff.WriteInt(len(b))
  1242. buff.WriteBytes(b)
  1243. // --- [end][write][reference](time.Time) ---
  1244. // --- [begin][write][reference](time.Time) ---
  1245. c, errC := target.end.MarshalBinary()
  1246. if errC != nil {
  1247. return nil, errC
  1248. }
  1249. buff.WriteInt(len(c))
  1250. buff.WriteBytes(c)
  1251. // --- [end][write][reference](time.Time) ---
  1252. // --- [begin][write][struct](Window) ---
  1253. d, errD := target.window.MarshalBinary()
  1254. if errD != nil {
  1255. return nil, errD
  1256. }
  1257. buff.WriteInt(len(d))
  1258. buff.WriteBytes(d)
  1259. // --- [end][write][struct](Window) ---
  1260. buff.WriteFloat64(target.adjustment) // write float64
  1261. buff.WriteFloat64(target.Cost) // write float64
  1262. buff.WriteFloat64(target.ByteHours) // write float64
  1263. buff.WriteFloat64(target.Local) // write float64
  1264. if target.Breakdown == nil {
  1265. buff.WriteUInt8(uint8(0)) // write nil byte
  1266. } else {
  1267. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1268. // --- [begin][write][struct](Breakdown) ---
  1269. e, errE := target.Breakdown.MarshalBinary()
  1270. if errE != nil {
  1271. return nil, errE
  1272. }
  1273. buff.WriteInt(len(e))
  1274. buff.WriteBytes(e)
  1275. // --- [end][write][struct](Breakdown) ---
  1276. }
  1277. return buff.Bytes(), nil
  1278. }
  1279. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1280. // the Disk type
  1281. func (target *Disk) UnmarshalBinary(data []byte) error {
  1282. buff := util.NewBufferFromBytes(data)
  1283. // Codec Version Check
  1284. version := buff.ReadUInt8()
  1285. if version != CodecVersion {
  1286. return fmt.Errorf("Invalid Version Unmarshaling Disk. Expected %d, got %d", CodecVersion, version)
  1287. }
  1288. // --- [begin][read][alias](AssetLabels) ---
  1289. var a map[string]string
  1290. if buff.ReadUInt8() == uint8(0) {
  1291. a = nil
  1292. } else {
  1293. // --- [begin][read][map](map[string]string) ---
  1294. b := make(map[string]string)
  1295. c := buff.ReadInt() // map len
  1296. for i := 0; i < c; i++ {
  1297. var k string
  1298. d := buff.ReadString() // read string
  1299. k = d
  1300. var v string
  1301. e := buff.ReadString() // read string
  1302. v = e
  1303. b[k] = v
  1304. }
  1305. a = b
  1306. // --- [end][read][map](map[string]string) ---
  1307. }
  1308. target.labels = AssetLabels(a)
  1309. // --- [end][read][alias](AssetLabels) ---
  1310. if buff.ReadUInt8() == uint8(0) {
  1311. target.properties = nil
  1312. } else {
  1313. // --- [begin][read][struct](AssetProperties) ---
  1314. f := &AssetProperties{}
  1315. g := buff.ReadInt() // byte array length
  1316. h := buff.ReadBytes(g) // byte array
  1317. errA := f.UnmarshalBinary(h)
  1318. if errA != nil {
  1319. return errA
  1320. }
  1321. target.properties = f
  1322. // --- [end][read][struct](AssetProperties) ---
  1323. }
  1324. // --- [begin][read][reference](time.Time) ---
  1325. l := &time.Time{}
  1326. m := buff.ReadInt() // byte array length
  1327. n := buff.ReadBytes(m) // byte array
  1328. errB := l.UnmarshalBinary(n)
  1329. if errB != nil {
  1330. return errB
  1331. }
  1332. target.start = *l
  1333. // --- [end][read][reference](time.Time) ---
  1334. // --- [begin][read][reference](time.Time) ---
  1335. o := &time.Time{}
  1336. p := buff.ReadInt() // byte array length
  1337. q := buff.ReadBytes(p) // byte array
  1338. errC := o.UnmarshalBinary(q)
  1339. if errC != nil {
  1340. return errC
  1341. }
  1342. target.end = *o
  1343. // --- [end][read][reference](time.Time) ---
  1344. // --- [begin][read][struct](Window) ---
  1345. r := &Window{}
  1346. s := buff.ReadInt() // byte array length
  1347. t := buff.ReadBytes(s) // byte array
  1348. errD := r.UnmarshalBinary(t)
  1349. if errD != nil {
  1350. return errD
  1351. }
  1352. target.window = *r
  1353. // --- [end][read][struct](Window) ---
  1354. u := buff.ReadFloat64() // read float64
  1355. target.adjustment = u
  1356. w := buff.ReadFloat64() // read float64
  1357. target.Cost = w
  1358. x := buff.ReadFloat64() // read float64
  1359. target.ByteHours = x
  1360. y := buff.ReadFloat64() // read float64
  1361. target.Local = y
  1362. if buff.ReadUInt8() == uint8(0) {
  1363. target.Breakdown = nil
  1364. } else {
  1365. // --- [begin][read][struct](Breakdown) ---
  1366. z := &Breakdown{}
  1367. aa := buff.ReadInt() // byte array length
  1368. bb := buff.ReadBytes(aa) // byte array
  1369. errE := z.UnmarshalBinary(bb)
  1370. if errE != nil {
  1371. return errE
  1372. }
  1373. target.Breakdown = z
  1374. // --- [end][read][struct](Breakdown) ---
  1375. }
  1376. return nil
  1377. }
  1378. //--------------------------------------------------------------------------
  1379. // LoadBalancer
  1380. //--------------------------------------------------------------------------
  1381. // MarshalBinary serializes the internal properties of this LoadBalancer instance
  1382. // into a byte array
  1383. func (target *LoadBalancer) MarshalBinary() (data []byte, err error) {
  1384. buff := util.NewBuffer()
  1385. buff.WriteUInt8(CodecVersion) // version
  1386. if target.properties == nil {
  1387. buff.WriteUInt8(uint8(0)) // write nil byte
  1388. } else {
  1389. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1390. // --- [begin][write][struct](AssetProperties) ---
  1391. a, errA := target.properties.MarshalBinary()
  1392. if errA != nil {
  1393. return nil, errA
  1394. }
  1395. buff.WriteInt(len(a))
  1396. buff.WriteBytes(a)
  1397. // --- [end][write][struct](AssetProperties) ---
  1398. }
  1399. // --- [begin][write][alias](AssetLabels) ---
  1400. if map[string]string(target.labels) == nil {
  1401. buff.WriteUInt8(uint8(0)) // write nil byte
  1402. } else {
  1403. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1404. // --- [begin][write][map](map[string]string) ---
  1405. buff.WriteInt(len(map[string]string(target.labels))) // map length
  1406. for k, v := range map[string]string(target.labels) {
  1407. buff.WriteString(k) // write string
  1408. buff.WriteString(v) // write string
  1409. }
  1410. // --- [end][write][map](map[string]string) ---
  1411. }
  1412. // --- [end][write][alias](AssetLabels) ---
  1413. // --- [begin][write][reference](time.Time) ---
  1414. b, errB := target.start.MarshalBinary()
  1415. if errB != nil {
  1416. return nil, errB
  1417. }
  1418. buff.WriteInt(len(b))
  1419. buff.WriteBytes(b)
  1420. // --- [end][write][reference](time.Time) ---
  1421. // --- [begin][write][reference](time.Time) ---
  1422. c, errC := target.end.MarshalBinary()
  1423. if errC != nil {
  1424. return nil, errC
  1425. }
  1426. buff.WriteInt(len(c))
  1427. buff.WriteBytes(c)
  1428. // --- [end][write][reference](time.Time) ---
  1429. // --- [begin][write][struct](Window) ---
  1430. d, errD := target.window.MarshalBinary()
  1431. if errD != nil {
  1432. return nil, errD
  1433. }
  1434. buff.WriteInt(len(d))
  1435. buff.WriteBytes(d)
  1436. // --- [end][write][struct](Window) ---
  1437. buff.WriteFloat64(target.adjustment) // write float64
  1438. buff.WriteFloat64(target.Cost) // write float64
  1439. return buff.Bytes(), nil
  1440. }
  1441. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1442. // the LoadBalancer type
  1443. func (target *LoadBalancer) UnmarshalBinary(data []byte) error {
  1444. buff := util.NewBufferFromBytes(data)
  1445. // Codec Version Check
  1446. version := buff.ReadUInt8()
  1447. if version != CodecVersion {
  1448. return fmt.Errorf("Invalid Version Unmarshaling LoadBalancer. Expected %d, got %d", CodecVersion, version)
  1449. }
  1450. if buff.ReadUInt8() == uint8(0) {
  1451. target.properties = nil
  1452. } else {
  1453. // --- [begin][read][struct](AssetProperties) ---
  1454. a := &AssetProperties{}
  1455. b := buff.ReadInt() // byte array length
  1456. c := buff.ReadBytes(b) // byte array
  1457. errA := a.UnmarshalBinary(c)
  1458. if errA != nil {
  1459. return errA
  1460. }
  1461. target.properties = a
  1462. // --- [end][read][struct](AssetProperties) ---
  1463. }
  1464. // --- [begin][read][alias](AssetLabels) ---
  1465. var d map[string]string
  1466. if buff.ReadUInt8() == uint8(0) {
  1467. d = nil
  1468. } else {
  1469. // --- [begin][read][map](map[string]string) ---
  1470. e := make(map[string]string)
  1471. f := buff.ReadInt() // map len
  1472. for i := 0; i < f; i++ {
  1473. var k string
  1474. g := buff.ReadString() // read string
  1475. k = g
  1476. var v string
  1477. h := buff.ReadString() // read string
  1478. v = h
  1479. e[k] = v
  1480. }
  1481. d = e
  1482. // --- [end][read][map](map[string]string) ---
  1483. }
  1484. target.labels = AssetLabels(d)
  1485. // --- [end][read][alias](AssetLabels) ---
  1486. // --- [begin][read][reference](time.Time) ---
  1487. l := &time.Time{}
  1488. m := buff.ReadInt() // byte array length
  1489. n := buff.ReadBytes(m) // byte array
  1490. errB := l.UnmarshalBinary(n)
  1491. if errB != nil {
  1492. return errB
  1493. }
  1494. target.start = *l
  1495. // --- [end][read][reference](time.Time) ---
  1496. // --- [begin][read][reference](time.Time) ---
  1497. o := &time.Time{}
  1498. p := buff.ReadInt() // byte array length
  1499. q := buff.ReadBytes(p) // byte array
  1500. errC := o.UnmarshalBinary(q)
  1501. if errC != nil {
  1502. return errC
  1503. }
  1504. target.end = *o
  1505. // --- [end][read][reference](time.Time) ---
  1506. // --- [begin][read][struct](Window) ---
  1507. r := &Window{}
  1508. s := buff.ReadInt() // byte array length
  1509. t := buff.ReadBytes(s) // byte array
  1510. errD := r.UnmarshalBinary(t)
  1511. if errD != nil {
  1512. return errD
  1513. }
  1514. target.window = *r
  1515. // --- [end][read][struct](Window) ---
  1516. u := buff.ReadFloat64() // read float64
  1517. target.adjustment = u
  1518. w := buff.ReadFloat64() // read float64
  1519. target.Cost = w
  1520. return nil
  1521. }
  1522. //--------------------------------------------------------------------------
  1523. // Network
  1524. //--------------------------------------------------------------------------
  1525. // MarshalBinary serializes the internal properties of this Network instance
  1526. // into a byte array
  1527. func (target *Network) MarshalBinary() (data []byte, err error) {
  1528. buff := util.NewBuffer()
  1529. buff.WriteUInt8(CodecVersion) // version
  1530. if target.properties == nil {
  1531. buff.WriteUInt8(uint8(0)) // write nil byte
  1532. } else {
  1533. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1534. // --- [begin][write][struct](AssetProperties) ---
  1535. a, errA := target.properties.MarshalBinary()
  1536. if errA != nil {
  1537. return nil, errA
  1538. }
  1539. buff.WriteInt(len(a))
  1540. buff.WriteBytes(a)
  1541. // --- [end][write][struct](AssetProperties) ---
  1542. }
  1543. // --- [begin][write][alias](AssetLabels) ---
  1544. if map[string]string(target.labels) == nil {
  1545. buff.WriteUInt8(uint8(0)) // write nil byte
  1546. } else {
  1547. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1548. // --- [begin][write][map](map[string]string) ---
  1549. buff.WriteInt(len(map[string]string(target.labels))) // map length
  1550. for k, v := range map[string]string(target.labels) {
  1551. buff.WriteString(k) // write string
  1552. buff.WriteString(v) // write string
  1553. }
  1554. // --- [end][write][map](map[string]string) ---
  1555. }
  1556. // --- [end][write][alias](AssetLabels) ---
  1557. // --- [begin][write][reference](time.Time) ---
  1558. b, errB := target.start.MarshalBinary()
  1559. if errB != nil {
  1560. return nil, errB
  1561. }
  1562. buff.WriteInt(len(b))
  1563. buff.WriteBytes(b)
  1564. // --- [end][write][reference](time.Time) ---
  1565. // --- [begin][write][reference](time.Time) ---
  1566. c, errC := target.end.MarshalBinary()
  1567. if errC != nil {
  1568. return nil, errC
  1569. }
  1570. buff.WriteInt(len(c))
  1571. buff.WriteBytes(c)
  1572. // --- [end][write][reference](time.Time) ---
  1573. // --- [begin][write][struct](Window) ---
  1574. d, errD := target.window.MarshalBinary()
  1575. if errD != nil {
  1576. return nil, errD
  1577. }
  1578. buff.WriteInt(len(d))
  1579. buff.WriteBytes(d)
  1580. // --- [end][write][struct](Window) ---
  1581. buff.WriteFloat64(target.adjustment) // write float64
  1582. buff.WriteFloat64(target.Cost) // write float64
  1583. return buff.Bytes(), nil
  1584. }
  1585. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1586. // the Network type
  1587. func (target *Network) UnmarshalBinary(data []byte) error {
  1588. buff := util.NewBufferFromBytes(data)
  1589. // Codec Version Check
  1590. version := buff.ReadUInt8()
  1591. if version != CodecVersion {
  1592. return fmt.Errorf("Invalid Version Unmarshaling Network. Expected %d, got %d", CodecVersion, version)
  1593. }
  1594. if buff.ReadUInt8() == uint8(0) {
  1595. target.properties = nil
  1596. } else {
  1597. // --- [begin][read][struct](AssetProperties) ---
  1598. a := &AssetProperties{}
  1599. b := buff.ReadInt() // byte array length
  1600. c := buff.ReadBytes(b) // byte array
  1601. errA := a.UnmarshalBinary(c)
  1602. if errA != nil {
  1603. return errA
  1604. }
  1605. target.properties = a
  1606. // --- [end][read][struct](AssetProperties) ---
  1607. }
  1608. // --- [begin][read][alias](AssetLabels) ---
  1609. var d map[string]string
  1610. if buff.ReadUInt8() == uint8(0) {
  1611. d = nil
  1612. } else {
  1613. // --- [begin][read][map](map[string]string) ---
  1614. e := make(map[string]string)
  1615. f := buff.ReadInt() // map len
  1616. for i := 0; i < f; i++ {
  1617. var k string
  1618. g := buff.ReadString() // read string
  1619. k = g
  1620. var v string
  1621. h := buff.ReadString() // read string
  1622. v = h
  1623. e[k] = v
  1624. }
  1625. d = e
  1626. // --- [end][read][map](map[string]string) ---
  1627. }
  1628. target.labels = AssetLabels(d)
  1629. // --- [end][read][alias](AssetLabels) ---
  1630. // --- [begin][read][reference](time.Time) ---
  1631. l := &time.Time{}
  1632. m := buff.ReadInt() // byte array length
  1633. n := buff.ReadBytes(m) // byte array
  1634. errB := l.UnmarshalBinary(n)
  1635. if errB != nil {
  1636. return errB
  1637. }
  1638. target.start = *l
  1639. // --- [end][read][reference](time.Time) ---
  1640. // --- [begin][read][reference](time.Time) ---
  1641. o := &time.Time{}
  1642. p := buff.ReadInt() // byte array length
  1643. q := buff.ReadBytes(p) // byte array
  1644. errC := o.UnmarshalBinary(q)
  1645. if errC != nil {
  1646. return errC
  1647. }
  1648. target.end = *o
  1649. // --- [end][read][reference](time.Time) ---
  1650. // --- [begin][read][struct](Window) ---
  1651. r := &Window{}
  1652. s := buff.ReadInt() // byte array length
  1653. t := buff.ReadBytes(s) // byte array
  1654. errD := r.UnmarshalBinary(t)
  1655. if errD != nil {
  1656. return errD
  1657. }
  1658. target.window = *r
  1659. // --- [end][read][struct](Window) ---
  1660. u := buff.ReadFloat64() // read float64
  1661. target.adjustment = u
  1662. w := buff.ReadFloat64() // read float64
  1663. target.Cost = w
  1664. return nil
  1665. }
  1666. //--------------------------------------------------------------------------
  1667. // Node
  1668. //--------------------------------------------------------------------------
  1669. // MarshalBinary serializes the internal properties of this Node instance
  1670. // into a byte array
  1671. func (target *Node) MarshalBinary() (data []byte, err error) {
  1672. buff := util.NewBuffer()
  1673. buff.WriteUInt8(CodecVersion) // version
  1674. if target.properties == nil {
  1675. buff.WriteUInt8(uint8(0)) // write nil byte
  1676. } else {
  1677. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1678. // --- [begin][write][struct](AssetProperties) ---
  1679. a, errA := target.properties.MarshalBinary()
  1680. if errA != nil {
  1681. return nil, errA
  1682. }
  1683. buff.WriteInt(len(a))
  1684. buff.WriteBytes(a)
  1685. // --- [end][write][struct](AssetProperties) ---
  1686. }
  1687. // --- [begin][write][alias](AssetLabels) ---
  1688. if map[string]string(target.labels) == nil {
  1689. buff.WriteUInt8(uint8(0)) // write nil byte
  1690. } else {
  1691. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1692. // --- [begin][write][map](map[string]string) ---
  1693. buff.WriteInt(len(map[string]string(target.labels))) // map length
  1694. for k, v := range map[string]string(target.labels) {
  1695. buff.WriteString(k) // write string
  1696. buff.WriteString(v) // write string
  1697. }
  1698. // --- [end][write][map](map[string]string) ---
  1699. }
  1700. // --- [end][write][alias](AssetLabels) ---
  1701. // --- [begin][write][reference](time.Time) ---
  1702. b, errB := target.start.MarshalBinary()
  1703. if errB != nil {
  1704. return nil, errB
  1705. }
  1706. buff.WriteInt(len(b))
  1707. buff.WriteBytes(b)
  1708. // --- [end][write][reference](time.Time) ---
  1709. // --- [begin][write][reference](time.Time) ---
  1710. c, errC := target.end.MarshalBinary()
  1711. if errC != nil {
  1712. return nil, errC
  1713. }
  1714. buff.WriteInt(len(c))
  1715. buff.WriteBytes(c)
  1716. // --- [end][write][reference](time.Time) ---
  1717. // --- [begin][write][struct](Window) ---
  1718. d, errD := target.window.MarshalBinary()
  1719. if errD != nil {
  1720. return nil, errD
  1721. }
  1722. buff.WriteInt(len(d))
  1723. buff.WriteBytes(d)
  1724. // --- [end][write][struct](Window) ---
  1725. buff.WriteFloat64(target.adjustment) // write float64
  1726. buff.WriteString(target.NodeType) // write string
  1727. buff.WriteFloat64(target.CPUCoreHours) // write float64
  1728. buff.WriteFloat64(target.RAMByteHours) // write float64
  1729. if target.CPUBreakdown == nil {
  1730. buff.WriteUInt8(uint8(0)) // write nil byte
  1731. } else {
  1732. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1733. // --- [begin][write][struct](Breakdown) ---
  1734. e, errE := target.CPUBreakdown.MarshalBinary()
  1735. if errE != nil {
  1736. return nil, errE
  1737. }
  1738. buff.WriteInt(len(e))
  1739. buff.WriteBytes(e)
  1740. // --- [end][write][struct](Breakdown) ---
  1741. }
  1742. if target.RAMBreakdown == nil {
  1743. buff.WriteUInt8(uint8(0)) // write nil byte
  1744. } else {
  1745. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1746. // --- [begin][write][struct](Breakdown) ---
  1747. f, errF := target.RAMBreakdown.MarshalBinary()
  1748. if errF != nil {
  1749. return nil, errF
  1750. }
  1751. buff.WriteInt(len(f))
  1752. buff.WriteBytes(f)
  1753. // --- [end][write][struct](Breakdown) ---
  1754. }
  1755. buff.WriteFloat64(target.CPUCost) // write float64
  1756. buff.WriteFloat64(target.GPUCost) // write float64
  1757. buff.WriteFloat64(target.RAMCost) // write float64
  1758. buff.WriteFloat64(target.Discount) // write float64
  1759. buff.WriteFloat64(target.Preemptible) // write float64
  1760. return buff.Bytes(), nil
  1761. }
  1762. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1763. // the Node type
  1764. func (target *Node) UnmarshalBinary(data []byte) error {
  1765. buff := util.NewBufferFromBytes(data)
  1766. // Codec Version Check
  1767. version := buff.ReadUInt8()
  1768. if version != CodecVersion {
  1769. return fmt.Errorf("Invalid Version Unmarshaling Node. Expected %d, got %d", CodecVersion, version)
  1770. }
  1771. if buff.ReadUInt8() == uint8(0) {
  1772. target.properties = nil
  1773. } else {
  1774. // --- [begin][read][struct](AssetProperties) ---
  1775. a := &AssetProperties{}
  1776. b := buff.ReadInt() // byte array length
  1777. c := buff.ReadBytes(b) // byte array
  1778. errA := a.UnmarshalBinary(c)
  1779. if errA != nil {
  1780. return errA
  1781. }
  1782. target.properties = a
  1783. // --- [end][read][struct](AssetProperties) ---
  1784. }
  1785. // --- [begin][read][alias](AssetLabels) ---
  1786. var d map[string]string
  1787. if buff.ReadUInt8() == uint8(0) {
  1788. d = nil
  1789. } else {
  1790. // --- [begin][read][map](map[string]string) ---
  1791. e := make(map[string]string)
  1792. f := buff.ReadInt() // map len
  1793. for i := 0; i < f; i++ {
  1794. var k string
  1795. g := buff.ReadString() // read string
  1796. k = g
  1797. var v string
  1798. h := buff.ReadString() // read string
  1799. v = h
  1800. e[k] = v
  1801. }
  1802. d = e
  1803. // --- [end][read][map](map[string]string) ---
  1804. }
  1805. target.labels = AssetLabels(d)
  1806. // --- [end][read][alias](AssetLabels) ---
  1807. // --- [begin][read][reference](time.Time) ---
  1808. l := &time.Time{}
  1809. m := buff.ReadInt() // byte array length
  1810. n := buff.ReadBytes(m) // byte array
  1811. errB := l.UnmarshalBinary(n)
  1812. if errB != nil {
  1813. return errB
  1814. }
  1815. target.start = *l
  1816. // --- [end][read][reference](time.Time) ---
  1817. // --- [begin][read][reference](time.Time) ---
  1818. o := &time.Time{}
  1819. p := buff.ReadInt() // byte array length
  1820. q := buff.ReadBytes(p) // byte array
  1821. errC := o.UnmarshalBinary(q)
  1822. if errC != nil {
  1823. return errC
  1824. }
  1825. target.end = *o
  1826. // --- [end][read][reference](time.Time) ---
  1827. // --- [begin][read][struct](Window) ---
  1828. r := &Window{}
  1829. s := buff.ReadInt() // byte array length
  1830. t := buff.ReadBytes(s) // byte array
  1831. errD := r.UnmarshalBinary(t)
  1832. if errD != nil {
  1833. return errD
  1834. }
  1835. target.window = *r
  1836. // --- [end][read][struct](Window) ---
  1837. u := buff.ReadFloat64() // read float64
  1838. target.adjustment = u
  1839. w := buff.ReadString() // read string
  1840. target.NodeType = w
  1841. x := buff.ReadFloat64() // read float64
  1842. target.CPUCoreHours = x
  1843. y := buff.ReadFloat64() // read float64
  1844. target.RAMByteHours = y
  1845. if buff.ReadUInt8() == uint8(0) {
  1846. target.CPUBreakdown = nil
  1847. } else {
  1848. // --- [begin][read][struct](Breakdown) ---
  1849. z := &Breakdown{}
  1850. aa := buff.ReadInt() // byte array length
  1851. bb := buff.ReadBytes(aa) // byte array
  1852. errE := z.UnmarshalBinary(bb)
  1853. if errE != nil {
  1854. return errE
  1855. }
  1856. target.CPUBreakdown = z
  1857. // --- [end][read][struct](Breakdown) ---
  1858. }
  1859. if buff.ReadUInt8() == uint8(0) {
  1860. target.RAMBreakdown = nil
  1861. } else {
  1862. // --- [begin][read][struct](Breakdown) ---
  1863. cc := &Breakdown{}
  1864. dd := buff.ReadInt() // byte array length
  1865. ee := buff.ReadBytes(dd) // byte array
  1866. errF := cc.UnmarshalBinary(ee)
  1867. if errF != nil {
  1868. return errF
  1869. }
  1870. target.RAMBreakdown = cc
  1871. // --- [end][read][struct](Breakdown) ---
  1872. }
  1873. ff := buff.ReadFloat64() // read float64
  1874. target.CPUCost = ff
  1875. gg := buff.ReadFloat64() // read float64
  1876. target.GPUCost = gg
  1877. hh := buff.ReadFloat64() // read float64
  1878. target.RAMCost = hh
  1879. ll := buff.ReadFloat64() // read float64
  1880. target.Discount = ll
  1881. mm := buff.ReadFloat64() // read float64
  1882. target.Preemptible = mm
  1883. return nil
  1884. }
  1885. //--------------------------------------------------------------------------
  1886. // SharedAsset
  1887. //--------------------------------------------------------------------------
  1888. // MarshalBinary serializes the internal properties of this SharedAsset instance
  1889. // into a byte array
  1890. func (target *SharedAsset) MarshalBinary() (data []byte, err error) {
  1891. buff := util.NewBuffer()
  1892. buff.WriteUInt8(CodecVersion) // version
  1893. if target.properties == nil {
  1894. buff.WriteUInt8(uint8(0)) // write nil byte
  1895. } else {
  1896. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1897. // --- [begin][write][struct](AssetProperties) ---
  1898. a, errA := target.properties.MarshalBinary()
  1899. if errA != nil {
  1900. return nil, errA
  1901. }
  1902. buff.WriteInt(len(a))
  1903. buff.WriteBytes(a)
  1904. // --- [end][write][struct](AssetProperties) ---
  1905. }
  1906. // --- [begin][write][alias](AssetLabels) ---
  1907. if map[string]string(target.labels) == nil {
  1908. buff.WriteUInt8(uint8(0)) // write nil byte
  1909. } else {
  1910. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1911. // --- [begin][write][map](map[string]string) ---
  1912. buff.WriteInt(len(map[string]string(target.labels))) // map length
  1913. for k, v := range map[string]string(target.labels) {
  1914. buff.WriteString(k) // write string
  1915. buff.WriteString(v) // write string
  1916. }
  1917. // --- [end][write][map](map[string]string) ---
  1918. }
  1919. // --- [end][write][alias](AssetLabels) ---
  1920. // --- [begin][write][struct](Window) ---
  1921. b, errB := target.window.MarshalBinary()
  1922. if errB != nil {
  1923. return nil, errB
  1924. }
  1925. buff.WriteInt(len(b))
  1926. buff.WriteBytes(b)
  1927. // --- [end][write][struct](Window) ---
  1928. buff.WriteFloat64(target.Cost) // write float64
  1929. return buff.Bytes(), nil
  1930. }
  1931. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1932. // the SharedAsset type
  1933. func (target *SharedAsset) UnmarshalBinary(data []byte) error {
  1934. buff := util.NewBufferFromBytes(data)
  1935. // Codec Version Check
  1936. version := buff.ReadUInt8()
  1937. if version != CodecVersion {
  1938. return fmt.Errorf("Invalid Version Unmarshaling SharedAsset. Expected %d, got %d", CodecVersion, version)
  1939. }
  1940. if buff.ReadUInt8() == uint8(0) {
  1941. target.properties = nil
  1942. } else {
  1943. // --- [begin][read][struct](AssetProperties) ---
  1944. a := &AssetProperties{}
  1945. b := buff.ReadInt() // byte array length
  1946. c := buff.ReadBytes(b) // byte array
  1947. errA := a.UnmarshalBinary(c)
  1948. if errA != nil {
  1949. return errA
  1950. }
  1951. target.properties = a
  1952. // --- [end][read][struct](AssetProperties) ---
  1953. }
  1954. // --- [begin][read][alias](AssetLabels) ---
  1955. var d map[string]string
  1956. if buff.ReadUInt8() == uint8(0) {
  1957. d = nil
  1958. } else {
  1959. // --- [begin][read][map](map[string]string) ---
  1960. e := make(map[string]string)
  1961. f := buff.ReadInt() // map len
  1962. for i := 0; i < f; i++ {
  1963. var k string
  1964. g := buff.ReadString() // read string
  1965. k = g
  1966. var v string
  1967. h := buff.ReadString() // read string
  1968. v = h
  1969. e[k] = v
  1970. }
  1971. d = e
  1972. // --- [end][read][map](map[string]string) ---
  1973. }
  1974. target.labels = AssetLabels(d)
  1975. // --- [end][read][alias](AssetLabels) ---
  1976. // --- [begin][read][struct](Window) ---
  1977. l := &Window{}
  1978. m := buff.ReadInt() // byte array length
  1979. n := buff.ReadBytes(m) // byte array
  1980. errB := l.UnmarshalBinary(n)
  1981. if errB != nil {
  1982. return errB
  1983. }
  1984. target.window = *l
  1985. // --- [end][read][struct](Window) ---
  1986. o := buff.ReadFloat64() // read float64
  1987. target.Cost = o
  1988. return nil
  1989. }
  1990. //--------------------------------------------------------------------------
  1991. // Window
  1992. //--------------------------------------------------------------------------
  1993. // MarshalBinary serializes the internal properties of this Window instance
  1994. // into a byte array
  1995. func (target *Window) MarshalBinary() (data []byte, err error) {
  1996. buff := util.NewBuffer()
  1997. buff.WriteUInt8(CodecVersion) // version
  1998. if target.start == nil {
  1999. buff.WriteUInt8(uint8(0)) // write nil byte
  2000. } else {
  2001. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2002. // --- [begin][write][reference](time.Time) ---
  2003. a, errA := target.start.MarshalBinary()
  2004. if errA != nil {
  2005. return nil, errA
  2006. }
  2007. buff.WriteInt(len(a))
  2008. buff.WriteBytes(a)
  2009. // --- [end][write][reference](time.Time) ---
  2010. }
  2011. if target.end == nil {
  2012. buff.WriteUInt8(uint8(0)) // write nil byte
  2013. } else {
  2014. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2015. // --- [begin][write][reference](time.Time) ---
  2016. b, errB := target.end.MarshalBinary()
  2017. if errB != nil {
  2018. return nil, errB
  2019. }
  2020. buff.WriteInt(len(b))
  2021. buff.WriteBytes(b)
  2022. // --- [end][write][reference](time.Time) ---
  2023. }
  2024. return buff.Bytes(), nil
  2025. }
  2026. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2027. // the Window type
  2028. func (target *Window) UnmarshalBinary(data []byte) error {
  2029. buff := util.NewBufferFromBytes(data)
  2030. // Codec Version Check
  2031. version := buff.ReadUInt8()
  2032. if version != CodecVersion {
  2033. return fmt.Errorf("Invalid Version Unmarshaling Window. Expected %d, got %d", CodecVersion, version)
  2034. }
  2035. if buff.ReadUInt8() == uint8(0) {
  2036. target.start = nil
  2037. } else {
  2038. // --- [begin][read][reference](time.Time) ---
  2039. a := &time.Time{}
  2040. b := buff.ReadInt() // byte array length
  2041. c := buff.ReadBytes(b) // byte array
  2042. errA := a.UnmarshalBinary(c)
  2043. if errA != nil {
  2044. return errA
  2045. }
  2046. target.start = a
  2047. // --- [end][read][reference](time.Time) ---
  2048. }
  2049. if buff.ReadUInt8() == uint8(0) {
  2050. target.end = nil
  2051. } else {
  2052. // --- [begin][read][reference](time.Time) ---
  2053. d := &time.Time{}
  2054. e := buff.ReadInt() // byte array length
  2055. f := buff.ReadBytes(e) // byte array
  2056. errB := d.UnmarshalBinary(f)
  2057. if errB != nil {
  2058. return errB
  2059. }
  2060. target.end = d
  2061. // --- [end][read][reference](time.Time) ---
  2062. }
  2063. return nil
  2064. }