export type UpdateApiVendorDomainLabelsArgs = {vendor_primary_hostname: string, hostname: string, labels: Array}; export type UpdateApiVendorDomainLabelsOptions = {baseUrl?: string | undefined, APIKeyInHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Assign labels to a domain * * PUT /vendor/domain/labels */ export const updateApiVendorDomainLabels = async (args: UpdateApiVendorDomainLabelsArgs, options?: UpdateApiVendorDomainLabelsOptions) => { 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)) if (args.hostname != null) query.append("hostname", String(args.hostname)) for (const item of args.labels ?? []) query.append("labels", String(item)) if (APIKeyInHeader !== undefined) headers.set("Authorization", APIKeyInHeader) const url = `${baseUrl.replace(/\/+$/, '')}/vendor/domain/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 };