Problem Statement
...
- Sunbird Platform will expose an API for end user to initiate update content
- Sunbird Platform will log the request in DB and pass the user a generated process Id
- Sunbird Platform will send the request with processId to kafka message queue
- Request will be picked up by Learning platform and would start the processing of update content based on the request
- Sunbird Platform will use a listener to get the status update and store in DB from the kafka based on processId
...
- Sunbird Platform will expose an API for end user to initiate update content
- Sunbird Platform will internally call Content Service with the request provided by User
- Content Service will validate the request
- With valid request, .
- Content Service will initiate the update process through kafka pipeline and will return unique process ID identifying the process.
- With Invalid request, Content Service will return error message which Sunbird platform will return to User
- For valid response from Content Service, processId with other details will be saved in Sunbird platform DB
- On user call to get status, Sunbird Platform will call Content Service.
pros and cons of both approaches
approaches | pros | cons |
---|---|---|
1.without content service | loosely coupled | |
2.with content service | dependent on content service, duplicate storage of statuses and processes by Content Service and Sunbird platform |
Problem Statement
What is the API for update content?
Solution approach
URL:
POST /v1/contentjob/updatestart
Headers:
Authorization
X-authenticated-user-token
Request Params:
name | type | description | |
---|---|---|---|
scriptscriptName | String | name of the script to be run by Content Service | |
version | String | the version of the script | |
contentattributes | Map | additional parameters which would Array | attributes to be updated, will work as arguments for to the scriptsscript |
Response Params:
name | type | description |
---|---|---|
processId | String | unique identifier of the process started for the request, needed to get the status of the process |
...
status code | error code | error message | |||
---|---|---|---|---|---|
400 | MANDATORY_PARAMETER_MISSING | Mandatory parameter {script,version} is missing. | 400 | UPDATE_FAILED | Data updation failed due to invalid Request |
Sample Request and Response:
No Format | ||
---|---|---|
| ||
Request { request : { "scriptscriptName" : "course_rename", "version" : "1.2", "attributes" : [{ "field" : "name" "oldValue" : "AB", "content "newValue" : "ab" },{ "field" : "orgDetails" "oldValue" : { "oldNamecourseName" : "AB" }, "newName"newValue" : { "courseName" : "ab" } }] } } Response { "id": "api.content.updatejob", "result": { "processId" : "01262366359399628812" } } |
...
content_update_process table structure should be as below
column | type | description | Index |
---|---|---|---|
id | text | holds process id | scriptPRIMARY |
scriptName | text | name of the script to run | |
version | text | the version of the script | |
request | text | holds the input request as it is | |
status | text | the status last received from content service | |
message | text | message from content service in case of failure | |
createdbycreatedBy | text | userid userId of one who invoked the process | SECONDARY |
createdatcreatedAt | timestamp | when the process was started | |
updatedatupdatedAt | timestamp | when the process was last updated |
...
What is the API for getting the process status
Solution approach
URL:job
GET /v1/contentjob/update/status/{processId}
Headers:
Authorization
X-authenticated-user-token
Request Params:
None
Response Params:
...
status code | error code | error message |
---|---|---|
400 | INVALID_PROCESS_ID | Invalid Process Id |
Sample Request and Response:
No Format | ||
---|---|---|
| ||
Request GET /v1/content/updatejob/status/01262366359399628812 Response { "id": "api.contentjob.update.status", "result": { "status" : "FAILURE", "message" : "Operation to update failed" } } |
Problem Statement
What is the API for get all the processes by a user
Solution approach
URL:
GET /v1/contentjob/update/processeslist
Headers:
Authorization
X-authenticated-user-token
Request Params:
None
Response Params:
returns an array of processes related to user
name | type | description |
---|---|---|
processId | text | the process id |
script | text | the script for which process exists |
version | text | version of the script |
Errors:
None
Sample Request and Response:
No Format | ||
---|---|---|
| ||
Request GET /v1/content/updatejob/processes Response { "id": "api.content.updatejob.processes", "result": { processes : [{ "processId" : "01262366359399628812", "script" : "course_rename", "version" : "1.2" }] } } |
...