Edits history of script submission #14941 for ' Update disruption specifications for a cluster (cockroachdb)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Cockroachdb = {
      token: string;
    };
    /**
     * Update disruption specifications for a cluster
     * Can be used by the following roles assigned at the organization, folder or cluster scope:
    - CLUSTER_ADMIN
    - CLUSTER_OPERATOR_WRITER
    
     */
    export async function main(
      auth: Cockroachdb,
      cluster_id: string,
      body: {
        regional_disruptor_specifications?: {
          azs?: string[];
          is_whole_region: false | true;
          pods?: string[];
          region_code: string;
        }[];
      },
    ) {
      const url = new URL(
        `https://cockroachlabs.cloud/api/v1/clusters/${cluster_id}/disrupt`,
      );
    
      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