1 | |
2 | |
3 | * Create a new dashboard for an organization |
4 | * Create a new dashboard for the given Organization |
5 | */ |
6 | export async function main(auth: RT.Sentry, body: Body) { |
7 | const url = new URL( |
8 | `https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/dashboards/` |
9 | ) |
10 |
|
11 | const response = await fetch(url, { |
12 | method: 'POST', |
13 | headers: { |
14 | 'Content-Type': 'application/json', |
15 | Authorization: 'Bearer ' + auth.token |
16 | }, |
17 | body: JSON.stringify(body) |
18 | }) |
19 | if (!response.ok) { |
20 | const text = await response.text() |
21 | throw new Error(`${response.status} ${text}`) |
22 | } |
23 | return await response.json() |
24 | } |
25 |
|
26 | |
27 | |
28 | * This file was automatically generated by json-schema-to-typescript. |
29 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
30 | * and run json-schema-to-typescript to regenerate this file. |
31 | */ |
32 |
|
33 | |
34 | * Allows parameters to be defined in snake case, but passed as camel case. |
35 | * |
36 | * Errors are output in camel case. |
37 | */ |
38 | export interface Body { |
39 | |
40 | * The user defined title for this dashboard. |
41 | */ |
42 | title: string |
43 | |
44 | * A dashboard's unique id. |
45 | */ |
46 | id?: string |
47 | |
48 | * A json list of widgets saved in this dashboard. |
49 | */ |
50 | widgets?: { |
51 | id?: string |
52 | title?: string |
53 | description?: string |
54 | thresholds?: { |
55 | [k: string]: unknown |
56 | } |
57 | |
58 | * * `line` |
59 | * * `area` |
60 | * * `stacked_area` |
61 | * * `bar` |
62 | * * `table` |
63 | * * `big_number` |
64 | * * `top_n` |
65 | */ |
66 | display_type?: 'line' | 'area' | 'stacked_area' | 'bar' | 'table' | 'big_number' | 'top_n' |
67 | interval?: string |
68 | queries?: { |
69 | id?: string |
70 | fields?: string[] |
71 | aggregates?: string[] |
72 | columns?: string[] |
73 | field_aliases?: string[] |
74 | name?: string |
75 | conditions?: string |
76 | orderby?: string |
77 | is_hidden?: boolean |
78 | |
79 | * Allows parameters to be defined in snake case, but passed as camel case. |
80 | * |
81 | * Errors are output in camel case. |
82 | */ |
83 | on_demand_extraction?: { |
84 | extraction_state?: string |
85 | enabled?: boolean |
86 | [k: string]: unknown |
87 | } |
88 | on_demand_extraction_disabled?: boolean |
89 | selected_aggregate?: number |
90 | [k: string]: unknown |
91 | }[] |
92 | |
93 | * * `discover` |
94 | * * `issue` |
95 | * * `metrics` |
96 | * * `error-events` |
97 | * * `transaction-like` |
98 | * * `spans` |
99 | * * `logs` |
100 | */ |
101 | widget_type?: |
102 | | 'discover' |
103 | | 'issue' |
104 | | 'metrics' |
105 | | 'error-events' |
106 | | 'transaction-like' |
107 | | 'spans' |
108 | | 'logs' |
109 | limit?: number |
110 | layout?: { |
111 | [k: string]: unknown |
112 | } |
113 | [k: string]: unknown |
114 | }[] |
115 | |
116 | * The saved projects filter for this dashboard. |
117 | */ |
118 | projects?: number[] |
119 | |
120 | * The saved environment filter for this dashboard. |
121 | */ |
122 | environment?: string[] |
123 | |
124 | * The saved time range period for this dashboard. |
125 | */ |
126 | period?: string |
127 | |
128 | * The saved start time for this dashboard. |
129 | */ |
130 | start?: string |
131 | |
132 | * The saved end time for this dashboard. |
133 | */ |
134 | end?: string |
135 | |
136 | * The saved filters for this dashboard. |
137 | */ |
138 | filters?: { |
139 | [k: string]: unknown |
140 | } |
141 | |
142 | * Setting that lets you display saved time range for this dashboard in UTC. |
143 | */ |
144 | utc?: boolean |
145 | |
146 | * Permissions that restrict users from editing dashboards |
147 | */ |
148 | permissions?: { |
149 | |
150 | * Whether the dashboard is editable by everyone. |
151 | */ |
152 | is_editable_by_everyone: boolean |
153 | |
154 | * List of team IDs that have edit access to a dashboard. |
155 | */ |
156 | teams_with_edit_access?: number[] |
157 | [k: string]: unknown |
158 | } |
159 | |
160 | * Favorite the dashboard automatically for the request user |
161 | */ |
162 | is_favorited?: boolean |
163 | [k: string]: unknown |
164 | } |
165 |
|