Skip to content

Latest commit

 

History

History
106 lines (77 loc) · 3.2 KB

README.md

File metadata and controls

106 lines (77 loc) · 3.2 KB

GoReportCard GitHub Actions CI Status GitHub Actions CodeQL Status Codebeat badge

Usage exampleCI StatusLicense


go-confluence is a Go package for working with Confluence REST API.

Important

Please note that this package only supports retrieving data from the Confluence API (i.e. you cannot create or modify data with this package).

Usage example

Authentication with username and password.

package main

import (
  "fmt"
  cf "github.com/essentialkaos/go-confluence/v6"
)

func main() {
  api, err := cf.NewAPI("https://confluence.domain.com", cf.AuthBasic{"john", "MySuppaPAssWOrd"})

  api.SetUserAgent("MyApp", "1.2.3")

  if err != nil {
    fmt.Printf("Error: %v\n", err)
    return
  }

  content, err := api.GetContentByID(
    "18173522", cf.ContentIDParameters{
      Version: 4,
      Expand:  []string{"space", "body.view", "version"},
    },
  )

  if err != nil {
    fmt.Printf("Error: %v\n", err)
    return
  }

  fmt.Printf("ID: %s\n", content.ID)
}

Authentication with personal token. Please make sure your confluence 7.9 version and later. See Using Personal Access Tokens guide

package main

import (
  "fmt"

  cf "github.com/essentialkaos/go-confluence/v6"
)

func main() {
  api, err := cf.NewAPI("https://confluence.domain.com", cf.AuthToken{"avaMTxxxqKaxpFHpmwHPXhjmUFfAJMaU3VXUji73EFhf"})

  api.SetUserAgent("MyApp", "1.2.3")

  if err != nil {
    fmt.Printf("Error: %v\n", err)
    return
  }

  content, err := api.GetContentByID(
    "18173522", cf.ContentIDParameters{
      Version: 4,
      Expand:  []string{"space", "body.view", "version"},
    },
  )
  if err != nil {
    fmt.Printf("Error: %v\n", err)
    return
  }

  fmt.Printf("ID: %s\n", content.ID)
}

CI Status

Branch Status
master (Stable) CI
develop (Unstable) CI

License

Apache License, Version 2.0