conformance_service.proto 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.api.expr.v1alpha1;
  16. import "google/api/expr/v1alpha1/checked.proto";
  17. import "google/api/expr/v1alpha1/eval.proto";
  18. import "google/api/expr/v1alpha1/syntax.proto";
  19. import "google/rpc/status.proto";
  20. option cc_enable_arenas = true;
  21. option go_package = "google.golang.org/genproto/googleapis/api/expr/conformance/v1alpha1;confpb";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "ConformanceServiceProto";
  24. option java_package = "com.google.api.expr.v1alpha1";
  25. // Access a CEL implementation from another process or machine.
  26. // A CEL implementation is decomposed as a parser, a static checker,
  27. // and an evaluator. Every CEL implementation is expected to provide
  28. // a server for this API. The API will be used for conformance testing
  29. // and other utilities.
  30. service ConformanceService {
  31. // Transforms CEL source text into a parsed representation.
  32. rpc Parse(ParseRequest) returns (ParseResponse) {
  33. }
  34. // Runs static checks on a parsed CEL representation and return
  35. // an annotated representation, or a set of issues.
  36. rpc Check(CheckRequest) returns (CheckResponse) {
  37. }
  38. // Evaluates a parsed or annotation CEL representation given
  39. // values of external bindings.
  40. rpc Eval(EvalRequest) returns (EvalResponse) {
  41. }
  42. }
  43. // Request message for the Parse method.
  44. message ParseRequest {
  45. // Required. Source text in CEL syntax.
  46. string cel_source = 1;
  47. // Tag for version of CEL syntax, for future use.
  48. string syntax_version = 2;
  49. // File or resource for source text, used in [SourceInfo][google.api.expr.v1alpha1.SourceInfo].
  50. string source_location = 3;
  51. // Prevent macro expansion. See "Macros" in Language Defiinition.
  52. bool disable_macros = 4;
  53. }
  54. // Response message for the Parse method.
  55. message ParseResponse {
  56. // The parsed representation, or unset if parsing failed.
  57. ParsedExpr parsed_expr = 1;
  58. // Any number of issues with [StatusDetails][] as the details.
  59. repeated google.rpc.Status issues = 2;
  60. }
  61. // Request message for the Check method.
  62. message CheckRequest {
  63. // Required. The parsed representation of the CEL program.
  64. ParsedExpr parsed_expr = 1;
  65. // Declarations of types for external variables and functions.
  66. // Required if program uses external variables or functions
  67. // not in the default environment.
  68. repeated Decl type_env = 2;
  69. // The protocol buffer context. See "Name Resolution" in the
  70. // Language Definition.
  71. string container = 3;
  72. // If true, use only the declarations in [type_env][google.api.expr.v1alpha1.CheckRequest.type_env]. If false (default),
  73. // add declarations for the standard definitions to the type environment. See
  74. // "Standard Definitions" in the Language Definition.
  75. bool no_std_env = 4;
  76. }
  77. // Response message for the Check method.
  78. message CheckResponse {
  79. // The annotated representation, or unset if checking failed.
  80. CheckedExpr checked_expr = 1;
  81. // Any number of issues with [StatusDetails][] as the details.
  82. repeated google.rpc.Status issues = 2;
  83. }
  84. // Request message for the Eval method.
  85. message EvalRequest {
  86. // Required. Either the parsed or annotated representation of the CEL program.
  87. oneof expr_kind {
  88. // Evaluate based on the parsed representation.
  89. ParsedExpr parsed_expr = 1;
  90. // Evaluate based on the checked representation.
  91. CheckedExpr checked_expr = 2;
  92. }
  93. // Bindings for the external variables. The types SHOULD be compatible
  94. // with the type environment in [CheckRequest][google.api.expr.v1alpha1.CheckRequest], if checked.
  95. map<string, ExprValue> bindings = 3;
  96. // SHOULD be the same container as used in [CheckRequest][google.api.expr.v1alpha1.CheckRequest], if checked.
  97. string container = 4;
  98. }
  99. // Response message for the Eval method.
  100. message EvalResponse {
  101. // The execution result, or unset if execution couldn't start.
  102. ExprValue result = 1;
  103. // Any number of issues with [StatusDetails][] as the details.
  104. // Note that CEL execution errors are reified into [ExprValue][google.api.expr.v1alpha1.ExprValue].
  105. // Nevertheless, we'll allow out-of-band issues to be raised,
  106. // which also makes the replies more regular.
  107. repeated google.rpc.Status issues = 2;
  108. }
  109. // Warnings or errors in service execution are represented by
  110. // [google.rpc.Status][google.rpc.Status] messages, with the following message
  111. // in the details field.
  112. message IssueDetails {
  113. // Severities of issues.
  114. enum Severity {
  115. // An unspecified severity.
  116. SEVERITY_UNSPECIFIED = 0;
  117. // Deprecation issue for statements and method that may no longer be
  118. // supported or maintained.
  119. DEPRECATION = 1;
  120. // Warnings such as: unused variables.
  121. WARNING = 2;
  122. // Errors such as: unmatched curly braces or variable redefinition.
  123. ERROR = 3;
  124. }
  125. // The severity of the issue.
  126. Severity severity = 1;
  127. // Position in the source, if known.
  128. SourcePosition position = 2;
  129. // Expression ID from [Expr][google.api.expr.v1alpha1.Expr], 0 if unknown.
  130. int64 id = 3;
  131. }