api

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

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

type APIError struct {
	StatusCode int
	Errors     []string
	URL        string
}

APIError represents an error response from the Redmine API.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) IsAuthError

func (e *APIError) IsAuthError() bool

IsAuthError returns true if the error is a 401.

func (*APIError) IsForbidden

func (e *APIError) IsForbidden() bool

IsForbidden returns true if the error is a 403.

func (*APIError) IsNotFound

func (e *APIError) IsNotFound() bool

IsNotFound returns true if the error is a 404.

func (*APIError) IsValidationError

func (e *APIError) IsValidationError() bool

IsValidationError returns true if the error is a 422.

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
	Trackers     *TrackerService
	Statuses     *StatusService
	Enumerations *EnumerationService
	Versions     *VersionService
	Categories   *CategoryService
	Groups       *GroupService
	Search       *SearchService
	Memberships  *MembershipService
	// contains filtered or unexported fields
}

Client is the Redmine API client.

func NewClient

func NewClient(cfg *config.Config, log *debug.Logger) (*Client, error)

NewClient creates a new Redmine API client from configuration.

func (*Client) DebugLog

func (c *Client) DebugLog() *debug.Logger

DebugLog returns the client's debug logger.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string) error

Delete performs a DELETE request.

func (*Client) DoRaw added in v1.10.0

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.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, params url.Values, out interface{}) error

Get performs a GET request and decodes the response into out.

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body interface{}, out interface{}) error

Post performs a POST request with a JSON body.

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, body interface{}) error

Put performs a PUT request with a JSON body.

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 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

func (s *GroupService) Get(ctx context.Context, id int, includes []string) (*models.Group, error)

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) 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) Get

func (s *IssueService) Get(ctx context.Context, id int, includes []string) (*models.Issue, error)

Get retrieves a single issue by ID.

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) Update

func (s *IssueService) Update(ctx context.Context, id int, update models.IssueUpdate) error

Update updates an existing issue.

type MembershipService added in v1.11.0

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

MembershipService handles membership-related API calls.

func (*MembershipService) Create added in v1.11.0

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 added in v1.11.0

func (s *MembershipService) Delete(ctx context.Context, id int) error

Delete deletes a membership.

func (*MembershipService) Get added in v1.11.0

Get retrieves a single membership by ID.

func (*MembershipService) List added in v1.11.0

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 added in v1.11.0

func (s *MembershipService) Update(ctx context.Context, id int, update models.MembershipUpdate) error

Update updates an existing membership.

type ProjectService

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

ProjectService handles project-related API calls.

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) Update

func (s *ProjectService) Update(ctx context.Context, identifier string, update models.ProjectUpdate) error

Update updates an existing project.

type RawResponse added in v1.10.0

type RawResponse struct {
	StatusCode int
	Status     string
	Headers    http.Header
	Body       []byte
}

RawResponse holds the unprocessed HTTP response from DoRaw.

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

List retrieves all issue statuses.

type TimeEntryService

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

TimeEntryService handles time entry API calls.

func (*TimeEntryService) Create

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) Get

Get retrieves a single time entry.

func (*TimeEntryService) List

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.

func (*TrackerService) List

func (s *TrackerService) List(ctx context.Context) ([]models.Tracker, error)

List retrieves all trackers.

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) (*models.User, error)

Create creates a new user.

func (*UserService) Current

func (s *UserService) Current(ctx context.Context) (*models.User, error)

Current retrieves the currently authenticated user.

func (*UserService) Delete

func (s *UserService) Delete(ctx context.Context, id int) error

Delete deletes a user.

func (*UserService) Get

func (s *UserService) Get(ctx context.Context, id int) (*models.User, error)

Get retrieves a single user by ID.

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) Get

func (s *VersionService) Get(ctx context.Context, id int) (*models.Version, error)

Get retrieves a single version by ID.

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.

Jump to

Keyboard shortcuts

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