Skip to content

ioki-mobility/go-outline

Repository files navigation

Go Reference Checks MIT

go-outline

The module provides Go client and cli for outline.

Go Client

The Go client provides easy to use API around outline's official HTTP API.

Installation

go get github.com/ioki-mobility/go-outline

Usage Examples

Create a client

cl := outline.New("https://server.url", &http.Client{}, "api key")

Note: You can create a new API key in your outline account settings.

Get a collection

col, err := cl.Collections().Get("collection id").Do(context.Background())
if err != nil {
	panic(err)
}
fmt.Println(col)

Get all collections

err := cl.Collections().List().Do(context.Background(), func(col *outline.Collection, err error) (bool, error) {
	fmt.Println(col)
	return true, nil
})
if err != nil {
	panic(err)
}

Create a collection

col, err := cl.Collections().Create("collection name").Do(context.Background()) 
if err != nil {
	panic(err)
}
fmt.Println(col)

There are also optional functions for the CollectionsCreateClient available:

colCreateClient := cl.Collections().Create("collection name")
colCreateClient.
	Description("desc"). 
	PermissionRead(). // or PermissionReadWrite()
	Color("#c0c0c0").
	Private(true).
	Do(context.Background())

Document Create

doc := cl.Documents().Create("Document name", "collection id").Do(context.Background())

There re also optional functions for the DocumentsCreateClient available:

docCreateClient := cl.Documents().Create("Document name")
docCreateClient.
	Publish(true). 
	Text("text").
	ParentDocumentID(DocumentId("parent document id")).
	TemplateID(TemplateId("templateId")).
	Template(false).
	Do(context.Background())

CLI

Installation

  • Download pre-built binaries from releases page
  • Install via go toolchain:
go install github.com/ioki-mobility/go-outline/cmd/outcli@latest

Usage

Check the project website: https://ioki-mobility.github.io/go-outline/