| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183 |
- ////////////////////////////////////////////////////////////////////////////////
- //
- // DO NOT MODIFY
- //
- // ┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
- //
- //
- // This source file was automatically generated by bingen.
- //
- ////////////////////////////////////////////////////////////////////////////////
- package kubecost
- import (
- "encoding"
- "fmt"
- util "github.com/kubecost/cost-model/pkg/util"
- "reflect"
- "strings"
- "time"
- )
- const (
- // GeneratorPackageName is the package the generator is targetting
- GeneratorPackageName string = "kubecost"
- // CodecVersion is the version passed into the generator
- CodecVersion uint8 = 11
- )
- //--------------------------------------------------------------------------
- // Type Map
- //--------------------------------------------------------------------------
- // Generated type map for resolving interface implementations to
- // to concrete types
- var typeMap map[string]reflect.Type = map[string]reflect.Type{
- "Allocation": reflect.TypeOf((*Allocation)(nil)).Elem(),
- "AllocationProperties": reflect.TypeOf((*AllocationProperties)(nil)).Elem(),
- "AllocationSet": reflect.TypeOf((*AllocationSet)(nil)).Elem(),
- "AllocationSetRange": reflect.TypeOf((*AllocationSetRange)(nil)).Elem(),
- "Any": reflect.TypeOf((*Any)(nil)).Elem(),
- "AssetProperties": reflect.TypeOf((*AssetProperties)(nil)).Elem(),
- "AssetSet": reflect.TypeOf((*AssetSet)(nil)).Elem(),
- "AssetSetRange": reflect.TypeOf((*AssetSetRange)(nil)).Elem(),
- "Breakdown": reflect.TypeOf((*Breakdown)(nil)).Elem(),
- "Cloud": reflect.TypeOf((*Cloud)(nil)).Elem(),
- "ClusterManagement": reflect.TypeOf((*ClusterManagement)(nil)).Elem(),
- "Disk": reflect.TypeOf((*Disk)(nil)).Elem(),
- "LoadBalancer": reflect.TypeOf((*LoadBalancer)(nil)).Elem(),
- "Network": reflect.TypeOf((*Network)(nil)).Elem(),
- "Node": reflect.TypeOf((*Node)(nil)).Elem(),
- "RawAllocationOnlyData": reflect.TypeOf((*RawAllocationOnlyData)(nil)).Elem(),
- "SharedAsset": reflect.TypeOf((*SharedAsset)(nil)).Elem(),
- "Window": reflect.TypeOf((*Window)(nil)).Elem(),
- }
- //--------------------------------------------------------------------------
- // Type Helpers
- //--------------------------------------------------------------------------
- // typeToString determines the basic properties of the type, the qualifier, package path, and
- // type name, and returns the qualified type
- func typeToString(f interface{}) string {
- qual := ""
- t := reflect.TypeOf(f)
- if t.Kind() == reflect.Ptr {
- t = t.Elem()
- qual = "*"
- }
- return fmt.Sprintf("%s%s.%s", qual, t.PkgPath(), t.Name())
- }
- // resolveType uses the name of a type and returns the package, base type name, and whether
- // or not it's a pointer.
- func resolveType(t string) (pkg string, name string, isPtr bool) {
- isPtr = t[:1] == "*"
- if isPtr {
- t = t[1:]
- }
- slashIndex := strings.LastIndex(t, "/")
- if slashIndex >= 0 {
- t = t[slashIndex+1:]
- }
- parts := strings.Split(t, ".")
- if parts[0] == GeneratorPackageName {
- parts[0] = ""
- }
- pkg = parts[0]
- name = parts[1]
- return
- }
- //--------------------------------------------------------------------------
- // Allocation
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Allocation instance
- // into a byte array
- func (target *Allocation) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- buff.WriteString(target.Name) // write string
- if target.Properties == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](AllocationProperties) ---
- a, errA := target.Properties.MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][struct](AllocationProperties) ---
- }
- // --- [begin][write][struct](Window) ---
- b, errB := target.Window.MarshalBinary()
- if errB != nil {
- return nil, errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][struct](Window) ---
- // --- [begin][write][reference](time.Time) ---
- c, errC := target.Start.MarshalBinary()
- if errC != nil {
- return nil, errC
- }
- buff.WriteInt(len(c))
- buff.WriteBytes(c)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- d, errD := target.End.MarshalBinary()
- if errD != nil {
- return nil, errD
- }
- buff.WriteInt(len(d))
- buff.WriteBytes(d)
- // --- [end][write][reference](time.Time) ---
- buff.WriteFloat64(target.CPUCoreHours) // write float64
- buff.WriteFloat64(target.CPUCoreRequestAverage) // write float64
- buff.WriteFloat64(target.CPUCoreUsageAverage) // write float64
- buff.WriteFloat64(target.CPUCost) // write float64
- buff.WriteFloat64(target.GPUHours) // write float64
- buff.WriteFloat64(target.GPUCost) // write float64
- buff.WriteFloat64(target.NetworkCost) // write float64
- buff.WriteFloat64(target.LoadBalancerCost) // write float64
- buff.WriteFloat64(target.PVByteHours) // write float64
- buff.WriteFloat64(target.PVCost) // write float64
- buff.WriteFloat64(target.RAMByteHours) // write float64
- buff.WriteFloat64(target.RAMBytesRequestAverage) // write float64
- buff.WriteFloat64(target.RAMBytesUsageAverage) // write float64
- buff.WriteFloat64(target.RAMCost) // write float64
- buff.WriteFloat64(target.SharedCost) // write float64
- buff.WriteFloat64(target.ExternalCost) // write float64
- if target.RawAllocationOnly == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](RawAllocationOnlyData) ---
- e, errE := target.RawAllocationOnly.MarshalBinary()
- if errE != nil {
- return nil, errE
- }
- buff.WriteInt(len(e))
- buff.WriteBytes(e)
- // --- [end][write][struct](RawAllocationOnlyData) ---
- }
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Allocation type
- func (target *Allocation) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling Allocation. Expected %d, got %d", CodecVersion, version)
- }
- a := buff.ReadString() // read string
- target.Name = a
- if buff.ReadUInt8() == uint8(0) {
- target.Properties = nil
- } else {
- // --- [begin][read][struct](AllocationProperties) ---
- b := &AllocationProperties{}
- c := buff.ReadInt() // byte array length
- d := buff.ReadBytes(c) // byte array
- errA := b.UnmarshalBinary(d)
- if errA != nil {
- return errA
- }
- target.Properties = b
- // --- [end][read][struct](AllocationProperties) ---
- }
- // --- [begin][read][struct](Window) ---
- e := &Window{}
- f := buff.ReadInt() // byte array length
- g := buff.ReadBytes(f) // byte array
- errB := e.UnmarshalBinary(g)
- if errB != nil {
- return errB
- }
- target.Window = *e
- // --- [end][read][struct](Window) ---
- // --- [begin][read][reference](time.Time) ---
- h := &time.Time{}
- k := buff.ReadInt() // byte array length
- l := buff.ReadBytes(k) // byte array
- errC := h.UnmarshalBinary(l)
- if errC != nil {
- return errC
- }
- target.Start = *h
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- m := &time.Time{}
- n := buff.ReadInt() // byte array length
- o := buff.ReadBytes(n) // byte array
- errD := m.UnmarshalBinary(o)
- if errD != nil {
- return errD
- }
- target.End = *m
- // --- [end][read][reference](time.Time) ---
- p := buff.ReadFloat64() // read float64
- target.CPUCoreHours = p
- q := buff.ReadFloat64() // read float64
- target.CPUCoreRequestAverage = q
- r := buff.ReadFloat64() // read float64
- target.CPUCoreUsageAverage = r
- s := buff.ReadFloat64() // read float64
- target.CPUCost = s
- t := buff.ReadFloat64() // read float64
- target.GPUHours = t
- u := buff.ReadFloat64() // read float64
- target.GPUCost = u
- w := buff.ReadFloat64() // read float64
- target.NetworkCost = w
- x := buff.ReadFloat64() // read float64
- target.LoadBalancerCost = x
- y := buff.ReadFloat64() // read float64
- target.PVByteHours = y
- aa := buff.ReadFloat64() // read float64
- target.PVCost = aa
- bb := buff.ReadFloat64() // read float64
- target.RAMByteHours = bb
- cc := buff.ReadFloat64() // read float64
- target.RAMBytesRequestAverage = cc
- dd := buff.ReadFloat64() // read float64
- target.RAMBytesUsageAverage = dd
- ee := buff.ReadFloat64() // read float64
- target.RAMCost = ee
- ff := buff.ReadFloat64() // read float64
- target.SharedCost = ff
- gg := buff.ReadFloat64() // read float64
- target.ExternalCost = gg
- if buff.ReadUInt8() == uint8(0) {
- target.RawAllocationOnly = nil
- } else {
- // --- [begin][read][struct](RawAllocationOnlyData) ---
- hh := &RawAllocationOnlyData{}
- kk := buff.ReadInt() // byte array length
- ll := buff.ReadBytes(kk) // byte array
- errE := hh.UnmarshalBinary(ll)
- if errE != nil {
- return errE
- }
- target.RawAllocationOnly = hh
- // --- [end][read][struct](RawAllocationOnlyData) ---
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // AllocationProperties
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this AllocationProperties instance
- // into a byte array
- func (target *AllocationProperties) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- buff.WriteString(target.Cluster) // write string
- buff.WriteString(target.Node) // write string
- buff.WriteString(target.Container) // write string
- buff.WriteString(target.Controller) // write string
- buff.WriteString(target.ControllerKind) // write string
- buff.WriteString(target.Namespace) // write string
- buff.WriteString(target.Pod) // write string
- if target.Services == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]string) ---
- buff.WriteInt(len(target.Services)) // array length
- for i := 0; i < len(target.Services); i++ {
- buff.WriteString(target.Services[i]) // write string
- }
- // --- [end][write][slice]([]string) ---
- }
- buff.WriteString(target.ProviderID) // write string
- // --- [begin][write][alias](AllocationLabels) ---
- if map[string]string(target.Labels) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(map[string]string(target.Labels))) // map length
- for v, z := range map[string]string(target.Labels) {
- buff.WriteString(v) // write string
- buff.WriteString(z) // write string
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [end][write][alias](AllocationLabels) ---
- // --- [begin][write][alias](AllocationAnnotations) ---
- if map[string]string(target.Annotations) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(map[string]string(target.Annotations))) // map length
- for vv, zz := range map[string]string(target.Annotations) {
- buff.WriteString(vv) // write string
- buff.WriteString(zz) // write string
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [end][write][alias](AllocationAnnotations) ---
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the AllocationProperties type
- func (target *AllocationProperties) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling AllocationProperties. Expected %d, got %d", CodecVersion, version)
- }
- a := buff.ReadString() // read string
- target.Cluster = a
- b := buff.ReadString() // read string
- target.Node = b
- c := buff.ReadString() // read string
- target.Container = c
- d := buff.ReadString() // read string
- target.Controller = d
- e := buff.ReadString() // read string
- target.ControllerKind = e
- f := buff.ReadString() // read string
- target.Namespace = f
- g := buff.ReadString() // read string
- target.Pod = g
- if buff.ReadUInt8() == uint8(0) {
- target.Services = nil
- } else {
- // --- [begin][read][slice]([]string) ---
- k := buff.ReadInt() // array len
- h := make([]string, k)
- for i := 0; i < k; i++ {
- var l string
- m := buff.ReadString() // read string
- l = m
- h[i] = l
- }
- target.Services = h
- // --- [end][read][slice]([]string) ---
- }
- n := buff.ReadString() // read string
- target.ProviderID = n
- // --- [begin][read][alias](AllocationLabels) ---
- var o map[string]string
- if buff.ReadUInt8() == uint8(0) {
- o = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- q := buff.ReadInt() // map len
- p := make(map[string]string, q)
- for j := 0; j < q; j++ {
- var v string
- r := buff.ReadString() // read string
- v = r
- var z string
- s := buff.ReadString() // read string
- z = s
- p[v] = z
- }
- o = p
- // --- [end][read][map](map[string]string) ---
- }
- target.Labels = AllocationLabels(o)
- // --- [end][read][alias](AllocationLabels) ---
- // --- [begin][read][alias](AllocationAnnotations) ---
- var t map[string]string
- if buff.ReadUInt8() == uint8(0) {
- t = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- w := buff.ReadInt() // map len
- u := make(map[string]string, w)
- for ii := 0; ii < w; ii++ {
- var vv string
- x := buff.ReadString() // read string
- vv = x
- var zz string
- y := buff.ReadString() // read string
- zz = y
- u[vv] = zz
- }
- t = u
- // --- [end][read][map](map[string]string) ---
- }
- target.Annotations = AllocationAnnotations(t)
- // --- [end][read][alias](AllocationAnnotations) ---
- return nil
- }
- //--------------------------------------------------------------------------
- // AllocationSet
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this AllocationSet instance
- // into a byte array
- func (target *AllocationSet) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- if target.allocations == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*Allocation) ---
- buff.WriteInt(len(target.allocations)) // map length
- for v, z := range target.allocations {
- buff.WriteString(v) // write string
- if z == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Allocation) ---
- a, errA := z.MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][struct](Allocation) ---
- }
- }
- // --- [end][write][map](map[string]*Allocation) ---
- }
- if target.externalKeys == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]bool) ---
- buff.WriteInt(len(target.externalKeys)) // map length
- for vv, zz := range target.externalKeys {
- buff.WriteString(vv) // write string
- buff.WriteBool(zz) // write bool
- }
- // --- [end][write][map](map[string]bool) ---
- }
- if target.idleKeys == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]bool) ---
- buff.WriteInt(len(target.idleKeys)) // map length
- for vvv, zzz := range target.idleKeys {
- buff.WriteString(vvv) // write string
- buff.WriteBool(zzz) // write bool
- }
- // --- [end][write][map](map[string]bool) ---
- }
- // --- [begin][write][struct](Window) ---
- b, errB := target.Window.MarshalBinary()
- if errB != nil {
- return nil, errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][struct](Window) ---
- if target.Warnings == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]string) ---
- buff.WriteInt(len(target.Warnings)) // array length
- for i := 0; i < len(target.Warnings); i++ {
- buff.WriteString(target.Warnings[i]) // write string
- }
- // --- [end][write][slice]([]string) ---
- }
- if target.Errors == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]string) ---
- buff.WriteInt(len(target.Errors)) // array length
- for j := 0; j < len(target.Errors); j++ {
- buff.WriteString(target.Errors[j]) // write string
- }
- // --- [end][write][slice]([]string) ---
- }
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the AllocationSet type
- func (target *AllocationSet) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling AllocationSet. Expected %d, got %d", CodecVersion, version)
- }
- if buff.ReadUInt8() == uint8(0) {
- target.allocations = nil
- } else {
- // --- [begin][read][map](map[string]*Allocation) ---
- b := buff.ReadInt() // map len
- a := make(map[string]*Allocation, b)
- for i := 0; i < b; i++ {
- var v string
- c := buff.ReadString() // read string
- v = c
- var z *Allocation
- if buff.ReadUInt8() == uint8(0) {
- z = nil
- } else {
- // --- [begin][read][struct](Allocation) ---
- d := &Allocation{}
- e := buff.ReadInt() // byte array length
- f := buff.ReadBytes(e) // byte array
- errA := d.UnmarshalBinary(f)
- if errA != nil {
- return errA
- }
- z = d
- // --- [end][read][struct](Allocation) ---
- }
- a[v] = z
- }
- target.allocations = a
- // --- [end][read][map](map[string]*Allocation) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.externalKeys = nil
- } else {
- // --- [begin][read][map](map[string]bool) ---
- h := buff.ReadInt() // map len
- g := make(map[string]bool, h)
- for j := 0; j < h; j++ {
- var vv string
- k := buff.ReadString() // read string
- vv = k
- var zz bool
- l := buff.ReadBool() // read bool
- zz = l
- g[vv] = zz
- }
- target.externalKeys = g
- // --- [end][read][map](map[string]bool) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.idleKeys = nil
- } else {
- // --- [begin][read][map](map[string]bool) ---
- n := buff.ReadInt() // map len
- m := make(map[string]bool, n)
- for ii := 0; ii < n; ii++ {
- var vvv string
- o := buff.ReadString() // read string
- vvv = o
- var zzz bool
- p := buff.ReadBool() // read bool
- zzz = p
- m[vvv] = zzz
- }
- target.idleKeys = m
- // --- [end][read][map](map[string]bool) ---
- }
- // --- [begin][read][struct](Window) ---
- q := &Window{}
- r := buff.ReadInt() // byte array length
- s := buff.ReadBytes(r) // byte array
- errB := q.UnmarshalBinary(s)
- if errB != nil {
- return errB
- }
- target.Window = *q
- // --- [end][read][struct](Window) ---
- if buff.ReadUInt8() == uint8(0) {
- target.Warnings = nil
- } else {
- // --- [begin][read][slice]([]string) ---
- u := buff.ReadInt() // array len
- t := make([]string, u)
- for jj := 0; jj < u; jj++ {
- var w string
- x := buff.ReadString() // read string
- w = x
- t[jj] = w
- }
- target.Warnings = t
- // --- [end][read][slice]([]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.Errors = nil
- } else {
- // --- [begin][read][slice]([]string) ---
- aa := buff.ReadInt() // array len
- y := make([]string, aa)
- for iii := 0; iii < aa; iii++ {
- var bb string
- cc := buff.ReadString() // read string
- bb = cc
- y[iii] = bb
- }
- target.Errors = y
- // --- [end][read][slice]([]string) ---
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // AllocationSetRange
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this AllocationSetRange instance
- // into a byte array
- func (target *AllocationSetRange) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- if target.allocations == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]*AllocationSet) ---
- buff.WriteInt(len(target.allocations)) // array length
- for i := 0; i < len(target.allocations); i++ {
- if target.allocations[i] == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](AllocationSet) ---
- a, errA := target.allocations[i].MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][struct](AllocationSet) ---
- }
- }
- // --- [end][write][slice]([]*AllocationSet) ---
- }
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the AllocationSetRange type
- func (target *AllocationSetRange) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling AllocationSetRange. Expected %d, got %d", CodecVersion, version)
- }
- if buff.ReadUInt8() == uint8(0) {
- target.allocations = nil
- } else {
- // --- [begin][read][slice]([]*AllocationSet) ---
- b := buff.ReadInt() // array len
- a := make([]*AllocationSet, b)
- for i := 0; i < b; i++ {
- var c *AllocationSet
- if buff.ReadUInt8() == uint8(0) {
- c = nil
- } else {
- // --- [begin][read][struct](AllocationSet) ---
- d := &AllocationSet{}
- e := buff.ReadInt() // byte array length
- f := buff.ReadBytes(e) // byte array
- errA := d.UnmarshalBinary(f)
- if errA != nil {
- return errA
- }
- c = d
- // --- [end][read][struct](AllocationSet) ---
- }
- a[i] = c
- }
- target.allocations = a
- // --- [end][read][slice]([]*AllocationSet) ---
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // Any
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Any instance
- // into a byte array
- func (target *Any) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- // --- [begin][write][alias](AssetLabels) ---
- if map[string]string(target.labels) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(map[string]string(target.labels))) // map length
- for v, z := range map[string]string(target.labels) {
- buff.WriteString(v) // write string
- buff.WriteString(z) // write string
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [end][write][alias](AssetLabels) ---
- if target.properties == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](AssetProperties) ---
- a, errA := target.properties.MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][struct](AssetProperties) ---
- }
- // --- [begin][write][reference](time.Time) ---
- b, errB := target.start.MarshalBinary()
- if errB != nil {
- return nil, errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- c, errC := target.end.MarshalBinary()
- if errC != nil {
- return nil, errC
- }
- buff.WriteInt(len(c))
- buff.WriteBytes(c)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][struct](Window) ---
- d, errD := target.window.MarshalBinary()
- if errD != nil {
- return nil, errD
- }
- buff.WriteInt(len(d))
- buff.WriteBytes(d)
- // --- [end][write][struct](Window) ---
- buff.WriteFloat64(target.adjustment) // write float64
- buff.WriteFloat64(target.Cost) // write float64
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Any type
- func (target *Any) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling Any. Expected %d, got %d", CodecVersion, version)
- }
- // --- [begin][read][alias](AssetLabels) ---
- var a map[string]string
- if buff.ReadUInt8() == uint8(0) {
- a = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- c := buff.ReadInt() // map len
- b := make(map[string]string, c)
- for i := 0; i < c; i++ {
- var v string
- d := buff.ReadString() // read string
- v = d
- var z string
- e := buff.ReadString() // read string
- z = e
- b[v] = z
- }
- a = b
- // --- [end][read][map](map[string]string) ---
- }
- target.labels = AssetLabels(a)
- // --- [end][read][alias](AssetLabels) ---
- if buff.ReadUInt8() == uint8(0) {
- target.properties = nil
- } else {
- // --- [begin][read][struct](AssetProperties) ---
- f := &AssetProperties{}
- g := buff.ReadInt() // byte array length
- h := buff.ReadBytes(g) // byte array
- errA := f.UnmarshalBinary(h)
- if errA != nil {
- return errA
- }
- target.properties = f
- // --- [end][read][struct](AssetProperties) ---
- }
- // --- [begin][read][reference](time.Time) ---
- k := &time.Time{}
- l := buff.ReadInt() // byte array length
- m := buff.ReadBytes(l) // byte array
- errB := k.UnmarshalBinary(m)
- if errB != nil {
- return errB
- }
- target.start = *k
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- n := &time.Time{}
- o := buff.ReadInt() // byte array length
- p := buff.ReadBytes(o) // byte array
- errC := n.UnmarshalBinary(p)
- if errC != nil {
- return errC
- }
- target.end = *n
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][struct](Window) ---
- q := &Window{}
- r := buff.ReadInt() // byte array length
- s := buff.ReadBytes(r) // byte array
- errD := q.UnmarshalBinary(s)
- if errD != nil {
- return errD
- }
- target.window = *q
- // --- [end][read][struct](Window) ---
- t := buff.ReadFloat64() // read float64
- target.adjustment = t
- u := buff.ReadFloat64() // read float64
- target.Cost = u
- return nil
- }
- //--------------------------------------------------------------------------
- // AssetProperties
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this AssetProperties instance
- // into a byte array
- func (target *AssetProperties) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- buff.WriteString(target.Category) // write string
- buff.WriteString(target.Provider) // write string
- buff.WriteString(target.Account) // write string
- buff.WriteString(target.Project) // write string
- buff.WriteString(target.Service) // write string
- buff.WriteString(target.Cluster) // write string
- buff.WriteString(target.Name) // write string
- buff.WriteString(target.ProviderID) // write string
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the AssetProperties type
- func (target *AssetProperties) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling AssetProperties. Expected %d, got %d", CodecVersion, version)
- }
- a := buff.ReadString() // read string
- target.Category = a
- b := buff.ReadString() // read string
- target.Provider = b
- c := buff.ReadString() // read string
- target.Account = c
- d := buff.ReadString() // read string
- target.Project = d
- e := buff.ReadString() // read string
- target.Service = e
- f := buff.ReadString() // read string
- target.Cluster = f
- g := buff.ReadString() // read string
- target.Name = g
- h := buff.ReadString() // read string
- target.ProviderID = h
- return nil
- }
- //--------------------------------------------------------------------------
- // AssetSet
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this AssetSet instance
- // into a byte array
- func (target *AssetSet) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- if target.aggregateBy == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]string) ---
- buff.WriteInt(len(target.aggregateBy)) // array length
- for i := 0; i < len(target.aggregateBy); i++ {
- buff.WriteString(target.aggregateBy[i]) // write string
- }
- // --- [end][write][slice]([]string) ---
- }
- if target.assets == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]Asset) ---
- buff.WriteInt(len(target.assets)) // map length
- for v, z := range target.assets {
- buff.WriteString(v) // write string
- if z == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][interface](Asset) ---
- a := reflect.ValueOf(z).Interface()
- b, okA := a.(encoding.BinaryMarshaler)
- if !okA {
- return nil, fmt.Errorf("Type: %s does not implement encoding.BinaryMarshaler", typeToString(z))
- }
- c, errA := b.MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteString(typeToString(z))
- buff.WriteInt(len(c))
- buff.WriteBytes(c)
- // --- [end][write][interface](Asset) ---
- }
- }
- // --- [end][write][map](map[string]Asset) ---
- }
- // --- [begin][write][struct](Window) ---
- d, errB := target.Window.MarshalBinary()
- if errB != nil {
- return nil, errB
- }
- buff.WriteInt(len(d))
- buff.WriteBytes(d)
- // --- [end][write][struct](Window) ---
- if target.Warnings == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]string) ---
- buff.WriteInt(len(target.Warnings)) // array length
- for j := 0; j < len(target.Warnings); j++ {
- buff.WriteString(target.Warnings[j]) // write string
- }
- // --- [end][write][slice]([]string) ---
- }
- if target.Errors == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]string) ---
- buff.WriteInt(len(target.Errors)) // array length
- for ii := 0; ii < len(target.Errors); ii++ {
- buff.WriteString(target.Errors[ii]) // write string
- }
- // --- [end][write][slice]([]string) ---
- }
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the AssetSet type
- func (target *AssetSet) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling AssetSet. Expected %d, got %d", CodecVersion, version)
- }
- if buff.ReadUInt8() == uint8(0) {
- target.aggregateBy = nil
- } else {
- // --- [begin][read][slice]([]string) ---
- b := buff.ReadInt() // array len
- a := make([]string, b)
- for i := 0; i < b; i++ {
- var c string
- d := buff.ReadString() // read string
- c = d
- a[i] = c
- }
- target.aggregateBy = a
- // --- [end][read][slice]([]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.assets = nil
- } else {
- // --- [begin][read][map](map[string]Asset) ---
- f := buff.ReadInt() // map len
- e := make(map[string]Asset, f)
- for j := 0; j < f; j++ {
- var v string
- g := buff.ReadString() // read string
- v = g
- var z Asset
- if buff.ReadUInt8() == uint8(0) {
- z = nil
- } else {
- // --- [begin][read][interface](Asset) ---
- h := buff.ReadString()
- _, k, _ := resolveType(h)
- if _, ok := typeMap[k]; !ok {
- return fmt.Errorf("Unknown Type: %s", k)
- }
- l, okA := reflect.New(typeMap[k]).Interface().(interface{ UnmarshalBinary([]byte) error })
- if !okA {
- return fmt.Errorf("Type: %s does not implement UnmarshalBinary([]byte) error", k)
- }
- m := buff.ReadInt() // byte array length
- n := buff.ReadBytes(m) // byte array
- errA := l.UnmarshalBinary(n)
- if errA != nil {
- return errA
- }
- z = l.(Asset)
- // --- [end][read][interface](Asset) ---
- }
- e[v] = z
- }
- target.assets = e
- // --- [end][read][map](map[string]Asset) ---
- }
- // --- [begin][read][struct](Window) ---
- o := &Window{}
- p := buff.ReadInt() // byte array length
- q := buff.ReadBytes(p) // byte array
- errB := o.UnmarshalBinary(q)
- if errB != nil {
- return errB
- }
- target.Window = *o
- // --- [end][read][struct](Window) ---
- if buff.ReadUInt8() == uint8(0) {
- target.Warnings = nil
- } else {
- // --- [begin][read][slice]([]string) ---
- s := buff.ReadInt() // array len
- r := make([]string, s)
- for ii := 0; ii < s; ii++ {
- var t string
- u := buff.ReadString() // read string
- t = u
- r[ii] = t
- }
- target.Warnings = r
- // --- [end][read][slice]([]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.Errors = nil
- } else {
- // --- [begin][read][slice]([]string) ---
- x := buff.ReadInt() // array len
- w := make([]string, x)
- for jj := 0; jj < x; jj++ {
- var y string
- aa := buff.ReadString() // read string
- y = aa
- w[jj] = y
- }
- target.Errors = w
- // --- [end][read][slice]([]string) ---
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // AssetSetRange
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this AssetSetRange instance
- // into a byte array
- func (target *AssetSetRange) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- if target.assets == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]*AssetSet) ---
- buff.WriteInt(len(target.assets)) // array length
- for i := 0; i < len(target.assets); i++ {
- if target.assets[i] == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](AssetSet) ---
- a, errA := target.assets[i].MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][struct](AssetSet) ---
- }
- }
- // --- [end][write][slice]([]*AssetSet) ---
- }
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the AssetSetRange type
- func (target *AssetSetRange) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling AssetSetRange. Expected %d, got %d", CodecVersion, version)
- }
- if buff.ReadUInt8() == uint8(0) {
- target.assets = nil
- } else {
- // --- [begin][read][slice]([]*AssetSet) ---
- b := buff.ReadInt() // array len
- a := make([]*AssetSet, b)
- for i := 0; i < b; i++ {
- var c *AssetSet
- if buff.ReadUInt8() == uint8(0) {
- c = nil
- } else {
- // --- [begin][read][struct](AssetSet) ---
- d := &AssetSet{}
- e := buff.ReadInt() // byte array length
- f := buff.ReadBytes(e) // byte array
- errA := d.UnmarshalBinary(f)
- if errA != nil {
- return errA
- }
- c = d
- // --- [end][read][struct](AssetSet) ---
- }
- a[i] = c
- }
- target.assets = a
- // --- [end][read][slice]([]*AssetSet) ---
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // Breakdown
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Breakdown instance
- // into a byte array
- func (target *Breakdown) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- buff.WriteFloat64(target.Idle) // write float64
- buff.WriteFloat64(target.Other) // write float64
- buff.WriteFloat64(target.System) // write float64
- buff.WriteFloat64(target.User) // write float64
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Breakdown type
- func (target *Breakdown) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling Breakdown. Expected %d, got %d", CodecVersion, version)
- }
- a := buff.ReadFloat64() // read float64
- target.Idle = a
- b := buff.ReadFloat64() // read float64
- target.Other = b
- c := buff.ReadFloat64() // read float64
- target.System = c
- d := buff.ReadFloat64() // read float64
- target.User = d
- return nil
- }
- //--------------------------------------------------------------------------
- // Cloud
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Cloud instance
- // into a byte array
- func (target *Cloud) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- // --- [begin][write][alias](AssetLabels) ---
- if map[string]string(target.labels) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(map[string]string(target.labels))) // map length
- for v, z := range map[string]string(target.labels) {
- buff.WriteString(v) // write string
- buff.WriteString(z) // write string
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [end][write][alias](AssetLabels) ---
- if target.properties == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](AssetProperties) ---
- a, errA := target.properties.MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][struct](AssetProperties) ---
- }
- // --- [begin][write][reference](time.Time) ---
- b, errB := target.start.MarshalBinary()
- if errB != nil {
- return nil, errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- c, errC := target.end.MarshalBinary()
- if errC != nil {
- return nil, errC
- }
- buff.WriteInt(len(c))
- buff.WriteBytes(c)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][struct](Window) ---
- d, errD := target.window.MarshalBinary()
- if errD != nil {
- return nil, errD
- }
- buff.WriteInt(len(d))
- buff.WriteBytes(d)
- // --- [end][write][struct](Window) ---
- buff.WriteFloat64(target.adjustment) // write float64
- buff.WriteFloat64(target.Cost) // write float64
- buff.WriteFloat64(target.Credit) // write float64
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Cloud type
- func (target *Cloud) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling Cloud. Expected %d, got %d", CodecVersion, version)
- }
- // --- [begin][read][alias](AssetLabels) ---
- var a map[string]string
- if buff.ReadUInt8() == uint8(0) {
- a = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- c := buff.ReadInt() // map len
- b := make(map[string]string, c)
- for i := 0; i < c; i++ {
- var v string
- d := buff.ReadString() // read string
- v = d
- var z string
- e := buff.ReadString() // read string
- z = e
- b[v] = z
- }
- a = b
- // --- [end][read][map](map[string]string) ---
- }
- target.labels = AssetLabels(a)
- // --- [end][read][alias](AssetLabels) ---
- if buff.ReadUInt8() == uint8(0) {
- target.properties = nil
- } else {
- // --- [begin][read][struct](AssetProperties) ---
- f := &AssetProperties{}
- g := buff.ReadInt() // byte array length
- h := buff.ReadBytes(g) // byte array
- errA := f.UnmarshalBinary(h)
- if errA != nil {
- return errA
- }
- target.properties = f
- // --- [end][read][struct](AssetProperties) ---
- }
- // --- [begin][read][reference](time.Time) ---
- k := &time.Time{}
- l := buff.ReadInt() // byte array length
- m := buff.ReadBytes(l) // byte array
- errB := k.UnmarshalBinary(m)
- if errB != nil {
- return errB
- }
- target.start = *k
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- n := &time.Time{}
- o := buff.ReadInt() // byte array length
- p := buff.ReadBytes(o) // byte array
- errC := n.UnmarshalBinary(p)
- if errC != nil {
- return errC
- }
- target.end = *n
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][struct](Window) ---
- q := &Window{}
- r := buff.ReadInt() // byte array length
- s := buff.ReadBytes(r) // byte array
- errD := q.UnmarshalBinary(s)
- if errD != nil {
- return errD
- }
- target.window = *q
- // --- [end][read][struct](Window) ---
- t := buff.ReadFloat64() // read float64
- target.adjustment = t
- u := buff.ReadFloat64() // read float64
- target.Cost = u
- w := buff.ReadFloat64() // read float64
- target.Credit = w
- return nil
- }
- //--------------------------------------------------------------------------
- // ClusterManagement
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this ClusterManagement instance
- // into a byte array
- func (target *ClusterManagement) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- // --- [begin][write][alias](AssetLabels) ---
- if map[string]string(target.labels) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(map[string]string(target.labels))) // map length
- for v, z := range map[string]string(target.labels) {
- buff.WriteString(v) // write string
- buff.WriteString(z) // write string
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [end][write][alias](AssetLabels) ---
- if target.properties == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](AssetProperties) ---
- a, errA := target.properties.MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][struct](AssetProperties) ---
- }
- // --- [begin][write][struct](Window) ---
- b, errB := target.window.MarshalBinary()
- if errB != nil {
- return nil, errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][struct](Window) ---
- buff.WriteFloat64(target.Cost) // write float64
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the ClusterManagement type
- func (target *ClusterManagement) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling ClusterManagement. Expected %d, got %d", CodecVersion, version)
- }
- // --- [begin][read][alias](AssetLabels) ---
- var a map[string]string
- if buff.ReadUInt8() == uint8(0) {
- a = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- c := buff.ReadInt() // map len
- b := make(map[string]string, c)
- for i := 0; i < c; i++ {
- var v string
- d := buff.ReadString() // read string
- v = d
- var z string
- e := buff.ReadString() // read string
- z = e
- b[v] = z
- }
- a = b
- // --- [end][read][map](map[string]string) ---
- }
- target.labels = AssetLabels(a)
- // --- [end][read][alias](AssetLabels) ---
- if buff.ReadUInt8() == uint8(0) {
- target.properties = nil
- } else {
- // --- [begin][read][struct](AssetProperties) ---
- f := &AssetProperties{}
- g := buff.ReadInt() // byte array length
- h := buff.ReadBytes(g) // byte array
- errA := f.UnmarshalBinary(h)
- if errA != nil {
- return errA
- }
- target.properties = f
- // --- [end][read][struct](AssetProperties) ---
- }
- // --- [begin][read][struct](Window) ---
- k := &Window{}
- l := buff.ReadInt() // byte array length
- m := buff.ReadBytes(l) // byte array
- errB := k.UnmarshalBinary(m)
- if errB != nil {
- return errB
- }
- target.window = *k
- // --- [end][read][struct](Window) ---
- n := buff.ReadFloat64() // read float64
- target.Cost = n
- return nil
- }
- //--------------------------------------------------------------------------
- // Disk
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Disk instance
- // into a byte array
- func (target *Disk) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- // --- [begin][write][alias](AssetLabels) ---
- if map[string]string(target.labels) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(map[string]string(target.labels))) // map length
- for v, z := range map[string]string(target.labels) {
- buff.WriteString(v) // write string
- buff.WriteString(z) // write string
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [end][write][alias](AssetLabels) ---
- if target.properties == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](AssetProperties) ---
- a, errA := target.properties.MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][struct](AssetProperties) ---
- }
- // --- [begin][write][reference](time.Time) ---
- b, errB := target.start.MarshalBinary()
- if errB != nil {
- return nil, errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- c, errC := target.end.MarshalBinary()
- if errC != nil {
- return nil, errC
- }
- buff.WriteInt(len(c))
- buff.WriteBytes(c)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][struct](Window) ---
- d, errD := target.window.MarshalBinary()
- if errD != nil {
- return nil, errD
- }
- buff.WriteInt(len(d))
- buff.WriteBytes(d)
- // --- [end][write][struct](Window) ---
- buff.WriteFloat64(target.adjustment) // write float64
- buff.WriteFloat64(target.Cost) // write float64
- buff.WriteFloat64(target.ByteHours) // write float64
- buff.WriteFloat64(target.Local) // write float64
- if target.Breakdown == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Breakdown) ---
- e, errE := target.Breakdown.MarshalBinary()
- if errE != nil {
- return nil, errE
- }
- buff.WriteInt(len(e))
- buff.WriteBytes(e)
- // --- [end][write][struct](Breakdown) ---
- }
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Disk type
- func (target *Disk) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling Disk. Expected %d, got %d", CodecVersion, version)
- }
- // --- [begin][read][alias](AssetLabels) ---
- var a map[string]string
- if buff.ReadUInt8() == uint8(0) {
- a = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- c := buff.ReadInt() // map len
- b := make(map[string]string, c)
- for i := 0; i < c; i++ {
- var v string
- d := buff.ReadString() // read string
- v = d
- var z string
- e := buff.ReadString() // read string
- z = e
- b[v] = z
- }
- a = b
- // --- [end][read][map](map[string]string) ---
- }
- target.labels = AssetLabels(a)
- // --- [end][read][alias](AssetLabels) ---
- if buff.ReadUInt8() == uint8(0) {
- target.properties = nil
- } else {
- // --- [begin][read][struct](AssetProperties) ---
- f := &AssetProperties{}
- g := buff.ReadInt() // byte array length
- h := buff.ReadBytes(g) // byte array
- errA := f.UnmarshalBinary(h)
- if errA != nil {
- return errA
- }
- target.properties = f
- // --- [end][read][struct](AssetProperties) ---
- }
- // --- [begin][read][reference](time.Time) ---
- k := &time.Time{}
- l := buff.ReadInt() // byte array length
- m := buff.ReadBytes(l) // byte array
- errB := k.UnmarshalBinary(m)
- if errB != nil {
- return errB
- }
- target.start = *k
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- n := &time.Time{}
- o := buff.ReadInt() // byte array length
- p := buff.ReadBytes(o) // byte array
- errC := n.UnmarshalBinary(p)
- if errC != nil {
- return errC
- }
- target.end = *n
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][struct](Window) ---
- q := &Window{}
- r := buff.ReadInt() // byte array length
- s := buff.ReadBytes(r) // byte array
- errD := q.UnmarshalBinary(s)
- if errD != nil {
- return errD
- }
- target.window = *q
- // --- [end][read][struct](Window) ---
- t := buff.ReadFloat64() // read float64
- target.adjustment = t
- u := buff.ReadFloat64() // read float64
- target.Cost = u
- w := buff.ReadFloat64() // read float64
- target.ByteHours = w
- x := buff.ReadFloat64() // read float64
- target.Local = x
- if buff.ReadUInt8() == uint8(0) {
- target.Breakdown = nil
- } else {
- // --- [begin][read][struct](Breakdown) ---
- y := &Breakdown{}
- aa := buff.ReadInt() // byte array length
- bb := buff.ReadBytes(aa) // byte array
- errE := y.UnmarshalBinary(bb)
- if errE != nil {
- return errE
- }
- target.Breakdown = y
- // --- [end][read][struct](Breakdown) ---
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // LoadBalancer
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this LoadBalancer instance
- // into a byte array
- func (target *LoadBalancer) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- if target.properties == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](AssetProperties) ---
- a, errA := target.properties.MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][struct](AssetProperties) ---
- }
- // --- [begin][write][alias](AssetLabels) ---
- if map[string]string(target.labels) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(map[string]string(target.labels))) // map length
- for v, z := range map[string]string(target.labels) {
- buff.WriteString(v) // write string
- buff.WriteString(z) // write string
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [end][write][alias](AssetLabels) ---
- // --- [begin][write][reference](time.Time) ---
- b, errB := target.start.MarshalBinary()
- if errB != nil {
- return nil, errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- c, errC := target.end.MarshalBinary()
- if errC != nil {
- return nil, errC
- }
- buff.WriteInt(len(c))
- buff.WriteBytes(c)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][struct](Window) ---
- d, errD := target.window.MarshalBinary()
- if errD != nil {
- return nil, errD
- }
- buff.WriteInt(len(d))
- buff.WriteBytes(d)
- // --- [end][write][struct](Window) ---
- buff.WriteFloat64(target.adjustment) // write float64
- buff.WriteFloat64(target.Cost) // write float64
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the LoadBalancer type
- func (target *LoadBalancer) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling LoadBalancer. Expected %d, got %d", CodecVersion, version)
- }
- if buff.ReadUInt8() == uint8(0) {
- target.properties = nil
- } else {
- // --- [begin][read][struct](AssetProperties) ---
- a := &AssetProperties{}
- b := buff.ReadInt() // byte array length
- c := buff.ReadBytes(b) // byte array
- errA := a.UnmarshalBinary(c)
- if errA != nil {
- return errA
- }
- target.properties = a
- // --- [end][read][struct](AssetProperties) ---
- }
- // --- [begin][read][alias](AssetLabels) ---
- var d map[string]string
- if buff.ReadUInt8() == uint8(0) {
- d = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- f := buff.ReadInt() // map len
- e := make(map[string]string, f)
- for i := 0; i < f; i++ {
- var v string
- g := buff.ReadString() // read string
- v = g
- var z string
- h := buff.ReadString() // read string
- z = h
- e[v] = z
- }
- d = e
- // --- [end][read][map](map[string]string) ---
- }
- target.labels = AssetLabels(d)
- // --- [end][read][alias](AssetLabels) ---
- // --- [begin][read][reference](time.Time) ---
- k := &time.Time{}
- l := buff.ReadInt() // byte array length
- m := buff.ReadBytes(l) // byte array
- errB := k.UnmarshalBinary(m)
- if errB != nil {
- return errB
- }
- target.start = *k
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- n := &time.Time{}
- o := buff.ReadInt() // byte array length
- p := buff.ReadBytes(o) // byte array
- errC := n.UnmarshalBinary(p)
- if errC != nil {
- return errC
- }
- target.end = *n
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][struct](Window) ---
- q := &Window{}
- r := buff.ReadInt() // byte array length
- s := buff.ReadBytes(r) // byte array
- errD := q.UnmarshalBinary(s)
- if errD != nil {
- return errD
- }
- target.window = *q
- // --- [end][read][struct](Window) ---
- t := buff.ReadFloat64() // read float64
- target.adjustment = t
- u := buff.ReadFloat64() // read float64
- target.Cost = u
- return nil
- }
- //--------------------------------------------------------------------------
- // Network
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Network instance
- // into a byte array
- func (target *Network) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- if target.properties == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](AssetProperties) ---
- a, errA := target.properties.MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][struct](AssetProperties) ---
- }
- // --- [begin][write][alias](AssetLabels) ---
- if map[string]string(target.labels) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(map[string]string(target.labels))) // map length
- for v, z := range map[string]string(target.labels) {
- buff.WriteString(v) // write string
- buff.WriteString(z) // write string
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [end][write][alias](AssetLabels) ---
- // --- [begin][write][reference](time.Time) ---
- b, errB := target.start.MarshalBinary()
- if errB != nil {
- return nil, errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- c, errC := target.end.MarshalBinary()
- if errC != nil {
- return nil, errC
- }
- buff.WriteInt(len(c))
- buff.WriteBytes(c)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][struct](Window) ---
- d, errD := target.window.MarshalBinary()
- if errD != nil {
- return nil, errD
- }
- buff.WriteInt(len(d))
- buff.WriteBytes(d)
- // --- [end][write][struct](Window) ---
- buff.WriteFloat64(target.adjustment) // write float64
- buff.WriteFloat64(target.Cost) // write float64
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Network type
- func (target *Network) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling Network. Expected %d, got %d", CodecVersion, version)
- }
- if buff.ReadUInt8() == uint8(0) {
- target.properties = nil
- } else {
- // --- [begin][read][struct](AssetProperties) ---
- a := &AssetProperties{}
- b := buff.ReadInt() // byte array length
- c := buff.ReadBytes(b) // byte array
- errA := a.UnmarshalBinary(c)
- if errA != nil {
- return errA
- }
- target.properties = a
- // --- [end][read][struct](AssetProperties) ---
- }
- // --- [begin][read][alias](AssetLabels) ---
- var d map[string]string
- if buff.ReadUInt8() == uint8(0) {
- d = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- f := buff.ReadInt() // map len
- e := make(map[string]string, f)
- for i := 0; i < f; i++ {
- var v string
- g := buff.ReadString() // read string
- v = g
- var z string
- h := buff.ReadString() // read string
- z = h
- e[v] = z
- }
- d = e
- // --- [end][read][map](map[string]string) ---
- }
- target.labels = AssetLabels(d)
- // --- [end][read][alias](AssetLabels) ---
- // --- [begin][read][reference](time.Time) ---
- k := &time.Time{}
- l := buff.ReadInt() // byte array length
- m := buff.ReadBytes(l) // byte array
- errB := k.UnmarshalBinary(m)
- if errB != nil {
- return errB
- }
- target.start = *k
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- n := &time.Time{}
- o := buff.ReadInt() // byte array length
- p := buff.ReadBytes(o) // byte array
- errC := n.UnmarshalBinary(p)
- if errC != nil {
- return errC
- }
- target.end = *n
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][struct](Window) ---
- q := &Window{}
- r := buff.ReadInt() // byte array length
- s := buff.ReadBytes(r) // byte array
- errD := q.UnmarshalBinary(s)
- if errD != nil {
- return errD
- }
- target.window = *q
- // --- [end][read][struct](Window) ---
- t := buff.ReadFloat64() // read float64
- target.adjustment = t
- u := buff.ReadFloat64() // read float64
- target.Cost = u
- return nil
- }
- //--------------------------------------------------------------------------
- // Node
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Node instance
- // into a byte array
- func (target *Node) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- if target.properties == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](AssetProperties) ---
- a, errA := target.properties.MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][struct](AssetProperties) ---
- }
- // --- [begin][write][alias](AssetLabels) ---
- if map[string]string(target.labels) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(map[string]string(target.labels))) // map length
- for v, z := range map[string]string(target.labels) {
- buff.WriteString(v) // write string
- buff.WriteString(z) // write string
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [end][write][alias](AssetLabels) ---
- // --- [begin][write][reference](time.Time) ---
- b, errB := target.start.MarshalBinary()
- if errB != nil {
- return nil, errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- c, errC := target.end.MarshalBinary()
- if errC != nil {
- return nil, errC
- }
- buff.WriteInt(len(c))
- buff.WriteBytes(c)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][struct](Window) ---
- d, errD := target.window.MarshalBinary()
- if errD != nil {
- return nil, errD
- }
- buff.WriteInt(len(d))
- buff.WriteBytes(d)
- // --- [end][write][struct](Window) ---
- buff.WriteFloat64(target.adjustment) // write float64
- buff.WriteString(target.NodeType) // write string
- buff.WriteFloat64(target.CPUCoreHours) // write float64
- buff.WriteFloat64(target.RAMByteHours) // write float64
- if target.CPUBreakdown == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Breakdown) ---
- e, errE := target.CPUBreakdown.MarshalBinary()
- if errE != nil {
- return nil, errE
- }
- buff.WriteInt(len(e))
- buff.WriteBytes(e)
- // --- [end][write][struct](Breakdown) ---
- }
- if target.RAMBreakdown == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Breakdown) ---
- f, errF := target.RAMBreakdown.MarshalBinary()
- if errF != nil {
- return nil, errF
- }
- buff.WriteInt(len(f))
- buff.WriteBytes(f)
- // --- [end][write][struct](Breakdown) ---
- }
- buff.WriteFloat64(target.CPUCost) // write float64
- buff.WriteFloat64(target.GPUCost) // write float64
- buff.WriteFloat64(target.GPUCount) // write float64
- buff.WriteFloat64(target.RAMCost) // write float64
- buff.WriteFloat64(target.Discount) // write float64
- buff.WriteFloat64(target.Preemptible) // write float64
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Node type
- func (target *Node) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling Node. Expected %d, got %d", CodecVersion, version)
- }
- if buff.ReadUInt8() == uint8(0) {
- target.properties = nil
- } else {
- // --- [begin][read][struct](AssetProperties) ---
- a := &AssetProperties{}
- b := buff.ReadInt() // byte array length
- c := buff.ReadBytes(b) // byte array
- errA := a.UnmarshalBinary(c)
- if errA != nil {
- return errA
- }
- target.properties = a
- // --- [end][read][struct](AssetProperties) ---
- }
- // --- [begin][read][alias](AssetLabels) ---
- var d map[string]string
- if buff.ReadUInt8() == uint8(0) {
- d = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- f := buff.ReadInt() // map len
- e := make(map[string]string, f)
- for i := 0; i < f; i++ {
- var v string
- g := buff.ReadString() // read string
- v = g
- var z string
- h := buff.ReadString() // read string
- z = h
- e[v] = z
- }
- d = e
- // --- [end][read][map](map[string]string) ---
- }
- target.labels = AssetLabels(d)
- // --- [end][read][alias](AssetLabels) ---
- // --- [begin][read][reference](time.Time) ---
- k := &time.Time{}
- l := buff.ReadInt() // byte array length
- m := buff.ReadBytes(l) // byte array
- errB := k.UnmarshalBinary(m)
- if errB != nil {
- return errB
- }
- target.start = *k
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- n := &time.Time{}
- o := buff.ReadInt() // byte array length
- p := buff.ReadBytes(o) // byte array
- errC := n.UnmarshalBinary(p)
- if errC != nil {
- return errC
- }
- target.end = *n
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][struct](Window) ---
- q := &Window{}
- r := buff.ReadInt() // byte array length
- s := buff.ReadBytes(r) // byte array
- errD := q.UnmarshalBinary(s)
- if errD != nil {
- return errD
- }
- target.window = *q
- // --- [end][read][struct](Window) ---
- t := buff.ReadFloat64() // read float64
- target.adjustment = t
- u := buff.ReadString() // read string
- target.NodeType = u
- w := buff.ReadFloat64() // read float64
- target.CPUCoreHours = w
- x := buff.ReadFloat64() // read float64
- target.RAMByteHours = x
- if buff.ReadUInt8() == uint8(0) {
- target.CPUBreakdown = nil
- } else {
- // --- [begin][read][struct](Breakdown) ---
- y := &Breakdown{}
- aa := buff.ReadInt() // byte array length
- bb := buff.ReadBytes(aa) // byte array
- errE := y.UnmarshalBinary(bb)
- if errE != nil {
- return errE
- }
- target.CPUBreakdown = y
- // --- [end][read][struct](Breakdown) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.RAMBreakdown = nil
- } else {
- // --- [begin][read][struct](Breakdown) ---
- cc := &Breakdown{}
- dd := buff.ReadInt() // byte array length
- ee := buff.ReadBytes(dd) // byte array
- errF := cc.UnmarshalBinary(ee)
- if errF != nil {
- return errF
- }
- target.RAMBreakdown = cc
- // --- [end][read][struct](Breakdown) ---
- }
- ff := buff.ReadFloat64() // read float64
- target.CPUCost = ff
- gg := buff.ReadFloat64() // read float64
- target.GPUCost = gg
- hh := buff.ReadFloat64() // read float64
- target.GPUCount = hh
- kk := buff.ReadFloat64() // read float64
- target.RAMCost = kk
- ll := buff.ReadFloat64() // read float64
- target.Discount = ll
- mm := buff.ReadFloat64() // read float64
- target.Preemptible = mm
- return nil
- }
- //--------------------------------------------------------------------------
- // RawAllocationOnlyData
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this RawAllocationOnlyData instance
- // into a byte array
- func (target *RawAllocationOnlyData) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- buff.WriteFloat64(target.CPUCoreUsageMax) // write float64
- buff.WriteFloat64(target.RAMBytesUsageMax) // write float64
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the RawAllocationOnlyData type
- func (target *RawAllocationOnlyData) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling RawAllocationOnlyData. Expected %d, got %d", CodecVersion, version)
- }
- a := buff.ReadFloat64() // read float64
- target.CPUCoreUsageMax = a
- b := buff.ReadFloat64() // read float64
- target.RAMBytesUsageMax = b
- return nil
- }
- //--------------------------------------------------------------------------
- // SharedAsset
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this SharedAsset instance
- // into a byte array
- func (target *SharedAsset) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- if target.properties == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](AssetProperties) ---
- a, errA := target.properties.MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][struct](AssetProperties) ---
- }
- // --- [begin][write][alias](AssetLabels) ---
- if map[string]string(target.labels) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(map[string]string(target.labels))) // map length
- for v, z := range map[string]string(target.labels) {
- buff.WriteString(v) // write string
- buff.WriteString(z) // write string
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [end][write][alias](AssetLabels) ---
- // --- [begin][write][struct](Window) ---
- b, errB := target.window.MarshalBinary()
- if errB != nil {
- return nil, errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][struct](Window) ---
- buff.WriteFloat64(target.Cost) // write float64
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the SharedAsset type
- func (target *SharedAsset) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling SharedAsset. Expected %d, got %d", CodecVersion, version)
- }
- if buff.ReadUInt8() == uint8(0) {
- target.properties = nil
- } else {
- // --- [begin][read][struct](AssetProperties) ---
- a := &AssetProperties{}
- b := buff.ReadInt() // byte array length
- c := buff.ReadBytes(b) // byte array
- errA := a.UnmarshalBinary(c)
- if errA != nil {
- return errA
- }
- target.properties = a
- // --- [end][read][struct](AssetProperties) ---
- }
- // --- [begin][read][alias](AssetLabels) ---
- var d map[string]string
- if buff.ReadUInt8() == uint8(0) {
- d = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- f := buff.ReadInt() // map len
- e := make(map[string]string, f)
- for i := 0; i < f; i++ {
- var v string
- g := buff.ReadString() // read string
- v = g
- var z string
- h := buff.ReadString() // read string
- z = h
- e[v] = z
- }
- d = e
- // --- [end][read][map](map[string]string) ---
- }
- target.labels = AssetLabels(d)
- // --- [end][read][alias](AssetLabels) ---
- // --- [begin][read][struct](Window) ---
- k := &Window{}
- l := buff.ReadInt() // byte array length
- m := buff.ReadBytes(l) // byte array
- errB := k.UnmarshalBinary(m)
- if errB != nil {
- return errB
- }
- target.window = *k
- // --- [end][read][struct](Window) ---
- n := buff.ReadFloat64() // read float64
- target.Cost = n
- return nil
- }
- //--------------------------------------------------------------------------
- // Window
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Window instance
- // into a byte array
- func (target *Window) MarshalBinary() (data []byte, err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBuffer()
- buff.WriteUInt8(CodecVersion) // version
- if target.start == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][reference](time.Time) ---
- a, errA := target.start.MarshalBinary()
- if errA != nil {
- return nil, errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][reference](time.Time) ---
- }
- if target.end == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][reference](time.Time) ---
- b, errB := target.end.MarshalBinary()
- if errB != nil {
- return nil, errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][reference](time.Time) ---
- }
- return buff.Bytes(), nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Window type
- func (target *Window) UnmarshalBinary(data []byte) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("Unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("Unexpected panic: %+v", r)
- }
- }
- }()
- buff := util.NewBufferFromBytes(data)
- // Codec Version Check
- version := buff.ReadUInt8()
- if version != CodecVersion {
- return fmt.Errorf("Invalid Version Unmarshaling Window. Expected %d, got %d", CodecVersion, version)
- }
- if buff.ReadUInt8() == uint8(0) {
- target.start = nil
- } else {
- // --- [begin][read][reference](time.Time) ---
- a := &time.Time{}
- b := buff.ReadInt() // byte array length
- c := buff.ReadBytes(b) // byte array
- errA := a.UnmarshalBinary(c)
- if errA != nil {
- return errA
- }
- target.start = a
- // --- [end][read][reference](time.Time) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.end = nil
- } else {
- // --- [begin][read][reference](time.Time) ---
- d := &time.Time{}
- e := buff.ReadInt() // byte array length
- f := buff.ReadBytes(e) // byte array
- errB := d.UnmarshalBinary(f)
- if errB != nil {
- return errB
- }
- target.end = d
- // --- [end][read][reference](time.Time) ---
- }
- return nil
- }
|