export type CreateApiDiscoveryBindingsBindingIdScanArgs = {bindingId: string}; export type CreateApiDiscoveryBindingsBindingIdScanOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Starts asynchronous discovery process for a binding and returns the timeout in seconds of the discovery operation. * * POST /discovery/bindings/{bindingId}/scan */ export const createApiDiscoveryBindingsBindingIdScan = async (args: CreateApiDiscoveryBindingsBindingIdScanArgs, options: CreateApiDiscoveryBindingsBindingIdScanOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/discovery/bindings/${encodeURIComponent(String(args.bindingId))}/scan${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };