dns.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package functions
  2. import (
  3. "fmt"
  4. "net/http"
  5. "github.com/gravitl/netmaker/models"
  6. )
  7. // GetDNS - fetch all DNS entries
  8. func GetDNS() *[]models.DNSEntry {
  9. return request[[]models.DNSEntry](http.MethodGet, "/api/dns", nil)
  10. }
  11. // GetNodeDNS - fetch all Node DNS entires
  12. func GetNodeDNS(networkName string) *[]models.DNSEntry {
  13. return request[[]models.DNSEntry](http.MethodGet, fmt.Sprintf("/api/dns/adm/%s/nodes", networkName), nil)
  14. }
  15. // GetCustomDNS - fetch user defined DNS entriees
  16. func GetCustomDNS(networkName string) *[]models.DNSEntry {
  17. return request[[]models.DNSEntry](http.MethodGet, fmt.Sprintf("/api/dns/adm/%s/custom", networkName), nil)
  18. }
  19. // GetNetworkDNS - fetch DNS entries associated with a network
  20. func GetNetworkDNS(networkName string) *[]models.DNSEntry {
  21. return request[[]models.DNSEntry](http.MethodGet, "/api/dns/adm/"+networkName, nil)
  22. }
  23. // CreateDNS - create a DNS entry
  24. func CreateDNS(networkName string, payload *models.DNSEntry) *models.DNSEntry {
  25. return request[models.DNSEntry](http.MethodPost, "/api/dns/"+networkName, payload)
  26. }
  27. // PushDNS - push a DNS entry to CoreDNS
  28. func PushDNS() *string {
  29. return request[string](http.MethodPost, "/api/dns/adm/pushdns", nil)
  30. }
  31. // DeleteDNS - delete a DNS entry
  32. func DeleteDNS(networkName, domainName string) *string {
  33. return request[string](http.MethodDelete, fmt.Sprintf("/api/dns/%s/%s", networkName, domainName), nil)
  34. }