0

Update a Longview client

by
Published Oct 17, 2025

Updates a Longview Client.

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Update a Longview client
7
 * Updates a Longview Client.
8
 */
9
export async function main(
10
  auth: Linode,
11
  apiVersion: "v4" | "v4beta",
12
  clientId: string,
13
  body: {
14
    api_key?: string;
15
    apps?: {
16
      apache?: false | true;
17
      mysql?: false | true;
18
      nginx?: false | true;
19
    };
20
    created?: string;
21
    id?: number;
22
    install_code?: string;
23
    label?: string;
24
    updated?: string;
25
  },
26
) {
27
  const url = new URL(
28
    `https://api.linode.com/${apiVersion}/longview/clients/${clientId}`,
29
  );
30

31
  const response = await fetch(url, {
32
    method: "PUT",
33
    headers: {
34
      "Content-Type": "application/json",
35
      Authorization: "Bearer " + auth.token,
36
    },
37
    body: JSON.stringify(body),
38
  });
39
  if (!response.ok) {
40
    const text = await response.text();
41
    throw new Error(`${response.status} ${text}`);
42
  }
43
  return await response.json();
44
}
45