Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
52
services/ota_update_go/handlers/sub_config_add.go
Normal file
52
services/ota_update_go/handlers/sub_config_add.go
Normal file
@@ -0,0 +1,52 @@
|
||||
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 <ID token>"
|
||||
// @Param Api-Key header string false "<API token>"
|
||||
// @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"`
|
||||
}
|
||||
Reference in New Issue
Block a user