Archived
Remove unsupported location field from DNS record resource
This commit is contained in:
@@ -106,7 +106,6 @@ type DNSRecord struct {
|
||||
UpdatedOn string `json:"updatedOn"`
|
||||
Group string `json:"group"`
|
||||
Host string `json:"host"`
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
type CreateDNSRecordRequest struct {
|
||||
@@ -117,7 +116,6 @@ type CreateDNSRecordRequest struct {
|
||||
State *bool `json:"state,omitempty"`
|
||||
Group string `json:"group,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Location string `json:"location,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateDNSRecordRequest struct {
|
||||
@@ -128,7 +126,6 @@ type UpdateDNSRecordRequest struct {
|
||||
State *bool `json:"state,omitempty"`
|
||||
Group string `json:"group,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Location string `json:"location,omitempty"`
|
||||
}
|
||||
|
||||
type listDomainsResponse struct {
|
||||
@@ -210,7 +207,7 @@ func (c *Client) GetDNSRecord(ctx context.Context, domainID int64, recordID int6
|
||||
|
||||
func (c *Client) CreateDNSRecord(ctx context.Context, domainID int64, req CreateDNSRecordRequest) (*DNSRecord, error) {
|
||||
var resp getDNSRecordResponse
|
||||
if err := c.doRequest(ctx, http.MethodPost, fmt.Sprintf("/dns/%d/record", domainID), buildDNSRecordUpsertPayload(req.RecordType, req.NodeName, req.Content, req.TTL, req.State, req.Group, req.Host, req.Location), &resp); err != nil {
|
||||
if err := c.doRequest(ctx, http.MethodPost, fmt.Sprintf("/dns/%d/record", domainID), buildDNSRecordUpsertPayload(req.RecordType, req.NodeName, req.Content, req.TTL, req.State, req.Group, req.Host), &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
normalizeDNSRecord(&resp.DNSRecord)
|
||||
@@ -219,7 +216,7 @@ func (c *Client) CreateDNSRecord(ctx context.Context, domainID int64, req Create
|
||||
|
||||
func (c *Client) UpdateDNSRecord(ctx context.Context, domainID int64, recordID int64, req UpdateDNSRecordRequest) (*DNSRecord, error) {
|
||||
var resp getDNSRecordResponse
|
||||
if err := c.doRequest(ctx, http.MethodPost, fmt.Sprintf("/dns/%d/record/%d", domainID, recordID), buildDNSRecordUpsertPayload(req.RecordType, req.NodeName, req.Content, req.TTL, req.State, req.Group, req.Host, req.Location), &resp); err != nil {
|
||||
if err := c.doRequest(ctx, http.MethodPost, fmt.Sprintf("/dns/%d/record/%d", domainID, recordID), buildDNSRecordUpsertPayload(req.RecordType, req.NodeName, req.Content, req.TTL, req.State, req.Group, req.Host), &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
normalizeDNSRecord(&resp.DNSRecord)
|
||||
@@ -322,10 +319,9 @@ type dnsRecordUpsertPayload struct {
|
||||
State *bool `json:"state,omitempty"`
|
||||
Group string `json:"group,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Location string `json:"location,omitempty"`
|
||||
}
|
||||
|
||||
func buildDNSRecordUpsertPayload(recordType string, nodeName string, content *string, ttl int64, state *bool, group string, host string, location string) dnsRecordUpsertPayload {
|
||||
func buildDNSRecordUpsertPayload(recordType string, nodeName string, content *string, ttl int64, state *bool, group string, host string) dnsRecordUpsertPayload {
|
||||
normalizedType := strings.ToUpper(strings.TrimSpace(recordType))
|
||||
normalizedContent := normalizeOptionalContent(content)
|
||||
payload := dnsRecordUpsertPayload{
|
||||
@@ -335,7 +331,6 @@ func buildDNSRecordUpsertPayload(recordType string, nodeName string, content *st
|
||||
State: state,
|
||||
Group: group,
|
||||
Host: host,
|
||||
Location: location,
|
||||
}
|
||||
|
||||
switch normalizedType {
|
||||
@@ -351,10 +346,8 @@ func buildDNSRecordUpsertPayload(recordType string, nodeName string, content *st
|
||||
if normalizedContent != nil {
|
||||
payload.Host = *normalizedContent
|
||||
}
|
||||
payload.Location = ""
|
||||
default:
|
||||
payload.Content = normalizedContent
|
||||
payload.Location = ""
|
||||
}
|
||||
|
||||
return payload
|
||||
|
||||
Reference in New Issue
Block a user