-
Notifications
You must be signed in to change notification settings - Fork 10
/
jira_event_config.go
310 lines (245 loc) · 7.8 KB
/
jira_event_config.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"bytes"
"context"
"encoding/json"
"io"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// JiraEventConfig JiraEventConfig
//
// Represents a Jira Event configuration.
//
// swagger:discriminator JiraEventConfig Represents a Jira Event configuration.
type JiraEventConfig interface {
runtime.Validatable
runtime.ContextValidatable
// User to whom the Jira will be assigned.
// Example: jason@vmware.com
Assignee() string
SetAssignee(string)
// Description for the Jira ticket.
// Example: Details about the issue being reported
Description() string
SetDescription(string)
// endpoint
Endpoint() string
SetEndpoint(string)
// event
// Enum: [SUCCESS FAILURE WAITING CANCELED STARTED]
Event() string
SetEvent(string)
// Jira Issue Type.
// Example: Bug/Story
Issuetype() string
SetIssuetype(string)
// Jira Project Name.
// Example: VRCS
Project() string
SetProject(string)
// stage
Stage() string
SetStage(string)
// Summary for the Jira ticket.
// Example: Pipeline-1 execution failed
Summary() string
SetSummary(string)
// task
Task() string
SetTask(string)
// AdditionalProperties in base type shoud be handled just like regular properties
// At this moment, the base type property is pushed down to the subtype
}
type jiraEventConfig struct {
assigneeField string
descriptionField string
endpointField string
eventField string
issuetypeField string
projectField string
stageField string
summaryField string
taskField string
}
// Assignee gets the assignee of this polymorphic type
func (m *jiraEventConfig) Assignee() string {
return m.assigneeField
}
// SetAssignee sets the assignee of this polymorphic type
func (m *jiraEventConfig) SetAssignee(val string) {
m.assigneeField = val
}
// Description gets the description of this polymorphic type
func (m *jiraEventConfig) Description() string {
return m.descriptionField
}
// SetDescription sets the description of this polymorphic type
func (m *jiraEventConfig) SetDescription(val string) {
m.descriptionField = val
}
// Endpoint gets the endpoint of this polymorphic type
func (m *jiraEventConfig) Endpoint() string {
return m.endpointField
}
// SetEndpoint sets the endpoint of this polymorphic type
func (m *jiraEventConfig) SetEndpoint(val string) {
m.endpointField = val
}
// Event gets the event of this polymorphic type
func (m *jiraEventConfig) Event() string {
return m.eventField
}
// SetEvent sets the event of this polymorphic type
func (m *jiraEventConfig) SetEvent(val string) {
m.eventField = val
}
// Issuetype gets the issuetype of this polymorphic type
func (m *jiraEventConfig) Issuetype() string {
return m.issuetypeField
}
// SetIssuetype sets the issuetype of this polymorphic type
func (m *jiraEventConfig) SetIssuetype(val string) {
m.issuetypeField = val
}
// Project gets the project of this polymorphic type
func (m *jiraEventConfig) Project() string {
return m.projectField
}
// SetProject sets the project of this polymorphic type
func (m *jiraEventConfig) SetProject(val string) {
m.projectField = val
}
// Stage gets the stage of this polymorphic type
func (m *jiraEventConfig) Stage() string {
return m.stageField
}
// SetStage sets the stage of this polymorphic type
func (m *jiraEventConfig) SetStage(val string) {
m.stageField = val
}
// Summary gets the summary of this polymorphic type
func (m *jiraEventConfig) Summary() string {
return m.summaryField
}
// SetSummary sets the summary of this polymorphic type
func (m *jiraEventConfig) SetSummary(val string) {
m.summaryField = val
}
// Task gets the task of this polymorphic type
func (m *jiraEventConfig) Task() string {
return m.taskField
}
// SetTask sets the task of this polymorphic type
func (m *jiraEventConfig) SetTask(val string) {
m.taskField = val
}
// UnmarshalJiraEventConfigSlice unmarshals polymorphic slices of JiraEventConfig
func UnmarshalJiraEventConfigSlice(reader io.Reader, consumer runtime.Consumer) ([]JiraEventConfig, error) {
var elements []json.RawMessage
if err := consumer.Consume(reader, &elements); err != nil {
return nil, err
}
var result []JiraEventConfig
for _, element := range elements {
obj, err := unmarshalJiraEventConfig(element, consumer)
if err != nil {
return nil, err
}
result = append(result, obj)
}
return result, nil
}
// UnmarshalJiraEventConfig unmarshals polymorphic JiraEventConfig
func UnmarshalJiraEventConfig(reader io.Reader, consumer runtime.Consumer) (JiraEventConfig, error) {
// we need to read this twice, so first into a buffer
data, err := io.ReadAll(reader)
if err != nil {
return nil, err
}
return unmarshalJiraEventConfig(data, consumer)
}
func unmarshalJiraEventConfig(data []byte, consumer runtime.Consumer) (JiraEventConfig, error) {
buf := bytes.NewBuffer(data)
buf2 := bytes.NewBuffer(data)
// the first time this is read is to fetch the value of the Represents a Jira Event configuration. property.
var getType struct {
RepresentsaJiraEventConfiguration string `json:"Represents a Jira Event configuration."`
}
if err := consumer.Consume(buf, &getType); err != nil {
return nil, err
}
if err := validate.RequiredString("Represents a Jira Event configuration.", "body", getType.RepresentsaJiraEventConfiguration); err != nil {
return nil, err
}
// The value of Represents a Jira Event configuration. is used to determine which type to create and unmarshal the data into
switch getType.RepresentsaJiraEventConfiguration {
case "JiraEventConfig":
var result jiraEventConfig
if err := consumer.Consume(buf2, &result); err != nil {
return nil, err
}
return &result, nil
}
return nil, errors.New(422, "invalid Represents a Jira Event configuration. value: %q", getType.RepresentsaJiraEventConfiguration)
}
// Validate validates this jira event config
func (m *jiraEventConfig) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateEvent(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var jiraEventConfigTypeEventPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["SUCCESS","FAILURE","WAITING","CANCELED","STARTED"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
jiraEventConfigTypeEventPropEnum = append(jiraEventConfigTypeEventPropEnum, v)
}
}
const (
// JiraEventConfigEventSUCCESS captures enum value "SUCCESS"
JiraEventConfigEventSUCCESS string = "SUCCESS"
// JiraEventConfigEventFAILURE captures enum value "FAILURE"
JiraEventConfigEventFAILURE string = "FAILURE"
// JiraEventConfigEventWAITING captures enum value "WAITING"
JiraEventConfigEventWAITING string = "WAITING"
// JiraEventConfigEventCANCELED captures enum value "CANCELED"
JiraEventConfigEventCANCELED string = "CANCELED"
// JiraEventConfigEventSTARTED captures enum value "STARTED"
JiraEventConfigEventSTARTED string = "STARTED"
)
// prop value enum
func (m *jiraEventConfig) validateEventEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, jiraEventConfigTypeEventPropEnum, true); err != nil {
return err
}
return nil
}
func (m *jiraEventConfig) validateEvent(formats strfmt.Registry) error {
if swag.IsZero(m.Event()) { // not required
return nil
}
// value enum
if err := m.validateEventEnum("event", "body", m.Event()); err != nil {
return err
}
return nil
}
// ContextValidate validates this jira event config based on context it is used
func (m *jiraEventConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}