sift_client.resources.user_defined_functions
¶
| CLASS | DESCRIPTION |
|---|---|
UserDefinedFunctionVersionsAPIAsync |
High-level API for a function's version history. |
UserDefinedFunctionsAPIAsync |
High-level API for interacting with user-defined functions. |
UserDefinedFunctionVersionsAPIAsync
¶
UserDefinedFunctionVersionsAPIAsync(
sift_client: SiftClient,
)
Bases: ResourceBase
High-level API for a function's version history.
Every save produces a new version. Reachable as
client.user_defined_functions.versions.
Initialize the UserDefinedFunctionVersionsAPI.
| PARAMETER | DESCRIPTION |
|---|---|
sift_client
|
The Sift client to use.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
get |
Get one version. |
list_ |
List a function's versions. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
client |
TYPE:
|
grpc_client |
TYPE:
|
rest_client |
TYPE:
|
get
async
¶
get(version_id: str) -> UserDefinedFunction
Get one version.
| PARAMETER | DESCRIPTION |
|---|---|
version_id
|
The ID of the version.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunction
|
The function at that version. |
list_
async
¶
list_(
*,
function: str | UserDefinedFunction | None = None,
name: str | None = None,
version: int | None = None,
include_archived: bool = False,
filter_query: str | None = None,
order_by: str | None = None,
limit: int | None = None,
page_size: int | None = None,
) -> list[UserDefinedFunction]
List a function's versions.
| PARAMETER | DESCRIPTION |
|---|---|
function
|
The UserDefinedFunction or function ID whose versions to list.
TYPE:
|
name
|
The function name, as an alternative to
TYPE:
|
version
|
Filter to a single version number.
TYPE:
|
include_archived
|
If True, include archived versions in results.
TYPE:
|
filter_query
|
Explicit CEL query to filter versions.
TYPE:
|
order_by
|
Field and direction to order results by.
TYPE:
|
limit
|
Maximum number of versions to return. If None, returns all matches.
TYPE:
|
page_size
|
Number of results to fetch per request.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[UserDefinedFunction]
|
A list of UserDefinedFunction objects, one per version. |
UserDefinedFunctionsAPIAsync
¶
UserDefinedFunctionsAPIAsync(sift_client: SiftClient)
Bases: ResourceBase
High-level API for interacting with user-defined functions.
A user-defined function is a named expression that calculated channels and rules can call. Every save produces a new version.
Initialize the UserDefinedFunctionsAPI.
| PARAMETER | DESCRIPTION |
|---|---|
sift_client
|
The Sift client to use.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
get |
Get a UserDefinedFunction. |
list_ |
List user-defined functions. |
find |
Find one function. Takes the same arguments as |
create |
Create a new function. |
update |
Update a function. This creates a new version. |
sync |
Create or update each function so Sift matches the definitions given. |
validate |
Check an expression without saving it. |
dependents |
Get what depends on a function. |
archive |
Archive a function. |
unarchive |
Unarchive a function. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
versions |
|
client |
TYPE:
|
grpc_client |
TYPE:
|
rest_client |
TYPE:
|
get
async
¶
get(function_id: str) -> UserDefinedFunction
Get a UserDefinedFunction.
| PARAMETER | DESCRIPTION |
|---|---|
function_id
|
The ID of the function.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunction
|
The UserDefinedFunction. |
list_
async
¶
list_(
*,
name: str | None = None,
name_contains: str | None = None,
name_regex: str | Pattern | None = None,
function_ids: list[str] | None = None,
include_archived: bool = False,
filter_query: str | None = None,
order_by: str | None = None,
limit: int | None = None,
page_size: int | None = None,
) -> list[UserDefinedFunction]
List user-defined functions.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Exact name of the function.
TYPE:
|
name_contains
|
Partial name of the function.
TYPE:
|
name_regex
|
Regular expression to filter functions by name.
TYPE:
|
function_ids
|
Filter to functions with any of these IDs.
TYPE:
|
include_archived
|
If True, include archived functions in results.
TYPE:
|
filter_query
|
Explicit CEL query to filter functions.
TYPE:
|
order_by
|
Field and direction to order results by.
TYPE:
|
limit
|
Maximum number of functions to return. If None, returns all matches.
TYPE:
|
page_size
|
Number of results to fetch per request.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[UserDefinedFunction]
|
A list of UserDefinedFunction objects that match the filter criteria. |
find
async
¶
find(**kwargs) -> UserDefinedFunction | None
Find one function. Takes the same arguments as list_.
Raises if more than one matches.
| PARAMETER | DESCRIPTION |
|---|---|
**kwargs
|
Keyword arguments to pass to
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunction | None
|
The UserDefinedFunction found or None. |
create
async
¶
create(
create: UserDefinedFunctionCreate | dict,
) -> UserDefinedFunction
Create a new function.
| PARAMETER | DESCRIPTION |
|---|---|
create
|
The function definition.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunction
|
The created UserDefinedFunction. |
update
async
¶
update(
function: str | UserDefinedFunction,
update: UserDefinedFunctionUpdate | dict,
) -> UserDefinedFunction
Update a function. This creates a new version.
| PARAMETER | DESCRIPTION |
|---|---|
function
|
The UserDefinedFunction or function ID to update.
TYPE:
|
update
|
Updates to apply to the function.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunction
|
The updated UserDefinedFunction. |
sync
async
¶
sync(
functions: list[UserDefinedFunctionCreate | dict],
) -> list[UserDefinedFunction]
Create or update each function so Sift matches the definitions given.
Functions match by name. A new name is created. An existing one is updated, which produces a new version. Nothing is archived.
| PARAMETER | DESCRIPTION |
|---|---|
functions
|
The function definitions to apply.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[UserDefinedFunction]
|
The created or updated functions, in the order given. |
validate
async
¶
validate(
expression: str,
function_inputs: list[FunctionInput] | None = None,
) -> UserDefinedFunctionValidation
Check an expression without saving it.
| PARAMETER | DESCRIPTION |
|---|---|
expression
|
The expression to check.
TYPE:
|
function_inputs
|
The inputs the expression refers to.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunctionValidation
|
Whether the expression compiles, and its output type or error. |
dependents
async
¶
dependents(
function: str | UserDefinedFunction,
*,
version_id: str | None = None,
) -> FunctionDependents
Get what depends on a function.
Check this before changing inputs or the output type. The server refuses those changes once a function has dependents.
| PARAMETER | DESCRIPTION |
|---|---|
function
|
The UserDefinedFunction or function ID.
TYPE:
|
version_id
|
A specific version, instead of the function as a whole.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FunctionDependents
|
The IDs of dependent functions, calculated channels, and rules. |
archive
async
¶
archive(
function: str | UserDefinedFunction,
) -> UserDefinedFunction
Archive a function.
| PARAMETER | DESCRIPTION |
|---|---|
function
|
The UserDefinedFunction or function ID to archive.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunction
|
The archived UserDefinedFunction. |
unarchive
async
¶
unarchive(
function: str | UserDefinedFunction,
) -> UserDefinedFunction
Unarchive a function.
| PARAMETER | DESCRIPTION |
|---|---|
function
|
The UserDefinedFunction or function ID to unarchive.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunction
|
The unarchived UserDefinedFunction. |