**Functions** ====================== **Create a Function** +++++++++++++++++++++++ .. http:post:: /_config/functions/ **Description** This is used for creating new asset. **HTTP Method** POST **Endpoint:** ``/_config/functions/`` **Request Header** ``Authorization`` `Basic ` **Request Parameters** Body Parameters - ``function_name`` (string, *required*): The name of the function to be created. - ``plant_id`` (string, *required*): The ID of the plant to which this function belongs. - ``site_id`` (string, *optional*): The ID of the site where the function is located.If not provided, it will be determined based on the plant_id. **Sample Request** .. code-block:: sh curl --location 'https://app.4pointx.com/_config/functions/' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic ' \ --data ' {"function_name":"demo-func-oct9-test2", "plant_id":"e29ae75e-dd88-45ef-90cb-cefb3807af70" }' **Sample Response** Success .. sourcecode:: json { "id": "96978782-b0ea-49dc-9f87-2edf8ba2f126" } Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } } .. sourcecode:: json { "error": { "status": 400, "message": "Invalid Content Type" } } .. sourcecode:: json { "error": { "status": 400, "message": "Insufficient Inputs" } } .. sourcecode:: json { "error": { "status": 400, "message": "Invalid Plant id" } } **Delete a Function** +++++++++++++++++++++++ .. http:delete:: /_config/functions/ **Description** This endpoint allows you to delete a specific function by providing its ID. **HTTP Method** DELETE **Endpoint** ``/_config/functions/`` **Request Header** ``Authorization`` `Basic ` **Request Parameters** URL Parameters - ``function_id`` (string, *required*): The ID of the function to delete. **Sample Request** .. code-block:: sh curl --location --request DELETE 'https://app.4pointx.com/_config/functions/1b78027a-b67f-4130-9325-0ab11a3cfd05' \ --header 'Authorization: Basic ' \ --data '' **Sample Response** Success .. sourcecode:: text "Function deleted" Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } } .. sourcecode:: json { "error": { "status": 400, "message": "Invalid Function 1b78027a-b67f-4130-9325-0ab11a3cfd05" } } .. sourcecode:: json { "error": { "status": 400, "message": "Monitors exist on the function" } } .. sourcecode:: json { "error": { "status": 400, "message": "Assets exist on the function" } } .. sourcecode:: json { "error": { "status": 400, "message": "Monitors and assets both exist on the function" } } **Update Function** ++++++++++++++++++++++++ .. http:put:: /_config/functions/ **Description** This endpoint allows you to update the details of a specific function by providing its ID. **HTTP Method** PUT **Endpoint** ``/_config/functions/`` **Request Header** ``Authorization`` `Basic ` **Request Parameters** Body Parameters - ``function_name`` (string, *required*): The updated name of the function. - ``plant_id`` (string, *required*): The updated ID of the plant to which this function belongs. URL Parameters - ``function_id`` (string, *required*): The ID of the function to update. **Sample Request** .. code-block:: sh curl --location --request PUT 'https://app.4pointx.com/_config/functions/96978782-b0ea-49dc-9f87-2edf8ba2f126' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic YWRtaW46clpvcGN1S3FVSXFteXJPVUNibDVTZGx4bVQzYU55ZG0=' \ --data ' {"function_name":"demo-func-2sep-test2-mod", "plant_id":"e29ae75e-dd88-45ef-90cb-cefb3807af70"}' **Sample Response** Success .. sourcecode:: json "Function Updated" Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } } .. sourcecode:: json { "error":{ "status": 400, "message": "Invalid Content Type" } } .. sourcecode:: json { "error":{ "status": 400, "message": "Insufficient Inputs" } } .. sourcecode:: json { "error":{ "status": 404, "message": "Invalid function" } } **Fetch Function** +++++++++++++++++++++++ .. http:get:: /_config/functions/ **Description** This endpoint allows you to retrieve details about a specific function by providing its ID. **HTTP Method** GET **Endpoint** ``/_config/functions/`` **Request Header** ``Authorization`` `Basic ` **Request Parameters** URL Parameters - ``function_id`` (string, *required*): The ID of the function to retrieve details for. **Sample Request** .. code-block:: sh curl --location 'https://app.4pointx.com/_config/functions/96978782-b0ea-49dc-9f87-2edf8ba2f126' \ --header 'Authorization: Basic ' **Sample Response** Success .. code-block:: json { "function_id": "96978782-b0ea-49dc-9f87-2edf8ba2f126", "function_name": "demo-func-oct9-test2mod", "plant_name": "Demo Plant", "site_name": "Demo Site" } Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } } .. sourcecode:: json { "error": { "status": 405, "message": "Method not allowed", } } .. sourcecode:: json { "error": { "status": 404, "message": "Data not found", } } **Fetch List of Functions** +++++++++++++++++++++++++++++ .. http:GET:: /_config/functions/_list **Description** This endpoint allows you to retrieve a list of functions associated with a specific plant. **HTTP Method** GET **Endpoint** ``/_config/functions/_list`` **Request Header** ``Authorization`` `Basic ` **Request Parameters** Query Parameters - ``plant_id`` (string, *required*): The ID of the plant for which you want to list functions. **Sample Request** .. code-block:: sh curl --location 'https://app.4pointx.com/_config/functions/_list?plant_id=e29ae75e-dd88-45ef-90cb-cefb3807af70' \ --header 'Authorization: Basic ' \ --data '' **Sample Response** Success .. code-block:: json [ { "function_id": "45c98f40-75e3-49e7-b178-d25ec878db79", "function_name": "Demo Function", "plant_name": "Demo Plant", "site_name": "Demo Site", "monitor_count": 7 }, { "function_id": "1eede0dd-93a6-4c0d-803e-4f41ff9728c1", "function_name": "Line 1", "plant_name": "Demo Plant", "site_name": "Demo Site", "monitor_count": 5 }, { "function_id": "8ca0f8cf-8128-47a5-843c-50e4cf9e5033", "function_name": "func22sep", "plant_name": "Demo Plant", "site_name": "Demo Site", "monitor_count": 1 }, { "function_id": "96978782-b0ea-49dc-9f87-2edf8ba2f126", "function_name": "demo-func-oct9-test2mod", "plant_name": "Demo Plant", "site_name": "Demo Site", "monitor_count": 0 } ] Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } } .. sourcecode:: json { "error": { "status": 400, "message": "Insufficient Inputs" } }