Documentation
¶
Overview ¶
Package template represents our SiteHost `/dns/domain_templates` API endpoint.
Index ¶
- type AddRecordRequest
- type Client
- func (s *Client) AddRecord(ctx context.Context, request AddRecordRequest) (response models.APIResponse, err error)
- func (s *Client) CloneTemplate(ctx context.Context, request CloneTemplateRequest) (response CloneTemplateResponse, err error)
- func (s *Client) CreateTemplate(ctx context.Context, request CreateTemplateRequest) (response CreateTemplateResponse, err error)
- func (s *Client) DeleteRecord(ctx context.Context, request DeleteRecordRequest) (response models.APIResponse, err error)
- func (s *Client) DeleteTemplate(ctx context.Context, request DeleteTemplateRequest) (response models.APIResponse, err error)
- func (s *Client) Get(ctx context.Context, request GetRequest) (response GetResponse, err error)
- func (s *Client) List(ctx context.Context) (response ListResponse, err error)
- func (s *Client) ListRecords(ctx context.Context, request ListRecordsRequest) (response ListRecordsResponse, err error)
- func (s *Client) SearchTemplates(ctx context.Context, request SearchTemplatesRequest) (response SearchTemplatesResponse, err error)
- func (s *Client) UpdateDomain(ctx context.Context, request UpdateDomainRequest) (response UpdateDomainResponse, err error)
- func (s *Client) UpdateDomainDNS(ctx context.Context, request UpdateDomainDNSRequest) (response JobResponse, err error)
- func (s *Client) UpdateRecord(ctx context.Context, request UpdateRecordRequest) (response models.APIResponse, err error)
- func (s *Client) UpdateTemplate(ctx context.Context, request UpdateTemplateRequest) (response models.APIResponse, err error)
- func (s *Client) UpdateTemplateDNS(ctx context.Context, request UpdateTemplateDNSRequest) (response JobResponse, err error)
- type CloneTemplateRequest
- type CloneTemplateResponse
- type CreateTemplateRequest
- type CreateTemplateResponse
- type DeleteRecordRequest
- type DeleteTemplateRequest
- type DomainTemplate
- type GetRequest
- type GetResponse
- type JobResponse
- type ListRecordsRequest
- type ListRecordsResponse
- type ListResponse
- type Record
- type SearchResult
- type SearchTemplatesRequest
- type SearchTemplatesResponse
- type TemplateDetails
- type UpdateDomainDNSRequest
- type UpdateDomainRequest
- type UpdateDomainResponse
- type UpdateRecordRequest
- type UpdateTemplateDNSRequest
- type UpdateTemplateRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddRecordRequest ¶
type AddRecordRequest struct {
TemplateID string
Type string
Name string
Content string
Priority int
}
AddRecordRequest adds a record to a template. Type is one of the documented enum: A, AAAA, NS, MX, PTR, SRV, TXT, CNAME. Priority is only meaningful for MX/SRV; pass 0 otherwise.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Service to work with DNS Domain Templates.
func (*Client) AddRecord ¶
func (s *Client) AddRecord(ctx context.Context, request AddRecordRequest) (response models.APIResponse, err error)
AddRecord adds a record to a template via /dns/domain_templates/add_record.json.
Type must be one of: A, AAAA, NS, MX, PTR, SRV, TXT, CNAME. Priority is only meaningful for MX/SRV; pass 0 otherwise.
func (*Client) CloneTemplate ¶
func (s *Client) CloneTemplate(ctx context.Context, request CloneTemplateRequest) (response CloneTemplateResponse, err error)
CloneTemplate duplicates an existing template under a new name via /dns/domain_templates/clone_template.json. The clone inherits records and SOA defaults from the source template.
func (*Client) CreateTemplate ¶
func (s *Client) CreateTemplate(ctx context.Context, request CreateTemplateRequest) (response CreateTemplateResponse, err error)
CreateTemplate registers a new DNS domain template via /dns/domain_templates/create_template.json. Name is required; the rest of the fields configure SOA defaults applied to every domain linked to the template.
Note the capitalised params[Nameserver] / params[Email] etc. — matches the API's published parameter casing.
Empirical floor: Min must be ≥ 3600 (1 hour). The API rejects lower values with "Please specify a valid minimum value above 3600 (1 hour)." even though the public docs only list 3600 as an example value, not a documented floor.
func (*Client) DeleteRecord ¶
func (s *Client) DeleteRecord(ctx context.Context, request DeleteRecordRequest) (response models.APIResponse, err error)
DeleteRecord removes one record from a template via /dns/domain_templates/delete_record.json.
func (*Client) DeleteTemplate ¶
func (s *Client) DeleteTemplate(ctx context.Context, request DeleteTemplateRequest) (response models.APIResponse, err error)
DeleteTemplate removes a template via /dns/domain_templates/delete_template.json. The API rejects the call if any domain is still linked to the template — unlink them first via UpdateDomain.
func (*Client) Get ¶
func (s *Client) Get(ctx context.Context, request GetRequest) (response GetResponse, err error)
Get fetches one template's metadata + SOA defaults via /dns/domain_templates/get_template.json.
The endpoint returns a single-element array; consumers typically just want response.Return[0].
func (*Client) List ¶
func (s *Client) List(ctx context.Context) (response ListResponse, err error)
List retrieves all DNS domain templates available to the authenticated client. It uses the "dns/domain_templates/list_templates.json" API endpoint.
The endpoint is documented at https://docs.sitehost.nz/api/v1.5/?path=/dns (the parent /dns index lists it; the per-endpoint reference page is sparse at the time of writing — field shapes here mirror what the production API returns).
func (*Client) ListRecords ¶
func (s *Client) ListRecords(ctx context.Context, request ListRecordsRequest) (response ListRecordsResponse, err error)
ListRecords lists every record under a template via /dns/domain_templates/list_records.json.
func (*Client) SearchTemplates ¶
func (s *Client) SearchTemplates(ctx context.Context, request SearchTemplatesRequest) (response SearchTemplatesResponse, err error)
SearchTemplates fuzzy-matches templates by name via /dns/domain_templates/search_templates.json. TemplateName is required; Offset and Limit are optional pagination knobs.
Results from SearchTemplates have a different shape than ListTemplates — no template_id field, SOA defaults inline. See SearchResult.
Empirical: matching appears to be **exact** on template_name, not the substring / fuzzy match the docs' phrasing implies. Searching for "gosh-example-" doesn't return templates named "gosh-example-abc12345"; only the full-name query does. Treat this as a lookup by exact name until the API contract clarifies.
func (*Client) UpdateDomain ¶
func (s *Client) UpdateDomain(ctx context.Context, request UpdateDomainRequest) (response UpdateDomainResponse, err error)
UpdateDomain points a domain at a different template via /dns/domain_templates/update_domain.json. Pass TemplateID="" to unlink the domain entirely (it then keeps its current zone but no longer tracks any template).
func (*Client) UpdateDomainDNS ¶
func (s *Client) UpdateDomainDNS(ctx context.Context, request UpdateDomainDNSRequest) (response JobResponse, err error)
UpdateDomainDNS forces a rebuild of one domain's zone from its currently-linked template via /dns/domain_templates/update_domain_dns.json. Returns a scheduler job; poll /job/get to track completion.
Useful after editing a template's records, when you want the change applied to a specific domain immediately rather than waiting for the bulk UpdateTemplateDNS rebuild.
func (*Client) UpdateRecord ¶
func (s *Client) UpdateRecord(ctx context.Context, request UpdateRecordRequest) (response models.APIResponse, err error)
UpdateRecord replaces a template record in-place via /dns/domain_templates/update_record.json. All fields required.
func (*Client) UpdateTemplate ¶
func (s *Client) UpdateTemplate(ctx context.Context, request UpdateTemplateRequest) (response models.APIResponse, err error)
UpdateTemplate renames an existing template via /dns/domain_templates/update_template.json. Only the name is editable here; SOA-default changes need a recreate or UpdateTemplateDNS to rebuild zones.
func (*Client) UpdateTemplateDNS ¶
func (s *Client) UpdateTemplateDNS(ctx context.Context, request UpdateTemplateDNSRequest) (response JobResponse, err error)
UpdateTemplateDNS forces a rebuild of every domain linked to the given template via /dns/domain_templates/update_template_dns.json. Returns a scheduler job that may take a while if the template has many linked domains.
The bulk equivalent of UpdateDomainDNS — use this after editing records on a template when you want the change applied to every domain it serves.
type CloneTemplateRequest ¶
CloneTemplateRequest duplicates an existing template under a new name. The clone inherits records and SOA defaults.
type CloneTemplateResponse ¶
type CloneTemplateResponse struct {
Return struct {
TemplateID string `json:"template_id"`
} `json:"return"`
models.APIResponse
}
CloneTemplateResponse — clone_template returns the new template's id (lowercase key per the API).
type CreateTemplateRequest ¶
type CreateTemplateRequest struct {
Name string
Nameserver string
Email string
Refresh int
Retry int
Expire int
Min int
}
CreateTemplateRequest registers a new template. Name is the only strictly-required field; the rest configure the SOA defaults applied to every domain linked to the template. Refresh / Retry / Expire / Min are TTL values in seconds.
type CreateTemplateResponse ¶
type CreateTemplateResponse struct {
Return struct {
TemplateID string `json:"TemplateID"`
} `json:"return"`
models.APIResponse
}
CreateTemplateResponse — create_template returns the new template's id (capitalised key per the API).
type DeleteRecordRequest ¶
DeleteRecordRequest removes one record from a template.
type DeleteTemplateRequest ¶
type DeleteTemplateRequest struct {
TemplateID string
}
DeleteTemplateRequest removes a template. The API rejects the call if any domain is still linked to it.
type DomainTemplate ¶
type DomainTemplate struct {
ClientID string `json:"client_id"`
TemplateID string `json:"template_id"`
TemplateName string `json:"template_name"`
DomainCount string `json:"domain_count"`
}
DomainTemplate is a single DNS domain template entry as returned by ListTemplates / SearchTemplates.
type GetRequest ¶
type GetRequest struct {
TemplateID string
}
GetRequest fetches one template's metadata + SOA defaults.
TemplateID is a string because the API accepts and returns it that way (e.g. "0", "855") and template_id "0" is the real "Manual DNS Settings" platform-shared template — typing it as int and rejecting the zero value would block legitimate calls.
type GetResponse ¶
type GetResponse struct {
Return []TemplateDetails `json:"return"`
models.APIResponse
}
GetResponse — get_template returns an array, but in practice always with a single element.
type JobResponse ¶
type JobResponse struct {
Return struct {
models.Job `json:"job"`
} `json:"return"`
models.APIResponse
}
JobResponse — shared shape for the async DNS-rebuild endpoints (UpdateDomainDNS, UpdateTemplateDNS).
type ListRecordsRequest ¶
type ListRecordsRequest struct {
TemplateID string
}
ListRecordsRequest lists every record under a template.
type ListRecordsResponse ¶
type ListRecordsResponse struct {
Return []Record `json:"return"`
models.APIResponse
}
ListRecordsResponse — list_records.
type ListResponse ¶
type ListResponse struct {
Return []DomainTemplate `json:"return"`
models.APIResponse
}
ListResponse — list_templates.
type Record ¶
type Record struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Content string `json:"content"`
Priority string `json:"prio"`
ChangeDate string `json:"change_date"`
}
Record is a single DNS record under a template.
type SearchResult ¶
type SearchResult struct {
ClientID string `json:"client_id"`
TemplateName string `json:"template_name"`
Nameserver string `json:"nameserver"`
Email string `json:"email"`
Refresh string `json:"refresh"`
Retry string `json:"retry"`
Expire string `json:"expire"`
Min string `json:"min"`
}
SearchResult is a single hit from SearchTemplates. Note the shape differs from ListTemplates / GetTemplate: no ID field, SOA defaults inline.
type SearchTemplatesRequest ¶
SearchTemplatesRequest fuzzy-matches templates by name. Offset / Limit are optional pagination knobs; both default to the API default when zero.
type SearchTemplatesResponse ¶
type SearchTemplatesResponse struct {
Return []SearchResult `json:"return"`
models.APIResponse
}
SearchTemplatesResponse — search_templates.
type TemplateDetails ¶
type TemplateDetails struct {
TemplateID string `json:"template_id"`
ClientID string `json:"client_id"`
TemplateName string `json:"template_name"`
Nameserver string `json:"nameserver"`
Email string `json:"email"`
Refresh string `json:"refresh"`
Retry string `json:"retry"`
Expire string `json:"expire"`
Min string `json:"min"`
DomainCount string `json:"domain_count"`
}
TemplateDetails carries the full metadata + SOA defaults for a single template, returned by GetTemplate. Fields are strings to match the API's stringly-typed numerics.
type UpdateDomainDNSRequest ¶
type UpdateDomainDNSRequest struct {
Domain string
}
UpdateDomainDNSRequest forces a rebuild of one domain's zone from its currently-linked template. Returns a scheduler job.
type UpdateDomainRequest ¶
UpdateDomainRequest points a domain at a different template (or unlinks it by passing TemplateID="").
type UpdateDomainResponse ¶
type UpdateDomainResponse struct {
Return bool `json:"return"`
models.APIResponse
}
UpdateDomainResponse — update_domain returns a bare bool in `return` plus the standard {msg, status} envelope.
type UpdateRecordRequest ¶
type UpdateRecordRequest struct {
TemplateID string
RecordID int
Type string
Name string
Content string
Priority int
}
UpdateRecordRequest replaces a record in-place. All fields are required.
type UpdateTemplateDNSRequest ¶
type UpdateTemplateDNSRequest struct {
TemplateID string
}
UpdateTemplateDNSRequest forces a rebuild of every domain linked to the given template. Returns a scheduler job.
type UpdateTemplateRequest ¶
UpdateTemplateRequest renames an existing template. The API only documents `new_name` as updatable here; for SOA-default edits, recreate or use UpdateTemplateDNS to rebuild zones.