Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Problem Statement

...

  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 validate the requestWith valid request, Content Service will initiate the update process through kafka pipeline and will return unique process ID identifying the process.
  4. With Invalid request, Content Service will return error message which Sunbird platform will return to User
  5. For valid response from Content Service, processId with other details will be saved in Sunbird platform DB
  6. 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 
reply

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:

nametype description
scriptscriptNameStringname of the script to be run by Content Service
versionStringthe version of the script
contentattributesMapadditional parameters which would Arrayattributes to be updated, will work as arguments for to the scriptsscript

Response Params:

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

...

status codeerror codeerror message
400MANDATORY_PARAMETER_MISSINGMandatory parameter {script,version} is missing.
400UPDATE_FAILEDData updation failed due to invalid Request

Sample Request and Response:


No Format
nopaneltrue
Request

{
	request : {
		"scriptscriptName" : "course_rename",
		"version" : "1.2",
		"attributes" : [{
		"content	"field" : "name"
			"oldValue" : "AB",
			"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

columntype descriptionIndex
idtextholds process idscriptPRIMARY
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
createdbycreatedBytextuserid userId of one who invoked the processSECONDARY
createdatcreatedAttimestamp

when the process was started


updatedatupdatedAttimestampwhen 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 codeerror codeerror message
400INVALID_PROCESS_IDInvalid Process Id

Sample Request and Response:

No Format
nopaneltrue
Request

GET /v1/content/updatejob/status/01262366359399628812

Response

{
  "id": "api.contentjob.update.status",
  "result": {
		"status" : "FAILURE",
		"message" : "Operation to update failed"
	}
}

...

Solution approach

URL:

GET /v1/contentjob/update/processeslist

Headers:

Authorization

X-authenticated-user-token

...

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

Errors:

None

Sample Request and Response:


No Format
nopaneltrue
Request

GET /v1/content/updatejob/processes

Response

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

...