// AnnotationEvent contains fields for annotating an event.
typeAnnotationEventstruct{
IDplatform.ID`json:"id,omitempty"`// ID is the annotation ID.
AnnotationCreate// AnnotationCreate defines the common input/output bits of an annotation.
}
// AnnotationCreate contains user providable fields for annotating an event.
typeAnnotationCreatestruct{
StreamTagstring`json:"stream,omitempty"`// StreamTag provides a means to logically group a set of annotated events.
Summarystring`json:"summary"`// Summary is the only field required to annotate an event.
Messagestring`json:"message,omitempty"`// Message provides more details about the event being annotated.
Stickersmap[string]string`json:"stickers,omitempty"`// Stickers are like tags, but named something obscure to differentiate them from influx tags. They are there to differentiate an annotated event.
EndTime*time.Time`json:"endTime,omitempty"`// EndTime is the time of the event being annotated. Defaults to now if not set.
StartTime*time.Time`json:"startTime,omitempty"`// StartTime is the start time of the event being annotated. Defaults to EndTime if not set.
}
// StoredAnnotation represents annotation data to be stored in the database.
typeStoredAnnotationstruct{
IDplatform.ID`db:"id"`// ID is the annotation's id.
OrgIDplatform.ID`db:"org_id"`// OrgID is the annotations's owning organization.
StreamIDplatform.ID`db:"stream_id"`// StreamID is the id of a stream.
StreamTagstring`db:"name"`// StreamTag is the name of a stream (when selecting with join of streams).
Summarystring`db:"summary"`// Summary is the summary of the annotated event.
Messagestring`db:"message"`// Message is a longer description of the annotated event.
Stickers[]string`db:"stickers"`// Stickers are additional labels to group annotations by.
Durationstring`db:"duration"`// Duration is the time range (with zone) of an annotated event.
Lowerstring`db:"lower"`// Lower is the time an annotated event beings.
Upperstring`db:"upper"`// Upper is the time an annotated event ends.
// AnnotationDeleteFilter contains fields for deleting an annotated event.
typeAnnotationDeleteFilterstruct{
StreamTagstring`json:"stream,omitempty"`// StreamTag provides a means to logically group a set of annotated events.
StreamIDplatform.ID`json:"streamID,omitempty"`// StreamID provides a means to logically group a set of annotated events.
Stickersmap[string]string`json:"stickers,omitempty"`// Stickers are like tags, but named something obscure to differentiate them from influx tags. They are there to differentiate an annotated event.
EndTime*time.Time`json:"endTime,omitempty"`// EndTime is the time of the event being annotated. Defaults to now if not set.
StartTime*time.Time`json:"startTime,omitempty"`// StartTime is the start time of the event being annotated. Defaults to EndTime if not set.
}
// Validate validates the deletion object.
func(a*AnnotationDeleteFilter)Validate()error{
varerrs[]string
iflen(a.StreamTag)==0&&!a.StreamID.Valid(){
errs=append(errs,errMissingStreamTagOrId.Error())
}
ifa.EndTime==nil{
errs=append(errs,errMissingEndTime.Error())
}
ifa.StartTime==nil{
errs=append(errs,errMissingStartTime.Error())
}
iflen(errs)>0{
return&errors.Error{
Code:errors.EInvalid,
Msg:strings.Join(errs,"; "),
}
}
ifa.EndTime.Before(*(a.StartTime)){
returnerrReversedTimes
}
returnnil
}
vardre=regexp.MustCompile(`stickers\[(.*)\]`)
// SetStickers sets the stickers from the query parameters.
// ReadAnnotation defines the simplest form of an annotation to be returned. Essentially, it's AnnotationEvent without stream info.
typeReadAnnotationstruct{
IDplatform.ID`json:"id"`// ID is the annotation's generated id.
Summarystring`json:"summary"`// Summary is the only field required to annotate an event.
Messagestring`json:"message,omitempty"`// Message provides more details about the event being annotated.
Stickersmap[string]string`json:"stickers,omitempty"`// Stickers are like tags, but named something obscure to differentiate them from influx tags. They are there to differentiate an annotated event.
EndTimestring`json:"endTime"`// EndTime is the time of the event being annotated.
StartTimestring`json:"startTime,omitempty"`// StartTime is the start time of the event being annotated.
}
// AnnotationListFilter is a selection filter for listing annotations.
typeAnnotationListFilterstruct{
StickerIncludesmap[string]string`json:"stickerIncludes,omitempty"`// StickerIncludes allows the user to filter annotated events based on it's sticker.
StreamIncludes[]string`json:"streamIncludes,omitempty"`// StreamIncludes allows the user to filter annotated events by stream.
// StreamListFilter is a selection filter for listing streams. Streams are not considered first class resources, but depend on an annotation using them.
typeStreamListFilterstruct{
StreamIncludes[]string`json:"streamIncludes,omitempty"`// StreamIncludes allows the user to filter streams returned.