Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: synced with the latest swagger #241

Merged
merged 2 commits into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.3.0 [in progress]
### Features
[#241](https://github.com/influxdata/influxdb-client-go/pull/241) Synced with InfluxDB 2.0.5 swagger:
- Setup (onboarding) now sends correctly retentionDuration if specified
- `RetentionRule` used in `Bucket` now contains `ShardGroupDurationSeconds` to specify the shard group duration.

## 2.2.3 [2021-04-01]
### Bug fixes
1. [#236](https://github.com/influxdata/influxdb-client-go/pull/236) Setting MaxRetries to zero value disables retry strategy.
Expand Down
16 changes: 10 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"errors"
"strings"
"sync"
"time"

"github.com/influxdata/influxdb-client-go/v2/api"
"github.com/influxdata/influxdb-client-go/v2/api/http"
Expand Down Expand Up @@ -146,17 +147,20 @@ func (c *clientImpl) Ready(ctx context.Context) (bool, error) {

func (c *clientImpl) Setup(ctx context.Context, username, password, org, bucket string, retentionPeriodHours int) (*domain.OnboardingResponse, error) {
if username == "" || password == "" {
return nil, errors.New("a username and password is required for a setup")
return nil, errors.New("a username and a password is required for a setup")
}
c.lock.Lock()
defer c.lock.Unlock()
params := &domain.PostSetupParams{}
retentionPeriodSeconds := retentionPeriodHours * 3600
retentionPeriodHrs := int(time.Duration(retentionPeriodSeconds) * time.Second)
body := &domain.PostSetupJSONRequestBody{
Bucket: bucket,
Org: org,
Password: &password,
RetentionPeriodHrs: &retentionPeriodHours,
Username: username,
Bucket: bucket,
Org: org,
Password: &password,
RetentionPeriodSeconds: &retentionPeriodSeconds,
RetentionPeriodHrs: &retentionPeriodHrs,
Username: username,
}
response, err := c.apiClient.PostSetupWithResponse(ctx, params, *body)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion client_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ func init() {

func TestSetup(t *testing.T) {
client := influxdb2.NewClientWithOptions(onboardingURL, "", influxdb2.DefaultOptions().SetLogLevel(2))
response, err := client.Setup(context.Background(), "my-user", "my-password", "my-org", "my-bucket", 0)
response, err := client.Setup(context.Background(), "my-user", "my-password", "my-org", "my-bucket", 24)
if err != nil {
t.Error(err)
}
require.NotNil(t, response)
require.NotNil(t, response.Auth)
require.NotNil(t, response.Auth.Token)
require.NotNil(t, response.Bucket)
require.NotNil(t, response.Bucket.RetentionRules)
require.Len(t, response.Bucket.RetentionRules, 1)
assert.Equal(t, 24*3600, response.Bucket.RetentionRules[0].EverySeconds)

_, err = client.Setup(context.Background(), "my-user", "my-password", "my-org", "my-bucket", 0)
require.NotNil(t, err)
Expand Down