Changes to align model discovery with specification.
Change-Id: Ib782f15e2b88cf7ab22861fa90747bbac4d79ac3
Signed-off-by: subhash kumar singh <subh.singh@samsung.com>
"github.com/google/uuid"
)
+const (
+ MODELNAME = "model-name"
+ MODELVERSION = "model-version"
+)
+
type MmeApiHandler struct {
dbmgr core.DBMgr
iDB db.IDB
queryParams := cont.Request.URL.Query()
//to check only modelName and modelVersion can be passed.
allowedParams := map[string]bool{
- "modelName": true,
- "modelVersion": true,
+ MODELNAME: true,
+ MODELVERSION: true,
}
for key := range queryParams {
}
}
- modelName := cont.Query("modelName")
- modelVersion := cont.Query("modelVersion")
+ modelName := cont.Query(MODELNAME)
+ modelVersion := cont.Query(MODELVERSION)
- if modelName == "" {
+ if modelName == "" && modelVersion == "" {
//return all modelinfo stored
models, err := m.iDB.GetAll()
return
}
- cont.JSON(http.StatusOK, gin.H{
- "modelinfoList": modelInfos,
- })
+ cont.JSON(http.StatusOK, modelInfos)
return
} else {
return
}
- cont.JSON(http.StatusOK, gin.H{
- "modelinfo": modelInfo,
- })
+ response := []models.ModelRelatedInformation{*modelInfo}
+ cont.JSON(http.StatusOK, response)
return
}
}
router := routers.InitRouter(handler)
responseRecorder := httptest.NewRecorder()
- req, _ := http.NewRequest("GET", "/getModelInfo", nil)
+ req, _ := http.NewRequest("GET", "/models", nil)
router.ServeHTTP(responseRecorder, req)
response := responseRecorder.Result()
router := routers.InitRouter(handler)
responseRecorder := httptest.NewRecorder()
- req, _ := http.NewRequest("GET", "/getModelInfo", nil)
+ req, _ := http.NewRequest("GET", "/models", nil)
router.ServeHTTP(responseRecorder, req)
response := responseRecorder.Result()
### Note: update the vm ip in the host
-@host = x.x.x.x:8082
+@host = x.x.x.x:32006
### registraton
-POST http://{{host}}/registerModel
+POST http://{{host}}/model-registrations
Content-Type: application/json
{
- "id": "12345",
- "model-id": {
- "modelName": "TestModel",
+ "modelId": {
+ "modelName": "TestModel1",
"modelVersion": "v1.0"
},
"description": "This is a test model.",
- "meta-info": {
- "metadata": {
- "author": "John Doe"
- }
+ "modelInformation": {
+ "metadata": {
+ "author": "John Doe"
+ },
+ "inputDataType": "pdcp",
+ "outputDataType": "pdcp"
}
}
### Get All Models info
-GET http://{{host}}/getModelInfo
+GET http://{{host}}/models
Content-Type: application/json
### Get all Models info by name
-GET http://{{host}}/getModelInfo?modelName=TestModel
+GET http://{{host}}/models?model-name=TestModel1
Content-Type: application/json
### Get all Models info by name and version
-GET http://{{host}}/getModelInfo?modelName=TestModel&modelVersion=v1.0
+GET http://{{host}}/models?model-name=TestModel1&model-version=v1.0
Content-Type: application/json
### updated model
r.PUT("/model-registrations/:modelRegistrationId", handler.UpdateModel)
r.DELETE("/model-registrations/:modelRegistrationId", handler.DeleteModel)
- r.GET("/getModelInfo", handler.GetModelInfo)
+ r.GET("/models", handler.GetModelInfo)
+
r.GET("/getModelInfo/:modelName", handler.GetModelInfoByName)
r.POST("/uploadModel/:modelName", handler.UploadModel)
r.GET("/downloadModel/:modelName/model.zip", handler.DownloadModel)