func (c *Client) DeleteRecord(zoneID, recordsetID, recordID string) error {
	resourceURL := path.Join("dns", c.locationID, "project", c.projectID, "zone", zoneID, "recordset", recordsetID, "record", recordID)
	req, err := c.createRequest(http.MethodDelete, resourceURL, nil)
	if err != nil {
		return err
	}
	return c.do(req, nil)
}
DeleteRecord deletes a record.
https://api.hyperone.com/v2/docs#operation/dns_project_zone_recordset_record_delete
package internal
import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"net/http"
	"net/url"
	"path"
	"time"
)
const defaultBaseURL = "https://api.hyperone.com/v2"
const defaultLocationID = "pl-waw-1"
type signer interface {
	GetJWT() (string, error)
}
type Client struct {
	HTTPClient *http.Client
	apiEndpoint string
	locationID  string
	projectID   string
	passport *Passport
	signer   signer
}
func NewClient(apiEndpoint, locationID string, passport *Passport) (*Client, error) {
	if passport == nil {
		return nil, errors.New("the passport is missing")
	}
	projectID, err := passport.ExtractProjectID()
	if err != nil {
		return nil, err
	}
	baseURL := defaultBaseURL
	if apiEndpoint != "" {
		baseURL = apiEndpoint
	}
	tokenSigner := &TokenSigner{
		PrivateKey: passport.PrivateKey,
		KeyID:      passport.CertificateID,
		Audience:   baseURL,
		Issuer:     passport.Issuer,
		Subject:    passport.SubjectID,
	}
	client := &Client{
		HTTPClient:  &http.Client{Timeout: 5 * time.Second},
		apiEndpoint: baseURL,
		locationID:  locationID,
		passport:    passport,
		projectID:   projectID,
		signer:      tokenSigner,
	}
	if client.locationID == "" {
		client.locationID = defaultLocationID
	}
	return client, nil
}
func (c *Client) FindRecordset(zoneID, recordType, name string) (*Recordset, error) {
	resourceURL := path.Join("dns", c.locationID, "project", c.projectID, "zone", zoneID, "recordset")
	req, err := c.createRequest(http.MethodGet, resourceURL, nil)
	if err != nil {
		return nil, err
	}
	var recordSets []Recordset
	err = c.do(req, &recordSets)
	if err != nil {
		return nil, fmt.Errorf("failed to get recordsets from server: %w", err)
	}
	for _, v := range recordSets {
		if v.RecordType == recordType && v.Name == name {
			return &v, nil
		}
	}
	return nil, nil
}
func (c *Client) CreateRecordset(zoneID, recordType, name, recordValue string, ttl int) (*Recordset, error) {
	recordsetInput := Recordset{
		RecordType: recordType,
		Name:       name,
		TTL:        ttl,
		Record:     &Record{Content: recordValue},
	}
	requestBody, err := json.Marshal(recordsetInput)
	if err != nil {
		return nil, fmt.Errorf("failed to marshal recordset: %w", err)
	}
	resourceURL := path.Join("dns", c.locationID, "project", c.projectID, "zone", zoneID, "recordset")
	req, err := c.createRequest(http.MethodPost, resourceURL, bytes.NewBuffer(requestBody))
	if err != nil {
		return nil, err
	}
	var recordsetResponse Recordset
	err = c.do(req, &recordsetResponse)
	if err != nil {
		return nil, fmt.Errorf("failed to create recordset: %w", err)
	}
	return &recordsetResponse, nil
}
func (c *Client) DeleteRecordset(zoneID string, recordsetID string) error {
	resourceURL := path.Join("dns", c.locationID, "project", c.projectID, "zone", zoneID, "recordset", recordsetID)
	req, err := c.createRequest(http.MethodDelete, resourceURL, nil)
	if err != nil {
		return err
	}
	return c.do(req, nil)
}
func (c *Client) GetRecords(zoneID string, recordsetID string) ([]Record, error) {
	resourceURL := path.Join("dns", c.locationID, "project", c.projectID, "zone", zoneID, "recordset", recordsetID, "record")
	req, err := c.createRequest(http.MethodGet, resourceURL, nil)
	if err != nil {
		return nil, err
	}
	var records []Record
	err = c.do(req, &records)
	if err != nil {
		return nil, fmt.Errorf("failed to get records from server: %w", err)
	}
	return records, err
}
func (c *Client) CreateRecord(zoneID, recordsetID, recordContent string) (*Record, error) {
	resourceURL := path.Join("dns", c.locationID, "project", c.projectID, "zone", zoneID, "recordset", recordsetID, "record")
	requestBody, err := json.Marshal(Record{Content: recordContent})
	if err != nil {
		return nil, fmt.Errorf("failed to marshal record: %w", err)
	}
	req, err := c.createRequest(http.MethodPost, resourceURL, bytes.NewBuffer(requestBody))
	if err != nil {
		return nil, err
	}
	var recordResponse Record
	err = c.do(req, &recordResponse)
	if err != nil {
		return nil, fmt.Errorf("failed to set record: %w", err)
	}
	return &recordResponse, nil
}