Skip to content

blues/notehub-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for notehub

The OpenAPI definition for the Notehub.io 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: 1.2.0
  • Package version: 1.0.0
  • Generator version: 7.17.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://dev.blues.io/support/

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 notehub "github.com/blues/notehub-go"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Updating the Auto-Generated notehub-go Package

When the openapi.yaml file is updated in the original Notehub repo which this library supports, the updated file is copied over into a new feature branch in this repo through the magic of GitHub Actions.

When this occurs, it's time to regenerate the notehub-go Go package based on the newly updated openapi.yaml.

To regenerate the notehub-go package:

  1. Git clone the repo from GitHub.

    git clone git@github.com:blues/notehub-go.git
  2. Check out the newly created remote branch from GitHub locally. (It will be named something like feat-XYZ.)

  3. At the root of the project, run the following script command from your terminal:

    ./scripts.sh generate_and_format

This command will run the following subcommands:

  • remove_deprecated_parameters - This makes a copy of the openapi.yaml file named openapi_filtered.yaml which has removed any query parameters marked as deprecated from the openapi.yaml file. Removing these now deprecated params ensures the generated SDK docs and sample code is clear and up to date, and no longer has potentially confusing artifacts to trip up users.
  • generate_package - This kicks off the OpenAPI Generator tool to generate a new copy of the library (using the newly updated openapi_filtered.yaml file).
  • format_code - This runs gofmt and goimports on the Go files, and Prettier on the markdown docs within the docs/ directory to make them look nice.
  • init_go_module - This initializes the Go module if it doesn't exist.
  • tidy_go_dependencies - This tidies up the Go module dependencies.

Once all of these steps have successfully run, you'll be ready to merge the change to main and publish a new release.

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

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

Templated Server URL

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

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

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

Documentation for API Endpoints

All URIs are relative to https://api.notefile.net

Class Method HTTP request Description
AlertAPI GetAlerts Get /v1/projects/{projectOrProductUID}/alerts
AuthorizationAPI Login Post /auth/login
AuthorizationAPI OAuth2ClientCredentials Post /oauth2/token Issue an OAuth 2.0 access token (Client Credentials)
BillingAccountAPI GetBillingAccounts Get /v1/billing-accounts
DeviceAPI AddDbNote Post /v1/projects/{projectOrProductUID}/devices/{deviceUID}/notes/{notefileID}/{noteID}
DeviceAPI AddQiNote Post /v1/projects/{projectOrProductUID}/devices/{deviceUID}/notes/{notefileID}
DeviceAPI DeleteDbNote Delete /v1/projects/{projectOrProductUID}/devices/{deviceUID}/notes/{notefileID}/{noteID}
DeviceAPI DeleteDevice Delete /v1/projects/{projectOrProductUID}/devices/{deviceUID}
DeviceAPI DeleteDeviceEnvironmentVariable Delete /v1/projects/{projectOrProductUID}/devices/{deviceUID}/environment_variables/{key}
DeviceAPI DeleteNotefiles Delete /v1/projects/{projectOrProductUID}/devices/{deviceUID}/files
DeviceAPI DisableDevice Post /v1/projects/{projectOrProductUID}/devices/{deviceUID}/disable
DeviceAPI DisableDeviceConnectivityAssurance Post /v1/projects/{projectOrProductUID}/devices/{deviceUID}/disable-connectivity-assurance
DeviceAPI EnableDevice Post /v1/projects/{projectOrProductUID}/devices/{deviceUID}/enable
DeviceAPI EnableDeviceConnectivityAssurance Post /v1/projects/{projectOrProductUID}/devices/{deviceUID}/enable-connectivity-assurance
DeviceAPI GetDbNote Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/notes/{notefileID}/{noteID}
DeviceAPI GetDevice Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}
DeviceAPI GetDeviceEnvironmentHierarchy Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/environment_hierarchy Get environment variable hierarchy for a device
DeviceAPI GetDeviceEnvironmentVariables Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/environment_variables
DeviceAPI GetDeviceEnvironmentVariablesByPin Get /v1/products/{productUID}/devices/{deviceUID}/environment_variables_with_pin
DeviceAPI GetDeviceHealthLog Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/health-log
DeviceAPI GetDeviceLatestEvents Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/latest
DeviceAPI GetDevicePlans Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/plans
DeviceAPI GetDevicePublicKey Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/public-key
DeviceAPI GetDevicePublicKeys Get /v1/projects/{projectOrProductUID}/devices/public-keys
DeviceAPI GetDeviceSessions Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/sessions
DeviceAPI GetDevices Get /v1/projects/{projectOrProductUID}/devices
DeviceAPI GetFleetDevices Get /v1/projects/{projectOrProductUID}/fleets/{fleetUID}/devices
DeviceAPI GetNotefile Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/notes/{notefileID}/changes
DeviceAPI ListNotefiles Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/files/changes
DeviceAPI ListPendingNotefiles Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/files/changes/pending
DeviceAPI ProvisionDevice Post /v1/projects/{projectOrProductUID}/devices/{deviceUID}/provision
DeviceAPI SetDeviceEnvironmentVariables Put /v1/projects/{projectOrProductUID}/devices/{deviceUID}/environment_variables
DeviceAPI SetDeviceEnvironmentVariablesByPin Put /v1/products/{productUID}/devices/{deviceUID}/environment_variables_with_pin
DeviceAPI SignalDevice Post /v1/projects/{projectOrProductUID}/devices/{deviceUID}/signal
DeviceAPI UpdateDbNote Put /v1/projects/{projectOrProductUID}/devices/{deviceUID}/notes/{notefileID}/{noteID}
EventAPI GetEvents Get /v1/projects/{projectOrProductUID}/events
EventAPI GetEventsByCursor Get /v1/projects/{projectOrProductUID}/events-cursor
EventAPI GetFleetEvents Get /v1/projects/{projectOrProductUID}/fleets/{fleetUID}/events
EventAPI GetFleetEventsByCursor Get /v1/projects/{projectOrProductUID}/fleets/{fleetUID}/events-cursor
EventAPI GetRouteLogsByEvent Get /v1/projects/{projectOrProductUID}/events/{eventUID}/route-logs
ExternalDevicesAPI CreateEventExtDevice Post /v1/products/{productUID}/ext-devices/{deviceUID}/event
ExternalDevicesAPI ExtDeviceSessionClose Post /v1/products/{productUID}/ext-devices/{deviceUID}/session/close
ExternalDevicesAPI ExtDeviceSessionOpen Post /v1/products/{productUID}/ext-devices/{deviceUID}/session/open
MonitorAPI CreateMonitor Post /v1/projects/{projectOrProductUID}/monitors
MonitorAPI DeleteMonitor Delete /v1/projects/{projectOrProductUID}/monitors/{monitorUID}
MonitorAPI GetMonitor Get /v1/projects/{projectOrProductUID}/monitors/{monitorUID}
MonitorAPI GetMonitors Get /v1/projects/{projectOrProductUID}/monitors
MonitorAPI UpdateMonitor Put /v1/projects/{projectOrProductUID}/monitors/{monitorUID}
ProjectAPI AddDeviceToFleets Put /v1/projects/{projectOrProductUID}/devices/{deviceUID}/fleets
ProjectAPI CloneProject Post /v1/projects/{projectOrProductUID}/clone
ProjectAPI CreateFleet Post /v1/projects/{projectOrProductUID}/fleets
ProjectAPI CreateProduct Post /v1/projects/{projectOrProductUID}/products
ProjectAPI CreateProject Post /v1/projects
ProjectAPI DeleteDeviceFromFleets Delete /v1/projects/{projectOrProductUID}/devices/{deviceUID}/fleets
ProjectAPI DeleteFleet Delete /v1/projects/{projectOrProductUID}/fleets/{fleetUID}
ProjectAPI DeleteFleetEnvironmentVariable Delete /v1/projects/{projectOrProductUID}/fleets/{fleetUID}/environment_variables/{key}
ProjectAPI DeleteProduct Delete /v1/projects/{projectOrProductUID}/products/{productUID}
ProjectAPI DeleteProject Delete /v1/projects/{projectOrProductUID}
ProjectAPI DeleteProjectEnvironmentVariable Delete /v1/projects/{projectOrProductUID}/environment_variables/{key}
ProjectAPI DisableGlobalEventTransformation Post /v1/projects/{projectOrProductUID}/global-transformation/disable
ProjectAPI EnableGlobalEventTransformation Post /v1/projects/{projectOrProductUID}/global-transformation/enable
ProjectAPI GetDeviceDfuHistory Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/dfu/{firmwareType}/history
ProjectAPI GetDeviceDfuStatus Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/dfu/{firmwareType}/status
ProjectAPI GetDeviceFleets Get /v1/projects/{projectOrProductUID}/devices/{deviceUID}/fleets
ProjectAPI GetDevicesDfuHistory Get /v1/projects/{projectOrProductUID}/dfu/{firmwareType}/history
ProjectAPI GetDevicesDfuStatus Get /v1/projects/{projectOrProductUID}/dfu/{firmwareType}/status
ProjectAPI GetFirmwareInfo Get /v1/projects/{projectOrProductUID}/firmware
ProjectAPI GetFleet Get /v1/projects/{projectOrProductUID}/fleets/{fleetUID}
ProjectAPI GetFleetEnvironmentHierarchy Get /v1/projects/{projectOrProductUID}/fleets/{fleetUID}/environment_hierarchy Get environment variable hierarchy for a device
ProjectAPI GetFleetEnvironmentVariables Get /v1/projects/{projectOrProductUID}/fleets/{fleetUID}/environment_variables
ProjectAPI GetFleets Get /v1/projects/{projectOrProductUID}/fleets
ProjectAPI GetNotefileSchemas Get /v1/projects/{projectOrProductUID}/schemas Get variable format for a notefile
ProjectAPI GetProducts Get /v1/projects/{projectOrProductUID}/products
ProjectAPI GetProject Get /v1/projects/{projectOrProductUID}
ProjectAPI GetProjectByProduct Get /v1/products/{productUID}/project
ProjectAPI GetProjectEnvironmentHierarchy Get /v1/projects/{projectOrProductUID}/environment_hierarchy Get environment variable hierarchy for a device
ProjectAPI GetProjectEnvironmentVariables Get /v1/projects/{projectOrProductUID}/environment_variables
ProjectAPI GetProjectMembers Get /v1/projects/{projectOrProductUID}/members
ProjectAPI GetProjects Get /v1/projects
ProjectAPI PerformDfuAction Post /v1/projects/{projectOrProductUID}/dfu/{firmwareType}/{action}
ProjectAPI SetFleetEnvironmentVariables Put /v1/projects/{projectOrProductUID}/fleets/{fleetUID}/environment_variables
ProjectAPI SetGlobalEventTransformation Post /v1/projects/{projectOrProductUID}/global-transformation
ProjectAPI SetProjectEnvironmentVariables Put /v1/projects/{projectOrProductUID}/environment_variables
ProjectAPI UpdateFleet Put /v1/projects/{projectOrProductUID}/fleets/{fleetUID}
ProjectAPI UploadFirmware Put /v1/projects/{projectOrProductUID}/firmware/{firmwareType}/{filename}
RouteAPI CreateRoute Post /v1/projects/{projectOrProductUID}/routes
RouteAPI DeleteRoute Delete /v1/projects/{projectOrProductUID}/routes/{routeUID}
RouteAPI GetRoute Get /v1/projects/{projectOrProductUID}/routes/{routeUID}
RouteAPI GetRouteLogsByRoute Get /v1/projects/{projectOrProductUID}/routes/{routeUID}/route-logs
RouteAPI GetRoutes Get /v1/projects/{projectOrProductUID}/routes
RouteAPI UpdateRoute Put /v1/projects/{projectOrProductUID}/routes/{routeUID}
UsageAPI GetDataUsage Get /v1/projects/{projectOrProductUID}/usage/data
UsageAPI GetEventsUsage Get /v1/projects/{projectOrProductUID}/usage/events
UsageAPI GetSessionsUsage Get /v1/projects/{projectOrProductUID}/usage/sessions
WebhookAPI CreateWebhook Post /v1/projects/{projectOrProductUID}/webhooks/{webhookUID}
WebhookAPI DeleteWebhook Delete /v1/projects/{projectOrProductUID}/webhooks/{webhookUID}
WebhookAPI GetWebhook Get /v1/projects/{projectOrProductUID}/webhooks/{webhookUID}
WebhookAPI GetWebhooks Get /v1/projects/{projectOrProductUID}/webhooks
WebhookAPI UpdateWebhook Put /v1/projects/{projectOrProductUID}/webhooks/{webhookUID}

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

personalAccessToken

  • Type: HTTP Bearer token authentication

Example

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

pin

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

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

Example

auth := context.WithValue(
		context.Background(),
		notehub.ContextAPIKeys,
		map[string]notehub.APIKey{
			"pin": {Key: "API_KEY_STRING"},
		},
	)
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

engineering@blues.io

About

Go-based library for accessing the Blues Notehub API.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages