Edits history of script submission #20009 for ' Create Validation in Warehouse (segment)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Segment = {
      token: string;
      baseUrl: string;
    };
    /**
     * Create Validation in Warehouse
     * Validates input settings against a Warehouse.
    
    
    
    • When called, this endpoint may generate the `Storage Destination Settings Validation` event in the audit trail.
          
     */
    export async function main(
      auth: Segment,
      body: { metadataId: string; settings: {} },
    ) {
      const url = new URL(`${auth.baseUrl}/warehouses/validation`);
    
      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 235 days ago