export type ReorderRequest = {ruleIds: Array}; export type CreateApiV1ContextsContextIdRulesReorderArgs = {'X-Request-Id'?: string | undefined, contextId: string, 'X-Idempotency-Key'?: string | undefined, body: ReorderRequest}; export type CreateApiV1ContextsContextIdRulesReorderOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Reorder match rules * * POST /v1/contexts/{contextId}/rules/reorder */ export const createApiV1ContextsContextIdRulesReorder = async (args: CreateApiV1ContextsContextIdRulesReorderArgs, options?: CreateApiV1ContextsContextIdRulesReorderOptions) => { const {baseUrl = "https://identity.sandbox.lerian.net", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Request-Id'] != null) headers.set("X-Request-Id", String(args['X-Request-Id'])) if (args['X-Idempotency-Key'] != null) headers.set("X-Idempotency-Key", String(args['X-Idempotency-Key'])) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/contexts/${encodeURIComponent(String(args.contextId))}/rules/reorder${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 };