export type UsagePolicyRuleInput = {role_names?: Array | undefined, team_names?: Array | undefined, user_emails?: Array | undefined}; export type UserRiskAppUsagePolicyUpdateBody = {app_name: string, base_rule: 'approve' | 'tolerate' | 'nudge' | 'block', custom_rules?: {[key: string]: UsagePolicyRuleInput} | undefined, note?: string | undefined}; export type CreateApiUserRiskAppsUsagePolicyUpdateArgs = {body: UserRiskAppUsagePolicyUpdateBody}; export type CreateApiUserRiskAppsUsagePolicyUpdateOptions = {baseUrl?: string | undefined, APIKeyInHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update app usage policy * * POST /user_risk/apps/usage_policy/update */ export const createApiUserRiskAppsUsagePolicyUpdate = async (args: CreateApiUserRiskAppsUsagePolicyUpdateArgs, options?: CreateApiUserRiskAppsUsagePolicyUpdateOptions) => { const {baseUrl = "https://cyber-risk.upguard.com/api/public", fetch: fetchFn = fetch, APIKeyInHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (APIKeyInHeader !== undefined) headers.set("Authorization", APIKeyInHeader) const url = `${baseUrl.replace(/\/+$/, '')}/user_risk/apps/usage_policy/update${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 };