@@ -69,7 +69,21 @@ func (s *DomainsService) Create(ctx context.Context, domainName string) (*Domain
6969// GetAll listing domains.
7070// https://desec.readthedocs.io/en/latest/dns/domains.html#listing-domains
7171func (s * DomainsService ) GetAll (ctx context.Context ) ([]Domain , error ) {
72- return s .getAll (ctx , nil )
72+ domains , _ , err := s .GetAllPaginated (ctx , "" )
73+ if err != nil {
74+ return nil , err
75+ }
76+
77+ return domains , nil
78+ }
79+
80+ // GetAllPaginated listing domains.
81+ // https://desec.readthedocs.io/en/latest/dns/domains.html#listing-domains
82+ func (s * DomainsService ) GetAllPaginated (ctx context.Context , cursor string ) ([]Domain , * Cursors , error ) {
83+ queryValues := url.Values {}
84+ queryValues .Set ("cursor" , cursor )
85+
86+ return s .getAll (ctx , queryValues )
7387}
7488
7589// GetResponsible returns the responsible domain for a given DNS query name.
@@ -78,7 +92,7 @@ func (s *DomainsService) GetResponsible(ctx context.Context, domainName string)
7892 queryValues := url.Values {}
7993 queryValues .Set ("owns_qname" , domainName )
8094
81- domains , err := s .getAll (ctx , queryValues )
95+ domains , _ , err := s .getAll (ctx , queryValues )
8296 if err != nil {
8397 return nil , err
8498 }
@@ -92,15 +106,15 @@ func (s *DomainsService) GetResponsible(ctx context.Context, domainName string)
92106
93107// getAll listing domains.
94108// https://desec.readthedocs.io/en/latest/dns/domains.html#listing-domains
95- func (s * DomainsService ) getAll (ctx context.Context , query url.Values ) ([]Domain , error ) {
109+ func (s * DomainsService ) getAll (ctx context.Context , query url.Values ) ([]Domain , * Cursors , error ) {
96110 endpoint , err := s .client .createEndpoint ("domains" )
97111 if err != nil {
98- return nil , fmt .Errorf ("failed to create endpoint: %w" , err )
112+ return nil , nil , fmt .Errorf ("failed to create endpoint: %w" , err )
99113 }
100114
101115 req , err := s .client .newRequest (ctx , http .MethodGet , endpoint , nil )
102116 if err != nil {
103- return nil , err
117+ return nil , nil , err
104118 }
105119
106120 if len (query ) > 0 {
@@ -109,22 +123,27 @@ func (s *DomainsService) getAll(ctx context.Context, query url.Values) ([]Domain
109123
110124 resp , err := s .client .httpClient .Do (req )
111125 if err != nil {
112- return nil , fmt .Errorf ("failed to call API: %w" , err )
126+ return nil , nil , fmt .Errorf ("failed to call API: %w" , err )
113127 }
114128
115129 defer func () { _ = resp .Body .Close () }()
116130
117131 if resp .StatusCode != http .StatusOK {
118- return nil , handleError (resp )
132+ return nil , nil , handleError (resp )
133+ }
134+
135+ cursors , err := parseCursor (resp .Header )
136+ if err != nil {
137+ return nil , nil , err
119138 }
120139
121140 var domains []Domain
122141 err = handleResponse (resp , & domains )
123142 if err != nil {
124- return nil , err
143+ return nil , nil , err
125144 }
126145
127- return domains , nil
146+ return domains , cursors , nil
128147}
129148
130149// Get retrieving a specific domain.
0 commit comments