forked from fabric8-services/fabric8-wit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_types.go
106 lines (96 loc) · 3.83 KB
/
user_types.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package design
import (
d "github.com/goadesign/goa/design"
a "github.com/goadesign/goa/design/apidsl"
)
// CreateWorkItemPayload defines the structure of work item payload
var CreateWorkItemPayload = a.Type("CreateWorkItemPayload", func() {
a.Attribute("type", d.UUID, "ID of the work item type of the newly created work item")
a.Attribute("fields", a.HashOf(d.String, d.Any), "The field values, must conform to the type", func() {
a.Example(map[string]interface{}{"system.creator": "user-ref", "system.state": "new", "system.title": "Example story"})
a.MinLength(1)
})
a.Required("type", "fields")
})
// UpdateWorkItemPayload has been added because the design.WorkItem could
// not be used since it mandated the presence of the ID in the payload
// which ideally should be optional. The ID should be passed on to REST URL.
var UpdateWorkItemPayload = a.Type("UpdateWorkItemPayload", func() {
a.Attribute("type", d.UUID, "ID of the work item type")
a.Attribute("fields", a.HashOf(d.String, d.Any), "The field values, must conform to the type", func() {
a.Example(map[string]interface{}{"system.creator": "user-ref", "system.state": "new", "system.title": "Example story"})
a.MinLength(1)
})
a.Attribute("version", d.Integer, "Version for optimistic concurrency control", func() {
a.Example(0)
})
a.Attribute("executionorder", d.Number, "The order of execution of workitem", func() {
a.Example(1000)
})
a.Attribute("relationships", workItemRelationships)
a.Required("type", "fields", "version", "executionorder")
})
// CreateTrackerAlternatePayload defines the structure of tracker payload for create
var CreateTrackerAlternatePayload = a.Type("CreateTrackerAlternatePayload", func() {
a.Attribute("url", d.String, "URL of the tracker", func() {
a.Example("https://api.github.com/")
a.MinLength(1)
})
a.Attribute("type", d.String, "Type of the tracker", func() {
a.Example("github")
a.Pattern("^[\\p{L}]+$")
a.MinLength(1)
})
a.Required("url", "type")
})
// UpdateTrackerAlternatePayload defines the structure of tracker payload for update
var UpdateTrackerAlternatePayload = a.Type("UpdateTrackerAlternatePayload", func() {
a.Attribute("url", d.String, "URL of the tracker", func() {
a.Example("https://api.github.com/")
a.MinLength(1)
})
a.Attribute("type", d.String, "Type of the tracker", func() {
a.Example("github")
a.MinLength(1)
a.Pattern("^[\\p{L}]+$")
})
a.Required("url", "type")
})
// CreateTrackerQueryAlternatePayload defines the structure of tracker query payload for create
var CreateTrackerQueryAlternatePayload = a.Type("CreateTrackerQueryAlternatePayload", func() {
a.Attribute("query", d.String, "Search query", func() {
a.Example("is:open is:issue user:wit")
a.MinLength(1)
})
a.Attribute("schedule", d.String, "Schedule for fetch and import", func() {
a.Example("0 0/15 * * * *")
a.Pattern("^[\\d]+|[\\d]+[\\/][\\d]+|\\*|\\-|\\?\\s{0,6}$")
a.MinLength(1)
})
a.Attribute("trackerID", d.String, "Tracker ID", func() {
a.Example("1")
a.MinLength(1)
a.Pattern("^[\\p{N}]+$")
})
a.Attribute("relationships", trackerQueryRelationships)
a.Required("query", "schedule", "trackerID")
})
// UpdateTrackerQueryAlternatePayload defines the structure of tracker query payload for update
var UpdateTrackerQueryAlternatePayload = a.Type("UpdateTrackerQueryAlternatePayload", func() {
a.Attribute("query", d.String, "Search query", func() {
a.Example("is:open is:issue user:wit")
a.MinLength(1)
})
a.Attribute("schedule", d.String, "Schedule for fetch and import", func() {
a.Example("0 0/15 * * * *")
a.Pattern("^[\\d]+|[\\d]+[\\/][\\d]+|\\*|\\-|\\?\\s{0,6}$")
a.MinLength(1)
})
a.Attribute("trackerID", d.String, "Tracker ID", func() {
a.Example("1")
a.MinLength(1)
a.Pattern("[\\p{N}]+")
})
a.Attribute("relationships", trackerQueryRelationships)
a.Required("query", "schedule", "trackerID")
})