Skip to content

bringauto/fleet-management-http-client-go

Repository files navigation

Go API client for openapi

Specification for BringAuto fleet backend HTTP API

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.1.0
  • Package version: 2.0.0
  • Generator version: 7.6.0-SNAPSHOT
  • 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 CreateCar Post /car Create a new Car object.
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 UpdateCar Put /car Update already existing Car.
CarStateAPI AddCarState Post /carstate Add a new Car State.
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 CreateOrder Post /order Create a new Order.
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 CreateOrderState Post /orderstate Add a new Order State.
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 CreateHw Post /platformhw Create a new Platform HW object.
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 CreateRoute Post /route Create a new Route.
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 RedefineRouteVisualization Post /route-visualization Redefine Route Visualization for an existing Route.
RouteAPI UpdateRoute Put /route Update already existing Route.
SecurityAPI Login Get /login
SecurityAPI TokenGet Get /token_get
SecurityAPI TokenRefresh Get /token_refresh
StopAPI CreateStop Post /stop Create a new Stop.
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 UpdateStop Put /stop Update already existing Stop.

Documentation For Models

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: api_key and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"api_key": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

oAuth2AuthCode

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

Author

fleet@bringauto.com