export type CreateApiFileGroupConfigArgs = {'X-Auth-Token': string, 'X-Transaction-ID'?: string | undefined, scope?: 'local' | undefined, body: string}; export type CreateApiFileGroupConfigOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * import group policy * * POST /file/group/config */ export const createApiFileGroupConfig = async (args: CreateApiFileGroupConfigArgs, options: CreateApiFileGroupConfigOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Auth-Token'] != null) headers.set("X-Auth-Token", String(args['X-Auth-Token'])) if (args['X-Transaction-ID'] != null) headers.set("X-Transaction-ID", String(args['X-Transaction-ID'])) if (args.scope != null) query.append("scope", String(args.scope)) const url = `${baseUrl.replace(/\/+$/, '')}/file/group/config${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 };