kubecost_codecs.go 83 KB

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