Documentation
¶
Overview ¶
Package redmine implements the Redmine API *
Index ¶
- Variables
- func ParseParameters(params ...Parameter) string
- type AuthKey
- type Authenticator
- type Author
- type Category
- type CustomField
- type Group
- type HeaderKey
- type Issue
- type IssueStatus
- type IssueStatuses
- type Issues
- type MailNotification
- type Membership
- type Parameter
- func GroupIDFilter(v int) Parameter
- func IncludeParameter(v []string) Parameter
- func IssueIDFilter(v int) Parameter
- func LimitParameter(v int) Parameter
- func NameParameter(v string) Parameter
- func OffsetParameter(v int) Parameter
- func ProjectIDFilter(v int) Parameter
- func StatusAllFilter() Parameter
- func StatusFilter(v int) Parameter
- func StatusIDFilter(v int) Parameter
- type Priorities
- type Priority
- type Project
- type Projects
- type Public
- type Redmine
- func (r *Redmine) CreateIssue(i *Issue) error
- func (r *Redmine) CreateUser(u *User, notify bool) error
- func (r *Redmine) DeleteUser(id int) error
- func (r *Redmine) Impersonate(name string)
- func (r *Redmine) Issue(id int) (*Issue, error)
- func (r *Redmine) IssueStatusWithName(name string) (*IssueStatus, error)
- func (r *Redmine) IssueStatuses(params ...Parameter) (IssueStatuses, error)
- func (r *Redmine) Issues(params ...Parameter) (*Issues, error)
- func (r *Redmine) Priorities(params ...Parameter) (Priorities, error)
- func (r *Redmine) PriorityWithName(name string) (*Priority, error)
- func (r *Redmine) ProjectWithIdentifier(identifier string) (*Project, error)
- func (r *Redmine) Projects(params ...Parameter) (*Projects, error)
- func (r *Redmine) TrackerWithName(name string) (*Tracker, error)
- func (r *Redmine) Trackers(params ...Parameter) (Trackers, error)
- func (r *Redmine) UpdateUser(u *User, notify bool) error
- func (r *Redmine) User(id int, params ...Parameter) (User, error)
- func (r *Redmine) UserWithLogin(login string) (*User, error)
- func (r *Redmine) Users(params ...Parameter) (*Users, error)
- type RegularLogin
- type Role
- type Tracker
- type Trackers
- type User
- type UserStatus
- type Users
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrServerEmpty = errors.New("server is empty") ErrUserEmpty = errors.New("user is empty") ErrPasswordEmpty = errors.New("password is empty") ErrLoginEmpty = errors.New("login is empty") ErrFirstnameEmpty = errors.New("firstname is empty") ErrLastnameEmpty = errors.New("lastname is empty") ErrMailEmpty = errors.New("mail is empty") ErrIDEmpty = errors.New("id is empty") ErrForbidden = errors.New("403 Forbidden") ErrUnprocessableEntity = errors.New("422 Unprocessable Entity") )
var ErrProjectNotFound = errors.New("project not found")
Functions ¶
func ParseParameters ¶
Types ¶
type AuthKey ¶
type AuthKey struct {
// contains filtered or unexported fields
}
AuthKey is authenticates to Redmine using the API key passed in as a username with a random password via HTTP Basic Auth
func (*AuthKey) Impersonate ¶
type Authenticator ¶
type Authenticator interface {
// Request create and do a new request to url with method method.
//
// The body parameter is a pointer to any struct.
// If body is not nil, then marshalled to JSON and use it in the new request's body.
//
// Returns the status code and the body bytes.
Request(method string, url string, body any) (int, []byte, error)
Impersonate(name string)
}
type CustomField ¶
type HeaderKey ¶
type HeaderKey struct {
// contains filtered or unexported fields
}
HeaderKey is authenticates to Redmine using the API key passed in "X-Redmine-API-Key" HTTP header.
func (*HeaderKey) Impersonate ¶
type Issue ¶
type Issue struct {
ID int `json:"id,omitempty" yaml:"id,omitempty"`
Project *Project `json:"project,omitempty" yaml:"project,omitempty"`
Tracker *Tracker `json:"tracker,omitempty" yaml:"tracker,omitempty"`
Status *IssueStatus `json:"status,omitempty" yaml:"status,omitempty"`
Priority *Priority `json:"priority,omitempty" yaml:"priority,omitempty"`
Author *Author `json:"author,omitempty" yaml:"author,omitempty"`
AssignedTo *User `json:"assigned_to,omitempty" yaml:"assigned_to,omitempty"`
Category *Category `json:"category,omitempty" yaml:"category,omitempty"`
Subject string `json:"subject,omitempty" yaml:"subject,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
StartDate string `json:"start_date,omitempty" yaml:"start_date,omitempty"`
DueDate string `json:"due_date,omitempty" yaml:"due_date,omitempty"`
DoneRation int `json:"done_ratio,omitempty" yaml:"done_ratio,omitempty"`
IsPrivate bool `json:"is_private,omitempty" yaml:"is_private,omitempty"`
SpentHours float64 `json:"spent_hours,omitempty" yaml:"spent_hours,omitempty"`
TotalSpentHours float64 `json:"total_spent_hours,omitempty" yaml:"total_spent_hours,omitempty"`
CreatedOn *time.Time `json:"created_on,omitempty" yaml:"created_on,omitempty"`
UpdatedOn *time.Time `json:"updated_on,omitempty" yaml:"updated_on,omitempty"`
ClosedOn *time.Time `json:"closed_on,omitempty" yaml:",omitempty"`
CustomFields []CustomField `json:"custom_fields,omitempty" yaml:"custom_fields,omitempty"`
EstimatedHours float64 `json:"estimated_hours,omitempty" yaml:"estimated_hours,omitempty"`
TotalEstimatedHours float64 `json:"total_estimated_hours,omitempty" yaml:"total_estimated_hours,omitempty"`
}
type IssueStatus ¶
type IssueStatuses ¶
type IssueStatuses []IssueStatus
func (*IssueStatuses) Names ¶
func (is *IssueStatuses) Names() []string
type Issues ¶
type Issues struct {
Issues []Issue `json:"issues,omitempty" yaml:"issues,omitempty"`
TotalCount int `json:"total_count,omitempty" yaml:"total_count,omitempty"`
Offset int `json:"offset,omitempty" yaml:"offset,omitempty"`
Limit int `json:"limit,omitempty" yaml:"limit,omitempty"`
}
Example ¶
package main
import (
"fmt"
"gorbe.io/go/redmine"
)
func main() {
issues, err := redmine.NewPublic("https://www.redmine.org").Issues()
if err != nil {
// handle error
}
fmt.Printf("%#v", issues)
}
Example (WithParameter) ¶
package main
import (
"fmt"
"gorbe.io/go/redmine"
)
func main() {
issues, err := redmine.NewPublic("https://www.redmine.org").Issues(redmine.OffsetParameter(100), redmine.LimitParameter(100))
if err != nil {
// handle error
}
fmt.Printf("%#v", issues)
}
type MailNotification ¶
type MailNotification string
const ( MailNotificationAll MailNotification = "all" MailNotificationNone MailNotification = "none" )
func (MailNotification) String ¶
func (m MailNotification) String() string
type Membership ¶
type Parameter ¶
func GroupIDFilter ¶
func IncludeParameter ¶
func IssueIDFilter ¶
func LimitParameter ¶
func NameParameter ¶
func OffsetParameter ¶
func ProjectIDFilter ¶
func StatusAllFilter ¶
func StatusAllFilter() Parameter
func StatusFilter ¶
func StatusIDFilter ¶
type Priorities ¶
type Priorities []Priority
func (*Priorities) Names ¶
func (p *Priorities) Names() []string
type Project ¶
type Project struct {
ID int `json:"id,omitempty" yaml:"id,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Identifier string `json:"identifier,omitempty" yaml:"identifier,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
CreatedOn time.Time `json:"created_on,omitempty" yaml:"created_on,omitempty"`
UpdatedOn time.Time `json:"updated_on,omitempty" yaml:"updated_on,omitempty"`
IsPublic bool `json:"is_public,omitempty" yaml:"is_public,omitempty"`
Homepage string `json:"homepage,omitempty" yaml:"homepage,omitempty"`
}
TODO: Parent Project
type Projects ¶
type Projects struct {
Projects []Project `json:"projects,omitempty" yaml:"projects,omitempty"`
TotalCount int `json:"total_count,omitempty" yaml:"total_count,omitempty"`
Offset int `json:"offset,omitempty" yaml:"offset,omitempty"`
Limit int `json:"limit,omitempty" yaml:"limit,omitempty"`
}
Example ¶
package main
import (
"fmt"
"gorbe.io/go/redmine"
)
func main() {
v, err := redmine.NewPublic("https://www.redmine.org").Projects()
if err != nil {
// handle error
}
fmt.Printf("%v\n", v.Identifiers())
}
func (*Projects) Identifiers ¶
Identifiers returns a slice of projects identifier.
type Public ¶
type Public struct {
// contains filtered or unexported fields
}
Public is an instance of a public Redmine server (eg.: www.redmine.org).
func (*Public) Impersonate ¶
type Redmine ¶
type Redmine struct {
// contains filtered or unexported fields
}
func NewAuthKey ¶
Example ¶
package main
import (
"gorbe.io/go/redmine"
)
func main() {
_ = redmine.NewAuthKey("https://www.redmine.org", "apikey")
}
func NewHeaderKey ¶
Example ¶
package main
import (
"gorbe.io/go/redmine"
)
func main() {
_ = redmine.NewHeaderKey("https://www.redmine.org", "apikey")
}
func NewPublic ¶
Example ¶
package main
import (
"gorbe.io/go/redmine"
)
func main() {
_ = redmine.NewPublic("https://www.redmine.org")
}
func NewRegularLogin ¶
NewRegularLogin creates a RegularLogin instance.
If the parameter "become" is set to a username, then the request includes the "X-Redmine-Switch-User: user" header to impersonate the given user.
Example ¶
package main
import (
"gorbe.io/go/redmine"
)
func main() {
_ = redmine.NewRegularLogin("https://www.redmine.org", "admin1", "password")
}
func (*Redmine) CreateIssue ¶
CreateIssue creates a new Issue.
If Issue is created, the underlying data of iss will be replaced by the returned Issue.
func (*Redmine) CreateUser ¶
CreateUser creates a new user.
Required fields: Login, Firstname, Lastname and Mail
If notify is true, sends account information to the user. If user created, the underlying data of u will be replaced by the returned user.
func (*Redmine) DeleteUser ¶
DeleteUser remves a user with the given id.
func (*Redmine) Impersonate ¶
func (*Redmine) IssueStatusWithName ¶
func (r *Redmine) IssueStatusWithName(name string) (*IssueStatus, error)
IssueStatusWithName returns the IssueStatus with the given Name. If no IssueStatus found with Name name, returns nil.
func (*Redmine) IssueStatuses ¶
func (r *Redmine) IssueStatuses(params ...Parameter) (IssueStatuses, error)
func (*Redmine) Priorities ¶
func (r *Redmine) Priorities(params ...Parameter) (Priorities, error)
func (*Redmine) PriorityWithName ¶
PriorityWithName returns the Priority with the given Name. If no Priority found with Name name, returns nil.
func (*Redmine) ProjectWithIdentifier ¶
ProjectWithIdentifier returns the Project with the given Identifier identifier.
If no project found with the given identifier returns ErrProjectNotFound.
func (*Redmine) TrackerWithName ¶
TrackerWithName returns the Tracker with the given Name. If no Tracker found with Name name, returns nil.
func (*Redmine) UpdateUser ¶
UpdateUser modify a user.
Required fields: ID, Login, Firstname, Lastname and Mail
If notify is true, sends account information to the user.
func (*Redmine) UserWithLogin ¶
UserWithName returns the User with the given Name. If no User found with Name name, returns nil.
type RegularLogin ¶
type RegularLogin struct {
// contains filtered or unexported fields
}
RegularLogin is authenticates to Redmine with the user's login and password via HTTP Basic Auth.
func (*RegularLogin) Impersonate ¶
func (rl *RegularLogin) Impersonate(name string)
type Tracker ¶
type Tracker struct {
ID int `json:"id,omitempty" yaml:"id,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
DefaultStatus IssueStatus `json:"default_status,omitempty" yaml:"default_status,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
EnabledStandardFields []string `json:"enabled_standard_fields,omitempty" yaml:"enabled_standard_fields,omitempty"`
}
type User ¶
type User struct {
ID int `json:"id,omitempty" yaml:"id,omitempty"`
Login string `json:"login,omitempty" yaml:"login,omitempty"`
Password string `json:"password,omitempty" yaml:"password,omitempty"`
Admin bool `json:"admin,omitempty" yaml:"admin,omitempty"`
FirstName string `json:"firstname,omitempty" yaml:"firstname,omitempty"`
LastName string `json:"lastname,omitempty" yaml:"lastname,omitempty"`
Mail string `json:"mail,omitempty" yaml:"mail,omitempty"`
CreatedOn time.Time `json:"created_on,omitempty" yaml:"created_on,omitempty"`
UpdatedOn time.Time `json:"updated_on,omitempty" yaml:"updated_on,omitempty"`
LastLoginOn time.Time `json:"last_login_on,omitempty" yaml:"last_login_on,omitempty"`
PasswdChangedOn time.Time `json:"passwd_changed_on,omitempty" yaml:"passwd_changed_on,omitempty"`
TwoFAScheme string `json:"twofa_scheme,omitempty" yaml:"twofa_scheme,omitempty"`
ApiKey string `json:"api_key,omitempty" yaml:"api_key,omitempty"`
AvatarURL string `json:"avatar_url,omitempty" yaml:"avatar_url,omitempty"`
Status UserStatus `json:"status,omitempty" yaml:"status,omitempty"`
CustomField []CustomField `json:"custom_fields,omitempty" yaml:"custom_fields,omitempty"`
Groups []Group `json:"groups,omitempty" yaml:"groups,omitempty"`
Memberships []Membership `json:"memberships,omitempty" yaml:"memberships,omitempty"`
// CreateUser fields
AuthSourceId int `json:"auth_source_id,omitempty" yaml:"auth_source_id,omitempty"`
MailNotification MailNotification `json:"mail_notification,omitempty" yaml:"mail_notification,omitempty"`
MustChangePassword bool `json:"must_change_passwd,omitempty" yaml:"must_change_passwd,omitempty"`
GeneratePassword bool `json:"generate_password,omitempty" yaml:"generate_password,omitempty"`
}
type UserStatus ¶
type UserStatus int
const ( UserActive UserStatus = 1 UserRegistered UserStatus = 2 UserLocked UserStatus = 3 )
func ParseUserStatus ¶
func ParseUserStatus(v string) UserStatus
ParseUserStatus converts user status string v to UserStatus. Returns -1 if v is not a valid user status.
func (UserStatus) String ¶
func (us UserStatus) String() string
type Users ¶
type Users struct {
Users []User `json:"users,omitempty" yaml:"users,omitempty"`
TotalCount int `json:"total_count,omitempty" yaml:"total_count,omitempty"`
Offset int `json:"offset,omitempty" yaml:"offset,omitempty"`
Limit int `json:"limit,omitempty" yaml:"limit,omitempty"`
}
Example ¶
package main
import (
"fmt"
"gorbe.io/go/redmine"
)
func main() {
users, err := redmine.NewPublic("https://www.redmine.org").Users()
if err != nil {
// handle error
}
fmt.Printf("%#v", users)
}
Example (WithParams) ¶
package main
import (
"fmt"
"gorbe.io/go/redmine"
)
func main() {
users, err := redmine.NewPublic("https://www.redmine.org").Users(redmine.NameParameter("tester"))
if err != nil {
// handle error
}
fmt.Printf("%#v", users)
}
func (*Users) JSON ¶
JSON encodes Users to JSON.
If marshaling fails for any reason, this function panics.