-
Notifications
You must be signed in to change notification settings - Fork 60
/
incidents.ts
196 lines (146 loc) · 4.37 KB
/
incidents.ts
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import * as Core from '@mux/mux-node/core';
import { APIResource } from '@mux/mux-node/resource';
import { isRequestOptions } from '@mux/mux-node/core';
import * as IncidentsAPI from '@mux/mux-node/resources/data/incidents';
import { BasePage, type BasePageParams } from '@mux/mux-node/pagination';
export class Incidents extends APIResource {
/**
* Returns the details of an incident.
*/
retrieve(incidentId: string, options?: Core.RequestOptions): Core.APIPromise<IncidentResponse> {
return this._client.get(`/data/v1/incidents/${incidentId}`, options);
}
/**
* Returns a list of incidents.
*/
list(
query?: IncidentListParams,
options?: Core.RequestOptions,
): Core.PagePromise<IncidentsBasePage, Incident>;
list(options?: Core.RequestOptions): Core.PagePromise<IncidentsBasePage, Incident>;
list(
query: IncidentListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<IncidentsBasePage, Incident> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/data/v1/incidents', IncidentsBasePage, { query, ...options });
}
/**
* Returns all the incidents that seem related to a specific incident.
*/
listRelated(
incidentId: string,
query?: IncidentListRelatedParams,
options?: Core.RequestOptions,
): Core.PagePromise<IncidentsBasePage, Incident>;
listRelated(
incidentId: string,
options?: Core.RequestOptions,
): Core.PagePromise<IncidentsBasePage, Incident>;
listRelated(
incidentId: string,
query: IncidentListRelatedParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<IncidentsBasePage, Incident> {
if (isRequestOptions(query)) {
return this.listRelated(incidentId, {}, query);
}
return this._client.getAPIList(`/data/v1/incidents/${incidentId}/related`, IncidentsBasePage, {
query,
...options,
});
}
}
export class IncidentsBasePage extends BasePage<Incident> {}
export interface Incident {
id: string;
affected_views: number;
affected_views_per_hour: number;
affected_views_per_hour_on_open: number;
breakdowns: Array<Incident.Breakdown>;
description: string;
error_description: string;
impact: string;
incident_key: string;
measured_value: number | null;
measured_value_on_close: number | null;
measurement: string;
notification_rules: Array<Incident.NotificationRule>;
notifications: Array<Incident.Notification>;
resolved_at: string | null;
sample_size: number;
sample_size_unit: string;
severity: string;
started_at: string;
status: string;
threshold: number;
}
export namespace Incident {
export interface Breakdown {
id: string;
name: string;
value: string;
}
export interface NotificationRule {
id: string;
action: string;
property_id: string;
rules: Array<NotificationRule.Rule>;
status: string;
}
export namespace NotificationRule {
export interface Rule {
id: string;
name: string;
value: string;
}
}
export interface Notification {
id: number;
attempted_at: string;
queued_at: string;
}
}
export interface IncidentResponse {
data: Incident;
timeframe: Array<number>;
total_row_count: number | null;
}
export interface IncidentListParams extends BasePageParams {
/**
* Value to order the results by
*/
order_by?: 'negative_impact' | 'value' | 'views' | 'field';
/**
* Sort order.
*/
order_direction?: 'asc' | 'desc';
/**
* Severity to filter incidents by
*/
severity?: 'warning' | 'alert';
/**
* Status to filter incidents by
*/
status?: 'open' | 'closed' | 'expired';
}
export interface IncidentListRelatedParams extends BasePageParams {
/**
* Value to order the results by
*/
order_by?: 'negative_impact' | 'value' | 'views' | 'field';
/**
* Sort order.
*/
order_direction?: 'asc' | 'desc';
}
export namespace Incidents {
export import Incident = IncidentsAPI.Incident;
export import IncidentResponse = IncidentsAPI.IncidentResponse;
export import IncidentsBasePage = IncidentsAPI.IncidentsBasePage;
export import IncidentListParams = IncidentsAPI.IncidentListParams;
export import IncidentListRelatedParams = IncidentsAPI.IncidentListRelatedParams;
}