| 1 |
package sarif |
| 2 |
|
| 3 |
import "time" |
| 4 |
|
| 5 |
// Notification ... |
| 6 |
type Notification struct { |
| 7 |
AssociatedRule *ReportingDescriptorReference `json:"associatedRule,omitempty"` |
| 8 |
Descriptor *ReportingDescriptorReference `json:"descriptor,omitempty"` |
| 9 |
Exception *Exception `json:"exception,omitempty"` |
| 10 |
Level string `json:"level,omitempty"` |
| 11 |
Locations []*Location `json:"locations,omitempty"` |
| 12 |
Message *Message `json:"message"` |
| 13 |
ThreadID *int `json:"threadId,omitempty"` |
| 14 |
TimeUTC *time.Time `json:"timeUtc,omitempty"` |
| 15 |
PropertyBag |
| 16 |
} |
| 17 |
|
| 18 |
// NewNotification creates a new Notification and returns a pointer to it |
| 19 |
func NewNotification() *Notification { |
| 20 |
return &Notification{} |
| 21 |
} |
| 22 |
|
| 23 |
// WithAssociatedRule sets the AssociatedRule |
| 24 |
func (notification *Notification) WithAssociatedRule(associatedRule *ReportingDescriptorReference) *Notification { |
| 25 |
notification.AssociatedRule = associatedRule |
| 26 |
|
| 27 |
return notification |
| 28 |
} |
| 29 |
|
| 30 |
// WithDescriptor sets the Descriptor |
| 31 |
func (notification *Notification) WithDescriptor(descriptor *ReportingDescriptorReference) *Notification { |
| 32 |
notification.Descriptor = descriptor |
| 33 |
|
| 34 |
return notification |
| 35 |
} |
| 36 |
|
| 37 |
// WithException sets the Exception |
| 38 |
func (notification *Notification) WithException(exception *Exception) *Notification { |
| 39 |
notification.Exception = exception |
| 40 |
|
| 41 |
return notification |
| 42 |
} |
| 43 |
|
| 44 |
// WithLevel sets the Level |
| 45 |
func (notification *Notification) WithLevel(level string) *Notification { |
| 46 |
notification.Level = level |
| 47 |
|
| 48 |
return notification |
| 49 |
} |
| 50 |
|
| 51 |
// WithLocations sets the Locations |
| 52 |
func (notification *Notification) WithLocations(locations []*Location) *Notification { |
| 53 |
notification.Locations = locations |
| 54 |
|
| 55 |
return notification |
| 56 |
} |
| 57 |
|
| 58 |
// AddLocation ... |
| 59 |
func (notification *Notification) AddLocation(location *Location) { |
| 60 |
notification.Locations = append(notification.Locations, location) |
| 61 |
} |
| 62 |
|
| 63 |
// WithMessage sets the Message |
| 64 |
func (notification *Notification) WithMessage(message *Message) *Notification { |
| 65 |
notification.Message = message |
| 66 |
return notification |
| 67 |
} |
| 68 |
|
| 69 |
// WithTextMessage sets the Message text |
| 70 |
func (notification *Notification) WithTextMessage(text string) *Notification { |
| 71 |
if notification.Message == nil { |
| 72 |
notification.Message = &Message{} |
| 73 |
} |
| 74 |
notification.Message.Text = &text |
| 75 |
return notification |
| 76 |
} |
| 77 |
|
| 78 |
// WithMessageMarkdown sets the Message markdown |
| 79 |
func (notification *Notification) WithMessageMarkdown(markdown string) *Notification { |
| 80 |
if notification.Message == nil { |
| 81 |
notification.Message = &Message{} |
| 82 |
} |
| 83 |
notification.Message.Markdown = &markdown |
| 84 |
return notification |
| 85 |
} |
| 86 |
|
| 87 |
// WithThreadID sets the ThreadID |
| 88 |
func (notification *Notification) WithThreadID(threadID int) *Notification { |
| 89 |
notification.ThreadID = &threadID |
| 90 |
|
| 91 |
return notification |
| 92 |
} |
| 93 |
|
| 94 |
// WithTimeUTC sets the TimeUTC |
| 95 |
func (notification *Notification) WithTimeUTC(timeUTC *time.Time) *Notification { |
| 96 |
notification.TimeUTC = timeUTC |
| 97 |
return notification |
| 98 |
} |