-
Notifications
You must be signed in to change notification settings - Fork 10
/
user_operation.go
692 lines (536 loc) · 17.8 KB
/
user_operation.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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
// 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/validate"
)
// UserOperation UserOperation
//
// UserOperation details.
//
// swagger:discriminator UserOperation UserOperation details.
type UserOperation interface {
runtime.Validatable
runtime.ContextValidatable
// This field is provided for backward compatibility. Contains the same value as the 'createdAt' field as a UNIX timestamp in microseconds
// Example: 1568625938000000
CreateTimeInMicros() int64
SetCreateTimeInMicros(int64)
// The time in micros when it would expire.
// Example: 1569216876209000
ExpiresOnInMicros() int64
SetExpiresOnInMicros(int64)
// Partial URL that provides details of the resource.
// Example: /codestream/api/\u003cprefix\u003e/8365ef3b-8bf3-48aa-bd5d-7113fcff827c
Link() string
SetLink(string)
// Contains project id of the entity
// Example: abcd-abcd-abcd
ProjectID() string
SetProjectID(string)
// The time in micros when the request was made.
// Example: 1568957676209000
RequestedOnInMicros() int64
SetRequestedOnInMicros(int64)
// This field is provided for backward compatibility. Contains the same value as the 'updatedAt' field as a UNIX timestamp in microseconds
// Example: 1568625938000000
UpdateTimeInMicros() int64
SetUpdateTimeInMicros(int64)
// The list of approver emails who can approve it.
// Example: exampleUser@vmware.com
Approvers() []string
SetApprovers([]string)
// The flag to determine whether to cancel previous pending user op of the pipeline.
// Example: true
CancelPreviousPendingUserOp() bool
SetCancelPreviousPendingUserOp(bool)
// Date when the entity was created. The date is in ISO 8601 with time zone
// Example: 2019-09-16 09:25:38.065065+00
CreatedAt() string
SetCreatedAt(string)
// The user that created this entity
// Example: exampleuser
CreatedBy() string
SetCreatedBy(string)
// A human-friendly description.
// Required: true
Description() *string
SetDescription(*string)
// The email Endpoint to be used if the sendemail is set to true.
// Example: My-email-endpoint
Endpoint() string
SetEndpoint(string)
// The Execution id of the Pipeline Execution consisting of this task.
// Example: 19e2d2c3-41b6-4bc0-9f27-b3f935d25366
ExecutionID() string
SetExecutionID(string)
// The index of the Pipeline Execution in which the entity is present.
// Example: 8
ExecutionIndex() int64
SetExecutionIndex(int64)
// The Execution link of the Pipeline Execution consisting of this task.
// Example: /codestream/api/executions/c1c08fc4-0bef-46fa-b5d2-c8aa10d18f6e
ExecutionLink() string
SetExecutionLink(string)
// The time after which this entity would expire based on expirationUnit.
// Example: 3
Expiration() int32
SetExpiration(int32)
// The time in days after which this entity would expire.
// Example: 3
ExpirationInDays() int32
SetExpirationInDays(int32)
// The time unit after which this entity would expire.
// Example: DAYS
ExpirationUnit() string
SetExpirationUnit(string)
// The id of this resource.
// Example: 8365ef3b-8bf3-48aa-bd5d-7113fcff827c
ID() string
SetID(string)
// The index of the entity.
// Example: 45b4d8
Index() string
SetIndex(string)
// A human-friendly name used as an identifier in APIs that support this option
// Example: My-Name
// Required: true
Name() *string
SetName(*string)
// The id of the Pipeline consisting of this task.
// Example: 6f6b006b-7fec-4684-9200-21a4a782c82b
PipelineID() string
SetPipelineID(string)
// The name of the Pipeline this task is configured in.
// Example: My-Pipeline
PipelineName() string
SetPipelineName(string)
// The project this entity belongs to.
// Example: My-Project
Project() string
SetProject(string)
// The user who requested this.
// Example: fritz
RequestedBy() string
SetRequestedBy(string)
// The user who responded to this approval.
// Example: fritz
RespondedBy() string
SetRespondedBy(string)
// The response message which the responder would like to give.
// Example: Approved on Monday
ResponseMessage() string
SetResponseMessage(string)
// The flag to determine if an email has to be sent.
// Example: true
Sendemail() bool
SetSendemail(bool)
// The status of this entity.
// Example: Approved
Status() string
SetStatus(string)
// The summary of this entity.
// Example: To be approved only by admin
Summary() string
SetSummary(string)
// Date when the entity was last updated. The date is in ISO 8601 with time zone.
// Example: 2019-09-16 09:25:38.065065+00
UpdatedAt() string
SetUpdatedAt(string)
// The user that last updated this entity
// Example: exampleuser
UpdatedBy() string
SetUpdatedBy(string)
// Version of the resource.
// Example: v1
Version() string
SetVersion(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 userOperation struct {
createTimeInMicrosField int64
expiresOnInMicrosField int64
linkField string
projectIdField string
requestedOnInMicrosField int64
updateTimeInMicrosField int64
approversField []string
cancelPreviousPendingUserOpField bool
createdAtField string
createdByField string
descriptionField *string
endpointField string
executionIdField string
executionIndexField int64
executionLinkField string
expirationField int32
expirationInDaysField int32
expirationUnitField string
idField string
indexField string
nameField *string
pipelineIdField string
pipelineNameField string
projectField string
requestedByField string
respondedByField string
responseMessageField string
sendemailField bool
statusField string
summaryField string
updatedAtField string
updatedByField string
versionField string
}
// CreateTimeInMicros gets the create time in micros of this polymorphic type
func (m *userOperation) CreateTimeInMicros() int64 {
return m.createTimeInMicrosField
}
// SetCreateTimeInMicros sets the create time in micros of this polymorphic type
func (m *userOperation) SetCreateTimeInMicros(val int64) {
m.createTimeInMicrosField = val
}
// ExpiresOnInMicros gets the expires on in micros of this polymorphic type
func (m *userOperation) ExpiresOnInMicros() int64 {
return m.expiresOnInMicrosField
}
// SetExpiresOnInMicros sets the expires on in micros of this polymorphic type
func (m *userOperation) SetExpiresOnInMicros(val int64) {
m.expiresOnInMicrosField = val
}
// Link gets the link of this polymorphic type
func (m *userOperation) Link() string {
return m.linkField
}
// SetLink sets the link of this polymorphic type
func (m *userOperation) SetLink(val string) {
m.linkField = val
}
// ProjectID gets the project Id of this polymorphic type
func (m *userOperation) ProjectID() string {
return m.projectIdField
}
// SetProjectID sets the project Id of this polymorphic type
func (m *userOperation) SetProjectID(val string) {
m.projectIdField = val
}
// RequestedOnInMicros gets the requested on in micros of this polymorphic type
func (m *userOperation) RequestedOnInMicros() int64 {
return m.requestedOnInMicrosField
}
// SetRequestedOnInMicros sets the requested on in micros of this polymorphic type
func (m *userOperation) SetRequestedOnInMicros(val int64) {
m.requestedOnInMicrosField = val
}
// UpdateTimeInMicros gets the update time in micros of this polymorphic type
func (m *userOperation) UpdateTimeInMicros() int64 {
return m.updateTimeInMicrosField
}
// SetUpdateTimeInMicros sets the update time in micros of this polymorphic type
func (m *userOperation) SetUpdateTimeInMicros(val int64) {
m.updateTimeInMicrosField = val
}
// Approvers gets the approvers of this polymorphic type
func (m *userOperation) Approvers() []string {
return m.approversField
}
// SetApprovers sets the approvers of this polymorphic type
func (m *userOperation) SetApprovers(val []string) {
m.approversField = val
}
// CancelPreviousPendingUserOp gets the cancel previous pending user op of this polymorphic type
func (m *userOperation) CancelPreviousPendingUserOp() bool {
return m.cancelPreviousPendingUserOpField
}
// SetCancelPreviousPendingUserOp sets the cancel previous pending user op of this polymorphic type
func (m *userOperation) SetCancelPreviousPendingUserOp(val bool) {
m.cancelPreviousPendingUserOpField = val
}
// CreatedAt gets the created at of this polymorphic type
func (m *userOperation) CreatedAt() string {
return m.createdAtField
}
// SetCreatedAt sets the created at of this polymorphic type
func (m *userOperation) SetCreatedAt(val string) {
m.createdAtField = val
}
// CreatedBy gets the created by of this polymorphic type
func (m *userOperation) CreatedBy() string {
return m.createdByField
}
// SetCreatedBy sets the created by of this polymorphic type
func (m *userOperation) SetCreatedBy(val string) {
m.createdByField = val
}
// Description gets the description of this polymorphic type
func (m *userOperation) Description() *string {
return m.descriptionField
}
// SetDescription sets the description of this polymorphic type
func (m *userOperation) SetDescription(val *string) {
m.descriptionField = val
}
// Endpoint gets the endpoint of this polymorphic type
func (m *userOperation) Endpoint() string {
return m.endpointField
}
// SetEndpoint sets the endpoint of this polymorphic type
func (m *userOperation) SetEndpoint(val string) {
m.endpointField = val
}
// ExecutionID gets the execution Id of this polymorphic type
func (m *userOperation) ExecutionID() string {
return m.executionIdField
}
// SetExecutionID sets the execution Id of this polymorphic type
func (m *userOperation) SetExecutionID(val string) {
m.executionIdField = val
}
// ExecutionIndex gets the execution index of this polymorphic type
func (m *userOperation) ExecutionIndex() int64 {
return m.executionIndexField
}
// SetExecutionIndex sets the execution index of this polymorphic type
func (m *userOperation) SetExecutionIndex(val int64) {
m.executionIndexField = val
}
// ExecutionLink gets the execution link of this polymorphic type
func (m *userOperation) ExecutionLink() string {
return m.executionLinkField
}
// SetExecutionLink sets the execution link of this polymorphic type
func (m *userOperation) SetExecutionLink(val string) {
m.executionLinkField = val
}
// Expiration gets the expiration of this polymorphic type
func (m *userOperation) Expiration() int32 {
return m.expirationField
}
// SetExpiration sets the expiration of this polymorphic type
func (m *userOperation) SetExpiration(val int32) {
m.expirationField = val
}
// ExpirationInDays gets the expiration in days of this polymorphic type
func (m *userOperation) ExpirationInDays() int32 {
return m.expirationInDaysField
}
// SetExpirationInDays sets the expiration in days of this polymorphic type
func (m *userOperation) SetExpirationInDays(val int32) {
m.expirationInDaysField = val
}
// ExpirationUnit gets the expiration unit of this polymorphic type
func (m *userOperation) ExpirationUnit() string {
return m.expirationUnitField
}
// SetExpirationUnit sets the expiration unit of this polymorphic type
func (m *userOperation) SetExpirationUnit(val string) {
m.expirationUnitField = val
}
// ID gets the id of this polymorphic type
func (m *userOperation) ID() string {
return m.idField
}
// SetID sets the id of this polymorphic type
func (m *userOperation) SetID(val string) {
m.idField = val
}
// Index gets the index of this polymorphic type
func (m *userOperation) Index() string {
return m.indexField
}
// SetIndex sets the index of this polymorphic type
func (m *userOperation) SetIndex(val string) {
m.indexField = val
}
// Name gets the name of this polymorphic type
func (m *userOperation) Name() *string {
return m.nameField
}
// SetName sets the name of this polymorphic type
func (m *userOperation) SetName(val *string) {
m.nameField = val
}
// PipelineID gets the pipeline Id of this polymorphic type
func (m *userOperation) PipelineID() string {
return m.pipelineIdField
}
// SetPipelineID sets the pipeline Id of this polymorphic type
func (m *userOperation) SetPipelineID(val string) {
m.pipelineIdField = val
}
// PipelineName gets the pipeline name of this polymorphic type
func (m *userOperation) PipelineName() string {
return m.pipelineNameField
}
// SetPipelineName sets the pipeline name of this polymorphic type
func (m *userOperation) SetPipelineName(val string) {
m.pipelineNameField = val
}
// Project gets the project of this polymorphic type
func (m *userOperation) Project() string {
return m.projectField
}
// SetProject sets the project of this polymorphic type
func (m *userOperation) SetProject(val string) {
m.projectField = val
}
// RequestedBy gets the requested by of this polymorphic type
func (m *userOperation) RequestedBy() string {
return m.requestedByField
}
// SetRequestedBy sets the requested by of this polymorphic type
func (m *userOperation) SetRequestedBy(val string) {
m.requestedByField = val
}
// RespondedBy gets the responded by of this polymorphic type
func (m *userOperation) RespondedBy() string {
return m.respondedByField
}
// SetRespondedBy sets the responded by of this polymorphic type
func (m *userOperation) SetRespondedBy(val string) {
m.respondedByField = val
}
// ResponseMessage gets the response message of this polymorphic type
func (m *userOperation) ResponseMessage() string {
return m.responseMessageField
}
// SetResponseMessage sets the response message of this polymorphic type
func (m *userOperation) SetResponseMessage(val string) {
m.responseMessageField = val
}
// Sendemail gets the sendemail of this polymorphic type
func (m *userOperation) Sendemail() bool {
return m.sendemailField
}
// SetSendemail sets the sendemail of this polymorphic type
func (m *userOperation) SetSendemail(val bool) {
m.sendemailField = val
}
// Status gets the status of this polymorphic type
func (m *userOperation) Status() string {
return m.statusField
}
// SetStatus sets the status of this polymorphic type
func (m *userOperation) SetStatus(val string) {
m.statusField = val
}
// Summary gets the summary of this polymorphic type
func (m *userOperation) Summary() string {
return m.summaryField
}
// SetSummary sets the summary of this polymorphic type
func (m *userOperation) SetSummary(val string) {
m.summaryField = val
}
// UpdatedAt gets the updated at of this polymorphic type
func (m *userOperation) UpdatedAt() string {
return m.updatedAtField
}
// SetUpdatedAt sets the updated at of this polymorphic type
func (m *userOperation) SetUpdatedAt(val string) {
m.updatedAtField = val
}
// UpdatedBy gets the updated by of this polymorphic type
func (m *userOperation) UpdatedBy() string {
return m.updatedByField
}
// SetUpdatedBy sets the updated by of this polymorphic type
func (m *userOperation) SetUpdatedBy(val string) {
m.updatedByField = val
}
// Version gets the version of this polymorphic type
func (m *userOperation) Version() string {
return m.versionField
}
// SetVersion sets the version of this polymorphic type
func (m *userOperation) SetVersion(val string) {
m.versionField = val
}
// UnmarshalUserOperationSlice unmarshals polymorphic slices of UserOperation
func UnmarshalUserOperationSlice(reader io.Reader, consumer runtime.Consumer) ([]UserOperation, error) {
var elements []json.RawMessage
if err := consumer.Consume(reader, &elements); err != nil {
return nil, err
}
var result []UserOperation
for _, element := range elements {
obj, err := unmarshalUserOperation(element, consumer)
if err != nil {
return nil, err
}
result = append(result, obj)
}
return result, nil
}
// UnmarshalUserOperation unmarshals polymorphic UserOperation
func UnmarshalUserOperation(reader io.Reader, consumer runtime.Consumer) (UserOperation, error) {
// we need to read this twice, so first into a buffer
data, err := io.ReadAll(reader)
if err != nil {
return nil, err
}
return unmarshalUserOperation(data, consumer)
}
func unmarshalUserOperation(data []byte, consumer runtime.Consumer) (UserOperation, error) {
buf := bytes.NewBuffer(data)
buf2 := bytes.NewBuffer(data)
// the first time this is read is to fetch the value of the UserOperation details. property.
var getType struct {
UserOperationDetails string `json:"UserOperation details."`
}
if err := consumer.Consume(buf, &getType); err != nil {
return nil, err
}
if err := validate.RequiredString("UserOperation details.", "body", getType.UserOperationDetails); err != nil {
return nil, err
}
// The value of UserOperation details. is used to determine which type to create and unmarshal the data into
switch getType.UserOperationDetails {
case "UserOperation":
var result userOperation
if err := consumer.Consume(buf2, &result); err != nil {
return nil, err
}
return &result, nil
}
return nil, errors.New(422, "invalid UserOperation details. value: %q", getType.UserOperationDetails)
}
// Validate validates this user operation
func (m *userOperation) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDescription(formats); err != nil {
res = append(res, err)
}
if err := m.validateName(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *userOperation) validateDescription(formats strfmt.Registry) error {
if err := validate.Required("description", "body", m.Description()); err != nil {
return err
}
return nil
}
func (m *userOperation) validateName(formats strfmt.Registry) error {
if err := validate.Required("name", "body", m.Name()); err != nil {
return err
}
return nil
}
// ContextValidate validates this user operation based on context it is used
func (m *userOperation) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}