Edits history of script submission #17165 for ' Update a node pool (linode)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Linode = {
      token: string;
    };
    /**
     * Update a node pool
     * Updates a node pool's count, labels and taints, and autoscaler configuration.
     */
    export async function main(
      auth: Linode,
      apiVersion: "v4" | "v4beta",
      clusterId: string,
      poolId: string,
      body: {
        autoscaler?: { enabled?: false | true; max?: number; min?: number };
        count?: number;
        labels?: {};
        taints?: {
          effect: "NoSchedule" | "PreferNoSchedule" | "NoExecute";
          key: string;
          value: string;
        }[];
      },
    ) {
      const url = new URL(
        `https://api.linode.com/${apiVersion}/lke/clusters/${clusterId}/pools/${poolId}`,
      );
    
      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