Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
56
services/ota_update_go/handlers/sub_config_delete.go
Normal file
56
services/ota_update_go/handlers/sub_config_delete.go
Normal file
@@ -0,0 +1,56 @@
|
||||
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"
|
||||
"github.com/gorilla/schema"
|
||||
)
|
||||
|
||||
// @deprecated
|
||||
// HandleSubscriptionConfigDelete godoc
|
||||
// @Summary Delete subscription configuration
|
||||
// @Description Delete subscription configuration data. Requires delete permissions
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Authorization header string false "Bearer <ID token>"
|
||||
// @Param Api-Key header string false "<API token>"
|
||||
// @Param feature_id query string true "Subscription feature id"
|
||||
// @Param ecu query string true "ECU name"
|
||||
// @Success 200 {object} common.JSONMessage
|
||||
// @Failure 400 {object} common.JSONError "Bad request"
|
||||
// @Failure 401 {object} common.JSONError "Unauthorized"
|
||||
// @Failure 503 {object} common.JSONError "Service unavailable"
|
||||
// @Router /subscriptionconfig [delete]
|
||||
func HandleSubscriptionConfigDelete(w http.ResponseWriter, r *http.Request) {
|
||||
subscriptionConfigDelete.Handle(w, r)
|
||||
}
|
||||
|
||||
var subscriptionConfigDelete = controllers.NewDelete(&subscriptionConfigDeleteHelper{})
|
||||
|
||||
type subscriptionConfigDeleteHelper struct {
|
||||
SubscriptionConfigsHelper
|
||||
}
|
||||
|
||||
func (h *subscriptionConfigDeleteHelper) ParseDeleteQueryParams(r *http.Request) interface{} {
|
||||
req := common.SubscriptionConfiguration{}
|
||||
decoder := schema.NewDecoder()
|
||||
|
||||
decoder.SetAliasTag("json")
|
||||
decoder.Decode(&req, r.URL.Query())
|
||||
|
||||
return &req
|
||||
}
|
||||
|
||||
func (h *subscriptionConfigDeleteHelper) QueryDelete(model interface{}) (orm.Result, error) {
|
||||
return services.GetDB().GetSubConfigurations().Delete(model.(*common.SubscriptionConfiguration))
|
||||
}
|
||||
|
||||
type SubscriptionConfigurationDeleteRequest struct {
|
||||
SubscriptionFeatureID uuid.UUID `validate:"required"`
|
||||
ECU string `validate:"required,max=100"`
|
||||
}
|
||||
Reference in New Issue
Block a user