Design for easy way to update content

Problem Statement

Currently to update the content implementation team needs to make multiple calls, which makes it a difficult process. Additionally there is no auditing in place to track as content was updated by whom. There should be an easier way to update the content.

SB-10220 - Getting issue details... STATUS

Solution Approach

Solution approach to overcome the problem has below approaches

APPROACH 1
  1. Sunbird Platform will expose an API for end user to initiate update content
  2. Sunbird Platform will log the request in DB and pass the user a generated process Id
  3. Sunbird Platform will send the request with processId to kafka message queue
  4. Request will be picked up by Learning platform and would start the processing of update content based on the request
  5. Sunbird Platform will use a listener to get the status update and store in DB from the kafka based on processId
Approach 2
  1. Sunbird Platform will expose an API for end user to initiate update content
  2. Sunbird Platform will internally call Content Service with the request provided by User.
  3. Content Service will initiate the update process through kafka pipeline and will return unique process ID identifying the process.
  4. For valid response from Content Service, processId with other details will be saved in Sunbird platform DB
  5. On user call to get status, Sunbird Platform will call Content Service. 


pros and cons of both approaches

approaches proscons

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/job/start

Headers:

Authorization

X-authenticated-user-token

Request Params:

nametype description
scriptNameStringname of the script to be run by Content Service
versionStringthe version of the script
attributesArrayattributes to be updated, will work as arguments to the script

Response Params:

nametypedescription
processIdStringunique identifier of the process started for the request, needed to get the status of the process

Errors:

status codeerror codeerror message
400MANDATORY_PARAMETER_MISSINGMandatory parameter {script,version} is missing.

Sample Request and Response:


Request

{
	request : {
		"scriptName" : "course_rename",
		"version" : "1.2",
		"attributes" : [{
			"field" : "name"
			"oldValue" : "AB",
			"newValue" : "ab"
		},{
			"field" : "orgDetails"
			"oldValue" : {
				"courseName" : "AB"
			},
			"newValue" : {
				"courseName" : "ab"
			}
		}]	
	}
}

Response

{
  "id": "api.job",
  "result": {
		"processId" : "01262366359399628812"
	}
}


Problem Statement

How we store the process information in DB

Solution approach

content_update_process table structure should be as below

columntype descriptionIndex
idtextholds process idPRIMARY
scriptNametextname of the script to run
versiontextthe version of the script
requesttextholds the input request as it is
statustextthe status last received from content service
messagetextmessage from content service in case of failure
createdBytextuserId of one who invoked the processSECONDARY
createdAttimestamp

when the process was started


updatedAttimestampwhen the process was last updated


Problem Statement

What is the API for getting the process status

Solution approach

URL:job

GET /v1/job/status/{processId}

Headers:

Authorization

X-authenticated-user-token

Request Params:

None

Response Params:

nametypedescription
statustextstatus as COMPLETED or FAILURE
messagetextcontains error messages in case of failure

Errors:

status codeerror codeerror message
400INVALID_PROCESS_IDInvalid Process Id

Sample Request and Response:

Request

GET /v1/job/status/01262366359399628812

Response

{
  "id": "api.job.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/job/list

Headers:

Authorization

X-authenticated-user-token

Request Params:

None

Response Params:

returns an array of processes related to user

nametypedescription
processIdtextthe process id
scripttextthe script for which process exists
versiontextversion of the script

Errors:

None

Sample Request and Response:

Request

GET /v1/job/processes

Response

{
  "id": "api.job.processes",
  "result": {
		processes : [{
			"processId" : "01262366359399628812",
			"script" : "course_rename",
			"version" : "1.2"
		}]
	}
}


Deprecated SOLUTION APPROACH

Solution approach is divided into multiple part

  • There should be generated key to facilitate the process of update of content in a channel by anyone who has the key, hence bypassing the user authentication process . The details of the master key generation design and approach are here (Master Key APIs).
  • Auditing of the update of the content by keys.