netmaker/cli/functions/dns.go

44 lines
1.4 KiB
Go
Raw Normal View History

2022-11-22 23:52:53 +08:00
package functions
import (
"fmt"
"net/http"
"github.com/gravitl/netmaker/models"
)
2022-11-28 20:36:46 +08:00
// GetDNS - fetch all DNS entries
2022-11-22 23:52:53 +08:00
func GetDNS() *[]models.DNSEntry {
return request[[]models.DNSEntry](http.MethodGet, "/api/dns", nil)
}
2022-11-28 20:36:46 +08:00
// GetNodeDNS - fetch all Node DNS entires
2022-11-22 23:52:53 +08:00
func GetNodeDNS(networkName string) *[]models.DNSEntry {
return request[[]models.DNSEntry](http.MethodGet, fmt.Sprintf("/api/dns/adm/%s/nodes", networkName), nil)
}
2022-11-28 20:36:46 +08:00
// GetCustomDNS - fetch user defined DNS entriees
2022-11-22 23:52:53 +08:00
func GetCustomDNS(networkName string) *[]models.DNSEntry {
return request[[]models.DNSEntry](http.MethodGet, fmt.Sprintf("/api/dns/adm/%s/custom", networkName), nil)
}
2022-11-28 20:36:46 +08:00
// GetNetworkDNS - fetch DNS entries associated with a network
2022-11-22 23:52:53 +08:00
func GetNetworkDNS(networkName string) *[]models.DNSEntry {
return request[[]models.DNSEntry](http.MethodGet, "/api/dns/adm/"+networkName, nil)
}
2022-11-28 20:36:46 +08:00
// CreateDNS - create a DNS entry
2022-11-22 23:52:53 +08:00
func CreateDNS(networkName string, payload *models.DNSEntry) *models.DNSEntry {
return request[models.DNSEntry](http.MethodPost, "/api/dns/"+networkName, payload)
}
2022-11-23 01:38:18 +08:00
2022-11-28 20:36:46 +08:00
// PushDNS - push a DNS entry to CoreDNS
2022-11-23 01:38:18 +08:00
func PushDNS() *string {
return request[string](http.MethodPost, "/api/dns/adm/pushdns", nil)
}
2022-11-28 20:36:46 +08:00
// DeleteDNS - delete a DNS entry
2022-11-23 01:38:18 +08:00
func DeleteDNS(networkName, domainName string) *string {
return request[string](http.MethodDelete, fmt.Sprintf("/api/dns/%s/%s", networkName, domainName), nil)
}