feat(api): endpoints to mark and unmark custom records

This commit is contained in:
2026-08-19 18:10:46 +07:00
parent 208e73980d
commit da267b3cef
5 changed files with 211 additions and 2 deletions
+14 -1
View File
@@ -44,6 +44,13 @@ type applyRequest struct {
Prunes []string `json:"prunes"`
}
// customRequest is the body of POST .../customs — the key travels here
// (never as a path segment) because it contains a space and dots, e.g.
// "CNAME admin.example.com.".
type customRequest struct {
Key string `json:"key"`
}
type recordView struct {
Key string `json:"key"`
Kind string `json:"kind"`
@@ -52,17 +59,19 @@ type recordView struct {
Desired []string `json:"desired,omitempty"`
Actual []string `json:"actual,omitempty"`
ReadOnly bool `json:"readOnly"`
Custom bool `json:"custom"`
}
type changesetResponse struct {
Updates []recordView `json:"updates"`
Prunes []recordView `json:"prunes"`
Customs []recordView `json:"customs"`
ReadOnly []recordView `json:"readOnly"`
InSync int `json:"inSyncCount"`
}
func toRecordView(d diff.RecordDiff) recordView {
rv := recordView{Key: d.Key(), Kind: string(d.Kind), Type: string(d.Type), Name: d.Name, ReadOnly: d.ReadOnly}
rv := recordView{Key: d.Key(), Kind: string(d.Kind), Type: string(d.Type), Name: d.Name, ReadOnly: d.ReadOnly, Custom: d.Custom}
if d.Desired != nil {
rv.Desired = d.Desired.Values
}
@@ -80,6 +89,7 @@ func toChangesetResponse(cs diff.Changeset) changesetResponse {
resp := changesetResponse{
Updates: []recordView{},
Prunes: []recordView{},
Customs: []recordView{},
ReadOnly: []recordView{},
}
for _, d := range cs.Updates() {
@@ -88,6 +98,9 @@ func toChangesetResponse(cs diff.Changeset) changesetResponse {
for _, d := range cs.Prunes() {
resp.Prunes = append(resp.Prunes, toRecordView(d))
}
for _, d := range cs.Customs() {
resp.Customs = append(resp.Customs, toRecordView(d))
}
for _, d := range cs.Diffs {
if d.ReadOnly {
resp.ReadOnly = append(resp.ReadOnly, toRecordView(d))