Skip to content

Commit

Permalink
Merge pull request #26 from databox/update-readme-and-clanup
Browse files Browse the repository at this point in the history
Cleanup and refactor README.md
  • Loading branch information
slavkor authored Sep 13, 2024
2 parents 630ba1c + 732ef2a commit 797dc2e
Show file tree
Hide file tree
Showing 34 changed files with 73 additions and 4,939 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/generate_sdk_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ jobs:
- name: Remove old SDK
run: |
rm -rf databox/*
rm -rf docs/*
rm -f go.mod
rm -f go.sum
Expand All @@ -79,9 +78,8 @@ jobs:
- name: Generate SDK
run: |
java --version
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
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
cp ./databox/README.md ./README.md
cp -r ./databox/docs ./
cp ./databox/go.mod ./go.mod
cp ./databox/go.sum ./go.sum
rm -f ./databox/go.mod
Expand Down
153 changes: 36 additions & 117 deletions README.md
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)
}
```
Loading

0 comments on commit 797dc2e

Please sign in to comment.