From 1d81a026d6d720d135802f5975cc1d98b9db2716 Mon Sep 17 00:00:00 2001 From: Costas Drogos Date: Thu, 12 Oct 2023 23:43:09 +0200 Subject: [PATCH] nameserver/List: fix parameters * Introduce NameserverListRequest struct, mapping to 2.15.10.nameserver.list. * Convert nameserver/List to use this NameserverListRequest instead. --- nameserver.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/nameserver.go b/nameserver.go index c7b764c..a96e3fb 100644 --- a/nameserver.go +++ b/nameserver.go @@ -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) @@ -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 } @@ -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"`