func ApiCheckCreateSettingsByIdHandler(s services.ChecksService) gin.HandlerFunc {
	return func(c *gin.Context) {
		id := c.Param("id")
		var r JSONChecksSettings
		err := c.BindJSON(&r)
		if err != nil {
			_ = c.Error(BadRequestError("unable to parse JSON body"))
			return
		}
		err = s.CreateSelectedChecks(id, r.SelectedChecks)
		if err != nil {
			_ = c.Error(err)
			return
		}
		for node, user := range r.ConnectionSettings {
			err = s.CreateConnectionSettings(id, node, user)
			if err != nil {
				_ = c.Error(err)
				return
			}
		}
		c.JSON(http.StatusCreated, &r)
	}
}
ApiCheckCreateSettingsByIdHandler godoc
@Summary Create the check settings
@Accept json
@Produce json
@Param id path string true "Resource id"
@Param Body body JSONChecksSettings true "Checks settings"
@Success 201 {object} JSONChecksSettings
@Failure 500 {object} map[string]string
@Router /api/checks/{id}/settings [post]
package web
import (
	"net/http"
	"github.com/gin-gonic/gin"
	"github.com/trento-project/trento/internal/consul"
	"github.com/trento-project/trento/web/services"
)
type JSONChecksSettings struct {
	SelectedChecks     []string          `json:"selected_checks" binding:"required"`
	ConnectionSettings map[string]string `json:"connection_settings" binding:"required"`
}
func ApiClusterCheckResultsHandler(client consul.Client, s services.ChecksService) gin.HandlerFunc {
	return func(c *gin.Context) {
		clusterId := c.Param("cluster_id")
		checkResults, err := s.GetChecksResultAndMetadataByCluster(clusterId)
		if err != nil {
			c.Error(err)
			return
		}
		c.JSON(http.StatusOK, checkResults)
	}
}
func ApiCheckGetSettingsByIdHandler(s services.ChecksService) gin.HandlerFunc {
	return func(c *gin.Context) {
		id := c.Param("id")
		selectedChecks, err := s.GetSelectedChecksById(id)
		if err != nil {
			_ = c.Error(NotFoundError("could not find check selection"))
			return
		}
		connSettings, err := s.GetConnectionSettingsById(id)
		if err != nil {
			_ = c.Error(NotFoundError("could not find connection settings"))
			return
		}
		var jsonCheckSetting JSONChecksSettings
		jsonCheckSetting.ConnectionSettings = make(map[string]string)
		jsonCheckSetting.SelectedChecks = selectedChecks.SelectedChecks
		for node, settings := range connSettings {
			jsonCheckSetting.ConnectionSettings[node] = settings.User
		}
		c.JSON(http.StatusOK, jsonCheckSetting)
	}
}