//native
type Linode = {
token: string;
};
/**
* Update a profile
* Update information in your profile.
*/
export async function main(
auth: Linode,
apiVersion: "v4" | "v4beta",
body: {
authentication_type?: "password" | "github";
authorized_keys?: string[];
email?: string;
email_notifications?: false | true;
ip_whitelist_enabled?: false | true;
lish_auth_method?: "password_keys" | "keys_only" | "disabled";
referrals?: {
code?: string;
completed?: number;
credit?: number;
pending?: number;
total?: number;
url?: string;
};
restricted?: false | true;
timezone?: string;
two_factor_auth?: false | true;
uid?: number;
username?: string;
verified_phone_number?: string;
},
) {
const url = new URL(`https://api.linode.com/${apiVersion}/profile`);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago