//native
type Linode = {
token: string;
};
/**
* Update a personal access token
* Updates a Personal Access Token.
>
---
- __CLI__.
```
linode-cli profile token-update 123 \
--label linode-cli
```
[Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli)
- __OAuth scopes__.
```
account:read_write
```
[Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
*/
export async function main(
auth: Linode,
apiVersion: "v4" | "v4beta",
tokenId: string,
body: {
created?: string;
expiry?: string;
id?: number;
label?: string;
scopes?: string;
token?: string;
},
) {
const url = new URL(
`https://api.linode.com/${apiVersion}/profile/tokens/${tokenId}`,
);
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