client

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurrentUserUrlPath = "/wiki/rest/api/user/current"
	GroupsListUrlPath  = "/wiki/rest/api/group"

	SearchUrlPath = "/wiki/rest/api/search/user"

	SpacesListUrlPath = "/wiki/api/v2/spaces"

	SpacePermissionsListUrlPath = "/wiki/api/v2/spaces/%s/permissions"
	SpaceRolesUrlPath           = "/wiki/api/v2/space-roles"
	SpaceRoleAssignmentsUrlPath = "/wiki/api/v2/spaces/%s/role-assignments"
	SpaceRoleModeUrlPath        = "/wiki/api/v2/space-role-mode"
)

Variables

This section is empty.

Functions

func WithConfluenceRatelimitData

func WithConfluenceRatelimitData(resource *v2.RateLimitDescription) uhttp.DoOption

WithConfluenceRatelimitData Per the docs: transient 5XX errors should be treated as 429/too-many-requests if they have a retry header. 503 errors were the only ones explicitly called out, but I guess it's possible for others too https://developer.atlassian.com/cloud/confluence/rate-limiting/

Types

type AddUserToGroupRequestBody

type AddUserToGroupRequestBody struct {
	AccountId string `json:"accountId"`
}

type ConfluenceClient

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

func NewConfluenceClient

func NewConfluenceClient(ctx context.Context, user, apiKey, domain string) (*ConfluenceClient, error)

func (*ConfluenceClient) AddSpacePermission

func (c *ConfluenceClient) AddSpacePermission(
	ctx context.Context,
	spaceName string,
	key string,
	target string,
	principalId string,
	principalType string,
) (
	*v2.RateLimitDescription,
	error,
)

func (*ConfluenceClient) AddUserToGroup

func (c *ConfluenceClient) AddUserToGroup(
	ctx context.Context,
	accountID string,
	groupId string,
) (*v2.RateLimitDescription, error)

func (*ConfluenceClient) ConfluenceSpaceOperations

func (c *ConfluenceClient) ConfluenceSpaceOperations(
	ctx context.Context,
	cursor string,
	pageSize int,
	spaceId string,
) (
	[]ConfluenceSpaceOperation,
	string,
	*v2.RateLimitDescription,
	error,
)

func (*ConfluenceClient) GetGroupMembers

func (c *ConfluenceClient) GetGroupMembers(
	ctx context.Context,
	pageToken string,
	pageSize int,
	groupId string,
) (
	[]ConfluenceUser,
	string,
	*v2.RateLimitDescription,
	error,
)

func (*ConfluenceClient) GetGroups

func (c *ConfluenceClient) GetGroups(
	ctx context.Context,
	pageToken string,
	pageSize int,
) (
	[]ConfluenceGroup,
	string,
	*v2.RateLimitDescription,
	error,
)

func (*ConfluenceClient) GetSpaceById added in v0.0.19

func (c *ConfluenceClient) GetSpaceById(
	ctx context.Context,
	spaceId string,
) (*ConfluenceSpace, *v2.RateLimitDescription, error)

GetSpaceById fetches a single space by its ID.

func (*ConfluenceClient) GetSpacePermissions

func (c *ConfluenceClient) GetSpacePermissions(
	ctx context.Context,
	pageToken string,
	pageSize int,
	spaceId string,
) (
	[]ConfluenceSpacePermission,
	string,
	*v2.RateLimitDescription,
	error,
)

func (*ConfluenceClient) GetSpaceRoleAssignments added in v0.0.19

func (c *ConfluenceClient) GetSpaceRoleAssignments(
	ctx context.Context,
	spaceId string,
	roleId string,
	principalId string,
	principalType string,
	cursor string,
	pageSize int,
) (
	[]SpaceRoleAssignment,
	string,
	*v2.RateLimitDescription,
	error,
)

GetSpaceRoleAssignments fetches role assignments for a given space. roleId, principalId, and principalType are optional filters; pass empty string to omit.

func (*ConfluenceClient) GetSpaceRoles added in v0.0.19

func (c *ConfluenceClient) GetSpaceRoles(
	ctx context.Context,
	spaceId string,
	cursor string,
	pageSize int,
) (
	[]SpaceRole,
	string,
	*v2.RateLimitDescription,
	error,
)

GetSpaceRoles fetches space roles from the v2 API, optionally filtered by spaceId.

func (*ConfluenceClient) GetSpaces

func (c *ConfluenceClient) GetSpaces(
	ctx context.Context,
	pageSize int,
	paginationCursor string,
) (
	[]ConfluenceSpace,
	string,
	*v2.RateLimitDescription,
	error,
)

GetSpaces uses pagination to get a list of spaces from the global list.

func (*ConfluenceClient) GetUsersFromSearch

func (c *ConfluenceClient) GetUsersFromSearch(
	ctx context.Context,
	pageToken string,
	pageSize int,
) (
	[]ConfluenceUser,
	string,
	*v2.RateLimitDescription,
	error,
)

GetUsersFromSearch There are no official, documented ways to get lists of users in Confluence. One way to get users is to issue a CQL search query with no conditions. The documentation mentions that queries return "up to 10k" users. So that may end up being a limitation of this approach.

func (*ConfluenceClient) RemoveSpacePermission

func (c *ConfluenceClient) RemoveSpacePermission(
	ctx context.Context,
	spaceId string,
	key string,
	target string,
	principalId string,
	principalType string,
) (
	*v2.RateLimitDescription,
	error,
)

func (*ConfluenceClient) RemoveUserFromGroup

func (c *ConfluenceClient) RemoveUserFromGroup(
	ctx context.Context,
	accountID string,
	groupId string,
) (*v2.RateLimitDescription, error)

func (*ConfluenceClient) SetSpaceRoleAssignment added in v0.0.19

func (c *ConfluenceClient) SetSpaceRoleAssignment(
	ctx context.Context,
	spaceId string,
	assignments []SetSpaceRoleAssignmentRequest,
) (
	*v2.RateLimitDescription,
	error,
)

SetSpaceRoleAssignment adds role assignments for a space.

func (*ConfluenceClient) Verify

func (c *ConfluenceClient) Verify(ctx context.Context) error

func (*ConfluenceClient) VerifyRbac added in v0.0.19

func (c *ConfluenceClient) VerifyRbac(ctx context.Context) error

VerifyRbac validates credentials by hitting the v2 space-role-mode endpoint. Use this instead of Verify when the connector is configured for RBAC mode, as those credentials may only have access to the v2 API.

type ConfluenceGroup

type ConfluenceGroup struct {
	Type string
	Name string
	Id   string
}
type ConfluenceLink struct {
	Base string `json:"base"`
	Next string `json:"next,omitempty"`
}

type ConfluenceMeta

type ConfluenceMeta struct {
	HasMore bool   `json:"hasMore"`
	Cursor  string `json:"cursor"`
}

type ConfluenceOperation

type ConfluenceOperation struct {
	Operation  string `json:"operation"`
	TargetType string `json:"targetType"`
}

type ConfluenceSearch

type ConfluenceSearch struct {
	EntityType string         `json:"entityType"`
	Score      float64        `json:"score"`
	Title      string         `json:"title"`
	User       ConfluenceUser `json:"user"`
}

type ConfluenceSearchList

type ConfluenceSearchList struct {
	Start     int                `json:"start"`
	Limit     int                `json:"limit"`
	TotalSize int                `json:"totalSize"`
	Size      int                `json:"size"`
	Results   []ConfluenceSearch `json:"results"`
}

type ConfluenceSpace

type ConfluenceSpace struct {
	AuthorId    string                            `json:"authorId"`
	CreatedAt   string                            `json:"createdAt"`
	Description ConfluenceSpaceDescription        `json:"description"`
	HomepageId  string                            `json:"homepageId"`
	Icon        string                            `json:"icon"`
	Id          string                            `json:"id"`
	Key         string                            `json:"key"`
	Name        string                            `json:"name"`
	Operations  ConfluenceSpaceOperationsResponse `json:"operations"`
	Status      string                            `json:"status"`
	Type        string                            `json:"type"`
}

type ConfluenceSpaceDescription

type ConfluenceSpaceDescription struct {
	Plain ConfluenceSpaceDescriptionValue `json:"plain"`
}

type ConfluenceSpaceDescriptionValue

type ConfluenceSpaceDescriptionValue struct {
	Value          string `json:"value"`
	Representation string `json:"representation"`
}

type ConfluenceSpaceOperation

type ConfluenceSpaceOperation struct {
	Operation  string `json:"operation"`
	TargetType string `json:"targetType"`
}

type ConfluenceSpaceOperationsResponse

type ConfluenceSpaceOperationsResponse struct {
	Links   ConfluenceLink             `json:"_links"`
	Meta    ConfluenceMeta             `json:"meta"`
	Results []ConfluenceSpaceOperation `json:"results"`
}

type ConfluenceSpacePermission

type ConfluenceSpacePermission struct {
	Id        string                             `json:"id"`
	Principal ConfluenceSpacePermissionPrincipal `json:"principal"`
	Operation ConfluenceSpacePermissionOperation `json:"operation"`
}

type ConfluenceSpacePermissionOperation

type ConfluenceSpacePermissionOperation struct {
	Key        string `json:"key"`
	TargetType string `json:"targetType"`
}

type ConfluenceSpacePermissionPrincipal

type ConfluenceSpacePermissionPrincipal struct {
	Id   string `json:"id"`
	Type string `json:"type"`
}

type ConfluenceSpacePermissionResponse

type ConfluenceSpacePermissionResponse struct {
	Links   ConfluenceLink              `json:"_links"`
	Results []ConfluenceSpacePermission `json:"results"`
}

type ConfluenceUser

type ConfluenceUser struct {
	AccountId   string                `json:"accountId"`
	AccountType string                `json:"accountType"`
	DisplayName string                `json:"displayName"`
	Email       string                `json:"email,omitempty"`
	Operations  []ConfluenceOperation `json:"operations,omitempty"`
}

type CreateSpacePermissionRequestBody

type CreateSpacePermissionRequestBody struct {
	Subject   SpacePermissionSubject   `json:"subject"`
	Operation SpacePermissionOperation `json:"operation"`
}

type Option

type Option = func(*url.URL) (*url.URL, error)

type RequestError

type RequestError struct {
	Status int
	URL    *url.URL
	Body   string
}

func (*RequestError) Error

func (r *RequestError) Error() string

type SetSpaceRoleAssignmentRequest added in v0.0.19

type SetSpaceRoleAssignmentRequest struct {
	Principal SpaceRoleAssignmentPrincipal `json:"principal"`
	RoleId    string                       `json:"roleId,omitempty"`
}

type SpacePermissionOperation

type SpacePermissionOperation struct {
	Key    string `json:"key"`
	Target string `json:"target"`
}

type SpacePermissionSubject

type SpacePermissionSubject struct {
	Type       string `json:"type"`
	Identifier string `json:"identifier"`
}

type SpaceRole added in v0.0.19

type SpaceRole struct {
	Id               string   `json:"id"`
	Type             string   `json:"type"`
	Name             string   `json:"name"`
	Description      string   `json:"description"`
	SpacePermissions []string `json:"spacePermissions"`
}

type SpaceRoleAssignment added in v0.0.19

type SpaceRoleAssignment struct {
	Principal SpaceRoleAssignmentPrincipal `json:"principal"`
	RoleId    string                       `json:"roleId"`
}

type SpaceRoleAssignmentPrincipal added in v0.0.19

type SpaceRoleAssignmentPrincipal struct {
	PrincipalType string `json:"principalType"`
	PrincipalId   string `json:"principalId"`
}

type SpaceRoleAssignmentsResponse added in v0.0.19

type SpaceRoleAssignmentsResponse struct {
	Results []SpaceRoleAssignment `json:"results"`
	Links   ConfluenceLink        `json:"_links"`
}

type SpaceRoleModeResponse added in v0.0.19

type SpaceRoleModeResponse struct {
	Mode string `json:"mode"`
}

type SpaceRolesResponse added in v0.0.19

type SpaceRolesResponse struct {
	Results []SpaceRole    `json:"results"`
	Links   ConfluenceLink `json:"_links"`
}

Jump to

Keyboard shortcuts

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