// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. // Lexicon schema: sh.tangled.ci.event package tangled import ( "bytes" "encoding/json" "fmt" "io" lexutil "github.com/bluesky-social/indigo/lex/util" cbg "github.com/whyrusleeping/cbor-gen" ) const ( CiEventNSID = "sh.tangled.ci.event" ) // CiEvent is a "main" in the sh.tangled.ci.event schema. type CiEvent struct { Meta *CiEvent_Meta `json:"meta" cborgen:"meta"` } // CiEvent_Manual is a "manual" in the sh.tangled.ci.event schema. type CiEvent_Manual struct { LexiconTypeID string `json:"$type" cborgen:"$type,const=sh.tangled.ci.event#manual"` } type CiEvent_Meta struct { CiEvent_PullRequest *CiEvent_PullRequest CiEvent_Push *CiEvent_Push CiEvent_Manual *CiEvent_Manual } func (t *CiEvent_Meta) MarshalJSON() ([]byte, error) { if t.CiEvent_PullRequest != nil { t.CiEvent_PullRequest.LexiconTypeID = "sh.tangled.ci.event#pullRequest" return json.Marshal(t.CiEvent_PullRequest) } if t.CiEvent_Push != nil { t.CiEvent_Push.LexiconTypeID = "sh.tangled.ci.event#push" return json.Marshal(t.CiEvent_Push) } if t.CiEvent_Manual != nil { t.CiEvent_Manual.LexiconTypeID = "sh.tangled.ci.event#manual" return json.Marshal(t.CiEvent_Manual) } return nil, fmt.Errorf("can not marshal empty union as JSON") } func (t *CiEvent_Meta) UnmarshalJSON(b []byte) error { typ, err := lexutil.TypeExtract(b) if err != nil { return err } switch typ { case "sh.tangled.ci.event#pullRequest": t.CiEvent_PullRequest = new(CiEvent_PullRequest) return json.Unmarshal(b, t.CiEvent_PullRequest) case "sh.tangled.ci.event#push": t.CiEvent_Push = new(CiEvent_Push) return json.Unmarshal(b, t.CiEvent_Push) case "sh.tangled.ci.event#manual": t.CiEvent_Manual = new(CiEvent_Manual) return json.Unmarshal(b, t.CiEvent_Manual) default: return nil } } func (t *CiEvent_Meta) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if t.CiEvent_PullRequest != nil { return t.CiEvent_PullRequest.MarshalCBOR(w) } if t.CiEvent_Push != nil { return t.CiEvent_Push.MarshalCBOR(w) } if t.CiEvent_Manual != nil { return t.CiEvent_Manual.MarshalCBOR(w) } return fmt.Errorf("can not marshal empty union as CBOR") } func (t *CiEvent_Meta) UnmarshalCBOR(r io.Reader) error { typ, b, err := lexutil.CborTypeExtractReader(r) if err != nil { return err } switch typ { case "sh.tangled.ci.event#pullRequest": t.CiEvent_PullRequest = new(CiEvent_PullRequest) return t.CiEvent_PullRequest.UnmarshalCBOR(bytes.NewReader(b)) case "sh.tangled.ci.event#push": t.CiEvent_Push = new(CiEvent_Push) return t.CiEvent_Push.UnmarshalCBOR(bytes.NewReader(b)) case "sh.tangled.ci.event#manual": t.CiEvent_Manual = new(CiEvent_Manual) return t.CiEvent_Manual.UnmarshalCBOR(bytes.NewReader(b)) default: return nil } } // CiEvent_PullRequest is a "pullRequest" in the sh.tangled.ci.event schema. type CiEvent_PullRequest struct { LexiconTypeID string `json:"$type" cborgen:"$type,const=sh.tangled.ci.event#pullRequest"` } // CiEvent_Push is a "push" in the sh.tangled.ci.event schema. type CiEvent_Push struct { LexiconTypeID string `json:"$type" cborgen:"$type,const=sh.tangled.ci.event#push"` NewSha string `json:"newSha" cborgen:"newSha"` OldSha string `json:"oldSha" cborgen:"oldSha"` Ref string `json:"ref" cborgen:"ref"` }