confluence

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	Storage             *BodyContent `json:"storage,omitempty"`
	View                *BodyContent `json:"view,omitempty"`
	ExportView          *BodyContent `json:"export_view,omitempty"`
	StyledView          *BodyContent `json:"styled_view,omitempty"`
	Editor              *BodyContent `json:"editor,omitempty"`
	Editor2             *BodyContent `json:"editor2,omitempty"`
	AnonymousExportView *BodyContent `json:"anonymous_export_view,omitempty"`
	Wiki                *BodyContent `json:"wiki,omitempty"`
}

Body represents content body in various formats

type BodyContent

type BodyContent struct {
	Value          string        `json:"value"`
	Representation ContentFormat `json:"representation"`
	Embeddeds      []Embedded    `json:"embeddedContent,omitempty"`
	WebResource    *WebResource  `json:"webresource,omitempty"`
}

BodyContent represents the actual content in a specific format

type Children

type Children struct {
	Page       *ContentArray `json:"page,omitempty"`
	Comment    *ContentArray `json:"comment,omitempty"`
	Attachment *ContentArray `json:"attachment,omitempty"`
	Links      *Links        `json:"_links,omitempty"`
	Expandable *Expandable   `json:"_expandable,omitempty"`
}

Children represents child content

type Client

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

Client is a Confluence API client

func NewClient

func NewClient(cfg *Config) (*Client, error)

NewClient creates a new Confluence client

func (*Client) AddComment

func (c *Client) AddComment(ctx context.Context, pageID string, body string) (*Comment, error)

AddComment adds a comment to a page

func (*Client) AddLabel

func (c *Client) AddLabel(ctx context.Context, contentID string, name string, prefix string) (*Label, error)

AddLabel adds a label to content

func (*Client) AddLabels

func (c *Client) AddLabels(ctx context.Context, contentID string, labels []CreateLabelRequest) ([]Label, error)

AddLabels adds multiple labels to content

func (*Client) ConvertMarkdownToStorage

func (c *Client) ConvertMarkdownToStorage(ctx context.Context, markdown string) (string, error)

ConvertMarkdownToStorage converts Markdown to Confluence storage format This is a stub - actual implementation would use a proper converter

func (*Client) ConvertWikiToStorage

func (c *Client) ConvertWikiToStorage(ctx context.Context, wiki string) (string, error)

ConvertWikiToStorage converts Wiki markup to Confluence storage format This is a stub - actual implementation would use the Confluence API

func (*Client) CreateContent

func (c *Client) CreateContent(ctx context.Context, req *CreateContentRequest) (*Content, error)

CreateContent creates new content

func (*Client) CreatePage

func (c *Client) CreatePage(ctx context.Context, spaceKey, title, body string, parentID string) (*Content, error)

CreatePage creates a new page

func (*Client) DeleteComment

func (c *Client) DeleteComment(ctx context.Context, commentID string) error

DeleteComment deletes a comment

func (*Client) DeleteContent

func (c *Client) DeleteContent(ctx context.Context, contentID string) error

DeleteContent deletes content

func (*Client) DeletePage

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

DeletePage deletes a page

func (*Client) GetAnonymousUser

func (c *Client) GetAnonymousUser(ctx context.Context) (*User, error)

GetAnonymousUser retrieves the anonymous user information

func (*Client) GetComment

func (c *Client) GetComment(ctx context.Context, commentID string, expand []string) (*Comment, error)

GetComment retrieves a specific comment by ID

func (*Client) GetComments

func (c *Client) GetComments(ctx context.Context, pageID string, expand []string, limit int) ([]Comment, error)

GetComments retrieves comments for a page

func (*Client) GetContent

func (c *Client) GetContent(ctx context.Context, contentID string, opts *GetContentOptions) (*Content, error)

GetContent retrieves content by ID

func (*Client) GetCurrentUser

func (c *Client) GetCurrentUser(ctx context.Context) (*User, error)

GetCurrentUser retrieves the currently authenticated user

func (*Client) GetDeploymentType

func (c *Client) GetDeploymentType() DeploymentType

GetDeploymentType returns the deployment type

func (*Client) GetLabels

func (c *Client) GetLabels(ctx context.Context, contentID string, prefix string, limit int) ([]Label, error)

GetLabels retrieves labels for content

func (*Client) GetPage

func (c *Client) GetPage(ctx context.Context, pageID string, expand []string) (*Content, error)

GetPage retrieves a page by ID

func (*Client) GetPageAncestors

func (c *Client) GetPageAncestors(ctx context.Context, pageID string) ([]Content, error)

GetPageAncestors retrieves ancestors of a page

func (*Client) GetPageByTitle

func (c *Client) GetPageByTitle(ctx context.Context, spaceKey, title string, expand []string) (*Content, error)

GetPageByTitle retrieves a page by title and space key

func (*Client) GetPageChildren

func (c *Client) GetPageChildren(ctx context.Context, pageID string, expand []string, limit int) ([]Content, error)

GetPageChildren retrieves child pages of a page

func (*Client) GetPageHistory

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

GetPageHistory retrieves the history of a page

func (*Client) GetSpace

func (c *Client) GetSpace(ctx context.Context, spaceKey string, expand []string) (*Space, error)

GetSpace retrieves a space by key

func (*Client) GetSpaceContent

func (c *Client) GetSpaceContent(ctx context.Context, spaceKey string, contentType ContentType, expand []string, limit int) ([]Content, error)

GetSpaceContent retrieves content in a space

func (*Client) GetSpaces

func (c *Client) GetSpaces(ctx context.Context, opts *GetSpacesOptions) ([]Space, error)

GetSpaces retrieves all spaces

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, accountIDOrUsername string) (*User, error)

GetUser retrieves a user by account ID (Cloud) or username (Server/DC)

func (*Client) GetUserGroups

func (c *Client) GetUserGroups(ctx context.Context, accountIDOrUsername string) ([]string, error)

GetUserGroups retrieves groups for a user

func (*Client) IsCloud

func (c *Client) IsCloud() bool

IsCloud returns true if the Confluence instance is Cloud

func (*Client) IsServer

func (c *Client) IsServer() bool

IsServer returns true if the Confluence instance is Server/Data Center

func (*Client) RemoveLabel

func (c *Client) RemoveLabel(ctx context.Context, contentID string, labelName string) error

RemoveLabel removes a label from content

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string, opts *SearchOptions) (*SearchResult, error)

Search searches content using text or CQL

func (*Client) SearchByLabel

func (c *Client) SearchByLabel(ctx context.Context, labelName string, spaceKey string, limit int) ([]Content, error)

SearchByLabel searches for content by label

func (*Client) SearchCQL

func (c *Client) SearchCQL(ctx context.Context, cql string, opts *SearchOptions) (*SearchResult, error)

SearchCQL searches content using CQL (Confluence Query Language)

func (*Client) SearchSpaces

func (c *Client) SearchSpaces(ctx context.Context, query string, limit int) ([]Space, error)

SearchSpaces searches for spaces

func (*Client) SearchUsers

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

SearchUsers searches for users using CQL

func (*Client) SearchUsersByName

func (c *Client) SearchUsersByName(ctx context.Context, query string, limit int) ([]User, error)

SearchUsersByName searches for users by name or email

func (*Client) UpdateComment

func (c *Client) UpdateComment(ctx context.Context, commentID string, body string, version int) (*Comment, error)

UpdateComment updates an existing comment

func (*Client) UpdateContent

func (c *Client) UpdateContent(ctx context.Context, contentID string, req *UpdateContentRequest) (*Content, error)

UpdateContent updates existing content

func (*Client) UpdatePage

func (c *Client) UpdatePage(ctx context.Context, pageID string, title, body string, version int) (*Content, error)

UpdatePage updates an existing page

type Comment

type Comment struct {
	ID         string      `json:"id"`
	Type       string      `json:"type"`
	Status     string      `json:"status,omitempty"`
	Title      string      `json:"title,omitempty"`
	Body       *Body       `json:"body,omitempty"`
	Version    *Version    `json:"version,omitempty"`
	Container  *Container  `json:"container,omitempty"`
	Links      *Links      `json:"_links,omitempty"`
	Expandable *Expandable `json:"_expandable,omitempty"`
}

Comment represents a comment

type Config

type Config struct {
	BaseURL       string
	Auth          auth.Provider
	CustomHeaders map[string]string
	SSLVerify     bool
	HTTPProxy     string
	HTTPSProxy    string
	SOCKSProxy    string
	NoProxy       string
}

Config holds the configuration for creating a Confluence client

type Container

type Container struct {
	ID         string      `json:"id,omitempty"`
	Type       string      `json:"type,omitempty"`
	Title      string      `json:"title,omitempty"`
	Links      *Links      `json:"_links,omitempty"`
	Expandable *Expandable `json:"_expandable,omitempty"`
}

Container represents a content container

type Content

type Content struct {
	ID          string                 `json:"id"`
	Type        ContentType            `json:"type"`
	Status      ContentStatus          `json:"status"`
	Title       string                 `json:"title,omitempty"`
	Space       *Space                 `json:"space,omitempty"`
	Version     *Version               `json:"version,omitempty"`
	Ancestors   []Content              `json:"ancestors,omitempty"`
	Body        *Body                  `json:"body,omitempty"`
	Extensions  map[string]interface{} `json:"extensions,omitempty"` // Can contain various types
	Links       *Links                 `json:"_links,omitempty"`
	Expandable  *Expandable            `json:"_expandable,omitempty"`
	History     *History               `json:"history,omitempty"`
	Children    *Children              `json:"children,omitempty"`
	Descendants *Descendants           `json:"descendants,omitempty"`
	Container   *Container             `json:"container,omitempty"`
	Metadata    *Metadata              `json:"metadata,omitempty"`
}

Content represents a piece of Confluence content (page, blogpost, comment, etc.)

type ContentArray

type ContentArray struct {
	Results    []Content   `json:"results,omitempty"`
	Start      int         `json:"start,omitempty"`
	Limit      int         `json:"limit,omitempty"`
	Size       int         `json:"size,omitempty"`
	Links      *Links      `json:"_links,omitempty"`
	Expandable *Expandable `json:"_expandable,omitempty"`
}

ContentArray represents an array of content

type ContentFormat

type ContentFormat string

ContentFormat represents the format of content

const (
	FormatStorage ContentFormat = "storage" // Confluence storage format (XHTML)
	FormatView    ContentFormat = "view"    // HTML view format
	FormatExport  ContentFormat = "export_view"
	FormatEditor  ContentFormat = "editor"
	FormatWiki    ContentFormat = "wiki" // Wiki markup (legacy)
)

type ContentRef

type ContentRef struct {
	ID   string `json:"id,omitempty"`
	Type string `json:"type,omitempty"`
}

ContentRef represents a content reference

type ContentStatus

type ContentStatus string

ContentStatus represents the status of content

const (
	ContentStatusCurrent ContentStatus = "current"
	ContentStatusTrashed ContentStatus = "trashed"
	ContentStatusDeleted ContentStatus = "deleted"
	ContentStatusDraft   ContentStatus = "draft"
)

type ContentType

type ContentType string

ContentType represents the type of Confluence content

const (
	ContentTypePage       ContentType = "page"
	ContentTypeBlogPost   ContentType = "blogpost"
	ContentTypeComment    ContentType = "comment"
	ContentTypeAttachment ContentType = "attachment"
)

type Contributors

type Contributors struct {
	Publishers *UserArray `json:"publishers,omitempty"`
}

Contributors represents content contributors

type CreateCommentRequest

type CreateCommentRequest struct {
	Type      string       `json:"type"`
	Container *ContentRef  `json:"container"`
	Body      *Body        `json:"body"`
	Ancestors []ContentRef `json:"ancestors,omitempty"`
}

CreateCommentRequest represents a request to create a comment

type CreateContentRequest

type CreateContentRequest struct {
	Type      ContentType   `json:"type"`
	Title     string        `json:"title"`
	Space     *SpaceRef     `json:"space"`
	Body      *Body         `json:"body,omitempty"`
	Ancestors []ContentRef  `json:"ancestors,omitempty"`
	Status    ContentStatus `json:"status,omitempty"`
}

CreateContentRequest represents a request to create content

type CreateLabelRequest

type CreateLabelRequest struct {
	Prefix string `json:"prefix,omitempty"`
	Name   string `json:"name"`
}

CreateLabelRequest represents a request to create a label

type DeploymentType

type DeploymentType string

DeploymentType represents the Confluence deployment type

const (
	DeploymentCloud  DeploymentType = "cloud"
	DeploymentServer DeploymentType = "server"
)

type Descendants

type Descendants struct {
	Page       *ContentArray `json:"page,omitempty"`
	Comment    *ContentArray `json:"comment,omitempty"`
	Attachment *ContentArray `json:"attachment,omitempty"`
	Links      *Links        `json:"_links,omitempty"`
	Expandable *Expandable   `json:"_expandable,omitempty"`
}

Descendants represents descendant content

type Embedded

type Embedded struct {
	EntityID   string `json:"entityId,omitempty"`
	EntityType string `json:"entityType,omitempty"`
}

Embedded represents embedded content

type ErrorData

type ErrorData struct {
	Authorized bool              `json:"authorized,omitempty"`
	Valid      bool              `json:"valid,omitempty"`
	Errors     []ValidationError `json:"errors,omitempty"`
	Successful bool              `json:"successful,omitempty"`
}

ErrorData represents error data

type ErrorMessage

type ErrorMessage struct {
	Key  string        `json:"key,omitempty"`
	Args []interface{} `json:"args,omitempty"`
}

ErrorMessage represents an error message

type ErrorResponse

type ErrorResponse struct {
	StatusCode int        `json:"statusCode,omitempty"`
	Data       *ErrorData `json:"data,omitempty"`
	Message    string     `json:"message,omitempty"`
	Reason     string     `json:"reason,omitempty"`
}

ErrorResponse represents a Confluence error response

type Expandable

type Expandable struct {
	Container    string `json:"container,omitempty"`
	Metadata     string `json:"metadata,omitempty"`
	Operations   string `json:"operations,omitempty"`
	Children     string `json:"children,omitempty"`
	Restrictions string `json:"restrictions,omitempty"`
	History      string `json:"history,omitempty"`
	Ancestors    string `json:"ancestors,omitempty"`
	Body         string `json:"body,omitempty"`
	Version      string `json:"version,omitempty"`
	Descendants  string `json:"descendants,omitempty"`
	Space        string `json:"space,omitempty"`
}

Expandable represents expandable fields

type Frontend

type Frontend struct {
	EditURL string `json:"editUrl,omitempty"`
	WebUI   string `json:"webui,omitempty"`
}

Frontend represents frontend metadata

type GetContentOptions

type GetContentOptions struct {
	Expand  []string      // Resources to expand (e.g., "body.storage", "version", "space")
	Status  ContentStatus // Filter by status
	Version int           // Specific version number
}

GetContentOptions contains options for getting content

type GetSpacesOptions

type GetSpacesOptions struct {
	SpaceKey  []string // Filter by space keys
	SpaceType string   // Filter by type (global, personal)
	Status    string   // Filter by status (current, archived)
	Expand    []string // Resources to expand
	Start     int      // Pagination start
	Limit     int      // Pagination limit
}

GetSpacesOptions contains options for listing spaces

type History

type History struct {
	Latest          bool          `json:"latest,omitempty"`
	CreatedBy       *User         `json:"createdBy,omitempty"`
	CreatedDate     string        `json:"createdDate,omitempty"`
	LastUpdated     *Version      `json:"lastUpdated,omitempty"`
	PreviousVersion *Version      `json:"previousVersion,omitempty"`
	Contributors    *Contributors `json:"contributors,omitempty"`
	NextVersion     *Version      `json:"nextVersion,omitempty"`
	Links           *Links        `json:"_links,omitempty"`
	Expandable      *Expandable   `json:"_expandable,omitempty"`
}

History represents content history

type Icon

type Icon struct {
	Path      string `json:"path,omitempty"`
	Width     int    `json:"width,omitempty"`
	Height    int    `json:"height,omitempty"`
	IsDefault bool   `json:"isDefault,omitempty"`
}

Icon represents an icon

type Label

type Label struct {
	ID     string `json:"id,omitempty"`
	Name   string `json:"name"`
	Prefix string `json:"prefix,omitempty"`
	Label  string `json:"label,omitempty"`
}

Label represents a label

type LabelArray

type LabelArray struct {
	Results    []Label     `json:"results,omitempty"`
	Start      int         `json:"start,omitempty"`
	Limit      int         `json:"limit,omitempty"`
	Size       int         `json:"size,omitempty"`
	Links      *Links      `json:"_links,omitempty"`
	Expandable *Expandable `json:"_expandable,omitempty"`
}

LabelArray represents an array of labels

type Links struct {
	Self       string `json:"self,omitempty"`
	Base       string `json:"base,omitempty"`
	Context    string `json:"context,omitempty"`
	WebUI      string `json:"webui,omitempty"`
	Edit       string `json:"edit,omitempty"`
	TinyUI     string `json:"tinyui,omitempty"`
	Collection string `json:"collection,omitempty"`
	Download   string `json:"download,omitempty"`
}

Links represents HAL links

type Metadata

type Metadata struct {
	Labels     *LabelArray            `json:"labels,omitempty"`
	Properties map[string]interface{} `json:"properties,omitempty"`
	Frontend   *Frontend              `json:"frontend,omitempty"`
	Links      *Links                 `json:"_links,omitempty"`
	Expandable *Expandable            `json:"_expandable,omitempty"`
}

Metadata represents content metadata

type ProfilePicture

type ProfilePicture struct {
	Path      string `json:"path,omitempty"`
	Width     int    `json:"width,omitempty"`
	Height    int    `json:"height,omitempty"`
	IsDefault bool   `json:"isDefault,omitempty"`
}

ProfilePicture represents a user's profile picture

type SearchOptions

type SearchOptions struct {
	Expand []string
	Start  int
	Limit  int
}

SearchOptions contains options for searching

type SearchResult

type SearchResult struct {
	Results        []Content `json:"results"`
	Start          int       `json:"start"`
	Limit          int       `json:"limit"`
	Size           int       `json:"size"`
	TotalSize      int       `json:"totalSize,omitempty"`
	CqlQuery       string    `json:"cqlQuery,omitempty"`
	SearchDuration int       `json:"searchDuration,omitempty"`
	Links          *Links    `json:"_links,omitempty"`
}

SearchResult represents search results

type Space

type Space struct {
	ID          interface{} `json:"id,omitempty"` // Can be string or number depending on API version
	Key         string      `json:"key"`
	Name        string      `json:"name,omitempty"`
	Type        string      `json:"type,omitempty"`
	Status      string      `json:"status,omitempty"`
	Description *Body       `json:"description,omitempty"`
	Homepage    *Content    `json:"homepage,omitempty"`
	Icon        *Icon       `json:"icon,omitempty"`
	Links       *Links      `json:"_links,omitempty"`
	Expandable  *Expandable `json:"_expandable,omitempty"`
}

Space represents a Confluence space

func (*Space) GetID

func (s *Space) GetID() string

GetID returns the space ID as a string

type SpaceRef

type SpaceRef struct {
	Key string `json:"key"`
}

SpaceRef represents a space reference

type SuperBatch

type SuperBatch struct {
	Uris map[string]string `json:"uris,omitempty"`
}

SuperBatch represents super batch information

type UpdateContentRequest

type UpdateContentRequest struct {
	Version *Version      `json:"version"`
	Title   string        `json:"title,omitempty"`
	Type    ContentType   `json:"type,omitempty"`
	Body    *Body         `json:"body,omitempty"`
	Status  ContentStatus `json:"status,omitempty"`
}

UpdateContentRequest represents a request to update content

type User

type User struct {
	Type           string          `json:"type,omitempty"`
	AccountID      string          `json:"accountId,omitempty"` // Cloud
	Username       string          `json:"username,omitempty"`  // Server/DC
	UserKey        string          `json:"userKey,omitempty"`   // Server/DC
	AccountType    string          `json:"accountType,omitempty"`
	Email          string          `json:"email,omitempty"`
	PublicName     string          `json:"publicName,omitempty"`
	DisplayName    string          `json:"displayName,omitempty"`
	ProfilePicture *ProfilePicture `json:"profilePicture,omitempty"`
	Links          *Links          `json:"_links,omitempty"`
	Expandable     *Expandable     `json:"_expandable,omitempty"`
}

User represents a Confluence user

type UserArray

type UserArray struct {
	Users      []User      `json:"users,omitempty"`
	UserKeys   []string    `json:"userKeys,omitempty"`
	Size       int         `json:"size,omitempty"`
	Links      *Links      `json:"_links,omitempty"`
	Expandable *Expandable `json:"_expandable,omitempty"`
}

UserArray represents an array of users

type ValidationError

type ValidationError struct {
	Message *ErrorMessage `json:"message,omitempty"`
}

ValidationError represents a validation error

type Version

type Version struct {
	By                  *User  `json:"by,omitempty"`
	When                string `json:"when,omitempty"`
	FriendlyWhen        string `json:"friendlyWhen,omitempty"`
	Message             string `json:"message,omitempty"`
	Number              int    `json:"number"`
	MinorEdit           bool   `json:"minorEdit,omitempty"`
	SyncRev             string `json:"syncRev,omitempty"`
	SyncRevSource       string `json:"syncRevSource,omitempty"`
	ConfRev             string `json:"confRev,omitempty"`
	ContentTypeModified bool   `json:"contentTypeModified,omitempty"`
}

Version represents content version information

type WebResource

type WebResource struct {
	Keys       []string          `json:"keys,omitempty"`
	Contexts   []string          `json:"contexts,omitempty"`
	Uris       map[string]string `json:"uris,omitempty"`
	Tags       map[string]string `json:"tags,omitempty"`
	SuperBatch *SuperBatch       `json:"superbatch,omitempty"`
}

WebResource represents web resources

Jump to

Keyboard shortcuts

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