import {z} from 'zod' export type PatchApiV1ExplorerDashboardsIdArgs = {id: string, 'Idempotency-Key': string, body: {name?: string | undefined, scope?: ('private' | 'shared' | 'global') | undefined, category?: string | undefined, widgets?: (Array<{id: string, explorerReportId: string, name: string, position: number, config?: ({dateRange?: {start: string, end: string} | undefined, dateRangeMode?: ('rolling' | 'fixed') | undefined, datePreset?: ('7D' | '14D' | '30D' | '60D' | '90D' | '1M' | '3M' | '6M' | '1Y' | '3Y' | 'MTD' | 'YTD' | '1Y+MTD' | '+0M' | '+1M' | '+3M' | '+6M' | '+1Y' | '+3Y' | '+4Y') | undefined, groupBy?: string | undefined, costType?: ('line_item_unblended_cost' | 'line_item_amortized_cost' | 'line_item_blended_cost' | 'pricing_public_on_demand_cost' | 'nops_line_item_net_unblended_cost' | 'nops_line_item_net_amortized_cost' | 'nops_pricing_net_public_on_demand_cost') | undefined, granularity?: ('hour' | 'day' | 'week' | 'month' | 'quarter') | undefined, filters?: (Array<{dimension: string, mode: 'include' | 'exclude', values: Array, valueModes?: ({[key: string]: 'include' | 'exclude'}) | undefined, texts?: (Array<{mode: 'include' | 'exclude', text: string}>) | undefined, textCombinator?: ('and' | 'or') | undefined, keyCombinator?: ('and' | 'or') | undefined, tagKeyOnly?: boolean | undefined, includePreAttributionHistory?: true | undefined}>) | undefined, tagKeyCombinators?: ({[key: string]: 'and' | 'or'}) | undefined, topN?: (number | null) | undefined, usageChart?: ('Hide' | 'Usage' | 'Normalized Usage') | undefined, widgetChartView?: ('all' | 'spend' | 'usage') | undefined, widgetTargetChartView?: ('all' | 'spend' | 'target') | undefined, widgetBusinessUnitChartView?: ('all' | 'spend' | 'unit') | undefined, page?: number | undefined, pageSize?: (number | null) | undefined, sortColumn?: ('name' | 'total' | 'lastPeriod' | 'periodChange' | string) | undefined, sortDir?: ('asc' | 'desc') | undefined, nameSearch?: string | undefined, budgetOverlay?: ({budgetId: string, enabled: boolean} | null) | undefined, bueOverlay?: ({economicsId: number, enabled: boolean} | null) | undefined, showbackOverlay?: ({showbackId: number, enabled: boolean, dimension?: (string | null) | undefined, grouping?: ('allocation' | 'dimension') | undefined, valueFilter?: ({mode: 'include' | 'exclude', values: Array, valueModes?: ({[key: string]: 'include' | 'exclude'}) | undefined} | null) | undefined, dataSource?: ('live' | 'processed' | 'force_processed') | undefined, drilldownGroupBy?: (string | null) | undefined} | null) | undefined, heatmap?: ({enabled: boolean, xAxis: string, yAxis: string} | null) | undefined, forecastHorizon?: number | undefined, bypassCache?: boolean | undefined, flexTable?: ({customColumns: Array<{id: string, dimension: string, label: string, tagKey?: string | undefined}>} | null) | undefined}) | undefined, showback?: (number | null) | undefined}>) | undefined, dashboardConfig?: ({showback: number | null, showbackValues: Array | null, filters?: (Array<{dimension: string, mode: 'include' | 'exclude', values: Array, valueModes?: ({[key: string]: 'include' | 'exclude'}) | undefined, texts?: (Array<{mode: 'include' | 'exclude', text: string}>) | undefined, textCombinator?: ('and' | 'or') | undefined, keyCombinator?: ('and' | 'or') | undefined, tagKeyOnly?: boolean | undefined, includePreAttributionHistory?: true | undefined}>) | undefined, dateRange?: {start: string, end: string} | undefined, datePreset?: ('7D' | '14D' | '30D' | '60D' | '90D' | '1M' | '3M' | '6M' | '1Y' | '3Y' | 'MTD' | 'YTD' | '1Y+MTD' | '+0M' | '+1M' | '+3M' | '+6M' | '+1Y' | '+3Y' | '+4Y') | undefined, granularity?: ('hour' | 'day' | 'week' | 'month' | 'quarter') | undefined, costType?: ('line_item_unblended_cost' | 'line_item_amortized_cost' | 'line_item_blended_cost' | 'pricing_public_on_demand_cost' | 'nops_line_item_net_unblended_cost' | 'nops_line_item_net_amortized_cost' | 'nops_pricing_net_public_on_demand_cost') | undefined, layoutMode?: ('grid' | 'sections') | undefined, sections?: (Array<{kind: 'budget', id: string, title?: string | undefined, budgetId: string, position: number} | {kind?: 'report' | undefined, id: string, title?: string | undefined, explorerReportId: string, config?: ({dateRange?: {start: string, end: string} | undefined, dateRangeMode?: ('rolling' | 'fixed') | undefined, datePreset?: ('7D' | '14D' | '30D' | '60D' | '90D' | '1M' | '3M' | '6M' | '1Y' | '3Y' | 'MTD' | 'YTD' | '1Y+MTD' | '+0M' | '+1M' | '+3M' | '+6M' | '+1Y' | '+3Y' | '+4Y') | undefined, groupBy?: string | undefined, costType?: ('line_item_unblended_cost' | 'line_item_amortized_cost' | 'line_item_blended_cost' | 'pricing_public_on_demand_cost' | 'nops_line_item_net_unblended_cost' | 'nops_line_item_net_amortized_cost' | 'nops_pricing_net_public_on_demand_cost') | undefined, granularity?: ('hour' | 'day' | 'week' | 'month' | 'quarter') | undefined, filters?: (Array<{dimension: string, mode: 'include' | 'exclude', values: Array, valueModes?: ({[key: string]: 'include' | 'exclude'}) | undefined, texts?: (Array<{mode: 'include' | 'exclude', text: string}>) | undefined, textCombinator?: ('and' | 'or') | undefined, keyCombinator?: ('and' | 'or') | undefined, tagKeyOnly?: boolean | undefined, includePreAttributionHistory?: true | undefined}>) | undefined, tagKeyCombinators?: ({[key: string]: 'and' | 'or'}) | undefined, topN?: (number | null) | undefined, usageChart?: ('Hide' | 'Usage' | 'Normalized Usage') | undefined, widgetChartView?: ('all' | 'spend' | 'usage') | undefined, widgetTargetChartView?: ('all' | 'spend' | 'target') | undefined, widgetBusinessUnitChartView?: ('all' | 'spend' | 'unit') | undefined, page?: number | undefined, pageSize?: (number | null) | undefined, sortColumn?: ('name' | 'total' | 'lastPeriod' | 'periodChange' | string) | undefined, sortDir?: ('asc' | 'desc') | undefined, nameSearch?: string | undefined, budgetOverlay?: ({budgetId: string, enabled: boolean} | null) | undefined, bueOverlay?: ({economicsId: number, enabled: boolean} | null) | undefined, showbackOverlay?: ({showbackId: number, enabled: boolean, dimension?: (string | null) | undefined, grouping?: ('allocation' | 'dimension') | undefined, valueFilter?: ({mode: 'include' | 'exclude', values: Array, valueModes?: ({[key: string]: 'include' | 'exclude'}) | undefined} | null) | undefined, dataSource?: ('live' | 'processed' | 'force_processed') | undefined, drilldownGroupBy?: (string | null) | undefined} | null) | undefined, heatmap?: ({enabled: boolean, xAxis: string, yAxis: string} | null) | undefined, forecastHorizon?: number | undefined, bypassCache?: boolean | undefined, flexTable?: ({customColumns: Array<{id: string, dimension: string, label: string, tagKey?: string | undefined}>} | null) | undefined}) | undefined, panels: Array<'metricTiles' | 'pie' | 'history' | 'table'>, position: number, suppressUsageBand?: boolean | undefined}>) | undefined, showbackScope?: {showbackId: number, values: Array} | undefined} | null) | undefined}}; export type PatchApiV1ExplorerDashboardsIdOptions = {baseUrl?: string | undefined, bearerApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const patchApiV1ExplorerDashboardsIdResponse = z.object({data: z.record(z.string(), z.unknown())}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Update Explorer dashboard * * PATCH /v1/explorer/dashboards/{id} */ export const patchApiV1ExplorerDashboardsId = async (args: PatchApiV1ExplorerDashboardsIdArgs, options?: PatchApiV1ExplorerDashboardsIdOptions) => { const {baseUrl = "https://api.nops.io", fetch: fetchFn = fetch, bearerApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['Idempotency-Key'] != null) headers.set("Idempotency-Key", String(args['Idempotency-Key'])) if (bearerApiKey !== undefined) headers.set('authorization', `Bearer ${bearerApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/explorer/dashboards/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 validateResponse(patchApiV1ExplorerDashboardsIdResponse, await res.json()) };