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. |
batch_get |
Get many versions in one call. |
list_ |
List a function's versions. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
client |
TYPE:
|
grpc_client |
TYPE:
|
rest_client |
TYPE:
|
get
async
¶
get(
*, version: str | UserDefinedFunctionVersion
) -> UserDefinedFunctionVersion
Get one version.
| PARAMETER | DESCRIPTION |
|---|---|
version
|
The UserDefinedFunctionVersion or version ID.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunctionVersion
|
The UserDefinedFunctionVersion. |
batch_get
async
¶
batch_get(
*,
versions: list[str] | list[UserDefinedFunctionVersion],
) -> list[UserDefinedFunctionVersion]
Get many versions in one call.
| PARAMETER | DESCRIPTION |
|---|---|
versions
|
The UserDefinedFunctionVersions or version IDs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[UserDefinedFunctionVersion]
|
The UserDefinedFunctionVersions. |
list_
async
¶
list_(
*,
user_defined_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[UserDefinedFunctionVersion]
List a function's versions.
| PARAMETER | DESCRIPTION |
|---|---|
user_defined_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[UserDefinedFunctionVersion]
|
A list of UserDefinedFunctionVersion objects in the service's order, which is |
list[UserDefinedFunctionVersion]
|
by name unless |
list[UserDefinedFunctionVersion]
|
name, so pass |
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. |
validate_expression |
Check an expression without saving it. |
get_where_used |
Get what uses a function. |
archive |
Archive a function. |
unarchive |
Unarchive a function. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
versions |
|
client |
TYPE:
|
grpc_client |
TYPE:
|
rest_client |
TYPE:
|
get
async
¶
get(
*, user_defined_function_id: str
) -> UserDefinedFunction
Get a UserDefinedFunction.
| PARAMETER | DESCRIPTION |
|---|---|
user_defined_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,
user_defined_function_ids: list[str]
| list[UserDefinedFunction]
| 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:
|
user_defined_function_ids
|
Filter to these UserDefinedFunctions or function 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(
user_defined_function: str | UserDefinedFunction,
update: UserDefinedFunctionUpdate | dict,
change_notes: str | None = None,
) -> UserDefinedFunction
Update a function.
Changes to the expression, inputs, description, or metadata create a new version.
| PARAMETER | DESCRIPTION |
|---|---|
user_defined_function
|
The UserDefinedFunction or function ID to update.
TYPE:
|
update
|
Updates to apply to the function.
TYPE:
|
change_notes
|
A note to attach to the new version. The server treats an empty note as a change, so the current version's note carries over when omitted.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunction
|
The updated UserDefinedFunction. |
validate_expression
async
¶
validate_expression(
expression: str, function_inputs: list[FunctionInput]
) -> UserDefinedFunctionValidation
Check an expression without saving it.
| PARAMETER | DESCRIPTION |
|---|---|
expression
|
The expression to check.
TYPE:
|
function_inputs
|
The inputs the expression refers to. The server rejects an empty list.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunctionValidation
|
Whether the expression compiles, and its output type or error. |
get_where_used
async
¶
get_where_used(
user_defined_function: str
| UserDefinedFunction
| None = None,
*,
version: str | UserDefinedFunctionVersion | None = None,
) -> FunctionUsage
Get what uses a function.
Check this before changing inputs or the output type. The server refuses those changes once a function is in use.
Each result set is capped at 1000. The service pages them separately but accepts
no page token, so the rest cannot be fetched; FunctionUsage.truncated says when
that happened.
| PARAMETER | DESCRIPTION |
|---|---|
user_defined_function
|
The UserDefinedFunction or function ID.
TYPE:
|
version
|
A specific UserDefinedFunctionVersion or version ID, instead of the function as a whole.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FunctionUsage
|
The functions, calculated channels, and rules that use it. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If neither or both are provided. |
archive
async
¶
archive(
user_defined_function: str | UserDefinedFunction,
) -> UserDefinedFunction
Archive a function.
| PARAMETER | DESCRIPTION |
|---|---|
user_defined_function
|
The UserDefinedFunction or function ID to archive.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunction
|
The archived UserDefinedFunction. |
unarchive
async
¶
unarchive(
user_defined_function: str | UserDefinedFunction,
) -> UserDefinedFunction
Unarchive a function.
| PARAMETER | DESCRIPTION |
|---|---|
user_defined_function
|
The UserDefinedFunction or function ID to unarchive.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserDefinedFunction
|
The unarchived UserDefinedFunction. |