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