-
Notifications
You must be signed in to change notification settings - Fork 1
/
jobgroup.go
56 lines (50 loc) · 2.07 KB
/
jobgroup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package gopenqa
import (
"fmt"
"net/url"
)
/* Job Group */
type JobGroup struct {
ID int `json:"id"`
Name string `json:"name"`
ParentID int `json:"parent_id"`
Description string `json:"description"`
BuildVersionSort int `json:"build_version_sort"`
CarryOverBugrefs int `json:"carry_over_bugrefs"`
DefaultPriority int `json:"default_priority`
// Disabled because of type mismatch in json
// Sometimes it's returned as int, sometimes as string and we cannot deal with that atm
//KeepImportantLogsInDays int `json:"keep_important_logs_in_days"`
//KeepImportantResultsInDays int `json:"keep_important_results_in_days"`
//KeepLogsInDays int `json:"keep_logs_in_days"`
//KeepResultsInDays int `json:"keep_results_in_days"`
//SizeLimit int `json:"size_limit_gb"` // Size limit in GB
SortOrder int `json:"sort_order"`
Template string `json:"template"`
}
func addIntIfNotZero(value int, name string, values *url.Values) {
if value > 0 {
values.Add(name, fmt.Sprintf("%d", value))
}
}
/* Get www-form-urlencoded parameters of this Product */
func (j *JobGroup) encodeWWW() string {
params := url.Values{}
addIntIfNotZero(j.ID, "id", ¶ms)
params.Add("name", j.Name)
if j.ParentID > 0 {
params.Add("parent_id", fmt.Sprintf("%d", j.ParentID))
}
params.Add("description", j.Description)
addIntIfNotZero(j.BuildVersionSort, "build_version_sort", ¶ms)
addIntIfNotZero(j.CarryOverBugrefs, "carry_over_bugrefs", ¶ms)
addIntIfNotZero(j.DefaultPriority, "default_priority", ¶ms)
//addIntIfNotZero(j.KeepImportantLogsInDays, "keep_important_logs_in_days", ¶ms)
//addIntIfNotZero(j.KeepImportantResultsInDays, "keep_important_results_in_days", ¶ms)
//addIntIfNotZero(j.KeepLogsInDays, "keep_logs_in_days", ¶ms)
//addIntIfNotZero(j.KeepResultsInDays, "keep_results_in_days", ¶ms)
//addIntIfNotZero(j.SizeLimit, "size_limit_gb", ¶ms)
addIntIfNotZero(j.SortOrder, "sort_order", ¶ms)
params.Add("template", j.Template)
return params.Encode()
}