Skip to content

Commit 797dc2e

Browse files
authored
Merge pull request #26 from databox/update-readme-and-clanup
Cleanup and refactor README.md
2 parents 630ba1c + 732ef2a commit 797dc2e

34 files changed

+73
-4939
lines changed

.github/workflows/generate_sdk_code.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ jobs:
6262
- name: Remove old SDK
6363
run: |
6464
rm -rf databox/*
65-
rm -rf docs/*
6665
rm -f go.mod
6766
rm -f go.sum
6867
@@ -79,9 +78,8 @@ jobs:
7978
- name: Generate SDK
8079
run: |
8180
java --version
82-
java -jar ${{ runner.temp }}/openapi-generator-cli.jar generate -i ${{ runner.temp }}/openapispec/openapi.yml -g go -o ./databox -c ${{ runner.temp }}/${{ env.CONFIG_FILE }} --skip-validate-spec -t ./codegen-template
81+
java -jar ${{ runner.temp }}/openapi-generator-cli.jar generate -i ${{ runner.temp }}/openapispec/openapi.yml -g go -o ./databox -c ${{ runner.temp }}/${{ env.CONFIG_FILE }} --skip-validate-spec
8382
cp ./databox/README.md ./README.md
84-
cp -r ./databox/docs ./
8583
cp ./databox/go.mod ./go.mod
8684
cp ./databox/go.sum ./go.sum
8785
rm -f ./databox/go.mod

README.md

Lines changed: 36 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,54 @@
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.
123

134
## Installation
145

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:
557

56-
Note, enum values are always validated and all unused variables are silently ignored.
8+
`go get github.com/databox/databox-go`
579

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.
5912

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
6314

6415
```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
8817

89-
## Documentation For Models
18+
import (
19+
"context"
20+
"fmt"
21+
"os"
9022

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+
)
11425

26+
const t = "<token>" // Your Databox token
11527

116-
## Documentation for Utility Methods
28+
func main() {
11729

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})
12132

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"
13137

132-
## Author
38+
// Create an API client
39+
apiClient := databox.NewAPIClient(configuration)
13340

41+
// Create a new PushData object
42+
data := databox.NewPushData()
43+
data.SetKey("test")
44+
data.SetValue(1.0)
13445

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+
}
13551

52+
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
53+
}
54+
```

0 commit comments

Comments
 (0)