|
1 |
| -# Go API client for databox |
2 |
| - |
3 |
| -Push API resources Open API documentation |
4 |
| - |
5 |
| -## Overview |
6 |
| -This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. |
7 |
| - |
8 |
| -- API version: 0.4.4-alpha.4 |
9 |
| -- Package version: v0.3.7 |
10 |
| -- Generator version: 7.6.0 |
11 |
| -- Build package: org.openapitools.codegen.languages.GoClientCodegen |
| 1 | +# Databox |
| 2 | +This package is designed to consume the Databox Push API functionality via a Java client. |
12 | 3 |
|
13 | 4 | ## Installation
|
14 | 5 |
|
15 |
| -Install the following dependencies: |
16 |
| - |
17 |
| -```sh |
18 |
| -go get github.com/stretchr/testify/assert |
19 |
| -go get golang.org/x/net/context |
20 |
| -``` |
21 |
| - |
22 |
| -Put the package under your project folder and add the following in import: |
23 |
| - |
24 |
| -```go |
25 |
| -import databox "github.com/databox/databox-go" |
26 |
| -``` |
27 |
| - |
28 |
| -To use a proxy, set the environment variable `HTTP_PROXY`: |
29 |
| - |
30 |
| -```go |
31 |
| -os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") |
32 |
| -``` |
33 |
| - |
34 |
| -## Configuration of Server URL |
35 |
| - |
36 |
| -Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification. |
37 |
| - |
38 |
| -### Select Server Configuration |
39 |
| - |
40 |
| -For using other server than the one defined on index 0 set context value `databox.ContextServerIndex` of type `int`. |
41 |
| - |
42 |
| -```go |
43 |
| -ctx := context.WithValue(context.Background(), databox.ContextServerIndex, 1) |
44 |
| -``` |
45 |
| - |
46 |
| -### Templated Server URL |
47 |
| - |
48 |
| -Templated server URL is formatted using default variables from configuration or from context value `databox.ContextServerVariables` of type `map[string]string`. |
49 |
| - |
50 |
| -```go |
51 |
| -ctx := context.WithValue(context.Background(), databox.ContextServerVariables, map[string]string{ |
52 |
| - "basePath": "v2", |
53 |
| -}) |
54 |
| -``` |
| 6 | +Add the package: |
55 | 7 |
|
56 |
| -Note, enum values are always validated and all unused variables are silently ignored. |
| 8 | +`go get github.com/databox/databox-go` |
57 | 9 |
|
58 |
| -### URLs Configuration per Operation |
| 10 | +## Prerequisites |
| 11 | +In use the Databox Push API functionality, please refer to [Databox Developers Page](https://developers.databox.com/), specifically the **Quick Guide** section, where you will learn how to create a **Databox Push API token** which is required for pushing your data. |
59 | 12 |
|
60 |
| -Each operation can use different server URL defined using `OperationServers` map in the `Configuration`. |
61 |
| -An operation is uniquely identified by `"{classname}Service.{nickname}"` string. |
62 |
| -Similar rules for overriding default operation server index and variables applies by using `databox.ContextOperationServerIndices` and `databox.ContextOperationServerVariables` context maps. |
| 13 | +## Example |
63 | 14 |
|
64 | 15 | ```go
|
65 |
| -ctx := context.WithValue(context.Background(), databox.ContextOperationServerIndices, map[string]int{ |
66 |
| - "{classname}Service.{nickname}": 2, |
67 |
| -}) |
68 |
| -ctx = context.WithValue(context.Background(), databox.ContextOperationServerVariables, map[string]map[string]string{ |
69 |
| - "{classname}Service.{nickname}": { |
70 |
| - "port": "8443", |
71 |
| - }, |
72 |
| -}) |
73 |
| -``` |
74 |
| - |
75 |
| -## Documentation for API Endpoints |
76 |
| - |
77 |
| -All URIs are relative to *https://push.databox.com* |
78 |
| - |
79 |
| -Class | Method | HTTP request | Description |
80 |
| ------------- | ------------- | ------------- | ------------- |
81 |
| -*DefaultAPI* | [**DataDelete**](docs/DefaultAPI.md#datadelete) | **Delete** /data | |
82 |
| -*DefaultAPI* | [**DataMetricKeyDelete**](docs/DefaultAPI.md#datametrickeydelete) | **Delete** /data/{metricKey} | |
83 |
| -*DefaultAPI* | [**DataPost**](docs/DefaultAPI.md#datapost) | **Post** /data | |
84 |
| -*DefaultAPI* | [**MetrickeysGet**](docs/DefaultAPI.md#metrickeysget) | **Get** /metrickeys | |
85 |
| -*DefaultAPI* | [**MetrickeysPost**](docs/DefaultAPI.md#metrickeyspost) | **Post** /metrickeys | |
86 |
| -*DefaultAPI* | [**PingGet**](docs/DefaultAPI.md#pingget) | **Get** /ping | |
87 |
| - |
| 16 | +package main |
88 | 17 |
|
89 |
| -## Documentation For Models |
| 18 | +import ( |
| 19 | + "context" |
| 20 | + "fmt" |
| 21 | + "os" |
90 | 22 |
|
91 |
| - - [ApiResponse](docs/ApiResponse.md) |
92 |
| - - [PushData](docs/PushData.md) |
93 |
| - - [PushDataAttribute](docs/PushDataAttribute.md) |
94 |
| - - [State](docs/State.md) |
95 |
| - |
96 |
| - |
97 |
| -## Documentation For Authorization |
98 |
| - |
99 |
| - |
100 |
| -Authentication schemes defined for the API: |
101 |
| -### basicAuth |
102 |
| - |
103 |
| -- **Type**: HTTP basic authentication |
104 |
| - |
105 |
| -Example |
106 |
| - |
107 |
| -```go |
108 |
| -auth := context.WithValue(context.Background(), databox.ContextBasicAuth, databox.BasicAuth{ |
109 |
| - UserName: "username", |
110 |
| - Password: "password", |
111 |
| -}) |
112 |
| -r, err := client.Service.Operation(auth, args) |
113 |
| -``` |
| 23 | + databox "github.com/databox/databox-go/databox" |
| 24 | +) |
114 | 25 |
|
| 26 | +const t = "<token>" // Your Databox token |
115 | 27 |
|
116 |
| -## Documentation for Utility Methods |
| 28 | +func main() { |
117 | 29 |
|
118 |
| -Due to the fact that model structure members are all pointers, this package contains |
119 |
| -a number of utility functions to easily obtain pointers to values of basic types. |
120 |
| -Each of these functions takes a value of the given basic type and returns a pointer to it: |
| 30 | + // Create a context with basic auth |
| 31 | + auth := context.WithValue(context.Background(), databox.ContextBasicAuth, databox.BasicAuth{UserName: t}) |
121 | 32 |
|
122 |
| -* `PtrBool` |
123 |
| -* `PtrInt` |
124 |
| -* `PtrInt32` |
125 |
| -* `PtrInt64` |
126 |
| -* `PtrFloat` |
127 |
| -* `PtrFloat32` |
128 |
| -* `PtrFloat64` |
129 |
| -* `PtrString` |
130 |
| -* `PtrTime` |
| 33 | + // Create a configuration |
| 34 | + configuration := databox.NewConfiguration() |
| 35 | + configuration.DefaultHeader["Content-Type"] = "application/json" |
| 36 | + configuration.DefaultHeader["Accept"] = "application/vnd.databox.v2+json" |
131 | 37 |
|
132 |
| -## Author |
| 38 | + // Create an API client |
| 39 | + apiClient := databox.NewAPIClient(configuration) |
133 | 40 |
|
| 41 | + // Create a new PushData object |
| 42 | + data := databox.NewPushData() |
| 43 | + data.SetKey("test") |
| 44 | + data.SetValue(1.0) |
134 | 45 |
|
| 46 | + // Push the data |
| 47 | + r, err := apiClient.DefaultAPI.DataPost(auth).PushData([]databox.PushData{*data}).Execute() |
| 48 | + if err != nil { |
| 49 | + fmt.Fprintf(os.Stderr, "Error when calling `DefaultAPI.DataPost``: %v\n", err) |
| 50 | + } |
135 | 51 |
|
| 52 | + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) |
| 53 | +} |
| 54 | +``` |
0 commit comments