Returns the labels on a piece of content.
package main
import (
"context"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
atlassian, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
atlassian.Auth.SetBasicAuth(mail, token)
atlassian.Auth.SetUserAgent("curl/7.54.0")
var (
contentID = "80412692"
prefix = ""
startAt = 0
maxResults = 50
)
labels, response, err := atlassian.Content.Label.Gets(context.Background(), contentID, prefix, startAt, maxResults)
if err != nil {
log.Println(response.Endpoint)
log.Println(response.Bytes.String())
log.Fatal(err)
}
for _, label := range labels.Results {
log.Println(label)
}
}
Adds labels to a piece of content. It does not modify the existing labels.
package main
import (
"context"
"github.com/ctreminiom/go-atlassian/confluence"
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
atlassian, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
atlassian.Auth.SetBasicAuth(mail, token)
atlassian.Auth.SetUserAgent("curl/7.54.0")
var (
contentID = "80412692"
payload = []*models.ContentLabelPayloadScheme{
{
Prefix: "global",
Name: "label-02",
},
}
)
labels, response, err := atlassian.Content.Label.Add(context.Background(), contentID, payload, false)
if err != nil {
log.Println(response.Endpoint)
log.Println(response.Bytes.String())
log.Fatal(err)
}
for _, label := range labels.Results {
log.Println(label)
}
}
Remove label from content
package main
import (
"context"
"github.com/ctreminiom/go-atlassian/confluence"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
atlassian, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
atlassian.Auth.SetBasicAuth(mail, token)
atlassian.Auth.SetUserAgent("curl/7.54.0")
response, err := atlassian.Content.Label.Remove(context.Background(), "80412692", "label-02")
if err != nil {
log.Println(response.Endpoint)
log.Println(response.Bytes.String())
log.Fatal(err)
}
}