Skip to content

lab5e/go-spanapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for spanapi

API for device, collection, output and firmware management

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: 5.0.3 pitch-dark-elza
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://lab5e.com

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import spanapi "github.com/lab5e/go-spanapi"

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 sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), spanapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), spanapi.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 sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), spanapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), spanapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://api.lab5e.com

Class Method HTTP request Description
BlobsApi DeleteBlob Delete /span/collections/{collectionId}/blobs/{blobId} Remove a blob stored on a collection
BlobsApi ListBlobs Get /span/collections/{collectionId}/blobs List the blobs for a collection
CertificatesApi CreateCertificate Post /span/collections/{collectionId}/certificates/create Create certificate
CertificatesApi RetrieveCertificateChain Get /span/collections/{collectionId}/certificates Get certificate chain
CertificatesApi SignCertificate Post /span/collections/{collectionId}/certificates/sign Sign certificate
CertificatesApi VerifyCertificate Post /span/collections/{collectionId}/certificates/verify Verify certificate
CollectionsApi CreateCollection Post /span/collections Create collection
CollectionsApi DeleteCollection Delete /span/collections/{collectionId} Delete collection
CollectionsApi ListCollectionData Get /span/collections/{collectionId}/data Retrieve data from devices
CollectionsApi ListCollections Get /span/collections List collections
CollectionsApi RetrieveCollection Get /span/collections/{collectionId} Retrieve collection
CollectionsApi RetrieveCollectionStats Get /span/collections/{collectionId}/stats Retrieve collection statistics
CollectionsApi UpdateCollection Patch /span/collections/{collectionId} Update collection
DevicesApi AddDownstreamMessage Post /span/collections/{collectionId}/devices/{deviceId}/outbox Add message to oubox
DevicesApi CreateDevice Post /span/collections/{collectionId}/devices Create device
DevicesApi DeleteDevice Delete /span/collections/{collectionId}/devices/{deviceId} Remove device.
DevicesApi DeleteDownstreamMessage Delete /span/collections/{collectionId}/devices/{deviceId}/outbox/{messageId} Delete outgoing message
DevicesApi DeviceCertificate Get /span/collections/{collectionId}/devices/{deviceId}/certs Get issued certificate(s) for device
DevicesApi ListDeviceData Get /span/collections/{collectionId}/devices/{deviceId}/data Retrieve data from device
DevicesApi ListDevices Get /span/collections/{collectionId}/devices List devices in collection.
DevicesApi ListDownstreamMessages Get /span/collections/{collectionId}/devices/{deviceId}/outbox List the messages in the outbox
DevicesApi ListUpstreamMessages Get /span/collections/{collectionId}/devices/{deviceId}/inbox List incoming messages
DevicesApi RetrieveDevice Get /span/collections/{collectionId}/devices/{deviceId} Retrieve device
DevicesApi RetrieveDeviceStats Get /span/collections/{collectionId}/devices/{deviceId}/stats Retrieve device statistics
DevicesApi UpdateDevice Patch /span/collections/{existingCollectionId}/devices/{deviceId} Update device
FotaApi ClearFirmwareError Delete /span/collections/{collectionId}/devices/{deviceId}/fwerror Clear FOTA error
FotaApi CreateFirmware Post /span/collections/{collectionId}/firmware Create firmware
FotaApi DeleteFirmware Delete /span/collections/{collectionId}/firmware/{imageId} Delete firmware
FotaApi FirmwareUsage Get /span/collections/{collectionId}/firmware/{imageId}/usage Firmware usage
FotaApi ListFirmware Get /span/collections/{collectionId}/firmware List firmware
FotaApi RetrieveFirmware Get /span/collections/{collectionId}/firmware/{imageId} Retrieve firmware
FotaApi RetrieveFirmwareStats Get /span/collections/{collectionId}/firmware/{imageId}/stats Retrieve firmware statistics
FotaApi UpdateFirmware Patch /span/collections/{existingCollectionId}/firmware/{imageId} Update firmware
GatewaysApi CreateGateway Post /span/collections/{collectionId}/gateways Create gateway
GatewaysApi DeleteGateway Delete /span/collections/{collectionId}/gateways/{gatewayId} Delete gateway
GatewaysApi GatewayCertificates Get /span/collections/{collectionId}/gateways/{gatewayId}/certs Get issued certificate(s) for gateway
GatewaysApi ListGateways Get /span/collections/{collectionId}/gateways List gateways
GatewaysApi RetrieveGateway Get /span/collections/{collectionId}/gateways/{gatewayId} Retrieve gateway
GatewaysApi RetrieveGatewayStats Get /span/collections/{collectionId}/gateways/{gatewayId}/stats Retrieve gateway statistics
GatewaysApi UpdateGateway Patch /span/collections/{existingCollectionId}/gateways/{gatewayId} Update gateway
OutputsApi CreateOutput Post /span/collections/{collectionId}/outputs Create output
OutputsApi DeleteOutput Delete /span/collections/{collectionId}/outputs/{outputId} Delete output
OutputsApi ListOutputs Get /span/collections/{collectionId}/outputs List outputs
OutputsApi Logs Get /span/collections/{collectionId}/outputs/{outputId}/logs Output logs
OutputsApi RetrieveOutput Get /span/collections/{collectionId}/outputs/{outputId} Retrieve output
OutputsApi RetrieveOutputStats Get /span/collections/{collectionId}/outputs/{outputId}/stats Retrieve output statistics
OutputsApi Status Get /span/collections/{collectionId}/outputs/{outputId}/status Output status
OutputsApi UpdateOutput Patch /span/collections/{existingCollectionId}/outputs/{outputId} Update output
SpanApi GetSystemInfo Get /span/system System information

Documentation For Models

Documentation For Authorization

APIToken

  • Type: API key
  • API key parameter name: X-API-Token
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: X-API-Token and passed in as the auth context for each request.

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

dev@lab5e.com