Skip to content

Torizon Cloud API Go code generated from OpenAPI specification

License

Notifications You must be signed in to change notification settings

commontorizon/torizon-openapi-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for openapi

This API is rate limited and will return the following headers for each API call.

  • X-RateLimit-Limit - The total number of requests allowed within a time period
  • X-RateLimit-Remaining - The total number of requests still allowed until the end of the rate limiting period
  • X-RateLimit-Reset - The number of seconds until the limit is fully reset

In addition, if an API client is rate limited, it will receive a HTTP 420 response with the following header:

  • Retry-After - The number of seconds to wait until this request is allowed

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: 2.0-Beta
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

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/commontorizon/torizon-openapi-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 https://app.torizon.io/api/v2beta

Class Method HTTP request Description
DeviceMetricsAPI GetDeviceDataDevicesDeviceuuidMetrics Get /device-data/devices/{deviceUuid}/metrics Get metrics data from a single device
DeviceMetricsAPI GetDeviceDataFleetsFleetidMetrics Get /device-data/fleets/{fleetId}/metrics Get aggregated metrics data from a fleet of devices
DeviceMetricsAPI GetDeviceDataMetricNames Get /device-data/metric-names Get the list of metrics available in your repository
DevicesAPI DeleteDevicesDeviceuuid Delete /devices/{deviceUuid} Delete a single device
DevicesAPI GetDevices Get /devices Query device information
DevicesAPI GetDevicesDeviceuuid Get /devices/{deviceUuid} Get detailed information about a single device
DevicesAPI GetDevicesNameDeviceuuid Get /devices/name/{deviceUuid} Get the display name of a single device
DevicesAPI GetDevicesNetwork Get /devices/network Get network information for many devices
DevicesAPI GetDevicesNetworkDeviceuuid Get /devices/network/{deviceUuid} Get network information for a single device
DevicesAPI GetDevicesNotesDeviceuuid Get /devices/notes/{deviceUuid} Get the device notes for a specific device
DevicesAPI GetDevicesPackages Get /devices/packages Get information about the installed packages for many devices
DevicesAPI GetDevicesPackagesDeviceuuid Get /devices/packages/{deviceUuid} Get information about the installed packages for a single device
DevicesAPI GetDevicesToken Get /devices/token Retrieve device provisioning token
DevicesAPI GetDevicesUptaneDeviceuuidAssignment Get /devices/uptane/{deviceUuid}/assignment Show detailed information about the currently-assigned update for a single device
DevicesAPI GetDevicesUptaneDeviceuuidComponents Get /devices/uptane/{deviceUuid}/components Get a list of the software components reported by a single device
DevicesAPI PostDevices Post /devices Manually create a new device
DevicesAPI PutDevicesHibernationDeviceuuid Put /devices/hibernation/{deviceUuid} Set the hibernation status of a device
DevicesAPI PutDevicesNameDeviceuuid Put /devices/name/{deviceUuid} Set the display name of a single device
DevicesAPI PutDevicesNotesDeviceuuid Put /devices/notes/{deviceUuid} Set the device notes for a specific device
FleetsAPI DeleteFleetsFleetid Delete /fleets/{fleetId} Delete a fleet
FleetsAPI DeleteFleetsFleetidDevices Delete /fleets/{fleetId}/devices Remove devices from a fleet
FleetsAPI GetFleets Get /fleets Get information about all fleets in your repository
FleetsAPI GetFleetsFleetidDevices Get /fleets/{fleetId}/devices Get information about the devices in a single fleet
FleetsAPI PostFleets Post /fleets Create a new fleet
FleetsAPI PostFleetsFleetidDevices Post /fleets/{fleetId}/devices Add devices to a fleet
PackagesAPI DeletePackagesPackageid Delete /packages/{packageId} Delete a package
PackagesAPI GetPackages Get /packages Retrieve metadata about packages in your repository
PackagesAPI GetPackagesExternal Get /packages_external Retrieve metadata about packages in your repository from other sources
PackagesAPI GetPackagesExternalInfo Get /packages_external/info Fetch information about external package sources
PackagesAPI GetPackagesExternalRefreshSourceFileName Get /packages_external/refresh/{source_file_name} Refresh metadata from an external package source
PackagesAPI PatchPackagesPackageid Patch /packages/{packageId} Edit metadata about a package
PackagesAPI PostPackages Post /packages Upload a new package
UpdatesAPI GetLockboxDetails Get /lockbox-details List all existing lockboxes on the repository, and their detailed contents
UpdatesAPI GetLockboxes Get /lockboxes List all existing lockboxes on the repository
UpdatesAPI GetLockboxesLockboxName Get /lockboxes/{lockbox_name} Get the raw Uptane metadata for a lockbox
UpdatesAPI PatchUpdates Patch /updates Cancel a pending update for one or more devices
UpdatesAPI PostLockboxesLockboxName Post /lockboxes/{lockbox_name} Define a new lockbox, or update an existing one
UpdatesAPI PostUpdates Post /updates Launch an update to one or more devices or fleets

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

BearerAuth

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

Oauth2

  • Type: OAuth
  • Flow: application
  • Authorization URL:
  • Scopes:
  • profile: Default scope; automatically added and not currently used.

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

About

Torizon Cloud API Go code generated from OpenAPI specification

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages