Site Tools


Hotfix release available: 2024-02-06a "Kaos". upgrade now! [55.1] (what's this?)
New release available: 2024-02-06 "Kaos". upgrade now! [55] (what's this?)
Hotfix release available: 2023-04-04a "Jack Jackrum". upgrade now! [54.1] (what's this?)
New release available: 2023-04-04 "Jack Jackrum". upgrade now! [54] (what's this?)
Hotfix release available: 2022-07-31b "Igor". upgrade now! [53.1] (what's this?)
Hotfix release available: 2022-07-31a "Igor". upgrade now! [53] (what's this?)
New release available: 2022-07-31 "Igor". upgrade now! [52.2] (what's this?)
New release candidate 2 available: rc2022-06-26 "Igor". upgrade now! [52.1] (what's this?)
New release candidate available: 2022-06-26 "Igor". upgrade now! [52] (what's this?)
Hotfix release available: 2020-07-29a "Hogfather". upgrade now! [51.4] (what's this?)
internal:dev_w:pa:dynamic_rest_api

Dynamic ReST API Creation

Introduction

Going forward, whenever we do the functional/architectural changes in ExpertusONE codebase, we need to ensure that the changes are migrated to ReST API. This is needed in order to keep the APIs in sync. It requires monitoring and comparing the functional/technical spec with each release and coming up with plan for the ReST API development/modifications.In order to minimize re-work, I would like to introduce the concept of Dynamic Rest API creation in ExpertusONE codebase.

Advantages

  • There will not be separate track to develop the rest api for the new feature/functionality. As part of the product development, framework seemlessly get coupled with ORM entity for ReST.
  • Put one entry in rest_api.config file in order to expose the existing functionality/feature into ReST.
  • zero effort for API documentation. API documentation PHP pages (http://www.expertusone.com/apis/docs) will have intelligence of picking the latest foot print of APIS in REST_API.config file and will generate the documentation dynamically.

Configuration REST_API.config

//Put the entry in rest_api.config file for exposing rest api.
{
	"Category":"Admin APIs","API Display Name":"Organization Creation",function:"org","action":"createorg","ORM File Name":"sites/all/dao/org_orm.php","ORM Method":"CreateOrg",
	"Category":"Admin APIs","API Display Name":"User Creation","function":"user","action":"createuser","ORM File Name:"sites/all/dao/user_orm.php","ORM Method":"CreateUser"
}	

How to call ReST API

Provide GET or POST call to the callapi.php with necessary parameters.

     EndPointURL: http://www.expertusone.com/apis/callapi.php?function=user&action=createuser&action_params=username^test^password^test^firstname^John&display_columns=id

Based on the function and action parameter from the request, framework will have intelligence of picking the proper ORM entity in REST_API.config and will execute it.

Constraints in ORM development

  • Should not read any values from cookies inside the ORM file
  • Should not read any values from session inside the ORM file
  • Should not include any UI related files(Example:- drupal modules/themes) inside ORM
  • ORM method parameter should be array or stdclass type.
  • Should not write stdout statements inside ORM (Example:- echo, print_r and etc…)
internal/dev_w/pa/dynamic_rest_api.txt · Last modified: 2022/06/14 10:16 (external edit)