Merge pull request #1 from carlallen/main

Fix GetDNSRecord
This commit is contained in:
Nick Atkins
2025-03-02 20:37:49 -06:00
committed by GitHub

View File

@@ -63,19 +63,22 @@ func (c *Client) ListDNSRecord(ctx context.Context, site string) ([]DNSRecord, e
} }
func (c *Client) GetDNSRecord(ctx context.Context, site, id string) (*DNSRecord, error) { func (c *Client) GetDNSRecord(ctx context.Context, site, id string) (*DNSRecord, error) {
var respBody DNSRecord respBody, err := c.ListDNSRecord(ctx, site)
err := c.do(ctx, "GET", fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiV2Path, site, id), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
// if len(respBody.Data) != 1 { if len(respBody) == 0 {
// return nil, &NotFoundError{} return nil, &NotFoundError{}
// } }
// d := respBody.Data[0] for _, dns := range respBody {
return &respBody, nil if dns.ID == id {
return &dns, nil
}
}
return nil, &NotFoundError{}
} }
func (c *Client) DeleteDNSRecord(ctx context.Context, site, id string) error { func (c *Client) DeleteDNSRecord(ctx context.Context, site, id string) error {