-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from databox/update-readme-and-clanup
Cleanup and refactor README.md
- Loading branch information
Showing
34 changed files
with
73 additions
and
4,939 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,135 +1,54 @@ | ||
# Go API client for databox | ||
|
||
Push API resources Open API documentation | ||
|
||
## Overview | ||
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. | ||
|
||
- API version: 0.4.4-alpha.4 | ||
- Package version: v0.3.7 | ||
- Generator version: 7.6.0 | ||
- Build package: org.openapitools.codegen.languages.GoClientCodegen | ||
# Databox | ||
This package is designed to consume the Databox Push API functionality via a Java client. | ||
|
||
## Installation | ||
|
||
Install the following dependencies: | ||
|
||
```sh | ||
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: | ||
|
||
```go | ||
import databox "github.com/databox/databox-go" | ||
``` | ||
|
||
To use a proxy, set the environment variable `HTTP_PROXY`: | ||
|
||
```go | ||
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 `databox.ContextServerIndex` of type `int`. | ||
|
||
```go | ||
ctx := context.WithValue(context.Background(), databox.ContextServerIndex, 1) | ||
``` | ||
|
||
### Templated Server URL | ||
|
||
Templated server URL is formatted using default variables from configuration or from context value `databox.ContextServerVariables` of type `map[string]string`. | ||
|
||
```go | ||
ctx := context.WithValue(context.Background(), databox.ContextServerVariables, map[string]string{ | ||
"basePath": "v2", | ||
}) | ||
``` | ||
Add the package: | ||
|
||
Note, enum values are always validated and all unused variables are silently ignored. | ||
`go get github.com/databox/databox-go` | ||
|
||
### URLs Configuration per Operation | ||
## Prerequisites | ||
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. | ||
|
||
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 `databox.ContextOperationServerIndices` and `databox.ContextOperationServerVariables` context maps. | ||
## Example | ||
|
||
```go | ||
ctx := context.WithValue(context.Background(), databox.ContextOperationServerIndices, map[string]int{ | ||
"{classname}Service.{nickname}": 2, | ||
}) | ||
ctx = context.WithValue(context.Background(), databox.ContextOperationServerVariables, map[string]map[string]string{ | ||
"{classname}Service.{nickname}": { | ||
"port": "8443", | ||
}, | ||
}) | ||
``` | ||
|
||
## Documentation for API Endpoints | ||
|
||
All URIs are relative to *https://push.databox.com* | ||
|
||
Class | Method | HTTP request | Description | ||
------------ | ------------- | ------------- | ------------- | ||
*DefaultAPI* | [**DataDelete**](docs/DefaultAPI.md#datadelete) | **Delete** /data | | ||
*DefaultAPI* | [**DataMetricKeyDelete**](docs/DefaultAPI.md#datametrickeydelete) | **Delete** /data/{metricKey} | | ||
*DefaultAPI* | [**DataPost**](docs/DefaultAPI.md#datapost) | **Post** /data | | ||
*DefaultAPI* | [**MetrickeysGet**](docs/DefaultAPI.md#metrickeysget) | **Get** /metrickeys | | ||
*DefaultAPI* | [**MetrickeysPost**](docs/DefaultAPI.md#metrickeyspost) | **Post** /metrickeys | | ||
*DefaultAPI* | [**PingGet**](docs/DefaultAPI.md#pingget) | **Get** /ping | | ||
|
||
package main | ||
|
||
## Documentation For Models | ||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
- [ApiResponse](docs/ApiResponse.md) | ||
- [PushData](docs/PushData.md) | ||
- [PushDataAttribute](docs/PushDataAttribute.md) | ||
- [State](docs/State.md) | ||
|
||
|
||
## Documentation For Authorization | ||
|
||
|
||
Authentication schemes defined for the API: | ||
### basicAuth | ||
|
||
- **Type**: HTTP basic authentication | ||
|
||
Example | ||
|
||
```go | ||
auth := context.WithValue(context.Background(), databox.ContextBasicAuth, databox.BasicAuth{ | ||
UserName: "username", | ||
Password: "password", | ||
}) | ||
r, err := client.Service.Operation(auth, args) | ||
``` | ||
databox "github.com/databox/databox-go/databox" | ||
) | ||
|
||
const t = "<token>" // Your Databox token | ||
|
||
## Documentation for Utility Methods | ||
func main() { | ||
|
||
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: | ||
// Create a context with basic auth | ||
auth := context.WithValue(context.Background(), databox.ContextBasicAuth, databox.BasicAuth{UserName: t}) | ||
|
||
* `PtrBool` | ||
* `PtrInt` | ||
* `PtrInt32` | ||
* `PtrInt64` | ||
* `PtrFloat` | ||
* `PtrFloat32` | ||
* `PtrFloat64` | ||
* `PtrString` | ||
* `PtrTime` | ||
// Create a configuration | ||
configuration := databox.NewConfiguration() | ||
configuration.DefaultHeader["Content-Type"] = "application/json" | ||
configuration.DefaultHeader["Accept"] = "application/vnd.databox.v2+json" | ||
|
||
## Author | ||
// Create an API client | ||
apiClient := databox.NewAPIClient(configuration) | ||
|
||
// Create a new PushData object | ||
data := databox.NewPushData() | ||
data.SetKey("test") | ||
data.SetValue(1.0) | ||
|
||
// Push the data | ||
r, err := apiClient.DefaultAPI.DataPost(auth).PushData([]databox.PushData{*data}).Execute() | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Error when calling `DefaultAPI.DataPost``: %v\n", err) | ||
} | ||
|
||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) | ||
} | ||
``` |
Oops, something went wrong.