export type ValidateColumnNamesRequest = {columnNames: Array}; export type CreateApiV2StorageValidateColumnNamesArgs = {body: ValidateColumnNamesRequest}; export type CreateApiV2StorageValidateColumnNamesOptions = {baseUrl?: string | undefined, StorageKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Validate column names * * POST /v2/storage/validate/column-names * * Also accepts auth: ManageKey, BearerAuth */ export const createApiV2StorageValidateColumnNames = async (args: CreateApiV2StorageValidateColumnNamesArgs, options?: CreateApiV2StorageValidateColumnNamesOptions) => { const {baseUrl = "https://connection.keboola.com", fetch: fetchFn = fetch, StorageKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (StorageKey !== undefined) headers.set("X-StorageApi-Token", StorageKey) const url = `${baseUrl.replace(/\/+$/, '')}/v2/storage/validate/column-names${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 undefined };