regfishapi

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 11 Imported by: 11 modules, 7 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

regfish DNS & TLS API Go Client

CI Go Reference Go Report Card

Go client for the regfish API v1 — domains, DNS records and zones, DNSSEC, web hosting and TLS certificates.

Install

go get github.com/regfish/regfish-dnsapi-go

Quick start

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	regfishapi "github.com/regfish/regfish-dnsapi-go"
)

func main() {
	client := regfishapi.NewClient(os.Getenv("RF_API_KEY"))
	ctx := context.Background()

	record, err := client.AddRecord(ctx, regfishapi.Record{
		Name: "www.example.com.",
		Type: regfishapi.RecordTypeA,
		Data: "10.2.3.4",
		TTL:  600,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("created rrid", record.ID)
}

The API key is created in the regfish dash under Account → Security → API keys and is sent as the x-api-key header.

Examples

Runnable programs live in examples/:

Example Shows
create-record create, read and delete a record; branching on the error code
permission-check inspecting the key and failing a deploy on an under-scoped one
zone-export zone summary and BIND export
resilient-writer a retry loop that does not hammer a permanent refusal
RF_API_KEY=... RF_TEST_DOMAIN=example.com go run ./examples/permission-check
Configuration
client := regfishapi.NewClient(apiKey,
	regfishapi.WithBaseURL("https://api.regfish.com"),
	regfishapi.WithHTTPClient(&http.Client{Timeout: 10 * time.Second}),
	regfishapi.WithUserAgent("my-app/1.0"),
)

The default endpoint is https://api.regfish.de. https://api.regfish.com serves the same API and is the endpoint listed in the OpenAPI specification.

Error handling

Every failed call returns an *APIError carrying the HTTP status as well as the regfish error code and message:

_, err := client.AddRecord(ctx, record)
switch {
case regfishapi.ErrorCode(err) == regfishapi.CodeResourceRecordAlreadyExists:
	// record with this name/type/data already exists
case regfishapi.IsRateLimited(err):
	// daily or per-minute limit reached
case err != nil:
	log.Fatal(err)
}

Use err.Reason() rather than reading Message or Detail directly — the API puts its explanation in message on some endpoints and in error on others.

Denials: why a call was refused

An HTTP status is not enough to decide what to do about a refusal. DenialOf turns the response into one value you can branch on:

switch regfishapi.DenialOf(err) {
case regfishapi.DenialPermission:
	if perm, ok := regfishapi.MissingPermission(err); ok {
		log.Fatalf("grant %s to this API key in the dash", perm)
	}
	log.Fatalf("this API key is not permitted to do that: %v", err)
case regfishapi.DenialScope:
	log.Fatal("this is a scope-bound platform credential; use a customer key")
case regfishapi.DenialUnmappedOperation:
	op, _ := regfishapi.DeniedOperation(err) // server-side gap, report it
	log.Fatalf("regfish has no permission mapping for %q", op)
case regfishapi.DenialGuardian:
	log.Print("Domain-Guardian blocked this — confirm it in the dash")
case regfishapi.DenialQuota:
	// retry after the window or the UTC day rolls over
case regfishapi.DenialUnauthenticated:
	log.Fatal("the API key was not accepted")
}

MissingPermission and DeniedOperation read the name out of the API's own message, so they are never stale — but they report false if the server ever rewords it. Always handle the not-ok branch.

The shorthands are IsPermissionDenied, IsDomainGuardianBlocked and IsPermanent.

If you retry on 5xx, check IsDomainGuardianBlocked first. The API reports a Domain-Guardian block as HTTP 403 on the domain endpoints but as HTTP 500 on the DNS record and DNSSEC endpoints, where nothing but the message text separates it from a genuine, retryable server fault. A naive retry loop will hammer a decision that cannot succeed until a human clicks a button in the dash:

for attempt := 0; attempt < 5; attempt++ {
	_, err = client.AddRecord(ctx, record)
	if err == nil || regfishapi.IsPermanent(err) {
		break
	}
	time.Sleep(time.Duration(1<<attempt) * time.Second)
}

IsPermanent is one-directional: true means no retry can clear it, false means only "not known to be permanent". Cap your retries either way.

API keys and permissions

A key is one of three kinds, and TokenInfo.Kind is the only safe way to tell them apart:

Kind permissions on the wire Meaning
KeyKindLegacy null Created before RBAC — full access
KeyKindRBAC [...], possibly [] Exactly the listed permissions; [] means none
KeyKindCapability null, plus a scope Platform credential (e.g. ACME DNS-01), limited to a fixed set of operations whatever its permissions

null and [] mean opposite things, and a capability-scoped key looks like a legacy key if you only read Permissions. Use Permits, which returns a tri-state and is scope-aware:

info, err := client.GetTokenInfo(ctx)
switch info.Permits(regfishapi.PermissionDNSWrite) {
case regfishapi.DecisionAllowed: // probably fine
case regfishapi.DecisionDenied:  // will be refused
case regfishapi.DecisionUnknown: // scope-bound key — permissions do not describe it
}

Check the key once at startup, so an under-scoped key fails the deploy instead of the first write hours later:

report, err := client.CheckPermissions(ctx,
	regfishapi.PermissionDNSRead, regfishapi.PermissionDNSWrite)
if err != nil {
	log.Fatal(err)
}
if !report.Satisfied() {
	log.Fatal(report) // "regfish API key kAbC [rbac]: missing dns:write"
}

Gate on Satisfied(), not on len(report.Missing): a capability-scoped credential has no missing permissions and still cannot do the work, so those land in report.Undetermined and a Missing-only check would wave it through.

The library never refuses a call on its own. It keeps no copy of the server's operation-to-permission table, so it can never deny something the server would have allowed, and it cannot go stale when regfish adds an endpoint. CheckPermissions and Permits are advisory diagnostics; the API remains the only authority. A clean report is not a promise either — it cannot see Domain-Guardian rules, domain ownership, plan entitlements or quotas.

To rehydrate cached token metadata, use ParseTokenInfo rather than json.Unmarshal: a payload that lost its permissions member would otherwise decode to a nil slice and read as a legacy key with full access.

Coverage

All v1 operations are implemented. Every method takes a context.Context as its first argument.

The Permission column is what to pass to CheckPermissions. It is documentation, not enforcement — the library never consults it, so it cannot cause a request to be refused. It mirrors the server's mapping as of API version 1.6.2 (2026-08-01); /meta/token and the dash are authoritative. Note that read and write do not split the way the method names suggest: DownloadCertificate needs tls:read, and every hosting method needs hosting:read.

The operationId column matters when handling denials: DeniedOperation returns the API's operationId, which differs from the Go method name in one case (ListRecordsByDomain → GetRecordsByDomain).

Meta
Method Endpoint operationId Permission
GetTokenInfo GET /meta/token GetTokenInfo — (any valid key)
CheckPermissions GET /meta/token GetTokenInfo — (any valid key)
DownloadOpenAPISpec GET /openapi.yaml DownloadOpenAPISpec — (any valid key)
Domains
Method Endpoint operationId Permission
ListDomains GET /domains ListDomains domain:read
GetDomainByName GET /domains/{domain} GetDomainByName domain:read
GetNameserversByDomain GET /domains/{domain}/nameservers GetNameserversByDomain domain:read
PutNameserversByDomain PUT /domains/{domain}/nameservers PutNameserversByDomain domain:write
RequestAuthinfoByDomain POST /domains/{domain}/authinfo RequestAuthinfoByDomain domain:write
DNS records
Method Endpoint operationId Permission
ListRecordsByDomain GET /dns/{domain}/rr GetRecordsByDomain dns:read
GetRecordByRRID GET /dns/rr/{rrid} GetRecordByRRID dns:read
AddRecord POST /dns/rr AddRecord dns:write
PatchRecord PATCH /dns/rr PatchRecord dns:write
PatchRecordByRRID PATCH /dns/rr/{rrid} PatchRecordByRRID dns:write
DeleteRecordByRRID DELETE /dns/rr/{rrid} DeleteRecordByRRID dns:write

AddRecord detects the zone from the record's fully qualified Name. PatchRecord matches an existing record by name and type — and, for every type except A and AAAA, by its current data — and requires a unique match; use PatchRecordByRRID to change a record's name or type. ListRecordsByDomain does not include NS records; GetDNSZoneByDomain does.

DNS zones
Method Endpoint operationId Permission
ListDNSZones GET /dns/zones ListDNSZones dns:read
GetDNSZoneByDomain GET /dns/zones/{domain} GetDNSZoneByDomain dns:read
ExportDNSZoneBindByDomain GET /dns/zones/{domain}/export ExportDNSZoneBindByDomain dns:read
DNSSEC
Method Endpoint operationId Permission
GetDNSSECByDomain GET /dns/{domain}/dnssec GetDNSSECByDomain dns:read
PutDNSSECByDomain PUT /dns/{domain}/dnssec PutDNSSECByDomain dns:write
CancelDNSSECByDomain POST /dns/{domain}/dnssec/cancel CancelDNSSECByDomain dns:write
VerifyDNSSECByDomain POST /dns/{domain}/dnssec/verify VerifyDNSSECByDomain dns:write
ListDNSSECJobsByDomain GET /dns/{domain}/dnssec/jobs ListDNSSECJobsByDomain dns:read
Hosting (read-only)
Method Endpoint operationId Permission
ListHostingPackages GET /hosting/packages ListHostingPackages hosting:read
GetHostingPackage GET /hosting/packages/{id} GetHostingPackage hosting:read
ListHostingAliases GET /hosting/packages/{id}/aliases ListHostingAliases hosting:read
ListHostingDatabases GET /hosting/packages/{id}/databases ListHostingDatabases hosting:read
TLS
Method Endpoint operationId Permission
ListTLSProducts GET /tls/products ListTLSProducts tls:read
ListCertificates GET /tls/certificate ListCertificates tls:read
CreateCertificate POST /tls/certificate CreateCertificate tls:write
GetCertificateByID GET /tls/certificate/{id} GetCertificateByID tls:read
CompleteCertificate POST /tls/certificate/{id}/complete CompleteCertificate tls:write
CancelCertificate POST /tls/certificate/{id}/cancel CancelCertificate tls:write
RevokeCertificate POST /tls/certificate/{id}/revoke RevokeCertificate tls:write
CancelIssuedCertificateOrder POST /tls/certificate/{id}/order-cancel CancelIssuedCertificateOrder tls:write
ReissueCertificate POST /tls/certificate/{id}/reissue ReissueCertificate tls:write
DownloadCertificate GET /tls/certificate/{id}/download/{format} DownloadCertificate tls:read
ListOrganizations GET /tls/organization ListOrganizations tls:read
CreateOrganization POST /tls/organization CreateOrganization tls:write
GetOrganizationByID GET /tls/organization/{id} GetOrganizationByID tls:read
PatchOrganizationByID PATCH /tls/organization/{id} PatchOrganizationByID tls:write

Migration from v0

The previous methods still work and delegate to the new ones, but they are deprecated because they cannot be cancelled:

Deprecated Replacement
GetRecord(rrid) GetRecordByRRID(ctx, rrid)
CreateRecord(rec) AddRecord(ctx, rec)
UpdateRecord(rec) PatchRecord(ctx, rec)
UpdateRecordById(rrid, rec) PatchRecordByRRID(ctx, rrid, rec)
DeleteRecord(rrid) DeleteRecordByRRID(ctx, rrid)
GetRecordsByDomain(domain) ListRecordsByDomain(ctx, domain)
Request(...) RequestContext(ctx, ...)

Behavioural changes to be aware of — this is not a drop-in no-op:

  • Failed requests now return *APIError with the API's error code and message instead of a bare request failed with status code N. Code that matched on the old error string will not match any more.
  • NewClient sets a 60 second timeout on its default HTTP client, where v0 had none. Calls that previously hung indefinitely now fail; pass WithHTTPClient(&http.Client{}) to restore the old behaviour.
  • Write payloads no longer carry id, and Record gained four read-only response fields (Auto, Active, TSCreated, TSUpdated), which changes what json.Marshal of a Record produces.

Testing

Unit tests run against a stub server and need no credentials:

go test ./...

The integration tests talk to the live API and create, update and delete a real DNS record on the domain you point them at:

RF_API_KEY=... RF_TEST_DOMAIN=example.com go test -tags integration -v

RF_API_BASE_URL overrides the endpoint. Subtests whose permission the key does not hold are skipped rather than failed, so a least-privilege RBAC key reports honestly instead of looking like a library regression.

Documentation

Overview

Package regfishapi is a Go client for the regfish DNS & TLS API (v1).

The API is documented at https://regfish.de/docs; the machine readable contract can be fetched with Client.DownloadOpenAPISpec.

All API calls authenticate with an API key ("x-api-key" header) that is created in the regfish dash under Account > Security > API keys.

Index

Constants

View Source
const (
	CodeSuccess = 0
	CodeFailed  = 1

	// Domains
	CodeDomainNotFound             = 18001
	CodeDomainGuardBlocked         = 18002
	CodeNameserverChangeNotAllowed = 18003
	CodeNameserverRateLimited      = 18004
	CodeAuthinfoUnavailable        = 18005
	CodeVanitySetNotFound          = 18006
	CodeAuthinfoRateLimited        = 18007

	// Hosting
	CodeHostingPackageNotFound = 19001

	// Zones
	CodeZoneNotFound = 13001

	// Schema
	CodeSchemaValidationFailed = 14001

	// Resource records
	CodeResourceRecordNotFound      = 15001
	CodeResourceRecordOutsideOfZone = 15002
	CodeResourceRecordAlreadyExists = 15003
	CodeResourceRecordNotAllowed    = 15004

	// DNSSEC
	CodeDNSSECDomainNotFound     = 17001
	CodeDNSSECUnsupported        = 17002
	CodeDNSSECInvalidMode        = 17003
	CodeDNSSECInvalidRecordSet   = 17004
	CodeDNSSECJobPending         = 17005
	CodeDNSSECRegistryError      = 17006
	CodeDNSSECVerificationFailed = 17007
	CodeDNSSECForbiddenForState  = 17008

	// TLS
	CodeTLSCertificateNotFound         = 16001
	CodeTLSCertificateInvalidState     = 16002
	CodeTLSCertificateProviderError    = 16003
	CodeTLSCertificateUnknownProduct   = 16004
	CodeTLSCertificateInvalidCSR       = 16005
	CodeTLSCertificateDownloadNotReady = 16006
	CodeTLSOrganizationNotFound        = 16007
)

regfish API error codes, mirroring server/api/errors.ts.

View Source
const (
	// DNSSECModeNone leaves no registry DNSSEC active.
	DNSSECModeNone = "none"
	// DNSSECModeRegfish lets regfish sign the zone and manage the registry
	// trust anchors. Only valid while the domain uses regfish nameservers.
	DNSSECModeRegfish = "regfish"
	// DNSSECModeExternal expects the caller to supply the DNSSEC records of
	// external authoritative nameservers.
	DNSSECModeExternal = "external"
)

DNSSEC operating modes.

View Source
const (
	DNSSECStateEnabled  = "enabled"
	DNSSECStateDisabled = "disabled"
)

Desired DNSSEC states accepted by PutDNSSECByDomain.

View Source
const (
	DNSSECStatePendingEnable  = "pending_enable"
	DNSSECStatePendingDisable = "pending_disable"
	DNSSECStateError          = "error"
	DNSSECStateDrift          = "drift"
	DNSSECStateUnknown        = "unknown"
)

Fine-grained registry DNSSEC states reported in DNSSEC.DesiredState and DNSSEC.LiveState.

View Source
const (
	DNSSECDisplayActive   = "active"
	DNSSECDisplayPending  = "pending"
	DNSSECDisplayInactive = "inactive"
)

High-level DNSSEC states reported in DNSSEC.DNSSECState.

View Source
const (
	DNSSECRecordKindDS     = "ds"
	DNSSECRecordKindDNSKEY = "dnskey"
)

DNSSEC record kinds.

View Source
const (
	NameserverModeStandard = "standard"
	NameserverModeVanity   = "vanity"
	NameserverModeExternal = "external"
)

Nameserver delegation modes returned by GetNameserversByDomain.

View Source
const (
	DomainSortByDomain            = "domain"
	DomainSortByExpiresAt         = "expires_at"
	DomainSortByCancelled         = "cancelled"
	DomainSortByPrimaryNameserver = "primary_nameserver"
	DomainSortByDNSSECState       = "dnssec_state"
	DomainSortByOwner             = "owner"
	DomainSortByRegisteredAt      = "registered_at"
)

Sort keys accepted by ListDomainsOptions.SortBy.

View Source
const (
	DomainFilterCancelled      = "cancelled"
	DomainFilterDNSSECInactive = "dnssec-inactive"
)

Filters accepted by ListDomainsOptions.Filters.

View Source
const (
	SortAsc  = "asc"
	SortDesc = "desc"
)

Sort directions.

View Source
const (
	PermissionDomainRead  = "domain:read"
	PermissionDomainWrite = "domain:write"
	PermissionDNSRead     = "dns:read"
	PermissionDNSWrite    = "dns:write"
	PermissionTLSRead     = "tls:read"
	PermissionTLSWrite    = "tls:write"
	PermissionHostingRead = "hosting:read"
)

API permissions that at least one v1 operation requires. A key created before RBAC (TokenInfo.Permissions == nil) holds all of them.

The RBAC vocabulary is larger than this — it also covers email, WordPress, SEO, hosting writes and the account/billing/team/security surfaces — but no operation in this API needs any of those, so they are deliberately not exported: asking for one in Client.CheckPermissions would fail a deployment over a permission that could never have caused a denial here.

View Source
const (
	RecordTypeA     = "A"
	RecordTypeAAAA  = "AAAA"
	RecordTypeCNAME = "CNAME"
	RecordTypeCAA   = "CAA"
	RecordTypeALIAS = "ALIAS"
	RecordTypeTXT   = "TXT"
	RecordTypeMX    = "MX"
	RecordTypeSRV   = "SRV"
	RecordTypeTLSA  = "TLSA"
)

Record type constants accepted by the API.

View Source
const (
	TLSProductRapidSSL         = "RapidSSL"
	TLSProductRapidSSLWildcard = "RapidSSLWildcard"
	TLSProductQuickSSLPremium  = "QuickSSLPremium"
	TLSProductSSL123           = "SSL123"
	TLSProductTrueBusinessID   = "TrueBusinessID"
	TLSProductSecureSite       = "SecureSite"
	TLSProductSSLWebServer     = "SSLWebServer"
)

TLS certificate product SKUs.

View Source
const (
	DCVMethodDNSCNAMEToken = "dns-cname-token"
	DCVMethodEmail         = "email"
)

Domain control validation methods.

View Source
const (
	TLSStatusPending                = "pending"
	TLSStatusIssued                 = "issued"
	TLSStatusPendingCancellation    = "pending_cancellation"
	TLSStatusPendingRevocation      = "pending_revocation"
	TLSStatusPendingOrderRevocation = "pending_order_revocation"
	TLSStatusCancelled              = "cancelled"
	TLSStatusOrderCancelled         = "order_cancelled"
	TLSStatusRevoked                = "revoked"
	TLSStatusOrderRevoked           = "order_revoked"
	TLSStatusRejected               = "rejected"
	TLSStatusExpired                = "expired"
	TLSStatusUnknown                = "unknown"
)

TLS certificate lifecycle states.

View Source
const (
	RevocationReasonUnspecified          = "unspecified"
	RevocationReasonKeyCompromise        = "keyCompromise"
	RevocationReasonAffiliationChanged   = "affiliationChanged"
	RevocationReasonSuperseded           = "superseded"
	RevocationReasonCessationOfOperation = "cessationOfOperation"
)

Revocation reasons forwarded to the CA.

View Source
const (
	TLSDownloadFormatPEM = "pem"
	TLSDownloadFormatZIP = "zip"
)

Certificate download formats.

View Source
const (
	TLSOrganizationStatusReady      = "ready"
	TLSOrganizationStatusIncomplete = "incomplete"
)

TLS organization readiness.

View Source
const (
	// TLSOrgEditModeCreateReplacement creates a replacement organization when
	// validation-relevant fields change.
	TLSOrgEditModeCreateReplacement = "create_replacement"
	// TLSOrgEditModeUpdateProvider updates the existing provider record.
	TLSOrgEditModeUpdateProvider = "update_provider"
)

Edit modes for TLSOrganizationPatchRequest.

View Source
const DefaultBaseURL = "https://api.regfish.de"

DefaultBaseURL is the API endpoint used when no other base URL is configured. https://api.regfish.com serves the same API and is the endpoint listed in the OpenAPI specification; either can be selected with WithBaseURL.

View Source
const DefaultUserAgent = "regfish-dnsapi-go"

DefaultUserAgent identifies this client to the API.

View Source
const ScopeACMEDNSChallenge = "acme-dns-challenge"

ScopeACMEDNSChallenge is the Scope of the platform credential regfish issues for ACME DNS-01 challenges. The API restricts such a key to adding, patching and deleting _acme-challenge TXT records and to GetTokenInfo, whatever permissions it carries.

Variables

View Source
var (
	// ErrTokenInfoIncomplete means the payload omitted the permissions member,
	// which cannot be told apart from an explicit null and would read as a
	// legacy key with full access.
	ErrTokenInfoIncomplete = errors.New("regfish: token info omitted the permissions field")
	// ErrTokenInfoMalformed means the payload was empty or not valid token
	// metadata.
	ErrTokenInfoMalformed = errors.New("regfish: malformed token info")
)

Errors ParseTokenInfo — and therefore GetTokenInfo — can return for a payload it will not interpret. Match them with errors.Is rather than on the message text.

Functions

func DeniedOperation added in v0.2.0

func DeniedOperation(err error) (string, bool)

DeniedOperation returns the operationId the API named when it refused a scope-bound credential or an operation it has no permission mapping for, and reports whether the denial named one.

func ErrorCode added in v0.2.0

func ErrorCode(err error) int

ErrorCode returns the regfish error code of err, or 0 if err is not an *APIError.

func IsDomainGuardianBlocked added in v0.2.0

func IsDomainGuardianBlocked(err error) bool

IsDomainGuardianBlocked reports whether the Domain-Guardian blocked the change. The block is permanent until a human confirms the change in the regfish dash or exempts this API key on the domain's protection page.

The API reports it in two incompatible shapes: HTTP 403 with CodeDomainGuardBlocked on the domain endpoints, but HTTP 500 with CodeFailed on the DNS record endpoints, where status and code alone cannot tell it from a genuine server fault. Callers that retry on 5xx must check this first, or they will retry a decision that can never succeed.

One case is beyond reach: the guardian block on PUT /dns/{domain}/dnssec is also served as HTTP 500, but 500 is not among that operation's documented responses, so the API's own response validator discards the body and sends a generic server error instead. Nothing in the response survives to identify it, here or in any other client. Both this and the ACME quota gap are server-side defects (see docs/API-REVIEW-2026-08-01.md, finding H4) rather than limits of this classification.

func IsForbidden added in v0.2.0

func IsForbidden(err error) bool

IsForbidden reports whether err is an *APIError with HTTP status 403.

It is a transport-level predicate. Prefer IsPermissionDenied, which is true for the authorization denials specifically, and IsDomainGuardianBlocked, which also catches the guardian block the API serves as HTTP 500.

func IsNotFound added in v0.2.0

func IsNotFound(err error) bool

IsNotFound reports whether err is an *APIError with HTTP status 404.

The API renders a reference to another customer's domain, record or zone as not-found rather than forbidden, deliberately, so that it cannot be used to probe for the existence of other tenants' objects. A 404 therefore means "not found, or not reachable with this key" — never assert from it that the object does not exist.

func IsPermanent added in v0.2.0

func IsPermanent(err error) bool

IsPermanent reports whether err is a denial that no retry can clear — authentication, permission, scope, an unmapped operation or a Domain-Guardian block. A quota denial is not permanent: it clears when the window or the calendar day rolls over.

IsPermanent is one-directional. False means "not known to be permanent", not "safe to retry": several policy refusals the library deliberately does not classify are permanent too, notably the plan and chargeable-TLD gates that share HTTP 409 and CodeNameserverChangeNotAllowed with a transient transfer-in-progress. Cap your retries either way.

func IsPermissionDenied added in v0.2.0

func IsPermissionDenied(err error) bool

IsPermissionDenied reports whether the API refused err because of what this credential is allowed to do: a missing permission, a scope-bound credential, or an operation the server has not mapped.

It is false for a Domain-Guardian block, which has a different remedy — see IsDomainGuardianBlocked — and false for HTTP 401, which means the key was not accepted at all. Use DenialOf when the three sub-cases need different handling.

func IsRateLimited added in v0.2.0

func IsRateLimited(err error) bool

IsRateLimited reports whether err is an *APIError with HTTP status 429.

The API sends no Retry-After header. The nameserver and auth-code budgets reset on the UTC calendar day, the ACME limiter over a 60 second window; the Code field tells them apart.

func IsUnauthorized added in v0.2.0

func IsUnauthorized(err error) bool

IsUnauthorized reports whether err is an *APIError with HTTP status 401. The API answers 401 for an absent, malformed, unknown or deactivated key alike, and does not distinguish the four.

func MissingPermission added in v0.2.0

func MissingPermission(err error) (string, bool)

MissingPermission returns the permission the API named when it denied the request, e.g. "dns:write", and reports whether the denial named one at all.

Only the missing-permission denial carries a permission; scope and unmapped-operation denials name an operation instead — see DeniedOperation.

The value comes from the response, so it is always current: the library keeps no local operation-to-permission table.

func StatusCode added in v0.2.0

func StatusCode(err error) int

StatusCode returns the HTTP status code of err, or 0 if err is not an *APIError.

Types

type APIError added in v0.2.0

type APIError struct {
	// StatusCode is the HTTP status code of the response.
	StatusCode int
	// Code is the regfish error code (see the Code* constants). It is 0 when
	// the response carried no code.
	Code int
	// Message is the human readable "message" field, if any.
	Message string
	// Detail is the human readable "error" field, if any.
	Detail string
	// Body is the raw response body, useful when the error was not a JSON
	// envelope (e.g. a proxy error page).
	Body []byte
}

APIError is returned for every request the API did not answer successfully. It carries the transport status code as well as the "code", "error" and "message" fields of the API's error envelope, so callers can distinguish e.g. a duplicate record from a zone constraint violation.

func (*APIError) Error added in v0.2.0

func (e *APIError) Error() string

func (*APIError) Reason added in v0.2.0

func (e *APIError) Reason() string

Reason returns the API's human readable explanation, without the status and code prefix that Error adds.

The API puts the text in "message" on some endpoints and in "error" on others — the same Domain-Guardian block uses "message" on the domain endpoints and "error" on the record and DNSSEC endpoints — so Reason reads both.

When both are set, "error" comes first: the one response that populates both carries the diagnosis there and a follow-up instruction in "message" ("Invalid JSON payload received." + "Please check your request and try again."), so the other order reads as though the instruction caused the error.

type Authinfo added in v0.2.0

type Authinfo struct {
	Domain   string `json:"domain"`
	Authinfo string `json:"authinfo"`
}

Authinfo is a transfer authorization code generated at the registry.

type Client

type Client struct {
	BaseURL string
	APIKey  string
	Client  *http.Client
	// contains filtered or unexported fields
}

Client struct holds the API client configuration including the base URL and the API key for authentication.

func NewClient

func NewClient(apiKey string, opts ...Option) *Client

NewClient creates a new instance of the Regfish API client.

func (*Client) AddRecord added in v0.2.0

func (c *Client) AddRecord(ctx context.Context, record Record) (Record, error)

AddRecord creates a new DNS record. The zone is detected automatically from the record's Name, which must be fully qualified for this endpoint.

With an ordinary customer key, re-creating an existing record fails with CodeResourceRecordAlreadyExists. With a capability-scoped ACME credential the same call is idempotent: an identical _acme-challenge TXT record that is already present is returned as a success, with its existing ID.

That difference is the only recovery path an ACME integration has. Such a credential may not call any read operation, so a solver that loses the rrid of a challenge record — a process restart between publish and cleanup — cannot look it up. Re-posting the identical name and value returns the record with its ID so it can then be deleted.

func (*Client) CancelCertificate added in v0.2.0

func (c *Client) CancelCertificate(ctx context.Context, certificateID string, req *TLSCertificateCancelRequest) (TLSCertificate, error)

CancelCertificate cancels a pending TLS certificate order. Use CancelIssuedCertificateOrder when an already issued order should be revoked in full. req may be nil.

func (*Client) CancelDNSSECByDomain added in v0.2.0

func (c *Client) CancelDNSSECByDomain(ctx context.Context, domain string) (DNSSEC, error)

CancelDNSSECByDomain cancels a pending DNSSEC activation or — for regfish-managed nameservers — a pending deactivation. The API answers 409 when no cancellable transition exists.

func (*Client) CancelIssuedCertificateOrder added in v0.2.0

func (c *Client) CancelIssuedCertificateOrder(ctx context.Context, certificateID string, req *TLSCertificateOrderCancelRequest) (TLSCertificate, error)

CancelIssuedCertificateOrder cancels a not-yet-issued order, or revokes the complete issued order within the first 7 days after ordering. A full revocation invalidates all certificate versions of that order and prevents further reissues. req may be nil.

func (*Client) CheckPermissions added in v0.2.0

func (c *Client) CheckPermissions(ctx context.Context, permissions ...string) (PermissionReport, error)

CheckPermissions reports how the API key in use relates to the permissions this program needs. It performs exactly one request (GET /meta/token, the one endpoint every valid key may call) and never blocks, alters or pre-empts any other call.

Call it once at startup and log or act on the report, so a misconfigured key fails the deployment instead of the first write hours later:

r, err := client.CheckPermissions(ctx, regfishapi.PermissionDNSWrite)
if err != nil {
	log.Fatal(err)
}
if !r.Satisfied() {
	log.Fatal(r)
}

Gate on Satisfied rather than on len(Missing): a capability-scoped credential has no missing permissions and still cannot do the work, so a Missing-only check would wave it through.

The report only reflects the key's permissions and scope. It cannot see Domain-Guardian rules, domain ownership, plan entitlements or daily quotas, so a satisfied report is not a promise that a later call will succeed.

On error the returned report has Kind KeyKindUnknown.

func (*Client) CompleteCertificate added in v0.2.0

func (c *Client) CompleteCertificate(ctx context.Context, certificateID, orgID string) (TLSCertificate, error)

CompleteCertificate completes an action-required order by binding it to an existing usable organization and submitting it to the provider.

func (*Client) CreateCertificate added in v0.2.0

func (c *Client) CreateCertificate(ctx context.Context, req TLSCertificateRequest) (TLSCertificate, error)

CreateCertificate creates a new TLS certificate order or renews an existing certificate.

OV and EV style products can answer with ActionRequired set, in which case the order has to be completed with CompleteCertificate.

func (*Client) CreateOrganization added in v0.2.0

func (c *Client) CreateOrganization(ctx context.Context, req TLSOrganizationCreateRequest) (TLSOrganization, error)

CreateOrganization creates a TLS organization including the local contact record used for OV and EV ordering.

func (*Client) CreateRecord deprecated

func (c *Client) CreateRecord(record Record) (Record, error)

CreateRecord creates a new DNS record.

Deprecated: use AddRecord.

func (*Client) DeleteRecord deprecated

func (c *Client) DeleteRecord(rrid int) error

DeleteRecord deletes a DNS record by RRID.

Deprecated: use DeleteRecordByRRID.

func (*Client) DeleteRecordByRRID added in v0.2.0

func (c *Client) DeleteRecordByRRID(ctx context.Context, rrid int) error

DeleteRecordByRRID deletes the DNS record with the given RRID.

func (*Client) DownloadCertificate added in v0.2.0

func (c *Client) DownloadCertificate(ctx context.Context, certificateID, format string) (TLSCertificateDownload, error)

DownloadCertificate downloads an issued certificate. format is TLSDownloadFormatPEM or TLSDownloadFormatZIP.

func (*Client) DownloadOpenAPISpec added in v0.2.0

func (c *Client) DownloadOpenAPISpec(ctx context.Context) ([]byte, error)

DownloadOpenAPISpec downloads the current OpenAPI specification as YAML.

func (*Client) ExportDNSZoneBindByDomain added in v0.2.0

func (c *Client) ExportDNSZoneBindByDomain(ctx context.Context, domain string) ([]byte, error)

ExportDNSZoneBindByDomain exports the zone as a BIND-compatible zone file. Non-standard ALIAS records are included as comments and, where possible, as resolved A records.

func (*Client) GetCertificateByID added in v0.2.0

func (c *Client) GetCertificateByID(ctx context.Context, certificateID string) (TLSCertificate, error)

GetCertificateByID retrieves a single TLS certificate.

func (*Client) GetDNSSECByDomain added in v0.2.0

func (c *Client) GetDNSSECByDomain(ctx context.Context, domain string) (DNSSEC, error)

GetDNSSECByDomain retrieves the DNSSEC configuration and status of a domain.

func (*Client) GetDNSZoneByDomain added in v0.2.0

func (c *Client) GetDNSZoneByDomain(ctx context.Context, domain string) (ZoneDetail, error)

GetDNSZoneByDomain retrieves the complete DNS zone of a domain, including all records and NS entries.

func (*Client) GetDomainByName added in v0.2.0

func (c *Client) GetDomainByName(ctx context.Context, domain string) (DomainDetails, error)

GetDomainByName retrieves the details of a single registered domain.

func (*Client) GetHostingPackage added in v0.2.0

func (c *Client) GetHostingPackage(ctx context.Context, id string) (HostingPackage, error)

GetHostingPackage retrieves a single web hosting package.

func (*Client) GetNameserversByDomain added in v0.2.0

func (c *Client) GetNameserversByDomain(ctx context.Context, domain string) (Nameservers, error)

GetNameserversByDomain returns the current delegation of the domain together with the vanity nameserver sets available on the account.

func (*Client) GetOrganizationByID added in v0.2.0

func (c *Client) GetOrganizationByID(ctx context.Context, organizationID string) (TLSOrganization, error)

GetOrganizationByID retrieves a single TLS organization.

func (*Client) GetRecord deprecated

func (c *Client) GetRecord(rrid int) (Record, error)

GetRecord retrieves details about a specific DNS record by RRID.

Deprecated: use GetRecordByRRID.

func (*Client) GetRecordByRRID added in v0.2.0

func (c *Client) GetRecordByRRID(ctx context.Context, rrid int) (Record, error)

GetRecordByRRID retrieves details about a specific DNS record by RRID.

func (*Client) GetRecordsByDomain deprecated

func (c *Client) GetRecordsByDomain(domain string) ([]Record, error)

GetRecordsByDomain retrieves all DNS records for a given domain.

Deprecated: use ListRecordsByDomain.

func (*Client) GetTokenInfo added in v0.2.0

func (c *Client) GetTokenInfo(ctx context.Context) (TokenInfo, error)

GetTokenInfo returns metadata about the API key in use: its public key id, the granted permissions, the capability scope and the customer it is scoped to.

Every valid key may call this, including capability-scoped ones, so it is a safe startup probe. It returns an error if the response omits the permission list entirely, because an absent list cannot be told apart from an explicit null — which would silently read as a legacy key with full access.

func (*Client) ListCertificates added in v0.2.0

func (c *Client) ListCertificates(ctx context.Context) ([]TLSCertificate, error)

ListCertificates lists the TLS certificates of the account.

func (*Client) ListDNSSECJobsByDomain added in v0.2.0

func (c *Client) ListDNSSECJobsByDomain(ctx context.Context, domain string) ([]DNSSECJob, error)

ListDNSSECJobsByDomain retrieves the recent registry DNSSEC jobs of a domain.

func (*Client) ListDNSZones added in v0.2.0

func (c *Client) ListDNSZones(ctx context.Context) ([]ZoneSummary, error)

ListDNSZones lists the DNS zones of the account with SOA data, delegated nameservers, DNSSEC status and record counts.

func (*Client) ListDomains added in v0.2.0

func (c *Client) ListDomains(ctx context.Context, opts *ListDomainsOptions) (DomainList, error)

ListDomains lists the customer's registered domains. opts may be nil.

func (*Client) ListHostingAliases added in v0.2.0

func (c *Client) ListHostingAliases(ctx context.Context, id string) ([]HostingAlias, error)

ListHostingAliases lists the domain aliases of a hosting package.

func (*Client) ListHostingDatabases added in v0.2.0

func (c *Client) ListHostingDatabases(ctx context.Context, id string) ([]HostingDatabase, error)

ListHostingDatabases lists the databases of a hosting package.

func (*Client) ListHostingPackages added in v0.2.0

func (c *Client) ListHostingPackages(ctx context.Context) ([]HostingPackage, error)

ListHostingPackages lists the customer's web hosting packages.

func (*Client) ListOrganizations added in v0.2.0

func (c *Client) ListOrganizations(ctx context.Context) ([]TLSOrganization, error)

ListOrganizations lists the TLS organizations usable for OV and EV orders.

func (*Client) ListRecordsByDomain added in v0.2.0

func (c *Client) ListRecordsByDomain(ctx context.Context, domain string) ([]Record, error)

ListRecordsByDomain retrieves all DNS records stored in the zone of the given domain. NS records are not part of the result; use GetDNSZoneByDomain for a view that includes the zone's delegation.

func (*Client) ListTLSProducts added in v0.2.0

func (c *Client) ListTLSProducts(ctx context.Context) ([]TLSProduct, error)

ListTLSProducts lists the available certificate products together with the current account pricing.

func (*Client) PatchOrganizationByID added in v0.2.0

func (c *Client) PatchOrganizationByID(ctx context.Context, organizationID string, req TLSOrganizationPatchRequest) (TLSOrganization, error)

PatchOrganizationByID updates a TLS organization. Depending on EditMode and the changed fields the API may create a replacement organization with a new id instead of updating in place.

func (*Client) PatchRecord added in v0.2.0

func (c *Client) PatchRecord(ctx context.Context, record Record) (Record, error)

PatchRecord updates a DNS record identified by its name and type — and, for every type except A and AAAA, its current data. Use PatchRecordByRRID to change a record's name or type, or when several records share the same name/type combination: this endpoint requires a unique match.

func (*Client) PatchRecordByRRID added in v0.2.0

func (c *Client) PatchRecordByRRID(ctx context.Context, rrid int, record Record) (Record, error)

PatchRecordByRRID updates the DNS record with the given RRID. Unlike PatchRecord this can also change the record's name and type.

func (*Client) PutDNSSECByDomain added in v0.2.0

func (c *Client) PutDNSSECByDomain(ctx context.Context, domain string, req DNSSECRequest) (DNSSEC, error)

PutDNSSECByDomain enables, disables or updates registry DNSSEC for a domain.

The response may already be final, or it may carry a PendingJob while the registry or the DNS delegation is still converging.

func (*Client) PutNameserversByDomain added in v0.2.0

func (c *Client) PutNameserversByDomain(ctx context.Context, domain string, vanitySetID *int) (Nameservers, error)

PutNameserversByDomain delegates the domain to one of the account's vanity nameserver sets, or — with a nil vanitySetID — back to the regfish standard nameservers. Free-form nameservers are not supported by this endpoint; external delegations are managed in the regfish dash.

The change is subject to the Domain-Guardian, the domain's status and a daily per-domain change limit, which surface as 403, 409 and 429.

func (*Client) ReissueCertificate added in v0.2.0

func (c *Client) ReissueCertificate(ctx context.Context, certificateID string, req TLSCertificateReissueRequest) (TLSCertificate, error)

ReissueCertificate reissues an already issued or certificate-revoked certificate with a new CSR, keeping the same order.

func (*Client) Request deprecated

func (c *Client) Request(method, endpoint string, body interface{}, headers map[string]string) ([]byte, error)

Request helper for making HTTP requests.

Deprecated: use RequestContext so the call can be cancelled.

func (*Client) RequestAuthinfoByDomain added in v0.2.0

func (c *Client) RequestAuthinfoByDomain(ctx context.Context, domain string) (Authinfo, error)

RequestAuthinfoByDomain generates the domain's transfer authorization code at the registry.

The code enables an outbound transfer — request it only on the domain owner's explicit demand. Requests are guarded by the Domain-Guardian and limited to 3 per domain and 10 per account per day; every issued code is recorded in the domain guard log.

func (*Client) RequestContext added in v0.2.0

func (c *Client) RequestContext(ctx context.Context, method, endpoint string, body interface{}, headers map[string]string) ([]byte, error)

RequestContext performs a raw request against the API and returns the response body. Non-2xx responses are returned as *APIError.

func (*Client) RevokeCertificate added in v0.2.0

func (c *Client) RevokeCertificate(ctx context.Context, certificateID string, req *TLSCertificateRevokeRequest) (TLSCertificate, error)

RevokeCertificate revokes only the currently selected certificate while keeping the order available for a later reissue. req may be nil.

func (*Client) UpdateRecord deprecated

func (c *Client) UpdateRecord(record Record) (Record, error)

UpdateRecord updates a DNS record by the records' name

Deprecated: use PatchRecord.

func (*Client) UpdateRecordById deprecated

func (c *Client) UpdateRecordById(rrid int, record Record) (Record, error)

UpdateRecordById updates a DNS record by RRID.

Deprecated: use PatchRecordByRRID.

func (*Client) VerifyDNSSECByDomain added in v0.2.0

func (c *Client) VerifyDNSSECByDomain(ctx context.Context, domain string) (DNSSEC, error)

VerifyDNSSECByDomain refreshes the registry DNSSEC state and checks whether the delegation is visible. A successful response can still report "pending" when the target state has not propagated completely yet.

type DNSSEC added in v0.2.0

type DNSSEC struct {
	Configured bool `json:"configured"`
	// DNSSECState is the high-level status: "active", "pending" or "inactive".
	DNSSECState string `json:"dnssec_state"`
	// Mode is one of the DNSSECMode* constants.
	Mode string `json:"mode"`
	// DesiredState is the target registry state.
	DesiredState string `json:"desired_state"`
	// LiveState is the last state observed from the registry and delegation
	// checks.
	LiveState          string             `json:"live_state"`
	Capabilities       DNSSECCapabilities `json:"capabilities"`
	DesiredRecords     []DNSSECRecord     `json:"desired_records"`
	LiveRecords        []DNSSECRecord     `json:"live_records"`
	LastErrorCode      *string            `json:"last_error_code"`
	LastError          *string            `json:"last_error"`
	LastRegistryName   *string            `json:"last_registry_name"`
	LastRegistryRef    *string            `json:"last_registry_reference"`
	LastRegistryStatus *string            `json:"last_registry_status"`
	LastVerifiedAt     *int64             `json:"last_verified_at"`
	LastAppliedAt      *int64             `json:"last_applied_at"`
	PendingJob         *DNSSECJob         `json:"pending_job"`
	UsingRegfishNS     bool               `json:"using_regfish_nameservers"`
	LegacyMode         bool               `json:"legacy_mode"`
	ZoneSigned         bool               `json:"zone_signed"`
	ZonePendingDisable bool               `json:"zone_pending_disable"`
	ZonePropagatedAt   *int64             `json:"zone_propagated_at"`
	Jobs               []DNSSECJob        `json:"jobs,omitempty"`
}

DNSSEC is the DNSSEC configuration and status of a domain.

DNSSEC changes can be asynchronous, so DesiredState and LiveState may differ temporarily; PendingJob is set while a transition is still in progress.

type DNSSECCapabilities added in v0.2.0

type DNSSECCapabilities struct {
	Supported             bool     `json:"supported"`
	Provider              string   `json:"provider"`
	ModeRegfishAvailable  bool     `json:"mode_regfish_available"`
	ModeExternalAvailable bool     `json:"mode_external_available"`
	AcceptedRecordKinds   []string `json:"accepted_record_kinds"`
	MinRecords            int      `json:"min_records"`
	MaxRecords            *int     `json:"max_records"`
	AcceptedAlgorithms    []int    `json:"accepted_algorithms"`
	ReasonUnavailable     string   `json:"reason_unavailable,omitempty"`
}

DNSSECCapabilities reports what the registry of a domain supports.

type DNSSECJob added in v0.2.0

type DNSSECJob struct {
	ID     int    `json:"id"`
	Action string `json:"action"`
	Mode   string `json:"mode"`
	// Status is one of PENDING, RUNNING, WAITING, OK, ERROR or CANCELLED.
	Status            string  `json:"status"`
	Source            string  `json:"source"`
	RegistryName      *string `json:"registry_name"`
	RegistryReference *string `json:"registry_reference"`
	ErrorCode         *string `json:"error_code"`
	ErrorText         *string `json:"error_text"`
	TSCreated         int64   `json:"ts_created"`
	TSUpdated         int64   `json:"ts_updated"`
	TSStarted         *int64  `json:"ts_started"`
	TSFinished        *int64  `json:"ts_finished"`
}

DNSSECJob is a registry DNSSEC transition job.

type DNSSECRecord added in v0.2.0

type DNSSECRecord struct {
	// Kind is DNSSECRecordKindDS or DNSSECRecordKindDNSKEY.
	Kind       string `json:"kind"`
	KeyTag     *int   `json:"key_tag,omitempty"`
	Flags      *int   `json:"flags,omitempty"`
	Protocol   *int   `json:"protocol,omitempty"`
	Algorithm  int    `json:"algorithm"`
	DigestType *int   `json:"digest_type,omitempty"`
	Digest     string `json:"digest,omitempty"`
	PublicKey  string `json:"public_key,omitempty"`
	Comment    string `json:"comment,omitempty"`
}

DNSSECRecord is a DS or DNSKEY record used as a registry trust anchor.

type DNSSECRequest added in v0.2.0

type DNSSECRequest struct {
	// Mode is one of the DNSSECMode* constants.
	Mode string `json:"mode"`
	// State is DNSSECStateEnabled or DNSSECStateDisabled. Use
	// DNSSECModeNone together with DNSSECStateDisabled to switch registry
	// DNSSEC off.
	State string `json:"state"`
	// VerifyAfterApply makes the API refresh the registry state and check the
	// DNS delegation right after the update. Defaults to true when nil.
	VerifyAfterApply *bool `json:"verify_after_apply,omitempty"`
	// Records is required for Mode DNSSECModeExternal with State
	// DNSSECStateEnabled and ignored otherwise.
	Records []DNSSECRecord `json:"records,omitempty"`
}

DNSSECRequest is the payload of PutDNSSECByDomain.

type Decision added in v0.2.0

type Decision int

Decision is the library's advisory expectation about a permission. It is never authoritative: the API decides, and it can refuse for reasons no key metadata reveals (Domain-Guardian, ownership, plan entitlements, quotas).

const (
	// DecisionUnknown means the library cannot say. It is returned for
	// capability-scoped credentials, whose permission list does not describe
	// what they may do, and for a TokenInfo that was never populated.
	DecisionUnknown Decision = iota
	// DecisionAllowed means the key holds the permission, or is a legacy key
	// with full access.
	DecisionAllowed
	// DecisionDenied means the key has a permission list that does not contain
	// this permission.
	DecisionDenied
)

func (Decision) String added in v0.2.0

func (d Decision) String() string

String implements fmt.Stringer.

type Denial added in v0.2.0

type Denial int

Denial classifies why the API refused a request.

The classification is derived from the response, never from a local copy of the server's permission model: the pair (HTTP status, presence and value of the "code" member) does the work, and message text only refines an already established denial. An unrecognised message therefore degrades to the coarser value, never to DenialNone.

const (
	// DenialNone means err is not a recognised authorization failure. It is
	// also returned for errors that are not *APIError and for denial shapes
	// this version does not know about — never read it as "the request was
	// permitted".
	DenialNone Denial = iota
	// DenialUnauthenticated is HTTP 401: the key was absent, malformed,
	// unknown or deactivated. The API does not distinguish these four.
	DenialUnauthenticated
	// DenialPermission means the key does not hold the permission the
	// operation requires. MissingPermission names it when the API did.
	DenialPermission
	// DenialScope means a scope-bound platform credential (see
	// ScopeACMEDNSChallenge) may not call this operation at all. Granting the
	// key more permissions does not help; a different key does.
	DenialScope
	// DenialUnmappedOperation means the server has no permission mapping for
	// the operation and denied it fail-closed. This is a server-side gap, not
	// an under-scoped key: no grant lifts it, and it affects every scoped key
	// at once. Worth reporting to regfish.
	DenialUnmappedOperation
	// DenialGuardian means the Domain-Guardian blocked the change. It is
	// permanent until a human confirms the change in the regfish dash or
	// exempts this API key there.
	DenialGuardian
	// DenialQuota means a rate limit or daily budget was exhausted. The API
	// sends no Retry-After header, and the budgets reset on the UTC calendar
	// day.
	//
	// Only the nameserver-change and auth-code budgets reach a client this way.
	// The ACME limiter also answers 429, but 429 is not among the documented
	// responses of the record endpoints, so the API's response validator
	// replaces it with a generic server error before it leaves the building —
	// see the note on IsDomainGuardianBlocked.
	DenialQuota
)

func DenialOf added in v0.2.0

func DenialOf(err error) Denial

DenialOf classifies err. It returns DenialNone for errors that are not *APIError and for failures that are not authorization decisions.

func (Denial) String added in v0.2.0

func (d Denial) String() string

String implements fmt.Stringer.

type Domain added in v0.2.0

type Domain struct {
	Domain            string `json:"domain"`
	SLD               string `json:"sld"`
	TLD               string `json:"tld"`
	Favorite          bool   `json:"favorite"`
	OwnerContactID    *int   `json:"owner_contact_id"`
	Owner             string `json:"owner"`
	PrimaryNameserver string `json:"primary_nameserver"`
	// DNSSECState is the high-level status: "active", "pending" or "inactive".
	DNSSECState  string `json:"dnssec_state"`
	AutoRenew    bool   `json:"auto_renew"`
	Cancelled    bool   `json:"cancelled"`
	RegisteredAt *int64 `json:"registered_at"`
	ExpiresAt    *int64 `json:"expires_at"`
}

Domain describes a registered domain in the customer's portfolio.

type DomainDetails added in v0.2.0

type DomainDetails struct {
	Domain
	// Nameservers holds the currently delegated nameservers, without a
	// trailing dot.
	Nameservers []string `json:"nameservers"`
}

DomainDetails adds the current delegation to a Domain.

type DomainList added in v0.2.0

type DomainList struct {
	Domains    []Domain `json:"domains"`
	TotalItems int      `json:"total_items"`
	TotalPages int      `json:"total_pages"`
	Page       int      `json:"page"`
	PageSize   int      `json:"page_size"`
	Search     string   `json:"search"`
	Filters    []string `json:"filters"`
	SortBy     string   `json:"sort_by"`
	SortOrder  string   `json:"sort_order"`
}

DomainList is a page of the customer's domain portfolio.

type HostingAlias added in v0.2.0

type HostingAlias struct {
	Name        string `json:"name"`
	OwnVhost    bool   `json:"own_vhost,omitempty"`
	VhostDir    string `json:"vhost_dir,omitempty"`
	RFDomainID  *int   `json:"rf_domain_id"`
	LinkedToApp bool   `json:"linked_to_app,omitempty"`
}

HostingAlias is a domain alias of a hosting package.

type HostingBackup added in v0.2.0

type HostingBackup struct {
	RecoverStatus      *string `json:"recover_status"`
	RecoverPointInTime *int64  `json:"recover_point_in_time"`
	RecoveredAt        *int64  `json:"recovered_at"`
}

HostingBackup is the state of a running or finished backup recovery.

type HostingDatabase added in v0.2.0

type HostingDatabase struct {
	Name string `json:"name"`
	User string `json:"user"`
	Host string `json:"host,omitempty"`
}

HostingDatabase is a database of a hosting package. Credentials are never returned by the API — database passwords are available only in the dash.

type HostingPackage added in v0.2.0

type HostingPackage struct {
	// ID is the package id, which is also the system user group of the package.
	ID            string         `json:"id"`
	WebhostID     int            `json:"webhost_id"`
	Plan          string         `json:"plan"`
	Generation    int            `json:"generation,omitempty"`
	Status        string         `json:"status"`
	Active        bool           `json:"active"`
	Cancelled     bool           `json:"cancelled"`
	PHPVersion    string         `json:"php_version,omitempty"`
	CreatedAt     int64          `json:"created_at,omitempty"`
	StartsAt      *int64         `json:"starts_at"`
	ExpiresAt     *int64         `json:"expires_at"`
	AliasCount    int            `json:"alias_count,omitempty"`
	DatabaseCount int            `json:"database_count,omitempty"`
	Backup        *HostingBackup `json:"backup,omitempty"`
}

HostingPackage is a web hosting package of the account.

type KeyKind added in v0.2.0

type KeyKind int

KeyKind classifies how the API evaluates a key's authorization.

const (
	// KeyKindUnknown means no key metadata is available — the zero TokenInfo,
	// or one from a GetTokenInfo call that failed.
	KeyKindUnknown KeyKind = iota
	// KeyKindLegacy is a key created before RBAC: Permissions is nil and the
	// API grants it full access.
	KeyKindLegacy
	// KeyKindRBAC is a key with a permission list. The list may be empty,
	// which is a valid state meaning "nothing beyond GetTokenInfo and the
	// OpenAPI spec".
	KeyKindRBAC
	// KeyKindCapability is a scope-bound platform credential such as an ACME
	// DNS-01 key. The API restricts it to a fixed set of operations regardless
	// of its permission list, which is why such a key must never be read as a
	// legacy full-access key.
	KeyKindCapability
)

func (KeyKind) String added in v0.2.0

func (k KeyKind) String() string

String implements fmt.Stringer.

type ListDomainsOptions added in v0.2.0

type ListDomainsOptions struct {
	// Search matches the domain name, owner label or primary nameserver,
	// case-insensitively and partially.
	Search string
	// Filters holds DomainFilter* values.
	Filters []string
	// SortBy holds a DomainSortBy* value.
	SortBy string
	// SortOrder is SortAsc or SortDesc.
	SortOrder string
	// Page is 1-based; 0 leaves the choice to the API.
	Page int
	// PageSize must be one of 10, 25, 50 or 100; 0 leaves the choice to the API.
	PageSize int
}

ListDomainsOptions narrows and orders the result of ListDomains. The zero value requests the first page with the API's defaults.

type Nameservers added in v0.2.0

type Nameservers struct {
	Domain string `json:"domain"`
	// Mode is one of NameserverModeStandard, NameserverModeVanity or
	// NameserverModeExternal.
	Mode string `json:"mode"`
	// Current holds the delegated nameservers, without a trailing dot.
	Current []string `json:"current"`
	// VanitySetID is nil unless the domain is delegated to a vanity set.
	VanitySetID *int        `json:"vanity_set_id"`
	VanitySets  []VanitySet `json:"vanity_sets"`
}

Nameservers describes the delegation of a domain.

type Option added in v0.2.0

type Option func(*Client)

Option customizes a Client created by NewClient.

func WithBaseURL added in v0.2.0

func WithBaseURL(baseURL string) Option

WithBaseURL overrides the API endpoint, e.g. "https://api.regfish.com".

func WithHTTPClient added in v0.2.0

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient sets the underlying HTTP client, for example to configure a custom transport, proxy or timeout.

func WithUserAgent added in v0.2.0

func WithUserAgent(ua string) Option

WithUserAgent overrides the User-Agent header sent with every request.

type PermissionReport added in v0.2.0

type PermissionReport struct {
	// Token is the metadata the report was derived from.
	Token TokenInfo
	// Kind is Token.Kind(), lifted for convenience.
	Kind KeyKind
	// Scope is the capability scope, or "" for an ordinary key.
	Scope string
	// Requested holds the permissions that were checked, in the order given.
	Requested []string
	// Granted, Missing and Undetermined partition Requested.
	//
	// Undetermined is where a capability-scoped credential lands: it must clear
	// a scope gate that permissions do not describe, so holding the permission
	// does not mean the call will be allowed. An unpopulated TokenInfo lands
	// there too. Gating a deployment on len(Missing) alone therefore passes a
	// scope-bound key that cannot do the work — use Satisfied.
	Granted      []string
	Missing      []string
	Undetermined []string
}

PermissionReport is the result of a startup permission check.

func (PermissionReport) Satisfied added in v0.2.0

func (r PermissionReport) Satisfied() bool

Satisfied reports whether every requested permission was positively confirmed — nothing missing and nothing undetermined.

It is the honest gate for a startup check. It is still only a statement about the key's permissions: Domain-Guardian rules, domain ownership, plan entitlements and quotas are invisible here, so a satisfied report is not a promise that a later call will succeed.

func (PermissionReport) String added in v0.2.0

func (r PermissionReport) String() string

String implements fmt.Stringer and renders a single log line naming the key, its kind and any missing permissions.

type Record

type Record struct {
	ID         int     `json:"id"`
	Name       string  `json:"name"`
	Type       string  `json:"type"`
	Data       string  `json:"data"`
	TTL        int     `json:"ttl,omitempty"`
	Priority   *int    `json:"priority,omitempty"`
	Annotation *string `json:"annotation,omitempty"`
	Tag        *string `json:"tag,omitempty"`
	Flags      *int    `json:"flags,omitempty"`

	// Weight and Port belong to SRV records.
	Weight *int `json:"weight,omitempty"`
	Port   *int `json:"port,omitempty"`

	// Usage, Selector and MatchingType belong to TLSA records.
	Usage        *int `json:"usage,omitempty"`
	Selector     *int `json:"selector,omitempty"`
	MatchingType *int `json:"matching_type,omitempty"`

	// Auto reports whether the record is managed automatically by regfish.
	// Read-only.
	Auto bool `json:"auto"`
	// Active reports whether the record is currently active. Read-only.
	Active bool `json:"active"`
	// TSCreated is the Unix timestamp of the record's creation. Read-only.
	TSCreated int64 `json:"ts_created"`
	// TSUpdated is the Unix timestamp of the record's last update. Read-only.
	TSUpdated int64 `json:"ts_updated"`
}

Record represents a DNS record with common fields.

Name accepts a fully qualified name ("www.example.com."), a bare subdomain ("www") or "@" for the zone apex. Responses return the apex as "@" and all other names fully qualified.

Priority is required for MX records; Flags and Tag are required for CAA records. SRV records require Priority, Weight and Port, with Data holding the target host. TLSA records require Usage, Selector and MatchingType, with Data holding the certificate association data as hexadecimal digits. Targets in Data (MX, SRV, CNAME, ALIAS) must be fully qualified and end with a period. The fields below the write set (Auto, Active, TSCreated, TSUpdated) are read-only and ignored when a Record is sent to the API.

type TLSCertificate added in v0.2.0

type TLSCertificate struct {
	ID string `json:"id"`
	// Status is one of the TLSStatus* constants.
	Status     string   `json:"status"`
	CommonName string   `json:"common_name"`
	Product    string   `json:"product"`
	Provider   string   `json:"provider"`
	DNSNames   []string `json:"dns_names"`
	// ActionRequired reports whether the order needs further input before it
	// can be submitted; CompletionURL and CompleteCertificate lead there.
	ActionRequired         bool                        `json:"action_required"`
	PendingReason          string                      `json:"pending_reason"`
	PendingMessage         string                      `json:"pending_message"`
	CompletionURL          string                      `json:"completion_url"`
	OrganizationID         *string                     `json:"organization_id"`
	Organization           *TLSCertificateOrganization `json:"organization,omitempty"`
	OrderState             string                      `json:"order_state,omitempty"`
	RevocationScope        string                      `json:"revocation_scope,omitempty"`
	RevocationPendingScope string                      `json:"revocation_pending_scope,omitempty"`
	ReissueSupported       bool                        `json:"reissue_supported,omitempty"`
	// ValidityDays is the purchased base order validity. On provider-linked
	// renewals the issued lifetime can be longer — ValidFrom and ValidUntil
	// are authoritative.
	ValidityDays            int            `json:"validity_days,omitempty"`
	RenewalBonusDays        int            `json:"renewal_bonus_days,omitempty"`
	SerialNumber            string         `json:"serial_number,omitempty"`
	ValidFrom               string         `json:"valid_from,omitempty"`
	ValidUntil              string         `json:"valid_until,omitempty"`
	ContractValidFrom       string         `json:"contract_valid_from,omitempty"`
	ContractValidUntil      string         `json:"contract_valid_until,omitempty"`
	LastStatusCheck         string         `json:"last_status_check,omitempty"`
	CertificatePEMAvailable bool           `json:"certificate_pem_available"`
	OrderCancellable        bool           `json:"order_cancellable,omitempty"`
	OrderCancellationMode   string         `json:"order_cancellation_mode,omitempty"`
	OrderCancellableUntil   string         `json:"order_cancellable_until,omitempty"`
	Validation              *TLSValidation `json:"validation,omitempty"`
	Reissue                 *TLSReissue    `json:"reissue,omitempty"`
}

TLSCertificate is a TLS certificate order and, once issued, the certificate itself.

type TLSCertificateCancelRequest added in v0.2.0

type TLSCertificateCancelRequest struct {
	// Note is stored with the cancellation request at the provider. regfish
	// sends a default note when it is empty, because the CA requires one.
	Note string `json:"note,omitempty"`
}

TLSCertificateCancelRequest is the optional payload of CancelCertificate.

type TLSCertificateDownload added in v0.2.0

type TLSCertificateDownload struct {
	// Body is the PEM text or the ZIP bundle, depending on the format.
	Body []byte
	// ContentType is the MIME type reported by the API.
	ContentType string
	// Filename is taken from the Content-Disposition header, if present.
	Filename string
}

TLSCertificateDownload is an issued certificate as returned by DownloadCertificate.

type TLSCertificateOrderCancelRequest added in v0.2.0

type TLSCertificateOrderCancelRequest struct {
	Comment          string `json:"comment,omitempty"`
	RevocationReason string `json:"revocation_reason,omitempty"`
}

TLSCertificateOrderCancelRequest is the optional payload of CancelIssuedCertificateOrder.

type TLSCertificateOrganization added in v0.2.0

type TLSCertificateOrganization struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Status string `json:"status"`
	// UsableForOrdering reports whether the organization can back a new order.
	UsableForOrdering bool `json:"usable_for_ordering"`
}

TLSCertificateOrganization is the organization a certificate is bound to.

type TLSCertificateReissueRequest added in v0.2.0

type TLSCertificateReissueRequest struct {
	CSR string `json:"csr"`
	// CommonName is optional; when set it must match the current order exactly.
	CommonName string `json:"common_name,omitempty"`
	// DNSNames is optional; when set the SAN list must match the current order
	// exactly.
	DNSNames  []string `json:"dns_names,omitempty"`
	DCVMethod string   `json:"dcv_method"`
	Comments  string   `json:"comments,omitempty"`
	// ValidityDays optionally requests a shorter replacement lifetime. The CA
	// honors it only for eligible multi-year plan orders.
	ValidityDays int `json:"validity_days,omitempty"`
}

TLSCertificateReissueRequest is the payload of ReissueCertificate.

type TLSCertificateRequest added in v0.2.0

type TLSCertificateRequest struct {
	// SKU is one of the TLSProduct* constants.
	SKU        string   `json:"sku"`
	CommonName string   `json:"common_name"`
	DNSNames   []string `json:"dns_names,omitempty"`
	// CSR is the PEM encoded certificate signing request.
	CSR string `json:"csr"`
	// DCVMethod is DCVMethodDNSCNAMEToken or DCVMethodEmail.
	DCVMethod string   `json:"dcv_method"`
	DCVEmails []string `json:"dcv_emails,omitempty"`
	// OrgID references a TLS organization for OV and EV orders.
	OrgID string `json:"org_id,omitempty"`
	// RenewalOfCertificateID submits the order as a provider-linked renewal of
	// the referenced certificate.
	RenewalOfCertificateID string `json:"renewal_of_certificate_id,omitempty"`
	// ValidityDays is the purchased base order validity, 1–199. Zero leaves
	// the choice to the API (199).
	ValidityDays int `json:"validity_days,omitempty"`
}

TLSCertificateRequest is the payload of CreateCertificate.

type TLSCertificateRevokeRequest added in v0.2.0

type TLSCertificateRevokeRequest struct {
	Comment string `json:"comment,omitempty"`
	// RevocationReason is one of the RevocationReason* constants and defaults
	// to RevocationReasonUnspecified.
	RevocationReason string `json:"revocation_reason,omitempty"`
}

TLSCertificateRevokeRequest is the optional payload of RevokeCertificate.

type TLSOrganization added in v0.2.0

type TLSOrganization struct {
	ID           string `json:"id"`
	Organization string `json:"organization"`
	// Status is TLSOrganizationStatusReady or TLSOrganizationStatusIncomplete.
	Status               string `json:"status"`
	UsableForOrdering    bool   `json:"usable_for_ordering"`
	Provider             string `json:"provider,omitempty"`
	ProviderStatus       string `json:"provider_status,omitempty"`
	ValidationStatus     string `json:"validation_status,omitempty"`
	ValidationType       string `json:"validation_type,omitempty"`
	ValidatedUntil       string `json:"validated_until,omitempty"`
	RevalidationRequired bool   `json:"revalidation_required,omitempty"`
	FirstName            string `json:"first_name"`
	LastName             string `json:"last_name"`
	Address              string `json:"address"`
	PostalCode           string `json:"postal_code"`
	City                 string `json:"city"`
	CountryCode          string `json:"country_code"`
	Phone                string `json:"phone"`
	Email                string `json:"email"`
}

TLSOrganization is an organization usable for OV and EV certificate orders.

type TLSOrganizationCreateRequest added in v0.2.0

type TLSOrganizationCreateRequest struct {
	Organization string `json:"organization"`
	FirstName    string `json:"first_name"`
	LastName     string `json:"last_name"`
	Address      string `json:"address"`
	PostalCode   string `json:"postal_code"`
	City         string `json:"city"`
	// CountryCode is a two letter ISO country code.
	CountryCode string `json:"country_code"`
	Phone       string `json:"phone"`
	Email       string `json:"email"`
}

TLSOrganizationCreateRequest is the payload of CreateOrganization.

type TLSOrganizationPatchRequest added in v0.2.0

type TLSOrganizationPatchRequest struct {
	// EditMode is TLSOrgEditModeCreateReplacement or
	// TLSOrgEditModeUpdateProvider.
	EditMode     string `json:"edit_mode,omitempty"`
	Organization string `json:"organization,omitempty"`
	FirstName    string `json:"first_name,omitempty"`
	LastName     string `json:"last_name,omitempty"`
	Address      string `json:"address,omitempty"`
	PostalCode   string `json:"postal_code,omitempty"`
	City         string `json:"city,omitempty"`
	CountryCode  string `json:"country_code,omitempty"`
	Phone        string `json:"phone,omitempty"`
	Email        string `json:"email,omitempty"`
}

TLSOrganizationPatchRequest is the payload of PatchOrganizationByID. At least one field must be set.

type TLSProduct added in v0.2.0

type TLSProduct struct {
	SKU  string `json:"sku"`
	Name string `json:"name"`
	// Type is "DV", "OV" or "EV".
	Type string `json:"type"`
	// ValidationLevel is the lower-case form of Type.
	ValidationLevel      string          `json:"validation_level"`
	OrganizationRequired bool            `json:"organization_required"`
	CA                   string          `json:"ca"`
	Price                TLSProductPrice `json:"price"`
	Recommended          bool            `json:"recommended,omitempty"`
	Specs                TLSProductSpecs `json:"specs"`
}

TLSProduct is an orderable certificate product.

type TLSProductPrice added in v0.2.0

type TLSProductPrice struct {
	Yearly float64 `json:"yearly"`
	Daily  float64 `json:"daily"`
}

TLSProductPrice is the account-specific price of a certificate product.

type TLSProductSpecs added in v0.2.0

type TLSProductSpecs struct {
	Seal         bool `json:"seal"`
	SANSupport   bool `json:"san_support"`
	WWWOnApex    bool `json:"www_on_apex"`
	ApexOnWC     bool `json:"apex_on_wc"`
	WCSupport    bool `json:"wc_support"`
	SANWCSupport bool `json:"san_wc_support"`
	MaxSANs      int  `json:"max_sans"`
	MalwareCheck bool `json:"malware_check"`
}

TLSProductSpecs are the capabilities of a certificate product.

type TLSReissue added in v0.2.0

type TLSReissue struct {
	ID            int            `json:"id"`
	Status        string         `json:"status"`
	CommonName    string         `json:"common_name"`
	DNSNames      []string       `json:"dns_names"`
	OrderState    string         `json:"order_state,omitempty"`
	RequestedAt   string         `json:"requested_at,omitempty"`
	LastUpdatedAt string         `json:"last_updated_at,omitempty"`
	Validation    *TLSValidation `json:"validation,omitempty"`
}

TLSReissue is the state of a certificate reissue.

type TLSValidation added in v0.2.0

type TLSValidation struct {
	// Method is DCVMethodDNSCNAMEToken or DCVMethodEmail.
	Method       string                   `json:"method"`
	DNSRecords   []TLSValidationDNSRecord `json:"dns_records,omitempty"`
	EmailTargets []string                 `json:"email_targets,omitempty"`
}

TLSValidation describes how a certificate order is validated.

type TLSValidationDNSRecord added in v0.2.0

type TLSValidationDNSRecord struct {
	Name  string `json:"name"`
	Type  string `json:"type"`
	Value string `json:"value"`
}

TLSValidationDNSRecord is a DNS record that has to be published to complete domain control validation.

type TokenInfo added in v0.2.0

type TokenInfo struct {
	// KeyID is the public key id (the HASH part of the token).
	KeyID string `json:"key_id"`
	// TokenL4 holds the last 4 characters of the token, used as display id.
	TokenL4 string `json:"token_l4"`
	// Permissions is nil for legacy keys with full access, and an empty
	// non-nil slice for an RBAC key that was granted nothing. The distinction
	// is load-bearing; see Kind.
	Permissions []string `json:"permissions"`
	// Scope marks a special-purpose platform credential restricted to a fixed
	// set of operations, e.g. ScopeACMEDNSChallenge. It is nil for ordinary
	// customer keys.
	Scope *string `json:"scope"`
	// CustomerID is the regfish user id the key is scoped to.
	CustomerID int `json:"customer_id"`
}

TokenInfo describes the API key a request authenticated with.

The three kinds of key it can describe — legacy, RBAC and capability-scoped — are distinguished by Kind. Do not read Permissions directly without consulting it: a nil slice and an empty slice mean opposite things, and a capability-scoped key has no permission list at all.

func ParseTokenInfo added in v0.2.0

func ParseTokenInfo(data []byte) (TokenInfo, error)

ParseTokenInfo decodes a /meta/token payload.

Prefer it over a plain json.Unmarshal whenever you rehydrate cached token metadata: encoding/json leaves a field untouched when its member is absent, so a payload that lost its "permissions" member would decode to a nil slice and read as a legacy key with full access. ParseTokenInfo rejects that instead, because an absent list and an explicit null mean opposite things.

TokenInfo itself deliberately has no UnmarshalJSON method: a promoted one would silently swallow the sibling fields of any struct that embeds it.

func (TokenInfo) CheckPermissions added in v0.2.0

func (t TokenInfo) CheckPermissions(permissions ...string) PermissionReport

CheckPermissions compares the key metadata against the permissions a program intends to use. It performs no request; see Client.CheckPermissions.

func (TokenInfo) HasPermission added in v0.2.0

func (t TokenInfo) HasPermission(permission string) bool

HasPermission reports whether the key may use the given permission. Legacy keys without a permission list are treated as having full access.

Note that HasPermission ignores Scope: a capability-scoped platform credential such as an ACME DNS-01 key has no permission list, so HasPermission reports true for every permission while the API refuses all but a handful of operations. It also reports true for a zero TokenInfo. Prefer Permits, which distinguishes both cases.

func (TokenInfo) IsLegacy added in v0.2.0

func (t TokenInfo) IsLegacy() bool

IsLegacy reports whether the key predates RBAC and therefore has full access.

func (TokenInfo) IsScopeLimited added in v0.2.0

func (t TokenInfo) IsScopeLimited() bool

IsScopeLimited reports whether the key is a scope-bound platform credential, restricted by the API to a fixed set of operations whatever its permissions.

func (TokenInfo) Kind added in v0.2.0

func (t TokenInfo) Kind() KeyKind

Kind reports how the API evaluates this key.

Scope wins over Permissions, mirroring the server, where the scope gate runs before the RBAC gate. A capability-scoped key carries no permission list, so testing Permissions first would read it as a legacy full-access key — exactly backwards.

func (TokenInfo) Permits added in v0.2.0

func (t TokenInfo) Permits(permission string) Decision

Permits reports what the library expects the API to decide for permission.

Unlike HasPermission it never claims access it cannot vouch for. A capability-scoped credential must clear the scope gate as well as the permission gate, and the scope gate is not described by any permission, so a permission it does hold yields DecisionUnknown rather than DecisionAllowed.

A permission list is authoritative in the other direction whatever the key's scope: the server runs its RBAC gate on every key that has a list, so a permission the list omits will be refused. That is why an absent permission reports DecisionDenied even for a scoped key.

Permits is advisory. Treat DecisionDenied as "do not bother" and DecisionAllowed as "probably", never as a reason to skip handling a denial.

func (TokenInfo) ScopeName added in v0.2.0

func (t TokenInfo) ScopeName() string

ScopeName returns the key's capability scope, or "" for an ordinary key.

type VanitySet added in v0.2.0

type VanitySet struct {
	ID          int      `json:"id"`
	Host        string   `json:"host"`
	Nameservers []string `json:"nameservers"`
}

VanitySet is a set of vanity nameservers available on the account.

type ZoneCounts added in v0.2.0

type ZoneCounts struct {
	RecordsTotal  int            `json:"records_total"`
	RecordsActive int            `json:"records_active"`
	RecordsAuto   int            `json:"records_auto"`
	RecordsManual int            `json:"records_manual"`
	ByType        map[string]int `json:"by_type"`
}

ZoneCounts breaks down the records of a zone.

type ZoneDelegationNameserver added in v0.2.0

type ZoneDelegationNameserver struct {
	Host string  `json:"host"`
	IPv4 *string `json:"ipv4"`
}

ZoneDelegationNameserver is one of the nameservers a zone is delegated to.

type ZoneDetail added in v0.2.0

type ZoneDetail struct {
	ZoneSummary
	DNSSEC  DNSSEC       `json:"dnssec"`
	Counts  ZoneCounts   `json:"counts"`
	Records []ZoneRecord `json:"records"`
}

ZoneDetail is a zone including its DNSSEC state and all of its records.

type ZoneRecord added in v0.2.0

type ZoneRecord struct {
	ID int `json:"id"`
	// Name is "@" for apex records and fully qualified otherwise.
	Name       string `json:"name"`
	Type       string `json:"type"`
	Data       string `json:"data"`
	Priority   *int   `json:"priority,omitempty"`
	Flags      *int   `json:"flags,omitempty"`
	Tag        string `json:"tag,omitempty"`
	TTL        int    `json:"ttl"`
	Auto       bool   `json:"auto"`
	Active     bool   `json:"active"`
	Annotation string `json:"annotation,omitempty"`
	TSCreated  int64  `json:"ts_created"`
	TSUpdated  int64  `json:"ts_updated"`
}

ZoneRecord is the superset record representation returned by the detailed zone endpoint. Unlike ListRecordsByDomain this includes NS records.

type ZoneSOA added in v0.2.0

type ZoneSOA struct {
	PrimaryNameserver string `json:"primary_nameserver"`
	Mailbox           string `json:"mailbox"`
	Serial            int64  `json:"serial"`
	Refresh           int    `json:"refresh"`
	Retry             int    `json:"retry"`
	Expire            int    `json:"expire"`
	Minimum           int    `json:"minimum"`
	TTL               int    `json:"ttl"`
}

ZoneSOA holds the SOA parameters of a zone.

type ZoneSummary added in v0.2.0

type ZoneSummary struct {
	Domain string `json:"domain"`
	Origin string `json:"origin"`
	Active bool   `json:"active"`
	// Signed reports whether the regfish-hosted zone itself is signed.
	Signed bool `json:"signed"`
	// UsingRegfishNameservers reports whether the domain currently uses
	// regfish authoritative nameservers.
	UsingRegfishNameservers bool                       `json:"using_regfish_nameservers"`
	DelegationNameservers   []ZoneDelegationNameserver `json:"delegation_nameservers"`
	SOA                     ZoneSOA                    `json:"soa"`
	RecordCount             int                        `json:"record_count"`
	// DNSSECState is the high-level status: "active", "pending" or "inactive".
	DNSSECState string `json:"dnssec_state"`
}

ZoneSummary describes a DNS zone without its records.

Directories

Path Synopsis
examples
create-record command
Command create-record adds an A record and deletes it again, showing the basic create/read/delete cycle and how to read an API error.
Command create-record adds an A record and deletes it again, showing the basic create/read/delete cycle and how to read an API error.
permission-check command
Command permission-check inspects the API key and reports whether it can do what a program needs, so a misconfigured key fails at startup instead of during the first write.
Command permission-check inspects the API key and reports whether it can do what a program needs, so a misconfigured key fails at startup instead of during the first write.
resilient-writer command
Command resilient-writer shows the retry loop a long-running process needs.
Command resilient-writer shows the retry loop a long-running process needs.
zone-export command
Command zone-export prints a zone summary and writes the BIND export to stdout.
Command zone-export prints a zone summary and writes the BIND export to stdout.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址