Edits history of script submission #2179 for ' Removes users from Codespaces billing for an organization (github)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Github = {
      token: string;
    };
    /**
     * Removes users from Codespaces billing for an organization
     * Codespaces for the specified users will no longer be billed to the organization.
    To use this endpoint, the billing settings for the organization must be set to `selected_members`. For information on how to change this setting please see [these docs].(https://docs.github.com/rest/codespaces/organizations#manage-access-control-for-organization-codespaces) 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[]; [k: string]: unknown }
    ) {
      const url = new URL(
        `https://api.github.com/orgs/${org}/codespaces/billing/selected_users`
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        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;
    };
    /**
     * Removes users from Codespaces billing for an organization
     * Codespaces for the specified users will no longer be billed to the organization.
    To use this endpoint, the billing settings for the organization must be set to `selected_members`. For information on how to change this setting please see [these docs].(https://docs.github.com/rest/codespaces/organizations#manage-access-control-for-organization-codespaces) 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[]; [k: string]: unknown }
    ) {
      const url = new URL(
        `https://api.github.com/orgs/${org}/codespaces/billing/selected_users`
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        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