export type GetApiCollectionsIdSearchArgs = {'x-apikey': string, id: string, query: string, limit?: number | undefined, cursor?: string | undefined, order?: string | undefined, attributes?: string | undefined, relationships?: string | undefined}; export type GetApiCollectionsIdSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search IoCs inside a threat * * GET /collections/{id}/search */ export const getApiCollectionsIdSearch = async (args: GetApiCollectionsIdSearchArgs, options?: GetApiCollectionsIdSearchOptions) => { const {baseUrl = "https://www.virustotal.com/api/v3", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['x-apikey'] != null) headers.set("x-apikey", String(args['x-apikey'])) if (args.query != null) query.append("query", String(args.query)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.cursor != null) query.append("cursor", String(args.cursor)) if (args.order != null) query.append("order", String(args.order)) if (args.attributes != null) query.append("attributes", String(args.attributes)) if (args.relationships != null) query.append("relationships", String(args.relationships)) const url = `${baseUrl.replace(/\/+$/, '')}/collections/${encodeURIComponent(String(args.id))}/search${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };