export type DnsRecordTypes = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15; export type DnsMonitoringType = 0 | 1 | 2 | 3; export type DnsSmartRoutingType = 0 | 1 | 2; export type DnsRecordEnviromentalVariableModel = {Name?: (string | null) | undefined, Value?: (string | null) | undefined}; export type AddDnsRecordModel = {Type?: (DnsRecordTypes | null) | undefined, Ttl?: (number | null) | undefined, Value?: (string | null) | undefined, Name?: (string | null) | undefined, Weight?: (number | null) | undefined, Priority?: (number | null) | undefined, Flags?: (number | null) | undefined, Tag?: (string | null) | undefined, Port?: (number | null) | undefined, PullZoneId?: (number | null) | undefined, ScriptId?: (number | null) | undefined, Accelerated?: (boolean | null) | undefined, MonitorType?: (DnsMonitoringType | null) | undefined, GeolocationLatitude?: (number | null) | undefined, GeolocationLongitude?: (number | null) | undefined, LatencyZone?: (string | null) | undefined, SmartRoutingType?: (DnsSmartRoutingType | null) | undefined, Disabled?: (boolean | null) | undefined, EnviromentalVariables?: (Array | null) | undefined, Comment?: (string | null) | undefined, AutoSslIssuance?: (boolean | null) | undefined}; export type DnsZoneAddModel = {Domain: string, Records?: (Array | null) | undefined}; export type CreateApiDnszoneArgs = {body: DnsZoneAddModel}; export type CreateApiDnszoneOptions = {baseUrl?: string | undefined, AccessKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add DNS Zone * * POST /dnszone */ export const createApiDnszone = async (args: CreateApiDnszoneArgs, options?: CreateApiDnszoneOptions) => { const {baseUrl = "https://api.bunny.net", fetch: fetchFn = fetch, AccessKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (AccessKey !== undefined) headers.set("AccessKey", AccessKey) const url = `${baseUrl.replace(/\/+$/, '')}/dnszone${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 };