# README
Go API client for openapi
Specification for BringAuto fleet backend HTTP API
Generation script
To regenerate the client run the regen.sh
script.
Requirements
- Java (openjdk-21-jre works)
- nodejs (v23 works)
Overview
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 3.4.3
- Package version: 2.0.0
- Generator version: 7.9.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://bringauto.com
Installation
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import openapi "github.com/bringauto/fleet-management-http-client-go"
To use a proxy, set the environment variable HTTP_PROXY
:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Configuration of Server URL
Default configuration comes with Servers
field that contains server objects as defined in the OpenAPI specification.
Select Server Configuration
For using other server than the one defined on index 0 set context value openapi.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)
Templated Server URL
Templated server URL is formatted using default variables from configuration or from context value openapi.ContextServerVariables
of type map[string]string
.
ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
URLs Configuration per Operation
Each operation can use different server URL defined using OperationServers
map in the Configuration
.
An operation is uniquely identified by "{classname}Service.{nickname}"
string.
Similar rules for overriding default operation server index and variables applies by using openapi.ContextOperationServerIndices
and openapi.ContextOperationServerVariables
context maps.
ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
Documentation for API Endpoints
All URIs are relative to /v2/management
Class | Method | HTTP request | Description |
---|---|---|---|
ApiAPI | CheckApiIsAlive | Head /apialive | Check HTTP server is running and accessible. |
CarAPI | CreateCars | Post /car | Create new Car objects. |
CarAPI | DeleteCar | Delete /car/{carId} | Delete a Car identified by its ID. |
CarAPI | GetCar | Get /car/{carId} | Find a single Car by its ID. |
CarAPI | GetCars | Get /car | Find and return all existing Cars. |
CarAPI | UpdateCars | Put /car | Update already existing Cars. |
CarActionAPI | GetCarActionStates | Get /action/car/{carId} | Finds car action states for a Car with given carId. |
CarActionAPI | PauseCar | Post /action/car/{carId}/pause | Finds and pauses a Car with given carId, if not already paused. Sets car action status to PAUSED if it is not in PAUSED action status already. |
CarActionAPI | UnpauseCar | Post /action/car/{carId}/unpause | Finds and unpauses a Car with given carId, if paused. Sets car action status to NORMAL only if it is in PAUSED action status. |
CarStateAPI | CreateCarStates | Post /carstate | Add new Car States. |
CarStateAPI | GetAllCarStates | Get /carstate | Find one or all Car States for all existing Cars. |
CarStateAPI | GetCarStates | Get /carstate/{carId} | Find one or all Car States for a Car with given ID. |
OrderAPI | CreateOrders | Post /order | Create new Orders. |
OrderAPI | DeleteOrder | Delete /order/{carId}/{orderId} | Delete an Order identified by its ID and ID of a car to which it is assigned. |
OrderAPI | GetCarOrders | Get /order/{carId} | Find existing Orders by the corresponding Car ID and return them. |
OrderAPI | GetOrder | Get /order/{carId}/{orderId} | Find an existing Order by the car ID and the order ID and return it. |
OrderAPI | GetOrders | Get /order | Find all currently existing Orders. |
OrderStateAPI | CreateOrderStates | Post /orderstate | Add new Order States. |
OrderStateAPI | GetAllOrderStates | Get /orderstate | Find Order States for all existing Orders. |
OrderStateAPI | GetOrderStates | Get /orderstate/{orderId} | Find all Order States for a particular Order specified by its ID. |
PlatformHWAPI | CreateHws | Post /platformhw | Create new Platform HW objects. |
PlatformHWAPI | DeleteHw | Delete /platformhw/{platformHwId} | Delete Platform HW with the given ID. |
PlatformHWAPI | GetHw | Get /platformhw/{platformHwId} | Find Platform HW with the given ID. |
PlatformHWAPI | GetHws | Get /platformhw | Find and return all existing Platform HW. |
RouteAPI | CreateRoutes | Post /route | Create new Routes. |
RouteAPI | DeleteRoute | Delete /route/{routeId} | Delete a Route with the specified ID. |
RouteAPI | GetRoute | Get /route/{routeId} | Find a single Route with the specified ID. |
RouteAPI | GetRouteVisualization | Get /route-visualization/{routeId} | Find Route Visualization for a Route identified by the route's ID. |
RouteAPI | GetRoutes | Get /route | Find and return all existing Routes. |
RouteAPI | RedefineRouteVisualizations | Post /route-visualization | Redefine Route Visualizations for existing Routes. |
RouteAPI | UpdateRoutes | Put /route | Update already existing Routes. |
SecurityAPI | Login | Get /login | |
SecurityAPI | TokenGet | Get /token_get | |
SecurityAPI | TokenRefresh | Get /token_refresh | |
StopAPI | CreateStops | Post /stop | Create new Stops. |
StopAPI | DeleteStop | Delete /stop/{stopId} | Delete a Stop with the specified ID. |
StopAPI | GetStop | Get /stop/{stopId} | Find and return a single Stop by its ID. |
StopAPI | GetStops | Get /stop | Find and return all existing Stops. |
StopAPI | UpdateStops | Put /stop | Update already existing Stops. |
Documentation For Models
- Car
- CarActionState
- CarActionStatus
- CarState
- CarStatus
- Error
- GNSSPosition
- MobilePhone
- Order
- OrderState
- OrderStatus
- PlatformHW
- Route
- RouteVisualization
- Stop
Documentation For Authorization
Authentication schemes defined for the API:
APIKeyAuth
- Type: API key
- API key parameter name: api_key
- Location: URL query string
Note, each API key must be added to a map of map[string]APIKey
where the key is: APIKeyAuth and passed in as the auth context for each request.
Example
auth := context.WithValue(
context.Background(),
openapi.ContextAPIKeys,
map[string]openapi.APIKey{
"APIKeyAuth": {Key: "API_KEY_STRING"},
},
)
r, err := client.Service.Operation(auth, args)
oAuth2AuthCode
- Type: OAuth
- Flow: accessCode
- Authorization URL: https://keycloak.bringauto.com/realms/bringauto/protocol/openid-connect/auth
- Scopes: N/A
Example
auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
import "golang.org/x/oauth2"
/* Perform OAuth2 round trip request and obtain a token */
tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, openapi.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)
Documentation for Utility Methods
Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBool
PtrInt
PtrInt32
PtrInt64
PtrFloat
PtrFloat32
PtrFloat64
PtrString
PtrTime