1 | |
2 | type Linode = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Open a support ticket |
7 | * Open a support ticket. |
8 | */ |
9 | export async function main( |
10 | auth: Linode, |
11 | apiVersion: "v4" | "v4beta", |
12 | body: { |
13 | bucket?: string; |
14 | database_id?: number; |
15 | description: string; |
16 | domain_id?: number; |
17 | firewall_id?: number; |
18 | linode_id?: number; |
19 | lkecluster_id?: number; |
20 | longviewclient_id?: number; |
21 | managed_issue?: false | true; |
22 | nodebalancer_id?: number; |
23 | region?: string; |
24 | summary: string; |
25 | vlan?: string; |
26 | volume_id?: number; |
27 | vpc_id?: number; |
28 | }, |
29 | ) { |
30 | const url = new URL(`https://api.linode.com/${apiVersion}/support/tickets`); |
31 |
|
32 | const response = await fetch(url, { |
33 | method: "POST", |
34 | headers: { |
35 | "Content-Type": "application/json", |
36 | Authorization: "Bearer " + auth.token, |
37 | }, |
38 | body: JSON.stringify(body), |
39 | }); |
40 | if (!response.ok) { |
41 | const text = await response.text(); |
42 | throw new Error(`${response.status} ${text}`); |
43 | } |
44 | return await response.json(); |
45 | } |
46 |
|