Edits history of script submission #10654 for ' Get a usage export (circleci)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Circleci = {
      token: string;
    };
    /**
     * Get a usage export
     * Gets a usage export for an organization.
     */
    export async function main(
      auth: Circleci,
      org_id: string,
      usage_export_job_id: string,
    ) {
      const url = new URL(
        `https://circleci.com/api/v2/organizations/${org_id}/usage_export_job/${usage_export_job_id}`,
      );
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
    			'Circle-Token': auth.token
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 536 days ago