func ApiClusterDeleteTagHandler(client consul.Client, tagsService services.TagsService) gin.HandlerFunc {
	return func(c *gin.Context) {
		id := c.Param("id")
		tag := c.Param("tag")
		clusters, err := cluster.Load(client)
		if err != nil {
			_ = c.Error(err)
			return
		}
		if _, ok := clusters[id]; !ok {
			_ = c.Error(NotFoundError("could not find cluster"))
			return
		}
		err = tagsService.Delete(tag, models.TagClusterResourceType, id)
		if err != nil {
			_ = c.Error(err)
			return
		}
		c.JSON(http.StatusNoContent, nil)
	}
}
ApiClusterDeleteTagHandler godoc
@Summary Delete a specific tag that belongs to a cluster
@Accept json
@Produce json
@Param id path string true "Cluster id"
@Param tag path string true "Tag"
@Success 204 {object} map[string]interface{}
@Router /api/clusters/{id}/tags/{tag} [delete]
package web
import (
	"net/http"
	"github.com/gin-gonic/gin"
	"github.com/trento-project/trento/internal/cluster"
	"github.com/trento-project/trento/internal/consul"
	"github.com/trento-project/trento/web/models"
	"github.com/trento-project/trento/web/services"
)
type JSONTag struct {
	Tag string `json:"tag" binding:"required"`
}
func ApiListTag(tagsService services.TagsService) gin.HandlerFunc {
	return func(c *gin.Context) {
		query := c.Request.URL.Query()
		resourceTypeFilter := query["resource_type"]
		tags, err := tagsService.GetAll(resourceTypeFilter...)
		if err != nil {
			_ = c.Error(err)
			return
		}
		if tags == nil {
			c.JSON(http.StatusOK, []string{})
			return
		}
		c.JSON(http.StatusOK, tags)
	}
}
func ApiHostCreateTagHandler(client consul.Client, tagsService services.TagsService) gin.HandlerFunc {
	return func(c *gin.Context) {
		name := c.Param("name")
		catalogNode, _, err := client.Catalog().Node(name, nil)
		if err != nil {
			_ = c.Error(err)
			return
		}
		if catalogNode == nil {
			_ = c.Error(NotFoundError("could not find host"))
			return
		}
		var r JSONTag
		err = c.BindJSON(&r)
		if err != nil {
			_ = c.Error(BadRequestError("unable to parse JSON body"))
			return
		}
		err = tagsService.Create(r.Tag, models.TagHostResourceType, name)
		if err != nil {
			_ = c.Error(err)
			return
		}
		c.JSON(http.StatusCreated, &r)
	}
}
func ApiHostDeleteTagHandler(client consul.Client, tagsService services.TagsService) gin.HandlerFunc {
	return func(c *gin.Context) {
		name := c.Param("name")
		tag := c.Param("tag")
		catalogNode, _, err := client.Catalog().Node(name, nil)
		if err != nil {
			_ = c.Error(err)
			return
		}
		if catalogNode == nil {
			_ = c.Error(NotFoundError("could not find host"))
			return
		}
		err = tagsService.Delete(tag, models.TagHostResourceType, name)
		if err != nil {
			_ = c.Error(err)
			return
		}
		c.JSON(http.StatusNoContent, nil)
	}
}
func ApiClusterCreateTagHandler(client consul.Client, tagsService services.TagsService) gin.HandlerFunc {
	return func(c *gin.Context) {
		id := c.Param("id")
		clusters, err := cluster.Load(client)
		if err != nil {
			_ = c.Error(err)
			return
		}
		if _, ok := clusters[id]; !ok {
			_ = c.Error(NotFoundError("could not find cluster"))
			return
		}
		var r JSONTag
		err = c.BindJSON(&r)
		if err != nil {
			_ = c.Error(BadRequestError("problems parsing JSON"))
			return
		}
		err = tagsService.Create(r.Tag, models.TagClusterResourceType, id)
		if err != nil {
			_ = c.Error(err)
			return
		}
		c.JSON(http.StatusCreated, &r)
	}
}