Class: Hatchet::Features::CEL
- Inherits:
-
Object
- Object
- Hatchet::Features::CEL
- Defined in:
- lib/hatchet/features/cel.rb
Overview
CEL client for debugging CEL expressions within Hatchet
This class provides a high-level interface for testing and debugging CEL (Common Expression Language) expressions used in filters and conditions.
Instance Method Summary collapse
-
#debug(expression:, input:, additional_metadata: nil, filter_payload: nil) ⇒ CELEvaluationResult
Debug a CEL expression with provided input and optional metadata.
-
#initialize(rest_client, config) ⇒ void
constructor
Initializes a new CEL client instance.
Constructor Details
#initialize(rest_client, config) ⇒ void
Initializes a new CEL client instance
44 45 46 47 48 |
# File 'lib/hatchet/features/cel.rb', line 44 def initialize(rest_client, config) @rest_client = rest_client @config = config @cel_api = HatchetSdkRest::CELApi.new(rest_client) end |
Instance Method Details
#debug(expression:, input:, additional_metadata: nil, filter_payload: nil) ⇒ CELEvaluationResult
Debug a CEL expression with provided input and optional metadata
Useful for testing and validating CEL expressions and debugging issues in production.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/hatchet/features/cel.rb', line 67 def debug(expression:, input:, additional_metadata: nil, filter_payload: nil) request = HatchetSdkRest::V1CELDebugRequest.new( expression: expression, input: input, additional_metadata: , filter_payload: filter_payload, ) result = @cel_api.v1_cel_debug(@config.tenant_id, request) if ["ERROR", :ERROR].include?(result.status) raise "No error message received from CEL debug API." if result.error.nil? return CELEvaluationResult.new(result: CELFailure.new(error: result.error)) end raise "No output received from CEL debug API." if result.output.nil? CELEvaluationResult.new(result: CELSuccess.new(output: result.output)) end |