Edits history of script submission #1637 for ' Manage access control for organization codespaces (github)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Github = {
      token: string;
    };
    /**
     * Manage access control for organization codespaces
     * Sets which users can access codespaces in an organization. This is synonymous with granting or revoking codespaces billing permissions for users according to the visibility.
    You must authenticate using an access token with the `admin:org` scope to use this endpoint.
     */
    export async function main(
      auth: Github,
      org: string,
      body: {
        selected_usernames?: string[];
        visibility:
          | "disabled"
          | "selected_members"
          | "all_members"
          | "all_members_and_outside_collaborators";
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.github.com/orgs/${org}/codespaces/billing`);
    
      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.text();
    }
    

    Submitted by hugo697 367 days ago

  • nativets
    type Github = {
      token: string;
    };
    /**
     * Manage access control for organization codespaces
     * Sets which users can access codespaces in an organization. This is synonymous with granting or revoking codespaces billing permissions for users according to the visibility.
    You must authenticate using an access token with the `admin:org` scope to use this endpoint.
     */
    export async function main(
      auth: Github,
      org: string,
      body: {
        selected_usernames?: string[];
        visibility:
          | "disabled"
          | "selected_members"
          | "all_members"
          | "all_members_and_outside_collaborators";
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.github.com/orgs/${org}/codespaces/billing`);
    
      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.text();
    }
    

    Submitted by hugo697 927 days ago