Add depot, attendant, jetfire, optimus, ota services with kustomize overlays

This commit is contained in:
Chris Rai
2026-01-31 15:35:07 -05:00
parent a0ec642ca1
commit 9a5cb2f547
404 changed files with 38817 additions and 16 deletions

View File

@@ -0,0 +1,71 @@
package handlers
import (
"net/http"
"strconv"
"otaupdate/services"
"github.com/fiskerinc/cloud-services/pkg/common"
"github.com/fiskerinc/cloud-services/pkg/db/queries"
"github.com/fiskerinc/cloud-services/pkg/utils"
"github.com/julienschmidt/httprouter"
"github.com/fiskerinc/cloud-services/pkg/loggerdataresp"
)
// HandleGetCarsByManifest godoc
// @Summary Get cars by manifest
// @Description Returns list of cars selected by manifest id
// @Accept json
// @Produce json
// @Param Authorization header string false "Bearer <ID token>"
// @Param Api-Key header string false "<API token>"
// @Param limit query int false "Max number of records"
// @Param offset query int false "Records offset"
// @Param order query string false "Sort on column with asc or desc"
// @Param manifest_id path int true "Manifest ID"
// @Success 200 {object} common.JSONDBQueryResult{data=[]common.Car} "list of cars"
// @Failure 400 {object} common.JSONError "Bad request"
// @Failure 401 {object} common.JSONError "Unauthorized"
// @Failure 503 {object} common.JSONError "Service unavailable"
// @Router /manifests/{manifest_id}/vehicles [get]
func HandleGetCarsByManifest(w http.ResponseWriter, r *http.Request) {
params := httprouter.ParamsFromContext(r.Context())
idS := params.ByName("manifest_id")
id, err := strconv.Atoi(idS)
if loggerdataresp.BadDataErrorResp(w, err, http.StatusBadRequest) {
return
}
options, err := queries.ParsePageQuery(r)
if loggerdataresp.BadDataErrorResp(w, err, http.StatusBadRequest) {
return
}
manDB := services.GetDB().GetUpdateManifests()
man := common.UpdateManifest{ID: int64(id)}
err = manDB.Load(&man)
if loggerdataresp.BadDataErrorResp(w, err, http.StatusServiceUnavailable, loggerdataresp.PostgresNoRowsErrorCheck) {
return
}
carsDB := services.GetDB().GetCars()
cars, err := carsDB.CarsByManifest(man, options)
if loggerdataresp.BadDataErrorResp(w, err, http.StatusServiceUnavailable) {
return
}
total, err := carsDB.CountCarsByManifest(man)
if loggerdataresp.BadDataErrorResp(w, err, http.StatusServiceUnavailable) {
return
}
if cars == nil {
cars = []common.Car{}
}
utils.RespJSON(w, http.StatusOK, common.JSONDBQueryResult{
Data: cars,
Total: total,
})
}