Skip to content

Commit

Permalink
Implement DNSDomains Export
Browse files Browse the repository at this point in the history
Returns the zonefile data as string.
  • Loading branch information
norrland committed May 25, 2023
1 parent c57534b commit 5a55e23
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dnsdomains.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,19 @@ func (s *DNSDomainService) Edit(context context.Context, params EditDNSDomainPar
return &data.Response.Domain, err
}

// Export - return the zonefile for the domain
func (s *DNSDomainService) Export(context context.Context, domainname string) (string, error) {
data := struct {
Response struct {
Zonefile string
}
}{}
err := s.client.post(context, "domain/export", &data, struct {
Name string `json:"domainname"`
}{domainname})
return data.Response.Zonefile, err
}

// List - return a list of all domains in your account
func (s *DNSDomainService) List(context context.Context) (*[]DNSDomain, error) {
data := struct {
Expand Down
10 changes: 10 additions & 0 deletions dnsdomains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,13 @@ func TestDnsDomainsGenerateAuthCode(t *testing.T) {
assert.Equal(t, "domain/generateauthcode", c.lastPath, "path used is correct")
assert.Equal(t, "abcxy123-=%", authcode, "correct return data")
}

func TestDnsDomainsExport(t *testing.T) {
c := &mockClient{}
d := DNSDomainService{client: c}

d.Export(context.Background(), "example.com")

assert.Equal(t, "POST", c.lastMethod, "method is used correct")
assert.Equal(t, "domain/export", c.lastPath, "path used is correct")
}

0 comments on commit 5a55e23

Please sign in to comment.