Edits history of script submission #2143 for ' Set interaction restrictions for an organization (github)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Github = {
      token: string;
    };
    /**
     * Set interaction restrictions for an organization
     * Temporarily restricts interactions to a certain type of GitHub user in any public repository in the given organization. You must be an organization owner to set these restrictions. Setting the interaction limit at the organization level will overwrite any interaction limits that are set for individual repositories owned by the organization.
     */
    export async function main(
      auth: Github,
      org: string,
      body: {
        expiry?: "one_day" | "three_days" | "one_week" | "one_month" | "six_months";
        limit: "existing_users" | "contributors_only" | "collaborators_only";
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.github.com/orgs/${org}/interaction-limits`);
    
      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 367 days ago

  • nativets
    type Github = {
      token: string;
    };
    /**
     * Set interaction restrictions for an organization
     * Temporarily restricts interactions to a certain type of GitHub user in any public repository in the given organization. You must be an organization owner to set these restrictions. Setting the interaction limit at the organization level will overwrite any interaction limits that are set for individual repositories owned by the organization.
     */
    export async function main(
      auth: Github,
      org: string,
      body: {
        expiry?: "one_day" | "three_days" | "one_week" | "one_month" | "six_months";
        limit: "existing_users" | "contributors_only" | "collaborators_only";
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.github.com/orgs/${org}/interaction-limits`);
    
      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 927 days ago