export type RESTVulnerabilityProfileEntry = {id: number, name: string, comment: string, days: number, domains: Array, images: Array}; export type RESTVulnerabilityProfileEntryConfigData = {config: RESTVulnerabilityProfileEntry}; export type CreateApiVulnerabilityProfileNameEntryArgs = {'X-Auth-Token': string, name: string, body: RESTVulnerabilityProfileEntryConfigData}; export type CreateApiVulnerabilityProfileNameEntryOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Create the vulnerability profile entry * * POST /vulnerability/profile/{name}/entry */ export const createApiVulnerabilityProfileNameEntry = async (args: CreateApiVulnerabilityProfileNameEntryArgs, options: CreateApiVulnerabilityProfileNameEntryOptions) => { 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'])) const url = `${baseUrl.replace(/\/+$/, '')}/vulnerability/profile/${encodeURIComponent(String(args.name))}/entry${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 };