//native
type Digitalocean = {
token: string;
};
/**
* Install Kubernetes 1-Click Applications
* To install a Kubernetes 1-Click application on a cluster, send a POST request to
`/v2/1-clicks/kubernetes`. The `addon_slugs` and `cluster_uuid` must be provided as body
parameter in order to specify which 1-Click application(s) to install. To list all available
1-Click Kubernetes applications, send a request to `/v2/1-clicks?type=kubernetes`.
*/
export async function main(
auth: Digitalocean,
body: { addon_slugs: string[]; cluster_uuid: string },
) {
const url = new URL(`https://api.digitalocean.com/v2/1-clicks/kubernetes`);
const response = await fetch(url, {
method: "POST",
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 536 days ago