Documentation
¶
Index ¶
- func FetchAll[T any](ctx context.Context, c *Client, path string, params url.Values, key string, ...) ([]T, int, error)
- func FetchAllFiltered[T any](ctx context.Context, c *Client, path string, params url.Values, key string, ...) ([]T, bool, error)
- type APIError
- type AttachmentService
- type CategoryService
- type Client
- func (c *Client) DebugLog() *debug.Logger
- func (c *Client) Delete(ctx context.Context, path string) error
- func (c *Client) DoRaw(ctx context.Context, method, path string, params url.Values, body io.Reader) (*RawResponse, error)
- func (c *Client) Get(ctx context.Context, path string, params url.Values, out interface{}) error
- func (c *Client) Post(ctx context.Context, path string, body interface{}, out interface{}) error
- func (c *Client) Put(ctx context.Context, path string, body interface{}) error
- type CustomFieldService
- type EnumerationService
- type FileService
- type GroupService
- func (s *GroupService) AddUser(ctx context.Context, groupID, userID int) error
- func (s *GroupService) Create(ctx context.Context, group models.GroupCreate) (*models.Group, error)
- func (s *GroupService) Delete(ctx context.Context, id int) error
- func (s *GroupService) Get(ctx context.Context, id int, includes []string) (*models.Group, error)
- func (s *GroupService) List(ctx context.Context, filter models.GroupFilter) ([]models.Group, int, error)
- func (s *GroupService) RemoveUser(ctx context.Context, groupID, userID int) error
- func (s *GroupService) Update(ctx context.Context, id int, update models.GroupUpdate) error
- type IssueService
- func (s *IssueService) AddWatcher(ctx context.Context, issueID, userID int) error
- func (s *IssueService) Create(ctx context.Context, issue models.IssueCreate) (*models.Issue, error)
- func (s *IssueService) Delete(ctx context.Context, id int) error
- func (s *IssueService) Get(ctx context.Context, id int, includes []string) (*models.Issue, error)
- func (s *IssueService) List(ctx context.Context, filter models.IssueFilter) ([]models.Issue, int, error)
- func (s *IssueService) ListWatchers(ctx context.Context, issueID int) ([]models.IDName, error)
- func (s *IssueService) RemoveWatcher(ctx context.Context, issueID, userID int) error
- func (s *IssueService) Update(ctx context.Context, id int, update models.IssueUpdate) error
- type MembershipService
- func (s *MembershipService) Create(ctx context.Context, projectID string, membership models.MembershipCreate) (*models.Membership, error)
- func (s *MembershipService) Delete(ctx context.Context, id int) error
- func (s *MembershipService) Get(ctx context.Context, id int) (*models.Membership, error)
- func (s *MembershipService) List(ctx context.Context, projectID string, limit, offset int) ([]models.Membership, int, error)
- func (s *MembershipService) Update(ctx context.Context, id int, update models.MembershipUpdate) error
- type MyAccountService
- type ProjectService
- func (s *ProjectService) Archive(ctx context.Context, identifier string) error
- func (s *ProjectService) Create(ctx context.Context, project models.ProjectCreate) (*models.Project, error)
- func (s *ProjectService) Delete(ctx context.Context, identifier string) error
- func (s *ProjectService) Get(ctx context.Context, identifier string, includes []string) (*models.Project, error)
- func (s *ProjectService) List(ctx context.Context, includes []string, limit, offset int) ([]models.Project, int, error)
- func (s *ProjectService) Members(ctx context.Context, identifier string, limit, offset int) ([]models.Membership, int, error)
- func (s *ProjectService) Unarchive(ctx context.Context, identifier string) error
- func (s *ProjectService) Update(ctx context.Context, identifier string, update models.ProjectUpdate) error
- type QueryService
- type RawResponse
- type RelationService
- func (s *RelationService) Create(ctx context.Context, issueID int, payload models.IssueRelationCreate) (*models.IssueRelation, error)
- func (s *RelationService) Delete(ctx context.Context, relationID int) error
- func (s *RelationService) Get(ctx context.Context, relationID int) (*models.IssueRelation, error)
- func (s *RelationService) ListByIssue(ctx context.Context, issueID int) ([]models.IssueRelation, error)
- type RoleService
- type SearchParams
- type SearchService
- type StatusService
- type TimeEntryService
- func (s *TimeEntryService) Create(ctx context.Context, entry models.TimeEntryCreate) (*models.TimeEntry, error)
- func (s *TimeEntryService) Delete(ctx context.Context, id int) error
- func (s *TimeEntryService) Get(ctx context.Context, id int) (*models.TimeEntry, error)
- func (s *TimeEntryService) List(ctx context.Context, filter models.TimeEntryFilter) ([]models.TimeEntry, int, error)
- func (s *TimeEntryService) Update(ctx context.Context, id int, update models.TimeEntryUpdate) error
- type TrackerService
- type UserService
- func (s *UserService) Create(ctx context.Context, user models.UserCreate, sendInformation bool) (*models.User, error)
- func (s *UserService) Current(ctx context.Context, includes []string) (*models.User, error)
- func (s *UserService) Delete(ctx context.Context, id int) error
- func (s *UserService) Get(ctx context.Context, id int, includes []string) (*models.User, error)
- func (s *UserService) List(ctx context.Context, filter models.UserFilter) ([]models.User, int, error)
- func (s *UserService) Update(ctx context.Context, id int, update models.UserUpdate) error
- type VersionService
- func (s *VersionService) Create(ctx context.Context, projectID string, version models.VersionCreate) (*models.Version, error)
- func (s *VersionService) Delete(ctx context.Context, id int) error
- func (s *VersionService) Get(ctx context.Context, id int) (*models.Version, error)
- func (s *VersionService) List(ctx context.Context, projectID string, limit, offset int) ([]models.Version, int, error)
- func (s *VersionService) ListFiltered(ctx context.Context, projectID string, need int, ...) ([]models.Version, bool, error)
- func (s *VersionService) Update(ctx context.Context, id int, update models.VersionUpdate) error
- type WikiService
- func (s *WikiService) Create(ctx context.Context, projectID, page string, wiki models.WikiPageCreate) (*models.WikiPage, error)
- func (s *WikiService) Delete(ctx context.Context, projectID, page string) error
- func (s *WikiService) Get(ctx context.Context, projectID, page string, includes []string) (*models.WikiPage, error)
- func (s *WikiService) GetVersion(ctx context.Context, projectID, page string, version int) (*models.WikiPage, error)
- func (s *WikiService) List(ctx context.Context, projectID string, limit, offset int) ([]models.WikiPageIndex, int, error)
- func (s *WikiService) Update(ctx context.Context, projectID, page string, update models.WikiPageUpdate) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchAll ¶
func FetchAll[T any](ctx context.Context, c *Client, path string, params url.Values, key string, maxResults int) ([]T, int, error)
FetchAll retrieves all pages of a resource. The key parameter is the JSON wrapper key (e.g., "issues", "projects"). If maxResults is 0, all results are fetched.
func FetchAllFiltered ¶
func FetchAllFiltered[T any](ctx context.Context, c *Client, path string, params url.Values, key string, maxResults int, filter func(T) bool) ([]T, bool, error)
FetchAllFiltered retrieves pages of a resource, keeping only items that pass the filter. If maxResults is 0, all matching items are fetched. Returns the matched items and whether more matches may exist beyond what was collected.
Types ¶
type APIError ¶
APIError represents an error response from the Redmine API.
func (*APIError) IsAuthError ¶
IsAuthError returns true if the error is a 401.
func (*APIError) IsConflict ¶ added in v2.6.0
IsConflict returns true if the error is a 409. Redmine surfaces 409 on optimistic-locking failures (e.g. updating a wiki page whose version has been bumped on the server since the client last fetched it).
func (*APIError) IsForbidden ¶
IsForbidden returns true if the error is a 403.
func (*APIError) IsNotFound ¶
IsNotFound returns true if the error is a 404.
func (*APIError) IsValidationError ¶
IsValidationError returns true if the error is a 422.
type AttachmentService ¶
type AttachmentService struct {
// contains filtered or unexported fields
}
AttachmentService handles file upload API calls.
func (*AttachmentService) Upload ¶
func (s *AttachmentService) Upload(ctx context.Context, filename string, body io.Reader, size int64) (string, error)
Upload streams body (of known size) to Redmine's /uploads.json endpoint and returns the upload token. filename is sent as a query parameter per the Redmine REST docs so the server records the original name.
type CategoryService ¶
type CategoryService struct {
// contains filtered or unexported fields
}
CategoryService handles issue category-related API calls.
func (*CategoryService) List ¶
func (s *CategoryService) List(ctx context.Context, projectID string) ([]models.IssueCategory, int, error)
List retrieves issue categories for a project.
type Client ¶
type Client struct {
Issues *IssueService
Projects *ProjectService
TimeEntries *TimeEntryService
Users *UserService
MyAccount *MyAccountService
Trackers *TrackerService
Statuses *StatusService
Roles *RoleService
Enumerations *EnumerationService
Versions *VersionService
Categories *CategoryService
Groups *GroupService
Search *SearchService
Memberships *MembershipService
Attachments *AttachmentService
Wikis *WikiService
Queries *QueryService
CustomFields *CustomFieldService
Files *FileService
Relations *RelationService
// contains filtered or unexported fields
}
Client is the Redmine API client.
func NewTestClient ¶
NewTestClient constructs a Client wired to a given http.Client and base URL without requiring a full config. It is exported only for use in tests of other packages (e.g. cmdutil) that need a working *Client.
func (*Client) DoRaw ¶
func (c *Client) DoRaw(ctx context.Context, method, path string, params url.Values, body io.Reader) (*RawResponse, error)
DoRaw performs an HTTP request and returns the raw response without parsing.
type CustomFieldService ¶ added in v2.6.0
type CustomFieldService struct {
// contains filtered or unexported fields
}
CustomFieldService handles custom field definition API calls. Redmine only exposes the list endpoint (admin only), so Get resolves from the list.
func (*CustomFieldService) Get ¶ added in v2.6.0
func (s *CustomFieldService) Get(ctx context.Context, id int) (*models.CustomField, error)
Get retrieves a single custom field definition by ID by resolving it from the list endpoint, which is the only custom-field endpoint Redmine exposes.
func (*CustomFieldService) List ¶ added in v2.6.0
func (s *CustomFieldService) List(ctx context.Context) ([]models.CustomField, error)
List retrieves all custom field definitions.
type EnumerationService ¶
type EnumerationService struct {
// contains filtered or unexported fields
}
EnumerationService handles enumeration-related API calls.
func (*EnumerationService) IssuePriorities ¶
func (s *EnumerationService) IssuePriorities(ctx context.Context) ([]models.Enumeration, error)
IssuePriorities retrieves all issue priorities.
func (*EnumerationService) TimeEntryActivities ¶
func (s *EnumerationService) TimeEntryActivities(ctx context.Context) ([]models.Enumeration, error)
TimeEntryActivities retrieves all time entry activities.
type FileService ¶ added in v2.6.0
type FileService struct {
// contains filtered or unexported fields
}
FileService handles project file API calls.
func (*FileService) Create ¶ added in v2.6.0
func (s *FileService) Create(ctx context.Context, projectID string, file models.ProjectFileCreate) error
Create uploads a file to a project using a previously obtained upload token. Redmine's POST /projects/:id/files.json returns 204 No Content on success and does not echo the created resource.
func (*FileService) List ¶ added in v2.6.0
func (s *FileService) List(ctx context.Context, projectID string, limit, offset int) ([]models.ProjectFile, int, error)
List retrieves the file list for a project. The Redmine endpoint does not honour pagination parameters, so all files are returned in a single response. limit/offset are still accepted for client-side trimming via FetchAll's fallback path.
type GroupService ¶
type GroupService struct {
// contains filtered or unexported fields
}
GroupService handles group-related API calls.
func (*GroupService) AddUser ¶
func (s *GroupService) AddUser(ctx context.Context, groupID, userID int) error
AddUser adds a user to a group.
func (*GroupService) Create ¶
func (s *GroupService) Create(ctx context.Context, group models.GroupCreate) (*models.Group, error)
Create creates a new group.
func (*GroupService) Delete ¶
func (s *GroupService) Delete(ctx context.Context, id int) error
Delete deletes a group.
func (*GroupService) Get ¶
Get retrieves a single group by ID. includes can contain "users" and/or "memberships".
func (*GroupService) List ¶
func (s *GroupService) List(ctx context.Context, filter models.GroupFilter) ([]models.Group, int, error)
List retrieves groups matching the given filter.
func (*GroupService) RemoveUser ¶
func (s *GroupService) RemoveUser(ctx context.Context, groupID, userID int) error
RemoveUser removes a user from a group.
func (*GroupService) Update ¶
func (s *GroupService) Update(ctx context.Context, id int, update models.GroupUpdate) error
Update updates an existing group.
type IssueService ¶
type IssueService struct {
// contains filtered or unexported fields
}
IssueService handles issue-related API calls.
func (*IssueService) AddWatcher ¶ added in v2.6.0
func (s *IssueService) AddWatcher(ctx context.Context, issueID, userID int) error
AddWatcher adds a user as a watcher on the given issue.
func (*IssueService) Create ¶
func (s *IssueService) Create(ctx context.Context, issue models.IssueCreate) (*models.Issue, error)
Create creates a new issue.
func (*IssueService) Delete ¶
func (s *IssueService) Delete(ctx context.Context, id int) error
Delete deletes an issue.
func (*IssueService) List ¶
func (s *IssueService) List(ctx context.Context, filter models.IssueFilter) ([]models.Issue, int, error)
List retrieves issues matching the given filter.
func (*IssueService) ListWatchers ¶ added in v2.6.0
ListWatchers returns the watchers on the given issue. Redmine has no dedicated list endpoint; the data is fetched via include=watchers on the issue itself.
func (*IssueService) RemoveWatcher ¶ added in v2.6.0
func (s *IssueService) RemoveWatcher(ctx context.Context, issueID, userID int) error
RemoveWatcher removes a user as a watcher from the given issue.
func (*IssueService) Update ¶
func (s *IssueService) Update(ctx context.Context, id int, update models.IssueUpdate) error
Update updates an existing issue.
type MembershipService ¶
type MembershipService struct {
// contains filtered or unexported fields
}
MembershipService handles membership-related API calls.
func (*MembershipService) Create ¶
func (s *MembershipService) Create(ctx context.Context, projectID string, membership models.MembershipCreate) (*models.Membership, error)
Create creates a new membership in a project.
func (*MembershipService) Delete ¶
func (s *MembershipService) Delete(ctx context.Context, id int) error
Delete deletes a membership.
func (*MembershipService) Get ¶
func (s *MembershipService) Get(ctx context.Context, id int) (*models.Membership, error)
Get retrieves a single membership by ID.
func (*MembershipService) List ¶
func (s *MembershipService) List(ctx context.Context, projectID string, limit, offset int) ([]models.Membership, int, error)
List retrieves memberships for a project.
func (*MembershipService) Update ¶
func (s *MembershipService) Update(ctx context.Context, id int, update models.MembershipUpdate) error
Update updates an existing membership.
type MyAccountService ¶ added in v2.6.0
type MyAccountService struct {
// contains filtered or unexported fields
}
MyAccountService handles /my/account.json calls. Unlike /users/* it is the only user-write endpoint that does not require admin privileges, and its GET response includes api_key and custom_fields.
func (*MyAccountService) Get ¶ added in v2.6.0
Get retrieves the authenticated user's account, including api_key and custom_fields.
func (*MyAccountService) Update ¶ added in v2.6.0
func (s *MyAccountService) Update(ctx context.Context, update models.MyAccountUpdate) error
Update updates the authenticated user's own account.
type ProjectService ¶
type ProjectService struct {
// contains filtered or unexported fields
}
ProjectService handles project-related API calls.
func (*ProjectService) Archive ¶ added in v2.6.0
func (s *ProjectService) Archive(ctx context.Context, identifier string) error
Archive archives a project. Requires Redmine 5.0+.
func (*ProjectService) Create ¶
func (s *ProjectService) Create(ctx context.Context, project models.ProjectCreate) (*models.Project, error)
Create creates a new project.
func (*ProjectService) Delete ¶
func (s *ProjectService) Delete(ctx context.Context, identifier string) error
Delete deletes a project.
func (*ProjectService) Get ¶
func (s *ProjectService) Get(ctx context.Context, identifier string, includes []string) (*models.Project, error)
Get retrieves a single project by identifier.
func (*ProjectService) List ¶
func (s *ProjectService) List(ctx context.Context, includes []string, limit, offset int) ([]models.Project, int, error)
List retrieves all projects.
func (*ProjectService) Members ¶
func (s *ProjectService) Members(ctx context.Context, identifier string, limit, offset int) ([]models.Membership, int, error)
Members retrieves project memberships.
func (*ProjectService) Unarchive ¶ added in v2.6.0
func (s *ProjectService) Unarchive(ctx context.Context, identifier string) error
Unarchive unarchives a previously-archived project. Requires Redmine 5.0+.
func (*ProjectService) Update ¶
func (s *ProjectService) Update(ctx context.Context, identifier string, update models.ProjectUpdate) error
Update updates an existing project.
type QueryService ¶ added in v2.6.0
type QueryService struct {
// contains filtered or unexported fields
}
QueryService handles saved-query API calls.
func (*QueryService) List ¶ added in v2.6.0
func (s *QueryService) List(ctx context.Context, limit, offset int) ([]models.SavedQuery, int, error)
List retrieves saved queries visible to the authenticated user. Redmine's /queries.json endpoint does not accept a project filter; callers receive every visible query (global plus project-specific) and can filter by the ProjectID field client-side if needed.
type RawResponse ¶
RawResponse holds the unprocessed HTTP response from DoRaw.
type RelationService ¶ added in v2.6.0
type RelationService struct {
// contains filtered or unexported fields
}
RelationService handles issue relation API calls.
func (*RelationService) Create ¶ added in v2.6.0
func (s *RelationService) Create(ctx context.Context, issueID int, payload models.IssueRelationCreate) (*models.IssueRelation, error)
Create creates a new relation on the given issue.
func (*RelationService) Delete ¶ added in v2.6.0
func (s *RelationService) Delete(ctx context.Context, relationID int) error
Delete removes a relation by its ID.
func (*RelationService) Get ¶ added in v2.6.0
func (s *RelationService) Get(ctx context.Context, relationID int) (*models.IssueRelation, error)
Get returns a single relation by its ID.
func (*RelationService) ListByIssue ¶ added in v2.6.0
func (s *RelationService) ListByIssue(ctx context.Context, issueID int) ([]models.IssueRelation, error)
ListByIssue returns relations attached to the given issue.
type RoleService ¶ added in v2.6.0
type RoleService struct {
// contains filtered or unexported fields
}
RoleService handles role-related API calls.
type SearchParams ¶
type SearchParams struct {
Query string
ProjectID string
Scope string // "all", "my_projects", "subprojects"
AllWords bool
TitlesOnly bool
OpenIssues bool
Attachments string // "0", "1", "only"
// Resource type filters
Issues bool
News bool
Documents bool
Changesets bool
WikiPages bool
Messages bool
Projects bool
Limit int
Offset int
}
SearchParams holds parameters for the search API call.
type SearchService ¶
type SearchService struct {
// contains filtered or unexported fields
}
SearchService handles the Redmine search API.
func (*SearchService) Search ¶
func (s *SearchService) Search(ctx context.Context, params SearchParams) ([]models.SearchResult, int, error)
Search performs a search query against the Redmine search API.
type StatusService ¶
type StatusService struct {
// contains filtered or unexported fields
}
StatusService handles issue status API calls.
func (*StatusService) List ¶
func (s *StatusService) List(ctx context.Context) ([]models.IssueStatus, error)
List retrieves all issue statuses.
type TimeEntryService ¶
type TimeEntryService struct {
// contains filtered or unexported fields
}
TimeEntryService handles time entry API calls.
func (*TimeEntryService) Create ¶
func (s *TimeEntryService) Create(ctx context.Context, entry models.TimeEntryCreate) (*models.TimeEntry, error)
Create creates a new time entry.
func (*TimeEntryService) Delete ¶
func (s *TimeEntryService) Delete(ctx context.Context, id int) error
Delete deletes a time entry.
func (*TimeEntryService) List ¶
func (s *TimeEntryService) List(ctx context.Context, filter models.TimeEntryFilter) ([]models.TimeEntry, int, error)
List retrieves time entries matching the given filter.
func (*TimeEntryService) Update ¶
func (s *TimeEntryService) Update(ctx context.Context, id int, update models.TimeEntryUpdate) error
Update updates an existing time entry.
type TrackerService ¶
type TrackerService struct {
// contains filtered or unexported fields
}
TrackerService handles tracker-related API calls.
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService handles user-related API calls.
func (*UserService) Create ¶
func (s *UserService) Create(ctx context.Context, user models.UserCreate, sendInformation bool) (*models.User, error)
Create creates a new user. When sendInformation is true, the server emails the new account holder; the flag is encoded as a sibling of the "user" object, not nested inside it.
func (*UserService) Current ¶
Current retrieves the currently authenticated user via /users/current.json. Optional includes accept the same values as Get.
func (*UserService) Delete ¶
func (s *UserService) Delete(ctx context.Context, id int) error
Delete deletes a user.
func (*UserService) Get ¶
Get retrieves a single user by ID. Optional includes can request memberships and groups (Redmine 2.1+).
func (*UserService) List ¶
func (s *UserService) List(ctx context.Context, filter models.UserFilter) ([]models.User, int, error)
List retrieves users matching the given filter.
func (*UserService) Update ¶
func (s *UserService) Update(ctx context.Context, id int, update models.UserUpdate) error
Update updates an existing user.
type VersionService ¶
type VersionService struct {
// contains filtered or unexported fields
}
VersionService handles version-related API calls.
func (*VersionService) Create ¶ added in v2.4.0
func (s *VersionService) Create(ctx context.Context, projectID string, version models.VersionCreate) (*models.Version, error)
Create creates a version for a project.
func (*VersionService) Delete ¶ added in v2.4.0
func (s *VersionService) Delete(ctx context.Context, id int) error
Delete deletes a version.
func (*VersionService) List ¶
func (s *VersionService) List(ctx context.Context, projectID string, limit, offset int) ([]models.Version, int, error)
List retrieves versions for a project. If limit is 0, all versions are fetched.
func (*VersionService) ListFiltered ¶
func (s *VersionService) ListFiltered(ctx context.Context, projectID string, need int, filter func(models.Version) bool) ([]models.Version, bool, error)
ListFiltered pages through versions for a project, keeping only those that match the filter function, and returns once need results have been collected (or there are no more pages). If need is 0, all matching versions are returned. The hasMore return indicates whether additional matches may exist beyond what was collected.
func (*VersionService) Update ¶ added in v2.4.0
func (s *VersionService) Update(ctx context.Context, id int, update models.VersionUpdate) error
Update updates an existing version.
type WikiService ¶
type WikiService struct {
// contains filtered or unexported fields
}
WikiService handles wiki-related API calls.
func (*WikiService) Create ¶
func (s *WikiService) Create(ctx context.Context, projectID, page string, wiki models.WikiPageCreate) (*models.WikiPage, error)
Create creates a new wiki page (or overwrites an existing one).
func (*WikiService) Delete ¶
func (s *WikiService) Delete(ctx context.Context, projectID, page string) error
Delete deletes a wiki page.
func (*WikiService) Get ¶
func (s *WikiService) Get(ctx context.Context, projectID, page string, includes []string) (*models.WikiPage, error)
Get retrieves a single wiki page by title.
func (*WikiService) GetVersion ¶
func (s *WikiService) GetVersion(ctx context.Context, projectID, page string, version int) (*models.WikiPage, error)
GetVersion retrieves a specific version of a wiki page.
func (*WikiService) List ¶
func (s *WikiService) List(ctx context.Context, projectID string, limit, offset int) ([]models.WikiPageIndex, int, error)
List retrieves the wiki page index for a project.
func (*WikiService) Update ¶
func (s *WikiService) Update(ctx context.Context, projectID, page string, update models.WikiPageUpdate) error
Update updates an existing wiki page.