export type RegisterStorageClientIPRequest = {ip_address: string, rental_id?: (string | null) | undefined, storage_id?: (string | null) | undefined}; export type CreateApiStorageClientIpsArgs = {body: RegisterStorageClientIPRequest}; export type CreateApiStorageClientIpsOptions = {baseUrl: string, apiTokenAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Whitelist a client IP on a rental's VAST tenant * * POST /storage/client-ips * * Also accepts auth: APIKeyHeader */ export const createApiStorageClientIps = async (args: CreateApiStorageClientIpsArgs, options: CreateApiStorageClientIpsOptions) => { const {baseUrl, fetch: fetchFn = fetch, apiTokenAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiTokenAuth !== undefined) headers.set('authorization', `Bearer ${apiTokenAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/storage/client-ips${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 };