Documentation
¶
Index ¶
- Constants
- func Retry(log *zerolog.Logger, fn func() (redmine.StatusCode, error)) error
- func RetryResult[V any](log *zerolog.Logger, fn func() (V, redmine.StatusCode, error)) (V, error)
- type API
- type Config
- type IssueRelation
- type IssueRelationRequest
- type Option
- func WithAPIKey(apikey string) Option
- func WithDoneStatusID(doneStatusID int) Option
- func WithHost(host string) Option
- func WithLog(log *zerolog.Logger) Option
- func WithProjectID(projectID int) Option
- func WithProjectIdentifier(projectIdentifier string) Option
- func WithTrackerID(trackerID int) Option
- func WithUserID(userID int) Option
- func WithWaitingForCustomerStatusID(waitingForCustomerStatusID int) Option
- func WithWaitingForOperatorStatusID(waitingForOperatorStatusID int) Option
- type Redmine
- func (r *Redmine) Configure(options ...Option) *Redmine
- func (r *Redmine) DeleteAttachment(attachmentID int64) error
- func (r *Redmine) DeleteIssue(issueID int64) error
- func (r *Redmine) Enabled() bool
- func (r *Redmine) GetAPI() *redmine.Context
- func (r *Redmine) GetAPIKey() string
- func (r *Redmine) GetDoneStatusID() int64
- func (r *Redmine) GetHost() string
- func (r *Redmine) GetIssue(issueID int64, includes ...redmine.IssueInclude) (redmine.IssueObject, error)
- func (r *Redmine) GetNotes(issueID int64) ([]*redmine.IssueJournalObject, error)
- func (r *Redmine) GetProjectID() int64
- func (r *Redmine) GetProjectIdentifier() string
- func (r *Redmine) GetStatus(issueID int64) (redmine.IssueStatusObject, error)
- func (r *Redmine) GetTrackerID() int64
- func (r *Redmine) GetUserID() int64
- func (r *Redmine) GetWaitingForCustomerStatusID() int64
- func (r *Redmine) GetWaitingForOperatorStatusID() int64
- func (r *Redmine) IsClosed(issueID int64) (bool, error)
- func (r *Redmine) NewIssue(subject, senderMedium, senderAddress, text string, files ...*UploadRequest) (int64, error)
- func (r *Redmine) NewIssueRelation(issueID, relatedIssueID int64, relationType string) error
- func (r *Redmine) Shutdown()
- func (r *Redmine) StatusToID(status Status) int64
- func (r *Redmine) UpdateIssue(issueID, statusID int64, text string, files ...*UploadRequest) error
- func (r *Redmine) UpdateProject() error
- func (r *Redmine) UpdateUser() error
- type Status
- type UploadRequest
Constants ¶
const ( // MaxRetries is the maximum number of retries MaxRetries = 5 // RetryDelay is the delay step between retries RetryDelay = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func Retry ¶
Retry retries the given function until it succeeds or the maximum number of retries is reached it should be used everywhere you call the underlying API object (inside the library: r.cfg.api, outside: r.GetAPI())
func RetryResult ¶
RetryResult retries the given function until it succeeds or the maximum number of retries is reached it should be used everywhere you call the underlying API object (inside the library: r.cfg.api, outside: r.GetAPI())
Types ¶
type API ¶
type API interface { ProjectSingleGet(identifier string, req redmine.ProjectSingleGetRequest) (redmine.ProjectObject, redmine.StatusCode, error) UserCurrentGet(req redmine.UserCurrentGetRequest) (redmine.UserObject, redmine.StatusCode, error) IssueCreate(req redmine.IssueCreate) (redmine.IssueObject, redmine.StatusCode, error) IssueUpdate(id int64, req redmine.IssueUpdate) (redmine.StatusCode, error) IssueSingleGet(id int64, req redmine.IssueSingleGetRequest) (redmine.IssueObject, redmine.StatusCode, error) IssueDelete(id int64) (redmine.StatusCode, error) AttachmentUpload(filePath string) (redmine.AttachmentUploadObject, redmine.StatusCode, error) AttachmentUploadStream(f io.Reader, fileName string) (redmine.AttachmentUploadObject, redmine.StatusCode, error) Del(in, out any, uri url.URL, statusExpected redmine.StatusCode) (redmine.StatusCode, error) Post(in, out any, uri url.URL, statusExpected redmine.StatusCode) (redmine.StatusCode, error) }
API is an interface for Redmine API
type Config ¶
type Config struct { Log *zerolog.Logger // Logger, defaults to discard Host string // Redmine host, e.g. "https://redmine.example.com" APIKey string // Redmine REST API Key ProjectIdentifier string // Redmine project identifier, e.g. "my-project" ProjectID int64 // Redmine project ID, e.g. 123. This is set automatically if you use ProjectIdentifier UserID int64 // Current redmine user ID, e.g. 123. This is set automatically TrackerID int64 // Task Tracker ID, e.g. 1 WaitingForOperatorStatusID int64 // Status ID for "Waiting for operator", e.g. 1 WaitingForCustomerStatusID int64 // Status ID for "Waiting for customer", e.g. 2 DoneStatusID int64 // Status ID for "Done", e.g. 3 // contains filtered or unexported fields }
Config is a configuration for Redmine
type IssueRelation ¶
type IssueRelation struct { IssueToID int64 `json:"issue_to_id"` RelationType string `json:"relation_type"` }
IssueRelation is a minimal struct for issue relations
type IssueRelationRequest ¶
type IssueRelationRequest struct {
Relation IssueRelation `json:"relation"`
}
IssueRelationRequest is a request to create a new issue relation
type Option ¶
type Option func(*Config)
Option is a functional option for Config
func WithDoneStatusID ¶
WithDoneStatusID sets the done status ID
func WithProjectID ¶
WithProjectID sets the project ID. This is set automatically if you use ProjectIdentifier
func WithProjectIdentifier ¶
WithProjectIdentifier sets the project identifier
func WithWaitingForCustomerStatusID ¶
WithWaitingForCustomerStatusID sets the waiting for customer status ID
func WithWaitingForOperatorStatusID ¶
WithWaitingForOperatorStatusID sets the waiting for operator status ID
type Redmine ¶
type Redmine struct {
// contains filtered or unexported fields
}
Redmine is a Redmine client
func (*Redmine) Configure ¶
Configure applies the new configuration options in runtime It is advisable to call UpdateUser() (if API key and/or host was changed), and UpdatePorject() (if project identifier was changed) after this method
func (*Redmine) DeleteAttachment ¶
DeleteAttachment deletes an attachment by its ID
func (*Redmine) DeleteIssue ¶
DeleteIssue deletes an issue by its ID
func (*Redmine) GetAPI ¶
GetAPI returns the underlying API object from the github.com/nixys/nxs-go-redmine package (actual version may vary) it's useful for calling methods that are not exposed by this package WARNING: it CAN return nil (API interface is defined for tests only, but this method does type casting, so if the type is wrong, it will return nil)
func (*Redmine) GetDoneStatusID ¶
GetDoneStatusID returns the Redmine done status ID
func (*Redmine) GetIssue ¶
func (r *Redmine) GetIssue(issueID int64, includes ...redmine.IssueInclude) (redmine.IssueObject, error)
GetIssue returns an issue by its ID
func (*Redmine) GetNotes ¶
func (r *Redmine) GetNotes(issueID int64) ([]*redmine.IssueJournalObject, error)
GetNotes returns the notes of an issue
func (*Redmine) GetProjectID ¶
GetProjectID returns the Redmine project ID
func (*Redmine) GetProjectIdentifier ¶
GetProjectIdentifier returns the Redmine project identifier
func (*Redmine) GetStatus ¶
func (r *Redmine) GetStatus(issueID int64) (redmine.IssueStatusObject, error)
GetStatus returns the status of an issue
func (*Redmine) GetTrackerID ¶
GetTrackerID returns the Redmine tracker ID
func (*Redmine) GetWaitingForCustomerStatusID ¶
GetWaitingForCustomerStatusID returns the Redmine waiting for customer status ID
func (*Redmine) GetWaitingForOperatorStatusID ¶
GetNewStatusID returns the Redmine new status ID
func (*Redmine) NewIssue ¶
func (r *Redmine) NewIssue(subject, senderMedium, senderAddress, text string, files ...*UploadRequest) (int64, error)
NewIssue creates a new issue in Redmine
func (*Redmine) NewIssueRelation ¶
func (*Redmine) StatusToID ¶
StatusToID converts a Status-typed number to actual status ID
func (*Redmine) UpdateIssue ¶
func (r *Redmine) UpdateIssue(issueID, statusID int64, text string, files ...*UploadRequest) error
UpdateIssue updates the status using one of the constants and notes of an issue
func (*Redmine) UpdateProject ¶
UpdateProject updates the project ID, it should be called after changing the project identifier
func (*Redmine) UpdateUser ¶
UpdateUser updates the current user ID, it should be called after changing the API key and/or host
type Status ¶
type Status int
Status is a type for issue statuses it should be used instead of sending raw status IDs to allow dynamic (re-)configuration
type UploadRequest ¶
UploadRequest is a request to upload a file you can use either only Path to specify the file from the filesystem OR Stream to specify the file from a stream. In this case, Path is used as a filename