confluence

package
v0.0.0-...-0fba574 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 14 Imported by: 0

README

markdown-to-confluence/confluence readme

the confluence package is for confluence api logic

The package contains multiple exported structs:
// PageResults contains a slice of returned Pages
PageResults{}

//Page holds the data of a page from confluence wiki
Page{}

there are more exported structs within Page available in confluence/structs.go of this repo

// APIClient struct is for interacting with confluence
APIClient{}
The package contains multiple exported methods:
APIClient{}

// CreateAPIClient creates the API client with relevant login details for confluence's API
CreateAPIClient() (*APIClient, error)
The username, API key and confluence space are provided via environment variables

// CreatePage is for creating a confluence page, root is the parent page ID
// if isroot is true the page is created as a root parent page in confluence
// it returns the page ID generated for the page
CreatePage(root int, contents *markdown.FileContents, isroot bool) (int, error)

// DeletePage deletes a confluence page using pageID to identify page to delete
DeletePage(pageID int) error

// UpdatePage updates a confluence page using pageID to identify page
UpdatePage(pageID int, pageVersion int64, pageContents *markdown.FileContents) error

// FindPage in confluence using title and returns page results
// if many is set to true it will also return the children pages of the page
FindPage(title string, many bool) (*PageResults, error)

// UploadAttachment to a page identified by page ID
UploadAttachment(filename string, id int) error

Documentation

Overview

Package confluence provides functionality for interacting with the confluence APIClient Specifically managing pages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	BaseURL  string
	Space    string
	Username string
	Password string
	Client   HTTPClient
}

APIClient struct for interacting with confluence

func APIClientWithAuths

func APIClientWithAuths(httpClient HTTPClient) *APIClient

APIClientWithAuths returns an APIClient with dependencies defaulted to sane values

func CreateAPIClient

func CreateAPIClient() (*APIClient, error)

CreateAPIClient creates the API client with relevant login details for confluence's API

func (*APIClient) CreatePage

func (a *APIClient) CreatePage(root int, contents *markdown.FileContents, isroot bool) (int, error)

CreatePage method takes root (root page id) and page contents and bool (is page root?) and generates a page in confluence and returns the generated page ID nolint: gocyclo // 11 is just about fine

func (*APIClient) DeletePage

func (a *APIClient) DeletePage(pageID int) error

DeletePage deletes a confluence page by page ID

func (*APIClient) FindPage

func (a *APIClient) FindPage(title string, many bool) (*PageResults, error)

FindPage in confluence Docs for this API endpoint are here https://developer.atlassian.com/cloud/confluence/rest/api-group-content/#api-api-content-get

func (*APIClient) UpdatePage

func (a *APIClient) UpdatePage(pageID int, pageVersion int64, pageContents *markdown.FileContents,
	originalPage PageResults) (bool, error)

UpdatePage updates a confluence page with our newly created data and increases the version by 1 each time.

func (*APIClient) UploadAttachment

func (a *APIClient) UploadAttachment(filename string, id int, isindex bool, indexid int) error

UploadAttachment to a page identify by page ID you need the page ID to upload the attachment(file path)

type AncestorObj

type AncestorObj struct {
	ID int `json:"id,omitempty"`
}

AncestorObj contains the page ID of a parent page

type BodyObj

type BodyObj struct {
	Storage StorageObj `json:"storage"`
}

BodyObj stores body object

type HTTPClient

type HTTPClient interface {
	Do(req *retryablehttp.Request) (*http.Response, error)
}

HTTPClient interface will allow mock Do request

type Page

type Page struct {
	ID        string        `json:"id,omitempty"`
	Type      string        `json:"type"`
	Status    string        `json:"status"`
	Title     string        `json:"title"`
	Space     SpaceObj      `json:"space,omitempty"`
	Version   VersionObj    `json:"version,omitempty"`
	Ancestors []AncestorObj `json:"ancestors,omitempty"`
	Body      BodyObj       `json:"body,omitempty"`
}

Page holds returned confluence data

type PageResults

type PageResults struct {
	Results []Page `json:"results"`
}

PageResults contains the returned page values

type SpaceObj

type SpaceObj struct {
	Key string `json:"key,omitempty"`
}

SpaceObj contains the confluence space value

type StorageObj

type StorageObj struct {
	Value          string `json:"value"`
	Representation string `json:"representation,omitempty"`
}

StorageObj stores storage object

type VersionObj

type VersionObj struct {
	Number int `json:"number"`
}

VersionObj stores page version increased by 1 for PUT request

Directories

Path Synopsis
test
confluencemocks
Package confluencemocks is a generated GoMock package.
Package confluencemocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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