Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultHTTPClient *http.Client
var ErrAPIError = errors.New("an API error was encountered while processing events")
var ErrInvalidRoutingKey = errors.New("invalid routing key")
var ErrUnrecognizedEventType = errors.New("unrecognized event type")
ErrUnrecognizedEventType occurs when an event isn't supported by the events API.
var StringToEventVersion = map[string]EventVersion{ "v1": EventVersion1, "v2": EventVersion2, }
Functions ¶
This section is empty.
Types ¶
type AgentContext ¶ added in v0.5.1
type AgentContext struct { QueuedBy string `json:"queued_by"` QueuedAt string `json:"queued_at"` AgentId string `json:"agent_id"` }
AgentContext is used for pdagent integrations
type BaseResponse ¶
BaseResponse is a minimal implementation of the `Response` interface.
func (*BaseResponse) GetHTTPResponse ¶
func (br *BaseResponse) GetHTTPResponse() *http.Response
func (*BaseResponse) SetHTTPResponse ¶
func (br *BaseResponse) SetHTTPResponse(resp *http.Response)
SetHTTPResponse sets `HTTPResponse` on a response.
type ContextV1 ¶
type ContextV1 struct { Type string `json:"type"` Href string `json:"href"` Text string `json:"text,omitempty"` Source string `json:"src"` Alt string `json:"alt,omitempty"` }
ContextV1 corresponds to a V1 context object.
Technically this can either be a `link` or `image` context type, but currently representing as a single type for convenience.
type DetailsV1 ¶
type DetailsV1 map[string]interface{}
DetailsV1 corresponds to a V1 details object.
type EnqueueOption ¶
type EnqueueOption func(*enqueueConfig)
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) EnqueueOption
WithHTTPClient is an option for use in conjunction with Enqueue allowing a user to override our default HTTP client with their own.
type Event ¶
type Event interface { GetRoutingKey() string Validate() error Version() EventVersion }
type EventContainer ¶ added in v0.4.0
type EventContainer struct { EventVersion EventVersion EventData json.RawMessage }
func (*EventContainer) UnmarshalEvent ¶ added in v0.4.0
func (ec *EventContainer) UnmarshalEvent() (Event, error)
type EventV1 ¶
type EventV1 struct { ServiceKey string `json:"service_key"` EventType string `json:"event_type"` IncidentKey string `json:"incident_key,omitempty"` Description string `json:"description"` Details DetailsV1 `json:"details,omitempty"` Client string `json:"client,omitempty"` ClientURL string `json:"client_url,omitempty"` Contexts []ContextV1 `json:"contexts,omitempty"` Agent AgentContext `json:"agent,omitempty"` }
EventV1 corresponds to a V1 event object.
func (*EventV1) GetRoutingKey ¶
func (*EventV1) Version ¶ added in v0.4.0
func (e *EventV1) Version() EventVersion
type EventV2 ¶
type EventV2 struct { RoutingKey string `json:"routing_key"` EventAction string `json:"event_action"` DedupKey string `json:"dedup_key,omitempty"` Payload PayloadV2 `json:"payload"` Client string `json:"client,omitempty"` ClientUrl string `json:"client_url,omitempty"` Images []ImageV2 `json:"images,omitempty"` Links []LinkV2 `json:"links,omitempty"` }
EventV2 corresponds to a V2 event object.
func (*EventV2) GetRoutingKey ¶
func (*EventV2) Version ¶ added in v0.4.0
func (e *EventV2) Version() EventVersion
type EventVersion ¶ added in v0.4.0
type EventVersion string
var EventVersion1 EventVersion = "v1"
var EventVersion2 EventVersion = "v2"
func (EventVersion) String ¶ added in v0.4.0
func (ev EventVersion) String() string
type ImageV2 ¶
type ImageV2 struct { Source string `json:"src"` Href string `json:"href,omitempty"` Alt string `json:"alt,omitempty"` }
ImageV2 corresponds to a V2 image object.
type PayloadV2 ¶
type PayloadV2 struct { Summary string `json:"summary"` Source string `json:"source"` Severity string `json:"severity"` Timestamp string `json:"timestamp,omitempty"` Component string `json:"component,omitempty"` Group string `json:"group,omitempty"` Class string `json:"class,omitempty"` CustomDetails map[string]interface{} `json:"custom_details,omitempty"` }
PayloadV2 corresponds to a V2 payload object.
type Response ¶
Response defines a minimal interface for the events APIs' HTTP responses.
func Enqueue ¶
func Enqueue(context context.Context, eventContainer *EventContainer, options ...EnqueueOption) (Response, error)
Enqueue an event to either the V1 or V2 events API depending on event type.
type ResponseV1 ¶
type ResponseV1 struct { BaseResponse Status string `json:"status,omitempty"` Message string `json:"message,omitempty"` IncidentKey string `json:"incident_key,omitempty"` Errors []string `json:"errors,omitempty"` }
ResponseV1 corresponds to a V1 response.
type ResponseV2 ¶
type ResponseV2 struct { BaseResponse Status string `json:"status,omitempty"` Message string `json:"message,omitempty"` DedupKey string `json:"dedupkey,omitempty"` Errors []string `json:"errors,omitempty"` }
ResponseV2 corresponds to a V2 response object.