-
Notifications
You must be signed in to change notification settings - Fork 0
/
confluence.go
47 lines (39 loc) · 915 Bytes
/
confluence.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
package main
import (
goconfluence "github.com/virtomize/confluence-go-api"
)
// UpdateContents is login confluence and update wiki page
func UpdateContents(url, user, pass, title, id, space, table string) (int, error) {
api, err := goconfluence.NewAPI(url, user, pass)
if err != nil {
return 0, err
}
c, err := api.GetContentByID(id, goconfluence.ContentQuery{})
if err != nil {
return 0, err
}
curVersion := c.Version.Number
newVersion := curVersion + 1
data := &goconfluence.Content{
ID: id,
Type: "page",
Title: title,
Body: goconfluence.Body{
Storage: goconfluence.Storage{
Value: table,
Representation: "storage",
},
},
Version: &goconfluence.Version{
Number: newVersion,
},
Space: &goconfluence.Space{
Key: space,
},
}
content, err := api.UpdateContent(data)
if err != nil {
return 0, err
}
return content.Version.Number, nil
}