Documentation ¶
Overview ¶
Package goconfluence implementing atlassian's Confluence API
Simple example:
//Initialize a new API instance api, err := goconfluence.NewAPI( "https://<your-domain>.atlassian.net/wiki/rest/api", "<username>", "<api-token>", ) if err != nil { log.Fatal(err) } // get current user information currentUser, err := api.CurrentUser() if err != nil { log.Fatal(err) } fmt.Printf("%+v\n", currentUser)
supported features:
- get user information
- create, update, delete content
- get comments, attachments, history, watchers and children of content objects
- get, add, delete labels
- search using CQL
see https://github.com/virtomize/confluence-go-api/tree/master/examples for more information and usage examples
Index ¶
- Variables
- func Debug(msg interface{})
- func SetDebug(state bool)
- func StripHTML(buf []byte, bodyOnly, stripImg bool) string
- type API
- func (a *API) AddLabels(id string, labels *[]Label) (*Labels, error)
- func (a *API) AddPage(title, spaceKey, filepath string, bodyOnly, stripImgs bool, ancestor string) error
- func (a *API) AddSpaceCategory(spaceKey string, category string) (*AddCategoryResponseType, error)
- func (a *API) AnonymousUser() (*User, error)
- func (a *API) Auth(req *http.Request)
- func (a *API) CreateContent(c *Content) (*Content, error)
- func (a *API) CurrentUser() (*User, error)
- func (a *API) DelContent(id string) (*Content, error)
- func (a *API) DeleteLabel(id string, name string) (*Labels, error)
- func (a *API) DoRequest(endpoint string, method string, responseContainer interface{}) error
- func (a *API) GetAllGroupsWithAnyPermission(spacekey string, options *PaginationOptions) (*GetAllGroupsWithAnyPermissionType, error)
- func (a *API) GetAllSpaces(query AllSpacesQuery) (*AllSpaces, error)
- func (a *API) GetAllUsersWithAnyPermission(spacekey string, options *PaginationOptions) (*GetAllUsersWithAnyPermissionType, error)
- func (a *API) GetAttachments(id string) (*Search, error)
- func (a *API) GetBlueprintTemplates(query TemplateQuery) (*TemplateSearch, error)
- func (a *API) GetChildPages(id string) (*Search, error)
- func (a *API) GetComments(id string) (*Search, error)
- func (a *API) GetContent(query ContentQuery) (*ContentSearch, error)
- func (a *API) GetContentByID(id string, query ContentQuery) (*Content, error)
- func (a *API) GetContentTemplates(query TemplateQuery) (*TemplateSearch, error)
- func (a *API) GetContentVersion(id string) (*ContentVersionResult, error)
- func (a *API) GetGroupPermissionsForSpace(spacekey, group string) (*GetPermissionsForSpaceType, error)
- func (a *API) GetGroups(options *GetGroupMembersOptions) (*GroupsType, error)
- func (a *API) GetHistory(id string) (*History, error)
- func (a *API) GetLabels(id string) (*Labels, error)
- func (a *API) GetPageId(spacename string, pagename string) (*ContentSearch, error)
- func (a *API) GetPermissionTypes() (*PermissionsTypes, error)
- func (a *API) GetUserPermissionsForSpace(spacekey, user string) (*GetPermissionsForSpaceType, error)
- func (a *API) GetUsers(group string, options *GetGroupMembersOptions) (*UsersType, error)
- func (a *API) GetWatchers(id string) (*Watchers, error)
- func (a *API) Request(req *http.Request) ([]byte, error)
- func (a *API) Search(query SearchQuery) (*Search, error)
- func (a *API) SendAddCategoryRequest(ep *url.URL, method string) (*AddCategoryResponseType, error)
- func (a *API) SendAllSpacesRequest(ep *url.URL, method string) (*AllSpaces, error)
- func (a *API) SendContentAttachmentRequest(ep *url.URL, attachmentName string, attachment io.Reader, ...) (*Search, error)
- func (a *API) SendContentRequest(ep *url.URL, method string, c *Content) (*Content, error)
- func (a *API) SendContentVersionRequest(ep *url.URL, method string) (*ContentVersionResult, error)
- func (a *API) SendGenericRequest(ep, method string) ([]byte, error)
- func (a *API) SendHistoryRequest(ep *url.URL, method string) (*History, error)
- func (a *API) SendLabelRequest(ep *url.URL, method string, labels *[]Label) (*Labels, error)
- func (a *API) SendSearchRequest(ep *url.URL, method string) (*Search, error)
- func (a *API) SendUserRequest(ep *url.URL, method string) (*User, error)
- func (a *API) SendWatcherRequest(ep *url.URL, method string) (*Watchers, error)
- func (a *API) UpdateAttachment(id string, attachmentName string, attachmentID string, attachment io.Reader) (*Search, error)
- func (a *API) UpdateContent(c *Content) (*Content, error)
- func (a *API) UploadAttachment(id string, attachmentName string, attachment io.Reader) (*Search, error)
- func (a *API) UppdateAttachment(spacename string, pagename string, filename string) error
- func (a *API) User(query string) (*User, error)
- func (a *API) VerifyTLS(set bool)
- type AddCategoryResponseType
- type AllSpaces
- type AllSpaces2
- type AllSpacesQuery
- type Ancestor
- type Body
- type BodyExportView
- type Content
- type ContentAppearanceDraft
- type ContentAppearancePublished
- type ContentQuery
- type ContentSearch
- type ContentVersionResult
- type Editor
- type GetAllGroupsWithAnyPermissionType
- type GetAllUsersWithAnyPermissionType
- type GetGroupMembersOptions
- type GetPermissionsForSpaceType
- type GroupsType
- type History
- type Label
- type Labels
- type LastUpdated
- type Links
- type Metadata
- type PaginationOptions
- type PermissionsTypes
- type Properties
- type Results
- type Search
- type SearchQuery
- type Space
- type Storage
- type Template
- type TemplateQuery
- type TemplateSearch
- type User
- type UsersType
- type Version
- type Watcher
- type Watchers
Constants ¶
This section is empty.
Variables ¶
var DebugFlag = false
DebugFlag is the global debugging variable
Functions ¶
Types ¶
type API ¶
API is the main api data structure
func NewAPIWithClient ¶
NewAPIWithClient creates a new API instance using an existing HTTP client. Useful when using oauth or other authentication methods.
func (*API) AddPage ¶
func (a *API) AddPage(title, spaceKey, filepath string, bodyOnly, stripImgs bool, ancestor string) error
AddPage adds a new page to the space with the given title, TODO what if page already exists?
func (*API) AddSpaceCategory ¶
func (a *API) AddSpaceCategory(spaceKey string, category string) (*AddCategoryResponseType, error)
AddSpaceCategory /rest/extender/1.0/category/addSpaceCategory/space/{SPACE_KEY}/category/{CATEGORY_NAME}
func (*API) AnonymousUser ¶
AnonymousUser return user information for anonymous user
func (*API) CreateContent ¶
CreateContent creates content
func (*API) CurrentUser ¶
CurrentUser return current user information
func (*API) DelContent ¶
DelContent deletes content by id
func (*API) DeleteLabel ¶
DeleteLabel removes a label by name from content identified by id
func (*API) GetAllGroupsWithAnyPermission ¶
func (a *API) GetAllGroupsWithAnyPermission(spacekey string, options *PaginationOptions) (*GetAllGroupsWithAnyPermissionType, error)
func (*API) GetAllSpaces ¶
func (a *API) GetAllSpaces(query AllSpacesQuery) (*AllSpaces, error)
GetAllSpaces queries content using a query parameters
func (*API) GetAllUsersWithAnyPermission ¶
func (a *API) GetAllUsersWithAnyPermission(spacekey string, options *PaginationOptions) (*GetAllUsersWithAnyPermissionType, error)
func (*API) GetAttachments ¶
GetAttachments returns a list of attachments belonging to id
func (*API) GetBlueprintTemplates ¶
func (a *API) GetBlueprintTemplates(query TemplateQuery) (*TemplateSearch, error)
GetBlueprintTemplates querys for content blueprints defined by TemplateQuery parameters
func (*API) GetChildPages ¶
GetChildPages returns a content list of child page objects
func (*API) GetComments ¶
GetComments returns a list of comments belonging to id
func (*API) GetContent ¶
func (a *API) GetContent(query ContentQuery) (*ContentSearch, error)
GetContent querys content using a query parameters
func (*API) GetContentByID ¶
func (a *API) GetContentByID(id string, query ContentQuery) (*Content, error)
GetContentByID querys content by id
func (*API) GetContentTemplates ¶
func (a *API) GetContentTemplates(query TemplateQuery) (*TemplateSearch, error)
GetContentTemplates querys for content templates
func (*API) GetContentVersion ¶
func (a *API) GetContentVersion(id string) (*ContentVersionResult, error)
GetContentVersion gets all versions of this content
func (*API) GetGroupPermissionsForSpace ¶
func (a *API) GetGroupPermissionsForSpace(spacekey, group string) (*GetPermissionsForSpaceType, error)
func (*API) GetGroups ¶
func (a *API) GetGroups(options *GetGroupMembersOptions) (*GroupsType, error)
func (*API) GetHistory ¶
GetHistory returns history information
func (*API) GetPageId ¶
func (a *API) GetPageId(spacename string, pagename string) (*ContentSearch, error)
func (*API) GetPermissionTypes ¶
func (a *API) GetPermissionTypes() (*PermissionsTypes, error)
func (*API) GetUserPermissionsForSpace ¶
func (a *API) GetUserPermissionsForSpace(spacekey, user string) (*GetPermissionsForSpaceType, error)
func (*API) GetUsers ¶
func (a *API) GetUsers(group string, options *GetGroupMembersOptions) (*UsersType, error)
func (*API) GetWatchers ¶
GetWatchers returns a list of watchers
func (*API) Search ¶
func (a *API) Search(query SearchQuery) (*Search, error)
Search querys confluence using CQL
func (*API) SendAddCategoryRequest ¶
func (*API) SendAllSpacesRequest ¶
SendAllSpacesRequest sends a request for all spaces
func (*API) SendContentAttachmentRequest ¶
func (a *API) SendContentAttachmentRequest(ep *url.URL, attachmentName string, attachment io.Reader, params map[string]string) (*Search, error)
SendContentAttachmentRequest sends a multipart/form-data attachment create/update request to a content
func (*API) SendContentRequest ¶
SendContentRequest sends content related requests this function is used for getting, updating and deleting content
func (*API) SendContentVersionRequest ¶
SendContentVersionRequest requests a version of a specific content
func (*API) SendGenericRequest ¶
SendGenericRequest sends a greneric request
func (*API) SendHistoryRequest ¶
SendHistoryRequest requests history
func (*API) SendLabelRequest ¶
SendLabelRequest requests history
func (*API) SendSearchRequest ¶
SendSearchRequest sends search related requests
func (*API) SendUserRequest ¶
SendUserRequest sends user related requests
func (*API) SendWatcherRequest ¶
SendWatcherRequest requests watchers
func (*API) UpdateAttachment ¶
func (a *API) UpdateAttachment(id string, attachmentName string, attachmentID string, attachment io.Reader) (*Search, error)
UpdateAttachment update the attachment with an attachmentID on a page with an id to a new version
func (*API) UpdateContent ¶
UpdateContent updates content
func (*API) UploadAttachment ¶
func (a *API) UploadAttachment(id string, attachmentName string, attachment io.Reader) (*Search, error)
UploadAttachment uploaded the given reader as an attachment to the page with the given id. The existing attachment won't be updated with a new version number
func (*API) UppdateAttachment ¶
type AddCategoryResponseType ¶
type AddCategoryResponseType struct {
Status string `json:"status"`
}
type AllSpaces ¶
type AllSpaces struct { Links struct { Base string `json:"base"` Context string `json:"context"` Self string `json:"self"` } `json:"_links"` Limit int64 `json:"limit"` Results []struct { Expandable struct { Description string `json:"description"` Homepage string `json:"homepage"` Icon string `json:"icon"` Metadata string `json:"metadata"` RetentionPolicy string `json:"retentionPolicy"` } `json:"_expandable"` Links struct { Self string `json:"self"` Webui string `json:"webui"` } `json:"_links"` ID int64 `json:"id"` Key string `json:"key"` Name string `json:"name"` Type string `json:"type"` } `json:"results"` Size int64 `json:"size"` Start int64 `json:"start"` }
type AllSpaces2 ¶
type AllSpaces2 struct { Links struct { Base string `json:"base"` Context string `json:"context"` Self string `json:"self"` } `json:"_links"` Limit int64 `json:"limit"` Results []struct { Expandable struct { Description string `json:"description"` Homepage string `json:"homepage"` Icon string `json:"icon"` Metadata string `json:"metadata"` RetentionPolicy string `json:"retentionPolicy"` } `json:"_expandable"` Links struct { Self string `json:"self"` Webui string `json:"webui"` } `json:"_links"` ID int64 `json:"id"` Key string `json:"key"` Name string `json:"name"` Type string `json:"type"` } `json:"results"` Size int64 `json:"size"` Start int64 `json:"start"` }
type AllSpacesQuery ¶
type AllSpacesQuery struct { Expand []string Favourite bool // Filter the results to the favourite spaces of the user specified by favouriteUserKey FavouriteUserKey string // The userKey of the user, whose favourite spaces are used to filter the results when using the favourite parameter. Leave blank for the current user Limit int // page limit SpaceKey string Start int // page start Status string // current, archived Type string // global, personal Label string }
AllSpacesQuery defines the query parameters Query parameter values https://developer.atlassian.com/cloud/confluence/rest/#api-space-get
type Ancestor ¶
type Ancestor struct {
ID string `json:"id"`
}
Ancestor defines ancestors to create sub pages
type BodyExportView ¶
type BodyExportView struct { ExportView *Storage `json:"export_view"` View *Storage `json:"view,omitempty"` }
BodyExportView holds the export_view information
type Content ¶
type Content struct { ID string `json:"id,omitempty"` Type string `json:"type"` Status string `json:"status,omitempty"` Title string `json:"title"` Ancestors []Ancestor `json:"ancestors,omitempty"` Body Body `json:"body"` Version *Version `json:"version,omitempty"` Space Space `json:"space"` History *History `json:"history,omitempty"` Links *Links `json:"_links,omitempty"` Metadata *Metadata `json:"metadata"` }
Content specifies content properties
type ContentAppearanceDraft ¶
type ContentAppearanceDraft struct {
Value string `json:"value"`
}
ContentAppearanceDraft sets the appearance of the content in draft form
type ContentAppearancePublished ¶
type ContentAppearancePublished struct {
Value string `json:"value"`
}
ContentAppearancePublished sets the appearance of the content in published form
type ContentQuery ¶
type ContentQuery struct { Expand []string Limit int // page limit OrderBy string // fieldpath asc/desc e.g: "history.createdDate desc" PostingDay string // required for blogpost type Format: yyyy-mm-dd SpaceKey string Start int // page start Status string // current, trashed, draft, any Title string // required for page Trigger string // viewed Type string // page, blogpost Version int //version number when not lastest }
ContentQuery defines the query parameters used for content related searching Query parameter values https://developer.atlassian.com/cloud/confluence/rest/#api-content-get
type ContentSearch ¶
type ContentSearch struct { Results []Content `json:"results"` Start int `json:"start,omitempty"` Limit int `json:"limit,omitempty"` Size int `json:"size,omitempty"` }
ContentSearch results
type ContentVersionResult ¶
type ContentVersionResult struct { Links struct { Base string `json:"base"` Context string `json:"context"` Self string `json:"self"` } `json:"_links"` Limit int64 `json:"limit"` Results []struct { Expandable struct { Content string `json:"content"` } `json:"_expandable"` Links struct { Self string `json:"self"` } `json:"_links"` By struct { DisplayName string `json:"displayName"` ProfilePicture struct { Height int64 `json:"height"` IsDefault bool `json:"isDefault"` Path string `json:"path"` Width int64 `json:"width"` } `json:"profilePicture"` Type string `json:"type"` } `json:"by"` Hidden bool `json:"hidden"` Message string `json:"message"` MinorEdit bool `json:"minorEdit"` Number int64 `json:"number"` When string `json:"when"` } `json:"results"` Size int64 `json:"size"` Start int64 `json:"start"` }
type GetGroupMembersOptions ¶
type GroupsType ¶
type History ¶
type History struct { LastUpdated LastUpdated `json:"lastUpdated"` Latest bool `json:"latest"` CreatedBy User `json:"createdBy"` CreatedDate string `json:"createdDate"` }
History contains object history information
type Label ¶
type Label struct { Prefix string `json:"prefix"` Name string `json:"name"` ID string `json:"id,omitempty"` Label string `json:"label,omitempty"` }
Label contains label information
type Labels ¶
type Labels struct { Labels []Label `json:"results"` Start int `json:"start,omitempty"` Limit int `json:"limit,omitempty"` Size int `json:"size,omitempty"` }
Labels is the label containter type
type LastUpdated ¶
type LastUpdated struct { By User `json:"by"` When string `json:"when"` FriendlyWhen string `json:"friendlyWhen"` Message string `json:"message"` Number int `json:"number"` MinorEdit bool `json:"minorEdit"` SyncRev string `json:"syncRev"` ConfRev string `json:"confRev"` }
LastUpdated contains information about the last update
type Metadata ¶
type Metadata struct {
Properties *Properties `json:"properties"`
}
Metadata specifies metadata properties
type PaginationOptions ¶
type PermissionsTypes ¶
type PermissionsTypes []string
type Properties ¶
type Properties struct { Editor *Editor `json:"editor"` ContentAppearanceDraft *ContentAppearanceDraft `json:"content-appearance-draft"` ContentAppearancePublished *ContentAppearancePublished `json:"content-appearance-published"` }
Properties defines properties of the editor
type Results ¶
type Results struct { ID string `json:"id,omitempty"` Type string `json:"type,omitempty"` Status string `json:"status,omitempty"` Content Content `json:"content"` Excerpt string `json:"excerpt,omitempty"` Title string `json:"title,omitempty"` URL string `json:"url,omitempty"` }
Results array
type Search ¶
type Search struct { Results []Results `json:"results"` Start int `json:"start,omitempty"` Limit int `json:"limit,omitempty"` Size int `json:"size,omitempty"` ID string `json:"id,omitempty"` TotalSize int `json:"totalSize,omitempty"` }
Search results
type SearchQuery ¶
type SearchQuery struct { CQL string CQLContext string IncludeArchivedSpaces bool Limit int Start int Expand []string }
SearchQuery defines query parameters used for searchng Query parameter values https://developer.atlassian.com/cloud/confluence/rest/#api-search-get
type Space ¶
type Space struct { ID int `json:"id,omitempty"` Key string `json:"key,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Status string `json:"status,omitempty"` }
Space holds the Space information of a Content Page
type Template ¶
type Template struct { ID string `json:"templateId,omitempty"` Name string `json:"name,omitempty"` Type string `json:"templateType,omitempty"` Description string `json:"description"` Body Body `json:"body"` Space Space `json:"space"` }
Template contains blueprint data
type TemplateQuery ¶
type TemplateQuery struct { SpaceKey string Start int // page start Limit int // page limit Expand []string }
TemplateQuery defines the query parameters
type TemplateSearch ¶
type TemplateSearch struct { Results []Template `json:"results"` Start int `json:"start,omitempty"` Limit int `json:"limit,omitempty"` Size int `json:"size,omitempty"` }
TemplateSearch contains blueprint search results
type User ¶
type User struct { Type string `json:"type"` Username string `json:"username"` UserKey string `json:"userKey"` AccountID string `json:"accountId"` DisplayName string `json:"displayName"` }
User defines user informations
type UsersType ¶
type UsersType struct { MaxResults int64 `json:"maxResults"` StartAt int64 `json:"startAt"` Status string `json:"status"` Total int64 `json:"total"` Users []struct { Business []struct { Department string `json:"department"` Location string `json:"location"` Position string `json:"position"` } `json:"business"` CreatedDate int64 `json:"createdDate"` CreatedDateString string `json:"createdDateString"` Email string `json:"email"` FullName string `json:"fullName"` HasAccessToUseConfluence bool `json:"hasAccessToUseConfluence"` Key string `json:"key"` LastFailedLoginDate interface{} `json:"lastFailedLoginDate"` LastFailedLoginDateString interface{} `json:"lastFailedLoginDateString"` LastSuccessfulLoginDate int64 `json:"lastSuccessfulLoginDate"` LastSuccessfulLoginDateString string `json:"lastSuccessfulLoginDateString"` Name string `json:"name"` Personal []struct { Im string `json:"im"` Phone string `json:"phone"` Website string `json:"website"` } `json:"personal"` UpdatedDate int64 `json:"updatedDate"` UpdatedDateString string `json:"updatedDateString"` } `json:"users"` }
type Version ¶
type Version struct { Number int `json:"number"` MinorEdit bool `json:"minorEdit"` Message string `json:"message,omitempty"` By *User `json:"by,omitempty"` }
Version defines the content version number the version number is used for updating content
Source Files ¶
- api.go
- auth.go
- content.go
- doc.go
- extender-dtos.go
- extender.go
- get-admin-permissions-dtos.go
- get-groups-dtos.go
- get-permissions-dtos.go
- get-users-dtos.go
- get-users-permissions-dtos.go
- get-usersperm-dtos.go
- html-utilities.go
- internal.go
- permissions-dtos.go
- request.go
- search.go
- space-dtos.go
- space.go
- template.go
- user.go
- version-dtos.go