list domains

This commit is contained in:
juancwu 2026-01-23 14:56:16 +00:00
commit 8498f6f0a7
4 changed files with 146 additions and 10 deletions

View file

@ -26,6 +26,28 @@ func New(apiKey, secretKey string) *Client {
}
}
// Get all domain names in account. Domains are returned in chunks of 1000.
func (c *Client) DomainListAll(start int, includeLabels bool) (*DomainListAllResponse, error) {
reqBody := DomainListAllRequest{
BaseRequest: BaseRequest{
APIKey: c.APIKey,
SecretAPIKey: c.SecretAPIKey,
},
Start: start,
IncludeLabels: "no",
}
if includeLabels {
reqBody.IncludeLabels = "yes"
}
var resp DomainListAllResponse
err := c.post("/domain/listAll", reqBody, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
func (c *Client) Ping() (*PingResponse, error) {
reqBody := PingRequest{
BaseRequest: BaseRequest{
@ -43,7 +65,7 @@ func (c *Client) Ping() (*PingResponse, error) {
return &resp, nil
}
func (c *Client) post(endpoint string, body interface{}, target interface{}) error {
func (c *Client) post(endpoint string, body any, target any) error {
jsonBody, err := json.Marshal(body)
if err != nil {
return fmt.Errorf("failed to marshal request body: %w", err)