forked from andygrunwald/go-incident
-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
412 lines (304 loc) · 10.9 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
package incident
import (
"time"
)
const (
// Custom Field Types
CustomFieldTypeLink = "link"
CustomFieldTypeMultiSelect = "multi_select"
CustomFieldTypeNumeric = "numeric"
CustomFieldTypeSingleSelect = "single_select"
CustomFieldTypeText = "text"
// User Roles
UserRoleAdministrator = "administrator"
UserRoleOwner = "owner"
UserRoleResponder = "responder"
UserRoleViewer = "viewer"
// Incident Roles
IncidentRoleCustom = "custom"
IncidentRoleLead = "lead"
// Incident Status
IncidentStatusClosed = "closed"
IncidentStatusDeclined = "declined"
IncidentStatusFixing = "fixing"
IncidentStatusInvestigating = "investigating"
IncidentStatusMonitoring = "monitoring"
IncidentStatusTriage = "triage"
// Incident Type
IncidentTypeReal = "real"
IncidentTypeTest = "test"
IncidentTypeTutorial = "tutorial"
// Incident Visbility
IncidentVisibilityPrivate = "private"
IncidentVisibilityPublic = "public"
// External Issue Reference Provider
ExternalIssueReferenceProviderClubhouse = "clubhouse"
ExternalIssueReferenceProviderGithub = "github"
ExternalIssueReferenceProviderJira = "jira"
ExternalIssueReferenceProviderJiraServer = "jira_server"
ExternalIssueReferenceProviderLinear = "linear"
// Action Status
ActionStatusCompleted = "completed"
ActionStatusDeleted = "deleted"
ActionStatusNotDoing = "not_doing"
ActionStatusOutstanding = "outstanding"
)
// IncidentsListOptions defines parameters for IncidentsService.List.
type IncidentsListOptions struct {
// Number of records to return
PageSize int `url:"page_size,omitempty"`
// An incident's ID. This endpoint will return a list of incidents created after this incident.
After string `url:"after,omitempty"`
// Filter for incidents in these statuses
Status []string `url:"status,omitempty"`
}
type Incident struct {
// The call URL attached to this incident
CallUrl string `json:"call_url,omitempty"`
// When the incident was created
CreatedAt time.Time `json:"created_at"`
// Custom field entries for this incident
CustomFieldEntries []CustomFieldEntry `json:"custom_field_entries"`
// Unique identifier for the incident
Id string `json:"id"`
// A list of who is assigned to each role for this incident
IncidentRoleAssignments []IncidentRoleAssignment `json:"incident_role_assignments"`
// Explanation of the incident
Name string `json:"name"`
// Description of the incident
PostmortemDocumentUrl string `json:"postmortem_document_url,omitempty"`
// Reference to this incident, as displayed across the product
Reference string `json:"reference"`
Creator Actor `json:"creator"`
Severity Severity `json:"severity"`
ExternalIssueReference *ExternalIssueReference `json:"external_issue_reference,omitempty"`
// ID of the Slack channel in the organisation Slack workspace
SlackChannelId string `json:"slack_channel_id"`
// Name of the slack channel
SlackChannelName string `json:"slack_channel_name,omitempty"`
// Current status of the incident
IncidentStatus IncidentStatus `json:"incident_status"`
// Detailed description of the incident
Summary string `json:"summary,omitempty"`
// Incident lifecycle events and when they last occurred
Timestamps *[]IncidentTimestamp `json:"timestamps,omitempty"`
// Whether the incident is real, a test, or a tutorial
Type string `json:"type"`
// When the incident was last updated
UpdatedAt time.Time `json:"updated_at"`
// Whether the incident is public or private
Visibility string `json:"visibility"`
}
type IncidentsList struct {
Incidents []Incident `json:"incidents"`
PaginationMeta *PaginationMeta `json:"pagination_meta,omitempty"`
}
type PaginationMeta struct {
// If provided, were records after a particular ID
After string `json:"after,omitempty"`
// What was the maximum number of results requested
PageSize int64 `json:"page_size"`
// How many matching records were there in total
TotalRecordCount int64 `json:"total_record_count"`
}
type CustomFieldEntry struct {
CustomField CustomFieldTypeInfo `json:"custom_field"`
// List of custom field values set on this entry
Values []CustomFieldValue `json:"values"`
}
type CustomFieldTypeInfo struct {
// Description of the custom field
Description string `json:"description"`
// Type of custom field
FieldType string `json:"field_type"`
// Unique identifier for the custom field
Id string `json:"id"`
// Human readable name for the custom field
Name string `json:"name"`
// What options are available for this custom field, if this field has options
Options []CustomFieldOption `json:"options"`
}
type CustomFieldOption struct {
// ID of the custom field this option belongs to
CustomFieldId string `json:"custom_field_id"`
// Unique identifier for the custom field option
Id string `json:"id"`
// Sort key used to order the custom field options correctly
SortKey int64 `json:"sort_key"`
// Human readable name for the custom field option
Value string `json:"value"`
}
type CustomFieldValue struct {
// Link value
ValueLink string `json:"value_link,omitempty"`
// Numeric value
ValueNumeric string `json:"value_numeric,omitempty"`
ValueOption *CustomFieldOption `json:"value_option,omitempty"`
// Text value
ValueText string `json:"value_text,omitempty"`
}
type IncidentRoleAssignment struct {
Assignee *User `json:"assignee,omitempty"`
Role IncidentRole `json:"role"`
}
type User struct {
// Unique identifier of the user
Id string `json:"id"`
// Name of the user
Name string `json:"name"`
// Role of the user
Role string `json:"role"`
// Email of the user
Email string `json:"email"`
// Slack User ID of the user
SlackUserID string `json:"slack_user_id"`
}
type IncidentRole struct {
// When the action was created
CreatedAt time.Time `json:"created_at"`
// Describes the purpose of the role
Description string `json:"description"`
// Unique identifier for the role
Id string `json:"id"`
// Provided to whoever is nominated for the role
Instructions string `json:"instructions"`
// Human readable name of the incident role
Name string `json:"name"`
// Whether incident require this role to be set
Required bool `json:"required"`
// Type of incident role
RoleType string `json:"role_type"`
// Short human readable name for Slack
Shortform string `json:"shortform"`
// When the action was last updated
UpdatedAt time.Time `json:"updated_at"`
}
type Actor struct {
ApiKey *APIKey `json:"api_key,omitempty"`
User *User `json:"user,omitempty"`
}
type Severity struct {
// When the action was created
CreatedAt time.Time `json:"created_at"`
// Description of the severity
Description string `json:"description"`
// Unique identifier of the severity
Id string `json:"id"`
// Human readable name of the severity
Name string `json:"name"`
// Rank to help sort severities (lower numbers are less severe)
Rank int64 `json:"rank"`
// When the action was last updated
UpdatedAt time.Time `json:"updated_at"`
}
type IncidentTimestamp struct {
// When this last occurred, if it did
LastOccurredAt time.Time `json:"last_occurred_at,omitempty"`
// Name of the lifecycle event
Name string `json:"name"`
}
type APIKey struct {
// Unique identifier for this API key
Id string `json:"id"`
// The name of the API key, for the user's reference
Name string `json:"name"`
}
type IncidentResponse struct {
Incident Incident `json:"incident"`
}
type SeveritiesList struct {
Severities []Severity `json:"severities"`
}
type SeverityResponse struct {
Severity Severity `json:"severity"`
}
type IncidentRolesList struct {
IncidentRoles []IncidentRole `json:"incident_roles"`
}
type IncidentRoleResponse struct {
IncidentRole IncidentRole `json:"incident_role"`
}
type CustomField struct {
// When the action was created
CreatedAt time.Time `json:"created_at"`
// Description of the custom field
Description string `json:"description"`
// Type of custom field
FieldType string `json:"field_type"`
// Unique identifier for the custom field
Id string `json:"id"`
// Human readable name for the custom field
Name string `json:"name"`
// What options are available for this custom field, if this field has options
Options []CustomFieldOption `json:"options"`
// Whether a custom field should be required in the incident close modal
RequireBeforeClosure bool `json:"require_before_closure"`
// Whether a custom field should be required in the incident creation modal
RequireBeforeCreation bool `json:"require_before_creation"`
// Whether a custom field should be shown in the incident close modal
ShowBeforeClosure bool `json:"show_before_closure"`
// Whether a custom field should be shown in the incident creation modal
ShowBeforeCreation bool `json:"show_before_creation"`
// When the action was last updated
UpdatedAt time.Time `json:"updated_at"`
}
type CustomFieldsList struct {
CustomFields []CustomField `json:"custom_fields"`
}
type CustomFieldResponse struct {
CustomField CustomField `json:"custom_field"`
}
type ActionsListOptions struct {
// Find actions related to this incident
IncidentId string `url:"incident_id,omitempty"`
// Filter to actions marked as being follow up actions
IsFollowUp bool `url:"is_follow_up,omitempty"`
// Filter to actions from incidents of the given mode.
// If not set, only actions from real incidents are returned
// Enum: "real" "test" "tutorial"
IncidentMode string `url:"incident_mode,omitempty"`
}
type ActionsList struct {
Actions []Action `json:"actions"`
}
type Action struct {
// When the action was completed
CompletedAt time.Time `json:"completed_at,omitempty"`
// When the action was created
CreatedAt time.Time `json:"created_at"`
// Description of the action
Description string `json:"description"`
ExternalIssueReference *ExternalIssueReference `json:"external_issue_reference,omitempty"`
// Whether an action is marked as follow-up
FollowUp bool `json:"follow_up"`
// Unique identifier for the action
Id string `json:"id"`
// Unique identifier of the incident the action belongs to
IncidentId string `json:"incident_id"`
// Status of the action
Status string `json:"status"`
// When the action was last updated
UpdatedAt time.Time `json:"updated_at"`
// Assignee of the action
Assignee *User `json:"assignee,omitempty"`
}
type ExternalIssueReference struct {
// Human readable ID for the issue
IssueName string `json:"issue_name"`
// URL linking directly to the action in the issue tracker
IssuePermalink string `json:"issue_permalink"`
// ID of the issue tracker provider
Provider string `json:"provider"`
}
type IncidentStatus struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Rank int `json:"rank"`
Category string `json:"category"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type ActionResponse struct {
Action Action `json:"action"`
}