Versions Compared

Key

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

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

DRAFT - Design in Progress
=====================================

Bulk Content Upload API

HTTP Method - POST

API Endpoint - v1/bulkupload/content

Request Headers

...

Request Body

Code Block
content: [contentUploadFile.csv]

Response : Success Response - OK (200)

...

Problem Statement

Related Jira Task - 

Jira Legacy
serverSystem JIRA
serverId2207a759-5bc8-39c5-9cd2-aa9ccc1f65dd
keySB-12164

  1. Bulk Content Upload is to be supported in Sunbird, with 3 operation modes
  2. API to be made available to check the real-time status of the bulk content upload process
  3. API to be made available to list the statuses of processes initiated by an user
operation-modeworkflow
uploadcreate-upload content
publishcreate-upload-publish content
linkcreate-upload-publish content and link it to textbook


Design


Image Added



API Specifications

Bulk Content Upload API - POST - /v1/textbook/content/bulk/upload

Request Headers

Content-Typemultipart/form-data
AuthorizationBearer {{api-key}}
x-authenticated-user-token{{keycloak-token}}
x-channel-id{{channel-identifier}}
x-framework-id{{framework-identifier}}
operation-modeupload/publish/link


Request Body

Code Block
content: [contentUploadFile.csv]


Response : Success Response - OK (200)

Code Block
{
    "id": "api.textbook.content.bulk.upload",
    "ver": "v1",
    "ts": "2019-07-26 11:28:42:315+0000",
    "params": {
        "processIdresmsgid": "012813442982903808142"null,
    } }

Response : Failure Response - BAD REQUEST (400) - Corrupt File

Code Block
{     "idmsgid": "api.bulkupload.content",cf5b2e8e-70cf-401c-af29-980bc3151c67",
        "vererr": "v1"null,
        "tsstatus": "2019-07-26 11:28:42:315+0000success",
        "paramserrmsg": null
{    },
    "resmsgidresponseCode": null,
   "OK",
    "msgidresult": "cf5b2e8e-70cf-401c-af29-980bc3151c67",{
        "errprocessId": "CORRUPT_FILE012813442982903808142",
      }
}


Response : Failure Response - BAD REQUEST (400) - Corrupt File

Code Block
{
    "statusid": "CORRUPT_FILEapi.textbook.content.bulk.upload",
 
      "errmsgver": "Bulkv1",
content upload failed due to corrupt file"
    } "ts": "2019-07-26 11:28:42:315+0000",
    "responseCodeparams": {
  "CLIENT_ERROR",      "resmsgid": null,
        "resultmsgid": { }
}

Response : Failure Response - BAD REQUEST (400) - Invalid File Format(Only CSV files are supported)

Code Block
{ "cf5b2e8e-70cf-401c-af29-980bc3151c67",
        "iderr": "api.bulkupload.contentCORRUPT_FILE",
        "verstatus": "v1CORRUPT_FILE",
        "tserrmsg": "2019-07-26 11:28:42:315+0000",
    "params": {Bulk content upload failed due to corrupt file"
        "resmsgid": null},
        "msgidresponseCode": "cf5b2e8e-70cf-401c-af29-980bc3151c67",
   CLIENT_ERROR",
    "err": "INVALID_FILE_FORMAT",
   result": { }
}


Response : Failure Response - BAD REQUEST (400) - Invalid File Format(Only CSV files are supported)

Code Block
{
    "statusid": "INVALID_FILE_FORMATapi.textbook.content.bulk.upload",

       "errmsgver": "Bulk content upload failed due to invalid file format"
v1",
    "ts": "2019-07-26 11:28:42:315+0000",
    "params": {
   },     "responseCoderesmsgid": "CLIENT_ERROR",null,
        "resultmsgid": { }
}

Response : Failure Response - BAD REQUEST (400) - Invalid File Template (Columns Missing)

Code Block
{"cf5b2e8e-70cf-401c-af29-980bc3151c67",
        "iderr": "api.bulkupload.contentINVALID_FILE_FORMAT",
        "verstatus": "v1INVALID_FILE_FORMAT",
        "tserrmsg": "2019-07-26 11:28:42:315+0000",
    "params": {Bulk content upload failed due to invalid file format"
    },
    "resmsgidresponseCode": null"CLIENT_ERROR",
    "result": {   "msgid": "cf5b2e8e-70cf-401c-af29-980bc3151c67",}
}


Response : Failure Response - BAD REQUEST (400) - Invalid File Template (Columns Missing)

Code Block
{
        "errid": "INVALID_FILE_TEMPLATE",
   api.textbook.content.bulk.upload",
    "statusver": "INVALID_FILE_TEMPLATEv1",
        "errmsg": "Bulk content upload failed due to invalid file template"
    },"ts": "2019-07-26 11:28:42:315+0000",
    "params": {
        "resmsgid": null,
        "responseCodemsgid": "CLIENT_ERRORcf5b2e8e-70cf-401c-af29-980bc3151c67",
    "result": { } }

Response : Failure Response - BAD REQUEST (400) - Too many rows

Code Block
{
    "iderr": "api.bulkupload.contentINVALID_FILE_TEMPLATE",
        "verstatus": "v1INVALID_FILE_TEMPLATE",
        "tserrmsg": "2019-07-26 11:28:42:315+0000",
    "params": {
Bulk content upload failed due to invalid file template"
       "resmsgid": null,
  },
     "msgidresponseCode": "cf5b2e8e-70cf-401c-af29-980bc3151c67CLIENT_ERROR",
        "errresult": "MAX_ROW_COUNT_EXCEEDED",
   { }
}


Response : Failure Response - BAD REQUEST (400) - Too many rows

Code Block
{
    "id": "api.textbook.content.bulk.upload",
    "statusver": "MAX_ROW_COUNT_EXCEEDEDv1",
        "errmsg": "Max row count allowed is <config>"
    },
    "responseCode": "CLIENT_ERROR",
    "result": { }
}

Bulk Content Upload Status Check API

HTTP Method - GET

API Endpoint - v1/bulkupload/status/:processId

Request Headers

...

Response : Success Response - OK (200) - In Queue

Code Block
{
    "id": "api.bulkupload.status",
    "ver": "v1",
    "ts": "2019-07-26 11:28:42:315+0000",
    "params": {"ts": "2019-07-26 11:28:42:315+0000",
    "params": {
        "resmsgid": null,
        "msgid": "cf5b2e8e-70cf-401c-af29-980bc3151c67",
        "err": "MAX_ROW_COUNT_EXCEEDED",
        "status": "MAX_ROW_COUNT_EXCEEDED",
        "errmsg": "Max row count allowed is <config>"
    },
    "responseCode": "CLIENT_ERROR",
    "result": { }
}



Bulk Content Upload Status Check API - GET - /v1/textbook/content/bulk/upload/status/:processId

Request Headers

Acceptapplication/json
AuthorizationBearer {{api-key}}
x-authenticated-user-token{{keycloak-token}}


Response : Success Response - OK (200) - In Queue

Code Block
{
    "id": "api.textbook.content.bulk.upload.status",
    "ver": "v1",
    "ts": "2019-07-26 11:28:42:315+0000",
    "params": {
        "resmsgid": null,
        "msgid": "cf5b2e8e-70cf-401c-af29-980bc3151c67",
        "err": null,
        "status": "success",
        "errmsg": null
    },
    "responseCode": "OK",
    "result": {
        "processId": "012813442982903808142",
		"status": "Queued",
		"totalCount": 500
    }
}


Response : Success Response - OK (200) - In Progress

Code Block
{
    "id": "api.textbook.content.bulk.upload.status",
    "ver": "v1",
    "ts": "2019-07-26 11:28:42:315+0000",
    "params": {
        "resmsgid": null,
        "msgid": "cf5b2e8e-70cf-401c-af29-980bc3151c67",
        "err": null,
        "status": "success",
        "errmsg": null
    },
    "responseCode": "OK",
    "result": {
        "processId": "012813442982903808142",
		"status": "Processing",
		"totalCount": 500,
		"successCount": 100,
		"failedCount": 10,
		"startTime": "2019-07-26 11:28:42:315+0000"
    }
}


Response : Success Response - OK (200) - Completed

Code Block
{
    "id": "api.textbook.content.bulk.upload.status",
    "ver": "v1",
    "ts": "2019-07-26 11:28:42:315+0000",
    "params": {
        "resmsgid": null,
        "msgid": "cf5b2e8e-70cf-401c-af29-980bc3151c67",
        "err": null,
        "status": "success",
        "errmsg": null
    },
    "responseCode": "OK",
    "result": {
        "processId": "012813442982903808142",
		"status": "Completed",
		"totalCount": 500,
		"successCount": 450,
		"failedCount": 50,
		"startTime": "2019-07-26 11:28:42:315+0000"
		"endTime": "2019-07-26 12:28:42:315+0000",
		"report": "signedDownloadUrl"
    }
}


Response : Failure Response - RESOURSE NOT FOUND (404) - ProcessId not found

Code Block
{
    "id": "api.textbook.content.bulk.upload.status",
    "ver": "v1",
    "ts": "2019-07-26 11:28:42:315+0000",
    "params": {
        "resmsgid": null,
        "msgid": "cf5b2e8e-70cf-401c-af29-980bc3151c67",
        "err": "PROCESS_NOT_FOUND",
        "status": "PROCESS_NOT_FOUND",
        "errmsg": "Process Id xxx is not found in the system"
    },
    "responseCode": "RESOURCE_NOT_FOUND",
    "result": { }
}


Bulk Content Upload Status List API

HTTP Method - GET

API Endpoint - /v1/textbook/content/bulk/upload/status/list

Request Headers

Acceptapplication/json
AuthorizationBearer {{api-key}}
x-authenticated-user-token{{keycloak-token}}


Response : Success Response - OK (200) - In Queue

Code Block
{
    "id": "api.textbook.content.bulk.upload.status.list",
    "ver": "v1",
    "ts": "2019-07-26 11:28:42:315+0000",
    "params": {
        "resmsgid": null,
        "msgid": "cf5b2e8e-70cf-401c-af29-980bc3151c67",
        "err": null,
        "status": "success",
        "resmsgiderrmsg": null,
    },
    "msgidresponseCode": "cf5b2e8e-70cf-401c-af29-980bc3151c67OK",
    "result": {
  		"erruserId": null"",
		"uploads":        "status[
			{
				"processId": "success012813442982903808142",
				"uploadedDate": "2018-12-12       "errmsg14:25:27:466+0530",
				"status": null
    "Completed"
			},
    "responseCode			{
				"processId": "OK012813442982903808143",
    "result				"uploadedDate": {
        "processId": "012813442982903808142"2018-12-14 12:01:36:807+0530",
				"status": "Queued",
			"totalCount": 500}
		]
    }
}


Response : Success Response - OK (200) - In Progress

...