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 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 StatusFilter(v int) Parameter
- func StatusIDFilter(v int) Parameter
- type Priority
- type Project
- type Projects
- type Public
- type Redmine
- func (r *Redmine) CreateUser(u *User, notify bool) error
- func (r *Redmine) DeleteUser(id int) error
- func (r *Redmine) Issue(id int) (*Issue, error)
- func (r *Redmine) Issues(params ...Parameter) (*Issues, error)
- func (r *Redmine) ProjectWithIdentifier(identifier string) (*Project, error)
- func (r *Redmine) Projects(params ...Parameter) (*Projects, error)
- func (r *Redmine) Trackers() (Trackers, error)
- func (r *Redmine) UpdateUser(u *User, notify bool) error
- func (r *Redmine) User(id int) (User, error)
- func (r *Redmine) Users(params ...Parameter) (*Users, error)
- type RegularLogin
- type Role
- type Status
- 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") )
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
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) }
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.
type Issue ¶
type Issue struct { ID int `json:"id"` Project Project `json:"project"` Tracker Tracker `json:"tracker"` Status Status `json:"status"` Priority Priority `json:"priority"` Author Author `json:"author"` Category Category `json:"category"` Subject string `json:"subject"` Description string `json:"description"` StartDate string `json:"start_date"` DueDate string `json:"due_date"` DoneRation int `json:"done_ratio"` IsPrivate bool `json:"is_private"` //EstimatedHours //TotalEstimatedHours SpentHours float64 `json:"spent_hours"` TotalSpentHours float64 `json:"total_spent_hours"` CreatedOn time.Time `json:"created_on"` UpdatedOn time.Time `json:"updated_on"` ClosedOn time.Time `json:"closed_on"` CustomFields []CustomField `json:"custom_fields"` }
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) }
Output:
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) }
Output:
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 StatusFilter ¶
func StatusIDFilter ¶
type Project ¶
type Project struct { ID int `json:"id"` Name string `json:"name"` Identifier string `json:"identifier"` Description string `json:"description"` CreatedOn time.Time `json:"created_on"` UpdatedOn time.Time `json:"updated_on"` IsPublic bool `json:"is_public"` Homepage string `json:"homepage"` }
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()) }
Output:
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).
type Redmine ¶
type Redmine struct {
// contains filtered or unexported fields
}
func NewAuthKey ¶
Example ¶
package main import ( "gorbe.io/go/redmine" ) func main() { // User of apikey impersonates admin2 if user is admin _ = redmine.NewAuthKey("https://www.redmine.org", "apikey", "admin2") }
Output:
func NewHeaderKey ¶
Example ¶
package main import ( "gorbe.io/go/redmine" ) func main() { // User of apikey impersonates admin2 if user is admin _ = redmine.NewHeaderKey("https://www.redmine.org", "apikey", "admin2") }
Output:
func NewPublic ¶
Example ¶
package main import ( "gorbe.io/go/redmine" ) func main() { _ = redmine.NewPublic("https://www.redmine.org") }
Output:
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() { // admin1 user impersonates admin2 _ = redmine.NewRegularLogin("https://www.redmine.org", "admin1", "password", "admin2") }
Output:
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) ProjectWithIdentifier ¶
ProjectWithIdentifier returns the Project with the given Identifier identifier. If no project found, 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.
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.
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"` // 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) }
Output:
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) }
Output:
func (*Users) JSON ¶
JSON encodes Users to JSON.
If marshaling fails for any reason, this function panics.