1 | |
2 | type Linode = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update a VPC subnet |
7 | * Update a VPC Subnet. |
8 | */ |
9 | export async function main( |
10 | auth: Linode, |
11 | apiVersion: "v4" | "v4beta", |
12 | vpcId: string, |
13 | vpcSubnetId: string, |
14 | body: { label?: string }, |
15 | ) { |
16 | const url = new URL( |
17 | `https://api.linode.com/${apiVersion}/vpcs/${vpcId}/subnets/${vpcSubnetId}`, |
18 | ); |
19 |
|
20 | const response = await fetch(url, { |
21 | method: "PUT", |
22 | headers: { |
23 | "Content-Type": "application/json", |
24 | Authorization: "Bearer " + auth.token, |
25 | }, |
26 | body: JSON.stringify(body), |
27 | }); |
28 | if (!response.ok) { |
29 | const text = await response.text(); |
30 | throw new Error(`${response.status} ${text}`); |
31 | } |
32 | return await response.json(); |
33 | } |
34 |
|