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:tdd:tech_details_dynamic_rest

Technical Architecture - Dynamic ReST API Framework

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.
  • Developed automated test engine which read the values from rest_api.config and invoke the API. If API fails, framework notify the api owner with cced to Product Head.
  • This framework can be integrated with cruise control script so that whenever build happens in QA, it will test the apis and will send the health of it to the Product Head.

Configuration REST_API.config

//Put the entry in rest_api.config file for exposing rest api. This config is following zend framework INI file complaints.
 
;API for Get Profile lookup
[ListProfileValues]  ;
category = AdminAPI  ; 
display_name = List Profile Values API 
description = This API is used to list the profile values.
ORM_file = /sites/all/dao/ProfileDAO.php
method_name = callProfileValuesAPI;the name of the function that is to be executed when this api is called.
params.paramsobj.level = Y> Level Id>0   ;Mandatory or optional > description of the param > test value of the param
params.paramsobj.id = Y> Profile Id>0
params.paramsobj.root = Y> Root value>R
params.userid=Y > User Id > 1
params.limit= Y > limit > 1
response.id= Profile Id>2 ; Description of the response column > sample data
response.name= Profile Name>2
response.attr3= attr3>2
response.attr4= attr4>2
response.children= children>2
api_owner.name = Vincent;the developer's name who develops the functionality
api_owner.email = smart_portal@expertus.com ;the developer's mail id who develops the functionality
test_category = list

How to call ReST API

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

     EndPointURL: http://www.expertusone.com/apis/ext/ExpertusOneAPI?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.

Architecture Diagram for Dynamic ReST API

Learn about the REST_API.config

TBD

Details about folder structure for APIs

TBD

Developer rules on the road

  • 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…)
  • In order to call orm file through API, include necessary sub components inside the ORM file.ORM should not depend other drupal module or theme related files to execute.
  • API will not throw any custom error which captured from ORM and the same will be propagated to the caller.
  • When retrieve the result set from DB, use separate method to retrieve the result set . Do not merge retrieving data and parsing of that in the same method.

FAQ

  • How do i add new api entry in REST_API.config file?
  • Will APIs compatible with older version of LMS?
internal/dev_w/tdd/tech_details_dynamic_rest.txt · Last modified: 2022/06/14 10:16 (external edit)