-
-

API

-

Details of the CEL-Python implementation and the API to the various components.

+
+

API Reference

+

Detailed reference material for the CEL-Python implementation.

The following modules are described here:

adapter

-

Converts some Python-native types into CEL structures.

+

Adapters to convert some Python-native types into CEL structures.

Currently, atomic Python objects have direct use of types in celpy.celtypes.

Non-atomic Python objects are characterized by JSON and Protobuf messages. This module has functions to convert JSON objects to CEL.

@@ -479,8 +539,57 @@
celpy.adapter.json_to_cel(document: Dict[str, Any] | List[Any] | bool | float | int | str | None) BoolType | BytesType | DoubleType | DurationType | IntType | ListType | MapType | None | StringType | TimestampType | UintType[source]
-

Convert parsed JSON object from Python to CEL to the extent possible.

-

It’s difficult to distinguish strings which should be timestamps or durations.

+

Converts parsed JSON object from Python to CEL to the extent possible.

+

Note that it’s difficult to distinguish strings which should be timestamps or durations. +Using the json package objecthook can help do these conversions.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

python

CEL

bool

celpy.celtypes.BoolType

float

celpy.celtypes.DoubleType

int

celpy.celtypes.IntType

str

celpy.celtypes.StringType

None

None

tuple, list

celpy.celtypes.ListType

dict

celpy.celtypes.MapType

datetime.datetime

celpy.celtypes.TimestampType

datetime.timedelta

celpy.celtypes.DurationType

+
+
Parameters:
+

document – A JSON document.

+
+
Returns:
+

celpy.celtypes.Value.

+
+
Raises:
+

internal ValueError or TypeError for failed conversions.

+
+
+

Example:

>>> from pprint import pprint
 >>> from celpy.adapter import json_to_cel
 >>> doc = json.loads('["str", 42, 3.14, null, true, {"hello": "world"}]')
@@ -1365,9 +1474,20 @@ 

Name Resolution evaluate(context: Mapping[str, BoolType | BytesType | DoubleType | DurationType | IntType | ListType | MapType | None | StringType | TimestampType | UintType | CELEvalError | Type[BoolType] | Type[BytesType] | Type[DoubleType] | Type[DurationType] | Type[IntType] | Type[ListType] | Type[MapType] | Callable[[...], None] | Type[StringType] | Type[TimestampType] | Type[TypeType] | Type[UintType] | Type[PackageType] | Type[MessageType] | NameContainer | CELFunction], filter: Any | None = None) BoolType | BytesType | DoubleType | DurationType | IntType | ListType | MapType | None | StringType | TimestampType | UintType[source]

Given variable definitions in the celpy.evaluation.Context, evaluate the given AST and return the resulting value.

-

Generally, this should raise an CELEvalError for most kinds of ordinary problems. -It may raise an CELUnsupportedError for future features that aren’t fully implemented. +

Generally, this should raise an celpy.evaluation.CELEvalError for most kinds of ordinary problems. +It may raise an celpy.evaluation.CELUnsupportedError for future features that aren’t fully implemented. Any Python exception reflects a serious problem.

+
+
Parameters:
+

activation – a celpy.evaluation.Context object with variable values to use for this evaluation.

+
+
Returns:
+

the computed value

+
+
Raises:
+

celpy.evaluation.CELEvalError or celpy.evaluation.CELUnsupportedError for problems encounterd.

+
+

@@ -2909,7 +3029,8 @@

Timzone Details
celpy.evaluation.function_matches(text: str, pattern: str) Result[source]
-

+

Implementation of the match() function using re2

+
@@ -4651,11 +4772,6 @@

Timzone Details__init__(facade: Transpiler) None[source]

-
-
-__parameters__ = ()
-
-
expr(tree: TranspilerTree) None[source]
@@ -4663,6 +4779,11 @@

Timzone Details +
+__parameters__ = ()
+

+
conditionalor(tree: TranspilerTree) None
@@ -4773,7 +4894,7 @@

CEL in Python

  • Configuration
  • Application Integration
  • Architecture and Design
  • -
  • API
      +
    • API Reference
      • celpy
      • __main__
      • adapter
      • diff --git a/docs/build/html/c7n_functions.html b/docs/build/html/c7n_functions.html index 951ab8b..73d7d37 100644 --- a/docs/build/html/c7n_functions.html +++ b/docs/build/html/c7n_functions.html @@ -14,7 +14,7 @@ - + @@ -230,14 +230,14 @@

        Design Principles

  • -
  • C7N Extension functions can rely on a global C7N object. This is the celpy.c7nlib.C7NContext instance +

  • C7N Extension functions can rely on a global C7N object. This is the celpy.c7nlib.C7NContext instance used to manage C7N CEL Execution. It generally has one attribute, filter which is the current CELFilter instance.

  • C7N Context Object

    -

    A global C7N object in the celpy.c7nlib module contains a reference to the current CELFilter instance. +

    A global C7N object in the celpy.c7nlib module contains a reference to the current CELFilter instance. This has a single attribite.