Merge "changes for the update artifact version"
authorsubhash kumar singh <subh.singh@samsung.com>
Thu, 19 Dec 2024 13:10:56 +0000 (13:10 +0000)
committerGerrit Code Review <gerrit@o-ran-sc.org>
Thu, 19 Dec 2024 13:10:56 +0000 (13:10 +0000)
1  2 
apis/mmes_apis.go

@@@ -332,6 -334,35 +334,32 @@@ func (m *MmeApiHandler) DeleteModel(con
                })
                return
        }
 -      message := "modelInfo deleted"
 -      if rowsAffected == 0 {
 -              message = fmt.Sprintf("id = %s already doesn't exist in database", id)
 -      }
 -      cont.JSON(http.StatusOK, gin.H{"message": message})
 +
 +      cont.JSON(http.StatusNoContent, nil)
  }
+ func (m *MmeApiHandler) UpdateArtifact(cont *gin.Context){
+       logging.INFO("Update artifact version of model")
+       // var modelInfo *models.ModelRelatedInformation
+       modelname := cont.Param("modelname")
+       modelversion := cont.Param("modelversion")
+       artifactversion := cont.Param("artifactversion")
+       modelInfo, err := m.iDB.GetModelInfoByNameAndVer(modelname, modelversion)
+       if err != nil {
+               logging.ERROR("error:", err)
+               cont.JSON(http.StatusInternalServerError, gin.H{
+                       "code":    http.StatusInternalServerError,
+                       "message": err.Error(),
+               })
+               return
+       }
+       modelInfo.ModelId.ArtifactVersion = artifactversion
+       if err := m.iDB.Update(*modelInfo); err != nil {
+               logging.ERROR(err)
+               return
+       }
+       logging.INFO("model updated")
+       cont.JSON(http.StatusOK, gin.H{
+               "modelinfo": modelInfo,
+       })
+ }