-
Notifications
You must be signed in to change notification settings - Fork 1
/
condition.pb.fieldpath.go
1749 lines (1547 loc) · 64.6 KB
/
condition.pb.fieldpath.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
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by protoc-gen-goten-object
// File: edgelq/iam/proto/v1/condition.proto
// DO NOT EDIT!!!
package condition
import (
"encoding/json"
"fmt"
"reflect"
"strings"
"time"
"github.com/iancoleman/strcase"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoregistry"
gotenobject "github.com/cloudwan/goten-sdk/runtime/object"
)
// proto imports
import (
organization "github.com/cloudwan/edgelq-sdk/iam/resources/v1/organization"
project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project"
meta_service "github.com/cloudwan/goten-sdk/meta-service/resources/v1/service"
meta "github.com/cloudwan/goten-sdk/types/meta"
structpb "google.golang.org/protobuf/types/known/structpb"
)
// ensure the imports are used
var (
_ = new(json.Marshaler)
_ = new(fmt.Stringer)
_ = reflect.DeepEqual
_ = strings.Builder{}
_ = time.Second
_ = strcase.ToLowerCamel
_ = codes.NotFound
_ = status.Status{}
_ = protojson.UnmarshalOptions{}
_ = new(proto.Message)
_ = protoregistry.GlobalTypes
_ = new(gotenobject.FieldPath)
)
// make sure we're using proto imports
var (
_ = &organization.Organization{}
_ = &project.Project{}
_ = &structpb.Struct{}
_ = &meta_service.Service{}
_ = &meta.Meta{}
)
// FieldPath provides implementation to handle
// https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto
type Condition_FieldPath interface {
gotenobject.FieldPath
Selector() Condition_FieldPathSelector
Get(source *Condition) []interface{}
GetSingle(source *Condition) (interface{}, bool)
ClearValue(item *Condition)
// Those methods build corresponding Condition_FieldPathValue
// (or array of values) and holds passed value. Panics if injected type is incorrect.
WithIValue(value interface{}) Condition_FieldPathValue
WithIArrayOfValues(values interface{}) Condition_FieldPathArrayOfValues
WithIArrayItemValue(value interface{}) Condition_FieldPathArrayItemValue
}
type Condition_FieldPathSelector int32
const (
Condition_FieldPathSelectorName Condition_FieldPathSelector = 0
Condition_FieldPathSelectorMetadata Condition_FieldPathSelector = 1
Condition_FieldPathSelectorDisplayName Condition_FieldPathSelector = 2
Condition_FieldPathSelectorDescription Condition_FieldPathSelector = 3
Condition_FieldPathSelectorExpression Condition_FieldPathSelector = 4
Condition_FieldPathSelectorParameterDeclarations Condition_FieldPathSelector = 5
)
func (s Condition_FieldPathSelector) String() string {
switch s {
case Condition_FieldPathSelectorName:
return "name"
case Condition_FieldPathSelectorMetadata:
return "metadata"
case Condition_FieldPathSelectorDisplayName:
return "display_name"
case Condition_FieldPathSelectorDescription:
return "description"
case Condition_FieldPathSelectorExpression:
return "expression"
case Condition_FieldPathSelectorParameterDeclarations:
return "parameter_declarations"
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", s))
}
}
func BuildCondition_FieldPath(fp gotenobject.RawFieldPath) (Condition_FieldPath, error) {
if len(fp) == 0 {
return nil, status.Error(codes.InvalidArgument, "empty field path for object Condition")
}
if len(fp) == 1 {
switch fp[0] {
case "name":
return &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorName}, nil
case "metadata":
return &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorMetadata}, nil
case "display_name", "displayName", "display-name":
return &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorDisplayName}, nil
case "description":
return &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorDescription}, nil
case "expression":
return &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorExpression}, nil
case "parameter_declarations", "parameterDeclarations", "parameter-declarations":
return &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorParameterDeclarations}, nil
}
} else {
switch fp[0] {
case "metadata":
if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil {
return nil, err
} else {
return &Condition_FieldSubPath{selector: Condition_FieldPathSelectorMetadata, subPath: subpath}, nil
}
case "parameter_declarations", "parameterDeclarations", "parameter-declarations":
if subpath, err := BuildConditionParameterDeclaration_FieldPath(fp[1:]); err != nil {
return nil, err
} else {
return &Condition_FieldSubPath{selector: Condition_FieldPathSelectorParameterDeclarations, subPath: subpath}, nil
}
}
}
return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Condition", fp)
}
func ParseCondition_FieldPath(rawField string) (Condition_FieldPath, error) {
fp, err := gotenobject.ParseRawFieldPath(rawField)
if err != nil {
return nil, err
}
return BuildCondition_FieldPath(fp)
}
func MustParseCondition_FieldPath(rawField string) Condition_FieldPath {
fp, err := ParseCondition_FieldPath(rawField)
if err != nil {
panic(err)
}
return fp
}
type Condition_FieldTerminalPath struct {
selector Condition_FieldPathSelector
}
var _ Condition_FieldPath = (*Condition_FieldTerminalPath)(nil)
func (fp *Condition_FieldTerminalPath) Selector() Condition_FieldPathSelector {
return fp.selector
}
// String returns path representation in proto convention
func (fp *Condition_FieldTerminalPath) String() string {
return fp.selector.String()
}
// JSONString returns path representation is JSON convention
func (fp *Condition_FieldTerminalPath) JSONString() string {
return strcase.ToLowerCamel(fp.String())
}
// Get returns all values pointed by specific field from source Condition
func (fp *Condition_FieldTerminalPath) Get(source *Condition) (values []interface{}) {
if source != nil {
switch fp.selector {
case Condition_FieldPathSelectorName:
if source.Name != nil {
values = append(values, source.Name)
}
case Condition_FieldPathSelectorMetadata:
if source.Metadata != nil {
values = append(values, source.Metadata)
}
case Condition_FieldPathSelectorDisplayName:
values = append(values, source.DisplayName)
case Condition_FieldPathSelectorDescription:
values = append(values, source.Description)
case Condition_FieldPathSelectorExpression:
values = append(values, source.Expression)
case Condition_FieldPathSelectorParameterDeclarations:
for _, value := range source.GetParameterDeclarations() {
values = append(values, value)
}
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fp.selector))
}
}
return
}
func (fp *Condition_FieldTerminalPath) GetRaw(source proto.Message) []interface{} {
return fp.Get(source.(*Condition))
}
// GetSingle returns value pointed by specific field of from source Condition
func (fp *Condition_FieldTerminalPath) GetSingle(source *Condition) (interface{}, bool) {
switch fp.selector {
case Condition_FieldPathSelectorName:
res := source.GetName()
return res, res != nil
case Condition_FieldPathSelectorMetadata:
res := source.GetMetadata()
return res, res != nil
case Condition_FieldPathSelectorDisplayName:
return source.GetDisplayName(), source != nil
case Condition_FieldPathSelectorDescription:
return source.GetDescription(), source != nil
case Condition_FieldPathSelectorExpression:
return source.GetExpression(), source != nil
case Condition_FieldPathSelectorParameterDeclarations:
res := source.GetParameterDeclarations()
return res, res != nil
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fp.selector))
}
}
func (fp *Condition_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) {
return fp.GetSingle(source.(*Condition))
}
// GetDefault returns a default value of the field type
func (fp *Condition_FieldTerminalPath) GetDefault() interface{} {
switch fp.selector {
case Condition_FieldPathSelectorName:
return (*Name)(nil)
case Condition_FieldPathSelectorMetadata:
return (*meta.Meta)(nil)
case Condition_FieldPathSelectorDisplayName:
return ""
case Condition_FieldPathSelectorDescription:
return ""
case Condition_FieldPathSelectorExpression:
return ""
case Condition_FieldPathSelectorParameterDeclarations:
return ([]*Condition_ParameterDeclaration)(nil)
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fp.selector))
}
}
func (fp *Condition_FieldTerminalPath) ClearValue(item *Condition) {
if item != nil {
switch fp.selector {
case Condition_FieldPathSelectorName:
item.Name = nil
case Condition_FieldPathSelectorMetadata:
item.Metadata = nil
case Condition_FieldPathSelectorDisplayName:
item.DisplayName = ""
case Condition_FieldPathSelectorDescription:
item.Description = ""
case Condition_FieldPathSelectorExpression:
item.Expression = ""
case Condition_FieldPathSelectorParameterDeclarations:
item.ParameterDeclarations = nil
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fp.selector))
}
}
}
func (fp *Condition_FieldTerminalPath) ClearValueRaw(item proto.Message) {
fp.ClearValue(item.(*Condition))
}
// IsLeaf - whether field path is holds simple value
func (fp *Condition_FieldTerminalPath) IsLeaf() bool {
return fp.selector == Condition_FieldPathSelectorName ||
fp.selector == Condition_FieldPathSelectorDisplayName ||
fp.selector == Condition_FieldPathSelectorDescription ||
fp.selector == Condition_FieldPathSelectorExpression
}
func (fp *Condition_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath {
return []gotenobject.FieldPath{fp}
}
func (fp *Condition_FieldTerminalPath) WithIValue(value interface{}) Condition_FieldPathValue {
switch fp.selector {
case Condition_FieldPathSelectorName:
return &Condition_FieldTerminalPathValue{Condition_FieldTerminalPath: *fp, value: value.(*Name)}
case Condition_FieldPathSelectorMetadata:
return &Condition_FieldTerminalPathValue{Condition_FieldTerminalPath: *fp, value: value.(*meta.Meta)}
case Condition_FieldPathSelectorDisplayName:
return &Condition_FieldTerminalPathValue{Condition_FieldTerminalPath: *fp, value: value.(string)}
case Condition_FieldPathSelectorDescription:
return &Condition_FieldTerminalPathValue{Condition_FieldTerminalPath: *fp, value: value.(string)}
case Condition_FieldPathSelectorExpression:
return &Condition_FieldTerminalPathValue{Condition_FieldTerminalPath: *fp, value: value.(string)}
case Condition_FieldPathSelectorParameterDeclarations:
return &Condition_FieldTerminalPathValue{Condition_FieldTerminalPath: *fp, value: value.([]*Condition_ParameterDeclaration)}
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fp.selector))
}
}
func (fp *Condition_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue {
return fp.WithIValue(value)
}
func (fp *Condition_FieldTerminalPath) WithIArrayOfValues(values interface{}) Condition_FieldPathArrayOfValues {
fpaov := &Condition_FieldTerminalPathArrayOfValues{Condition_FieldTerminalPath: *fp}
switch fp.selector {
case Condition_FieldPathSelectorName:
return &Condition_FieldTerminalPathArrayOfValues{Condition_FieldTerminalPath: *fp, values: values.([]*Name)}
case Condition_FieldPathSelectorMetadata:
return &Condition_FieldTerminalPathArrayOfValues{Condition_FieldTerminalPath: *fp, values: values.([]*meta.Meta)}
case Condition_FieldPathSelectorDisplayName:
return &Condition_FieldTerminalPathArrayOfValues{Condition_FieldTerminalPath: *fp, values: values.([]string)}
case Condition_FieldPathSelectorDescription:
return &Condition_FieldTerminalPathArrayOfValues{Condition_FieldTerminalPath: *fp, values: values.([]string)}
case Condition_FieldPathSelectorExpression:
return &Condition_FieldTerminalPathArrayOfValues{Condition_FieldTerminalPath: *fp, values: values.([]string)}
case Condition_FieldPathSelectorParameterDeclarations:
return &Condition_FieldTerminalPathArrayOfValues{Condition_FieldTerminalPath: *fp, values: values.([][]*Condition_ParameterDeclaration)}
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fp.selector))
}
return fpaov
}
func (fp *Condition_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues {
return fp.WithIArrayOfValues(values)
}
func (fp *Condition_FieldTerminalPath) WithIArrayItemValue(value interface{}) Condition_FieldPathArrayItemValue {
switch fp.selector {
case Condition_FieldPathSelectorParameterDeclarations:
return &Condition_FieldTerminalPathArrayItemValue{Condition_FieldTerminalPath: *fp, value: value.(*Condition_ParameterDeclaration)}
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fp.selector))
}
}
func (fp *Condition_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue {
return fp.WithIArrayItemValue(value)
}
type Condition_FieldSubPath struct {
selector Condition_FieldPathSelector
subPath gotenobject.FieldPath
}
var _ Condition_FieldPath = (*Condition_FieldSubPath)(nil)
func (fps *Condition_FieldSubPath) Selector() Condition_FieldPathSelector {
return fps.selector
}
func (fps *Condition_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) {
res, ok := fps.subPath.(meta.Meta_FieldPath)
return res, ok
}
func (fps *Condition_FieldSubPath) AsParameterDeclarationsSubPath() (ConditionParameterDeclaration_FieldPath, bool) {
res, ok := fps.subPath.(ConditionParameterDeclaration_FieldPath)
return res, ok
}
// String returns path representation in proto convention
func (fps *Condition_FieldSubPath) String() string {
return fps.selector.String() + "." + fps.subPath.String()
}
// JSONString returns path representation is JSON convention
func (fps *Condition_FieldSubPath) JSONString() string {
return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString()
}
// Get returns all values pointed by selected field from source Condition
func (fps *Condition_FieldSubPath) Get(source *Condition) (values []interface{}) {
switch fps.selector {
case Condition_FieldPathSelectorMetadata:
values = append(values, fps.subPath.GetRaw(source.GetMetadata())...)
case Condition_FieldPathSelectorParameterDeclarations:
for _, item := range source.GetParameterDeclarations() {
values = append(values, fps.subPath.GetRaw(item)...)
}
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fps.selector))
}
return
}
func (fps *Condition_FieldSubPath) GetRaw(source proto.Message) []interface{} {
return fps.Get(source.(*Condition))
}
// GetSingle returns value of selected field from source Condition
func (fps *Condition_FieldSubPath) GetSingle(source *Condition) (interface{}, bool) {
switch fps.selector {
case Condition_FieldPathSelectorMetadata:
if source.GetMetadata() == nil {
return nil, false
}
return fps.subPath.GetSingleRaw(source.GetMetadata())
case Condition_FieldPathSelectorParameterDeclarations:
if len(source.GetParameterDeclarations()) == 0 {
return nil, false
}
return fps.subPath.GetSingleRaw(source.GetParameterDeclarations()[0])
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fps.selector))
}
}
func (fps *Condition_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) {
return fps.GetSingle(source.(*Condition))
}
// GetDefault returns a default value of the field type
func (fps *Condition_FieldSubPath) GetDefault() interface{} {
return fps.subPath.GetDefault()
}
func (fps *Condition_FieldSubPath) ClearValue(item *Condition) {
if item != nil {
switch fps.selector {
case Condition_FieldPathSelectorMetadata:
fps.subPath.ClearValueRaw(item.Metadata)
case Condition_FieldPathSelectorParameterDeclarations:
for _, subItem := range item.ParameterDeclarations {
fps.subPath.ClearValueRaw(subItem)
}
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fps.selector))
}
}
}
func (fps *Condition_FieldSubPath) ClearValueRaw(item proto.Message) {
fps.ClearValue(item.(*Condition))
}
// IsLeaf - whether field path is holds simple value
func (fps *Condition_FieldSubPath) IsLeaf() bool {
return fps.subPath.IsLeaf()
}
func (fps *Condition_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath {
iPaths := []gotenobject.FieldPath{&Condition_FieldTerminalPath{selector: fps.selector}}
iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...)
return iPaths
}
func (fps *Condition_FieldSubPath) WithIValue(value interface{}) Condition_FieldPathValue {
return &Condition_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)}
}
func (fps *Condition_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue {
return fps.WithIValue(value)
}
func (fps *Condition_FieldSubPath) WithIArrayOfValues(values interface{}) Condition_FieldPathArrayOfValues {
return &Condition_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)}
}
func (fps *Condition_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues {
return fps.WithIArrayOfValues(values)
}
func (fps *Condition_FieldSubPath) WithIArrayItemValue(value interface{}) Condition_FieldPathArrayItemValue {
return &Condition_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)}
}
func (fps *Condition_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue {
return fps.WithIArrayItemValue(value)
}
// Condition_FieldPathValue allows storing values for Condition fields according to their type
type Condition_FieldPathValue interface {
Condition_FieldPath
gotenobject.FieldPathValue
SetTo(target **Condition)
CompareWith(*Condition) (cmp int, comparable bool)
}
func ParseCondition_FieldPathValue(pathStr, valueStr string) (Condition_FieldPathValue, error) {
fp, err := ParseCondition_FieldPath(pathStr)
if err != nil {
return nil, err
}
fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "error parsing Condition field path value from %s: %v", valueStr, err)
}
return fpv.(Condition_FieldPathValue), nil
}
func MustParseCondition_FieldPathValue(pathStr, valueStr string) Condition_FieldPathValue {
fpv, err := ParseCondition_FieldPathValue(pathStr, valueStr)
if err != nil {
panic(err)
}
return fpv
}
type Condition_FieldTerminalPathValue struct {
Condition_FieldTerminalPath
value interface{}
}
var _ Condition_FieldPathValue = (*Condition_FieldTerminalPathValue)(nil)
// GetRawValue returns raw value stored under selected path for 'Condition' as interface{}
func (fpv *Condition_FieldTerminalPathValue) GetRawValue() interface{} {
return fpv.value
}
func (fpv *Condition_FieldTerminalPathValue) AsNameValue() (*Name, bool) {
res, ok := fpv.value.(*Name)
return res, ok
}
func (fpv *Condition_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) {
res, ok := fpv.value.(*meta.Meta)
return res, ok
}
func (fpv *Condition_FieldTerminalPathValue) AsDisplayNameValue() (string, bool) {
res, ok := fpv.value.(string)
return res, ok
}
func (fpv *Condition_FieldTerminalPathValue) AsDescriptionValue() (string, bool) {
res, ok := fpv.value.(string)
return res, ok
}
func (fpv *Condition_FieldTerminalPathValue) AsExpressionValue() (string, bool) {
res, ok := fpv.value.(string)
return res, ok
}
func (fpv *Condition_FieldTerminalPathValue) AsParameterDeclarationsValue() ([]*Condition_ParameterDeclaration, bool) {
res, ok := fpv.value.([]*Condition_ParameterDeclaration)
return res, ok
}
// SetTo stores value for selected field for object Condition
func (fpv *Condition_FieldTerminalPathValue) SetTo(target **Condition) {
if *target == nil {
*target = new(Condition)
}
switch fpv.selector {
case Condition_FieldPathSelectorName:
(*target).Name = fpv.value.(*Name)
case Condition_FieldPathSelectorMetadata:
(*target).Metadata = fpv.value.(*meta.Meta)
case Condition_FieldPathSelectorDisplayName:
(*target).DisplayName = fpv.value.(string)
case Condition_FieldPathSelectorDescription:
(*target).Description = fpv.value.(string)
case Condition_FieldPathSelectorExpression:
(*target).Expression = fpv.value.(string)
case Condition_FieldPathSelectorParameterDeclarations:
(*target).ParameterDeclarations = fpv.value.([]*Condition_ParameterDeclaration)
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fpv.selector))
}
}
func (fpv *Condition_FieldTerminalPathValue) SetToRaw(target proto.Message) {
typedObject := target.(*Condition)
fpv.SetTo(&typedObject)
}
// CompareWith compares value in the 'Condition_FieldTerminalPathValue' with the value under path in 'Condition'.
func (fpv *Condition_FieldTerminalPathValue) CompareWith(source *Condition) (int, bool) {
switch fpv.selector {
case Condition_FieldPathSelectorName:
leftValue := fpv.value.(*Name)
rightValue := source.GetName()
if leftValue == nil {
if rightValue != nil {
return -1, true
}
return 0, true
}
if rightValue == nil {
return 1, true
}
if leftValue.String() == rightValue.String() {
return 0, true
} else if leftValue.String() < rightValue.String() {
return -1, true
} else {
return 1, true
}
case Condition_FieldPathSelectorMetadata:
return 0, false
case Condition_FieldPathSelectorDisplayName:
leftValue := fpv.value.(string)
rightValue := source.GetDisplayName()
if (leftValue) == (rightValue) {
return 0, true
} else if (leftValue) < (rightValue) {
return -1, true
} else {
return 1, true
}
case Condition_FieldPathSelectorDescription:
leftValue := fpv.value.(string)
rightValue := source.GetDescription()
if (leftValue) == (rightValue) {
return 0, true
} else if (leftValue) < (rightValue) {
return -1, true
} else {
return 1, true
}
case Condition_FieldPathSelectorExpression:
leftValue := fpv.value.(string)
rightValue := source.GetExpression()
if (leftValue) == (rightValue) {
return 0, true
} else if (leftValue) < (rightValue) {
return -1, true
} else {
return 1, true
}
case Condition_FieldPathSelectorParameterDeclarations:
return 0, false
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fpv.selector))
}
}
func (fpv *Condition_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) {
return fpv.CompareWith(source.(*Condition))
}
type Condition_FieldSubPathValue struct {
Condition_FieldPath
subPathValue gotenobject.FieldPathValue
}
var _ Condition_FieldPathValue = (*Condition_FieldSubPathValue)(nil)
func (fpvs *Condition_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) {
res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue)
return res, ok
}
func (fpvs *Condition_FieldSubPathValue) AsParameterDeclarationsPathValue() (ConditionParameterDeclaration_FieldPathValue, bool) {
res, ok := fpvs.subPathValue.(ConditionParameterDeclaration_FieldPathValue)
return res, ok
}
func (fpvs *Condition_FieldSubPathValue) SetTo(target **Condition) {
if *target == nil {
*target = new(Condition)
}
switch fpvs.Selector() {
case Condition_FieldPathSelectorMetadata:
fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata)
case Condition_FieldPathSelectorParameterDeclarations:
panic("FieldPath setter is unsupported for array subpaths")
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fpvs.Selector()))
}
}
func (fpvs *Condition_FieldSubPathValue) SetToRaw(target proto.Message) {
typedObject := target.(*Condition)
fpvs.SetTo(&typedObject)
}
func (fpvs *Condition_FieldSubPathValue) GetRawValue() interface{} {
return fpvs.subPathValue.GetRawValue()
}
func (fpvs *Condition_FieldSubPathValue) CompareWith(source *Condition) (int, bool) {
switch fpvs.Selector() {
case Condition_FieldPathSelectorMetadata:
return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata())
case Condition_FieldPathSelectorParameterDeclarations:
return 0, false // repeated field
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fpvs.Selector()))
}
}
func (fpvs *Condition_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) {
return fpvs.CompareWith(source.(*Condition))
}
// Condition_FieldPathArrayItemValue allows storing single item in Path-specific values for Condition according to their type
// Present only for array (repeated) types.
type Condition_FieldPathArrayItemValue interface {
gotenobject.FieldPathArrayItemValue
Condition_FieldPath
ContainsValue(*Condition) bool
}
// ParseCondition_FieldPathArrayItemValue parses string and JSON-encoded value to its Value
func ParseCondition_FieldPathArrayItemValue(pathStr, valueStr string) (Condition_FieldPathArrayItemValue, error) {
fp, err := ParseCondition_FieldPath(pathStr)
if err != nil {
return nil, err
}
fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "error parsing Condition field path array item value from %s: %v", valueStr, err)
}
return fpaiv.(Condition_FieldPathArrayItemValue), nil
}
func MustParseCondition_FieldPathArrayItemValue(pathStr, valueStr string) Condition_FieldPathArrayItemValue {
fpaiv, err := ParseCondition_FieldPathArrayItemValue(pathStr, valueStr)
if err != nil {
panic(err)
}
return fpaiv
}
type Condition_FieldTerminalPathArrayItemValue struct {
Condition_FieldTerminalPath
value interface{}
}
var _ Condition_FieldPathArrayItemValue = (*Condition_FieldTerminalPathArrayItemValue)(nil)
// GetRawValue returns stored element value for array in object Condition as interface{}
func (fpaiv *Condition_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} {
return fpaiv.value
}
func (fpaiv *Condition_FieldTerminalPathArrayItemValue) AsParameterDeclarationsItemValue() (*Condition_ParameterDeclaration, bool) {
res, ok := fpaiv.value.(*Condition_ParameterDeclaration)
return res, ok
}
func (fpaiv *Condition_FieldTerminalPathArrayItemValue) GetSingle(source *Condition) (interface{}, bool) {
return nil, false
}
func (fpaiv *Condition_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) {
return fpaiv.GetSingle(source.(*Condition))
}
// Contains returns a boolean indicating if value that is being held is present in given 'Condition'
func (fpaiv *Condition_FieldTerminalPathArrayItemValue) ContainsValue(source *Condition) bool {
slice := fpaiv.Condition_FieldTerminalPath.Get(source)
for _, v := range slice {
if asProtoMsg, ok := fpaiv.value.(proto.Message); ok {
if proto.Equal(asProtoMsg, v.(proto.Message)) {
return true
}
} else if reflect.DeepEqual(v, fpaiv.value) {
return true
}
}
return false
}
type Condition_FieldSubPathArrayItemValue struct {
Condition_FieldPath
subPathItemValue gotenobject.FieldPathArrayItemValue
}
// GetRawValue returns stored array item value
func (fpaivs *Condition_FieldSubPathArrayItemValue) GetRawItemValue() interface{} {
return fpaivs.subPathItemValue.GetRawItemValue()
}
func (fpaivs *Condition_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) {
res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue)
return res, ok
}
func (fpaivs *Condition_FieldSubPathArrayItemValue) AsParameterDeclarationsPathItemValue() (ConditionParameterDeclaration_FieldPathArrayItemValue, bool) {
res, ok := fpaivs.subPathItemValue.(ConditionParameterDeclaration_FieldPathArrayItemValue)
return res, ok
}
// Contains returns a boolean indicating if value that is being held is present in given 'Condition'
func (fpaivs *Condition_FieldSubPathArrayItemValue) ContainsValue(source *Condition) bool {
switch fpaivs.Selector() {
case Condition_FieldPathSelectorMetadata:
return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata())
case Condition_FieldPathSelectorParameterDeclarations:
return false // repeated/map field
default:
panic(fmt.Sprintf("Invalid selector for Condition: %d", fpaivs.Selector()))
}
}
// Condition_FieldPathArrayOfValues allows storing slice of values for Condition fields according to their type
type Condition_FieldPathArrayOfValues interface {
gotenobject.FieldPathArrayOfValues
Condition_FieldPath
}
func ParseCondition_FieldPathArrayOfValues(pathStr, valuesStr string) (Condition_FieldPathArrayOfValues, error) {
fp, err := ParseCondition_FieldPath(pathStr)
if err != nil {
return nil, err
}
fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "error parsing Condition field path array of values from %s: %v", valuesStr, err)
}
return fpaov.(Condition_FieldPathArrayOfValues), nil
}
func MustParseCondition_FieldPathArrayOfValues(pathStr, valuesStr string) Condition_FieldPathArrayOfValues {
fpaov, err := ParseCondition_FieldPathArrayOfValues(pathStr, valuesStr)
if err != nil {
panic(err)
}
return fpaov
}
type Condition_FieldTerminalPathArrayOfValues struct {
Condition_FieldTerminalPath
values interface{}
}
var _ Condition_FieldPathArrayOfValues = (*Condition_FieldTerminalPathArrayOfValues)(nil)
func (fpaov *Condition_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) {
switch fpaov.selector {
case Condition_FieldPathSelectorName:
for _, v := range fpaov.values.([]*Name) {
values = append(values, v)
}
case Condition_FieldPathSelectorMetadata:
for _, v := range fpaov.values.([]*meta.Meta) {
values = append(values, v)
}
case Condition_FieldPathSelectorDisplayName:
for _, v := range fpaov.values.([]string) {
values = append(values, v)
}
case Condition_FieldPathSelectorDescription:
for _, v := range fpaov.values.([]string) {
values = append(values, v)
}
case Condition_FieldPathSelectorExpression:
for _, v := range fpaov.values.([]string) {
values = append(values, v)
}
case Condition_FieldPathSelectorParameterDeclarations:
for _, v := range fpaov.values.([][]*Condition_ParameterDeclaration) {
values = append(values, v)
}
}
return
}
func (fpaov *Condition_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) {
res, ok := fpaov.values.([]*Name)
return res, ok
}
func (fpaov *Condition_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) {
res, ok := fpaov.values.([]*meta.Meta)
return res, ok
}
func (fpaov *Condition_FieldTerminalPathArrayOfValues) AsDisplayNameArrayOfValues() ([]string, bool) {
res, ok := fpaov.values.([]string)
return res, ok
}
func (fpaov *Condition_FieldTerminalPathArrayOfValues) AsDescriptionArrayOfValues() ([]string, bool) {
res, ok := fpaov.values.([]string)
return res, ok
}
func (fpaov *Condition_FieldTerminalPathArrayOfValues) AsExpressionArrayOfValues() ([]string, bool) {
res, ok := fpaov.values.([]string)
return res, ok
}
func (fpaov *Condition_FieldTerminalPathArrayOfValues) AsParameterDeclarationsArrayOfValues() ([][]*Condition_ParameterDeclaration, bool) {
res, ok := fpaov.values.([][]*Condition_ParameterDeclaration)
return res, ok
}
type Condition_FieldSubPathArrayOfValues struct {
Condition_FieldPath
subPathArrayOfValues gotenobject.FieldPathArrayOfValues
}
var _ Condition_FieldPathArrayOfValues = (*Condition_FieldSubPathArrayOfValues)(nil)
func (fpsaov *Condition_FieldSubPathArrayOfValues) GetRawValues() []interface{} {
return fpsaov.subPathArrayOfValues.GetRawValues()
}
func (fpsaov *Condition_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) {
res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues)
return res, ok
}
func (fpsaov *Condition_FieldSubPathArrayOfValues) AsParameterDeclarationsPathArrayOfValues() (ConditionParameterDeclaration_FieldPathArrayOfValues, bool) {
res, ok := fpsaov.subPathArrayOfValues.(ConditionParameterDeclaration_FieldPathArrayOfValues)
return res, ok
}
// FieldPath provides implementation to handle
// https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto
type ConditionParameterDeclaration_FieldPath interface {
gotenobject.FieldPath
Selector() ConditionParameterDeclaration_FieldPathSelector
Get(source *Condition_ParameterDeclaration) []interface{}
GetSingle(source *Condition_ParameterDeclaration) (interface{}, bool)
ClearValue(item *Condition_ParameterDeclaration)
// Those methods build corresponding ConditionParameterDeclaration_FieldPathValue
// (or array of values) and holds passed value. Panics if injected type is incorrect.
WithIValue(value interface{}) ConditionParameterDeclaration_FieldPathValue
WithIArrayOfValues(values interface{}) ConditionParameterDeclaration_FieldPathArrayOfValues
WithIArrayItemValue(value interface{}) ConditionParameterDeclaration_FieldPathArrayItemValue
}
type ConditionParameterDeclaration_FieldPathSelector int32
const (
ConditionParameterDeclaration_FieldPathSelectorKey ConditionParameterDeclaration_FieldPathSelector = 0
ConditionParameterDeclaration_FieldPathSelectorType ConditionParameterDeclaration_FieldPathSelector = 1
)
func (s ConditionParameterDeclaration_FieldPathSelector) String() string {
switch s {
case ConditionParameterDeclaration_FieldPathSelectorKey:
return "key"
case ConditionParameterDeclaration_FieldPathSelectorType:
return "type"
default:
panic(fmt.Sprintf("Invalid selector for Condition_ParameterDeclaration: %d", s))
}
}
func BuildConditionParameterDeclaration_FieldPath(fp gotenobject.RawFieldPath) (ConditionParameterDeclaration_FieldPath, error) {
if len(fp) == 0 {
return nil, status.Error(codes.InvalidArgument, "empty field path for object Condition_ParameterDeclaration")
}
if len(fp) == 1 {
switch fp[0] {
case "key":
return &ConditionParameterDeclaration_FieldTerminalPath{selector: ConditionParameterDeclaration_FieldPathSelectorKey}, nil
case "type":
return &ConditionParameterDeclaration_FieldTerminalPath{selector: ConditionParameterDeclaration_FieldPathSelectorType}, nil
}
}
return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Condition_ParameterDeclaration", fp)
}
func ParseConditionParameterDeclaration_FieldPath(rawField string) (ConditionParameterDeclaration_FieldPath, error) {
fp, err := gotenobject.ParseRawFieldPath(rawField)
if err != nil {
return nil, err
}
return BuildConditionParameterDeclaration_FieldPath(fp)
}
func MustParseConditionParameterDeclaration_FieldPath(rawField string) ConditionParameterDeclaration_FieldPath {
fp, err := ParseConditionParameterDeclaration_FieldPath(rawField)
if err != nil {
panic(err)
}
return fp
}
type ConditionParameterDeclaration_FieldTerminalPath struct {
selector ConditionParameterDeclaration_FieldPathSelector
}
var _ ConditionParameterDeclaration_FieldPath = (*ConditionParameterDeclaration_FieldTerminalPath)(nil)
func (fp *ConditionParameterDeclaration_FieldTerminalPath) Selector() ConditionParameterDeclaration_FieldPathSelector {
return fp.selector
}
// String returns path representation in proto convention
func (fp *ConditionParameterDeclaration_FieldTerminalPath) String() string {
return fp.selector.String()
}
// JSONString returns path representation is JSON convention
func (fp *ConditionParameterDeclaration_FieldTerminalPath) JSONString() string {
return strcase.ToLowerCamel(fp.String())
}
// Get returns all values pointed by specific field from source Condition_ParameterDeclaration
func (fp *ConditionParameterDeclaration_FieldTerminalPath) Get(source *Condition_ParameterDeclaration) (values []interface{}) {
if source != nil {
switch fp.selector {
case ConditionParameterDeclaration_FieldPathSelectorKey:
values = append(values, source.Key)
case ConditionParameterDeclaration_FieldPathSelectorType:
values = append(values, source.Type)
default:
panic(fmt.Sprintf("Invalid selector for Condition_ParameterDeclaration: %d", fp.selector))
}
}
return
}