list domains
This commit is contained in:
parent
2f18893ef2
commit
8498f6f0a7
4 changed files with 146 additions and 10 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue