confluence

package
v1.0.1-0...-9290184 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttachmentNotFoundError = "attachment not found"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	StatusCode int `json:"statusCode,omitempty"`
	Data       struct {
		Authorized bool `json:"authorized,omitempty"`
		Valid      bool `json:"valid,omitempty"`
		Errors     []struct {
			Message struct {
				Key  string        `json:"key,omitempty"`
				Args []interface{} `json:"args,omitempty"`
			} `json:"message,omitempty"`
		} `json:"errors,omitempty"`
		Successful bool `json:"successful,omitempty"`
	} `json:"data,omitempty"`
	Message string `json:"message,omitempty"`
}

APIResponse provides default response from API

type Attachment

type Attachment struct {
	ID       string `json:"id"`
	Type     string `json:"type"`
	Status   string `json:"status"`
	Title    string `json:"title"`
	Metadata struct {
		Comment   string `json:"comment"`
		MediaType string `json:"mediaType"`
	} `json:"metadata"`
	Version struct {
		Number int `json:"number"`
	} `json:"version"`
}

Attachment ...

type AttachmentExpandable

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

AttachmentExpandable expandable

type AttachmentExtensions

type AttachmentExtensions struct {
	MediaType string  `json:"mediaType"`
	FileSize  float64 `json:"fileSize"`
	Comment   string  `json:"comment"`
}

AttachmentExtensions Extensions

type AttachmentFetchResult

type AttachmentFetchResult struct {
	ID         string               `json:"id"`
	Type       string               `json:"type"`
	Status     string               `json:"status"`
	Title      string               `json:"title"`
	MetaData   AttachmentMetaData   `json:"metadata"`
	Extensions AttachmentExtensions `json:"extensions"`
	Expandable AttachmentExpandable `json:"_expandable"`
	Links      AttachmentLinks      `json:"_links"`
}

AttachmentFetchResult ...

type AttachmentLabels

type AttachmentLabels struct {
	Results []interface{}     `json:"results"`
	Start   float64           `json:"start"`
	Limit   float64           `json:"limit"`
	Size    float64           `json:"size"`
	Links   map[string]string `json:"_links"`
}

AttachmentLabels ...

type AttachmentLinks struct {
	Self      string `json:"self"`
	Webui     string `json:"webui"`
	Download  string `json:"download"`
	Thumbnail string `json:"thumbnail"`
}

AttachmentLinks links

func (*AttachmentLinks) UnmarshalJSON

func (a *AttachmentLinks) UnmarshalJSON(data []byte) error

UnmarshalJSON Custom Unmarshaller

type AttachmentMetaData

type AttachmentMetaData struct {
	MediaType  string                 `json:"mediaType"`
	Labels     AttachmentLabels       `json:"labels"`
	Expandable map[string]interface{} `json:"_expandable"`
}

AttachmentMetaData ...

type AttachmentResults

type AttachmentResults struct {
	Results []AttachmentFetchResult `json:"results"`
	Start   float64                 `json:"start"`
	Limit   float64                 `json:"limit"`
	Size    float64                 `json:"size"`
	Links   map[string]string       `json:"_links"`
}

AttachmentResults Results

type Attachments

type Attachments struct {
	Results []Attachment `json:"results"`
	Size    int          `json:"size"`
}

Attachments ..

type Body

type Body struct {
	Storage        ContentBody `json:"storage,omitempty"`
	AtlasDocFormat ContentBody `json:"atlas_doc_format,omitempty"`
	View           ContentBody `json:"view,omitempty"`
}

type Client

type Client struct {
	Cookie      string
	Username    string
	Password    string
	AccessToken string
	Endpoint    string
	InsecureTLS bool
	LogLevel    string
}

Client for the Confluence API

func (*Client) AddAttachment

func (client *Client) AddAttachment(contentID, path string) (*Attachment, error)

AddAttachment ...

func (*Client) AddLabels

func (client *Client) AddLabels(contentID string, labels []string, prefix LabelPrefix) error

AddLabels ...

func (*Client) AddUpdateAttachments

func (client *Client) AddUpdateAttachments(contentID string, files []string) ([]*Attachment, []error)

AddUpdateAttachments ...

func (*Client) CreateContent

func (client *Client) CreateContent(bp *CreateContentBodyParameters, qp *QueryParameters) (Content, error)

CreateContent creates a new piece of content or publishes an existing draft. https://developer.atlassian.com/cloud/confluence/rest/#api-content-post

func (*Client) CreatePage

func (client *Client) CreatePage(createPageBody *CreatePageBody, qp *CreatePageQueryParameters) (Page, error)

CreatePage creates a page in the space https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-post

func (*Client) Delete

func (client *Client) Delete(class interface{}) error

Delete deletes various API types

func (*Client) DeleteAllPagesInSpace

func (client *Client) DeleteAllPagesInSpace(spaceID string) error

UpdatePage update a page by id https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-id-delete

func (*Client) DeleteAttachment

func (client *Client) DeleteAttachment(contentID string, attachmentID string) error

DeleteAttachment ..

func (*Client) DeleteContent

func (client *Client) DeleteContent(content Content) error

DeleteContent oves a piece of content to the space’s trash or purges it from the trash, depending on the content’s type and status:

  • If the content’s type is `page` or `blogpost` and its status is `current`, it will be trashed.
  • If the content’s type is `page` or `blogpost` and its status is `trashed`, the content will be purged from the trash and deleted permanently. Note, you must also set the `status` query parameter to `trashed` in your request.
  • If the content’s type is `comment` or `attachment`, it will be deleted permanently without being trashed.

https://developer.atlassian.com/cloud/confluence/rest/#api-content-id-delete

func (*Client) DownloadAttachmentsFromPage

func (client *Client) DownloadAttachmentsFromPage(pageID, directory string) error

DownloadAttachmentsFromPage ...

func (*Client) DownloadFromURL

func (client *Client) DownloadFromURL(url, outputFilepath string) error

DownloadFromURL ...

func (*Client) FetchAttachmentMetaData

func (client *Client) FetchAttachmentMetaData(contentID string) (*AttachmentResults, error)

FetchAttachmentMetaData ...

func (*Client) GetAttachment

func (client *Client) GetAttachment(contentID, attachmentID string) (*Attachment, error)

GetAttachment ...

func (*Client) GetAttachmentByFilename

func (client *Client) GetAttachmentByFilename(contentID, filename string) (*Attachment, error)

GetAttachmentByFilename ...

func (*Client) GetContent

func (client *Client) GetContent(qp *GetContentQueryParameters) ([]Content, error)

GetContent Returns all content in a Confluence instance. https://developer.atlassian.com/cloud/confluence/rest/#api-content-get

func (*Client) GetPageAttachmentByFilename

func (client *Client) GetPageAttachmentByFilename(pageID, filename string) (PageAttachment, error)

func (*Client) GetSpaceByKey

func (client *Client) GetSpaceByKey(key string) (*Space, error)

func (*Client) Search

func (client *Client) Search(qp *SearchQueryParameters) ([]SearchResult, error)

func (*Client) UpdateAttachment

func (client *Client) UpdateAttachment(contentID, attachmentID, path string, minorEdit bool) (*Attachment, error)

UpdateAttachment ...

func (*Client) UpdateContent

func (client *Client) UpdateContent(content *Content, qp *QueryParameters) (Content, error)

UpdateContent updates a piece of content. Use this method to update the title or body of a piece of content, change the status, change the parent page, and more. https://developer.atlassian.com/cloud/confluence/rest/#api-content-id-put

func (*Client) UpdatePage

func (client *Client) UpdatePage(pageID string, createPageBody *CreatePageBody) (Page, error)

UpdatePage update a page by id https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-id-put

func (*Client) UpdatePageWithVersionBump

func (client *Client) UpdatePageWithVersionBump(pageID string, createPageBody *CreatePageBody) (Page, error)

UpdatePage updates a page, incrementing the version manually

func (*Client) UpdateSpaceHomePage

func (client *Client) UpdateSpaceHomePage(key string, pageID string) error

UpdateSpaceHomePage updates the homepage of a given space https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-space/#api-wiki-rest-api-space-spacekey-put

type Content

type Content struct {
	ID        string `json:"id,omitempty"`
	Type      string `json:"type,omitempty"`
	Status    string `json:"status,omitempty"`
	Title     string `json:"title,omitempty"`
	URL       string `json:"url,omitempty"`
	Ancestors []struct {
		ID string `json:"id,omitempty"`
	} `json:"ancestors,omitempty"`
	Space struct {
		Key string `json:"key,omitempty"`
	} `json:"space,omitempty"`
	Version struct {
		Number  int    `json:"number,omitempty"`
		Message string `json:"message,omitempty"`
	} `json:"version,omitempty"`
	Body struct {
		Storage struct {
			Value           string        `json:"value,omitempty"`
			Representation  string        `json:"representation,omitempty"`
			EmbeddedContent []interface{} `json:"embeddedContent,omitempty"`
			Expandable      struct {
				Content string `json:"content,omitempty"`
			} `json:"_expandable,omitempty"`
		} `json:"storage,omitempty"`
	} `json:"body,omitempty"`
	Links struct {
		Self   string `json:"self,omitempty"`
		Tinyui string `json:"tinyui,omitempty"`
		Editui string `json:"editui,omitempty"`
		Webui  string `json:"webui,omitempty"`
	} `json:"_links,omitempty"`
}

Content represents the data returned from the Confluence API

type ContentBody

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

type ContentResponse

type ContentResponse struct {
	Results []Content `json:"results"`
}

ContentResponse represents the data returned from the Confluence API

type CreateContentBodyParameters

type CreateContentBodyParameters struct {
	Content
}

CreateContentBodyParameters query parameters for CreateContent

type CreatePageBody

type CreatePageBody struct {
	ID             string      `json:"id,omitempty"`
	SpaceID        string      `json:"spaceId,omitempty"`
	Status         string      `json:"status,omitempty"`
	Title          string      `json:"title,omitempty"`
	RemoteParentID string      `json:"parentId,omitempty"`
	Body           ContentBody `json:"body,omitempty"`
	Version        Version     `json:"version,omitempty"`
}

type CreatePageQueryParameters

type CreatePageQueryParameters struct {
	Embedded  bool `url:"embedded,omitempty"`   // Tag the content as embedded and content will be created in NCS.
	Private   bool `url:"private,omitempty"`    // The page will be private. Only the user who creates this page will have permission to view and edit one.
	RootLevel bool `url:"root-level,omitempty"` // The page will be created at the root level of the space (outside the space homepage tree).
}

type DeletePageQueryParameters

type DeletePageQueryParameters struct {
	Purge bool `url:"purge,omitempty"` // If attempting to purge the page.
}

type ErrorResponse

type ErrorResponse struct {
	Errors []Errors `json:"errors,omitempty"`
}

type Errors

type Errors struct {
	Status int    `json:"status,omitempty"`
	Code   string `json:"code,omitempty"`
	Title  string `json:"title,omitempty"`
	Detail string `json:"detail,omitempty"`
}

type GetAttachmentsForPageQueryParameters

type GetAttachmentsForPageQueryParameters struct {
	Status    []string `url:"status,omitempty"`
	MediaType string   `url:"mediaType,omitempty"`
	Filename  string   `url:"filename,omitempty"`
	GetResultsQueryParameters
}

type GetAttachmentsForPageResponse

type GetAttachmentsForPageResponse struct {
	Results []PageAttachment `json:"results,omitempty"`
	Links   Links            `json:"_links,omitempty"`
}

type GetContentQueryParameters

type GetContentQueryParameters struct {
	QueryParameters
	Expand       []string `url:"-"`
	ExpandString string   `url:"expand,omitempty"`
	Limit        int      `url:"limit,omitempty"`
	Orderby      string   `url:"orderby,omitempty"`
	PostingDay   string   `url:"postingDay,omitempty"`
	Spacekey     string   `url:"spaceKey,omitempty"`
	Start        int      `url:"start,omitempty"`
	Title        string   `url:"title,omitempty"`
	Trigger      string   `url:"trigger,omitempty"`
	Type         string   `url:"type,omitempty"`
}

GetContentQueryParameters query parameters for GetContent

type GetPagesInSpaceQueryParameters

type GetPagesInSpaceQueryParameters struct {
	Status     []string `url:"status,omitempty"`      // Filter the results to pages based on their status. By default, current and archived are used.
	BodyFormat string   `url:"body-format,omitempty"` // Maximum number of pages per result to return. If more results exist, use the Link header to retrieve a relative URL that will return the next set of results.
	Title      string   `url:"title,omitempty"`
	Depth      string   `url:"depth,omitempty"`
	GetResultsQueryParameters
}

type GetPagesInSpaceResponse

type GetPagesInSpaceResponse struct {
	Results []Page `json:"results,omitempty"`
	Links   Links  `json:"_links,omitempty"`
}

type GetPagesResponse

type GetPagesResponse struct {
	Results []Page `json:"results"`
	Links   Links  `json:"_links"`
}

type GetPageseQueryParameters

type GetPageseQueryParameters struct {
	ID         []string `url:"id,omitempty"`          // Filter the results based on page ids. Multiple page ids can be specified as a comma-separated list.
	SpaceID    []string `url:"space-id,omitempty"`    // Filter the results based on space ids. Multiple space ids can be specified as a comma-separated list.
	Status     []string `url:"status,omitempty"`      // Filter the results to pages based on their status. By default, current and archived are used.
	Title      string   `url:"title,omitempty"`       // Filter the results to pages based on their title.
	BodyFormat string   `url:"body-format,omitempty"` // The content format types to be returned in the body field of the response. If available, the representation will be available under a response field of the same name under the body field.
	GetResultsQueryParameters
}

type GetResultsQueryParameters

type GetResultsQueryParameters struct {
	Cursor string `url:"cursor,omitempty"` // Used for pagination, this opaque cursor will be returned in the next URL in the Link response header. Use the relative URL in the Link header to retrieve the next set of results.
	Limit  int    `url:"limit,omitempty"`  // Maximum number of pages per result to return. If more results exist, use the Link header to retrieve a relative URL that will return the next set of results.
	Sort   string `url:"sort,omitempty"`   // Used to sort the result by a particular field.
}

type GetSpacesQueryParameters

type GetSpacesQueryParameters struct {
	Keys   []string `url:"keys,omitempty"`   // Filter the results to spaces based on their keys. Multiple keys can be specified as a comma-separated list.
	Status string   `url:"status,omitempty"` // Filter the results to spaces based on their keys. Multiple keys can be specified as a comma-separated list.
}

type GetSpacesResponse

type GetSpacesResponse struct {
	Results []Space `json:"results,omitempty"`
	Links   Links   `json:"_links,omitempty"`
}

type LabelPrefix

type LabelPrefix string

LabelPrefix ...

const (
	// GlobalPrefix ...
	GlobalPrefix LabelPrefix = "global"
	// LocalPrefix ...
	LocalPrefix LabelPrefix = "local"
)
type Links struct {
	Webui    string `json:"webui,omitempty"`
	Next     string `json:"next,omitempty"`
	Editui   string `json:"editui,omitempty"`
	Tinyui   string `json:"tinyui,omitempty"`
	Download string `json:"download,omitempty"`
}

type Page

type Page struct {
	ID             string  `json:"id,omitempty"`
	Status         string  `json:"status,omitempty"`
	Title          string  `json:"title,omitempty"`
	SpaceID        string  `json:"spaceId,omitempty"`
	RemoteParentID string  `json:"parentId,omitempty"`
	ParentType     string  `json:"parentType,omitempty"`
	Position       int     `json:"position,omitempty"`
	AuthorID       string  `json:"authorId,omitempty"`
	OwnerID        string  `json:"ownerId,omitempty"`
	LastOwnerID    string  `json:"lastOwnerId,omitempty"`
	CreatedAt      string  `json:"createdAt,omitempty"`
	Version        Version `json:"version,omitempty"`
	Body           Body    `json:"body,omitempty"`
	Links          Links   `json:"_links,omitempty"`
}

type PageAttachment

type PageAttachment struct {
	ID                   string  `json:"id,omitempty"`
	Status               string  `json:"status,omitempty"`
	Title                string  `json:"title,omitempty"`
	CreatedAt            string  `json:"createdAt,omitempty"`
	PageID               string  `json:"pageId,omitempty"`
	BlogPostID           string  `json:"blogPostId,omitempty"`
	CustomContentID      string  `json:"customContentId,omitempty"`
	MediaType            string  `json:"mediaType,omitempty"`
	MediaTypeDescription string  `json:"mediaTypeDescription,omitempty"`
	Comment              string  `json:"comment,omitempty"`
	FileID               string  `json:"fileId,omitempty"`
	FileSize             int     `json:"fileSize,omitempty"`
	WebuiLink            string  `json:"webuiLink,omitempty"`
	DownloadLink         string  `json:"downloadLink,omitempty"`
	Version              Version `json:"version,omitempty"`
	Links                Links   `json:"_links,omitempty"`
}

type PageVersion

type PageVersion struct {
	Number    int       `json:"number,omitempty"`
	Message   string    `json:"message,omitempty"`
	MinorEdit bool      `json:"minorEdit,omitempty"`
	AuthorID  string    `json:"authorId,omitempty"`
	CreatedAt time.Time `json:"createdAt,omitempty"`
}

type PreRequestFn

type PreRequestFn func(request *http.Request)

PreRequestFn ...

type QueryParameters

type QueryParameters struct {
	Expand []string `url:"expand,omitempty"`
	Status string   `url:"status,omitempty"`
}

QueryParameters provides default query parameters for client

type SearchQueryParameters

type SearchQueryParameters struct {
	CQL                   string `url:"cql"`
	CQLContext            string `url:"cqlcontext,omitempty"`
	IncludeArchivedSpaces bool   `url:"includeArchivedSpaces,omitempty"`
	Limit                 int    `url:"limit,omitempty"`
	Start                 int    `url:"start,omitempty"`
}

SearchQueryParameters query parameters for Search

type SearchResponse

type SearchResponse struct {
	APIResponse
	Results        []SearchResult `json:"results,omitempty"`
	Start          int            `json:"start,omitempty"`
	Limit          int            `json:"limit,omitempty"`
	Size           int            `json:"size,omitempty"`
	TotalSize      int            `json:"totalSize,omitempty"`
	CqlQuery       string         `json:"cqlQuery,omitempty"`
	SearchDuration int            `json:"searchDuration,omitempty"`
	Links          struct {
		Base    string `json:"base,omitempty"`
		Context string `json:"context,omitempty"`
	} `json:"_links,omitempty"`
}

SearchResponse represents the data returned from the Confluence API

type SearchResult

type SearchResult struct {
	Space struct {
		Key      string `json:"key,omitempty"`
		Name     string `json:"name,omitempty"`
		Type     string `json:"type,omitempty"`
		Metadata struct {
		} `json:"metadata,omitempty"`
		Status     string `json:"status,omitempty"`
		Expandable struct {
			Operations  string `json:"operations,omitempty"`
			Permissions string `json:"permissions,omitempty"`
			Description string `json:"description,omitempty"`
		} `json:"_expandable,omitempty"`
		Links struct {
			Self string `json:"self,omitempty"`
		} `json:"_links,omitempty"`
	} `json:"space,omitempty"`
	Title                 string `json:"title,omitempty"`
	Excerpt               string `json:"excerpt,omitempty"`
	URL                   string `json:"url,omitempty"`
	ResultGlobalContainer struct {
		Title      string `json:"title"`
		DisplayURL string `json:"displayUrl"`
	} `json:"resultGlobalContainer"`
	Breadcrumbs          []interface{} `json:"breadcrumbs,omitempty"`
	EntityType           string        `json:"entityType,omitempty"`
	IconCSSClass         string        `json:"iconCssClass,omitempty"`
	LastModified         time.Time     `json:"lastModified,omitempty"`
	FriendlyLastModified string        `json:"friendlyLastModified,omitempty"`
	Score                float64       `json:"score,omitempty"`
	Content              `json:"content,omitempty"`
}

SearchResult results from Search

type Space

type Space struct {
	CreatedAt   time.Time `json:"createdAt,omitempty"`
	AuthorID    string    `json:"authorId,omitempty"`
	HomepageID  string    `json:"homepageId,omitempty"`
	Icon        any       `json:"icon,omitempty"`
	Name        string    `json:"name,omitempty"`
	Key         string    `json:"key,omitempty"`
	ID          string    `json:"id,omitempty"`
	Type        string    `json:"type,omitempty"`
	Description any       `json:"description,omitempty"`
	Status      string    `json:"status,omitempty"`
	Links       Links     `json:"_links,omitempty"`
}

type Version

type Version struct {
	CreatedAt string `json:"createdAt,omitempty"`
	Message   string `json:"message,omitempty"`
	Number    int    `json:"number,omitempty"`
	MinorEdit bool   `json:"minorEdit,omitempty"`
	AuthorID  string `json:"authorId,omitempty"`
}

Jump to

Keyboard shortcuts

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