export type DeleteApiApiV1ContextIdKeysKeyNameArgs = {context_id: string, key_name: string}; export type DeleteApiApiV1ContextIdKeysKeyNameOptions = {baseUrl: string, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete the caller's own key by name (or, for a context administrator holding `grant:manage` over `/`, any key). A key that is not the caller's own and that it may not manage surfaces as 404 (no cross-key leakage). Gated by `allow_self_service_keys`; rejects legacy / delegated callers. * * DELETE /api/v1/{context_id}/keys/{key_name} */ export const deleteApiApiV1ContextIdKeysKeyName = async (args: DeleteApiApiV1ContextIdKeysKeyNameArgs, options: DeleteApiApiV1ContextIdKeysKeyNameOptions) => { const {baseUrl, fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/${encodeURIComponent(String(args.context_id))}/keys/${encodeURIComponent(String(args.key_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 };