add delete and push dns subcommands

This commit is contained in:
Anish Mukherjee 2022-11-22 23:08:18 +05:30
parent f8d65e2a80
commit 2e0b4726c9
3 changed files with 50 additions and 0 deletions

20
cli/cmd/dns/delete.go Normal file
View file

@ -0,0 +1,20 @@
package dns
import (
"github.com/gravitl/netmaker/cli/functions"
"github.com/spf13/cobra"
)
var dnsDeleteCmd = &cobra.Command{
Use: "delete [NETWORK NAME] [DOMAIN NAME]",
Args: cobra.ExactArgs(2),
Short: "Delete a DNS entry",
Long: `Delete a DNS entry`,
Run: func(cmd *cobra.Command, args []string) {
functions.PrettyPrint(functions.DeleteDNS(args[0], args[1]))
},
}
func init() {
rootCmd.AddCommand(dnsDeleteCmd)
}

22
cli/cmd/dns/push.go Normal file
View file

@ -0,0 +1,22 @@
package dns
import (
"fmt"
"github.com/gravitl/netmaker/cli/functions"
"github.com/spf13/cobra"
)
var dnsPushCmd = &cobra.Command{
Use: "push",
Args: cobra.NoArgs,
Short: "Push latest DNS entries",
Long: `Push latest DNS entries`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(*functions.PushDNS())
},
}
func init() {
rootCmd.AddCommand(dnsPushCmd)
}

View file

@ -26,3 +26,11 @@ func GetNetworkDNS(networkName string) *[]models.DNSEntry {
func CreateDNS(networkName string, payload *models.DNSEntry) *models.DNSEntry {
return request[models.DNSEntry](http.MethodPost, "/api/dns/"+networkName, payload)
}
func PushDNS() *string {
return request[string](http.MethodPost, "/api/dns/adm/pushdns", nil)
}
func DeleteDNS(networkName, domainName string) *string {
return request[string](http.MethodDelete, fmt.Sprintf("/api/dns/%s/%s", networkName, domainName), nil)
}