-
Notifications
You must be signed in to change notification settings - Fork 4
/
issue_trigger.go
326 lines (285 loc) · 13.6 KB
/
issue_trigger.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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
// This file was auto-generated by Fern from our API Definition.
package api
import (
json "encoding/json"
fmt "fmt"
time "time"
core "github.com/hookdeck/hookdeck-go-sdk/core"
)
type IssueTriggerCreateRequest struct {
Type IssueType `json:"type" url:"-"`
// Configuration object for the specific issue type selected
Configs *core.Optional[IssueTriggerCreateRequestConfigs] `json:"configs,omitempty" url:"-"`
Channels *core.Optional[IssueTriggerChannels] `json:"channels,omitempty" url:"-"`
// Optional unique name to use as reference when using the API
Name *core.Optional[string] `json:"name,omitempty" url:"-"`
}
type IssueTriggerListRequest struct {
Name *string `json:"-" url:"name,omitempty"`
Type *IssueType `json:"-" url:"type,omitempty"`
DisabledAt *time.Time `json:"-" url:"disabled_at,omitempty"`
OrderBy *IssueTriggerListRequestOrderBy `json:"-" url:"order_by,omitempty"`
Dir *IssueTriggerListRequestDir `json:"-" url:"dir,omitempty"`
Limit *int `json:"-" url:"limit,omitempty"`
Next *string `json:"-" url:"next,omitempty"`
Prev *string `json:"-" url:"prev,omitempty"`
}
// Configuration object for the specific issue type selected
type IssueTriggerCreateRequestConfigs struct {
IssueTriggerDeliveryConfigs *IssueTriggerDeliveryConfigs
IssueTriggerTransformationConfigs *IssueTriggerTransformationConfigs
IssueTriggerBackpressureConfigs *IssueTriggerBackpressureConfigs
}
func NewIssueTriggerCreateRequestConfigsFromIssueTriggerDeliveryConfigs(value *IssueTriggerDeliveryConfigs) *IssueTriggerCreateRequestConfigs {
return &IssueTriggerCreateRequestConfigs{IssueTriggerDeliveryConfigs: value}
}
func NewIssueTriggerCreateRequestConfigsFromIssueTriggerTransformationConfigs(value *IssueTriggerTransformationConfigs) *IssueTriggerCreateRequestConfigs {
return &IssueTriggerCreateRequestConfigs{IssueTriggerTransformationConfigs: value}
}
func NewIssueTriggerCreateRequestConfigsFromIssueTriggerBackpressureConfigs(value *IssueTriggerBackpressureConfigs) *IssueTriggerCreateRequestConfigs {
return &IssueTriggerCreateRequestConfigs{IssueTriggerBackpressureConfigs: value}
}
func (i *IssueTriggerCreateRequestConfigs) UnmarshalJSON(data []byte) error {
valueIssueTriggerDeliveryConfigs := new(IssueTriggerDeliveryConfigs)
if err := json.Unmarshal(data, &valueIssueTriggerDeliveryConfigs); err == nil {
i.IssueTriggerDeliveryConfigs = valueIssueTriggerDeliveryConfigs
return nil
}
valueIssueTriggerTransformationConfigs := new(IssueTriggerTransformationConfigs)
if err := json.Unmarshal(data, &valueIssueTriggerTransformationConfigs); err == nil {
i.IssueTriggerTransformationConfigs = valueIssueTriggerTransformationConfigs
return nil
}
valueIssueTriggerBackpressureConfigs := new(IssueTriggerBackpressureConfigs)
if err := json.Unmarshal(data, &valueIssueTriggerBackpressureConfigs); err == nil {
i.IssueTriggerBackpressureConfigs = valueIssueTriggerBackpressureConfigs
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, i)
}
func (i IssueTriggerCreateRequestConfigs) MarshalJSON() ([]byte, error) {
if i.IssueTriggerDeliveryConfigs != nil {
return json.Marshal(i.IssueTriggerDeliveryConfigs)
}
if i.IssueTriggerTransformationConfigs != nil {
return json.Marshal(i.IssueTriggerTransformationConfigs)
}
if i.IssueTriggerBackpressureConfigs != nil {
return json.Marshal(i.IssueTriggerBackpressureConfigs)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", i)
}
type IssueTriggerCreateRequestConfigsVisitor interface {
VisitIssueTriggerDeliveryConfigs(*IssueTriggerDeliveryConfigs) error
VisitIssueTriggerTransformationConfigs(*IssueTriggerTransformationConfigs) error
VisitIssueTriggerBackpressureConfigs(*IssueTriggerBackpressureConfigs) error
}
func (i *IssueTriggerCreateRequestConfigs) Accept(visitor IssueTriggerCreateRequestConfigsVisitor) error {
if i.IssueTriggerDeliveryConfigs != nil {
return visitor.VisitIssueTriggerDeliveryConfigs(i.IssueTriggerDeliveryConfigs)
}
if i.IssueTriggerTransformationConfigs != nil {
return visitor.VisitIssueTriggerTransformationConfigs(i.IssueTriggerTransformationConfigs)
}
if i.IssueTriggerBackpressureConfigs != nil {
return visitor.VisitIssueTriggerBackpressureConfigs(i.IssueTriggerBackpressureConfigs)
}
return fmt.Errorf("type %T does not include a non-empty union type", i)
}
type IssueTriggerListRequestDir string
const (
IssueTriggerListRequestDirAsc IssueTriggerListRequestDir = "asc"
IssueTriggerListRequestDirDesc IssueTriggerListRequestDir = "desc"
)
func NewIssueTriggerListRequestDirFromString(s string) (IssueTriggerListRequestDir, error) {
switch s {
case "asc":
return IssueTriggerListRequestDirAsc, nil
case "desc":
return IssueTriggerListRequestDirDesc, nil
}
var t IssueTriggerListRequestDir
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (i IssueTriggerListRequestDir) Ptr() *IssueTriggerListRequestDir {
return &i
}
type IssueTriggerListRequestOrderBy string
const (
IssueTriggerListRequestOrderByCreatedAt IssueTriggerListRequestOrderBy = "created_at"
IssueTriggerListRequestOrderByType IssueTriggerListRequestOrderBy = "type"
)
func NewIssueTriggerListRequestOrderByFromString(s string) (IssueTriggerListRequestOrderBy, error) {
switch s {
case "created_at":
return IssueTriggerListRequestOrderByCreatedAt, nil
case "type":
return IssueTriggerListRequestOrderByType, nil
}
var t IssueTriggerListRequestOrderBy
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (i IssueTriggerListRequestOrderBy) Ptr() *IssueTriggerListRequestOrderBy {
return &i
}
// Configuration object for the specific issue type selected
type IssueTriggerUpdateRequestConfigs struct {
IssueTriggerDeliveryConfigs *IssueTriggerDeliveryConfigs
IssueTriggerTransformationConfigs *IssueTriggerTransformationConfigs
IssueTriggerBackpressureConfigs *IssueTriggerBackpressureConfigs
}
func NewIssueTriggerUpdateRequestConfigsFromIssueTriggerDeliveryConfigs(value *IssueTriggerDeliveryConfigs) *IssueTriggerUpdateRequestConfigs {
return &IssueTriggerUpdateRequestConfigs{IssueTriggerDeliveryConfigs: value}
}
func NewIssueTriggerUpdateRequestConfigsFromIssueTriggerTransformationConfigs(value *IssueTriggerTransformationConfigs) *IssueTriggerUpdateRequestConfigs {
return &IssueTriggerUpdateRequestConfigs{IssueTriggerTransformationConfigs: value}
}
func NewIssueTriggerUpdateRequestConfigsFromIssueTriggerBackpressureConfigs(value *IssueTriggerBackpressureConfigs) *IssueTriggerUpdateRequestConfigs {
return &IssueTriggerUpdateRequestConfigs{IssueTriggerBackpressureConfigs: value}
}
func (i *IssueTriggerUpdateRequestConfigs) UnmarshalJSON(data []byte) error {
valueIssueTriggerDeliveryConfigs := new(IssueTriggerDeliveryConfigs)
if err := json.Unmarshal(data, &valueIssueTriggerDeliveryConfigs); err == nil {
i.IssueTriggerDeliveryConfigs = valueIssueTriggerDeliveryConfigs
return nil
}
valueIssueTriggerTransformationConfigs := new(IssueTriggerTransformationConfigs)
if err := json.Unmarshal(data, &valueIssueTriggerTransformationConfigs); err == nil {
i.IssueTriggerTransformationConfigs = valueIssueTriggerTransformationConfigs
return nil
}
valueIssueTriggerBackpressureConfigs := new(IssueTriggerBackpressureConfigs)
if err := json.Unmarshal(data, &valueIssueTriggerBackpressureConfigs); err == nil {
i.IssueTriggerBackpressureConfigs = valueIssueTriggerBackpressureConfigs
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, i)
}
func (i IssueTriggerUpdateRequestConfigs) MarshalJSON() ([]byte, error) {
if i.IssueTriggerDeliveryConfigs != nil {
return json.Marshal(i.IssueTriggerDeliveryConfigs)
}
if i.IssueTriggerTransformationConfigs != nil {
return json.Marshal(i.IssueTriggerTransformationConfigs)
}
if i.IssueTriggerBackpressureConfigs != nil {
return json.Marshal(i.IssueTriggerBackpressureConfigs)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", i)
}
type IssueTriggerUpdateRequestConfigsVisitor interface {
VisitIssueTriggerDeliveryConfigs(*IssueTriggerDeliveryConfigs) error
VisitIssueTriggerTransformationConfigs(*IssueTriggerTransformationConfigs) error
VisitIssueTriggerBackpressureConfigs(*IssueTriggerBackpressureConfigs) error
}
func (i *IssueTriggerUpdateRequestConfigs) Accept(visitor IssueTriggerUpdateRequestConfigsVisitor) error {
if i.IssueTriggerDeliveryConfigs != nil {
return visitor.VisitIssueTriggerDeliveryConfigs(i.IssueTriggerDeliveryConfigs)
}
if i.IssueTriggerTransformationConfigs != nil {
return visitor.VisitIssueTriggerTransformationConfigs(i.IssueTriggerTransformationConfigs)
}
if i.IssueTriggerBackpressureConfigs != nil {
return visitor.VisitIssueTriggerBackpressureConfigs(i.IssueTriggerBackpressureConfigs)
}
return fmt.Errorf("type %T does not include a non-empty union type", i)
}
// Configuration object for the specific issue type selected
type IssueTriggerUpsertRequestConfigs struct {
IssueTriggerDeliveryConfigs *IssueTriggerDeliveryConfigs
IssueTriggerTransformationConfigs *IssueTriggerTransformationConfigs
IssueTriggerBackpressureConfigs *IssueTriggerBackpressureConfigs
}
func NewIssueTriggerUpsertRequestConfigsFromIssueTriggerDeliveryConfigs(value *IssueTriggerDeliveryConfigs) *IssueTriggerUpsertRequestConfigs {
return &IssueTriggerUpsertRequestConfigs{IssueTriggerDeliveryConfigs: value}
}
func NewIssueTriggerUpsertRequestConfigsFromIssueTriggerTransformationConfigs(value *IssueTriggerTransformationConfigs) *IssueTriggerUpsertRequestConfigs {
return &IssueTriggerUpsertRequestConfigs{IssueTriggerTransformationConfigs: value}
}
func NewIssueTriggerUpsertRequestConfigsFromIssueTriggerBackpressureConfigs(value *IssueTriggerBackpressureConfigs) *IssueTriggerUpsertRequestConfigs {
return &IssueTriggerUpsertRequestConfigs{IssueTriggerBackpressureConfigs: value}
}
func (i *IssueTriggerUpsertRequestConfigs) UnmarshalJSON(data []byte) error {
valueIssueTriggerDeliveryConfigs := new(IssueTriggerDeliveryConfigs)
if err := json.Unmarshal(data, &valueIssueTriggerDeliveryConfigs); err == nil {
i.IssueTriggerDeliveryConfigs = valueIssueTriggerDeliveryConfigs
return nil
}
valueIssueTriggerTransformationConfigs := new(IssueTriggerTransformationConfigs)
if err := json.Unmarshal(data, &valueIssueTriggerTransformationConfigs); err == nil {
i.IssueTriggerTransformationConfigs = valueIssueTriggerTransformationConfigs
return nil
}
valueIssueTriggerBackpressureConfigs := new(IssueTriggerBackpressureConfigs)
if err := json.Unmarshal(data, &valueIssueTriggerBackpressureConfigs); err == nil {
i.IssueTriggerBackpressureConfigs = valueIssueTriggerBackpressureConfigs
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, i)
}
func (i IssueTriggerUpsertRequestConfigs) MarshalJSON() ([]byte, error) {
if i.IssueTriggerDeliveryConfigs != nil {
return json.Marshal(i.IssueTriggerDeliveryConfigs)
}
if i.IssueTriggerTransformationConfigs != nil {
return json.Marshal(i.IssueTriggerTransformationConfigs)
}
if i.IssueTriggerBackpressureConfigs != nil {
return json.Marshal(i.IssueTriggerBackpressureConfigs)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", i)
}
type IssueTriggerUpsertRequestConfigsVisitor interface {
VisitIssueTriggerDeliveryConfigs(*IssueTriggerDeliveryConfigs) error
VisitIssueTriggerTransformationConfigs(*IssueTriggerTransformationConfigs) error
VisitIssueTriggerBackpressureConfigs(*IssueTriggerBackpressureConfigs) error
}
func (i *IssueTriggerUpsertRequestConfigs) Accept(visitor IssueTriggerUpsertRequestConfigsVisitor) error {
if i.IssueTriggerDeliveryConfigs != nil {
return visitor.VisitIssueTriggerDeliveryConfigs(i.IssueTriggerDeliveryConfigs)
}
if i.IssueTriggerTransformationConfigs != nil {
return visitor.VisitIssueTriggerTransformationConfigs(i.IssueTriggerTransformationConfigs)
}
if i.IssueTriggerBackpressureConfigs != nil {
return visitor.VisitIssueTriggerBackpressureConfigs(i.IssueTriggerBackpressureConfigs)
}
return fmt.Errorf("type %T does not include a non-empty union type", i)
}
type IssueTriggerUpdateRequest struct {
// Configuration object for the specific issue type selected
Configs *core.Optional[IssueTriggerUpdateRequestConfigs] `json:"configs,omitempty" url:"-"`
Channels *core.Optional[IssueTriggerChannels] `json:"channels,omitempty" url:"-"`
// Date when the issue trigger was disabled
DisabledAt *core.Optional[time.Time] `json:"disabled_at,omitempty" url:"-"`
// Optional unique name to use as reference when using the API
Name *core.Optional[string] `json:"name,omitempty" url:"-"`
}
func (i *IssueTriggerUpdateRequest) UnmarshalJSON(data []byte) error {
type unmarshaler IssueTriggerUpdateRequest
var body unmarshaler
if err := json.Unmarshal(data, &body); err != nil {
return err
}
*i = IssueTriggerUpdateRequest(body)
return nil
}
func (i *IssueTriggerUpdateRequest) MarshalJSON() ([]byte, error) {
type embed IssueTriggerUpdateRequest
var marshaler = struct {
embed
DisabledAt *core.DateTime `json:"disabled_at,omitempty"`
}{
embed: embed(*i),
DisabledAt: NewDateTimeFromOptional(i.DisabledAt),
}
return json.Marshal(marshaler)
}
type IssueTriggerUpsertRequest struct {
Type IssueType `json:"type" url:"-"`
// Configuration object for the specific issue type selected
Configs *core.Optional[IssueTriggerUpsertRequestConfigs] `json:"configs,omitempty" url:"-"`
Channels *core.Optional[IssueTriggerChannels] `json:"channels,omitempty" url:"-"`
// Required unique name to use as reference when using the API
Name string `json:"name" url:"-"`
}