tinc 0.1.6

GRPc to REST transcoding library
Documentation
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
syntax = "proto3";

package tinc;

import "google/protobuf/descriptor.proto";

extend google.protobuf.MessageOptions {
    // See `MessageOptions` for what options can be added onto messages.
    MessageOptions message = 15501;
}

extend google.protobuf.FieldOptions {
    // See `FieldOptions` for all the options that can be applied to fields.
    FieldOptions field = 15502;
    // Predefined is used to construct custom field cel expression templates.
    // For more information refer to the see the `PredefinedConstraint`
    optional PredefinedConstraints predefined = 15508;
}

extend google.protobuf.EnumOptions {
    // See `EnumOptions` for all the options that can be applied to enums.
    EnumOptions enum = 15503;
}

extend google.protobuf.EnumValueOptions {
    // See `EnumVariantOptions` for all the options that can be applied to enum variants.
    EnumVariantOptions variant = 15504;
}

extend google.protobuf.MethodOptions {
    // See `MethodOptions` for all the options that can be applied to methods.
    MethodOptions method = 15505;
}

extend google.protobuf.ServiceOptions {
    // See `ServiceOptions` for all the options that can be applied to services.
    ServiceOptions service = 15506;
}

extend google.protobuf.OneofOptions {
    // See `OneofOptions` for all the options that can be applied to oneofs.
    OneofOptions oneof = 15507;
}

message ServiceOptions {
    // By default service routes are defined in the method, however if you want
    // all routes in this service to be prefixed this is
    // how you would apply such a prefix.
    optional string prefix = 1;
}


// Enum to define how to rename fields or enum variants.
enum RenameAll {
    // protolint:disable ENUM_FIELD_NAMES_PREFIX
    RENAME_ALL_UNSPECIFIED = 0;
    // Rename to lowercase.
    LOWER_CASE = 1;
    // Rename to UPPERCASE.
    UPPER_CASE = 2;
    // Rename to PascalCase.
    PASCAL_CASE = 3;
    // Rename to camelCase.
    CAMEL_CASE = 4;
    // Rename to snake_case.
    SNAKE_CASE = 5;
    // Rename to SCREAMING_SNAKE_CASE.
    SCREAMING_SNAKE_CASE = 6;
    // Rename to kebab-case.
    KEBAB_CASE = 7;
    // Rename to SCREAMING-KEBAB-CASE.
    SCREAMING_KEBAB_CASE = 8;
}

message MethodOptions {
    // A list of endpoints to be built from this method.
    repeated HttpEndpointOptions endpoint = 1;
    // A list of cel expressions to apply to the input of this message.
    repeated CelExpression cel = 2;
}

message MessageOptions {
    // If false, this message will not be generated even if its depended on by a method.
    // If true, this message will always be generated.
    // By default: this message is only generated if its depended on by a method.
    optional bool generate = 1;
    // Rename all fields in the message.
    optional RenameAll rename_all = 2;
    // Disable cel-validation generation.
    optional bool skip_validation = 101;

    // A list of custom cel expressions that apply to the message in its entirety
    // You can use this to create expressions that depend on multiple field values.
    repeated CelExpression cel = 100;
}

// Change the visibility of a field or enum variant
enum Visibility {
    VISIBILITY_UNSPECIFIED = 0;
    // Skipped fields will not be deserialized or serialized.
    SKIP = 1;
    // Fields marked as input only will only be deserialized and will not be
    // serialized.
    INPUT_ONLY = 2;
    // Fields marked as output only will not be deserialized and only will be
    // serialized.
    OUTPUT_ONLY = 3;
}

// Predefined constraints allow us to extend the validation system
// by defining our own custom message extensions with validation
// constraints.
message PredefinedConstraints {
    // The set of constraints that should be applied.
    repeated CelExpression cel = 1;

    // The type of the target of the expression
    enum Type {
        TYPE_UNSPECIFIED = 0;
        // Only apply all sub items to repeated items
        WRAPPER_REPEATED_ITEM = 1;
        // Only apply all sub items to map keys
        WRAPPER_MAP_KEY = 2;
        // Only apply all sub items to map values
        WRAPPER_MAP_VALUE = 3;
        // Unlike the others, this can only be applied
        // to lists of `CelExpression`
        CUSTOM_EXPRESSION = 4;
    }
    Type type = 2;
}

// JsonOmittable is the notion of leaving out fields, and
// how we behave when a field is missing.
enum JsonOmittable {
    JSON_OMITTABLE_UNSPECIFIED = 0;
    // If true the field will just be defaulted if not provided.
    // The field will also not be serialized if its the default value.
    TRUE = 1;
    // If false we will raise an error when the field is not provided.
    FALSE = 2;
    // Same as true, except always serialize the field even if its a default value.
    TRUE_BUT_STILL_SERIALIZE = 3;
}

message FieldOptions {
    // Rename this specific field to another name.
    optional string rename = 1;

    // Deserialization:
    // This flag dictates how we handle fields which are
    // not provided in the json representation of the message.
    // If this is true, then no error will be returned
    // if the field is not provided.
    // If this is false then not providing a value for this field
    // will result in an error.
    //
    // Serialization:
    // This flag dictates if we should skip serializing the field
    // in the json representation of the message if the field
    // is equal to the default value for its type.
    //
    // By default if the value depends on the type of field.
    // If the field is an option then the default value is
    // `TRUE_BUT_SERIALIZE` which means that the option does not
    // need to be provided but a `null` value will always be serialized.
    // If the field is not an option then it will be required so `FALSE`.
    JsonOmittable json_omittable = 200;

    // Flatten this field into the parent message.
    // This only works on messages.
    optional bool flatten = 205;
    // Change the visibility of the field. By Default all fields are visible.
    optional Visibility visibility = 202;

    // Add some constraints to the field.
    optional FieldConstraints constraint = 101;
}

message FloatConstraints {
    oneof greater {
        // Requires the input value is greater than the value provided.
        float gt = 1 [(predefined).cel = {
            message: "value must be greater than `{this}`"
            expression: "input > this"
            jsonschemas: '{ "exclusiveMinimum": this }'
        }];
        // Requires the input value is greater than or equal to the value provided.
        float gte = 2 [(predefined).cel = {
            message: "value must be greater than or equal to `{this}`"
            expression: "input >= this"
            jsonschemas: '{ "minimum": this }'
        }];
    }

    oneof less {
        // Requires the input value is less than the value provided.
        float lt = 3 [(predefined).cel = {
            message: "value must be less than `{this}`"
            expression: "input < this"
            jsonschemas: '{ "exclusiveMaximum": this }'
        }];
        // Requires the input value is less than or equal to the value provided.
        float lte = 4 [(predefined).cel = {
            message: "value must be less than or equal to {this}"
            expression: "input <= this"
            jsonschemas: '{ "maximum": this }'
        }];
    }

    // Requires the input value be one of the values in the list
    repeated float in = 5 [(predefined).cel = {
        message: "value must be one of `{this}`"
        expression: "this.contains(input)"
        jsonschemas: '{ "enum": this }'
    }];
    // Requires the input value not be one of the values in the list.
    repeated float not_in = 6 [(predefined).cel = {
        message: "value must not be one of `{this}`"
        expression: "!this.contains(input)"
        jsonschemas: '{ "not": { "enum": this }}'
    }];
    // Requires the input value be exactly equal to the value provided.
    optional float const = 8 [(predefined).cel = {
        message: "value must be equal to `{this}`"
        expression: "input == this"
        jsonschemas: '{ "const": this }'
    }];
}

message DoubleConstraints {
    oneof greater {
        // Requires the input value is greater than the value provided.
        double gt = 1 [(predefined).cel = {
            message: "value must be greater than `{this}`"
            expression: "input > this"
            jsonschemas: '{ "exclusiveMinimum": this }'
        }];
        // Requires the input value is greater than or equal to the value provided.
        double gte = 2 [(predefined).cel = {
            message: "value must be greater than or equal to `{this}`"
            expression: "input >= this"
            jsonschemas: '{ "minimum": this }'
        }];
    }

    oneof less {
        // Requires the input value is less than the value provided.
        double lt = 3 [(predefined).cel = {
            message: "value must be less than `{this}`"
            expression: "input < this"
            jsonschemas: '{ "exclusiveMaximum": this }'
        }];
        // Requires the input value is less than or equal to the value provided.
        double lte = 4 [(predefined).cel = {
            message: "value must be less than or equal to `{this}`"
            expression: "input <= this"
            jsonschemas: '{ "maximum": this }'
        }];
    }

    // Requires the input value be one of the values in the list
    repeated double in = 5 [(predefined).cel = {
        message: "value must be one of `{this}`"
        expression: "this.contains(input)"
        jsonschemas: '{ "enum": this }'
    }];
    // Requires the input value not be one of the values in the list.
    repeated double not_in = 6 [(predefined).cel = {
        message: "value must not be one of `{this}`"
        expression: "!this.contains(input)"
        jsonschemas: '{ "not": { "enum": this }}'
    }];
    // Requires the input value be exactly equal to the value provided.
    optional double const = 8 [(predefined).cel = {
        message: "value must be equal to `{this}`"
        expression: "input == this"
        jsonschemas: '{ "const": this }'
    }];
}

message Int32Constraints {
    oneof greater {
        // Requires the input value is greater than the value provided.
        int32 gt = 1 [(predefined).cel = {
            message: "value must be greater than `{this}`"
            expression: "input > this"
            jsonschemas: '{ "exclusiveMinimum": this }'
        }];
        // Requires the input value is greater than or equal to the value provided.
        int32 gte = 2 [(predefined).cel = {
            message: "value must be greater than or equal to `{this}`"
            expression: "input >= this"
            jsonschemas: '{ "minimum": this }'
        }];
    }

    oneof less {
        // Requires the input value is less than the value provided.
        int32 lt = 3 [(predefined).cel = {
            message: "value must be less than `{this}`"
            expression: "input < this"
            jsonschemas: '{ "exclusiveMaximum": this }'
        }];
        // Requires the input value is less than or equal to the value provided.
        int32 lte = 4 [(predefined).cel = {
            message: "value must be less than or equal to `{this}`"
            expression: "input <= this"
            jsonschemas: '{ "maximum": this }'
        }];
    }
    // Requires the input value be one of the values in the list
    repeated int32 in = 5 [(predefined).cel = {
        message: "value must be one of `{this}`"
        expression: "this.contains(input)"
        jsonschemas: '{ "enum": this }'
    }];
    // Requires the input value not be one of the values in the list.
    repeated int32 not_in = 6 [(predefined).cel = {
        message: "value must not be one of `{this}`"
        expression: "!this.contains(input)"
        jsonschemas: '{ "not": { "enum": this }}'
    }];
    // Requires the input value be exactly equal to the value provided.
    optional int32 const = 8 [(predefined).cel = {
        message: "value must be equal to `{this}`"
        expression: "input == this"
        jsonschemas: '{ "const": this }'
    }];
}

message Int64Constraints {
    oneof greater {
        // Requires the input value is greater than the value provided.
        int64 gt = 1 [(predefined).cel = {
            message: "value must be greater than `{this}`"
            expression: "input > this"
            jsonschemas: '{ "exclusiveMinimum": this }'
        }];
        // Requires the input value is greater than or equal to the value provided.
        int64 gte = 2 [(predefined).cel = {
            message: "value must be greater than or equal to `{this}`"
            expression: "input >= this"
            jsonschemas: '{ "minimum": this }'
        }];
    }

    oneof less {
        // Requires the input value is less than the value provided.
        int64 lt = 3 [(predefined).cel = {
            message: "value must be less than `{this}`"
            expression: "input < this"
            jsonschemas: '{ "exclusiveMaximum": this }'
        }];
        // Requires the input value is less than or equal to the value provided.
        int64 lte = 4 [(predefined).cel = {
            message: "value must be less than or equal to `{this}`"
            expression: "input <= this"
            jsonschemas: '{ "maximum": this }'
        }];
    }
    // Requires the input value be one of the values in the list
    repeated int64 in = 5 [(predefined).cel = {
        message: "value must be one of `{this}`"
        expression: "this.contains(input)"
        jsonschemas: '{ "enum": this }'
    }];
    // Requires the input value not be one of the values in the list.
    repeated int64 not_in = 6 [(predefined).cel = {
        message: "value must not be one of `{this}`"
        expression: "!this.contains(input)"
        jsonschemas: '{ "not": { "enum": this }}'
    }];
    // Requires the input value be exactly equal to the value provided.
    optional int64 const = 8 [(predefined).cel = {
        message: "value must be equal to `{this}`"
        expression: "input == this"
        jsonschemas: '{ "const": this }'
    }];
}

message UInt32Constraints {
    oneof greater {
        // Requires the input value is greater than the value provided.
        uint32 gt = 1 [(predefined).cel = {
            message: "value must be greater than `{this}`"
            expression: "input > this"
            jsonschemas: '{ "exclusiveMinimum": this }'
        }];
        // Requires the input value is greater than or equal to the value provided.
        uint32 gte = 2 [(predefined).cel = {
            message: "value must be greater than or equal to `{this}`"
            expression: "input >= this"
            jsonschemas: '{ "minimum": this }'
        }];
    }

    oneof less {
        // Requires the input value is less than the value provided.
        uint32 lt = 3 [(predefined).cel = {
            message: "value must be less than `{this}`"
            expression: "input < this"
            jsonschemas: '{ "exclusiveMaximum": this }'
        }];
        // Requires the input value is less than or equal to the value provided.
        uint32 lte = 4 [(predefined).cel = {
            message: "value must be less than or equal to `{this}`"
            expression: "input <= this"
            jsonschemas: '{ "maximum": this }'
        }];
    }
    // Requires the input value be one of the values in the list
    repeated uint32 in = 5 [(predefined).cel = {
        message: "value must be one of `{this}`"
        expression: "this.contains(input)"
        jsonschemas: '{ "enum": this }'
    }];
    // Requires the input value not be one of the values in the list.
    repeated uint32 not_in = 6 [(predefined).cel = {
        message: "value must not be one of `{this}`"
        expression: "!this.contains(input)"
        jsonschemas: '{ "not": { "enum": this }}'
    }];
    // Requires the input value be exactly equal to the value provided.
    optional uint32 const = 8 [(predefined).cel = {
        message: "value must be equal to `{this}`"
        expression: "input == this"
        jsonschemas: '{ "const": this }'
    }];
}

message UInt64Constraints {
    oneof greater {
        // Requires the input value is greater than the value provided.
        int64 gt = 1 [(predefined).cel = {
            message: "value must be greater than `{this}`"
            expression: "input > this"
            jsonschemas: '{ "exclusiveMinimum": this }'
        }];
        // Requires the input value is greater than or equal to the value provided.
        uint64 gte = 2 [(predefined).cel = {
            message: "value must be greater than or equal to `{this}`"
            expression: "input >= this"
            jsonschemas: '{ "minimum": this }'
        }];
    }

    oneof less {
        // Requires the input value is less than the value provided.
        uint64 lt = 3 [(predefined).cel = {
            message: "value must be less than `{this}`"
            expression: "input < this"
            jsonschemas: '{ "exclusiveMaximum": this }'
        }];
        // Requires the input value is less than or equal to the value provided.
        uint64 lte = 4 [(predefined).cel = {
            message: "value must be less than or equal to `{this}`"
            expression: "input <= this"
            jsonschemas: '{ "maximum": this }'
        }];
    }
    // Requires the input value be one of the values in the list
    repeated uint64 in = 5 [(predefined).cel = {
        message: "value must be one of `{this}`"
        expression: "this.contains(input)"
        jsonschemas: '{ "enum": this }'
    }];
    // Requires the input value not be one of the values in the list.
    repeated uint64 not_in = 6 [(predefined).cel = {
        message: "value must not be one of `{this}`"
        expression: "!this.contains(input)"
        jsonschemas: '{ "not": { "enum": this }}'
    }];
    // Requires the input value be exactly equal to the value provided.
    optional uint64 const = 8 [(predefined).cel = {
        message: "value must be equal to `{this}`"
        expression: "input == this"
        jsonschemas: '{ "const": this }'
    }];
}

message StringConstraints {
    // Requires the input value be exactly equal to the value provided.
    optional string const = 1 [(predefined).cel = {
        message: "value must equal `{this}`"
        expression: "input == this"
        jsonschemas: '{"const": this }'
    }];
    // Requires the input value length be exactly equal to the value provided.
    optional uint64 len = 2 [(predefined).cel = {
        message: "value must be exactly `{this}` characters long"
        expression: "input.size() == this"
        jsonschemas: '{ "maxLength": this }'
        jsonschemas: '{ "minLength": this }'
    }];
    // Requires the input value length be greater then or equal to the value provided.
    optional uint64 min_len = 3 [(predefined).cel = {
        message: "value must be at least `{this}` characters long"
        expression: "input.size() >= this"
        jsonschemas: '{ "minLength": this }'
    }];
    // Requires the input value length be less then or equal to the value provided.
    optional uint64 max_len = 4 [(predefined).cel = {
        message: "value must be at most `{this}` characters long"
        expression: "input.size() <= this"
        jsonschemas: '{ "maxLength": this }'
    }];
    // Requires the input value to match against regex provided.
    optional string match = 5 [(predefined).cel = {
        message: "value must match the pattern `{this}`"
        expression: "input.matches(this)"
        jsonschemas: '{ "pattern": this }'
    }];
    // Requires the input value not match against the regex provided.
    optional string not_match = 6 [(predefined).cel = {
        message: "value must not match the pattern `{this}`"
        expression: "!(input.matches(this))"
        jsonschemas: '{ "not": { "pattern": this }}'
    }];
    // Requires the input value to start with the value provided.
    optional string prefix = 7 [(predefined).cel = {
        message: "value must start with `{this}`"
        expression: "input.startsWith(this)"
        jsonschemas: '{ "pattern": "^" + this }'
    }];
    // Requires the input value to end with the value provided.
    optional string suffix = 8 [(predefined).cel = {
        message: "value must end with `{this}`"
        expression: "input.endsWith(this)"
        jsonschemas: '{ "pattern": this + "$" }'
    }];
    // Requires the input value to contain this sub string.
    optional string contains = 9 [(predefined).cel = {
        message: "value must contain `{this}`"
        expression: "input.contains(this)"
        jsonschemas: '{ "pattern": this }'
    }];
    // Requires the input value to not contain this sub string.
    optional string not_contains = 10 [(predefined).cel = {
        message: "value must not contain `{this}`"
        expression: "!input.contains(this)"
        jsonschemas: '{ "not": { "pattern": this }}'
    }];
    // Requires the input value to be one of the values in the list.
    repeated string in = 11 [(predefined).cel = {
        message: "value must be one of `{this}`"
        expression: "this.contains(input)"
        jsonschemas: '{ "enum": this }'
    }];
    // Requires the input value to not be in the list.
    repeated string not_in = 12 [(predefined).cel = {
        message: "value must not be one of `{this}`"
        expression: "!this.contains(input)"
        jsonschemas: '{ "not": { "enum": this }}'
    }];
    oneof well_known {
        // Ensure the value is a valid email address format
        bool email = 13 [(predefined).cel = {
            message: "value must be a valid email address"
            expression: "!this || input.isEmail()"
            jsonschemas: 'this ? { "format": "email" } : {}'
        }];
        // Requires the input value to be a valid ipv4 or ipv6 address.
        bool ip = 14 [(predefined).cel = {
            message: "value must be a valid ipv4 or ipv6 address"
            expression: "!this || input.isIpv4() || input.isIpv6()"
            jsonschemas: 'this ? { "anyOf": [ { "format": "ipv4" }, { "format": "ipv6" } ] } : {}'
        }];
        // Requires the input value to be a valid ipv4 address.
        bool ipv4 = 15 [(predefined).cel = {
            message: "value must be a valid ipv4 address"
            expression: "!this || input.isIpv4()"
            jsonschemas: 'this ? { "format": "ipv4" } : {}'
        }];
        // Requires the input value to be a valid ipv6 address.
        bool ipv6 = 16 [(predefined).cel = {
            message: "value must be a valid ipv6 address"
            expression: "!this || input.isIpv6()"
            jsonschemas: 'this ? { "format": "ipv6" } : {}'
        }];
        // Requires the input value to be a valid uuid.
        bool uuid = 17 [(predefined).cel = {
            message: "value must be a valid uuid"
            expression: "!this || input.isUuid()"
            jsonschemas: 'this ? { "format": "uuid" } : {}'
        }];
        // Requires the input value to be a valid hostname.
        bool hostname = 18 [(predefined).cel = {
            message: "value must be a valid hostname"
            expression: "!this || input.isHostname()"
            jsonschemas: 'this ? { "format": "hostname" } : {}'
        }];
        // Requires the input value to be a valid uri.
        bool uri = 19 [(predefined).cel = {
            message: "value must be a valid uri"
            expression: "!this || input.isUri()"
            jsonschemas: 'this ? { "format": "uri" } : {}'
        }];
    }
}

message BytesConstraints {
    // Requires the input value be exactly equal to the value provided.
    optional bytes const = 1 [(predefined).cel = {
        message: "value must equal `{this}`"
        expression: "input == this"
        jsonschemas: '{"const": this }'
    }];
    // Requires the input value length be exactly equal to the value provided.
    optional uint64 len = 2 [(predefined).cel = {
        message: "value must be exactly `{this}` bytes long"
        expression: "input.size() == this"
        jsonschemas: '{ "minLength": this }'
        jsonschemas: '{ "maxLength": this }'
    }];
    // Requires the input value length be greater then or equal to the value provided.
    optional uint64 min_len = 3 [(predefined).cel = {
        message: "value must be at least `{this}` bytes long"
        expression: "input.size() >= this"
        jsonschemas: '{ "minLength": this }'
    }];
    // Requires the input value length be less then or equal to the value provided.
    optional uint64 max_len = 4 [(predefined).cel = {
        message: "value must be at most `{this}` bytes long"
        expression: "input.size() <= this"
        jsonschemas: '{ "maxLength": this }'
    }];
}

message EnumConstraints {
    // Requires the input value to be equal to the enum value where the tag is the value provided.
    optional int32 const = 1 [(predefined).cel = {
        message: "value must be equal to `{this.enum()}`"
        expression: "input == this"
        jsonschemas: '{ "const": this.enum() }'
    }];
    // Requires the input to be a valid value for this enum.
    optional bool defined = 2 [(predefined).cel = {
        message: "value must be defined in the enum"
        expression: "!this || input.enum()"
    }];
    // Requires the input to be one of the enum's provided.
    repeated int32 in = 3 [(predefined).cel = {
        message: "value must be one of `{this.map(e, e.enum())}`"
        expression: "this.contains(input)"
        jsonschemas: '{ "enum": this.map(e, e.enum()) }'
    }];
    // Requires the input to not be one of the enums provided.
    repeated int32 not_in = 4 [(predefined).cel = {
        message: "value must not be one of `{this.map(e, e.enum())}`"
        expression: "!this.contains(input)"
        jsonschemas: '{ "not": { "enum": this.map(e, e.enum()) }}'
    }];
}

message RepeatedConstraints {
    // Requires the length of the list be greater than or equal to the value provided.
    optional uint64 min_len = 1 [(predefined).cel = {
        message: "value must have at least `{this}` elements"
        expression: "input.size() >= this"
        jsonschemas: '{ "minItems": this }'
    }];
    // Requires the length of the list be less than or equal to the value provided.
    optional uint64 max_len = 2 [(predefined).cel = {
        message: "value must have at most `{this}` elements"
        expression: "input.size() <= this"
        jsonschemas: '{ "maxItems": this }'
    }];
    // Requires the length of the list be equal to the value provided.
    optional uint64 len = 3 [(predefined).cel = {
        message: "value must have exactly `{this}` elements"
        expression: "input.size() == this"
        jsonschemas: '{ "maxItems": this }'
        jsonschemas: '{ "minItems": this }'
    }];

    // Requires all items in the list are unique
    // optional bool unique = 4 [(predefined).cel = {
    //     message: "value must be unique"
    //     expression: "!this || input.isUnique()"
    //     jsonschemas: 'this ? { "uniqueItems": this } : {}'
    // }];

    // Apply a constraints to the items in the list.
    optional PrimitiveConstraints item = 5 [
        (predefined).type = WRAPPER_REPEATED_ITEM
    ];
}

message MapConstraints {
    // Requires the length of the map be greater than or equal to the value provided.
    optional uint64 min_len = 1 [(predefined).cel = {
        message: "value must have at least `{this}` elements"
        expression: "input.size() >= this"
        jsonschemas: '{ "minProperties": this }'
    }];
    // Requires the length of the map be less than or equal to the value provided.
    optional uint64 max_len = 2 [(predefined).cel = {
        message: "value must have at most `{this}` elements"
        expression: "input.size() <= this"
        jsonschemas: '{ "maxProperties": this }'
    }];
    // Requires the length of the map be equal to the value provided.
    optional uint64 len = 3 [(predefined).cel = {
        message: "value must have exactly `{this}` elements"
        expression: "input.size() == this"
        jsonschemas: '{ "minProperties": this }'
        jsonschemas: '{ "maxProperties": this }'
    }];

    message MapKeyConstraints {
        oneof constraint {
            // for int32 keys
            Int32Constraints int32 = 1;
            // for int64 keys
            Int64Constraints int64 = 2;
            // for uint32 keys
            UInt32Constraints uint32 = 3;
            // for uint64 keys
            UInt64Constraints uint64 = 4;
            // for string keys
            StringConstraints string = 5;
        }

        // A list of custom expressions to apply to map keys.
        repeated CelExpression cel = 8 [
            (predefined).type = CUSTOM_EXPRESSION
        ];
    }

    // Apply a constraints to the keys in the list.
    optional MapKeyConstraints key = 4 [
        (predefined).type = WRAPPER_MAP_KEY
    ];

    // Apply a constraints to the values in the list.
    optional PrimitiveConstraints value = 5 [
        (predefined).type = WRAPPER_MAP_VALUE
    ];
}

message PrimitiveConstraints {
    oneof constraint {
        // for float values
        FloatConstraints float = 1;
        // for double values
        DoubleConstraints double = 2;
        // for int32 values
        Int32Constraints int32 = 3;
        // for int64 values
        Int64Constraints int64 = 4;
        // for uint32 values
        UInt32Constraints uint32 = 5;
        // for uint64 values
        UInt64Constraints uint64 = 6;
        // for string values
        StringConstraints string = 7;
        // for bytes values
        BytesConstraints bytes = 8;
        // for enum values
        EnumConstraints enum = 9;
    }

    // A list of custom expressions to apply to the value
    repeated CelExpression cel = 11 [
            (predefined).type = CUSTOM_EXPRESSION
        ];
}

message FieldConstraints {
    oneof constraint {
        // for float fields.
        FloatConstraints float = 1;
        // for double fields.
        DoubleConstraints double = 2;
        // for int32 fields.
        Int32Constraints int32 = 3;
        // for int64 fields.
        Int64Constraints int64 = 4;
        // for uint32 fields.
        UInt32Constraints uint32 = 5;
        // for uint64 fields.
        UInt64Constraints uint64 = 6;
        // for string fields.
        StringConstraints string = 7;
        // for bytes fields.
        BytesConstraints bytes = 8;
        // for enum fields.
        EnumConstraints enum = 9;
        // for repeated fields.
        RepeatedConstraints repeated = 10;
        // for map fields.
        MapConstraints map = 11;
    }

    // A list of custom expressions to apply to the field.
    repeated CelExpression cel = 13 [
        (predefined).type = CUSTOM_EXPRESSION
    ];
}

message CelExpression {
    // The message to use when the validation fails.
    // You can template cel expressions using the `{<cel-expr>}` syntax
    string message = 2;
    // The expression itself.
    // Note: This expression's result will be converted into a bool.
    string expression = 3;
    // Json Scheamas that should be used when this expression is applied.
    // This is also a cel-expression which is evaluated at compile time
    // and should return a map object in the json schema format.
    repeated string jsonschemas = 5;
}

message EnumOptions {
    // Treat this enum as a number enum instead of string
    optional bool repr_enum = 2;
    // Rename all the fields on the enum
    optional RenameAll rename_all = 3;
}

message EnumVariantOptions {
    // Rename this variant
    optional string rename = 1;
    // Change the visibility for this variant.
    optional Visibility visibility = 2;
}

message HttpEndpointOptions {
    // HTTP method - Path parameters can be specified using `{param}` syntax.
    oneof method {
        // GET method
        string get = 1;
        // POST method
        string post = 2;
        // PUT method
        string put = 3;
        // DELETE method
        string delete = 4;
        // PATCH method
        string patch = 5;
    }


    // The default input for `GET` and `DELETE` methods is `query`
    // Otherwise the default is `body`.
    message Request {
        message JsonBody {
            optional string field = 1;
        }

        message TextBody {
            optional string field = 1;
        }

        message BinaryBody {
            optional string field = 1;
            // Specify the field to take the content-type from.
            optional string content_type_field = 2;
            // This field is purely used by the openapi spec to denote the set of valid output formats.
            optional string content_type_accepts = 3;

        }

        message QueryParams {
            // The field to parse the query parameters into.
            // By Default this is empty and therefore its parsed into the root message.
            optional string field = 1;
        }

        oneof mode {
            JsonBody json = 1;
            TextBody text = 2;
            BinaryBody binary = 3;
            QueryParams query = 4;
        }
    }

    Request request = 8;

    message Response {
        message Json {
            // Specify a sub field to return as the response
            // If this field is bytes or string it will be returned as is
            // without decoding.
            optional string field = 1;
        }

        message Text {
            // Specify a sub field to return as the response
            // If this field is bytes or string it will be returned as is
            // without decoding.
            optional string field = 1;
        }

        message Binary {
            // Specify a sub field to return as the response
            // If this field is bytes or string it will be returned as is
            // without decoding.
            optional string field = 1;
            // Specify the field to take the content-type from.
            optional string content_type_field = 2;
            // This field is purely used by the openapi spec to denote the set of valid output formats.
            optional string content_type_accepts = 3;
        }

        oneof mode {
            Json json = 1;
            Text text = 2;
            Binary binary = 3;
        }
    }

    // Response options,
    // by default the entire message will be sent as a response with the content type
    // being `application/json`
    Response response = 9;
}

message OneofOptions {
    // Rename this oneof's name
    optional string rename = 1;
    // Rename all the fields in the oneof.
    optional RenameAll rename_all = 4;

    // Deserialization:
    // This flag dictates how we handle fields which are
    // not provided in the json representation of the message.
    // If this is true, then no error will be returned
    // if the field is not provided.
    // If this is false then not providing a value for this field
    // will result in an error.
    //
    // Serialization:
    // This flag dictates if we should skip serializing the field
    // in the json representation of the message if the field
    // is equal to the default value for its type.
    //
    // By default if the value depends on the type of field.
    // If the field is an option then the default value is
    // `TRUE_BUT_SERIALIZE` which means that the option does not
    // need to be provided but a `null` value will always be serialized.
    // If the field is not an option then it will be required so `FALSE`.
    JsonOmittable json_omittable = 200;

    // This specifies the visibility for oneof fields.
    optional Visibility visibility = 202;

    // Tagging a oneof causes the ser/de to represent it like such
    // {
    //        "tag": "tag",
    //        "content": content
    // }
    message Tagged {
        string tag = 1;
        string content = 2;
    }

    // If you want to use tagged notation this allows you to configure that.
    optional Tagged tagged = 100;
    // You can also flatten the oneof directly into the containing message.
    optional bool flatten = 101;
}