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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140
// This file is @generated by prost-build.
/// Represents a CEL value.
///
/// This is similar to `google.protobuf.Value`, but can represent CEL's full
/// range of values.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Value {
/// Required. The valid kinds of values.
#[prost(oneof = "value::Kind", tags = "1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 15")]
pub kind: ::core::option::Option<value::Kind>,
}
/// Nested message and enum types in `Value`.
pub mod value {
/// Required. The valid kinds of values.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
/// Null value.
#[prost(enumeration = "::prost_types::NullValue", tag = "1")]
NullValue(i32),
/// Boolean value.
#[prost(bool, tag = "2")]
BoolValue(bool),
/// Signed integer value.
#[prost(int64, tag = "3")]
Int64Value(i64),
/// Unsigned integer value.
#[prost(uint64, tag = "4")]
Uint64Value(u64),
/// Floating point value.
#[prost(double, tag = "5")]
DoubleValue(f64),
/// UTF-8 string value.
#[prost(string, tag = "6")]
StringValue(::prost::alloc::string::String),
/// Byte string value.
#[prost(bytes, tag = "7")]
BytesValue(::prost::bytes::Bytes),
/// An enum value.
#[prost(message, tag = "9")]
EnumValue(super::EnumValue),
/// The proto message backing an object value.
#[prost(message, tag = "10")]
ObjectValue(::prost_types::Any),
/// Map value.
#[prost(message, tag = "11")]
MapValue(super::MapValue),
/// List value.
#[prost(message, tag = "12")]
ListValue(super::ListValue),
/// Type value.
#[prost(string, tag = "15")]
TypeValue(::prost::alloc::string::String),
}
}
/// An enum value.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EnumValue {
/// The fully qualified name of the enum type.
#[prost(string, tag = "1")]
pub r#type: ::prost::alloc::string::String,
/// The value of the enum.
#[prost(int32, tag = "2")]
pub value: i32,
}
/// A list.
///
/// Wrapped in a message so 'not set' and empty can be differentiated, which is
/// required for use in a 'oneof'.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListValue {
/// The ordered values in the list.
#[prost(message, repeated, tag = "1")]
pub values: ::prost::alloc::vec::Vec<Value>,
}
/// A map.
///
/// Wrapped in a message so 'not set' and empty can be differentiated, which is
/// required for use in a 'oneof'.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MapValue {
/// The set of map entries.
///
/// CEL has fewer restrictions on keys, so a protobuf map represenation
/// cannot be used.
#[prost(message, repeated, tag = "1")]
pub entries: ::prost::alloc::vec::Vec<map_value::Entry>,
}
/// Nested message and enum types in `MapValue`.
pub mod map_value {
/// An entry in the map.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Entry {
/// The key.
///
/// Must be unique with in the map.
/// Currently only boolean, int, uint, and string values can be keys.
#[prost(message, optional, tag = "1")]
pub key: ::core::option::Option<super::Value>,
/// The value.
#[prost(message, optional, tag = "2")]
pub value: ::core::option::Option<super::Value>,
}
}
/// An expression together with source information as returned by the parser.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ParsedExpr {
/// The parsed expression.
#[prost(message, optional, tag = "2")]
pub expr: ::core::option::Option<Expr>,
/// The source info derived from input that generated the parsed `expr`.
#[prost(message, optional, tag = "3")]
pub source_info: ::core::option::Option<SourceInfo>,
}
/// An abstract representation of a common expression.
///
/// Expressions are abstractly represented as a collection of identifiers,
/// select statements, function calls, literals, and comprehensions. All
/// operators with the exception of the '.' operator are modelled as function
/// calls. This makes it easy to represent new operators into the existing AST.
///
/// All references within expressions must resolve to a
/// [Decl][google.api.expr.v1alpha1.Decl] provided at type-check for an
/// expression to be valid. A reference may either be a bare identifier `name` or
/// a qualified identifier `google.api.name`. References may either refer to a
/// value or a function declaration.
///
/// For example, the expression `google.api.name.startsWith('expr')` references
/// the declaration `google.api.name` within a
/// [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and the
/// function declaration `startsWith`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Expr {
/// Required. An id assigned to this node by the parser which is unique in a
/// given expression tree. This is used to associate type information and other
/// attributes to a node in the parse tree.
#[prost(int64, tag = "2")]
pub id: i64,
/// Required. Variants of expressions.
#[prost(oneof = "expr::ExprKind", tags = "3, 4, 5, 6, 7, 8, 9")]
pub expr_kind: ::core::option::Option<expr::ExprKind>,
}
/// Nested message and enum types in `Expr`.
pub mod expr {
/// An identifier expression. e.g. `request`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Ident {
/// Required. Holds a single, unqualified identifier, possibly preceded by a
/// '.'.
///
/// Qualified names are represented by the
/// [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// A field selection expression. e.g. `request.auth`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Select {
/// Required. The target of the selection expression.
///
/// For example, in the select expression `request.auth`, the `request`
/// portion of the expression is the `operand`.
#[prost(message, optional, boxed, tag = "1")]
pub operand: ::core::option::Option<::prost::alloc::boxed::Box<super::Expr>>,
/// Required. The name of the field to select.
///
/// For example, in the select expression `request.auth`, the `auth` portion
/// of the expression would be the `field`.
#[prost(string, tag = "2")]
pub field: ::prost::alloc::string::String,
/// Whether the select is to be interpreted as a field presence test.
///
/// This results from the macro `has(request.auth)`.
#[prost(bool, tag = "3")]
pub test_only: bool,
}
/// A call expression, including calls to predefined functions and operators.
///
/// For example, `value == 10`, `size(map_value)`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Call {
/// The target of an method call-style expression. For example, `x` in
/// `x.f()`.
#[prost(message, optional, boxed, tag = "1")]
pub target: ::core::option::Option<::prost::alloc::boxed::Box<super::Expr>>,
/// Required. The name of the function or method being called.
#[prost(string, tag = "2")]
pub function: ::prost::alloc::string::String,
/// The arguments.
#[prost(message, repeated, tag = "3")]
pub args: ::prost::alloc::vec::Vec<super::Expr>,
}
/// A list creation expression.
///
/// Lists may either be homogenous, e.g. `\[1, 2, 3\]`, or heterogeneous, e.g.
/// `dyn(\[1, 'hello', 2.0\])`
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateList {
/// The elements part of the list.
#[prost(message, repeated, tag = "1")]
pub elements: ::prost::alloc::vec::Vec<super::Expr>,
/// The indices within the elements list which are marked as optional
/// elements.
///
/// When an optional-typed value is present, the value it contains
/// is included in the list. If the optional-typed value is absent, the list
/// element is omitted from the CreateList result.
#[prost(int32, repeated, tag = "2")]
pub optional_indices: ::prost::alloc::vec::Vec<i32>,
}
/// A map or message creation expression.
///
/// Maps are constructed as `{'key_name': 'value'}`. Message construction is
/// similar, but prefixed with a type name and composed of field ids:
/// `types.MyType{field_id: 'value'}`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateStruct {
/// The type name of the message to be created, empty when creating map
/// literals.
#[prost(string, tag = "1")]
pub message_name: ::prost::alloc::string::String,
/// The entries in the creation expression.
#[prost(message, repeated, tag = "2")]
pub entries: ::prost::alloc::vec::Vec<create_struct::Entry>,
}
/// Nested message and enum types in `CreateStruct`.
pub mod create_struct {
/// Represents an entry.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Entry {
/// Required. An id assigned to this node by the parser which is unique
/// in a given expression tree. This is used to associate type
/// information and other attributes to the node.
#[prost(int64, tag = "1")]
pub id: i64,
/// Required. The value assigned to the key.
///
/// If the optional_entry field is true, the expression must resolve to an
/// optional-typed value. If the optional value is present, the key will be
/// set; however, if the optional value is absent, the key will be unset.
#[prost(message, optional, tag = "4")]
pub value: ::core::option::Option<super::super::Expr>,
/// Whether the key-value pair is optional.
#[prost(bool, tag = "5")]
pub optional_entry: bool,
/// The `Entry` key kinds.
#[prost(oneof = "entry::KeyKind", tags = "2, 3")]
pub key_kind: ::core::option::Option<entry::KeyKind>,
}
/// Nested message and enum types in `Entry`.
pub mod entry {
/// The `Entry` key kinds.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum KeyKind {
/// The field key for a message creator statement.
#[prost(string, tag = "2")]
FieldKey(::prost::alloc::string::String),
/// The key expression for a map creation statement.
#[prost(message, tag = "3")]
MapKey(super::super::super::Expr),
}
}
}
/// A comprehension expression applied to a list or map.
///
/// Comprehensions are not part of the core syntax, but enabled with macros.
/// A macro matches a specific call signature within a parsed AST and replaces
/// the call with an alternate AST block. Macro expansion happens at parse
/// time.
///
/// The following macros are supported within CEL:
///
/// Aggregate type macros may be applied to all elements in a list or all keys
/// in a map:
///
/// * `all`, `exists`, `exists_one` - test a predicate expression against
/// the inputs and return `true` if the predicate is satisfied for all,
/// any, or only one value `list.all(x, x < 10)`.
/// * `filter` - test a predicate expression against the inputs and return
/// the subset of elements which satisfy the predicate:
/// `payments.filter(p, p > 1000)`.
/// * `map` - apply an expression to all elements in the input and return the
/// output aggregate type: `\[1, 2, 3\].map(i, i * i)`.
///
/// The `has(m.x)` macro tests whether the property `x` is present in struct
/// `m`. The semantics of this macro depend on the type of `m`. For proto2
/// messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the
/// macro tests whether the property is set to its default. For map and struct
/// types, the macro tests whether the property `x` is defined on `m`.
///
/// Comprehensions for the standard environment macros evaluation can be best
/// visualized as the following pseudocode:
///
/// ```
/// let `accu_var` = `accu_init`
/// for (let `iter_var` in `iter_range`) {
/// if (!`loop_condition`) {
/// break
/// }
/// `accu_var` = `loop_step`
/// }
/// return `result`
/// ```
///
/// Comprehensions for the optional V2 macros which support map-to-map
/// translation differ slightly from the standard environment macros in that
/// they expose both the key or index in addition to the value for each list
/// or map entry:
///
/// ```
/// let `accu_var` = `accu_init`
/// for (let `iter_var`, `iter_var2` in `iter_range`) {
/// if (!`loop_condition`) {
/// break
/// }
/// `accu_var` = `loop_step`
/// }
/// return `result`
/// ```
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Comprehension {
/// The name of the first iteration variable.
/// When the iter_range is a list, this variable is the list element.
/// When the iter_range is a map, this variable is the map entry key.
#[prost(string, tag = "1")]
pub iter_var: ::prost::alloc::string::String,
/// The name of the second iteration variable, empty if not set.
/// When the iter_range is a list, this variable is the integer index.
/// When the iter_range is a map, this variable is the map entry value.
/// This field is only set for comprehension v2 macros.
#[prost(string, tag = "8")]
pub iter_var2: ::prost::alloc::string::String,
/// The range over which the comprehension iterates.
#[prost(message, optional, boxed, tag = "2")]
pub iter_range: ::core::option::Option<::prost::alloc::boxed::Box<super::Expr>>,
/// The name of the variable used for accumulation of the result.
#[prost(string, tag = "3")]
pub accu_var: ::prost::alloc::string::String,
/// The initial value of the accumulator.
#[prost(message, optional, boxed, tag = "4")]
pub accu_init: ::core::option::Option<::prost::alloc::boxed::Box<super::Expr>>,
/// An expression which can contain iter_var, iter_var2, and accu_var.
///
/// Returns false when the result has been computed and may be used as
/// a hint to short-circuit the remainder of the comprehension.
#[prost(message, optional, boxed, tag = "5")]
pub loop_condition: ::core::option::Option<
::prost::alloc::boxed::Box<super::Expr>,
>,
/// An expression which can contain iter_var, iter_var2, and accu_var.
///
/// Computes the next value of accu_var.
#[prost(message, optional, boxed, tag = "6")]
pub loop_step: ::core::option::Option<::prost::alloc::boxed::Box<super::Expr>>,
/// An expression which can contain accu_var.
///
/// Computes the result.
#[prost(message, optional, boxed, tag = "7")]
pub result: ::core::option::Option<::prost::alloc::boxed::Box<super::Expr>>,
}
/// Required. Variants of expressions.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum ExprKind {
/// A literal expression.
#[prost(message, tag = "3")]
ConstExpr(super::Constant),
/// An identifier expression.
#[prost(message, tag = "4")]
IdentExpr(Ident),
/// A field selection expression, e.g. `request.auth`.
#[prost(message, tag = "5")]
SelectExpr(::prost::alloc::boxed::Box<Select>),
/// A call expression, including calls to predefined functions and operators.
#[prost(message, tag = "6")]
CallExpr(::prost::alloc::boxed::Box<Call>),
/// A list creation expression.
#[prost(message, tag = "7")]
ListExpr(CreateList),
/// A map or message creation expression.
#[prost(message, tag = "8")]
StructExpr(CreateStruct),
/// A comprehension expression.
#[prost(message, tag = "9")]
ComprehensionExpr(::prost::alloc::boxed::Box<Comprehension>),
}
}
/// Represents a primitive literal.
///
/// Named 'Constant' here for backwards compatibility.
///
/// This is similar as the primitives supported in the well-known type
/// `google.protobuf.Value`, but richer so it can represent CEL's full range of
/// primitives.
///
/// Lists and structs are not included as constants as these aggregate types may
/// contain [Expr][google.api.expr.v1alpha1.Expr] elements which require
/// evaluation and are thus not constant.
///
/// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`,
/// `true`, `null`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Constant {
/// Required. The valid constant kinds.
#[prost(oneof = "constant::ConstantKind", tags = "1, 2, 3, 4, 5, 6, 7, 8, 9")]
pub constant_kind: ::core::option::Option<constant::ConstantKind>,
}
/// Nested message and enum types in `Constant`.
pub mod constant {
/// Required. The valid constant kinds.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum ConstantKind {
/// null value.
#[prost(enumeration = "::prost_types::NullValue", tag = "1")]
NullValue(i32),
/// boolean value.
#[prost(bool, tag = "2")]
BoolValue(bool),
/// int64 value.
#[prost(int64, tag = "3")]
Int64Value(i64),
/// uint64 value.
#[prost(uint64, tag = "4")]
Uint64Value(u64),
/// double value.
#[prost(double, tag = "5")]
DoubleValue(f64),
/// string value.
#[prost(string, tag = "6")]
StringValue(::prost::alloc::string::String),
/// bytes value.
#[prost(bytes, tag = "7")]
BytesValue(::prost::bytes::Bytes),
/// protobuf.Duration value.
///
/// Deprecated: duration is no longer considered a builtin cel type.
#[prost(message, tag = "8")]
DurationValue(::prost_types::Duration),
/// protobuf.Timestamp value.
///
/// Deprecated: timestamp is no longer considered a builtin cel type.
#[prost(message, tag = "9")]
TimestampValue(::prost_types::Timestamp),
}
}
/// Source information collected at parse time.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SourceInfo {
/// The syntax version of the source, e.g. `cel1`.
#[prost(string, tag = "1")]
pub syntax_version: ::prost::alloc::string::String,
/// The location name. All position information attached to an expression is
/// relative to this location.
///
/// The location could be a file, UI element, or similar. For example,
/// `acme/app/AnvilPolicy.cel`.
#[prost(string, tag = "2")]
pub location: ::prost::alloc::string::String,
/// Monotonically increasing list of code point offsets where newlines
/// `\n` appear.
///
/// The line number of a given position is the index `i` where for a given
/// `id` the `line_offsets\[i\] < id_positions\[id\] < line_offsets\[i+1\]`. The
/// column may be derivd from `id_positions\[id\] - line_offsets\[i\]`.
#[prost(int32, repeated, tag = "3")]
pub line_offsets: ::prost::alloc::vec::Vec<i32>,
/// A map from the parse node id (e.g. `Expr.id`) to the code point offset
/// within the source.
#[prost(btree_map = "int64, int32", tag = "4")]
pub positions: ::prost::alloc::collections::BTreeMap<i64, i32>,
/// A map from the parse node id where a macro replacement was made to the
/// call `Expr` that resulted in a macro expansion.
///
/// For example, `has(value.field)` is a function call that is replaced by a
/// `test_only` field selection in the AST. Likewise, the call
/// `list.exists(e, e > 10)` translates to a comprehension expression. The key
/// in the map corresponds to the expression id of the expanded macro, and the
/// value is the call `Expr` that was replaced.
#[prost(btree_map = "int64, message", tag = "5")]
pub macro_calls: ::prost::alloc::collections::BTreeMap<i64, Expr>,
/// A list of tags for extensions that were used while parsing or type checking
/// the source expression. For example, optimizations that require special
/// runtime support may be specified.
///
/// These are used to check feature support between components in separate
/// implementations. This can be used to either skip redundant work or
/// report an error if the extension is unsupported.
#[prost(message, repeated, tag = "6")]
pub extensions: ::prost::alloc::vec::Vec<source_info::Extension>,
}
/// Nested message and enum types in `SourceInfo`.
pub mod source_info {
/// An extension that was requested for the source expression.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Extension {
/// Identifier for the extension. Example: constant_folding
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
/// If set, the listed components must understand the extension for the
/// expression to evaluate correctly.
///
/// This field has set semantics, repeated values should be deduplicated.
#[prost(enumeration = "extension::Component", repeated, tag = "2")]
pub affected_components: ::prost::alloc::vec::Vec<i32>,
/// Version info. May be skipped if it isn't meaningful for the extension.
/// (for example constant_folding might always be v0.0).
#[prost(message, optional, tag = "3")]
pub version: ::core::option::Option<extension::Version>,
}
/// Nested message and enum types in `Extension`.
pub mod extension {
/// Version
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Version {
/// Major version changes indicate different required support level from
/// the required components.
#[prost(int64, tag = "1")]
pub major: i64,
/// Minor version changes must not change the observed behavior from
/// existing implementations, but may be provided informationally.
#[prost(int64, tag = "2")]
pub minor: i64,
}
/// CEL component specifier.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Component {
/// Unspecified, default.
Unspecified = 0,
/// Parser. Converts a CEL string to an AST.
Parser = 1,
/// Type checker. Checks that references in an AST are defined and types
/// agree.
TypeChecker = 2,
/// Runtime. Evaluates a parsed and optionally checked CEL AST against a
/// context.
Runtime = 3,
}
impl Component {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Component::Unspecified => "COMPONENT_UNSPECIFIED",
Component::Parser => "COMPONENT_PARSER",
Component::TypeChecker => "COMPONENT_TYPE_CHECKER",
Component::Runtime => "COMPONENT_RUNTIME",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"COMPONENT_UNSPECIFIED" => Some(Self::Unspecified),
"COMPONENT_PARSER" => Some(Self::Parser),
"COMPONENT_TYPE_CHECKER" => Some(Self::TypeChecker),
"COMPONENT_RUNTIME" => Some(Self::Runtime),
_ => None,
}
}
}
}
}
/// A specific position in source.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SourcePosition {
/// The soucre location name (e.g. file name).
#[prost(string, tag = "1")]
pub location: ::prost::alloc::string::String,
/// The UTF-8 code unit offset.
#[prost(int32, tag = "2")]
pub offset: i32,
/// The 1-based index of the starting line in the source text
/// where the issue occurs, or 0 if unknown.
#[prost(int32, tag = "3")]
pub line: i32,
/// The 0-based index of the starting position within the line of source text
/// where the issue occurs. Only meaningful if line is nonzero.
#[prost(int32, tag = "4")]
pub column: i32,
}
/// A CEL expression which has been successfully type checked.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CheckedExpr {
/// A map from expression ids to resolved references.
///
/// The following entries are in this table:
///
/// - An Ident or Select expression is represented here if it resolves to a
/// declaration. For instance, if `a.b.c` is represented by
/// `select(select(id(a), b), c)`, and `a.b` resolves to a declaration,
/// while `c` is a field selection, then the reference is attached to the
/// nested select expression (but not to the id or or the outer select).
/// In turn, if `a` resolves to a declaration and `b.c` are field selections,
/// the reference is attached to the ident expression.
/// - Every Call expression has an entry here, identifying the function being
/// called.
/// - Every CreateStruct expression for a message has an entry, identifying
/// the message.
#[prost(btree_map = "int64, message", tag = "2")]
pub reference_map: ::prost::alloc::collections::BTreeMap<i64, Reference>,
/// A map from expression ids to types.
///
/// Every expression node which has a type different than DYN has a mapping
/// here. If an expression has type DYN, it is omitted from this map to save
/// space.
#[prost(btree_map = "int64, message", tag = "3")]
pub type_map: ::prost::alloc::collections::BTreeMap<i64, Type>,
/// The source info derived from input that generated the parsed `expr` and
/// any optimizations made during the type-checking pass.
#[prost(message, optional, tag = "5")]
pub source_info: ::core::option::Option<SourceInfo>,
/// The expr version indicates the major / minor version number of the `expr`
/// representation.
///
/// The most common reason for a version change will be to indicate to the CEL
/// runtimes that transformations have been performed on the expr during static
/// analysis. In some cases, this will save the runtime the work of applying
/// the same or similar transformations prior to evaluation.
#[prost(string, tag = "6")]
pub expr_version: ::prost::alloc::string::String,
/// The checked expression. Semantically equivalent to the parsed `expr`, but
/// may have structural differences.
#[prost(message, optional, tag = "4")]
pub expr: ::core::option::Option<Expr>,
}
/// Represents a CEL type.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Type {
/// The kind of type.
#[prost(
oneof = "r#type::TypeKind",
tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14"
)]
pub type_kind: ::core::option::Option<r#type::TypeKind>,
}
/// Nested message and enum types in `Type`.
pub mod r#type {
/// List type with typed elements, e.g. `list<example.proto.MyMessage>`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListType {
/// The element type.
#[prost(message, optional, boxed, tag = "1")]
pub elem_type: ::core::option::Option<::prost::alloc::boxed::Box<super::Type>>,
}
/// Map type with parameterized key and value types, e.g. `map<string, int>`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MapType {
/// The type of the key.
#[prost(message, optional, boxed, tag = "1")]
pub key_type: ::core::option::Option<::prost::alloc::boxed::Box<super::Type>>,
/// The type of the value.
#[prost(message, optional, boxed, tag = "2")]
pub value_type: ::core::option::Option<::prost::alloc::boxed::Box<super::Type>>,
}
/// Function type with result and arg types.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FunctionType {
/// Result type of the function.
#[prost(message, optional, boxed, tag = "1")]
pub result_type: ::core::option::Option<::prost::alloc::boxed::Box<super::Type>>,
/// Argument types of the function.
#[prost(message, repeated, tag = "2")]
pub arg_types: ::prost::alloc::vec::Vec<super::Type>,
}
/// Application defined abstract type.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AbstractType {
/// The fully qualified name of this abstract type.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Parameter types for this abstract type.
#[prost(message, repeated, tag = "2")]
pub parameter_types: ::prost::alloc::vec::Vec<super::Type>,
}
/// CEL primitive types.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum PrimitiveType {
/// Unspecified type.
Unspecified = 0,
/// Boolean type.
Bool = 1,
/// Int64 type.
///
/// Proto-based integer values are widened to int64.
Int64 = 2,
/// Uint64 type.
///
/// Proto-based unsigned integer values are widened to uint64.
Uint64 = 3,
/// Double type.
///
/// Proto-based float values are widened to double values.
Double = 4,
/// String type.
String = 5,
/// Bytes type.
Bytes = 6,
}
impl PrimitiveType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
PrimitiveType::Unspecified => "PRIMITIVE_TYPE_UNSPECIFIED",
PrimitiveType::Bool => "BOOL",
PrimitiveType::Int64 => "INT64",
PrimitiveType::Uint64 => "UINT64",
PrimitiveType::Double => "DOUBLE",
PrimitiveType::String => "STRING",
PrimitiveType::Bytes => "BYTES",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"PRIMITIVE_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"BOOL" => Some(Self::Bool),
"INT64" => Some(Self::Int64),
"UINT64" => Some(Self::Uint64),
"DOUBLE" => Some(Self::Double),
"STRING" => Some(Self::String),
"BYTES" => Some(Self::Bytes),
_ => None,
}
}
}
/// Well-known protobuf types treated with first-class support in CEL.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum WellKnownType {
/// Unspecified type.
Unspecified = 0,
/// Well-known protobuf.Any type.
///
/// Any types are a polymorphic message type. During type-checking they are
/// treated like `DYN` types, but at runtime they are resolved to a specific
/// message type specified at evaluation time.
Any = 1,
/// Well-known protobuf.Timestamp type, internally referenced as `timestamp`.
Timestamp = 2,
/// Well-known protobuf.Duration type, internally referenced as `duration`.
Duration = 3,
}
impl WellKnownType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
WellKnownType::Unspecified => "WELL_KNOWN_TYPE_UNSPECIFIED",
WellKnownType::Any => "ANY",
WellKnownType::Timestamp => "TIMESTAMP",
WellKnownType::Duration => "DURATION",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"WELL_KNOWN_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"ANY" => Some(Self::Any),
"TIMESTAMP" => Some(Self::Timestamp),
"DURATION" => Some(Self::Duration),
_ => None,
}
}
}
/// The kind of type.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum TypeKind {
/// Dynamic type.
#[prost(message, tag = "1")]
Dyn(()),
/// Null value.
#[prost(enumeration = "::prost_types::NullValue", tag = "2")]
Null(i32),
/// Primitive types: `true`, `1u`, `-2.0`, `'string'`, `b'bytes'`.
#[prost(enumeration = "PrimitiveType", tag = "3")]
Primitive(i32),
/// Wrapper of a primitive type, e.g. `google.protobuf.Int64Value`.
#[prost(enumeration = "PrimitiveType", tag = "4")]
Wrapper(i32),
/// Well-known protobuf type such as `google.protobuf.Timestamp`.
#[prost(enumeration = "WellKnownType", tag = "5")]
WellKnown(i32),
/// Parameterized list with elements of `list_type`, e.g. `list<timestamp>`.
#[prost(message, tag = "6")]
ListType(::prost::alloc::boxed::Box<ListType>),
/// Parameterized map with typed keys and values.
#[prost(message, tag = "7")]
MapType(::prost::alloc::boxed::Box<MapType>),
/// Function type.
#[prost(message, tag = "8")]
Function(::prost::alloc::boxed::Box<FunctionType>),
/// Protocol buffer message type.
///
/// The `message_type` string specifies the qualified message type name. For
/// example, `google.plus.Profile`.
#[prost(string, tag = "9")]
MessageType(::prost::alloc::string::String),
/// Type param type.
///
/// The `type_param` string specifies the type parameter name, e.g. `list<E>`
/// would be a `list_type` whose element type was a `type_param` type
/// named `E`.
#[prost(string, tag = "10")]
TypeParam(::prost::alloc::string::String),
/// Type type.
///
/// The `type` value specifies the target type. e.g. int is type with a
/// target type of `Primitive.INT`.
#[prost(message, tag = "11")]
Type(::prost::alloc::boxed::Box<super::Type>),
/// Error type.
///
/// During type-checking if an expression is an error, its type is propagated
/// as the `ERROR` type. This permits the type-checker to discover other
/// errors present in the expression.
#[prost(message, tag = "12")]
Error(()),
/// Abstract, application defined type.
#[prost(message, tag = "14")]
AbstractType(AbstractType),
}
}
/// Represents a declaration of a named value or function.
///
/// A declaration is part of the contract between the expression, the agent
/// evaluating that expression, and the caller requesting evaluation.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Decl {
/// The fully qualified name of the declaration.
///
/// Declarations are organized in containers and this represents the full path
/// to the declaration in its container, as in `google.api.expr.Decl`.
///
/// Declarations used as
/// [FunctionDecl.Overload][google.api.expr.v1alpha1.Decl.FunctionDecl.Overload]
/// parameters may or may not have a name depending on whether the overload is
/// function declaration or a function definition containing a result
/// [Expr][google.api.expr.v1alpha1.Expr].
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Required. The declaration kind.
#[prost(oneof = "decl::DeclKind", tags = "2, 3")]
pub decl_kind: ::core::option::Option<decl::DeclKind>,
}
/// Nested message and enum types in `Decl`.
pub mod decl {
/// Identifier declaration which specifies its type and optional `Expr` value.
///
/// An identifier without a value is a declaration that must be provided at
/// evaluation time. An identifier with a value should resolve to a constant,
/// but may be used in conjunction with other identifiers bound at evaluation
/// time.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IdentDecl {
/// Required. The type of the identifier.
#[prost(message, optional, tag = "1")]
pub r#type: ::core::option::Option<super::Type>,
/// The constant value of the identifier. If not specified, the identifier
/// must be supplied at evaluation time.
#[prost(message, optional, tag = "2")]
pub value: ::core::option::Option<super::Constant>,
/// Documentation string for the identifier.
#[prost(string, tag = "3")]
pub doc: ::prost::alloc::string::String,
}
/// Function declaration specifies one or more overloads which indicate the
/// function's parameter types and return type.
///
/// Functions have no observable side-effects (there may be side-effects like
/// logging which are not observable from CEL).
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FunctionDecl {
/// Required. List of function overloads, must contain at least one overload.
#[prost(message, repeated, tag = "1")]
pub overloads: ::prost::alloc::vec::Vec<function_decl::Overload>,
}
/// Nested message and enum types in `FunctionDecl`.
pub mod function_decl {
/// An overload indicates a function's parameter types and return type, and
/// may optionally include a function body described in terms of
/// [Expr][google.api.expr.v1alpha1.Expr] values.
///
/// Functions overloads are declared in either a function or method
/// call-style. For methods, the `params\[0\]` is the expected type of the
/// target receiver.
///
/// Overloads must have non-overlapping argument types after erasure of all
/// parameterized type variables (similar as type erasure in Java).
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Overload {
/// Required. Globally unique overload name of the function which reflects
/// the function name and argument types.
///
/// This will be used by a [Reference][google.api.expr.v1alpha1.Reference]
/// to indicate the `overload_id` that was resolved for the function
/// `name`.
#[prost(string, tag = "1")]
pub overload_id: ::prost::alloc::string::String,
/// List of function parameter [Type][google.api.expr.v1alpha1.Type]
/// values.
///
/// Param types are disjoint after generic type parameters have been
/// replaced with the type `DYN`. Since the `DYN` type is compatible with
/// any other type, this means that if `A` is a type parameter, the
/// function types `int<A>` and `int<int>` are not disjoint. Likewise,
/// `map<string, string>` is not disjoint from `map<K, V>`.
///
/// When the `result_type` of a function is a generic type param, the
/// type param name also appears as the `type` of on at least one params.
#[prost(message, repeated, tag = "2")]
pub params: ::prost::alloc::vec::Vec<super::super::Type>,
/// The type param names associated with the function declaration.
///
/// For example, `function ex<K,V>(K key, map<K, V> map) : V` would yield
/// the type params of `K, V`.
#[prost(string, repeated, tag = "3")]
pub type_params: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Required. The result type of the function. For example, the operator
/// `string.isEmpty()` would have `result_type` of `kind: BOOL`.
#[prost(message, optional, tag = "4")]
pub result_type: ::core::option::Option<super::super::Type>,
/// Whether the function is to be used in a method call-style `x.f(...)`
/// or a function call-style `f(x, ...)`.
///
/// For methods, the first parameter declaration, `params\[0\]` is the
/// expected type of the target receiver.
#[prost(bool, tag = "5")]
pub is_instance_function: bool,
/// Documentation string for the overload.
#[prost(string, tag = "6")]
pub doc: ::prost::alloc::string::String,
}
}
/// Required. The declaration kind.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum DeclKind {
/// Identifier declaration.
#[prost(message, tag = "2")]
Ident(IdentDecl),
/// Function declaration.
#[prost(message, tag = "3")]
Function(FunctionDecl),
}
}
/// Describes a resolved reference to a declaration.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Reference {
/// The fully qualified name of the declaration.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// For references to functions, this is a list of `Overload.overload_id`
/// values which match according to typing rules.
///
/// If the list has more than one element, overload resolution among the
/// presented candidates must happen at runtime because of dynamic types. The
/// type checker attempts to narrow down this list as much as possible.
///
/// Empty if this is not a reference to a
/// [Decl.FunctionDecl][google.api.expr.v1alpha1.Decl.FunctionDecl].
#[prost(string, repeated, tag = "3")]
pub overload_id: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// For references to constants, this may contain the value of the
/// constant if known at compile time.
#[prost(message, optional, tag = "4")]
pub value: ::core::option::Option<Constant>,
}
/// The state of an evaluation.
///
/// Can represent an inital, partial, or completed state of evaluation.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EvalState {
/// The unique values referenced in this message.
#[prost(message, repeated, tag = "1")]
pub values: ::prost::alloc::vec::Vec<ExprValue>,
/// An ordered list of results.
///
/// Tracks the flow of evaluation through the expression.
/// May be sparse.
#[prost(message, repeated, tag = "3")]
pub results: ::prost::alloc::vec::Vec<eval_state::Result>,
}
/// Nested message and enum types in `EvalState`.
pub mod eval_state {
/// A single evalution result.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Result {
/// The id of the expression this result if for.
#[prost(int64, tag = "1")]
pub expr: i64,
/// The index in `values` of the resulting value.
#[prost(int64, tag = "2")]
pub value: i64,
}
}
/// The value of an evaluated expression.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExprValue {
/// An expression can resolve to a value, error or unknown.
#[prost(oneof = "expr_value::Kind", tags = "1, 2, 3")]
pub kind: ::core::option::Option<expr_value::Kind>,
}
/// Nested message and enum types in `ExprValue`.
pub mod expr_value {
/// An expression can resolve to a value, error or unknown.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
/// A concrete value.
#[prost(message, tag = "1")]
Value(super::Value),
/// The set of errors in the critical path of evalution.
///
/// Only errors in the critical path are included. For example,
/// `(<error1> || true) && <error2>` will only result in `<error2>`,
/// while `<error1> || <error2>` will result in both `<error1>` and
/// `<error2>`.
///
/// Errors cause by the presence of other errors are not included in the
/// set. For example `<error1>.foo`, `foo(<error1>)`, and `<error1> + 1` will
/// only result in `<error1>`.
///
/// Multiple errors *might* be included when evaluation could result
/// in different errors. For example `<error1> + <error2>` and
/// `foo(<error1>, <error2>)` may result in `<error1>`, `<error2>` or both.
/// The exact subset of errors included for this case is unspecified and
/// depends on the implementation details of the evaluator.
#[prost(message, tag = "2")]
Error(super::ErrorSet),
/// The set of unknowns in the critical path of evaluation.
///
/// Unknown behaves identically to Error with regards to propagation.
/// Specifically, only unknowns in the critical path are included, unknowns
/// caused by the presence of other unknowns are not included, and multiple
/// unknowns *might* be included included when evaluation could result in
/// different unknowns. For example:
///
/// (<unknown\[1\]> || true) && <unknown\[2\]> -> <unknown\[2\]>
/// <unknown\[1\]> || <unknown\[2\]> -> <unknown\[1,2\]>
/// <unknown\[1\]>.foo -> <unknown\[1\]>
/// foo(<unknown\[1\]>) -> <unknown\[1\]>
/// <unknown\[1\]> + <unknown\[2\]> -> <unknown\[1\]> or <unknown[2[>
///
/// Unknown takes precidence over Error in cases where a `Value` can short
/// circuit the result:
///
/// <error> || <unknown> -> <unknown>
/// <error> && <unknown> -> <unknown>
///
/// Errors take precidence in all other cases:
///
/// <unknown> + <error> -> <error>
/// foo(<unknown>, <error>) -> <error>
#[prost(message, tag = "3")]
Unknown(super::UnknownSet),
}
}
/// A set of errors.
///
/// The errors included depend on the context. See `ExprValue.error`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ErrorSet {
/// The errors in the set.
#[prost(message, repeated, tag = "1")]
pub errors: ::prost::alloc::vec::Vec<super::super::super::rpc::Status>,
}
/// A set of expressions for which the value is unknown.
///
/// The unknowns included depend on the context. See `ExprValue.unknown`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UnknownSet {
/// The ids of the expressions with unknown values.
#[prost(int64, repeated, tag = "1")]
pub exprs: ::prost::alloc::vec::Vec<i64>,
}
/// Values of intermediate expressions produced when evaluating expression.
/// Deprecated, use `EvalState` instead.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Explain {
/// All of the observed values.
///
/// The field value_index is an index in the values list.
/// Separating values from steps is needed to remove redundant values.
#[prost(message, repeated, tag = "1")]
pub values: ::prost::alloc::vec::Vec<Value>,
/// List of steps.
///
/// Repeated evaluations of the same expression generate new ExprStep
/// instances. The order of such ExprStep instances matches the order of
/// elements returned by Comprehension.iter_range.
#[prost(message, repeated, tag = "2")]
pub expr_steps: ::prost::alloc::vec::Vec<explain::ExprStep>,
}
/// Nested message and enum types in `Explain`.
pub mod explain {
/// ID and value index of one step.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ExprStep {
/// ID of corresponding Expr node.
#[prost(int64, tag = "1")]
pub id: i64,
/// Index of the value in the values list.
#[prost(int32, tag = "2")]
pub value_index: i32,
}
}