export type UpdateApiBulkHostnamesHostnameLabelsArgs = {hostname: string, body: Array}; export type UpdateApiBulkHostnamesHostnameLabelsOptions = {baseUrl?: string | undefined, APIKeyInHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Assign new labels to a hostname * * PUT /bulk/hostnames/{hostname}/labels */ export const updateApiBulkHostnamesHostnameLabels = async (args: UpdateApiBulkHostnamesHostnameLabelsArgs, options?: UpdateApiBulkHostnamesHostnameLabelsOptions) => { 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(/\/+$/, '')}/bulk/hostnames/${encodeURIComponent(String(args.hostname))}/labels${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };