Skip to content

Commit

Permalink
nameserver/List: fix parameters
Browse files Browse the repository at this point in the history
* Introduce NameserverListRequest struct, mapping to 2.15.10.nameserver.list.
* Convert nameserver/List to use this NameserverListRequest instead.
  • Loading branch information
costasd committed Oct 12, 2023
1 parent f12862f commit 1d81a02
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions nameserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ func (s *NameserverService) Info(request *NameserverInfoRequest) (*NameserverInf
}

// List lists nameservers for a domain.
func (s *NameserverService) List(domain string) (*NameserverListResponse, error) {
requestMap := map[string]interface{}{
"domain": "*",
"wide": 2,
func (s *NameserverService) List(request *NameserverListRequest) (*NameserverListResponse, error) {
if request == nil {
return nil, errors.New("request can't be nil")
}

if domain != "" {
requestMap["domain"] = domain
}
requestMap := structs.Map(request)
requestMap["wide"] = "2"

req := s.client.NewRequest(methodNameserverList, requestMap)

Expand Down Expand Up @@ -161,7 +159,7 @@ func (s *NameserverService) DeleteRecord(recID int) error {

// FindRecordByID search a DNS record by ID.
func (s *NameserverService) FindRecordByID(recID int) (*NameserverRecord, *NameserverDomain, error) {
listResp, err := s.client.Nameservers.List("")
listResp, err := s.client.Nameservers.List(&NameserverListRequest{})
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -268,6 +266,14 @@ type NameserverRecord struct {
URLRedirectFavIcon string `mapstructure:"urlRedirectFavIcon"`
}

// NameserverListRequest API model.
type NameserverListRequest struct {
Domain string `structs:"domain,omitempty"`
Wide int `structs:"wide,omitempty"`
Page int `structs:"page,omitempty"`
PageLimit int `structs:"pagelimit,omitempty"`
}

// NameserverListResponse API model.
type NameserverListResponse struct {
Count int `mapstructure:"count"`
Expand Down

0 comments on commit 1d81a02

Please sign in to comment.