Files
cloud-services/services/ota_update_go/handlers/sub_config_update.go

39 lines
1.3 KiB
Go

package handlers
import (
"net/http"
"otaupdate/controllers"
"otaupdate/services"
"github.com/fiskerinc/cloud-services/pkg/common"
"github.com/go-pg/pg/v10/orm"
)
// @deprecated
// HandleSubscriptionConfigUpdate godoc
// @Summary Update subscription package
// @Description Update subscription package
// @Accept json
// @Produce json
// @Param Authorization header string false "Bearer <ID token>"
// @Param Api-Key header string false "<API token>"
// @Param config body common.SubscriptionConfiguration true "Subscription configuration data"
// @Success 200 {object} common.SubscriptionConfiguration
// @Failure 400 {object} common.JSONError "Bad request"
// @Failure 401 {object} common.JSONError "Unauthorized"
// @Failure 503 {object} common.JSONError "Service unavailable"
// @Router /subscriptionconfig [put]
func HandleSubscriptionConfigUpdate(w http.ResponseWriter, r *http.Request) {
subscriptionConfigUpdate.Handle(w, r)
}
var subscriptionConfigUpdate = controllers.NewUpdate(&subscriptionConfigUpdateHelper{})
type subscriptionConfigUpdateHelper struct {
SubscriptionConfigsHelper
}
func (h *subscriptionConfigUpdateHelper) QueryUpdate(model interface{}) (orm.Result, error) {
return services.GetDB().GetSubConfigurations().Update(model.(*common.SubscriptionConfiguration))
}