API DocsRESTUser defined function service

UpdateUserDefinedFunction

Update and create a new version of a user defined function.

PATCH
/api/v1/user-defined-functions

Request Body

application/jsonRequired

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. 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.

userDefinedFunction
Required
object

updateMask
Required
string

The list of fields to be updated. The fields available to be updated are archived_date, description, expression, and function_inputs. -- 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.

curl -X PATCH "<API_URL>/api/v1/user-defined-functions" \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "userDefinedFunction": {
      "userDefinedFunctionId": "string",
      "name": "string",
      "archivedDate": "2019-08-24T14:15:22Z",
      "userDefinedFunctionVersionId": "string",
      "version": 0,
      "description": "string",
      "changeMessage": "string",
      "userNotes": "string",
      "expression": "string",
      "functionInputs": [
        {
          "identifier": "string",
          "dataType": "FUNCTION_DATA_TYPE_UNSPECIFIED"
        }
      ],
      "functionOutputType": "FUNCTION_DATA_TYPE_UNSPECIFIED",
      "functionDependencies": [
        {
          "userDefinedFunctionVersionId": "string"
        }
      ],
      "createdDate": "2019-08-24T14:15:22Z",
      "modifiedDate": "2019-08-24T14:15:22Z",
      "createdByUserId": "string",
      "modifiedByUserId": "string"
    },
    "updateMask": "string"
  }'

A successful response.

{
  "userDefinedFunction": {
    "userDefinedFunctionId": "string",
    "name": "string",
    "archivedDate": "2019-08-24T14:15:22Z",
    "userDefinedFunctionVersionId": "string",
    "version": 0,
    "description": "string",
    "changeMessage": "string",
    "userNotes": "string",
    "expression": "string",
    "functionInputs": [
      {
        "identifier": "string",
        "dataType": "FUNCTION_DATA_TYPE_UNSPECIFIED"
      }
    ],
    "functionOutputType": "FUNCTION_DATA_TYPE_UNSPECIFIED",
    "functionDependencies": [
      {
        "userDefinedFunctionVersionId": "string"
      }
    ],
    "createdDate": "2019-08-24T14:15:22Z",
    "modifiedDate": "2019-08-24T14:15:22Z",
    "createdByUserId": "string",
    "modifiedByUserId": "string"
  }
}