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

feat: added SetupWithToken() method, allowing users to specify Admin token … #328

Merged
merged 1 commit into from
May 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ type Client interface {
// and returns details about newly created entities along with the authorization object.
// Retention period of zero will result to infinite retention.
Setup(ctx context.Context, username, password, org, bucket string, retentionPeriodHours int) (*domain.OnboardingResponse, error)
// SetupWithToken sends request to initialise new InfluxDB server with user, org and bucket, data retention period and token
// and returns details about newly created entities along with the authorization object.
// Retention period of zero will result to infinite retention.
SetupWithToken(ctx context.Context, username, password, org, bucket string, retentionPeriodHours int, token string) (*domain.OnboardingResponse, error)
// Ready returns InfluxDB uptime info of server. It doesn't validate authentication params.
Ready(ctx context.Context) (*domain.Ready, error)
// Health returns an InfluxDB server health check result. Read the HealthCheck.Status field to get server status.
Expand Down Expand Up @@ -161,6 +165,10 @@ func (c *clientImpl) Ready(ctx context.Context) (*domain.Ready, error) {
}

func (c *clientImpl) Setup(ctx context.Context, username, password, org, bucket string, retentionPeriodHours int) (*domain.OnboardingResponse, error) {
return c.SetupWithToken(ctx, username, password, org, bucket, retentionPeriodHours, "")
}

func (c *clientImpl) SetupWithToken(ctx context.Context, username, password, org, bucket string, retentionPeriodHours int, token string) (*domain.OnboardingResponse, error) {
if username == "" || password == "" {
return nil, errors.New("a username and a password is required for a setup")
}
Expand All @@ -176,6 +184,7 @@ func (c *clientImpl) Setup(ctx context.Context, username, password, org, bucket
RetentionPeriodSeconds: &retentionPeriodSeconds,
RetentionPeriodHrs: &retentionPeriodHrs,
Username: username,
Token: &token,
}
response, err := c.apiClient.PostSetupWithResponse(ctx, params, *body)
if err != nil {
Expand Down