github.com/cilium/cilium@v1.16.2/pkg/hubble/api/v1/types.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Hubble 3 4 package v1 5 6 import ( 7 "google.golang.org/protobuf/types/known/timestamppb" 8 9 pb "github.com/cilium/cilium/api/v1/flow" 10 ) 11 12 // Event represents a single event observed and stored by Hubble 13 type Event struct { 14 // Timestamp when event was observed in Hubble 15 Timestamp *timestamppb.Timestamp 16 // Event contains the actual event 17 Event interface{} 18 } 19 20 // GetFlow returns the decoded flow, or nil if the event is nil or not a flow 21 func (ev *Event) GetFlow() *pb.Flow { 22 if ev == nil || ev.Event == nil { 23 return nil 24 } 25 if f, ok := ev.Event.(*pb.Flow); ok { 26 return f 27 } 28 return nil 29 } 30 31 // GetAgentEvent returns the decoded agent event, or nil if the event is nil 32 // or not an agent event 33 func (ev *Event) GetAgentEvent() *pb.AgentEvent { 34 if ev == nil || ev.Event == nil { 35 return nil 36 } 37 if f, ok := ev.Event.(*pb.AgentEvent); ok { 38 return f 39 } 40 return nil 41 } 42 43 // GetDebugEvent returns the decoded debug event, or nil if the event is nil 44 // or not an debug event 45 func (ev *Event) GetDebugEvent() *pb.DebugEvent { 46 if ev == nil || ev.Event == nil { 47 return nil 48 } 49 if d, ok := ev.Event.(*pb.DebugEvent); ok { 50 return d 51 } 52 return nil 53 } 54 55 // GetLostEvent returns the decoded lost event, or nil if the event is nil 56 // or not a lost event 57 func (ev *Event) GetLostEvent() *pb.LostEvent { 58 if ev == nil || ev.Event == nil { 59 return nil 60 } 61 if f, ok := ev.Event.(*pb.LostEvent); ok { 62 return f 63 } 64 return nil 65 }