func (c *Client) GetDomainByName(name string) (*DNSDomain, error) {
	name = dns01.UnFqdn(name)
	for {
		i := strings.Index(name, ".")
		if i == -1 {
			break
		}
		domain, err := c.getDomainByName(name)
		if err != nil {
			return nil, err
		}
		if domain != nil {
			return domain, nil
		}
		log.Infof("domain %q not found, trying with %q", name, name[i+1:])
		name = name[i+1:]
	}
	return nil, fmt.Errorf("domain not found %s", name)
}
GetDomainByName gets a Domain object from its name.
package internal
import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"net/url"
	"path"
	"strings"
	"time"
	"github.com/go-acme/lego/v4/challenge/dns01"
	"github.com/go-acme/lego/v4/log"
)
type Client struct {
	apiEndpoint string
	apiToken    string
	HTTPClient  *http.Client
}
func New(apiEndpoint, apiToken string) *Client {
	return &Client{
		apiEndpoint: apiEndpoint,
		apiToken:    apiToken,
		HTTPClient:  &http.Client{Timeout: 5 * time.Second},
	}
}
func (c *Client) CreateDNSRecord(domain *DNSDomain, record Record) (string, error) {
	rawJSON, err := json.Marshal(record)
	if err != nil {
		return "", err
	}
	uri := fmt.Sprintf("/1/domain/%d/dns/record", domain.ID)
	req, err := c.newRequest(http.MethodPost, uri, bytes.NewBuffer(rawJSON))
	if err != nil {
		return "", err
	}
	resp, err := c.do(req)
	if err != nil {
		return "", err
	}
	var recordID string
	if err = json.Unmarshal(resp.Data, &recordID); err != nil {
		return "", fmt.Errorf("expected record, got: %s", string(resp.Data))
	}
	return recordID, err
}
func (c *Client) DeleteDNSRecord(domainID uint64, recordID string) error {
	uri := fmt.Sprintf("/1/domain/%d/dns/record/%s", domainID, recordID)
	req, err := c.newRequest(http.MethodDelete, uri, nil)
	if err != nil {
		return err
	}
	_, err = c.do(req)
	return err
}