> ## Documentation Index
> Fetch the complete documentation index at: https://docs.siftstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# user_defined_functions

> sift/user_defined_functions/v1/user_defined_functions.proto

<a name="sift_user_defined_functions_v1_user_defined_functions-proto" />

<a name="sift_user_defined_functions_v1_user_defined_functions-proto-services" />

## Services

*RPC methods exposed by this API.*

### UserDefinedFunctionService

| Method                           | Request                                                                             | Response                                                                              | Description                                                                         |
| :------------------------------- | :---------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------------- |
| GetUserDefinedFunction           | [GetUserDefinedFunctionRequest](#getuserdefinedfunctionrequest)                     | [GetUserDefinedFunctionResponse](#getuserdefinedfunctionresponse)                     | Retrieve the latest version of a user defined function                              |
| GetUserDefinedFunctionVersion    | [GetUserDefinedFunctionVersionRequest](#getuserdefinedfunctionversionrequest)       | [GetUserDefinedFunctionVersionResponse](#getuserdefinedfunctionversionresponse)       | Retrieve a specific version of a user defined function                              |
| GetUserDefinedFunctionVersions   | [GetUserDefinedFunctionVersionsRequest](#getuserdefinedfunctionversionsrequest)     | [GetUserDefinedFunctionVersionsResponse](#getuserdefinedfunctionversionsresponse)     | Retrieve versions of user defined functions                                         |
| GetUserDefinedFunctionDependents | [GetUserDefinedFunctionDependentsRequest](#getuserdefinedfunctiondependentsrequest) | [GetUserDefinedFunctionDependentsResponse](#getuserdefinedfunctiondependentsresponse) | Retrieve versions of user defined functions                                         |
| CreateUserDefinedFunction        | [CreateUserDefinedFunctionRequest](#createuserdefinedfunctionrequest)               | [CreateUserDefinedFunctionResponse](#createuserdefinedfunctionresponse)               | Create a user defined function.                                                     |
| ValidateUserDefinedFunction      | [ValidateUserDefinedFunctionRequest](#validateuserdefinedfunctionrequest)           | [ValidateUserDefinedFunctionResponse](#validateuserdefinedfunctionresponse)           | Validate a potential user defined function                                          |
| UpdateUserDefinedFunction        | [UpdateUserDefinedFunctionRequest](#updateuserdefinedfunctionrequest)               | [UpdateUserDefinedFunctionResponse](#updateuserdefinedfunctionresponse)               | Update a user defined function.                                                     |
| CheckUpdatableFields             | [CheckUpdatableFieldsRequest](#checkupdatablefieldsrequest)                         | [CheckUpdatableFieldsResponse](#checkupdatablefieldsresponse)                         | Check if given update paths are allowed to update for the user defined function.    |
| ListUserDefinedFunctions         | [ListUserDefinedFunctionsRequest](#listuserdefinedfunctionsrequest)                 | [ListUserDefinedFunctionsResponse](#listuserdefinedfunctionsresponse)                 | Retrieve the latest versions of user defined functions based on an optional filter. |
| ListUserDefinedFunctionVersions  | [ListUserDefinedFunctionVersionsRequest](#listuserdefinedfunctionversionsrequest)   | [ListUserDefinedFunctionVersionsResponse](#listuserdefinedfunctionversionsresponse)   | List versions of a particular user defined functions with an optional filter.       |

<a name="sift_user_defined_functions_v1_user_defined_functions-proto-messages" />

## Messages

*Data models used across requests/responses.*

### CheckUpdatableFieldsRequest

| Field                       | Type                                                    | Label | Description |
| :-------------------------- | :------------------------------------------------------ | :---- | :---------- |
| user\_defined\_function\_id | string                                                  |       |             |
| update\_mask                | [google.protobuf.FieldMask](#google-protobuf-fieldmask) |       |             |

### CheckUpdatableFieldsResponse

| Field              | Type                                                                                                      | Label    | Description                                                                                            |
| :----------------- | :-------------------------------------------------------------------------------------------------------- | :------- | :----------------------------------------------------------------------------------------------------- |
| allowed\_fields    | [google.protobuf.FieldMask](#google-protobuf-fieldmask)                                                   |          |                                                                                                        |
| disallowed\_fields | [CheckUpdatableFieldsResponse.DisallowedFieldsEntry](#checkupdatablefieldsresponse-disallowedfieldsentry) | repeated | Disallowed Fields will contain the update fields as the key and the reason for rejection as the value. |

### CheckUpdatableFieldsResponse.DisallowedFieldsEntry

| Field | Type   | Label | Description |
| :---- | :----- | :---- | :---------- |
| key   | string |       |             |
| value | string |       |             |

### CreateUserDefinedFunctionRequest

| Field            | Type                                                                    | Label    | Description |
| :--------------- | :---------------------------------------------------------------------- | :------- | :---------- |
| name             | string                                                                  |          |             |
| description      | string                                                                  | optional |             |
| expression       | string                                                                  |          |             |
| function\_inputs | [sift.common.type.v1.FunctionInput](#sift-common-type-v1-functioninput) | repeated |             |
| user\_notes      | string                                                                  | optional |             |
| metadata         | [sift.metadata.v1.MetadataValue](#sift-metadata-v1-metadatavalue)       | repeated |             |

### CreateUserDefinedFunctionResponse

| Field                   | Type                                                                                | Label | Description |
| :---------------------- | :---------------------------------------------------------------------------------- | :---- | :---------- |
| user\_defined\_function | [sift.common.type.v1.UserDefinedFunction](#sift-common-type-v1-userdefinedfunction) |       |             |

### GetUserDefinedFunctionDependentsRequest

The request for a call to `UserDefinedFunctionService_GetUserDefinedFunctionDependents` to retrieve versions of user defined functions.

| Field                                                               | Type   | Label | Description |
| :------------------------------------------------------------------ | :----- | :---- | :---------- |
| page\_size                                                          | uint32 |       |             |
| oneof user\_defined\_function. user\_defined\_function\_id          | string |       |             |
| oneof user\_defined\_function. user\_defined\_function\_name        | string |       |             |
| oneof user\_defined\_function. user\_defined\_function\_version\_id | string |       |             |

### GetUserDefinedFunctionDependentsResponse

| Field                                      | Type                                                                                             | Label    | Description |
| :----------------------------------------- | :----------------------------------------------------------------------------------------------- | :------- | :---------- |
| user\_defined\_functions                   | [sift.common.type.v1.UserDefinedFunction](#sift-common-type-v1-userdefinedfunction)              | repeated |             |
| next\_page\_token\_user\_defined\_function | string                                                                                           |          |             |
| calculated\_channels                       | [sift.calculated\_channels.v2.CalculatedChannel](#sift-calculated_channels-v2-calculatedchannel) | repeated |             |
| next\_page\_token\_calculated\_channel     | string                                                                                           |          |             |
| rules                                      | [sift.rules.v1.Rule](#sift-rules-v1-rule)                                                        | repeated |             |
| next\_page\_token\_rule                    | string                                                                                           |          |             |

### GetUserDefinedFunctionRequest

The request for a call to `UserDefinedFunctionService_GetUserDefinedFunction` to retrieve the latest version of a user defined function.
If `user_defined_function_id` is provided then all other arguments will be ignored. The argument `user_defined_function_id`
should not be used together with `name`.

| Field                       | Type   | Label | Description |
| :-------------------------- | :----- | :---- | :---------- |
| user\_defined\_function\_id | string |       |             |
| name                        | string |       |             |

### GetUserDefinedFunctionResponse

| Field                   | Type                                                                                | Label | Description |
| :---------------------- | :---------------------------------------------------------------------------------- | :---- | :---------- |
| user\_defined\_function | [sift.common.type.v1.UserDefinedFunction](#sift-common-type-v1-userdefinedfunction) |       |             |

### GetUserDefinedFunctionVersionRequest

The request for a call to `UserDefinedFunctionService_GetUserDefinedFunctionVersion` to retrieve a specific version of a user defined function.

| Field                                | Type   | Label | Description |
| :----------------------------------- | :----- | :---- | :---------- |
| user\_defined\_function\_version\_id | string |       |             |

### GetUserDefinedFunctionVersionResponse

| Field                   | Type                                                                                | Label | Description |
| :---------------------- | :---------------------------------------------------------------------------------- | :---- | :---------- |
| user\_defined\_function | [sift.common.type.v1.UserDefinedFunction](#sift-common-type-v1-userdefinedfunction) |       |             |

### GetUserDefinedFunctionVersionsRequest

The request for a call to `UserDefinedFunctionService_GetUserDefinedFunctionVersions` to retrieve versions of user defined functions.

| Field                                 | Type   | Label    | Description |
| :------------------------------------ | :----- | :------- | :---------- |
| user\_defined\_function\_version\_ids | string | repeated |             |

### GetUserDefinedFunctionVersionsResponse

| Field                    | Type                                                                                | Label    | Description |
| :----------------------- | :---------------------------------------------------------------------------------- | :------- | :---------- |
| user\_defined\_functions | [sift.common.type.v1.UserDefinedFunction](#sift-common-type-v1-userdefinedfunction) | repeated |             |

### ListUserDefinedFunctionVersionsRequest

The request for a call to `UserDefinedFunctionService_ListUserDefinedFunctionVersions` to retrieve versions of user defined function.
If `user_defined_function_id` is provided then `name` is ignored.

| Field                       | Type   | Label | Description                                                                                                                                                                                                                                                                                                                                                                                                                          |
| :-------------------------- | :----- | :---- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| user\_defined\_function\_id | string |       |                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| name                        | string |       |                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| page\_size                  | uint32 |       | The maximum number of user defined function versions to return. The service may return fewer than this value. If unspecified, at most 50 user defined function versions will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. Optional.                                                                                                                                                            |
| page\_token                 | string |       | A page token, received from a previous `ListUserDefinedFunctions` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListUserDefinedFunctions` must match the call that provided the page token. Optional.                                                                                                                                                                       |
| filter                      | string |       | A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string. Available fields to filter by are `user_defined_function_id`, `name`, `version`, `archived_date`, and `is_archived`. For further information about how to use CELs, please refer to [this guide](https://github.com/google/cel-spec/blob/master/doc/langdef.md#standard-definitions).                                                        |
| order\_by                   | string |       | How to order the retrieved user defined functions. Formatted as a comma-separated string i.e. "FIELD\_NAME\[ desc],...". Available fields to order\_by are `created_date`, `modified_date`, `name`, and `version`. If left empty, items are ordered by `name` in ascending order (oldest-first). For more information about the format of this field, read [this](https://google.aip.dev/132#ordering) Example: "version desc,name". |

### ListUserDefinedFunctionVersionsResponse

The response of a call to `UserDefinedFunctionService_ListUserDefinedFunctionVersions`.

| Field                    | Type                                                                                | Label    | Description |
| :----------------------- | :---------------------------------------------------------------------------------- | :------- | :---------- |
| user\_defined\_functions | [sift.common.type.v1.UserDefinedFunction](#sift-common-type-v1-userdefinedfunction) | repeated |             |
| next\_page\_token        | string                                                                              |          |             |

### ListUserDefinedFunctionsRequest

The request for a call to `UserDefinedFunctionService_ListUserDefinedFunctions` to retrieve lateset versions of user defined functions.

| Field       | Type   | Label | Description                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| :---------- | :----- | :---- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| page\_size  | uint32 |       | The maximum number of user defined functions to return. The service may return fewer than this value. If unspecified, at most 50 user defined functions will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. Optional.                                                                                                                                                                                          |
| page\_token | string |       | A page token, received from a previous `ListUserDefinedFunctions` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListUserDefinedFunctions` must match the call that provided the page token. Optional.                                                                                                                                                                                     |
| filter      | string |       | A [Common Expression Language (CEL)](https://github.com/google/cel-spec) filter string. Available fields to filter by are `user_defined_function_id`, `name`, `archived_date`, and `is_archived`. For further information about how to use CELs, please refer to [this guide](https://github.com/google/cel-spec/blob/master/doc/langdef.md#standard-definitions).                                                                                 |
| order\_by   | string |       | How to order the retrieved user defined functions. Formatted as a comma-separated string i.e. "FIELD\_NAME\[ desc],...". Available fields to order\_by are `created_date`, `modified_date`, and `name`. If left empty, items are ordered by `created_date` in descending order (newest-first). For more information about the format of this field, read [this](https://google.aip.dev/132#ordering) Example: "created\_date desc,modified\_date". |

### ListUserDefinedFunctionsResponse

The response of a call to `UserDefinedFunctionService_ListUserDefinedFunctions`.

| Field                    | Type                                                                                | Label    | Description |
| :----------------------- | :---------------------------------------------------------------------------------- | :------- | :---------- |
| user\_defined\_functions | [sift.common.type.v1.UserDefinedFunction](#sift-common-type-v1-userdefinedfunction) | repeated |             |
| next\_page\_token        | string                                                                              |          |             |

### UpdateUserDefinedFunctionRequest

The request for a call to `UserDefinedFunctionService_UpdateUserDefinedFunction` to update a user defined function. Updating a user
defined function creates a new version of the user defined function, leaving the previous untouched. If no update is deemed necessary, then the
the current version is returned. If name is changed then only name will be changed. If archive date is changed then only archive date will be changed.
To archive user defined function, specify `archived_date` in the `update mask` as well as a non-null value for `archived_date` in the
`user_defined_function` object. To unarchive a user defined function, specify `archived_date` in the `update mask` and a `null` value for `archived_date`
in the `user_defined_function` object. Alternatively, use `is_archived` with a boolean value to archive/unarchive.

| Field                   | Type                                                                                | Label | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| :---------------------- | :---------------------------------------------------------------------------------- | :---- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| user\_defined\_function | [sift.common.type.v1.UserDefinedFunction](#sift-common-type-v1-userdefinedfunction) |       | The user defined function to update.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| update\_mask            | [google.protobuf.FieldMask](#google-protobuf-fieldmask)                             |       | The list of fields to be updated. The fields available to be updated are `name`, `archived_date`, `is_archived`, `description`, `expression`, `function_inputs`, and `metadata`. -- `name` can't be updated if the function has ever had any dependencies -- `function_inputs` inputs can't be updated if the function has any dependents (functions or calculated channels with a dependency on this function). -- `expression` can't be updated if the function has dependents and the expression changes the output type. -- `metadata` updates metadata associated with the function |

### UpdateUserDefinedFunctionResponse

| Field                   | Type                                                                                | Label | Description |
| :---------------------- | :---------------------------------------------------------------------------------- | :---- | :---------- |
| user\_defined\_function | [sift.common.type.v1.UserDefinedFunction](#sift-common-type-v1-userdefinedfunction) |       |             |

### ValidateUserDefinedFunctionRequest

| Field            | Type                                                                    | Label    | Description |
| :--------------- | :---------------------------------------------------------------------- | :------- | :---------- |
| expression       | string                                                                  |          |             |
| function\_inputs | [sift.common.type.v1.FunctionInput](#sift-common-type-v1-functioninput) | repeated |             |

### ValidateUserDefinedFunctionResponse

| Field                 | Type                                                                                                                                                              | Label | Description |
| :-------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---- | :---------- |
| oneof result. error   | [ValidateUserDefinedFunctionResponse.ErrorValidatingUserDefinedFunctionResult](#validateuserdefinedfunctionresponse-errorvalidatinguserdefinedfunctionresult)     |       |             |
| oneof result. success | [ValidateUserDefinedFunctionResponse.SuccessValidatingUserDefinedFunctionResult](#validateuserdefinedfunctionresponse-successvalidatinguserdefinedfunctionresult) |       |             |

### ValidateUserDefinedFunctionResponse.ErrorValidatingUserDefinedFunctionResult

| Field          | Type   | Label | Description |
| :------------- | :----- | :---- | :---------- |
| error\_message | string |       |             |

### ValidateUserDefinedFunctionResponse.SuccessValidatingUserDefinedFunctionResult

| Field                   | Type                                                                                | Label | Description |
| :---------------------- | :---------------------------------------------------------------------------------- | :---- | :---------- |
| user\_defined\_function | [sift.common.type.v1.UserDefinedFunction](#sift-common-type-v1-userdefinedfunction) |       |             |

<a name="sift_user_defined_functions_v1_user_defined_functions-proto-enums" />

## Enums

*Allowed constant values used in message fields.*
