Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
39
services/ota_update_go/handlers/vehiclemodels_get.go
Normal file
39
services/ota_update_go/handlers/vehiclemodels_get.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"otaupdate/services"
|
||||
|
||||
"github.com/fiskerinc/cloud-services/pkg/utils"
|
||||
"github.com/fiskerinc/cloud-services/pkg/loggerdataresp"
|
||||
)
|
||||
|
||||
// HandleVehicleModels godoc
|
||||
// @Summary Returns vehicle models
|
||||
// @Description Returns vehicle models
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Authorization header string false "Bearer <ID token>"
|
||||
// @Param Api-Key header string false "<API token>"
|
||||
// @Success 200 {object} JSONModelsResult
|
||||
// @Failure 400 {object} common.JSONError "Bad request"
|
||||
// @Failure 401 {object} common.JSONError "Unauthorized"
|
||||
// @Failure 503 {object} common.JSONError "Service unavailable"
|
||||
// @Router /vehiclemodels [get]
|
||||
func HandleVehicleModels(w http.ResponseWriter, r *http.Request) {
|
||||
c := services.GetDB().GetCars()
|
||||
|
||||
models, err := c.GetModels()
|
||||
if loggerdataresp.BadDataErrorResp(w, err, http.StatusServiceUnavailable, loggerdataresp.PostgresNoRowsErrorCheck) {
|
||||
return
|
||||
}
|
||||
|
||||
utils.RespJSON(w, http.StatusOK, JSONModelsResult{
|
||||
Data: models,
|
||||
})
|
||||
}
|
||||
|
||||
type JSONModelsResult struct {
|
||||
Data []string `json:"data"`
|
||||
}
|
||||
Reference in New Issue
Block a user