-
Notifications
You must be signed in to change notification settings - Fork 0
/
domains_ns.go
66 lines (53 loc) · 2.02 KB
/
domains_ns.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package porkbun
import "context"
// NameServers represents an array of name server hostnames.
type NameServers []string
// GetNameServersRequest represents the request structure for retrieving name servers.
type GetNameServersRequest struct {
BaseRequest // Embeds the BaseRequest to include API credentials
}
// GetNameServersResponse represents the response structure for retrieving name servers.
type GetNameServersResponse struct {
BaseResponse
NS NameServers `json:"ns"` // An array of name server hostnames
}
// UpdateNameServersRequest represents the request structure for updating name servers.
type UpdateNameServersRequest struct {
BaseRequest
NS NameServers `json:"ns"` // An array of name servers to update the domain with
}
// UpdateNameServersResponse represents the response structure for updating name servers.
type UpdateNameServersResponse struct {
BaseResponse
}
// GetNameServers retrieves the current name servers for the specified domain.
func (s *DomainsService) GetNameServers(ctx context.Context, domain string) (*GetNameServersResponse, error) {
path := domainPath("getNs", domain)
request := &GetNameServersRequest{}
response := &GetNameServersResponse{}
resp, err := s.client.post(ctx, path, request, response)
if err != nil {
return response, err
}
response.HTTPResponse = resp
return response, err
}
// UpdateNameServers updates the name servers for the specified domain.
func (s *DomainsService) UpdateNameServers(ctx context.Context, domain string, newNameservers *NameServers) (*UpdateNameServersResponse, error) {
path := domainPath("updateNs", domain)
request := &UpdateNameServersRequest{
NS: *newNameservers,
}
response := &UpdateNameServersResponse{}
resp, err := s.client.post(ctx, path, request, response)
if err != nil {
return response, err
}
response.HTTPResponse = resp
return response, err
}
// Interface guards to ensure the request types implement ApiKeyAcceptor.
var (
_ ApiKeyAcceptor = (*GetNameServersRequest)(nil)
_ ApiKeyAcceptor = (*UpdateNameServersRequest)(nil)
)