export type DeleteApiIndexesIndexNameArgs = {'X-Pinecone-Api-Version': string, index_name: string}; export type DeleteApiIndexesIndexNameOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete an index * * DELETE /indexes/{index_name} */ export const deleteApiIndexesIndexName = async (args: DeleteApiIndexesIndexNameArgs, options?: DeleteApiIndexesIndexNameOptions) => { const {baseUrl = "https://api.pinecone.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['X-Pinecone-Api-Version'] != null) headers.set("X-Pinecone-Api-Version", String(args['X-Pinecone-Api-Version'])) if (ApiKeyAuth !== undefined) headers.set("Api-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/indexes/${encodeURIComponent(String(args.index_name))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };