Categorygithub.com/bringauto/fleet-management-http-client-go

# Packages

No description provided by the author

# 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

ClassMethodHTTP requestDescription
ApiAPICheckApiIsAliveHead /apialiveCheck HTTP server is running and accessible.
CarAPICreateCarsPost /carCreate new Car objects.
CarAPIDeleteCarDelete /car/{carId}Delete a Car identified by its ID.
CarAPIGetCarGet /car/{carId}Find a single Car by its ID.
CarAPIGetCarsGet /carFind and return all existing Cars.
CarAPIUpdateCarsPut /carUpdate already existing Cars.
CarActionAPIGetCarActionStatesGet /action/car/{carId}Finds car action states for a Car with given carId.
CarActionAPIPauseCarPost /action/car/{carId}/pauseFinds 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.
CarActionAPIUnpauseCarPost /action/car/{carId}/unpauseFinds and unpauses a Car with given carId, if paused. Sets car action status to NORMAL only if it is in PAUSED action status.
CarStateAPICreateCarStatesPost /carstateAdd new Car States.
CarStateAPIGetAllCarStatesGet /carstateFind one or all Car States for all existing Cars.
CarStateAPIGetCarStatesGet /carstate/{carId}Find one or all Car States for a Car with given ID.
OrderAPICreateOrdersPost /orderCreate new Orders.
OrderAPIDeleteOrderDelete /order/{carId}/{orderId}Delete an Order identified by its ID and ID of a car to which it is assigned.
OrderAPIGetCarOrdersGet /order/{carId}Find existing Orders by the corresponding Car ID and return them.
OrderAPIGetOrderGet /order/{carId}/{orderId}Find an existing Order by the car ID and the order ID and return it.
OrderAPIGetOrdersGet /orderFind all currently existing Orders.
OrderStateAPICreateOrderStatesPost /orderstateAdd new Order States.
OrderStateAPIGetAllOrderStatesGet /orderstateFind Order States for all existing Orders.
OrderStateAPIGetOrderStatesGet /orderstate/{orderId}Find all Order States for a particular Order specified by its ID.
PlatformHWAPICreateHwsPost /platformhwCreate new Platform HW objects.
PlatformHWAPIDeleteHwDelete /platformhw/{platformHwId}Delete Platform HW with the given ID.
PlatformHWAPIGetHwGet /platformhw/{platformHwId}Find Platform HW with the given ID.
PlatformHWAPIGetHwsGet /platformhwFind and return all existing Platform HW.
RouteAPICreateRoutesPost /routeCreate new Routes.
RouteAPIDeleteRouteDelete /route/{routeId}Delete a Route with the specified ID.
RouteAPIGetRouteGet /route/{routeId}Find a single Route with the specified ID.
RouteAPIGetRouteVisualizationGet /route-visualization/{routeId}Find Route Visualization for a Route identified by the route's ID.
RouteAPIGetRoutesGet /routeFind and return all existing Routes.
RouteAPIRedefineRouteVisualizationsPost /route-visualizationRedefine Route Visualizations for existing Routes.
RouteAPIUpdateRoutesPut /routeUpdate already existing Routes.
SecurityAPILoginGet /login
SecurityAPITokenGetGet /token_get
SecurityAPITokenRefreshGet /token_refresh
StopAPICreateStopsPost /stopCreate new Stops.
StopAPIDeleteStopDelete /stop/{stopId}Delete a Stop with the specified ID.
StopAPIGetStopGet /stop/{stopId}Find and return a single Stop by its ID.
StopAPIGetStopsGet /stopFind and return all existing Stops.
StopAPIUpdateStopsPut /stopUpdate already existing Stops.

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: 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

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

[email protected]