export type UpdateApiVendorLabelsArgs = {vendor_primary_hostname: string, labels: Array}; export type UpdateApiVendorLabelsOptions = {baseUrl?: string | undefined, APIKeyInHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Assign labels to a vendor * * PUT /vendor/labels */ export const updateApiVendorLabels = async (args: UpdateApiVendorLabelsArgs, options?: UpdateApiVendorLabelsOptions) => { const {baseUrl = "https://cyber-risk.upguard.com/api/public", fetch: fetchFn = fetch, APIKeyInHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.vendor_primary_hostname != null) query.append("vendor_primary_hostname", String(args.vendor_primary_hostname)) for (const item of args.labels ?? []) query.append("labels", String(item)) if (APIKeyInHeader !== undefined) headers.set("Authorization", APIKeyInHeader) const url = `${baseUrl.replace(/\/+$/, '')}/vendor/labels${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };