#!/bin/bash

API_KEY=
URL=https://phantom1.lan:53443

#while IFS=, read -r domain ipaddr; do
#  echo -n $ipaddr
#  curl --insecure --silent --header "Authorization: Bearer $API_KEY" "$URL/api/zones/records/add?domain=$domain&type=A&ipAddress=$ipaddr&ptr=true"
#  echo
#done < ~/bin/dns_hosts.csv

while IFS=, read -r domain cname; do
  echo -n $domain
  curl --insecure --silent --header "Authorization: Bearer $API_KEY" "$URL/api/zones/records/add?domain=$domain&type=CNAME&cname=$cname"
  echo
done < ~/bin/dns_alias.csv


# "https://phantom1.lan:53443/api/zones/records/add?domain=api.phantom1.lan&type=CNAME&cname=backend.phantom1.lan&ttl=300&overwrite=true" | jq


# curl --insecure --silent --header "Authorization: Bearer $API_KEY" "$URL/api/zones/records/add?domain=$domain&type=A&ipAddress=$ipaddr&ptr=true"
echo
 # &ttl=300&overwrite=true"
