Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FirstTriggerLogEntry and CommonLogEntryField fields and json tags #230

Merged
merged 2 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions incident.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,37 @@ type Assignee struct {
Assignee APIObject `json:"assignee"`
}

// FirstTriggerLogEntry is the first LogEntry
type FirstTriggerLogEntry struct {
CommonLogEntryField
Incident APIObject `json:"incident,omitempty"`
}

// Incident is a normalized, de-duplicated event generated by a PagerDuty integration.
type Incident struct {
APIObject
IncidentNumber uint `json:"incident_number,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
PendingActions []PendingAction `json:"pending_actions,omitempty"`
IncidentKey string `json:"incident_key,omitempty"`
Service APIObject `json:"service,omitempty"`
Assignments []Assignment `json:"assignments,omitempty"`
Acknowledgements []Acknowledgement `json:"acknowledgements,omitempty"`
LastStatusChangeAt string `json:"last_status_change_at,omitempty"`
LastStatusChangeBy APIObject `json:"last_status_change_by,omitempty"`
FirstTriggerLogEntry APIObject `json:"first_trigger_log_entry,omitempty"`
EscalationPolicy APIObject `json:"escalation_policy,omitempty"`
Teams []APIObject `json:"teams,omitempty"`
Priority *Priority `json:"priority,omitempty"`
Urgency string `json:"urgency,omitempty"`
Status string `json:"status,omitempty"`
Id string `json:"id,omitempty"`
ResolveReason ResolveReason `json:"resolve_reason,omitempty"`
AlertCounts AlertCounts `json:"alert_counts,omitempty"`
Body IncidentBody `json:"body,omitempty"`
IsMergeable bool `json:"is_mergeable,omitempty"`
IncidentNumber uint `json:"incident_number,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
PendingActions []PendingAction `json:"pending_actions,omitempty"`
IncidentKey string `json:"incident_key,omitempty"`
Service APIObject `json:"service,omitempty"`
Assignments []Assignment `json:"assignments,omitempty"`
Acknowledgements []Acknowledgement `json:"acknowledgements,omitempty"`
LastStatusChangeAt string `json:"last_status_change_at,omitempty"`
LastStatusChangeBy APIObject `json:"last_status_change_by,omitempty"`
FirstTriggerLogEntry FirstTriggerLogEntry `json:"first_trigger_log_entry,omitempty"`
EscalationPolicy APIObject `json:"escalation_policy,omitempty"`
Teams []APIObject `json:"teams,omitempty"`
Priority *Priority `json:"priority,omitempty"`
Urgency string `json:"urgency,omitempty"`
Status string `json:"status,omitempty"`
Id string `json:"id,omitempty"`
ResolveReason ResolveReason `json:"resolve_reason,omitempty"`
AlertCounts AlertCounts `json:"alert_counts,omitempty"`
Body IncidentBody `json:"body,omitempty"`
IsMergeable bool `json:"is_mergeable,omitempty"`
}

// ListIncidentsResponse is the response structure when calling the ListIncident API endpoint.
Expand Down
16 changes: 10 additions & 6 deletions incident_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,11 @@ func TestIncident_ListLogEntries(t *testing.T) {
APIListObject: listObj,
LogEntries: []LogEntry{
{
APIObject: APIObject{
ID: "1",
Summary: "foo",
CommonLogEntryField: CommonLogEntryField{
APIObject: APIObject{
ID: "1",
Summary: "foo",
},
},
},
},
Expand Down Expand Up @@ -514,9 +516,11 @@ func TestIncident_ListLogEntriesSinceUntil(t *testing.T) {
APIListObject: listObj,
LogEntries: []LogEntry{
{
APIObject: APIObject{
ID: "1",
Summary: "foo",
CommonLogEntryField: CommonLogEntryField{
APIObject: APIObject{
ID: "1",
Summary: "foo",
},
},
},
},
Expand Down
23 changes: 14 additions & 9 deletions log_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@ type Context struct {
Type string
}

// CommonLogEntryField is the list of shared log entry between Incident and LogEntry
type CommonLogEntryField struct {
APIObject
CreatedAt string `json:"created_at,omitempty"`
Agent Agent `json:"agent,omitempty"`
Channel Channel `json:"channel,omitempty"`
Teams []Team `json:"teams,omitempty"`
Contexts []Context `json:"contexts,omitempty"`
AcknowledgementTimeout int `json:"acknowledgement_timeout"`
EventDetails map[string]string `json:"event_details,omitempty"`
}

// LogEntry is a list of all of the events that happened to an incident.
type LogEntry struct {
APIObject
CreatedAt string `json:"created_at"`
Agent Agent
Channel Channel
Incident Incident
Teams []Team
Contexts []Context
AcknowledgementTimeout int `json:"acknowledgement_timeout"`
EventDetails map[string]string
CommonLogEntryField
Incident Incident
}

// ListLogEntryResponse is the response data when calling the ListLogEntry API endpoint.
Expand Down
16 changes: 10 additions & 6 deletions log_entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ func TestLogEntry_List(t *testing.T) {
APIListObject: listObj,
LogEntries: []LogEntry{
{
APIObject: APIObject{
ID: "1",
Summary: "foo",
CommonLogEntryField: CommonLogEntryField{
APIObject: APIObject{
ID: "1",
Summary: "foo",
},
},
},
},
Expand All @@ -57,9 +59,11 @@ func TestLogEntry_Get(t *testing.T) {
res, err := client.GetLogEntry(id, opts)

want := &LogEntry{
APIObject: APIObject{
ID: "1",
Summary: "foo",
CommonLogEntryField: CommonLogEntryField{
APIObject: APIObject{
ID: "1",
Summary: "foo",
},
},
}

Expand Down