export type LinkFixture = {id: number, key: string}; export type LinkDataRequest = {orgs?: Array | undefined, orgUsers?: Array | undefined, projects?: Array | undefined, projectTokens?: Array | undefined}; export type UpdateApiApiV1FixturesBindingsArgs = {body: LinkDataRequest}; export type UpdateApiApiV1FixturesBindingsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Bind existing resources to fixture keys * * PUT /api/v1/fixtures/bindings * * Also accepts auth: authTokenQuery */ export const updateApiApiV1FixturesBindings = async (args: UpdateApiApiV1FixturesBindingsArgs, options?: UpdateApiApiV1FixturesBindingsOptions) => { const {baseUrl = "https://api.uptrace.dev", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/fixtures/bindings${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };