export type RestrictionType = 'BLOCK' | 'READ' | 'WRITE'; export type RestrictionItem = {userEmail: string, restrictionType: RestrictionType}; export type UpdateApiMinionsRestrictionsMinionIdArgs = {minionId: string, body: Array}; export type UpdateApiMinionsRestrictionsMinionIdOptions = {baseUrl: string, adminAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Set minion access restrictions * * PUT /minions/restrictions/{minionId} */ export const updateApiMinionsRestrictionsMinionId = async (args: UpdateApiMinionsRestrictionsMinionIdArgs, options: UpdateApiMinionsRestrictionsMinionIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, adminAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (adminAuth !== undefined) headers.set("authentication", adminAuth) const url = `${baseUrl.replace(/\/+$/, '')}/minions/restrictions/${encodeURIComponent(String(args.minionId))}${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 };