export type BillingFilters = {categories?: (Array<'operationalComputeAndStorage' | 'operationalBucketBackup' | 'operationalClusterBackup' | 'analyticsCompute' | 'analyticsStorage' | 'analyticsClusterBackup' | 'appServicesComputeAndStorage' | 'dataTransferStandard' | 'privateEndpointsStandard' | 'aiServicesLLM' | 'aiServicesAiGateway' | 'aiServicesUdsPager' | 'aiServicesSdsPager' | 'dataApiStandard' | 'operationalExpressScaling' | 'aiServicesMcpServer' | 'aiServicesAgentMemory'>) | undefined, projectIds?: Array | undefined, instanceIds?: Array | undefined}; export type CategorizedBillingRequest = {startDate: string, endDate: string, filters?: BillingFilters | undefined}; export type CreateApiV4OrganizationsOrganizationIdBillingDownloadArgs = {body: CategorizedBillingRequest}; export type CreateApiV4OrganizationsOrganizationIdBillingDownloadOptions = {baseUrl?: string | undefined, token?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download Categorized Billing * * POST /v4/organizations/{organizationId}/billing/download */ export const createApiV4OrganizationsOrganizationIdBillingDownload = async (args: CreateApiV4OrganizationsOrganizationIdBillingDownloadArgs, options?: CreateApiV4OrganizationsOrganizationIdBillingDownloadOptions) => { const {baseUrl = "https://cloudapi.cloud.couchbase.com", fetch: fetchFn = fetch, token} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/csv") if (token !== undefined) headers.set('authorization', `Bearer ${token}`) const url = `${baseUrl.replace(/\/+$/, '')}/v4/organizations/${encodeURIComponent(String(args.organizationId))}/billing/download${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };