feat: implement retrieve dns records by domain or id
This commit is contained in:
@@ -27,7 +27,7 @@ The following API endpoints are the ones that will be supported, the currently i
|
|||||||
- [x] [DNS Edit Records by Domain, Subdomain and Type](https://porkbun.com/api/json/v3/documentation#DNS%20Edit%20Record%20by%20Domain,%20Subdomain%20and%20Type)
|
- [x] [DNS Edit Records by Domain, Subdomain and Type](https://porkbun.com/api/json/v3/documentation#DNS%20Edit%20Record%20by%20Domain,%20Subdomain%20and%20Type)
|
||||||
- [x] [DNS Delete Record by Domain and ID](https://porkbun.com/api/json/v3/documentation#DNS%20Delete%20Record%20by%20Domain%20and%20ID)
|
- [x] [DNS Delete Record by Domain and ID](https://porkbun.com/api/json/v3/documentation#DNS%20Delete%20Record%20by%20Domain%20and%20ID)
|
||||||
- [x] [DNS Delete Records by Domain, Subdomain and Type](https://porkbun.com/api/json/v3/documentation#DNS%20Delete%20Records%20by%20Domain,%20Subdomain%20and%20Type)
|
- [x] [DNS Delete Records by Domain, Subdomain and Type](https://porkbun.com/api/json/v3/documentation#DNS%20Delete%20Records%20by%20Domain,%20Subdomain%20and%20Type)
|
||||||
- [ ] [DNS Retrieve Records by Domain or ID](https://porkbun.com/api/json/v3/documentation#DNS%20Retrieve%20Records%20by%20Domain%20or%20ID)
|
- [x] [DNS Retrieve Records by Domain or ID](https://porkbun.com/api/json/v3/documentation#DNS%20Retrieve%20Records%20by%20Domain%20or%20ID)
|
||||||
- [ ] [DNS Retrieve Records by Domain, Subdomain and Type](https://porkbun.com/api/json/v3/documentation#DNS%20Retrieve%20Records%20by%20Domain,%20Subdomain%20and%20Type)
|
- [ ] [DNS Retrieve Records by Domain, Subdomain and Type](https://porkbun.com/api/json/v3/documentation#DNS%20Retrieve%20Records%20by%20Domain,%20Subdomain%20and%20Type)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
@@ -311,6 +311,11 @@ function handle_dns {
|
|||||||
|
|
||||||
handle_dns_delete $@
|
handle_dns_delete $@
|
||||||
;;
|
;;
|
||||||
|
$HANDLE_DNS_LIST)
|
||||||
|
shift
|
||||||
|
|
||||||
|
handle_dns_list $@
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
handle_dns_help
|
handle_dns_help
|
||||||
|
|
||||||
@@ -327,6 +332,7 @@ function handle_dns_help {
|
|||||||
echo " $DNS_CREATE_RECORD Create a DNS record"
|
echo " $DNS_CREATE_RECORD Create a DNS record"
|
||||||
echo " $HANDLE_DNS_EDIT Edit DNS record(s)"
|
echo " $HANDLE_DNS_EDIT Edit DNS record(s)"
|
||||||
echo " $HANDLE_DNS_DELETE Delete a DNS record"
|
echo " $HANDLE_DNS_DELETE Delete a DNS record"
|
||||||
|
echo " $HANDLE_DNS_LIST List DNS record(s)"
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE_DNS_EDIT="edit"
|
HANDLE_DNS_EDIT="edit"
|
||||||
@@ -805,6 +811,78 @@ function dns_delete_records_help {
|
|||||||
echo " $PARAM_CONTENT_SHORT, $PARAM_CONTENT"
|
echo " $PARAM_CONTENT_SHORT, $PARAM_CONTENT"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HANDLE_DNS_LIST="list"
|
||||||
|
|
||||||
|
function handle_dns_list {
|
||||||
|
case $1 in
|
||||||
|
$PARAM_HELP_SHORT|$PARAM_HELP)
|
||||||
|
handle_dns_list_help
|
||||||
|
;;
|
||||||
|
$DNS_LIST_RECORD)
|
||||||
|
shift
|
||||||
|
|
||||||
|
handle_show_help_on_error dns_list_record $@
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
handle_dns_list_help
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_dns_list_help {
|
||||||
|
echo "Usage: $0 $HANDLE_DNS $HANDLE_DNS_LIST <command>"
|
||||||
|
echo
|
||||||
|
echo "Commands:"
|
||||||
|
echo " $DNS_LIST_RECORD List a DNS record by Domain and ID"
|
||||||
|
}
|
||||||
|
|
||||||
|
DNS_LIST_RECORD="record"
|
||||||
|
|
||||||
|
function dns_list_record {
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
$PARAM_DOMAIN_SHORT|$PARAM_DOMAIN)
|
||||||
|
DOMAIN="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
$PARAM_ID_SHORT|$PARAM_ID)
|
||||||
|
ID="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*|--*)
|
||||||
|
echo "Unknown option $1"
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $DOMAIN ]]; then
|
||||||
|
echo "Missing domain parameter"
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
URL="$BASE_URL/dns/retrieve/$DOMAIN"
|
||||||
|
|
||||||
|
PAYLOAD=""
|
||||||
|
|
||||||
|
if [[ ! -z $ID ]]; then
|
||||||
|
URL="$URL/$ID"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $(request "$URL" "$PAYLOAD")
|
||||||
|
}
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
Reference in New Issue
Block a user