diff --git a/routes/infrastructure-component/ic_endpoints.go b/routes/infrastructure-component/ic_endpoints.go index 1bf39ec..c806e90 100644 --- a/routes/infrastructure-component/ic_endpoints.go +++ b/routes/infrastructure-component/ic_endpoints.go @@ -35,7 +35,7 @@ func RegisterICEndpoints(r *gin.RouterGroup) { r.PUT("/:ICID", updateIC) r.GET("/:ICID", getIC) r.DELETE("/:ICID", deleteIC) - r.GET("/:ICID/models", getConfigsOfIC) + r.GET("/:ICID/configs", getConfigsOfIC) } // getICs godoc @@ -216,7 +216,7 @@ func deleteIC(c *gin.Context) { // @Failure 500 {object} docs.ResponseError "Internal server error" // @Param Authorization header string true "Authorization token" // @Param ICID path int true "Infrastructure Component ID" -// @Router /ic/{ICID}/models [get] +// @Router /ic/{ICID}/configs [get] func getConfigsOfIC(c *gin.Context) { ok, s := CheckPermissions(c, database.ModelInfrastructureComponent, database.Read, true) @@ -224,10 +224,10 @@ func getConfigsOfIC(c *gin.Context) { return } - // get all associated simulation models - allModels, _, err := s.getModels() + // get all associated configurations + allConfigs, _, err := s.getConfigs() if !helper.DBError(c, err) { - c.JSON(http.StatusOK, gin.H{"simulationModels": allModels}) + c.JSON(http.StatusOK, gin.H{"configs": allConfigs}) } } diff --git a/routes/infrastructure-component/ic_methods.go b/routes/infrastructure-component/ic_methods.go index 9ceadc7..be908e9 100644 --- a/routes/infrastructure-component/ic_methods.go +++ b/routes/infrastructure-component/ic_methods.go @@ -54,10 +54,10 @@ func (s *InfrastructureComponent) update(updatedIC InfrastructureComponent) erro func (s *InfrastructureComponent) delete() error { db := database.GetDB() - no_simulationmodels := db.Model(s).Association("SimulationModels").Count() + no_configs := db.Model(s).Association("SimulationModels").Count() - if no_simulationmodels > 0 { - return fmt.Errorf("InfrastructureComponent cannot be deleted as it is still used in SimulationModels (active or dangling)") + if no_configs > 0 { + return fmt.Errorf("InfrastructureComponent cannot be deleted as it is still used in configurations (active or dangling)") } // delete InfrastructureComponent from DB (does NOT remain as dangling) @@ -65,9 +65,9 @@ func (s *InfrastructureComponent) delete() error { return err } -func (s *InfrastructureComponent) getModels() ([]database.SimulationModel, int, error) { +func (s *InfrastructureComponent) getConfigs() ([]database.SimulationModel, int, error) { db := database.GetDB() - var models []database.SimulationModel - err := db.Order("ID asc").Model(s).Related(&models, "SimulationModels").Error - return models, len(models), err + var configs []database.SimulationModel + err := db.Order("ID asc").Model(s).Related(&configs, "SimulationModels").Error + return configs, len(configs), err }