confluence

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package confluence provides a client for the Confluence REST API. It integrates with the storage package for reading and writing pages using Confluence Storage Format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
	Body       string
}

APIError represents an error returned by the Confluence API.

func (*APIError) Error

func (e *APIError) Error() string

type AuthMethod

type AuthMethod interface {
	Apply(req *http.Request)
}

AuthMethod represents an authentication method.

type BasicAuth

type BasicAuth struct {
	Username string
	Token    string // API token (not password)
}

BasicAuth implements basic authentication using API tokens.

func (BasicAuth) Apply

func (b BasicAuth) Apply(req *http.Request)

Apply implements AuthMethod.

type BearerAuth

type BearerAuth struct {
	Token string
}

BearerAuth implements bearer token authentication.

func (BearerAuth) Apply

func (b BearerAuth) Apply(req *http.Request)

Apply implements AuthMethod.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Confluence REST API client.

func NewClient

func NewClient(baseURL string, auth AuthMethod, opts ...Option) *Client

NewClient creates a new Confluence client.

func (*Client) CreatePage

func (c *Client) CreatePage(ctx context.Context, spaceKey, title string, page *storage.Page, parentID string) (string, error)

CreatePage creates a new page with IR content.

func (*Client) CreatePageRaw

func (c *Client) CreatePageRaw(ctx context.Context, spaceKey, title, xhtml, parentID string) (string, error)

CreatePageRaw creates a new page with raw Storage XHTML.

func (*Client) DeletePage

func (c *Client) DeletePage(ctx context.Context, pageID string) error

DeletePage deletes a page by ID.

func (*Client) GetPageStorage

func (c *Client) GetPageStorage(ctx context.Context, pageID string) (*storage.Page, *PageInfo, error)

GetPageStorage retrieves a page's content as Storage Format, parsed to IR.

func (*Client) GetPageStorageRaw

func (c *Client) GetPageStorageRaw(ctx context.Context, pageID string) (string, *PageInfo, error)

GetPageStorageRaw retrieves a page's raw Storage XHTML.

func (*Client) GetSpace

func (c *Client) GetSpace(ctx context.Context, spaceKey string) (*SpaceInfo, error)

GetSpace retrieves information about a space.

func (*Client) SearchPages

func (c *Client) SearchPages(ctx context.Context, cql string, limit int) ([]PageInfo, error)

SearchPages searches for pages matching the given CQL query.

func (*Client) UpdatePageStorage

func (c *Client) UpdatePageStorage(ctx context.Context, pageID string, page *storage.Page, version int, title string) error

UpdatePageStorage updates a page with the given IR content.

func (*Client) UpdatePageStorageRaw

func (c *Client) UpdatePageStorageRaw(ctx context.Context, pageID, xhtml string, version int, title string) error

UpdatePageStorageRaw updates a page with raw Storage XHTML.

type Option

type Option func(*Client)

Option configures a Client.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient sets a custom HTTP client.

type PageInfo

type PageInfo struct {
	ID       string `json:"id"`
	Type     string `json:"type"`
	Status   string `json:"status"`
	Title    string `json:"title"`
	Version  int    `json:"version"`
	SpaceKey string `json:"spaceKey,omitempty"`
}

PageInfo contains metadata about a Confluence page.

type SpaceInfo

type SpaceInfo struct {
	ID          int    `json:"id"`
	Key         string `json:"key"`
	Name        string `json:"name"`
	Type        string `json:"type"`
	Description string `json:"description,omitempty"`
}

SpaceInfo contains metadata about a Confluence space.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL