-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathanalytics.go
More file actions
136 lines (123 loc) · 8.25 KB
/
Copy pathanalytics.go
File metadata and controls
136 lines (123 loc) · 8.25 KB
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
// Code generated by internal/cmd/gen; DO NOT EDIT.
package flashduty
import "context"
// AnalyticsService handles the "On-call/Analytics" API resource.
type AnalyticsService service
// Get account-level insight.
//
// Return aggregated incident insight metrics for the entire account.
//
// API: POST /insight/account (insightByAccount).
func (s *AnalyticsService) ByAccount(ctx context.Context, req *InsightQueryRequest) (*DimensionInsightResponse, *Response, error) {
out := new(DimensionInsightResponse)
resp, err := s.client.do(ctx, "/insight/account", req, out)
if err != nil {
return nil, resp, err
}
return out, resp, nil
}
// Get channel insight.
//
// Return insight metrics aggregated by channel.
//
// API: POST /insight/channel (insightByChannel).
func (s *AnalyticsService) ByChannel(ctx context.Context, req *InsightQueryRequest) (*DimensionInsightResponse, *Response, error) {
out := new(DimensionInsightResponse)
resp, err := s.client.do(ctx, "/insight/channel", req, out)
if err != nil {
return nil, resp, err
}
return out, resp, nil
}
// Get responder insight.
//
// Return insight metrics aggregated by responder.
//
// API: POST /insight/responder (insightByResponder).
func (s *AnalyticsService) ByResponder(ctx context.Context, req *InsightQueryRequest) (*ResponderInsightResponse, *Response, error) {
out := new(ResponderInsightResponse)
resp, err := s.client.do(ctx, "/insight/responder", req, out)
if err != nil {
return nil, resp, err
}
return out, resp, nil
}
// Get team insight.
//
// Return insight metrics aggregated by team.
//
// API: POST /insight/team (insightByTeam).
func (s *AnalyticsService) ByTeam(ctx context.Context, req *InsightQueryRequest) (*DimensionInsightResponse, *Response, error) {
out := new(DimensionInsightResponse)
resp, err := s.client.do(ctx, "/insight/team", req, out)
if err != nil {
return nil, resp, err
}
return out, resp, nil
}
// Export channel insight.
//
// Export channel insight metrics as a CSV file — one row per channel (and per time/hour bucket when `aggregate_unit`/`split_hours` is used). The response is a CSV stream delivered with `Content-Disposition: attachment` — it is not a JSON envelope. `time_zone` defaults to UTC. Rows without a valid channel ID are skipped. Valid `export_fields` keys: channel_id, channel_name, total_incident_cnt, total_incidents_acknowledged, total_incidents_closed, total_incidents_auto_closed, total_incidents_manually_closed, total_incidents_timeout_closed, total_incidents_escalated, total_incidents_manually_escalated, total_incidents_timeout_escalated, total_incidents_reassigned, total_interruptions, total_notifications, total_engaged_seconds, mean_seconds_to_ack, mean_seconds_to_close, noise_reduction_pct, acknowledgement_pct, total_alert_cnt, total_alert_event_cnt, hours. The `hours` column is included by default only when `split_hours` is true. For compatibility, incident-export column keys are also accepted but produce empty columns.
//
// The success body is a file, not a JSON envelope: it is returned on Response.Raw.
//
// API: POST /insight/channel/export (insightChannelExport).
func (s *AnalyticsService) ChannelExport(ctx context.Context, req *InsightQueryRequest) (*Response, error) {
return s.client.do(ctx, "/insight/channel/export", req, nil)
}
// Export insight incidents.
//
// Export the filtered incident analytics list as a CSV file. The response is a CSV stream delivered with `Content-Disposition: attachment` — it is not a JSON envelope. CSV headers and formatted values use the request locale, falling back to the member locale and then the account locale. `time_zone` defaults to the account time zone, then `Asia/Shanghai`. Export stops after at most 100,000 rows. Valid `export_fields` keys: incident_id, title, severity, progress, channel_id, channel_name, team_id, team_name, created_at, alert_cnt, active_alert_cnt, alert_event_cnt, seconds_to_ack, seconds_to_close, closed_by, owner_id, owner_name, creator_id, creator_name, closer_id, closer_name, engaged_seconds, hours, notifications, interruptions, acknowledgements, ackers, assignments, reassignments, escalations, manual_escalations, timeout_escalations, assigned_to, raw_assigned_to, escalate_rule_name, responders, raw_responders, snooze_status, snoozed_before, ever_muted, frequency, is_rare, description, labels, fields. When `export_fields` is omitted, all columns are exported.
//
// The success body is a file, not a JSON envelope: it is returned on Response.Raw.
//
// API: POST /insight/incident/export (insightIncidentExport).
func (s *AnalyticsService) IncidentExport(ctx context.Context, req *InsightIncidentExportRequest) (*Response, error) {
return s.client.do(ctx, "/insight/incident/export", req, nil)
}
// List insight incidents.
//
// Return a paged list of incidents with per-incident handling metrics used by the analytics dashboard.
//
// API: POST /insight/incident/list (insightIncidentList).
func (s *AnalyticsService) IncidentList(ctx context.Context, req *InsightIncidentListRequest) (*InsightIncidentListResponse, *Response, error) {
out := new(InsightIncidentListResponse)
resp, err := s.client.do(ctx, "/insight/incident/list", req, out)
if err != nil {
return nil, resp, err
}
return out, resp, nil
}
// Export responder insight.
//
// Export responder insight metrics as a CSV file — one row per responder (and per time/hour bucket when `aggregate_unit`/`split_hours` is used). The response is a CSV stream delivered with `Content-Disposition: attachment` — it is not a JSON envelope. `time_zone` defaults to UTC. Rows without a valid responder ID are skipped. Valid `export_fields` keys: responder_id, responder_name, total_incident_cnt, total_incidents_acknowledged, total_incidents_reassigned, total_incidents_escalated, total_incidents_manually_escalated, total_incidents_timeout_escalated, total_interruptions, total_notifications, total_engaged_seconds, mean_seconds_to_ack, acknowledgement_pct, hours. The `hours` column is included by default only when `split_hours` is true. For compatibility, incident-export column keys are also accepted but produce empty columns.
//
// The success body is a file, not a JSON envelope: it is returned on Response.Raw.
//
// API: POST /insight/responder/export (insightResponderExport).
func (s *AnalyticsService) ResponderExport(ctx context.Context, req *InsightQueryRequest) (*Response, error) {
return s.client.do(ctx, "/insight/responder/export", req, nil)
}
// Export team insight.
//
// Export team insight metrics as a CSV file — one row per team (and per time/hour bucket when `aggregate_unit`/`split_hours` is used). The response is a CSV stream delivered with `Content-Disposition: attachment` — it is not a JSON envelope. `time_zone` defaults to UTC. Rows without a valid team ID are skipped. Valid `export_fields` keys: team_id, team_name, total_incident_cnt, total_incidents_acknowledged, total_incidents_closed, total_incidents_auto_closed, total_incidents_manually_closed, total_incidents_timeout_closed, total_incidents_escalated, total_incidents_manually_escalated, total_incidents_timeout_escalated, total_incidents_reassigned, total_interruptions, total_notifications, total_engaged_seconds, mean_seconds_to_ack, mean_seconds_to_close, noise_reduction_pct, acknowledgement_pct, total_alert_cnt, total_alert_event_cnt, hours. The `hours` column is included by default only when `split_hours` is true. For compatibility, incident-export column keys are also accepted but produce empty columns.
//
// The success body is a file, not a JSON envelope: it is returned on Response.Raw.
//
// API: POST /insight/team/export (insightTeamExport).
func (s *AnalyticsService) TeamExport(ctx context.Context, req *InsightQueryRequest) (*Response, error) {
return s.client.do(ctx, "/insight/team/export", req, nil)
}
// Get top-K alerts grouped by check or resource.
//
// Return the top-K alert groups aggregated either by `check` or by `resource` label over the specified time range.
//
// API: POST /insight/alert/topk-by-label (insightTopkAlertsByLabel).
func (s *AnalyticsService) TopkAlertsByLabel(ctx context.Context, req *InsightTopkAlertByLabelRequest) (*InsightAlertByLabelResponse, *Response, error) {
out := new(InsightAlertByLabelResponse)
resp, err := s.client.do(ctx, "/insight/alert/topk-by-label", req, out)
if err != nil {
return nil, resp, err
}
return out, resp, nil
}