From: subhash kumar singh Date: Thu, 19 Dec 2024 13:10:56 +0000 (+0000) Subject: Merge "changes for the update artifact version" X-Git-Tag: 4.0.0~17 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=2f038f640e1d5fcaeae981eafe739398f5e846bc;p=aiml-fw%2Fawmf%2Fmodelmgmtservice.git Merge "changes for the update artifact version" --- 2f038f640e1d5fcaeae981eafe739398f5e846bc diff --cc apis/mmes_apis.go index c31fff5,aa5e2b9..017c417 --- a/apis/mmes_apis.go +++ b/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, + }) + }