export type Interceptor = {name: string, pluginClass: string, priority: number, config: unknown}; export type CreateApiPublicV1ClustersClusterNameInterceptorsArgs = {clusterName: string, body: Interceptor}; export type CreateApiPublicV1ClustersClusterNameInterceptorsOptions = {baseUrl: string, httpAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create an Interceptor * * POST /public/v1/clusters/{clusterName}/interceptors */ export const createApiPublicV1ClustersClusterNameInterceptors = async (args: CreateApiPublicV1ClustersClusterNameInterceptorsArgs, options: CreateApiPublicV1ClustersClusterNameInterceptorsOptions) => { const {baseUrl, fetch: fetchFn = fetch, httpAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (httpAuth !== undefined) headers.set('authorization', `Bearer ${httpAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/public/v1/clusters/${encodeURIComponent(String(args.clusterName))}/interceptors${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 };