<commit_before>package handler

import (
	"github.com/MerlinDMC/dsapid"
	"github.com/MerlinDMC/dsapid/converter"
	"github.com/MerlinDMC/dsapid/server/logger"
	"github.com/MerlinDMC/dsapid/server/middleware"
	"github.com/MerlinDMC/dsapid/storage"
	"github.com/codegangsta/martini"
	"net/http"
)

func ApiPostDatasetUpdate(encoder middleware.OutputEncoder, params martini.Params, manifests storage.ManifestStorage, converter converter.DsapiManifestEncoder, user middleware.User, req *http.Request) (int, []byte) {
	action := req.URL.Query().Get("action")

	if manifest, ok := manifests.GetOK(params["id"]); ok && action != "" {
		switch action {
		case "enable":
			logger.Infof("enabling image %s (user=%s)", manifest.Uuid, user.GetId())

			manifest.State = dsapid.ManifestStateActive
			manifest.Disabled = false
			break
		case "disable":
			logger.Infof("disabling image %s (user=%s)", manifest.Uuid, user.GetId())

			manifest.State = dsapid.ManifestStateDisabled
			manifest.Disabled = true
			break<commit_msg>make deprecating images possible via API<commit_after>package handler

import (
	"github.com/MerlinDMC/dsapid"
	"github.com/MerlinDMC/dsapid/converter"
	"github.com/MerlinDMC/dsapid/server/logger"
	"github.com/MerlinDMC/dsapid/server/middleware"
	"github.com/MerlinDMC/dsapid/storage"
	"github.com/codegangsta/martini"
	"net/http"
)

func ApiPostDatasetUpdate(encoder middleware.OutputEncoder, params martini.Params, manifests storage.ManifestStorage, converter converter.DsapiManifestEncoder, user middleware.User, req *http.Request) (int, []byte) {
	action := req.URL.Query().Get("action")

	if manifest, ok := manifests.GetOK(params["id"]); ok && action != "" {
		switch action {
		case "enable":
			logger.Infof("enabling image %s (user=%s)", manifest.Uuid, user.GetId())

			manifest.State = dsapid.ManifestStateActive
			manifest.Disabled = false
			break
		case "deprecate":
			logger.Infof("deprecating image %s (user=%s)", manifest.Uuid, user.GetId())

			manifest.State = dsapid.ManifestStateDeprecated
			manifest.Disabled = false
			break
		case "disable":
			logger.Infof("disabling image %s (user=%s)", manifest.Uuid, user.GetId())

			manifest.State = dsapid.ManifestStateDisabled
			manifest.Disabled = true
			break
{'fraction_non_alphanumeric': 0.13701067615658363, 'fraction_numerical': 0.0, 'mean_word_length': 5.045698924731183, 'pattern_counts': {'":': 5, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3600078', 'n_tokens_mistral': 820, 'n_tokens_neox': 741, 'n_words': 139}