1 | |
2 | type Linode = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Create a configuration profile |
7 | * Adds a new configuration profile to a Linode. |
8 |
|
9 |
|
10 | > |
11 |
|
12 | --- |
13 |
|
14 |
|
15 | - __CLI__. |
16 |
|
17 | ``` |
18 | linode-cli linodes config-create 7590910 \ |
19 | --label "My Config" \ |
20 | --devices.sda.disk_id 123456 \ |
21 | --devices.sdb.disk_id 123457 |
22 | ``` |
23 |
|
24 | [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli) |
25 |
|
26 | - __OAuth scopes__. |
27 |
|
28 | ``` |
29 | linodes:read_write |
30 | ``` |
31 |
|
32 | [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth) |
33 | */ |
34 | export async function main( |
35 | auth: Linode, |
36 | apiVersion: "v4" | "v4beta", |
37 | linodeId: string, |
38 | body: { |
39 | comments?: string; |
40 | devices?: { |
41 | sda?: { disk_id?: number; volume_id?: number }; |
42 | sdb?: { disk_id?: number; volume_id?: number }; |
43 | sdc?: { disk_id?: number; volume_id?: number }; |
44 | sdd?: { disk_id?: number; volume_id?: number }; |
45 | sde?: { disk_id?: number; volume_id?: number }; |
46 | sdf?: { disk_id?: number; volume_id?: number }; |
47 | sdg?: { disk_id?: number; volume_id?: number }; |
48 | sdh?: { disk_id?: number; volume_id?: number }; |
49 | }; |
50 | helpers?: { |
51 | devtmpfs_automount?: false | true; |
52 | distro?: false | true; |
53 | modules_dep?: false | true; |
54 | network?: false | true; |
55 | updatedb_disabled?: false | true; |
56 | }; |
57 | id?: number; |
58 | interfaces?: { |
59 | active?: false | true; |
60 | id?: number; |
61 | ip_ranges?: string[]; |
62 | ipam_address?: string; |
63 | ipv4?: { nat_1_1?: string; vpc?: string }; |
64 | label?: string; |
65 | primary?: false | true; |
66 | purpose: "public" | "vlan" | "vpc"; |
67 | subnet_id?: number; |
68 | vpc_id?: number; |
69 | }[]; |
70 | kernel?: string; |
71 | label?: string; |
72 | memory_limit?: number; |
73 | root_device?: string; |
74 | run_level?: "default" | "single" | "binbash"; |
75 | virt_mode?: "paravirt" | "fullvirt"; |
76 | }, |
77 | ) { |
78 | const url = new URL( |
79 | `https://api.linode.com/${apiVersion}/linode/instances/${linodeId}/configs`, |
80 | ); |
81 |
|
82 | const response = await fetch(url, { |
83 | method: "POST", |
84 | headers: { |
85 | "Content-Type": "application/json", |
86 | Authorization: "Bearer " + auth.token, |
87 | }, |
88 | body: JSON.stringify(body), |
89 | }); |
90 | if (!response.ok) { |
91 | const text = await response.text(); |
92 | throw new Error(`${response.status} ${text}`); |
93 | } |
94 | return await response.json(); |
95 | } |
96 |
|