//native
type Linode = {
token: string;
};
/**
* Update a volume
* Updates a Volume that you have permission to `read_write`.
>
---
- __CLI__.
```
linode-cli volumes update 12345 \
--label my_volume
```
[Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli)
- __OAuth scopes__.
```
volumes:read_write
```
[Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
*/
export async function main(
auth: Linode,
apiVersion: "v4" | "v4beta",
volumeId: string,
body: {
created?: string;
encryption?: "enabled" | "disabled";
filesystem_path?: string;
hardware_type?: "hdd" | "nvme";
id?: number;
label?: string;
linode_id?: number;
linode_label?: string;
region?: string;
size?: number;
status?: "creating" | "active" | "resizing" | "key_rotating";
tags?: string[];
updated?: string;
} & { linode_id?: {}; size?: {} },
) {
const url = new URL(
`https://api.linode.com/${apiVersion}/volumes/${volumeId}`,
);
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