export type GetApiOrganizationsOrganizationIdUsageExportArgs = {organization_id: string, projects: Array, resources: Array, resource_types: Array, regions: Array, start_date: string, end_date: string}; export type GetApiOrganizationsOrganizationIdUsageExportOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get resource-level usage for products in Crusoe Cloud. * * GET /organizations/{organization_id}/usage/export */ export const getApiOrganizationsOrganizationIdUsageExport = async (args: GetApiOrganizationsOrganizationIdUsageExportArgs, options?: GetApiOrganizationsOrganizationIdUsageExportOptions) => { const {baseUrl = "https://api.cloud.crusoe.ai/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() for (const item of args.projects ?? []) query.append("projects", String(item)) for (const item of args.resources ?? []) query.append("resources", String(item)) for (const item of args.resource_types ?? []) query.append("resource_types", String(item)) for (const item of args.regions ?? []) query.append("regions", String(item)) if (args.start_date != null) query.append("start_date", String(args.start_date)) if (args.end_date != null) query.append("end_date", String(args.end_date)) const url = `${baseUrl.replace(/\/+$/, '')}/organizations/${encodeURIComponent(String(args.organization_id))}/usage/export${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };