package handlers import ( "net/http" "otaupdate/controllers" "otaupdate/services" "github.com/fiskerinc/cloud-services/pkg/common" "github.com/go-pg/pg/v10/orm" "github.com/google/uuid" ) // @deprecated // HandleSubscriptionConfigAdd godoc // @Summary Add subscription config // @Description Create subscription config // @Accept json // @Produce json // @Param Authorization header string false "Bearer " // @Param Api-Key header string false "" // @Param config body SubConfigRequest true "Subscription config 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 [post] func HandleSubscriptionConfigAdd(w http.ResponseWriter, r *http.Request) { subscriptionConfigAdd.Handle(w, r) } var subscriptionConfigAdd = controllers.NewCreate(&subscriptionConfigsCreateHelper{}) type subscriptionConfigsCreateHelper struct { SubscriptionConfigsHelper } func (h *subscriptionConfigsCreateHelper) QueryInsert(model interface{}) (orm.Result, error) { return services.GetDB().GetSubConfigurations().Insert(model.(*common.SubscriptionConfiguration)) } type SubConfigRequest struct { SubscriptionFeatureID uuid.UUID `json:"feature_id"` ECU string `json:"name"` SoftwareVersion string `json:"sw_version"` HardwareVersion string `json:"hw_version"` Configuration []byte `json:"configuration"` DID []byte `json:"did"` PID []byte `json:"pid"` Mask []byte `json:"mask"` }