Documentation
¶
Overview ¶
Package dns represents our SiteHost `/dns` API endpoint.
Index ¶
- type AddRecordRequest
- type AddRecordResponse
- type Client
- func (s *Client) AddRecord(ctx context.Context, opts AddRecordRequest) (response AddRecordResponse, err error)
- func (s *Client) CreateZone(ctx context.Context, opts CreateZoneRequest) (response CreateZoneResponse, err error)
- func (s *Client) DeleteRecord(ctx context.Context, opts DeleteRecordRequest) (response models.APIResponse, err error)
- func (s *Client) DeleteZone(ctx context.Context, request DeleteZoneRequest) (response models.APIResponse, err error)
- func (s *Client) GetRecord(ctx context.Context, request RecordRequest) (response models.DNSRecord, err error)
- func (s *Client) GetRecordWithRecord(ctx context.Context, request models.DNSRecord) (response models.DNSRecord, err error)deprecated
- func (s *Client) GetRecordWithType(ctx context.Context, request RecordRequest) (response []models.DNSRecord, err error)
- func (s *Client) GetZone(ctx context.Context, request GetZoneRequest) (response GetZoneResponse, err error)
- func (s *Client) ListIPs(ctx context.Context) (response ListIPsResponse, err error)
- func (s *Client) ListRecords(ctx context.Context, request ListRecordsRequest) (response ListRecordsResponse, err error)
- func (s *Client) ListZones(ctx context.Context, opt *ListZoneOptions) (response ListZoneResponse, err error)
- func (s *Client) ResetReverseDNS(ctx context.Context, request ResetReverseDNSRequest) (response models.APIResponse, err error)
- func (s *Client) UpdateRecord(ctx context.Context, opts UpdateRecordRequest) (response models.APIResponse, err error)
- func (s *Client) UpdateReverseDNS(ctx context.Context, request UpdateReverseDNSRequest) (response models.APIResponse, err error)
- func (s *Client) UpdateSOA(ctx context.Context, request UpdateSOARequest) (response models.APIResponse, err error)
- type CreateZoneRequest
- type CreateZoneResponse
- type DeleteRecordRequest
- type DeleteZoneRequest
- type GetZoneRequest
- type GetZoneResponse
- type IPInfo
- type ListIPsResponse
- type ListRecordsRequest
- type ListRecordsResponse
- type ListZoneOptions
- type ListZoneResponse
- type RecordRequest
- type ResetReverseDNSRequest
- type ReverseDNSResponse
- type UpdateRecordRequest
- type UpdateReverseDNSRequest
- type UpdateSOARequest
- type UpdateSOAResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddRecordRequest ¶
type AddRecordRequest struct {
ClientID string `json:"client_id"`
Domain string `json:"domain"`
Type string `json:"type"`
Name string `json:"name"`
Content string `json:"content"`
Priority string `json:"prio"`
}
AddRecordRequest represents a request to create a DNSRecord.
type AddRecordResponse ¶ added in v0.4.0
type AddRecordResponse struct {
Return struct {
ID string `json:"id"`
} `json:"return"`
models.APIResponse
}
AddRecordResponse is the return for adding a cloud database.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Service to work with SiteHost API.
func (*Client) AddRecord ¶
func (s *Client) AddRecord(ctx context.Context, opts AddRecordRequest) (response AddRecordResponse, err error)
AddRecord adds a new record to the DNS for a domain. This function takes a context.Context and an AddRecordRequest struct as input parameters. It returns an APIResponse struct and an error.
func (*Client) CreateZone ¶
func (s *Client) CreateZone(ctx context.Context, opts CreateZoneRequest) (response CreateZoneResponse, err error)
CreateZone creates a new DNS zone with the specified domain name. This function takes a context.Context and a CreateZoneRequest struct as input parameters. It returns a CreateZoneResponse struct and an error.
func (*Client) DeleteRecord ¶
func (s *Client) DeleteRecord(ctx context.Context, opts DeleteRecordRequest) (response models.APIResponse, err error)
DeleteRecord deletes a record from the DNS for a domain. This function takes a context.Context and a DeleteRecordRequest struct as input parameters. It returns an APIResponse struct and an error.
func (*Client) DeleteZone ¶
func (s *Client) DeleteZone(ctx context.Context, request DeleteZoneRequest) (response models.APIResponse, err error)
DeleteZone deletes an existing DNS zone with the specified domain name. It takes a context.Context and a DeleteZoneRequest struct as input parameters. It returns a models.APIResponse pointer and an error.
func (*Client) GetRecord ¶ added in v0.3.2
func (s *Client) GetRecord(ctx context.Context, request RecordRequest) (response models.DNSRecord, err error)
GetRecord returns a record by id.
func (*Client) GetRecordWithRecord
deprecated
added in
v0.3.2
func (s *Client) GetRecordWithRecord(ctx context.Context, request models.DNSRecord) (response models.DNSRecord, err error)
GetRecordWithRecord is a special case, for mainly when we are creating records where we need to get back what we just created.
Deprecated: This is only needed for older versions of the Terraform provider as we now get a record ID back.
func (*Client) GetRecordWithType ¶ added in v0.3.2
func (s *Client) GetRecordWithType(ctx context.Context, request RecordRequest) (response []models.DNSRecord, err error)
GetRecordWithType gets the record and filter based on type, as we often want to deal with the records of a specific type, mainly for use in external contexts, ie: terrorform.
func (*Client) GetZone ¶
func (s *Client) GetZone(ctx context.Context, request GetZoneRequest) (response GetZoneResponse, err error)
GetZone searches for a domain in the DNS made easy service by sending a request with a query containing the domain name. If the response contains any matching domain, it returns it as part of the GetZoneResponse. If the response is empty, a control to handle this case is missing and should be added.
func (*Client) ListIPs ¶ added in v0.7.0
func (s *Client) ListIPs(ctx context.Context) (response ListIPsResponse, err error)
ListIPs retrieves the IP allocations associated with the authenticated client via "dns/list_ips.json". The response is a map keyed by IP address; each entry includes addressing details (netmask, prefix, address family), the allocated server, and rDNS.
func (*Client) ListRecords ¶
func (s *Client) ListRecords(ctx context.Context, request ListRecordsRequest) (response ListRecordsResponse, err error)
ListRecords returns a list of DNS records for the specified domain. This function takes a context.Context and a ListRecordsRequest struct as input parameters. It returns a ListRecordsResponse struct and an error.
func (*Client) ListZones ¶
func (s *Client) ListZones(ctx context.Context, opt *ListZoneOptions) (response ListZoneResponse, err error)
ListZones retrieves a list of all DNS zones associated with the client's account, optionally filtering by specified parameters in ListZoneOptions. It returns a pointer to a slice of DNSZone objects and an error if any.
func (*Client) ResetReverseDNS ¶ added in v0.7.0
func (s *Client) ResetReverseDNS(ctx context.Context, request ResetReverseDNSRequest) (response models.APIResponse, err error)
ResetReverseDNS clears any custom PTR record for an IP via /dns/reset_reverse_dns.json, returning the IP to the platform default RDNS.
**Live finding** (May 2026): the API may reject this call with "You do not have access to this IP address" even when the same client_id can successfully UpdateReverseDNS the same IP — the access check is asymmetric between the two endpoints. Workaround: call UpdateReverseDNS with the platform default form (e.g. "<dashed-ip>.sitehost.co.nz") instead of attempting a reset.
func (*Client) UpdateRecord ¶
func (s *Client) UpdateRecord(ctx context.Context, opts UpdateRecordRequest) (response models.APIResponse, err error)
UpdateRecord updates an existing DNS record for a domain. This function takes a context.Context and an UpdateRecordRequest struct as input parameters. It returns an APIResponse struct and an error.
func (*Client) UpdateReverseDNS ¶ added in v0.7.0
func (s *Client) UpdateReverseDNS(ctx context.Context, request UpdateReverseDNSRequest) (response models.APIResponse, err error)
UpdateReverseDNS sets the PTR record for an IP address via /dns/update_reverse_dns.json. Both the IP and the desired RDNS hostname are required.
func (*Client) UpdateSOA ¶ added in v0.7.0
func (s *Client) UpdateSOA(ctx context.Context, request UpdateSOARequest) (response models.APIResponse, err error)
UpdateSOA updates the SOA (Start of Authority) record for a hosted zone via /dns/update_soa.json.
All fields are required by the API. NS is the primary nameserver, Email is the SOA contact (in @-separated form, not the dot-encoded BIND form), and Refresh / Retry / Expire / Minimum are the TTL fields in seconds.
type CreateZoneRequest ¶
type CreateZoneRequest struct {
DomainName string `json:"name"`
}
CreateZoneRequest represents a request to create a DNSZone (domain).
type CreateZoneResponse ¶
type CreateZoneResponse struct {
Return struct {
IsMigration bool `json:"is_migration"`
} `json:"return"`
models.APIResponse
}
CreateZoneResponse represents a request to create a DNSZone (domain).
type DeleteRecordRequest ¶
type DeleteRecordRequest struct {
ClientID string `json:"client_id"`
Domain string `json:"domain"`
RecordID string `json:"record_id"`
}
DeleteRecordRequest represents a request to delete a DNSRecord.
type DeleteZoneRequest ¶
type DeleteZoneRequest struct {
DomainName string `json:"name"`
}
DeleteZoneRequest represents a request to delete a DNSZone.
type GetZoneRequest ¶
type GetZoneRequest struct {
DomainName string `json:"name"`
}
GetZoneRequest represents a request to get a DNSZone.
type GetZoneResponse ¶
type GetZoneResponse struct {
Return []models.DNSZone `json:"return"`
models.APIResponse
}
GetZoneResponse represents a request to get a DNSZone (domain). search_domains returns matching DNSZone summaries; only Name, ClientID, and TemplateID are populated (Pending is returned by list_domains but not by search_domains).
type IPInfo ¶ added in v0.7.0
type IPInfo struct {
IPAddr string `json:"ip_addr"`
Netmask string `json:"netmask"`
Prefix string `json:"prefix"`
Reserved string `json:"reserved"`
RDNS string `json:"rdns"`
AddrFamily string `json:"addr_family"`
DateAllocated string `json:"date_allocated"`
ServerID string `json:"server_id"`
Name string `json:"name"`
Label string `json:"label"`
IsPrimary string `json:"is_primary"`
IPType string `json:"ip_type"`
}
IPInfo describes a single IP allocation as returned by list_ips. String-typed numeric / boolean fields ("0"/"1", "32", "128") reflect the API's actual response shape; consumers should convert as needed.
type ListIPsResponse ¶ added in v0.7.0
type ListIPsResponse struct {
Return map[string]IPInfo `json:"return"`
models.APIResponse
}
ListIPsResponse represents the response from list_ips. The Return map is keyed by the IP address (as a string) — the same string is also present as IPAddr inside each entry.
**Wire-shape quirk** (verified live): when the account has no allocated IPs, "return" is the JSON array `[]`, not the empty object `{}`. Custom UnmarshalJSON tolerates both forms.
func (*ListIPsResponse) UnmarshalJSON ¶ added in v0.7.0
func (r *ListIPsResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON tolerates the empty-array form the API returns when the account has no allocated IPs. See type comment.
type ListRecordsRequest ¶
type ListRecordsRequest struct {
Domain string `json:"domain"`
}
ListRecordsRequest represents a request to list DNSRecords.
type ListRecordsResponse ¶
type ListRecordsResponse struct {
Return []models.DNSRecord `json:"return"`
models.APIResponse
}
ListRecordsResponse represents a response from the ListRecords method.
type ListZoneOptions ¶
type ListZoneOptions struct {
Domain string `url:"filters[domain],omitempty"`
SortBy string `url:"filters[sort_by],omitempty"`
SortDir string `url:"filters[sort_dir],omitempty"`
PageSize int `url:"filters[page_size],omitempty"`
PageNumber int `url:"filters[page_number],omitempty"`
}
ListZoneOptions represents a request to list DNSZones.
type ListZoneResponse ¶
type ListZoneResponse struct {
Return struct {
models.Pagination
Data []models.DNSZone `json:"data"`
} `json:"return"`
models.APIResponse
}
ListZoneResponse represents a request to list all DNSZones (domains).
type RecordRequest ¶
type RecordRequest struct {
ID string `json:"id"`
RRType string `json:"rr_type"`
DomainName string `json:"name"`
}
RecordRequest represents a request to get a DNSRecord.
type ResetReverseDNSRequest ¶ added in v0.7.0
type ResetReverseDNSRequest struct {
IPAddr string `json:"ip_addr"`
}
ResetReverseDNSRequest clears any custom PTR for an IP, returning it to the platform default.
type ReverseDNSResponse ¶ added in v0.7.0
type ReverseDNSResponse struct {
models.APIResponse
}
ReverseDNSResponse is the response shape for the reset_reverse_dns and update_reverse_dns endpoints. Both are synchronous.
type UpdateRecordRequest ¶
type UpdateRecordRequest struct {
ClientID string `json:"client_id"`
Domain string `json:"domain"`
RecordID string `json:"record_id"`
Type string `json:"type"`
Name string `json:"name"`
Content string `json:"content"`
Priority string `json:"prio"`
}
UpdateRecordRequest represents a request to update a DNSRecord.
type UpdateReverseDNSRequest ¶ added in v0.7.0
type UpdateReverseDNSRequest struct {
IPAddr string `json:"ip_addr"`
// RDNS is the desired reverse-DNS hostname
// (e.g. "192-168-1-105.sitehost.co.nz").
RDNS string `json:"rdns"`
}
UpdateReverseDNSRequest sets the PTR record for an IP.
type UpdateSOARequest ¶ added in v0.7.0
type UpdateSOARequest struct {
// Domain is the zone whose SOA to replace (e.g. "example.nz").
Domain string `json:"domain"`
// NS is the primary nameserver (e.g. "ns1.sitehost.co.nz").
NS string `json:"ns"`
// Email is the SOA contact in @-separated form
// (e.g. "support@sitehost.co.nz") — the API converts to the
// dot-encoded BIND form internally.
Email string `json:"email"`
// Refresh / Retry / Expire / Minimum are TTL values in seconds.
Refresh int `json:"refresh"`
Retry int `json:"retry"`
Expire int `json:"expire"`
Minimum int `json:"minimum"`
}
UpdateSOARequest configures the new SOA values for a hosted zone. All fields are required by the API.
type UpdateSOAResponse ¶ added in v0.7.0
type UpdateSOAResponse struct {
models.APIResponse
}
UpdateSOAResponse is returned by update_soa. Synchronous; only models.APIResponse status fields populate.