Help us shape the future of Go! Take the 2026 Go Developer Survey

api

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2022 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	Router *mux.Router

	*database.Store
	*util.Formatter
	// contains filtered or unexported fields
}

func NewServer

func NewServer(conn *pgxpool.Pool) *Server

func (*Server) CreateBreak

func (server *Server) CreateBreak(w http.ResponseWriter, r *http.Request)

CreateBreak godoc @Summary Create a new break @Description Create a new break with the input payload @Tags Break @Accept application/json @Produce application/json @Param vehicle_id path int true "Vehicle ID" @Param Break body database.CreateBreakParams true "Create break" @Success 200 {object} util.SuccessResponse{data=database.Break} @Failure 400 {object} util.ErrorResponse @Router /vehicles/{vehicle_id}/breaks [post]

func (*Server) CreateJob

func (server *Server) CreateJob(w http.ResponseWriter, r *http.Request)

CreateJob godoc @Summary Create a new job @Description Create a new job with the input payload @Tags Job @Accept application/json @Produce application/json @Param project_id path int true "Project ID" @Param Job body database.CreateJobParams true "Job object" @Success 200 {object} util.SuccessResponse{data=database.Job} @Failure 400 {object} util.ErrorResponse @Router /projects/{project_id}/jobs [post]

func (*Server) CreateProject

func (server *Server) CreateProject(w http.ResponseWriter, r *http.Request)

CreateProject godoc @Summary Create a new project @Description Create a new project with the input payload @Description The "duration_calc" parameter must be either "euclidean", "valhalla" or "osrm" @Tags Project @Accept application/json @Produce application/json @Param Project body database.CreateProjectParams true "Create project" @Success 200 {object} util.SuccessResponse{data=database.Project} @Failure 400 {object} util.ErrorResponse @Router /projects [post]

func (*Server) CreateSchedule

func (server *Server) CreateSchedule(w http.ResponseWriter, r *http.Request)

CreateSchedule godoc @Summary Schedule the tasks @Description Schedule the tasks present in a project, deleting any previous schedule and return the new schedule. @Description @Description When fresh = true, the old schedule is ignored and a fresh schedule is created. Otherwise, the old schedule of each task is altered such that it remains in the "max_shift" interval. Default value is false. @Description **For JSON content type**: When overview = true, only the metadata is returned. Default value is false, which also returns the summary object. @Tags Schedule @Accept application/json @Produce application/json @Param project_id path int true "Project ID" @Param fresh query bool false "Fresh" @Param overview query bool false "Overview" @Success 201 {object} util.SuccessResponse{data=util.ScheduleData} @Failure 400 {object} util.ErrorResponse @Router /projects/{project_id}/schedule [post]

func (*Server) CreateShipment

func (server *Server) CreateShipment(w http.ResponseWriter, r *http.Request)

CreateShipments godoc @Summary Create a new shipment @Description Create a new shipment with the input payload @Tags Shipment @Accept application/json @Produce application/json @Param project_id path int true "Project ID" @Param Shipment body database.CreateShipmentParams true "Create shipment" @Success 200 {object} util.SuccessResponse{data=database.Shipment} @Failure 400 {object} util.ErrorResponse @Router /projects/{project_id}/shipments [post]

func (*Server) CreateVehicle

func (server *Server) CreateVehicle(w http.ResponseWriter, r *http.Request)

CreateVehicles godoc @Summary Create a new vehicle @Description Create a new vehicle with the input payload @Tags Vehicle @Accept application/json @Produce application/json @Param project_id path int true "Project ID" @Param Vehicle body database.CreateVehicleParams true "Create vehicle" @Success 200 {object} util.SuccessResponse{data=database.Vehicle} @Failure 400 {object} util.ErrorResponse @Router /projects/{project_id}/vehicles [post]

func (*Server) DeleteBreak

func (server *Server) DeleteBreak(w http.ResponseWriter, r *http.Request)

DeleteBreak godoc @Summary Delete a break @Description Delete a break with its break_id @Tags Break @Accept application/json @Produce application/json @Param break_id path int true "Break ID" @Success 200 {object} util.Success @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /breaks/{break_id} [delete]

func (*Server) DeleteJob

func (server *Server) DeleteJob(w http.ResponseWriter, r *http.Request)

GetJob godoc @Summary Delete a job @Description Delete a job with its job_id @Tags Job @Accept application/json @Produce application/json @Param job_id path int true "Job ID" @Success 200 {object} util.Success @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /jobs/{job_id} [delete]

func (*Server) DeleteProject

func (server *Server) DeleteProject(w http.ResponseWriter, r *http.Request)

DeleteProject godoc @Summary Delete a project @Description Delete a project with its project_id @Tags Project @Accept application/json @Produce application/json @Param project_id path int true "Project ID" @Success 200 {object} util.Success @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /projects/{project_id} [delete]

func (*Server) DeleteSchedule

func (server *Server) DeleteSchedule(w http.ResponseWriter, r *http.Request)

DeleteSchedule godoc @Summary Delete the schedule @Description Delete the schedule for a project @Tags Schedule @Accept application/json @Produce application/json @Param project_id path int true "Project ID" @Success 200 {object} util.Success @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /projects/{project_id}/schedule [delete]

func (*Server) DeleteShipment

func (server *Server) DeleteShipment(w http.ResponseWriter, r *http.Request)

DeleteShipment godoc @Summary Delete a shipment @Description Delete a shipment with its shipment_id @Tags Shipment @Accept application/json @Produce application/json @Param shipment_id path int true "Shipment ID" @Success 200 {object} util.Success @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /shipments/{shipment_id} [delete]

func (*Server) DeleteVehicle

func (server *Server) DeleteVehicle(w http.ResponseWriter, r *http.Request)

DeleteVehicle godoc @Summary Delete a vehicle @Description Delete a vehicle with its vehicle_id @Tags Vehicle @Accept application/json @Produce application/json @Param vehicle_id path int true "Vehicle ID" @Success 200 {object} util.Success @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /vehicles/{vehicle_id} [delete]

func (*Server) GetBreak

func (server *Server) GetBreak(w http.ResponseWriter, r *http.Request)

GetBreak godoc @Summary Fetch a break @Description Fetch a break with its break_id @Tags Break @Accept application/json @Produce application/json @Param break_id path int true "Break ID" @Success 200 {object} util.SuccessResponse{data=database.Break} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /breaks/{break_id} [get]

func (*Server) GetJob

func (server *Server) GetJob(w http.ResponseWriter, r *http.Request)

GetJob godoc @Summary Fetch a job @Description Fetch a job with its job_id @Tags Job @Accept application/json @Produce application/json @Param job_id path int true "Job ID" @Success 200 {object} util.SuccessResponse{data=database.Job} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /jobs/{job_id} [get]

func (*Server) GetJobSchedule

func (server *Server) GetJobSchedule(w http.ResponseWriter, r *http.Request)

GetJobSchedule godoc @Summary Get the schedule for a job @Description Get the schedule for a job using job_id @Tags Job @Accept application/json @Produce text/calendar,application/json @Param job_id path int true "Job ID" @Success 200 {object} util.SuccessResponse{data=[]util.ScheduleDataTask} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /jobs/{job_id}/schedule [get]

func (*Server) GetProject

func (server *Server) GetProject(w http.ResponseWriter, r *http.Request)

GetProject godoc @Summary Fetch a project @Description Fetch a project with its project_id @Tags Project @Accept application/json @Produce application/json @Param project_id path int true "Project ID" @Success 200 {object} util.SuccessResponse{data=database.Project} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /projects/{project_id} [get]

func (*Server) GetSchedule

func (server *Server) GetSchedule(w http.ResponseWriter, r *http.Request)

GetSchedule godoc @Summary Get the schedule @Description Get the schedule for a project. @Description @Description **For JSON content type**: When overview = true, only the metadata is returned. Default value is false, which also returns the summary object. @Tags Schedule @Accept application/json @Produce text/calendar,application/json @Param project_id path int true "Project ID" @Param overview query bool false "Overview" @Success 200 {object} util.SuccessResponse{data=util.ScheduleData} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /projects/{project_id}/schedule [get]

func (*Server) GetShipment

func (server *Server) GetShipment(w http.ResponseWriter, r *http.Request)

GetShipment godoc @Summary Fetch a shipment @Description Fetch a shipment with its shipment_id @Tags Shipment @Accept application/json @Produce application/json @Param shipment_id path int true "Shipment ID" @Success 200 {object} util.SuccessResponse{data=database.Shipment} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /shipments/{shipment_id} [get]

func (*Server) GetShipmentSchedule

func (server *Server) GetShipmentSchedule(w http.ResponseWriter, r *http.Request)

GetShipmentSchedule godoc @Summary Get the schedule for a shipment @Description Get the schedule for a shipment using shipment_id @Tags Shipment @Accept application/json @Produce text/calendar,application/json @Param shipment_id path int true "Shipment ID" @Success 200 {object} util.SuccessResponse{data=[]util.ScheduleDataTask} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /shipments/{shipment_id}/schedule [get]

func (*Server) GetVehicle

func (server *Server) GetVehicle(w http.ResponseWriter, r *http.Request)

GetVehicle godoc @Summary Fetch a vehicle @Description Fetch a vehicle with its vehicle_id @Tags Vehicle @Accept application/json @Produce application/json @Param vehicle_id path int true "Vehicle ID" @Success 200 {object} util.SuccessResponse{data=database.Vehicle} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /vehicles/{vehicle_id} [get]

func (*Server) GetVehicleSchedule

func (server *Server) GetVehicleSchedule(w http.ResponseWriter, r *http.Request)

GetVehicleSchedule godoc @Summary Get the schedule for a vehicle @Description Get the schedule for a vehicle using vehicle_id @Description @Description **For JSON content type**: When overview = true, only the metadata is returned. Default value is false, which also returns the summary object. @Tags Vehicle @Accept application/json @Produce text/calendar,application/json @Param vehicle_id path int true "Vehicle ID" @Param overview query bool false "Overview" @Success 200 {object} util.SuccessResponse{data=[]util.ScheduleDB} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /vehicles/{vehicle_id}/schedule [get]

func (*Server) ListBreaks

func (server *Server) ListBreaks(w http.ResponseWriter, r *http.Request)

ListBreaks godoc @Summary List breaks @Description Get a list of breaks @Tags Break @Accept application/json @Produce application/json @Param vehicle_id path int true "Vehicle ID" @Success 200 {object} util.SuccessResponse{data=[]database.Break} @Failure 400 {object} util.ErrorResponse @Router /vehicles/{vehicle_id}/breaks [get]

func (*Server) ListJobs

func (server *Server) ListJobs(w http.ResponseWriter, r *http.Request)

ListJobs godoc @Summary List jobs for a project @Description Get a list of jobs for a project with project_id @Tags Job @Accept application/json @Produce application/json @Param project_id path int true "Project ID" @Success 200 {object} util.SuccessResponse{data=[]database.Job} @Failure 400 {object} util.ErrorResponse @Router /projects/{project_id}/jobs [get]

func (*Server) ListProjects

func (server *Server) ListProjects(w http.ResponseWriter, r *http.Request)

ListProjects godoc @Summary List projects @Description Get a list of projects @Tags Project @Accept application/json @Produce application/json @Success 200 {object} util.SuccessResponse{data=[]database.Project} @Failure 400 {object} util.ErrorResponse @Router /projects [get]

func (*Server) ListShipments

func (server *Server) ListShipments(w http.ResponseWriter, r *http.Request)

ListShipments godoc @Summary List shipments for a project @Description Get a list of shipments for a project with project_id @Tags Shipment @Accept application/json @Produce application/json @Param project_id path int true "Project ID" @Success 200 {object} util.SuccessResponse{data=[]database.Shipment} @Failure 400 {object} util.ErrorResponse @Router /projects/{project_id}/shipments [get]

func (*Server) ListVehicles

func (server *Server) ListVehicles(w http.ResponseWriter, r *http.Request)

ListVehicles godoc @Summary List vehicles for a project @Description Get a list of vehicles for a project with project_id @Tags Vehicle @Accept application/json @Produce application/json @Param project_id path int true "Project ID" @Success 200 {object} util.SuccessResponse{data=[]database.Vehicle} @Failure 400 {object} util.ErrorResponse @Router /projects/{project_id}/vehicles [get]

func (*Server) Start

func (server *Server) Start(port string) error

func (*Server) UpdateBreak

func (server *Server) UpdateBreak(w http.ResponseWriter, r *http.Request)

UpdateBreak godoc @Summary Update a break @Description Update a break with its break_id @Tags Break @Accept application/json @Produce application/json @Param break_id path int true "Break ID" @Param Break body database.CreateBreakParams true "Update break" @Success 200 {object} util.SuccessResponse{data=database.Break} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /breaks/{break_id} [patch]

func (*Server) UpdateJob

func (server *Server) UpdateJob(w http.ResponseWriter, r *http.Request)

GetJob godoc @Summary Update a job @Description Update a job (partial update) with its job_id @Tags Job @Accept application/json @Produce application/json @Param job_id path int true "Job ID" @Param Job body database.UpdateJobParams true "Job object" @Success 200 {object} util.SuccessResponse{data=database.Job} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /jobs/{job_id} [patch]

func (*Server) UpdateProject

func (server *Server) UpdateProject(w http.ResponseWriter, r *http.Request)

UpdateProject godoc @Summary Update a project @Description Update a project with its project_id @Description The "duration_calc" parameter must be either "euclidean", "valhalla" or "osrm" @Tags Project @Accept application/json @Produce application/json @Param project_id path int true "Project ID" @Param Project body database.CreateProjectParams true "Update project" @Success 200 {object} util.SuccessResponse{data=database.Project} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /projects/{project_id} [patch]

func (*Server) UpdateShipment

func (server *Server) UpdateShipment(w http.ResponseWriter, r *http.Request)

UpdateShipment godoc @Summary Update a shipment @Description Update a shipment with its shipment_id @Tags Shipment @Accept application/json @Produce application/json @Param shipment_id path int true "Shipment ID" @Param Shipment body database.UpdateShipmentParams true "Update shipment" @Success 200 {object} util.SuccessResponse{data=database.Shipment} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /shipments/{shipment_id} [patch]

func (*Server) UpdateVehicle

func (server *Server) UpdateVehicle(w http.ResponseWriter, r *http.Request)

UpdateVehicle godoc @Summary Update a vehicle @Description Update a vehicle with its vehicle_id @Tags Vehicle @Accept application/json @Produce application/json @Param vehicle_id path int true "Vehicle ID" @Param Vehicle body database.UpdateVehicleParams true "Update vehicle" @Success 200 {object} util.SuccessResponse{data=database.Vehicle} @Failure 400 {object} util.ErrorResponse @Failure 404 {object} util.NotFound @Router /vehicles/{vehicle_id} [patch]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL