export type ApplicationAssociationRequest = {id: string, op: 'add' | 'remove'}; export type CreateApiProvidersProviderIdApplicationsIdAssociationsArgs = {provider_id: string, id: string, body: ApplicationAssociationRequest}; export type CreateApiProvidersProviderIdApplicationsIdAssociationsOptions = {baseUrl?: string | undefined, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Edit associations of a Provider Application * * POST /providers/{provider_id}/applications/{id}/associations */ export const createApiProvidersProviderIdApplicationsIdAssociations = async (args: CreateApiProvidersProviderIdApplicationsIdAssociationsArgs, options?: CreateApiProvidersProviderIdApplicationsIdAssociationsOptions) => { const {baseUrl = "https://console.jumpcloud.com/api/v2", fetch: fetchFn = fetch, xApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (xApiKey !== undefined) headers.set("x-api-key", xApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/providers/${encodeURIComponent(String(args.provider_id))}/applications/${encodeURIComponent(String(args.id))}/associations${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 };