Go client library for Redmine
- Compatible with Redmine 4.2+ (some functionality provided by this library may not be available when working with Redmine versions below 5.0)
- Implemented following Redmine resources:
- All implemented method updated to work with latest Redmine API version
- All fields that may be omitted are now pointers
- Replaced all IDs from
int
toint64
- Includes for methods now are specified with named constants
- Added tools to operate with filters and sorts
Developer teams or sysadmins who need to automate a business processes that works around Redmine.
import "github.com/nixys/nxs-go-redmine/v5"
To initialize this library you need to do:
- Initialize context via call
redmine.Init()
function with specified values of Redmine endpoint and API key
After thar you be able to use all available methods to interact with Redmine API.
In the example below will be printed a names for all active projects from Redmine
package main
import (
"fmt"
"os"
redmine "github.com/nixys/nxs-go-redmine/v5"
)
func main() {
// Get variables from environment for connect to Redmine server
rdmnHost := os.Getenv("REDMINE_HOST")
rdmnAPIKey := os.Getenv("REDMINE_API_KEY")
if rdmnHost == "" || rdmnAPIKey == "" {
fmt.Println("Init error: make sure environment variables `REDMINE_HOST` and `REDMINE_API_KEY` are defined")
os.Exit(1)
}
r := redmine.Init(
redmine.Settings{
Endpoint: rdmnHost,
APIKey: rdmnAPIKey,
},
)
fmt.Println("Init: success")
// Get all active projects with additional
// fields (trackers, categories and modules)
p, _, err := r.ProjectAllGet(
redmine.ProjectAllGetRequest{
Includes: []redmine.ProjectInclude{
redmine.ProjectIncludeTrackers,
redmine.ProjectIncludeIssueCategories,
redmine.ProjectIncludeEnabledModules,
},
Filters: redmine.ProjectGetRequestFiltersInit().
StatusSet(redmine.ProjectStatusActive),
})
if err != nil {
fmt.Println("Projects get error:", err)
os.Exit(1)
}
fmt.Println("Projects:")
for _, e := range p.Projects {
fmt.Println("-", e.Name)
}
}
Run:
REDMINE_HOST="https://redmine.yourdomain.com" REDMINE_API_KEY="YOUR_API_KEY" go run main.go
For more examples see apps based on this library:
Following features are already in backlog for our development team and will be released soon:
- Implement more Redmine API methods (let us know which one you want to see at first)
- Improve error handling in the library
For support and feedback please contact me:
- Issues
- telegram: @borisershov
- e-mail: b.ershov@nixys.ru
nxs-go-redmine is released under the MIT License.