2
0

kubecost_codecs.go 87 KB

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