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

# 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]

# Packages

No description provided by the author

# Functions

CacheExpires helper function to determine remaining time before repeating a request.
IsNil checks if an input is nil.
NewAPIClient creates a new API client.
NewAPIResponse returns a new APIResponse object.
NewAPIResponseWithError returns a new APIResponse object with the provided error message.
NewCar instantiates a new Car object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewCarActionState instantiates a new CarActionState object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewCarActionStateWithDefaults instantiates a new CarActionState object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewCarActionStatusFromValue returns a pointer to a valid CarActionStatus for the value passed as argument, or an error if the value passed is not allowed by the enum.
NewCarState instantiates a new CarState object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewCarStateWithDefaults instantiates a new CarState object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewCarStatusFromValue returns a pointer to a valid CarStatus for the value passed as argument, or an error if the value passed is not allowed by the enum.
NewCarWithDefaults instantiates a new Car object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewConfiguration returns a new Configuration object.
NewError instantiates a new Error object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewErrorWithDefaults instantiates a new Error object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewGNSSPosition instantiates a new GNSSPosition object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewGNSSPositionWithDefaults instantiates a new GNSSPosition object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewMobilePhone instantiates a new MobilePhone object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewMobilePhoneWithDefaults instantiates a new MobilePhone object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewOrder instantiates a new Order object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewOrderState instantiates a new OrderState object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewOrderStateWithDefaults instantiates a new OrderState object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewOrderStatusFromValue returns a pointer to a valid OrderStatus for the value passed as argument, or an error if the value passed is not allowed by the enum.
NewOrderWithDefaults instantiates a new Order object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewPlatformHW instantiates a new PlatformHW object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewPlatformHWWithDefaults instantiates a new PlatformHW object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewRoute instantiates a new Route object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewRouteVisualization instantiates a new RouteVisualization object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewRouteVisualizationWithDefaults instantiates a new RouteVisualization object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewRouteWithDefaults instantiates a new Route object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
NewStop instantiates a new Stop object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed.
NewStopWithDefaults instantiates a new Stop object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set.
PtrBool is a helper routine that returns a pointer to given boolean value.
PtrFloat32 is a helper routine that returns a pointer to given float value.
PtrFloat64 is a helper routine that returns a pointer to given float value.
PtrInt is a helper routine that returns a pointer to given integer value.
PtrInt32 is a helper routine that returns a pointer to given integer value.
PtrInt64 is a helper routine that returns a pointer to given integer value.
PtrString is a helper routine that returns a pointer to given string value.
PtrTime is helper routine that returns a pointer to given Time value.

# Constants

List of OrderStatus.
List of OrderStatus.
List of CarStatus.
List of OrderStatus.
List of CarStatus.
List of CarStatus.
List of OrderStatus.
List of CarStatus.
List of CarActionStatus.
List of CarStatus.
List of CarActionStatus.
List of CarStatus.
List of CarStatus.
List of OrderStatus.

# Variables

All allowed values of CarActionStatus enum.
All allowed values of CarStatus enum.
All allowed values of OrderStatus enum.
ContextAPIKeys takes a string apikey as authentication for the request.
ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
ContextOperationServerIndices uses a server configuration from the index mapping.
ContextOperationServerVariables overrides a server configuration variables using operation specific values.
ContextServerIndex uses a server configuration from the index.
ContextServerVariables overrides a server configuration variables.
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
APIClient manages communication with the BringAuto Fleet Management v2 API API v3.4.3 In most cases there should be only one, shared, APIClient.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
APIKey provides API key based authentication to a request passed via context using ContextAPIKey.
No description provided by the author
No description provided by the author
No description provided by the author
APIResponse stores the API response returned by the server.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth.
Car Car model structure.
CarActionState Car Action State object structure.
CarState Car State object structure.
Configuration stores the configuration of the API client.
Error Error object structure.
GenericOpenAPIError Provides access to the body, error and model on returned errors.
GNSSPosition GNSSPosition primitive structure.
MobilePhone MobilePhone Primitive structure.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Order Order object structure.
OrderState Order state object structure.
PlatformHW PlatformHW object structure.
Route Route object structure.
RouteVisualization Route Visualization object structure.
ServerConfiguration stores the information about a server.
ServerVariable stores the information about a server variable.
Stop Stop object structure.

# Interfaces

No description provided by the author

# Type aliases

ApiAPIService ApiAPI service.
CarActionAPIService CarActionAPI service.
CarActionStatus Car Action Status enum.
CarAPIService CarAPI service.
CarStateAPIService CarStateAPI service.
CarStatus Car Status enum.
OrderAPIService OrderAPI service.
OrderStateAPIService OrderStateAPI service.
OrderStatus OrderStatus (to_accept, accepted, in_progress, done, canceled).
PlatformHWAPIService PlatformHWAPI service.
RouteAPIService RouteAPI service.
SecurityAPIService SecurityAPI service.
ServerConfigurations stores multiple ServerConfiguration items.
StopAPIService StopAPI service.