Documentation ¶
Overview ¶
Redmine Package is a set of accessors that provide you to get, update, and delete Redmine Issues, Wikis, files, and project-wide configuration values.
Index ¶
- Variables
- func CreateIssue(url, key string, timeout int, issue IssueParam, customClient *http.Client) (int, error)
- func CreateJournalStrings(issue Issue) []string
- func DeleteIssue(url, key string, id, timeout int, customClient *http.Client) error
- func DownloadAttachmentFiles(key string, timeout int, attachments Attachments, customClient *http.Client) ([][]byte, error)
- func UpdateIssueJournals(url, key string, id, timeout int, journals []string, customClient *http.Client) error
- func UpdateWatchers(url, key string, id, timeout int, issue Issue, customClient *http.Client) error
- type AssignedTo
- type Attachment
- type Attachments
- type Author
- type CustomField
- type CustomFields
- type Detail
- type Details
- type FileParam
- type Issue
- type IssueParam
- type IssueParamJson
- type Issues
- type Journal
- type Journals
- type Priority
- type Project
- type Status
- type Tracker
- type Uploads
- type User
- type Watcher
- type WatcherParam
- type Watchers
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var UploadResult struct { Upload struct { Token string `json:"token"` } }
Functions ¶
func CreateIssue ¶
func CreateIssue(url, key string, timeout int, issue IssueParam, customClient *http.Client) (int, error)
CreateIssue is function to create an Issue from an IssueParam. As a return value, the ID of the created Issue will be returned. You can also customize it to plant round trips, go through proxies, or disable TLS validation by using a custom http client.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" ) func main() { var exampleParam = redmine.IssueParam{ ProjectId: 1, TrackerId: 1, StatusId: 1, PriorityId: 1, Subject: "test1", Description: "testtesttesttest", AssignedToId: 1, CustomFields: redmine.CustomFields{ &redmine.CustomField{Id: 1}, }, Notes: "testNote", Uploads: []redmine.Uploads{ { Token: "aaa", FileName: "aaa.png", ContentType: "image/png", }, }, } resp, _ := redmine.CreateIssue("https://redmine.example.com", "your-api-key-1234567890", 10000, exampleParam, nil) // Issue ID fmt.Printf("'%d'", resp) }
Output:
func CreateJournalStrings ¶
CreateJournalStrings is a function that can create a slice of a Note from an Issue structure. This function is used in conjunction with UpdateIssueJournals.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" ) func main() { var exampleIssue = redmine.Issue{ Id: 1, Project: redmine.Project{Id: 1, Name: "testProject"}, Tracker: redmine.Tracker{Id: 1, Name: "doing"}, Status: redmine.Status{Id: 1, Name: "test"}, Priority: redmine.Priority{Id: 1, Name: "High"}, Author: redmine.Author{Id: 1, Name: "testUser"}, AssignedTo: redmine.AssignedTo{Id: 1, Name: "testUser"}, Subject: "test1", Description: "testtesttesttest", StartDate: "2020-01-01T00:00:00Z", CustomFields: redmine.CustomFields{&redmine.CustomField{ Id: 1, Name: "customField1", Multiple: true, Value: []string{"aaaa", "bbb", "ccc"}}}, CreatedOn: "2020-01-01T00:00:00Z", UpdatedOn: "2020-01-01T00:00:00Z", Attachments: redmine.Attachments{&redmine.Attachment{ Id: 1, FileName: "test.png", FileSize: 12000, ContentUrl: "http://example.com/test.png", Description: "testFile", Author: redmine.Author{Id: 1, Name: "testUser"}, CreatedOn: "2020-01-01T00:00:00Z"}}, Journals: redmine.Journals{&redmine.Journal{ Id: 1, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 2, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest2", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 3, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z", Details: redmine.Details{&redmine.Detail{ Property: "change", Name: "upload", OldValue: "aaa", NewValue: "bbb"}}}, }, Watchers: redmine.Watchers{&redmine.Watcher{ Id: 1, Name: "testUser"}, &redmine.Watcher{Id: 2, Name: "testUser2"}, &redmine.Watcher{Id: 3, Name: "testUser3"}}, } resp := redmine.CreateJournalStrings(exampleIssue) for _, v := range resp { fmt.Println(v) } }
Output:
func DeleteIssue ¶
DeleteIssue is a function to delete a specific Issue. You can also customize it to plant round trips, go through proxies, or disable TLS validation by using a custom http client.
Example ¶
package main import ( "github.com/tubone24/redump/pkg/redmine" ) func main() { _ = redmine.DeleteIssue("https://redmine.example.com", "your-api-key-1234567890", 1, 10000, nil) }
Output:
func DownloadAttachmentFiles ¶
func DownloadAttachmentFiles(key string, timeout int, attachments Attachments, customClient *http.Client) ([][]byte, error)
DownloadAttachmentFiles is function that you pass the Attachment structure, you can store all the included attachments locally and return a byte slice of the attachment along with it You can also customize it to plant round trips, go through proxies, or disable TLS validation by using a custom http client.
Example ¶
package main import ( "github.com/tubone24/redump/pkg/redmine" "github.com/tubone24/redump/pkg/utils" "strconv" ) func main() { attachment := redmine.Attachments{&redmine.Attachment{ Id: 1, FileName: "test.png", FileSize: 12000, ContentUrl: "http://example.com/test.png", Description: "testFile", Author: redmine.Author{Id: 1, Name: "testUser"}, CreatedOn: "2020-01-01T00:00:00Z"}} resp, _ := redmine.DownloadAttachmentFiles("https://redmine.example.com", 10000, attachment, nil) // Return byte slice's slice. So for loop. for i, v := range resp { _ = utils.WriteFile("test"+strconv.Itoa(i)+".png", v) } }
Output:
func UpdateIssueJournals ¶
func UpdateIssueJournals(url, key string, id, timeout int, journals []string, customClient *http.Client) error
UpdateIssueJournals is function that updating Journal notes on specific issue. you must input a slice of a string, which can be created in advance with CreateJournalStrings function. Also, if the string is empty, (which is often the case for ticket status updates without note updates) no updates will be made. You can also customize it to plant round trips, go through proxies, or disable TLS validation by using a custom http client.
Example ¶
package main import ( "github.com/tubone24/redump/pkg/redmine" ) func main() { exampleJournalsString := []string{"test", "test2", "test3"} _ = redmine.UpdateIssueJournals("https://redmine.example.com", "your-api-key-1234567890", 1, 10000, exampleJournalsString, nil) }
Output:
func UpdateWatchers ¶
UpdateWatchers is a function that allows you to postfix watchers to a specific issue. In Redmine, it is recommended to run this function after all ticket updates are completed, because the issue with a watcher will be notified every time there is an update. You can also customize it to plant round trips, go through proxies, or disable TLS validation by using a custom http client.
Example ¶
package main import ( "github.com/tubone24/redump/pkg/redmine" ) func main() { var exampleIssue = redmine.Issue{ Id: 1, Project: redmine.Project{Id: 1, Name: "testProject"}, Tracker: redmine.Tracker{Id: 1, Name: "doing"}, Status: redmine.Status{Id: 1, Name: "test"}, Priority: redmine.Priority{Id: 1, Name: "High"}, Author: redmine.Author{Id: 1, Name: "testUser"}, AssignedTo: redmine.AssignedTo{Id: 1, Name: "testUser"}, Subject: "test1", Description: "testtesttesttest", StartDate: "2020-01-01T00:00:00Z", CustomFields: redmine.CustomFields{&redmine.CustomField{ Id: 1, Name: "customField1", Multiple: true, Value: []string{"aaaa", "bbb", "ccc"}}}, CreatedOn: "2020-01-01T00:00:00Z", UpdatedOn: "2020-01-01T00:00:00Z", Attachments: redmine.Attachments{&redmine.Attachment{ Id: 1, FileName: "test.png", FileSize: 12000, ContentUrl: "http://example.com/test.png", Description: "testFile", Author: redmine.Author{Id: 1, Name: "testUser"}, CreatedOn: "2020-01-01T00:00:00Z"}}, Journals: redmine.Journals{&redmine.Journal{ Id: 1, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 2, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest2", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 3, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z", Details: redmine.Details{&redmine.Detail{ Property: "change", Name: "upload", OldValue: "aaa", NewValue: "bbb"}}}, }, Watchers: redmine.Watchers{&redmine.Watcher{ Id: 1, Name: "testUser"}, &redmine.Watcher{Id: 2, Name: "testUser2"}, &redmine.Watcher{Id: 3, Name: "testUser3"}}, } _ = redmine.UpdateWatchers("https://redmine.example.com", "your-api-key-1234567890", 1, 10000, exampleIssue, nil) }
Output:
Types ¶
type AssignedTo ¶
func ListUserIdAssignedTo ¶
func ListUserIdAssignedTo(issues Issues, filename string) ([]AssignedTo, error)
ListUserIdAssignedTo is a function that creates a set of User IDs and names from the Issues structure on assigned to objects. If filename is specified, the JSON file will be output with the specified file name.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" ) func main() { exampleIssues := redmine.Issues{{ Id: 1, Project: redmine.Project{Id: 1, Name: "testProject"}, Tracker: redmine.Tracker{Id: 1, Name: "doing"}, Status: redmine.Status{Id: 1, Name: "test"}, Priority: redmine.Priority{Id: 1, Name: "High"}, Author: redmine.Author{Id: 1, Name: "testUser"}, AssignedTo: redmine.AssignedTo{Id: 1, Name: "testUser"}, Subject: "test1", Description: "testtesttesttest", StartDate: "2020-01-01T00:00:00Z", CustomFields: redmine.CustomFields{&redmine.CustomField{ Id: 1, Name: "customField1", Multiple: true, Value: []string{"aaaa", "bbb", "ccc"}}}, CreatedOn: "2020-01-01T00:00:00Z", UpdatedOn: "2020-01-01T00:00:00Z", Attachments: redmine.Attachments{&redmine.Attachment{ Id: 1, FileName: "test.png", FileSize: 12000, ContentUrl: "http://example.com/test.png", Description: "testFile", Author: redmine.Author{Id: 1, Name: "testUser"}, CreatedOn: "2020-01-01T00:00:00Z"}}, Journals: redmine.Journals{&redmine.Journal{ Id: 1, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 2, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest2", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 3, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z", Details: redmine.Details{&redmine.Detail{ Property: "change", Name: "upload", OldValue: "aaa", NewValue: "bbb"}}}, }, Watchers: redmine.Watchers{&redmine.Watcher{ Id: 1, Name: "testUser"}, &redmine.Watcher{Id: 2, Name: "testUser2"}, &redmine.Watcher{Id: 3, Name: "testUser3"}}, }} resp, _ := redmine.ListUserIdAssignedTo(exampleIssues, "") for _, v := range resp { fmt.Println(v.Name) } }
Output:
type Attachment ¶
type Attachments ¶
type Attachments []*Attachment
type CustomField ¶
type CustomField struct { Id int `json:"id"` Name string `json:"name"` Multiple bool `json:"multiple"` Value interface{} `json:"value"` }
func ListCustomFieldsId ¶
func ListCustomFieldsId(issues Issues, filename string) ([]CustomField, error)
ListCustomFieldsId is a function that creates a set of CustomFields IDs and names from the Issues structure. If filename is specified, the JSON file will be output with the specified file name.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" ) func main() { exampleIssues := redmine.Issues{{ Id: 1, Project: redmine.Project{Id: 1, Name: "testProject"}, Tracker: redmine.Tracker{Id: 1, Name: "doing"}, Status: redmine.Status{Id: 1, Name: "test"}, Priority: redmine.Priority{Id: 1, Name: "High"}, Author: redmine.Author{Id: 1, Name: "testUser"}, AssignedTo: redmine.AssignedTo{Id: 1, Name: "testUser"}, Subject: "test1", Description: "testtesttesttest", StartDate: "2020-01-01T00:00:00Z", CustomFields: redmine.CustomFields{&redmine.CustomField{ Id: 1, Name: "customField1", Multiple: true, Value: []string{"aaaa", "bbb", "ccc"}}}, CreatedOn: "2020-01-01T00:00:00Z", UpdatedOn: "2020-01-01T00:00:00Z", Attachments: redmine.Attachments{&redmine.Attachment{ Id: 1, FileName: "test.png", FileSize: 12000, ContentUrl: "http://example.com/test.png", Description: "testFile", Author: redmine.Author{Id: 1, Name: "testUser"}, CreatedOn: "2020-01-01T00:00:00Z"}}, Journals: redmine.Journals{&redmine.Journal{ Id: 1, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 2, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest2", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 3, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z", Details: redmine.Details{&redmine.Detail{ Property: "change", Name: "upload", OldValue: "aaa", NewValue: "bbb"}}}, }, Watchers: redmine.Watchers{&redmine.Watcher{ Id: 1, Name: "testUser"}, &redmine.Watcher{Id: 2, Name: "testUser2"}, &redmine.Watcher{Id: 3, Name: "testUser3"}}, }} resp, _ := redmine.ListCustomFieldsId(exampleIssues, "") for _, v := range resp { fmt.Println(v.Name) } }
Output:
type CustomFields ¶
type CustomFields []*CustomField
type FileParam ¶
func UploadAttachmentFiles ¶
func UploadAttachmentFiles(u, key string, timeout int, files []FileParam, customClient *http.Client) ([]FileParam, error)
UploadAttachmentFiles is a function that updates the attachment files on Redmine. When you perform a file upload to Redmine, a token is returned, so when you run CreateIssue, you can specify a FileParam that contains the token in the return value to complete the attachment to the ticket. You can also customize it to plant round trips, go through proxies, or disable TLS validation by using a custom http client.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" ) func main() { ExampleuploadFile := []redmine.FileParam{ { FileName: "test.png", ContentType: "image/png", Contents: []byte{}, }, } fileParams, _ := redmine.UploadAttachmentFiles("https://redmine.example.com", "your-api-key-1234567890", 10000, ExampleuploadFile, nil) fmt.Println(fileParams[0].Token) }
Output:
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"` AssignedTo AssignedTo `json:"assigned_to"` Subject string `json:"subject"` Description string `json:"description"` StartDate string `json:"start_date"` DueDate string `json:"due_date"` DoneRatio int `json:"done_ratio"` CustomFields CustomFields `json:"custom_fields"` IsPrivate bool `json:"is_private"` EstimatedHours string `json:"estimated_hours"` CreatedOn string `json:"created_on"` UpdatedOn string `json:"updated_on"` ClosedOn string `json:"closed_on"` Attachments Attachments `json:"attachments"` Journals Journals `json:"journals"` Watchers Watchers `json:"watchers"` }
func ConvertNewEnv ¶
ConvertNewEnv converts the information in the source Redmine ticket to that of the new Redmine ticket using the mappings that exist in Config. When silent mode is enabled, only the user specified in default will be assigned.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/config" "github.com/tubone24/redump/pkg/redmine" ) func main() { var exampleIssue = redmine.Issue{ Id: 1, Project: redmine.Project{Id: 1, Name: "testProject"}, Tracker: redmine.Tracker{Id: 1, Name: "doing"}, Status: redmine.Status{Id: 1, Name: "test"}, Priority: redmine.Priority{Id: 1, Name: "High"}, Author: redmine.Author{Id: 1, Name: "testUser"}, AssignedTo: redmine.AssignedTo{Id: 1, Name: "testUser"}, Subject: "test1", Description: "testtesttesttest", StartDate: "2020-01-01T00:00:00Z", CustomFields: redmine.CustomFields{&redmine.CustomField{ Id: 1, Name: "customField1", Multiple: true, Value: []string{"aaaa", "bbb", "ccc"}}}, CreatedOn: "2020-01-01T00:00:00Z", UpdatedOn: "2020-01-01T00:00:00Z", Attachments: redmine.Attachments{&redmine.Attachment{ Id: 1, FileName: "test.png", FileSize: 12000, ContentUrl: "http://example.com/test.png", Description: "testFile", Author: redmine.Author{Id: 1, Name: "testUser"}, CreatedOn: "2020-01-01T00:00:00Z"}}, Journals: redmine.Journals{&redmine.Journal{ Id: 1, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 2, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest2", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 3, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z", Details: redmine.Details{&redmine.Detail{ Property: "change", Name: "upload", OldValue: "aaa", NewValue: "bbb"}}}, }, Watchers: redmine.Watchers{&redmine.Watcher{ Id: 1, Name: "testUser"}, &redmine.Watcher{Id: 2, Name: "testUser2"}, &redmine.Watcher{Id: 3, Name: "testUser3"}}, } cfg := config.Config{Mappings: []config.Mapping{ { Name: "project_id", Values: []config.MappingValue{ { Old: 1, New: 2, }, }, }, { Name: "tracker_id", Values: []config.MappingValue{ { Old: 1, New: 2, }, }, }, { Name: "status_id", Values: []config.MappingValue{ { Old: 1, New: 2, }, }, }, { Name: "priority_id", Values: []config.MappingValue{ { Old: 1, New: 2, }, }, }, { Name: "user_id", Values: []config.MappingValue{ { Old: 1, New: 2, }, }, }, { Name: "custom_field_id", Values: []config.MappingValue{ { Old: 1, New: 2, }, }, }, }} resp, _ := redmine.ConvertNewEnv(exampleIssue, cfg, false) fmt.Println(exampleIssue.Project.Id) // Change to 1 to 2 fmt.Println(resp.Project.Id) }
Output:
func CreateIssueFromByteSlice ¶
CreateIssueFromByteSlice is function to create the structure of an Issue by receiving a byte slice. If an invalid byte slice is received, an empty Issue structure will be returned with an error.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" "github.com/tubone24/redump/pkg/utils" ) func main() { resp, _ := utils.ReadFile("test.json") issue, _ := redmine.CreateIssueFromByteSlice(resp) fmt.Printf("'%d'", issue.Id) }
Output:
func GetIssue ¶
GetIssue is function that you can retrieve the details by specifying the Issue ID. You can also customize it to plant round trips, go through proxies, or disable TLS validation by using a custom http client.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" ) func main() { // Several Project (ex. ID is 1) issue, _ := redmine.GetIssue("https://redmine.example.com", "your-api-key-1234567890", 1, 10000, nil) fmt.Printf("'%#v'", issue) }
Output:
func UnmarshalByteIssue ¶
UnmarshalByteIssue is function to create the structure of an Issue by receiving a byte slice. If an invalid byte slice is received, an empty Issue structure will be returned with an error. Deprecated: This function is deprecated
type IssueParam ¶
type IssueParam struct { ProjectId int `json:"project_id,omitempty"` TrackerId int `json:"tracker_id,omitempty"` StatusId int `json:"status_id,omitempty"` PriorityId int `json:"priority_id,omitempty"` Subject string `json:"subject,omitempty"` Description string `json:"description,omitempty"` AssignedToId int `json:"assigned_to_id,omitempty"` ParentIssueId int `json:"parent_issue_id,omitempty"` CustomFields CustomFields `json:"custom_fields,omitempty"` Notes string `json:"notes,omitempty"` Uploads []Uploads `json:"uploads,omitempty"` }
func CreateIssueParam ¶
func CreateIssueParam(issue Issue, uploadFiles []FileParam) IssueParam
CreateIssueParam is creating a structure that contains the parameters required for creating an Issue from the Issue structure. If you have attachments, you will also need to create a FileParam slice in advance.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" ) func main() { var exampleIssue = redmine.Issue{ Id: 1, Project: redmine.Project{Id: 1, Name: "testProject"}, Tracker: redmine.Tracker{Id: 1, Name: "doing"}, Status: redmine.Status{Id: 1, Name: "test"}, Priority: redmine.Priority{Id: 1, Name: "High"}, Author: redmine.Author{Id: 1, Name: "testUser"}, AssignedTo: redmine.AssignedTo{Id: 1, Name: "testUser"}, Subject: "test1", Description: "testtesttesttest", StartDate: "2020-01-01T00:00:00Z", CustomFields: redmine.CustomFields{&redmine.CustomField{ Id: 1, Name: "customField1", Multiple: true, Value: []string{"aaaa", "bbb", "ccc"}}}, CreatedOn: "2020-01-01T00:00:00Z", UpdatedOn: "2020-01-01T00:00:00Z", Attachments: redmine.Attachments{&redmine.Attachment{ Id: 1, FileName: "test.png", FileSize: 12000, ContentUrl: "http://example.com/test.png", Description: "testFile", Author: redmine.Author{Id: 1, Name: "testUser"}, CreatedOn: "2020-01-01T00:00:00Z"}}, Journals: redmine.Journals{&redmine.Journal{ Id: 1, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 2, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest2", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 3, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z", Details: redmine.Details{&redmine.Detail{ Property: "change", Name: "upload", OldValue: "aaa", NewValue: "bbb"}}}, }, Watchers: redmine.Watchers{&redmine.Watcher{ Id: 1, Name: "testUser"}, &redmine.Watcher{Id: 2, Name: "testUser2"}, &redmine.Watcher{Id: 3, Name: "testUser3"}}, } exampleUploadFiles := []redmine.FileParam{ { FileName: "test.png", ContentType: "image/png", Contents: []byte{}, Token: "tokentoken", }, } resp := redmine.CreateIssueParam(exampleIssue, exampleUploadFiles) fmt.Printf("'%#v'", resp) }
Output:
type IssueParamJson ¶
type IssueParamJson struct {
Issue IssueParam `json:"issue"`
}
type Issues ¶
type Issues []*Issue
func GetIssues ¶
func GetIssues(url, key string, projectId, timeout int, status string, customClient *http.Client) (Issues, error)
GetIssues is function that you can get all issues of Redmine. However, you can't get detailed information such as Watchers and Journals. If you want to get them, you have to specify the Issue ID and get them individually for GetIssue. You can also customize it to plant round trips, go through proxies, or disable TLS validation by using a custom http client.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" ) func main() { // All Projects issues, _ := redmine.GetIssues("https://redmine.example.com", "your-api-key-1234567890", 0, 10000, "", nil) fmt.Printf("'%#v'", issues) // Several Project (ex. ID is 1) issues, _ = redmine.GetIssues("https://redmine.example.com", "your-api-key-1234567890", 1, 10000, "", nil) fmt.Printf("'%#v'", issues) // Only Closed Status issues, _ = redmine.GetIssues("https://redmine.example.com", "your-api-key-1234567890", 0, 10000, "closed", nil) fmt.Printf("'%#v'", issues) }
Output:
type Priority ¶
func ListPriorityId ¶
ListPriorityId is a function that creates a set of Priority IDs and names from the Issues structure. If filename is specified, the JSON file will be output with the specified file name.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" ) func main() { exampleIssues := redmine.Issues{{ Id: 1, Project: redmine.Project{Id: 1, Name: "testProject"}, Tracker: redmine.Tracker{Id: 1, Name: "doing"}, Status: redmine.Status{Id: 1, Name: "test"}, Priority: redmine.Priority{Id: 1, Name: "High"}, Author: redmine.Author{Id: 1, Name: "testUser"}, AssignedTo: redmine.AssignedTo{Id: 1, Name: "testUser"}, Subject: "test1", Description: "testtesttesttest", StartDate: "2020-01-01T00:00:00Z", CustomFields: redmine.CustomFields{&redmine.CustomField{ Id: 1, Name: "customField1", Multiple: true, Value: []string{"aaaa", "bbb", "ccc"}}}, CreatedOn: "2020-01-01T00:00:00Z", UpdatedOn: "2020-01-01T00:00:00Z", Attachments: redmine.Attachments{&redmine.Attachment{ Id: 1, FileName: "test.png", FileSize: 12000, ContentUrl: "http://example.com/test.png", Description: "testFile", Author: redmine.Author{Id: 1, Name: "testUser"}, CreatedOn: "2020-01-01T00:00:00Z"}}, Journals: redmine.Journals{&redmine.Journal{ Id: 1, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 2, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest2", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 3, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z", Details: redmine.Details{&redmine.Detail{ Property: "change", Name: "upload", OldValue: "aaa", NewValue: "bbb"}}}, }, Watchers: redmine.Watchers{&redmine.Watcher{ Id: 1, Name: "testUser"}, &redmine.Watcher{Id: 2, Name: "testUser2"}, &redmine.Watcher{Id: 3, Name: "testUser3"}}, }} resp, _ := redmine.ListPriorityId(exampleIssues, "") for _, v := range resp { fmt.Println(v.Name) } }
Output:
type Project ¶
func ListProjectId ¶
ListProjectId is a function that creates a set of Project IDs and names from the Issues structure. If filename is specified, the JSON file will be output with the specified file name.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" ) func main() { exampleIssues := redmine.Issues{{ Id: 1, Project: redmine.Project{Id: 1, Name: "testProject"}, Tracker: redmine.Tracker{Id: 1, Name: "doing"}, Status: redmine.Status{Id: 1, Name: "test"}, Priority: redmine.Priority{Id: 1, Name: "High"}, Author: redmine.Author{Id: 1, Name: "testUser"}, AssignedTo: redmine.AssignedTo{Id: 1, Name: "testUser"}, Subject: "test1", Description: "testtesttesttest", StartDate: "2020-01-01T00:00:00Z", CustomFields: redmine.CustomFields{&redmine.CustomField{ Id: 1, Name: "customField1", Multiple: true, Value: []string{"aaaa", "bbb", "ccc"}}}, CreatedOn: "2020-01-01T00:00:00Z", UpdatedOn: "2020-01-01T00:00:00Z", Attachments: redmine.Attachments{&redmine.Attachment{ Id: 1, FileName: "test.png", FileSize: 12000, ContentUrl: "http://example.com/test.png", Description: "testFile", Author: redmine.Author{Id: 1, Name: "testUser"}, CreatedOn: "2020-01-01T00:00:00Z"}}, Journals: redmine.Journals{&redmine.Journal{ Id: 1, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 2, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest2", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 3, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z", Details: redmine.Details{&redmine.Detail{ Property: "change", Name: "upload", OldValue: "aaa", NewValue: "bbb"}}}, }, Watchers: redmine.Watchers{&redmine.Watcher{ Id: 1, Name: "testUser"}, &redmine.Watcher{Id: 2, Name: "testUser2"}, &redmine.Watcher{Id: 3, Name: "testUser3"}}, }} resp, _ := redmine.ListProjectId(exampleIssues, "") for _, v := range resp { fmt.Println(v.Name) } }
Output:
type Status ¶
func ListStatusId ¶
ListStatusId is a function that creates a set of status IDs and names from the Issues structure. If filename is specified, the JSON file will be output with the specified file name.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" ) func main() { exampleIssues := redmine.Issues{{ Id: 1, Project: redmine.Project{Id: 1, Name: "testProject"}, Tracker: redmine.Tracker{Id: 1, Name: "doing"}, Status: redmine.Status{Id: 1, Name: "test"}, Priority: redmine.Priority{Id: 1, Name: "High"}, Author: redmine.Author{Id: 1, Name: "testUser"}, AssignedTo: redmine.AssignedTo{Id: 1, Name: "testUser"}, Subject: "test1", Description: "testtesttesttest", StartDate: "2020-01-01T00:00:00Z", CustomFields: redmine.CustomFields{&redmine.CustomField{ Id: 1, Name: "customField1", Multiple: true, Value: []string{"aaaa", "bbb", "ccc"}}}, CreatedOn: "2020-01-01T00:00:00Z", UpdatedOn: "2020-01-01T00:00:00Z", Attachments: redmine.Attachments{&redmine.Attachment{ Id: 1, FileName: "test.png", FileSize: 12000, ContentUrl: "http://example.com/test.png", Description: "testFile", Author: redmine.Author{Id: 1, Name: "testUser"}, CreatedOn: "2020-01-01T00:00:00Z"}}, Journals: redmine.Journals{&redmine.Journal{ Id: 1, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 2, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest2", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 3, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z", Details: redmine.Details{&redmine.Detail{ Property: "change", Name: "upload", OldValue: "aaa", NewValue: "bbb"}}}, }, Watchers: redmine.Watchers{&redmine.Watcher{ Id: 1, Name: "testUser"}, &redmine.Watcher{Id: 2, Name: "testUser2"}, &redmine.Watcher{Id: 3, Name: "testUser3"}}, }} resp, _ := redmine.ListStatusId(exampleIssues, "") for _, v := range resp { fmt.Println(v.Name) } }
Output:
type Tracker ¶
func ListTrackerId ¶
ListTrackerId is a function that creates a set of Tracker IDs and names from the Issues structure. If filename is specified, the JSON file will be output with the specified file name.
Example ¶
package main import ( "fmt" "github.com/tubone24/redump/pkg/redmine" ) func main() { exampleIssues := redmine.Issues{{ Id: 1, Project: redmine.Project{Id: 1, Name: "testProject"}, Tracker: redmine.Tracker{Id: 1, Name: "doing"}, Status: redmine.Status{Id: 1, Name: "test"}, Priority: redmine.Priority{Id: 1, Name: "High"}, Author: redmine.Author{Id: 1, Name: "testUser"}, AssignedTo: redmine.AssignedTo{Id: 1, Name: "testUser"}, Subject: "test1", Description: "testtesttesttest", StartDate: "2020-01-01T00:00:00Z", CustomFields: redmine.CustomFields{&redmine.CustomField{ Id: 1, Name: "customField1", Multiple: true, Value: []string{"aaaa", "bbb", "ccc"}}}, CreatedOn: "2020-01-01T00:00:00Z", UpdatedOn: "2020-01-01T00:00:00Z", Attachments: redmine.Attachments{&redmine.Attachment{ Id: 1, FileName: "test.png", FileSize: 12000, ContentUrl: "http://example.com/test.png", Description: "testFile", Author: redmine.Author{Id: 1, Name: "testUser"}, CreatedOn: "2020-01-01T00:00:00Z"}}, Journals: redmine.Journals{&redmine.Journal{ Id: 1, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 2, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest2", CreatedOn: "2020-01-01T00:00:00Z"}, &redmine.Journal{ Id: 3, User: redmine.User{Id: 1, Name: "testUser"}, Notes: "testtest", CreatedOn: "2020-01-01T00:00:00Z", Details: redmine.Details{&redmine.Detail{ Property: "change", Name: "upload", OldValue: "aaa", NewValue: "bbb"}}}, }, Watchers: redmine.Watchers{&redmine.Watcher{ Id: 1, Name: "testUser"}, &redmine.Watcher{Id: 2, Name: "testUser2"}, &redmine.Watcher{Id: 3, Name: "testUser3"}}, }} resp, _ := redmine.ListTrackerId(exampleIssues, "") for _, v := range resp { fmt.Println(v.Name) } }
Output:
type WatcherParam ¶
type WatcherParam struct {
UserId int `json:"user_id"`
}