Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
52
services/ota_update_go/handlers/updatemanifest_sums_get.go
Normal file
52
services/ota_update_go/handlers/updatemanifest_sums_get.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"otaupdate/services"
|
||||
|
||||
"github.com/fiskerinc/cloud-services/pkg/common"
|
||||
orm "github.com/fiskerinc/cloud-services/pkg/db/queries"
|
||||
"github.com/fiskerinc/cloud-services/pkg/utils"
|
||||
"github.com/fiskerinc/cloud-services/pkg/loggerdataresp"
|
||||
)
|
||||
|
||||
// HandleUpdateManifestSUMSGet godoc
|
||||
// @Summary Get all update manifest versions
|
||||
// @Description Get all update manifest versions
|
||||
// @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"
|
||||
// @Success 200 {object} []common.SUMSVersion
|
||||
// @Failure 400 {object} common.JSONError "Bad request"
|
||||
// @Failure 401 {object} common.JSONError "Unauthorized"
|
||||
// @Failure 503 {object} common.JSONError "Service unavailable"
|
||||
// @Router /manifest/sums [get]
|
||||
func HandleUpdateManifestSUMSGet(w http.ResponseWriter, r *http.Request) {
|
||||
options, err := orm.ParsePageQuery(r)
|
||||
if loggerdataresp.BadDataErrorResp(w, err, http.StatusBadRequest) {
|
||||
return
|
||||
}
|
||||
if options.Order == "" {
|
||||
options.Order = "version DESC"
|
||||
}
|
||||
|
||||
sums := services.GetDB().GetUpdateManifestVersions()
|
||||
|
||||
allUpdateManifestVersions, err := sums.SelectAll(options)
|
||||
if loggerdataresp.BadDataErrorResp(w, err, http.StatusServiceUnavailable, loggerdataresp.PostgresNoRowsErrorCheck) {
|
||||
return
|
||||
}
|
||||
|
||||
total, err := sums.SelectAllCount()
|
||||
if loggerdataresp.BadDataErrorResp(w, err, http.StatusServiceUnavailable) {
|
||||
return
|
||||
}
|
||||
|
||||
utils.RespJSON(w, http.StatusOK, common.JSONDBQueryResult{
|
||||
Data: allUpdateManifestVersions,
|
||||
Total: total,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user