Add label support

This commit is contained in:
Rolf Ahrenberg
2021-01-04 13:08:58 +02:00
parent 8018b54627
commit f86dd2723a
4 changed files with 23 additions and 2 deletions

View File

@@ -434,7 +434,7 @@ func (api *API) CreatePage(
}
func (api *API) UpdatePage(
page *PageInfo, newContent string,
page *PageInfo, newContent string, newLabels []string,
) error {
nextPageVersion := page.Version.Number + 1
@@ -450,6 +450,17 @@ func (api *API) UpdatePage(
{"id": page.Ancestors[len(page.Ancestors)-1].Id},
}
labels := []map[string]interface{}{}
for _, label := range newLabels {
if label != "" {
item := map[string]interface{}{
"prexix": "global",
"name": label,
}
labels = append(labels, item)
}
}
payload := map[string]interface{}{
"id": page.ID,
"type": "page",
@@ -465,6 +476,9 @@ func (api *API) UpdatePage(
"representation": "storage",
},
},
"metadata": map[string]interface{}{
"labels": labels,
},
}
request, err := api.rest.Res(