package privatetypesrdata

// Code generated by "go run types_generate.go"; DO NOT EDIT.

import (
	"fmt"
	"strings"

	dnsv2 "codeberg.org/miekg/dns"
	"github.com/DNSControl/dnscontrol/v5/pkg/mustbe"
	"github.com/DNSControl/dnscontrol/v5/pkg/nrc"
	"github.com/DNSControl/dnscontrol/v5/pkg/txtutil"
)

type CLOUDFLAREAPISINGLEREDIRECT struct {
	SRName              string
	Code                uint16
	SRWhen              string
	SRThen              string
	RT_SRRRulesetID     string
	RT_SRRRulesetRuleID string
}

func (rd CLOUDFLAREAPISINGLEREDIRECT) Len() int {
	return len(rd.String())
}

func (rd CLOUDFLAREAPISINGLEREDIRECT) String() string {
	parts := make([]string, 0, 4)
	parts = append(parts, txtutil.ZoneifyString(rd.SRName))
	parts = append(parts, fmt.Sprintf("%d", rd.Code))
	parts = append(parts, txtutil.ZoneifyString(rd.SRWhen))
	parts = append(parts, txtutil.ZoneifyString(rd.SRThen))
	return strings.Join(parts, " ")
}

func MakeCLOUDFLAREAPISINGLEREDIRECT(origin string, _ map[string]string, _ nrc.Flags, args ...any) (dnsv2.RDATA, error) {
	mustbe.ValidArgs(args)
	if len(args) != 4 {
		return nil, fmt.Errorf("CLOUDFLAREAPI_SINGLE_REDIRECT expects 4 arguments, got %d: %+v", len(args), args)
	}
	return CLOUDFLAREAPISINGLEREDIRECT{
		SRName: mustbe.RawString(args[0]),
		Code:   mustbe.Uint16(args[1]),
		SRWhen: mustbe.RawString(args[2]),
		SRThen: mustbe.RawString(args[3]),
	}, nil
}

// Code generated by "go run types_generate.go"; DO NOT EDIT.
