Documentation ¶
Index ¶
- Constants
- type APIResponse
- type Attachment
- type AttachmentExpandable
- type AttachmentExtensions
- type AttachmentFetchResult
- type AttachmentLabels
- type AttachmentLinks
- type AttachmentMetaData
- type AttachmentResults
- type Attachments
- type Body
- type Client
- func (client *Client) AddAttachment(contentID, path string) (*Attachment, error)
- func (client *Client) AddLabels(contentID string, labels []string, prefix LabelPrefix) error
- func (client *Client) AddUpdateAttachments(contentID string, files []string) ([]*Attachment, []error)
- func (client *Client) CreateContent(bp *CreateContentBodyParameters, qp *QueryParameters) (Content, error)
- func (client *Client) CreatePage(createPageBody *CreatePageBody, qp *CreatePageQueryParameters) (Page, error)
- func (client *Client) Delete(class interface{}) error
- func (client *Client) DeleteAllPagesInSpace(spaceID string) error
- func (client *Client) DeleteAttachment(contentID string, attachmentID string) error
- func (client *Client) DeleteContent(content Content) error
- func (client *Client) DeletePage(pageID string, qp *DeletePageQueryParameters) error
- func (client *Client) DownloadAttachmentsFromPage(pageID, directory string) error
- func (client *Client) DownloadFromURL(url, outputFilepath string) error
- func (client *Client) FetchAttachmentMetaData(contentID string) (*AttachmentResults, error)
- func (client *Client) GetAttachment(contentID, attachmentID string) (*Attachment, error)
- func (client *Client) GetAttachmentByFilename(contentID, filename string) (*Attachment, error)
- func (client *Client) GetContent(qp *GetContentQueryParameters) ([]Content, error)
- func (client *Client) GetPageAttachmentByFilename(pageID, filename string) (PageAttachment, error)
- func (client *Client) GetPageAttachments(pageID string, qp *GetAttachmentsForPageQueryParameters) (GetAttachmentsForPageResponse, error)
- func (client *Client) GetPages(qp *GetPageseQueryParameters) (GetPagesResponse, error)
- func (client *Client) GetPagesInSpace(id string, qp *GetPagesInSpaceQueryParameters) (GetPagesInSpaceResponse, error)
- func (client *Client) GetSpaceByKey(key string) (*Space, error)
- func (client *Client) GetSpaces(qp *GetSpacesQueryParameters) (GetSpacesResponse, error)
- func (client *Client) Search(qp *SearchQueryParameters) ([]SearchResult, error)
- func (client *Client) UpdateAttachment(contentID, attachmentID, path string, minorEdit bool) (*Attachment, error)
- func (client *Client) UpdateContent(content *Content, qp *QueryParameters) (Content, error)
- func (client *Client) UpdatePage(pageID string, createPageBody *CreatePageBody) (Page, error)
- func (client *Client) UpdatePageWithVersionBump(pageID string, createPageBody *CreatePageBody) (Page, error)
- func (client *Client) UpdateSpaceHomePage(key string, pageID string) error
- type Content
- type ContentBody
- type ContentResponse
- type CreateContentBodyParameters
- type CreatePageBody
- type CreatePageQueryParameters
- type DeletePageQueryParameters
- type ErrorResponse
- type Errors
- type GetAttachmentsForPageQueryParameters
- type GetAttachmentsForPageResponse
- type GetContentQueryParameters
- type GetPagesInSpaceQueryParameters
- type GetPagesInSpaceResponse
- type GetPagesResponse
- type GetPageseQueryParameters
- type GetResultsQueryParameters
- type GetSpacesQueryParameters
- type GetSpacesResponse
- type LabelPrefix
- type Links
- type Page
- type PageAttachment
- type PageVersion
- type PreRequestFn
- type QueryParameters
- type SearchQueryParameters
- type SearchResponse
- type SearchResult
- type Space
- type Version
Constants ¶
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 ¶
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) DeleteAllPagesInSpace ¶
UpdatePage update a page by id https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-id-delete
func (*Client) DeleteAttachment ¶
DeleteAttachment ..
func (*Client) DeleteContent ¶
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) DeletePage ¶
func (client *Client) DeletePage(pageID string, qp *DeletePageQueryParameters) error
UpdatePage update a page by id https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-id-delete
func (*Client) DownloadAttachmentsFromPage ¶
DownloadAttachmentsFromPage ...
func (*Client) DownloadFromURL ¶
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) GetPageAttachments ¶
func (client *Client) GetPageAttachments(pageID string, qp *GetAttachmentsForPageQueryParameters) (GetAttachmentsForPageResponse, error)
GetAttachmentsForPage returns the attachments of specific page https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-attachment/#api-pages-id-attachments-get
func (*Client) GetPages ¶
func (client *Client) GetPages(qp *GetPageseQueryParameters) (GetPagesResponse, error)
UpdatePage update a page by id https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-get
func (*Client) GetPagesInSpace ¶
func (client *Client) GetPagesInSpace(id string, qp *GetPagesInSpaceQueryParameters) (GetPagesInSpaceResponse, error)
GetPagesInSpace Returns all pages https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-spaces-id-pages-get
func (*Client) GetSpaces ¶
func (client *Client) GetSpaces(qp *GetSpacesQueryParameters) (GetSpacesResponse, error)
GetSpaces returns all spaces https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-space/#api-spaces-get
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 ¶
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 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 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 GetPagesResponse ¶
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 LabelPrefix ¶
type LabelPrefix string
LabelPrefix ...
const ( // GlobalPrefix ... GlobalPrefix LabelPrefix = "global" // LocalPrefix ... LocalPrefix LabelPrefix = "local" )
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 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"` }