conformance_service.proto 5.7 KB

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