Edits history of script submission #12055 for ' Update a SAML Connection (clerk)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clerk = {
      apiKey: string;
    };
    /**
     * Update a SAML Connection
     * Updates the SAML Connection whose ID matches the provided `id` in the path.
     */
    export async function main(
      auth: Clerk,
      saml_connection_id: string,
      body: {
        name?: string;
        domain?: string;
        idp_entity_id?: string;
        idp_sso_url?: string;
        idp_certificate?: string;
        idp_metadata_url?: string;
        idp_metadata?: string;
        organization_id?: string;
        attribute_mapping?: {
          user_id?: string;
          email_address?: string;
          first_name?: string;
          last_name?: string;
        };
        active?: false | true;
        sync_user_attributes?: false | true;
        allow_subdomains?: false | true;
        allow_idp_initiated?: false | true;
        disable_additional_identifications?: false | true;
      },
    ) {
      const url = new URL(
        `https://api.clerk.com/v1/saml_connections/${saml_connection_id}`,
      );
    
      const response = await fetch(url, {
        method: "PATCH",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.apiKey,
        },
        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 428 days ago