Ver Fonte

addvendor

lijian há 2 anos atrás
pai
commit
45ab1a9396

+ 21 - 0
vendor/github.com/influxdata/influxdb-client-go/LICENSE

@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020-2021 Influxdata, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 127 - 0
vendor/github.com/influxdata/influxdb-client-go/api/authorizations.go

@@ -0,0 +1,127 @@
+// Copyright 2020-2021 InfluxData, Inc. All rights reserved.
+// Use of this source code is governed by MIT
+// license that can be found in the LICENSE file.
+
+package api
+
+import (
+	"context"
+
+	"github.com/influxdata/influxdb-client-go/v2/domain"
+)
+
+// AuthorizationsAPI provides methods for organizing Authorization in a InfluxDB server
+type AuthorizationsAPI interface {
+	// GetAuthorizations returns all authorizations
+	GetAuthorizations(ctx context.Context) (*[]domain.Authorization, error)
+	// FindAuthorizationsByUserName returns all authorizations for given userName
+	FindAuthorizationsByUserName(ctx context.Context, userName string) (*[]domain.Authorization, error)
+	// FindAuthorizationsByUserID returns all authorizations for given userID
+	FindAuthorizationsByUserID(ctx context.Context, userID string) (*[]domain.Authorization, error)
+	// FindAuthorizationsByOrgName returns all authorizations for given organization name
+	FindAuthorizationsByOrgName(ctx context.Context, orgName string) (*[]domain.Authorization, error)
+	// FindAuthorizationsByOrgID returns all authorizations for given organization id
+	FindAuthorizationsByOrgID(ctx context.Context, orgID string) (*[]domain.Authorization, error)
+	// CreateAuthorization creates new authorization
+	CreateAuthorization(ctx context.Context, authorization *domain.Authorization) (*domain.Authorization, error)
+	// CreateAuthorizationWithOrgID creates new authorization with given permissions scoped to given orgID
+	CreateAuthorizationWithOrgID(ctx context.Context, orgID string, permissions []domain.Permission) (*domain.Authorization, error)
+	// UpdateAuthorizationStatus updates status of authorization
+	UpdateAuthorizationStatus(ctx context.Context, authorization *domain.Authorization, status domain.AuthorizationUpdateRequestStatus) (*domain.Authorization, error)
+	// UpdateAuthorizationStatusWithID updates status of authorization with authID
+	UpdateAuthorizationStatusWithID(ctx context.Context, authID string, status domain.AuthorizationUpdateRequestStatus) (*domain.Authorization, error)
+	// DeleteAuthorization deletes authorization
+	DeleteAuthorization(ctx context.Context, authorization *domain.Authorization) error
+	// DeleteAuthorization deletes authorization with authID
+	DeleteAuthorizationWithID(ctx context.Context, authID string) error
+}
+
+// authorizationsAPI implements AuthorizationsAPI
+type authorizationsAPI struct {
+	apiClient *domain.Client
+}
+
+// NewAuthorizationsAPI creates new instance of AuthorizationsAPI
+func NewAuthorizationsAPI(apiClient *domain.Client) AuthorizationsAPI {
+	return &authorizationsAPI{
+		apiClient: apiClient,
+	}
+}
+
+func (a *authorizationsAPI) GetAuthorizations(ctx context.Context) (*[]domain.Authorization, error) {
+	authQuery := &domain.GetAuthorizationsParams{}
+	return a.listAuthorizations(ctx, authQuery)
+}
+
+func (a *authorizationsAPI) FindAuthorizationsByUserName(ctx context.Context, userName string) (*[]domain.Authorization, error) {
+	authQuery := &domain.GetAuthorizationsParams{User: &userName}
+	return a.listAuthorizations(ctx, authQuery)
+}
+
+func (a *authorizationsAPI) FindAuthorizationsByUserID(ctx context.Context, userID string) (*[]domain.Authorization, error) {
+	authQuery := &domain.GetAuthorizationsParams{UserID: &userID}
+	return a.listAuthorizations(ctx, authQuery)
+}
+
+func (a *authorizationsAPI) FindAuthorizationsByOrgName(ctx context.Context, orgName string) (*[]domain.Authorization, error) {
+	authQuery := &domain.GetAuthorizationsParams{Org: &orgName}
+	return a.listAuthorizations(ctx, authQuery)
+}
+
+func (a *authorizationsAPI) FindAuthorizationsByOrgID(ctx context.Context, orgID string) (*[]domain.Authorization, error) {
+	authQuery := &domain.GetAuthorizationsParams{OrgID: &orgID}
+	return a.listAuthorizations(ctx, authQuery)
+}
+
+func (a *authorizationsAPI) listAuthorizations(ctx context.Context, query *domain.GetAuthorizationsParams) (*[]domain.Authorization, error) {
+	response, err := a.apiClient.GetAuthorizations(ctx, query)
+	if err != nil {
+		return nil, err
+	}
+	return response.Authorizations, nil
+}
+
+func (a *authorizationsAPI) CreateAuthorization(ctx context.Context, authorization *domain.Authorization) (*domain.Authorization, error) {
+	params := &domain.PostAuthorizationsAllParams{
+		Body: domain.PostAuthorizationsJSONRequestBody{
+			AuthorizationUpdateRequest: authorization.AuthorizationUpdateRequest,
+			OrgID:                      authorization.OrgID,
+			Permissions:                authorization.Permissions,
+			UserID:                     authorization.UserID,
+		},
+	}
+	return a.apiClient.PostAuthorizations(ctx, params)
+}
+
+func (a *authorizationsAPI) CreateAuthorizationWithOrgID(ctx context.Context, orgID string, permissions []domain.Permission) (*domain.Authorization, error) {
+	status := domain.AuthorizationUpdateRequestStatusActive
+	auth := &domain.Authorization{
+		AuthorizationUpdateRequest: domain.AuthorizationUpdateRequest{Status: &status},
+		OrgID:                      &orgID,
+		Permissions:                &permissions,
+	}
+	return a.CreateAuthorization(ctx, auth)
+}
+
+func (a *authorizationsAPI) UpdateAuthorizationStatusWithID(ctx context.Context, authID string, status domain.AuthorizationUpdateRequestStatus) (*domain.Authorization, error) {
+	params := &domain.PatchAuthorizationsIDAllParams{
+		Body:   domain.PatchAuthorizationsIDJSONRequestBody{Status: &status},
+		AuthID: authID,
+	}
+	return a.apiClient.PatchAuthorizationsID(ctx, params)
+}
+
+func (a *authorizationsAPI) UpdateAuthorizationStatus(ctx context.Context, authorization *domain.Authorization, status domain.AuthorizationUpdateRequestStatus) (*domain.Authorization, error) {
+	return a.UpdateAuthorizationStatusWithID(ctx, *authorization.Id, status)
+}
+
+func (a *authorizationsAPI) DeleteAuthorization(ctx context.Context, authorization *domain.Authorization) error {
+	return a.DeleteAuthorizationWithID(ctx, *authorization.Id)
+}
+
+func (a *authorizationsAPI) DeleteAuthorizationWithID(ctx context.Context, authID string) error {
+	params := &domain.DeleteAuthorizationsIDAllParams{
+		AuthID: authID,
+	}
+	return a.apiClient.DeleteAuthorizationsID(ctx, params)
+}

+ 275 - 0
vendor/github.com/influxdata/influxdb-client-go/api/buckets.go

@@ -0,0 +1,275 @@
+// Copyright 2020-2021 InfluxData, Inc. All rights reserved.
+// Use of this source code is governed by MIT
+// license that can be found in the LICENSE file.
+
+package api
+
+import (
+	"context"
+	"fmt"
+	"github.com/influxdata/influxdb-client-go/v2/domain"
+)
+
+// BucketsAPI provides methods for managing Buckets in a InfluxDB server.
+type BucketsAPI interface {
+	// GetBuckets returns all buckets.
+	// GetBuckets supports PagingOptions: Offset, Limit, After. Empty pagingOptions means the default paging (first 20 results).
+	GetBuckets(ctx context.Context, pagingOptions ...PagingOption) (*[]domain.Bucket, error)
+	// FindBucketByName returns a bucket found using bucketName.
+	FindBucketByName(ctx context.Context, bucketName string) (*domain.Bucket, error)
+	// FindBucketByID returns a bucket found using bucketID.
+	FindBucketByID(ctx context.Context, bucketID string) (*domain.Bucket, error)
+	// FindBucketsByOrgID returns buckets belonging to the organization with ID orgID.
+	// FindBucketsByOrgID supports PagingOptions: Offset, Limit, After. Empty pagingOptions means the default paging (first 20 results).
+	FindBucketsByOrgID(ctx context.Context, orgID string, pagingOptions ...PagingOption) (*[]domain.Bucket, error)
+	// FindBucketsByOrgName returns buckets belonging to the organization with name orgName, with the specified paging. Empty pagingOptions means the default paging (first 20 results).
+	FindBucketsByOrgName(ctx context.Context, orgName string, pagingOptions ...PagingOption) (*[]domain.Bucket, error)
+	// CreateBucket creates a new bucket.
+	CreateBucket(ctx context.Context, bucket *domain.Bucket) (*domain.Bucket, error)
+	// CreateBucketWithName creates a new bucket with bucketName in organization org, with retention specified in rules. Empty rules means infinite retention.
+	CreateBucketWithName(ctx context.Context, org *domain.Organization, bucketName string, rules ...domain.RetentionRule) (*domain.Bucket, error)
+	// CreateBucketWithNameWithID creates a new bucket with bucketName in organization with orgID, with retention specified in rules. Empty rules means infinite retention.
+	CreateBucketWithNameWithID(ctx context.Context, orgID, bucketName string, rules ...domain.RetentionRule) (*domain.Bucket, error)
+	// UpdateBucket updates a bucket.
+	UpdateBucket(ctx context.Context, bucket *domain.Bucket) (*domain.Bucket, error)
+	// DeleteBucket deletes a bucket.
+	DeleteBucket(ctx context.Context, bucket *domain.Bucket) error
+	// DeleteBucketWithID deletes a bucket with bucketID.
+	DeleteBucketWithID(ctx context.Context, bucketID string) error
+	// GetMembers returns members of a bucket.
+	GetMembers(ctx context.Context, bucket *domain.Bucket) (*[]domain.ResourceMember, error)
+	// GetMembersWithID returns members of a bucket with bucketID.
+	GetMembersWithID(ctx context.Context, bucketID string) (*[]domain.ResourceMember, error)
+	// AddMember adds a member to a bucket.
+	AddMember(ctx context.Context, bucket *domain.Bucket, user *domain.User) (*domain.ResourceMember, error)
+	// AddMemberWithID adds a member with id memberID to a bucket with bucketID.
+	AddMemberWithID(ctx context.Context, bucketID, memberID string) (*domain.ResourceMember, error)
+	// RemoveMember removes a member from a bucket.
+	RemoveMember(ctx context.Context, bucket *domain.Bucket, user *domain.User) error
+	// RemoveMemberWithID removes a member with id memberID from a bucket with bucketID.
+	RemoveMemberWithID(ctx context.Context, bucketID, memberID string) error
+	// GetOwners returns owners of a bucket.
+	GetOwners(ctx context.Context, bucket *domain.Bucket) (*[]domain.ResourceOwner, error)
+	// GetOwnersWithID returns owners of a bucket with bucketID.
+	GetOwnersWithID(ctx context.Context, bucketID string) (*[]domain.ResourceOwner, error)
+	// AddOwner adds an owner to a bucket.
+	AddOwner(ctx context.Context, bucket *domain.Bucket, user *domain.User) (*domain.ResourceOwner, error)
+	// AddOwnerWithID adds an owner with id memberID to a bucket with bucketID.
+	AddOwnerWithID(ctx context.Context, bucketID, memberID string) (*domain.ResourceOwner, error)
+	// RemoveOwner removes an owner from a bucket.
+	RemoveOwner(ctx context.Context, bucket *domain.Bucket, user *domain.User) error
+	// RemoveOwnerWithID removes a member with id memberID from a bucket with bucketID.
+	RemoveOwnerWithID(ctx context.Context, bucketID, memberID string) error
+}
+
+// bucketsAPI implements BucketsAPI
+type bucketsAPI struct {
+	apiClient *domain.Client
+}
+
+// NewBucketsAPI creates new instance of BucketsAPI
+func NewBucketsAPI(apiClient *domain.Client) BucketsAPI {
+	return &bucketsAPI{
+		apiClient: apiClient,
+	}
+}
+
+func (b *bucketsAPI) GetBuckets(ctx context.Context, pagingOptions ...PagingOption) (*[]domain.Bucket, error) {
+	return b.getBuckets(ctx, nil, pagingOptions...)
+}
+
+func (b *bucketsAPI) getBuckets(ctx context.Context, params *domain.GetBucketsParams, pagingOptions ...PagingOption) (*[]domain.Bucket, error) {
+	if params == nil {
+		params = &domain.GetBucketsParams{}
+	}
+	options := defaultPaging()
+	for _, opt := range pagingOptions {
+		opt(options)
+	}
+	if options.limit > 0 {
+		params.Limit = &options.limit
+	}
+	params.Offset = &options.offset
+
+	response, err := b.apiClient.GetBuckets(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return response.Buckets, nil
+}
+
+func (b *bucketsAPI) FindBucketByName(ctx context.Context, bucketName string) (*domain.Bucket, error) {
+	params := &domain.GetBucketsParams{Name: &bucketName}
+	response, err := b.apiClient.GetBuckets(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	if response.Buckets != nil && len(*response.Buckets) > 0 {
+		return &(*response.Buckets)[0], nil
+	}
+	return nil, fmt.Errorf("bucket '%s' not found", bucketName)
+}
+
+func (b *bucketsAPI) FindBucketByID(ctx context.Context, bucketID string) (*domain.Bucket, error) {
+	params := &domain.GetBucketsIDAllParams{
+		BucketID: bucketID,
+	}
+	return b.apiClient.GetBucketsID(ctx, params)
+}
+
+func (b *bucketsAPI) FindBucketsByOrgID(ctx context.Context, orgID string, pagingOptions ...PagingOption) (*[]domain.Bucket, error) {
+	params := &domain.GetBucketsParams{OrgID: &orgID}
+	return b.getBuckets(ctx, params, pagingOptions...)
+}
+
+func (b *bucketsAPI) FindBucketsByOrgName(ctx context.Context, orgName string, pagingOptions ...PagingOption) (*[]domain.Bucket, error) {
+	params := &domain.GetBucketsParams{Org: &orgName}
+	return b.getBuckets(ctx, params, pagingOptions...)
+}
+
+func (b *bucketsAPI) createBucket(ctx context.Context, bucketReq *domain.PostBucketRequest) (*domain.Bucket, error) {
+	params := &domain.PostBucketsAllParams{
+		Body: domain.PostBucketsJSONRequestBody(*bucketReq),
+	}
+	return b.apiClient.PostBuckets(ctx, params)
+}
+
+func (b *bucketsAPI) CreateBucket(ctx context.Context, bucket *domain.Bucket) (*domain.Bucket, error) {
+	bucketReq := &domain.PostBucketRequest{
+		Description:    bucket.Description,
+		Name:           bucket.Name,
+		OrgID:          *bucket.OrgID,
+		RetentionRules: &bucket.RetentionRules,
+		Rp:             bucket.Rp,
+	}
+	return b.createBucket(ctx, bucketReq)
+}
+
+func (b *bucketsAPI) CreateBucketWithNameWithID(ctx context.Context, orgID, bucketName string, rules ...domain.RetentionRule) (*domain.Bucket, error) {
+	rs := domain.RetentionRules(rules)
+	bucket := &domain.PostBucketRequest{Name: bucketName, OrgID: orgID, RetentionRules: &rs}
+	return b.createBucket(ctx, bucket)
+}
+func (b *bucketsAPI) CreateBucketWithName(ctx context.Context, org *domain.Organization, bucketName string, rules ...domain.RetentionRule) (*domain.Bucket, error) {
+	return b.CreateBucketWithNameWithID(ctx, *org.Id, bucketName, rules...)
+}
+
+func (b *bucketsAPI) DeleteBucket(ctx context.Context, bucket *domain.Bucket) error {
+	return b.DeleteBucketWithID(ctx, *bucket.Id)
+}
+
+func (b *bucketsAPI) DeleteBucketWithID(ctx context.Context, bucketID string) error {
+	params := &domain.DeleteBucketsIDAllParams{
+		BucketID: bucketID,
+	}
+	return b.apiClient.DeleteBucketsID(ctx, params)
+}
+
+func (b *bucketsAPI) UpdateBucket(ctx context.Context, bucket *domain.Bucket) (*domain.Bucket, error) {
+	params := &domain.PatchBucketsIDAllParams{
+		Body: domain.PatchBucketsIDJSONRequestBody{
+			Description:    bucket.Description,
+			Name:           &bucket.Name,
+			RetentionRules: retentionRulesToPatchRetentionRules(&bucket.RetentionRules),
+		},
+		BucketID: *bucket.Id,
+	}
+	return b.apiClient.PatchBucketsID(ctx, params)
+}
+
+func (b *bucketsAPI) GetMembers(ctx context.Context, bucket *domain.Bucket) (*[]domain.ResourceMember, error) {
+	return b.GetMembersWithID(ctx, *bucket.Id)
+}
+
+func (b *bucketsAPI) GetMembersWithID(ctx context.Context, bucketID string) (*[]domain.ResourceMember, error) {
+	params := &domain.GetBucketsIDMembersAllParams{
+		BucketID: bucketID,
+	}
+	response, err := b.apiClient.GetBucketsIDMembers(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return response.Users, nil
+}
+
+func (b *bucketsAPI) AddMember(ctx context.Context, bucket *domain.Bucket, user *domain.User) (*domain.ResourceMember, error) {
+	return b.AddMemberWithID(ctx, *bucket.Id, *user.Id)
+}
+
+func (b *bucketsAPI) AddMemberWithID(ctx context.Context, bucketID, memberID string) (*domain.ResourceMember, error) {
+	params := &domain.PostBucketsIDMembersAllParams{
+		BucketID: bucketID,
+		Body:     domain.PostBucketsIDMembersJSONRequestBody{Id: memberID},
+	}
+	return b.apiClient.PostBucketsIDMembers(ctx, params)
+}
+
+func (b *bucketsAPI) RemoveMember(ctx context.Context, bucket *domain.Bucket, user *domain.User) error {
+	return b.RemoveMemberWithID(ctx, *bucket.Id, *user.Id)
+}
+
+func (b *bucketsAPI) RemoveMemberWithID(ctx context.Context, bucketID, memberID string) error {
+	params := &domain.DeleteBucketsIDMembersIDAllParams{
+		BucketID: bucketID,
+		UserID:   memberID,
+	}
+	return b.apiClient.DeleteBucketsIDMembersID(ctx, params)
+}
+
+func (b *bucketsAPI) GetOwners(ctx context.Context, bucket *domain.Bucket) (*[]domain.ResourceOwner, error) {
+	return b.GetOwnersWithID(ctx, *bucket.Id)
+}
+
+func (b *bucketsAPI) GetOwnersWithID(ctx context.Context, bucketID string) (*[]domain.ResourceOwner, error) {
+	params := &domain.GetBucketsIDOwnersAllParams{
+		BucketID: bucketID,
+	}
+	response, err := b.apiClient.GetBucketsIDOwners(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return response.Users, nil
+}
+
+func (b *bucketsAPI) AddOwner(ctx context.Context, bucket *domain.Bucket, user *domain.User) (*domain.ResourceOwner, error) {
+	return b.AddOwnerWithID(ctx, *bucket.Id, *user.Id)
+}
+
+func (b *bucketsAPI) AddOwnerWithID(ctx context.Context, bucketID, memberID string) (*domain.ResourceOwner, error) {
+	params := &domain.PostBucketsIDOwnersAllParams{
+		BucketID: bucketID,
+		Body:     domain.PostBucketsIDOwnersJSONRequestBody{Id: memberID},
+	}
+	return b.apiClient.PostBucketsIDOwners(ctx, params)
+}
+
+func (b *bucketsAPI) RemoveOwner(ctx context.Context, bucket *domain.Bucket, user *domain.User) error {
+	return b.RemoveOwnerWithID(ctx, *bucket.Id, *user.Id)
+}
+
+func (b *bucketsAPI) RemoveOwnerWithID(ctx context.Context, bucketID, memberID string) error {
+	params := &domain.DeleteBucketsIDOwnersIDAllParams{
+		BucketID: bucketID,
+		UserID:   memberID,
+	}
+	return b.apiClient.DeleteBucketsIDOwnersID(ctx, params)
+}
+
+func retentionRulesToPatchRetentionRules(rrs *domain.RetentionRules) *domain.PatchRetentionRules {
+	if rrs == nil {
+		return nil
+	}
+	prrs := make([]domain.PatchRetentionRule, len(*rrs))
+	for i, rr := range *rrs {
+		prrs[i] = domain.PatchRetentionRule{
+			EverySeconds:              rr.EverySeconds,
+			ShardGroupDurationSeconds: rr.ShardGroupDurationSeconds,
+		}
+		if rr.Type != nil {
+			rrt := domain.PatchRetentionRuleType(*rr.Type)
+			prrs[i].Type = &rrt
+		}
+	}
+	dprrs := domain.PatchRetentionRules(prrs)
+	return &dprrs
+}

+ 84 - 0
vendor/github.com/influxdata/influxdb-client-go/api/delete.go

@@ -0,0 +1,84 @@
+// Copyright 2020-2021 InfluxData, Inc. All rights reserved.
+// Use of this source code is governed by MIT
+// license that can be found in the LICENSE file.
+
+package api
+
+import (
+	"context"
+	"github.com/influxdata/influxdb-client-go/v2/domain"
+	"time"
+)
+
+// DeleteAPI provides methods for deleting time series data from buckets.
+// Deleted series are selected by the time range specified by start and stop arguments and optional predicate string which contains condition for selecting data for deletion, such as:
+// 		tag1="value1" and (tag2="value2" and tag3!="value3")
+// Empty predicate string means all data from the given time range will be deleted. See https://v2.docs.influxdata.com/v2.0/reference/syntax/delete-predicate/
+// for more info about predicate syntax.
+type DeleteAPI interface {
+	// Delete deletes series selected by the time range specified by start and stop arguments and optional predicate string from the bucket bucket belonging to the organization org.
+	Delete(ctx context.Context, org *domain.Organization, bucket *domain.Bucket, start, stop time.Time, predicate string) error
+	// DeleteWithID deletes series selected by the time range specified by start and stop arguments and optional predicate string from the bucket with ID bucketID belonging to the organization with ID orgID.
+	DeleteWithID(ctx context.Context, orgID, bucketID string, start, stop time.Time, predicate string) error
+	// DeleteWithName deletes series selected by the time range specified by start and stop arguments and optional predicate string from the bucket with name bucketName belonging to the organization with name orgName.
+	DeleteWithName(ctx context.Context, orgName, bucketName string, start, stop time.Time, predicate string) error
+}
+
+// deleteAPI implements DeleteAPI
+type deleteAPI struct {
+	apiClient *domain.Client
+}
+
+// NewDeleteAPI creates new instance of DeleteAPI
+func NewDeleteAPI(apiClient *domain.Client) DeleteAPI {
+	return &deleteAPI{
+		apiClient: apiClient,
+	}
+}
+
+func (d *deleteAPI) delete(ctx context.Context, params *domain.PostDeleteParams, conditions *domain.DeletePredicateRequest) error {
+	allParams := &domain.PostDeleteAllParams{
+		PostDeleteParams: *params,
+		Body:             domain.PostDeleteJSONRequestBody(*conditions),
+	}
+	return d.apiClient.PostDelete(ctx, allParams)
+}
+
+func (d *deleteAPI) Delete(ctx context.Context, org *domain.Organization, bucket *domain.Bucket, start, stop time.Time, predicate string) error {
+	params := &domain.PostDeleteParams{
+		OrgID:    org.Id,
+		BucketID: bucket.Id,
+	}
+	conditions := &domain.DeletePredicateRequest{
+		Predicate: &predicate,
+		Start:     start,
+		Stop:      stop,
+	}
+	return d.delete(ctx, params, conditions)
+}
+
+func (d *deleteAPI) DeleteWithID(ctx context.Context, orgID, bucketID string, start, stop time.Time, predicate string) error {
+	params := &domain.PostDeleteParams{
+		OrgID:    &orgID,
+		BucketID: &bucketID,
+	}
+	conditions := &domain.DeletePredicateRequest{
+		Predicate: &predicate,
+		Start:     start,
+		Stop:      stop,
+	}
+	return d.delete(ctx, params, conditions)
+}
+
+func (d *deleteAPI) DeleteWithName(ctx context.Context, orgName, bucketName string, start, stop time.Time, predicate string) error {
+	params := &domain.PostDeleteParams{
+		Org:    &orgName,
+		Bucket: &bucketName,
+	}
+	conditions := &domain.DeletePredicateRequest{
+		Predicate: &predicate,
+		Start:     start,
+		Stop:      stop,
+	}
+	return d.delete(ctx, params, conditions)
+}

+ 6 - 0
vendor/github.com/influxdata/influxdb-client-go/api/doc.go

@@ -0,0 +1,6 @@
+// Copyright 2020-2021 InfluxData, Inc. All rights reserved.
+// Use of this source code is governed by MIT
+// license that can be found in the LICENSE file.
+
+// Package api provides clients for InfluxDB server APIs.
+package api

+ 155 - 0
vendor/github.com/influxdata/influxdb-client-go/api/labels.go

@@ -0,0 +1,155 @@
+// Copyright 2020-2021 InfluxData, Inc. All rights reserved.
+// Use of this source code is governed by MIT
+// license that can be found in the LICENSE file.
+
+package api
+
+import (
+	"context"
+	"fmt"
+
+	"github.com/influxdata/influxdb-client-go/v2/domain"
+)
+
+// LabelsAPI provides methods for managing labels in a InfluxDB server.
+type LabelsAPI interface {
+	// GetLabels returns all labels.
+	GetLabels(ctx context.Context) (*[]domain.Label, error)
+	// FindLabelsByOrg returns labels belonging to organization org.
+	FindLabelsByOrg(ctx context.Context, org *domain.Organization) (*[]domain.Label, error)
+	// FindLabelsByOrgID returns labels belonging to organization with id orgID.
+	FindLabelsByOrgID(ctx context.Context, orgID string) (*[]domain.Label, error)
+	// FindLabelByID returns a label with labelID.
+	FindLabelByID(ctx context.Context, labelID string) (*domain.Label, error)
+	// FindLabelByName returns a label with name labelName under an organization orgID.
+	FindLabelByName(ctx context.Context, orgID, labelName string) (*domain.Label, error)
+	// CreateLabel creates a new label.
+	CreateLabel(ctx context.Context, label *domain.LabelCreateRequest) (*domain.Label, error)
+	// CreateLabelWithName creates a new label with label labelName and properties, under the organization org.
+	// Properties example: {"color": "ffb3b3", "description": "this is a description"}.
+	CreateLabelWithName(ctx context.Context, org *domain.Organization, labelName string, properties map[string]string) (*domain.Label, error)
+	// CreateLabelWithNameWithID creates a new label with label labelName and properties, under the organization with id orgID.
+	// Properties example: {"color": "ffb3b3", "description": "this is a description"}.
+	CreateLabelWithNameWithID(ctx context.Context, orgID, labelName string, properties map[string]string) (*domain.Label, error)
+	// UpdateLabel updates the label.
+	// Properties can be removed by sending an update with an empty value.
+	UpdateLabel(ctx context.Context, label *domain.Label) (*domain.Label, error)
+	// DeleteLabelWithID deletes a label with labelID.
+	DeleteLabelWithID(ctx context.Context, labelID string) error
+	// DeleteLabel deletes a label.
+	DeleteLabel(ctx context.Context, label *domain.Label) error
+}
+
+// labelsAPI implements LabelsAPI
+type labelsAPI struct {
+	apiClient *domain.Client
+}
+
+// NewLabelsAPI creates new instance of LabelsAPI
+func NewLabelsAPI(apiClient *domain.Client) LabelsAPI {
+	return &labelsAPI{
+		apiClient: apiClient,
+	}
+}
+
+func (u *labelsAPI) GetLabels(ctx context.Context) (*[]domain.Label, error) {
+	params := &domain.GetLabelsParams{}
+	return u.getLabels(ctx, params)
+}
+
+func (u *labelsAPI) getLabels(ctx context.Context, params *domain.GetLabelsParams) (*[]domain.Label, error) {
+	response, err := u.apiClient.GetLabels(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return (*[]domain.Label)(response.Labels), nil
+}
+
+func (u *labelsAPI) FindLabelsByOrg(ctx context.Context, org *domain.Organization) (*[]domain.Label, error) {
+	return u.FindLabelsByOrgID(ctx, *org.Id)
+}
+
+func (u *labelsAPI) FindLabelsByOrgID(ctx context.Context, orgID string) (*[]domain.Label, error) {
+	params := &domain.GetLabelsParams{OrgID: &orgID}
+	return u.getLabels(ctx, params)
+}
+
+func (u *labelsAPI) FindLabelByID(ctx context.Context, labelID string) (*domain.Label, error) {
+	params := &domain.GetLabelsIDAllParams{
+		LabelID: labelID,
+	}
+	response, err := u.apiClient.GetLabelsID(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return response.Label, nil
+}
+
+func (u *labelsAPI) FindLabelByName(ctx context.Context, orgID, labelName string) (*domain.Label, error) {
+	labels, err := u.FindLabelsByOrgID(ctx, orgID)
+	if err != nil {
+		return nil, err
+	}
+	var label *domain.Label
+	for _, u := range *labels {
+		if *u.Name == labelName {
+			label = &u
+			break
+		}
+	}
+	if label == nil {
+		return nil, fmt.Errorf("label '%s' not found", labelName)
+	}
+	return label, nil
+}
+
+func (u *labelsAPI) CreateLabelWithName(ctx context.Context, org *domain.Organization, labelName string, properties map[string]string) (*domain.Label, error) {
+	return u.CreateLabelWithNameWithID(ctx, *org.Id, labelName, properties)
+}
+
+func (u *labelsAPI) CreateLabelWithNameWithID(ctx context.Context, orgID, labelName string, properties map[string]string) (*domain.Label, error) {
+	props := &domain.LabelCreateRequest_Properties{AdditionalProperties: properties}
+	label := &domain.LabelCreateRequest{Name: labelName, OrgID: orgID, Properties: props}
+	return u.CreateLabel(ctx, label)
+}
+
+func (u *labelsAPI) CreateLabel(ctx context.Context, label *domain.LabelCreateRequest) (*domain.Label, error) {
+	params := &domain.PostLabelsAllParams{
+		Body: domain.PostLabelsJSONRequestBody(*label),
+	}
+	response, err := u.apiClient.PostLabels(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return response.Label, nil
+}
+
+func (u *labelsAPI) UpdateLabel(ctx context.Context, label *domain.Label) (*domain.Label, error) {
+	var props *domain.LabelUpdate_Properties
+	if label.Properties != nil {
+		props = &domain.LabelUpdate_Properties{AdditionalProperties: label.Properties.AdditionalProperties}
+	}
+	params := &domain.PatchLabelsIDAllParams{
+		Body: domain.PatchLabelsIDJSONRequestBody(domain.LabelUpdate{
+			Name:       label.Name,
+			Properties: props,
+		}),
+		LabelID: *label.Id,
+	}
+	response, err := u.apiClient.PatchLabelsID(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return response.Label, nil
+}
+
+func (u *labelsAPI) DeleteLabel(ctx context.Context, label *domain.Label) error {
+	return u.DeleteLabelWithID(ctx, *label.Id)
+}
+
+func (u *labelsAPI) DeleteLabelWithID(ctx context.Context, labelID string) error {
+	params := &domain.DeleteLabelsIDAllParams{
+		LabelID: labelID,
+	}
+	return u.apiClient.DeleteLabelsID(ctx, params)
+}

+ 233 - 0
vendor/github.com/influxdata/influxdb-client-go/api/organizations.go

@@ -0,0 +1,233 @@
+// Copyright 2020-2021 InfluxData, Inc. All rights reserved.
+// Use of this source code is governed by MIT
+// license that can be found in the LICENSE file.
+
+package api
+
+import (
+	"context"
+	"fmt"
+
+	"github.com/influxdata/influxdb-client-go/v2/domain"
+)
+
+// OrganizationsAPI provides methods for managing Organizations in a InfluxDB server.
+type OrganizationsAPI interface {
+	// GetOrganizations returns all organizations.
+	// GetOrganizations supports PagingOptions: Offset, Limit, Descending
+	GetOrganizations(ctx context.Context, pagingOptions ...PagingOption) (*[]domain.Organization, error)
+	// FindOrganizationByName returns an organization found using orgName.
+	FindOrganizationByName(ctx context.Context, orgName string) (*domain.Organization, error)
+	// FindOrganizationByID returns an organization found using orgID.
+	FindOrganizationByID(ctx context.Context, orgID string) (*domain.Organization, error)
+	// FindOrganizationsByUserID returns organizations an user with userID belongs to.
+	// FindOrganizationsByUserID supports PagingOptions: Offset, Limit, Descending
+	FindOrganizationsByUserID(ctx context.Context, userID string, pagingOptions ...PagingOption) (*[]domain.Organization, error)
+	// CreateOrganization creates new organization.
+	CreateOrganization(ctx context.Context, org *domain.Organization) (*domain.Organization, error)
+	// CreateOrganizationWithName creates new organization with orgName and with status active.
+	CreateOrganizationWithName(ctx context.Context, orgName string) (*domain.Organization, error)
+	// UpdateOrganization updates organization.
+	UpdateOrganization(ctx context.Context, org *domain.Organization) (*domain.Organization, error)
+	// DeleteOrganization deletes an organization.
+	DeleteOrganization(ctx context.Context, org *domain.Organization) error
+	// DeleteOrganizationWithID deletes an organization with orgID.
+	DeleteOrganizationWithID(ctx context.Context, orgID string) error
+	// GetMembers returns members of an organization.
+	GetMembers(ctx context.Context, org *domain.Organization) (*[]domain.ResourceMember, error)
+	// GetMembersWithID returns members of an organization with orgID.
+	GetMembersWithID(ctx context.Context, orgID string) (*[]domain.ResourceMember, error)
+	// AddMember adds a member to an organization.
+	AddMember(ctx context.Context, org *domain.Organization, user *domain.User) (*domain.ResourceMember, error)
+	// AddMemberWithID adds a member with id memberID to an organization with orgID.
+	AddMemberWithID(ctx context.Context, orgID, memberID string) (*domain.ResourceMember, error)
+	// RemoveMember removes a member from an organization.
+	RemoveMember(ctx context.Context, org *domain.Organization, user *domain.User) error
+	// RemoveMemberWithID removes a member with id memberID from an organization with orgID.
+	RemoveMemberWithID(ctx context.Context, orgID, memberID string) error
+	// GetOwners returns owners of an organization.
+	GetOwners(ctx context.Context, org *domain.Organization) (*[]domain.ResourceOwner, error)
+	// GetOwnersWithID returns owners of an organization with orgID.
+	GetOwnersWithID(ctx context.Context, orgID string) (*[]domain.ResourceOwner, error)
+	// AddOwner adds an owner to an organization.
+	AddOwner(ctx context.Context, org *domain.Organization, user *domain.User) (*domain.ResourceOwner, error)
+	// AddOwnerWithID adds an owner with id memberID to an organization with orgID.
+	AddOwnerWithID(ctx context.Context, orgID, memberID string) (*domain.ResourceOwner, error)
+	// RemoveOwner removes an owner from an organization.
+	RemoveOwner(ctx context.Context, org *domain.Organization, user *domain.User) error
+	// RemoveOwnerWithID removes an owner with id memberID from an organization with orgID.
+	RemoveOwnerWithID(ctx context.Context, orgID, memberID string) error
+}
+
+// organizationsAPI implements OrganizationsAPI
+type organizationsAPI struct {
+	apiClient *domain.Client
+}
+
+// NewOrganizationsAPI creates new instance of OrganizationsAPI
+func NewOrganizationsAPI(apiClient *domain.Client) OrganizationsAPI {
+	return &organizationsAPI{
+		apiClient: apiClient,
+	}
+}
+
+func (o *organizationsAPI) getOrganizations(ctx context.Context, params *domain.GetOrgsParams, pagingOptions ...PagingOption) (*[]domain.Organization, error) {
+	options := defaultPaging()
+	for _, opt := range pagingOptions {
+		opt(options)
+	}
+	if options.limit > 0 {
+		params.Limit = &options.limit
+	}
+	params.Offset = &options.offset
+	params.Descending = &options.descending
+	response, err := o.apiClient.GetOrgs(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return response.Orgs, nil
+}
+func (o *organizationsAPI) GetOrganizations(ctx context.Context, pagingOptions ...PagingOption) (*[]domain.Organization, error) {
+	params := &domain.GetOrgsParams{}
+	return o.getOrganizations(ctx, params, pagingOptions...)
+}
+
+func (o *organizationsAPI) FindOrganizationByName(ctx context.Context, orgName string) (*domain.Organization, error) {
+	params := &domain.GetOrgsParams{Org: &orgName}
+	organizations, err := o.getOrganizations(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	if organizations != nil && len(*organizations) > 0 {
+		return &(*organizations)[0], nil
+	}
+	return nil, fmt.Errorf("organization '%s' not found", orgName)
+}
+
+func (o *organizationsAPI) FindOrganizationByID(ctx context.Context, orgID string) (*domain.Organization, error) {
+	params := &domain.GetOrgsIDAllParams{
+		OrgID: orgID,
+	}
+	return o.apiClient.GetOrgsID(ctx, params)
+}
+
+func (o *organizationsAPI) FindOrganizationsByUserID(ctx context.Context, userID string, pagingOptions ...PagingOption) (*[]domain.Organization, error) {
+	params := &domain.GetOrgsParams{UserID: &userID}
+	return o.getOrganizations(ctx, params, pagingOptions...)
+}
+
+func (o *organizationsAPI) CreateOrganization(ctx context.Context, org *domain.Organization) (*domain.Organization, error) {
+	params := &domain.PostOrgsAllParams{
+		Body: domain.PostOrgsJSONRequestBody{
+			Name:        org.Name,
+			Description: org.Description,
+		},
+	}
+	return o.apiClient.PostOrgs(ctx, params)
+}
+
+func (o *organizationsAPI) CreateOrganizationWithName(ctx context.Context, orgName string) (*domain.Organization, error) {
+	status := domain.OrganizationStatusActive
+	org := &domain.Organization{Name: orgName, Status: &status}
+	return o.CreateOrganization(ctx, org)
+}
+
+func (o *organizationsAPI) DeleteOrganization(ctx context.Context, org *domain.Organization) error {
+	return o.DeleteOrganizationWithID(ctx, *org.Id)
+}
+
+func (o *organizationsAPI) DeleteOrganizationWithID(ctx context.Context, orgID string) error {
+	params := &domain.DeleteOrgsIDAllParams{
+		OrgID: orgID,
+	}
+	return o.apiClient.DeleteOrgsID(ctx, params)
+}
+
+func (o *organizationsAPI) UpdateOrganization(ctx context.Context, org *domain.Organization) (*domain.Organization, error) {
+	params := &domain.PatchOrgsIDAllParams{
+		Body: domain.PatchOrgsIDJSONRequestBody{
+			Name:        &org.Name,
+			Description: org.Description,
+		},
+		OrgID: *org.Id,
+	}
+	return o.apiClient.PatchOrgsID(ctx, params)
+}
+
+func (o *organizationsAPI) GetMembers(ctx context.Context, org *domain.Organization) (*[]domain.ResourceMember, error) {
+	return o.GetMembersWithID(ctx, *org.Id)
+}
+
+func (o *organizationsAPI) GetMembersWithID(ctx context.Context, orgID string) (*[]domain.ResourceMember, error) {
+	params := &domain.GetOrgsIDMembersAllParams{
+		OrgID: orgID,
+	}
+	response, err := o.apiClient.GetOrgsIDMembers(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return response.Users, nil
+}
+
+func (o *organizationsAPI) AddMember(ctx context.Context, org *domain.Organization, user *domain.User) (*domain.ResourceMember, error) {
+	return o.AddMemberWithID(ctx, *org.Id, *user.Id)
+}
+
+func (o *organizationsAPI) AddMemberWithID(ctx context.Context, orgID, memberID string) (*domain.ResourceMember, error) {
+	params := &domain.PostOrgsIDMembersAllParams{
+		Body:  domain.PostOrgsIDMembersJSONRequestBody{Id: memberID},
+		OrgID: orgID,
+	}
+	return o.apiClient.PostOrgsIDMembers(ctx, params)
+}
+
+func (o *organizationsAPI) RemoveMember(ctx context.Context, org *domain.Organization, user *domain.User) error {
+	return o.RemoveMemberWithID(ctx, *org.Id, *user.Id)
+}
+
+func (o *organizationsAPI) RemoveMemberWithID(ctx context.Context, orgID, memberID string) error {
+	params := &domain.DeleteOrgsIDMembersIDAllParams{
+		OrgID:  orgID,
+		UserID: memberID,
+	}
+	return o.apiClient.DeleteOrgsIDMembersID(ctx, params)
+}
+
+func (o *organizationsAPI) GetOwners(ctx context.Context, org *domain.Organization) (*[]domain.ResourceOwner, error) {
+	return o.GetOwnersWithID(ctx, *org.Id)
+}
+
+func (o *organizationsAPI) GetOwnersWithID(ctx context.Context, orgID string) (*[]domain.ResourceOwner, error) {
+	params := &domain.GetOrgsIDOwnersAllParams{
+		OrgID: orgID,
+	}
+	response, err := o.apiClient.GetOrgsIDOwners(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return response.Users, nil
+}
+
+func (o *organizationsAPI) AddOwner(ctx context.Context, org *domain.Organization, user *domain.User) (*domain.ResourceOwner, error) {
+	return o.AddOwnerWithID(ctx, *org.Id, *user.Id)
+}
+
+func (o *organizationsAPI) AddOwnerWithID(ctx context.Context, orgID, memberID string) (*domain.ResourceOwner, error) {
+	params := &domain.PostOrgsIDOwnersAllParams{
+		Body:  domain.PostOrgsIDOwnersJSONRequestBody{Id: memberID},
+		OrgID: orgID,
+	}
+	return o.apiClient.PostOrgsIDOwners(ctx, params)
+}
+
+func (o *organizationsAPI) RemoveOwner(ctx context.Context, org *domain.Organization, user *domain.User) error {
+	return o.RemoveOwnerWithID(ctx, *org.Id, *user.Id)
+}
+
+func (o *organizationsAPI) RemoveOwnerWithID(ctx context.Context, orgID, memberID string) error {
+	params := &domain.DeleteOrgsIDOwnersIDAllParams{
+		OrgID:  orgID,
+		UserID: memberID,
+	}
+	return o.apiClient.DeleteOrgsIDOwnersID(ctx, params)
+}

+ 69 - 0
vendor/github.com/influxdata/influxdb-client-go/api/paging.go

@@ -0,0 +1,69 @@
+// Copyright 2020-2021 InfluxData, Inc. All rights reserved.
+// Use of this source code is governed by MIT
+// license that can be found in the LICENSE file.
+
+package api
+
+import "github.com/influxdata/influxdb-client-go/v2/domain"
+
+// PagingOption is the function type for applying paging option
+type PagingOption func(p *Paging)
+
+// Paging holds pagination parameters for various Get* functions of InfluxDB 2 API
+// Not the all options are usable for some Get* functions
+type Paging struct {
+	// Starting offset for returning items
+	// Default 0.
+	offset domain.Offset
+	// Maximum number of items returned.
+	// Default 0 - not applied
+	limit domain.Limit
+	// What field should be used for sorting
+	sortBy string
+	// Changes sorting direction
+	descending domain.Descending
+	// The last resource ID from which to seek from (but not including).
+	// This is to be used instead of `offset`.
+	after domain.After
+}
+
+// defaultPagingOptions returns default paging options: offset 0, limit 0 (not applied), default sorting, ascending
+func defaultPaging() *Paging {
+	return &Paging{limit: 0, offset: 0, sortBy: "", descending: false, after: ""}
+}
+
+// PagingWithLimit sets limit option - maximum number of items returned.
+func PagingWithLimit(limit int) PagingOption {
+	return func(p *Paging) {
+		p.limit = domain.Limit(limit)
+	}
+}
+
+// PagingWithOffset set starting offset for returning items. Default 0.
+func PagingWithOffset(offset int) PagingOption {
+	return func(p *Paging) {
+		p.offset = domain.Offset(offset)
+	}
+}
+
+// PagingWithSortBy sets field name which should be used for sorting
+func PagingWithSortBy(sortBy string) PagingOption {
+	return func(p *Paging) {
+		p.sortBy = sortBy
+	}
+}
+
+// PagingWithDescending changes sorting direction
+func PagingWithDescending(descending bool) PagingOption {
+	return func(p *Paging) {
+		p.descending = domain.Descending(descending)
+	}
+}
+
+// PagingWithAfter set after option - the last resource ID from which to seek from (but not including).
+// This is to be used instead of `offset`.
+func PagingWithAfter(after string) PagingOption {
+	return func(p *Paging) {
+		p.after = domain.After(after)
+	}
+}

+ 532 - 0
vendor/github.com/influxdata/influxdb-client-go/api/query.go

@@ -0,0 +1,532 @@
+// Copyright 2020-2021 InfluxData, Inc. All rights reserved.
+// Use of this source code is governed by MIT
+// license that can be found in the LICENSE file.
+
+package api
+
+import (
+	"bytes"
+	"compress/gzip"
+	"context"
+	"encoding/base64"
+	"encoding/csv"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"io"
+	"io/ioutil"
+	"net/http"
+	"net/url"
+	"path"
+	"reflect"
+	"strconv"
+	"strings"
+	"sync"
+	"time"
+
+	http2 "github.com/influxdata/influxdb-client-go/v2/api/http"
+	"github.com/influxdata/influxdb-client-go/v2/api/query"
+	"github.com/influxdata/influxdb-client-go/v2/domain"
+	"github.com/influxdata/influxdb-client-go/v2/internal/log"
+	ilog "github.com/influxdata/influxdb-client-go/v2/log"
+)
+
+const (
+	stringDatatype       = "string"
+	doubleDatatype       = "double"
+	boolDatatype         = "boolean"
+	longDatatype         = "long"
+	uLongDatatype        = "unsignedLong"
+	durationDatatype     = "duration"
+	base64BinaryDataType = "base64Binary"
+	timeDatatypeRFC      = "dateTime:RFC3339"
+	timeDatatypeRFCNano  = "dateTime:RFC3339Nano"
+)
+
+// QueryAPI provides methods for performing synchronously flux query against InfluxDB server.
+//
+// Flux query can contain reference to parameters, which must be passed via queryParams.
+// it can be a struct or map. Param values can be only simple types or time.Time.
+// The name of a struct field or a map key (must be a string) will be a param name.
+// The name of the parameter represented by a struct field can be specified by JSON annotation:
+//
+// type Condition struct {
+//     Start  time.Time  `json:"start"`
+//     Field  string     `json:"field"`
+//     Value  float64    `json:"value"`
+//	}
+//
+//  Parameters are then accessed via the Flux params object:
+//
+//  query:= `from(bucket: "environment")
+// 		|> range(start: time(v: params.start))
+//		|> filter(fn: (r) => r._measurement == "air")
+//		|> filter(fn: (r) => r._field == params.field)
+//		|> filter(fn: (r) => r._value > params.value)`
+//
+type QueryAPI interface {
+	// QueryRaw executes flux query on the InfluxDB server and returns complete query result as a string with table annotations according to dialect
+	QueryRaw(ctx context.Context, query string, dialect *domain.Dialect) (string, error)
+	// QueryRawWithParams executes flux parametrized query on the InfluxDB server and returns complete query result as a string with table annotations according to dialect
+	QueryRawWithParams(ctx context.Context, query string, dialect *domain.Dialect, params interface{}) (string, error)
+	// Query executes flux query on the InfluxDB server and returns QueryTableResult which parses streamed response into structures representing flux table parts
+	Query(ctx context.Context, query string) (*QueryTableResult, error)
+	// QueryWithParams executes flux parametrized query  on the InfluxDB server and returns QueryTableResult which parses streamed response into structures representing flux table parts
+	QueryWithParams(ctx context.Context, query string, params interface{}) (*QueryTableResult, error)
+}
+
+// NewQueryAPI returns new query client for querying buckets belonging to org
+func NewQueryAPI(org string, service http2.Service) QueryAPI {
+	return &queryAPI{
+		org:         org,
+		httpService: service,
+	}
+}
+
+// QueryTableResult parses streamed flux query response into structures representing flux table parts
+// Walking though the result is done by repeatedly calling Next() until returns false.
+// Actual flux table info (columns with names, data types, etc) is returned by TableMetadata() method.
+// Data are acquired by Record() method.
+// Preliminary end can be caused by an error, so when Next() return false, check Err() for an error
+type QueryTableResult struct {
+	io.Closer
+	csvReader     *csv.Reader
+	tablePosition int
+	tableChanged  bool
+	table         *query.FluxTableMetadata
+	record        *query.FluxRecord
+	err           error
+}
+
+// NewQueryTableResult returns new QueryTableResult
+func NewQueryTableResult(rawResponse io.ReadCloser) *QueryTableResult {
+	csvReader := csv.NewReader(rawResponse)
+	csvReader.FieldsPerRecord = -1
+	return &QueryTableResult{Closer: rawResponse, csvReader: csvReader}
+}
+
+// queryAPI implements QueryAPI interface
+type queryAPI struct {
+	org         string
+	httpService http2.Service
+	url         string
+	lock        sync.Mutex
+}
+
+//  queryBody holds the body for an HTTP query request.
+type queryBody struct {
+	Dialect *domain.Dialect  `json:"dialect,omitempty"`
+	Query   string           `json:"query"`
+	Type    domain.QueryType `json:"type"`
+	Params  interface{}      `json:"params,omitempty"`
+}
+
+func (q *queryAPI) QueryRaw(ctx context.Context, query string, dialect *domain.Dialect) (string, error) {
+	return q.QueryRawWithParams(ctx, query, dialect, nil)
+}
+
+func (q *queryAPI) QueryRawWithParams(ctx context.Context, query string, dialect *domain.Dialect, params interface{}) (string, error) {
+	if err := checkParamsType(params); err != nil {
+		return "", err
+	}
+	queryURL, err := q.queryURL()
+	if err != nil {
+		return "", err
+	}
+	qr := queryBody{
+		Query:   query,
+		Type:    domain.QueryTypeFlux,
+		Dialect: dialect,
+		Params:  params,
+	}
+	qrJSON, err := json.Marshal(qr)
+	if err != nil {
+		return "", err
+	}
+	if log.Level() >= ilog.DebugLevel {
+		log.Debugf("Query: %s", qrJSON)
+	}
+	var body string
+	perror := q.httpService.DoPostRequest(ctx, queryURL, bytes.NewReader(qrJSON), func(req *http.Request) {
+		req.Header.Set("Content-Type", "application/json")
+		req.Header.Set("Accept-Encoding", "gzip")
+	},
+		func(resp *http.Response) error {
+			if resp.Header.Get("Content-Encoding") == "gzip" {
+				resp.Body, err = gzip.NewReader(resp.Body)
+				if err != nil {
+					return err
+				}
+			}
+			respBody, err := ioutil.ReadAll(resp.Body)
+			if err != nil {
+				return err
+			}
+			body = string(respBody)
+			return nil
+		})
+	if perror != nil {
+		return "", perror
+	}
+	return body, nil
+}
+
+// DefaultDialect return flux query Dialect with full annotations (datatype, group, default), header and comma char as a delimiter
+func DefaultDialect() *domain.Dialect {
+	annotations := []domain.DialectAnnotations{domain.DialectAnnotationsDatatype, domain.DialectAnnotationsGroup, domain.DialectAnnotationsDefault}
+	delimiter := ","
+	header := true
+	return &domain.Dialect{
+		Annotations: &annotations,
+		Delimiter:   &delimiter,
+		Header:      &header,
+	}
+}
+
+func (q *queryAPI) Query(ctx context.Context, query string) (*QueryTableResult, error) {
+	return q.QueryWithParams(ctx, query, nil)
+}
+
+func (q *queryAPI) QueryWithParams(ctx context.Context, query string, params interface{}) (*QueryTableResult, error) {
+	var queryResult *QueryTableResult
+	if err := checkParamsType(params); err != nil {
+		return nil, err
+	}
+	queryURL, err := q.queryURL()
+	if err != nil {
+		return nil, err
+	}
+	qr := queryBody{
+		Query:   query,
+		Type:    domain.QueryTypeFlux,
+		Dialect: DefaultDialect(),
+		Params:  params,
+	}
+	qrJSON, err := json.Marshal(qr)
+	if err != nil {
+		return nil, err
+	}
+	if log.Level() >= ilog.DebugLevel {
+		log.Debugf("Query: %s", qrJSON)
+	}
+	perror := q.httpService.DoPostRequest(ctx, queryURL, bytes.NewReader(qrJSON), func(req *http.Request) {
+		req.Header.Set("Content-Type", "application/json")
+		req.Header.Set("Accept-Encoding", "gzip")
+	},
+		func(resp *http.Response) error {
+			if resp.Header.Get("Content-Encoding") == "gzip" {
+				resp.Body, err = gzip.NewReader(resp.Body)
+				if err != nil {
+					return err
+				}
+			}
+			csvReader := csv.NewReader(resp.Body)
+			csvReader.FieldsPerRecord = -1
+			queryResult = &QueryTableResult{Closer: resp.Body, csvReader: csvReader}
+			return nil
+		})
+	if perror != nil {
+		return queryResult, perror
+	}
+	return queryResult, nil
+}
+
+func (q *queryAPI) queryURL() (string, error) {
+	if q.url == "" {
+		u, err := url.Parse(q.httpService.ServerAPIURL())
+		if err != nil {
+			return "", err
+		}
+		u.Path = path.Join(u.Path, "query")
+
+		params := u.Query()
+		params.Set("org", q.org)
+		u.RawQuery = params.Encode()
+		q.lock.Lock()
+		q.url = u.String()
+		q.lock.Unlock()
+	}
+	return q.url, nil
+}
+
+// checkParamsType validates the value is struct with simple type fields
+// or a map with key as string and value as a simple type
+func checkParamsType(p interface{}) error {
+	if p == nil {
+		return nil
+	}
+	t := reflect.TypeOf(p)
+	v := reflect.ValueOf(p)
+	if t.Kind() == reflect.Ptr {
+		t = t.Elem()
+		v = v.Elem()
+	}
+	if t.Kind() != reflect.Struct && t.Kind() != reflect.Map {
+		return fmt.Errorf("cannot use %v as query params", t)
+	}
+	switch t.Kind() {
+	case reflect.Struct:
+		fields := reflect.VisibleFields(t)
+		for _, f := range fields {
+			fv := v.FieldByIndex(f.Index)
+			t := getFieldType(fv)
+			if !validParamType(t) {
+				return fmt.Errorf("cannot use field '%s' of type '%v' as a query param", f.Name, t)
+			}
+
+		}
+	case reflect.Map:
+		key := t.Key()
+		if key.Kind() != reflect.String {
+			return fmt.Errorf("cannot use map key of type '%v' for query param name", key)
+		}
+		for _, k := range v.MapKeys() {
+			f := v.MapIndex(k)
+			t := getFieldType(f)
+			if !validParamType(t) {
+				return fmt.Errorf("cannot use map value type '%v' as a query param", t)
+			}
+		}
+	}
+	return nil
+}
+
+// getFieldType extracts type of value
+func getFieldType(v reflect.Value) reflect.Type {
+	t := v.Type()
+	if t.Kind() == reflect.Ptr {
+		t = t.Elem()
+		v = v.Elem()
+	}
+	if t.Kind() == reflect.Interface && !v.IsNil() {
+		t = reflect.ValueOf(v.Interface()).Type()
+	}
+	return t
+}
+
+// timeType is the exact type for the Time
+var timeType = reflect.TypeOf(time.Time{})
+
+// validParamType validates that t is primitive type or string or interface
+func validParamType(t reflect.Type) bool {
+	return (t.Kind() > reflect.Invalid && t.Kind() < reflect.Complex64) ||
+		t.Kind() == reflect.String ||
+		t == timeType
+}
+
+// TablePosition returns actual flux table position in the result, or -1 if no table was found yet
+// Each new table is introduced by an annotation in csv
+func (q *QueryTableResult) TablePosition() int {
+	if q.table != nil {
+		return q.table.Position()
+	}
+	return -1
+}
+
+// TableMetadata returns actual flux table metadata
+func (q *QueryTableResult) TableMetadata() *query.FluxTableMetadata {
+	return q.table
+}
+
+// TableChanged returns true if last call of Next() found also new result table
+// Table information is available via TableMetadata method
+func (q *QueryTableResult) TableChanged() bool {
+	return q.tableChanged
+}
+
+// Record returns last parsed flux table data row
+// Use Record methods to access value and row properties
+func (q *QueryTableResult) Record() *query.FluxRecord {
+	return q.record
+}
+
+type parsingState int
+
+const (
+	parsingStateNormal parsingState = iota
+	parsingStateAnnotation
+	parsingStateNameRow
+	parsingStateError
+)
+
+// Next advances to next row in query result.
+// During the first time it is called, Next creates also table metadata
+// Actual parsed row is available through Record() function
+// Returns false in case of end or an error, otherwise true
+func (q *QueryTableResult) Next() bool {
+	var row []string
+	// set closing query in case of preliminary return
+	closer := func() {
+		if err := q.Close(); err != nil {
+			message := err.Error()
+			if q.err != nil {
+				message = fmt.Sprintf("%s,%s", message, q.err.Error())
+			}
+			q.err = errors.New(message)
+		}
+	}
+	defer func() {
+		closer()
+	}()
+	parsingState := parsingStateNormal
+	q.tableChanged = false
+	dataTypeAnnotationFound := false
+readRow:
+	row, q.err = q.csvReader.Read()
+	if q.err == io.EOF {
+		q.err = nil
+		return false
+	}
+	if q.err != nil {
+		return false
+	}
+
+	if len(row) <= 1 {
+		goto readRow
+	}
+	if len(row[0]) > 0 && row[0][0] == '#' {
+		if parsingState == parsingStateNormal {
+			q.table = query.NewFluxTableMetadata(q.tablePosition)
+			q.tablePosition++
+			q.tableChanged = true
+			for i := range row[1:] {
+				q.table.AddColumn(query.NewFluxColumn(i))
+			}
+			parsingState = parsingStateAnnotation
+		}
+	}
+	if q.table == nil {
+		q.err = errors.New("parsing error, annotations not found")
+		return false
+	}
+	if len(row)-1 != len(q.table.Columns()) {
+		q.err = fmt.Errorf("parsing error, row has different number of columns than the table: %d vs %d", len(row)-1, len(q.table.Columns()))
+		return false
+	}
+	switch row[0] {
+	case "":
+		switch parsingState {
+		case parsingStateAnnotation:
+			if !dataTypeAnnotationFound {
+				q.err = errors.New("parsing error, datatype annotation not found")
+				return false
+			}
+			parsingState = parsingStateNameRow
+			fallthrough
+		case parsingStateNameRow:
+			if row[1] == "error" {
+				parsingState = parsingStateError
+			} else {
+				for i, n := range row[1:] {
+					if q.table.Column(i) != nil {
+						q.table.Column(i).SetName(n)
+					}
+				}
+				parsingState = parsingStateNormal
+			}
+			goto readRow
+		case parsingStateError:
+			var message string
+			if len(row) > 1 && len(row[1]) > 0 {
+				message = row[1]
+			} else {
+				message = "unknown query error"
+			}
+			reference := ""
+			if len(row) > 2 && len(row[2]) > 0 {
+				reference = fmt.Sprintf(",%s", row[2])
+			}
+			q.err = fmt.Errorf("%s%s", message, reference)
+			return false
+		}
+		values := make(map[string]interface{})
+		for i, v := range row[1:] {
+			if q.table.Column(i) != nil {
+				values[q.table.Column(i).Name()], q.err = toValue(stringTernary(v, q.table.Column(i).DefaultValue()), q.table.Column(i).DataType(), q.table.Column(i).Name())
+				if q.err != nil {
+					return false
+				}
+			}
+		}
+		q.record = query.NewFluxRecord(q.table.Position(), values)
+	case "#datatype":
+		dataTypeAnnotationFound = true
+		for i, d := range row[1:] {
+			if q.table.Column(i) != nil {
+				q.table.Column(i).SetDataType(d)
+			}
+		}
+		goto readRow
+	case "#group":
+		for i, g := range row[1:] {
+			if q.table.Column(i) != nil {
+				q.table.Column(i).SetGroup(g == "true")
+			}
+		}
+		goto readRow
+	case "#default":
+		for i, c := range row[1:] {
+			if q.table.Column(i) != nil {
+				q.table.Column(i).SetDefaultValue(c)
+			}
+		}
+		goto readRow
+	}
+	// don't close query
+	closer = func() {}
+	return true
+}
+
+// Err returns an error raised during flux query response parsing
+func (q *QueryTableResult) Err() error {
+	return q.err
+}
+
+// Close reads remaining data and closes underlying Closer
+func (q *QueryTableResult) Close() error {
+	var err error
+	for err == nil {
+		_, err = q.csvReader.Read()
+	}
+	return q.Closer.Close()
+}
+
+// stringTernary returns a if not empty, otherwise b
+func stringTernary(a, b string) string {
+	if a == "" {
+		return b
+	}
+	return a
+}
+
+// toValues converts s into type by t
+func toValue(s, t, name string) (interface{}, error) {
+	if s == "" {
+		return nil, nil
+	}
+	switch t {
+	case stringDatatype:
+		return s, nil
+	case timeDatatypeRFC:
+		return time.Parse(time.RFC3339, s)
+	case timeDatatypeRFCNano:
+		return time.Parse(time.RFC3339Nano, s)
+	case durationDatatype:
+		return time.ParseDuration(s)
+	case doubleDatatype:
+		return strconv.ParseFloat(s, 64)
+	case boolDatatype:
+		if strings.ToLower(s) == "false" {
+			return false, nil
+		}
+		return true, nil
+	case longDatatype:
+		return strconv.ParseInt(s, 10, 64)
+	case uLongDatatype:
+		return strconv.ParseUint(s, 10, 64)
+	case base64BinaryDataType:
+		return base64.StdEncoding.DecodeString(s)
+	default:
+		return nil, fmt.Errorf("%s has unknown data type %s", name, t)
+	}
+}

+ 511 - 0
vendor/github.com/influxdata/influxdb-client-go/api/tasks.go

@@ -0,0 +1,511 @@
+// Copyright 2020-2021 InfluxData, Inc. All rights reserved.
+// Use of this source code is governed by MIT
+// license that can be found in the LICENSE file.
+
+package api
+
+import (
+	"context"
+	"fmt"
+	"time"
+
+	"github.com/influxdata/influxdb-client-go/v2/domain"
+)
+
+// TaskFilter defines filtering options for FindTasks functions.
+type TaskFilter struct {
+	// Returns task with a specific name
+	Name string
+	// Filter tasks to a specific organization name.
+	OrgName string
+	// Filter tasks to a specific organization ID.
+	OrgID string
+	// Filter tasks to a specific user ID.
+	User string
+	// Filter tasks by a status--"inactive" or "active".
+	Status domain.TaskStatusType
+	// Return tasks after a specified ID.
+	After string
+	// The number of tasks to return.
+	// Default 100, minimum: 1, maximum 500
+	Limit int
+}
+
+// RunFilter defines filtering options for FindRun* functions.
+type RunFilter struct {
+	// Return runs after a specified ID.
+	After string
+	// The number of runs to return.
+	// Default 100, minimum 1, maximum 500.
+	Limit int
+	// Filter runs to those scheduled before this time.
+	BeforeTime time.Time
+	// Filter runs to those scheduled after this time.
+	AfterTime time.Time
+}
+
+// TasksAPI provides methods for managing tasks and task runs in an InfluxDB server.
+type TasksAPI interface {
+	// FindTasks retrieves tasks according to the filter. More fields can be applied. Filter can be nil.
+	FindTasks(ctx context.Context, filter *TaskFilter) ([]domain.Task, error)
+	// GetTask retrieves a refreshed instance of task.
+	GetTask(ctx context.Context, task *domain.Task) (*domain.Task, error)
+	// GetTaskByID retrieves a task found using taskID.
+	GetTaskByID(ctx context.Context, taskID string) (*domain.Task, error)
+	// CreateTask creates a new task according the task object.
+	// It copies OrgId, Name, Description, Flux, Status and Every or Cron properties. Every and Cron are mutually exclusive.
+	// Every has higher priority.
+	CreateTask(ctx context.Context, task *domain.Task) (*domain.Task, error)
+	// CreateTaskWithEvery creates a new task with the name, flux script and every repetition setting, in the org orgID.
+	// Every means duration values.
+	CreateTaskWithEvery(ctx context.Context, name, flux, every, orgID string) (*domain.Task, error)
+	// CreateTaskWithCron creates a new task with the name, flux script and cron repetition setting, in the org orgID
+	// Cron holds cron-like setting, e.g. once an hour at beginning of the hour "0 * * * *".
+	CreateTaskWithCron(ctx context.Context, name, flux, cron, orgID string) (*domain.Task, error)
+	// CreateTaskByFlux creates a new task with complete definition in flux script, in the org orgID
+	CreateTaskByFlux(ctx context.Context, flux, orgID string) (*domain.Task, error)
+	// UpdateTask updates a task.
+	// It copies Description, Flux, Status, Offset and Every or Cron properties. Every and Cron are mutually exclusive.
+	// Every has higher priority.
+	UpdateTask(ctx context.Context, task *domain.Task) (*domain.Task, error)
+	// DeleteTask deletes a task.
+	DeleteTask(ctx context.Context, task *domain.Task) error
+	// DeleteTaskWithID deletes a task with taskID.
+	DeleteTaskWithID(ctx context.Context, taskID string) error
+	// FindMembers retrieves members of a task.
+	FindMembers(ctx context.Context, task *domain.Task) ([]domain.ResourceMember, error)
+	// FindMembersWithID retrieves members of a task with taskID.
+	FindMembersWithID(ctx context.Context, taskID string) ([]domain.ResourceMember, error)
+	// AddMember adds a member to a task.
+	AddMember(ctx context.Context, task *domain.Task, user *domain.User) (*domain.ResourceMember, error)
+	// AddMemberWithID adds a member with id memberID to a task with taskID.
+	AddMemberWithID(ctx context.Context, taskID, memberID string) (*domain.ResourceMember, error)
+	// RemoveMember removes a member from a task.
+	RemoveMember(ctx context.Context, task *domain.Task, user *domain.User) error
+	// RemoveMemberWithID removes a member with id memberID from a task with taskID.
+	RemoveMemberWithID(ctx context.Context, taskID, memberID string) error
+	// FindOwners retrieves owners of a task.
+	FindOwners(ctx context.Context, task *domain.Task) ([]domain.ResourceOwner, error)
+	// FindOwnersWithID retrieves owners of a task with taskID.
+	FindOwnersWithID(ctx context.Context, taskID string) ([]domain.ResourceOwner, error)
+	// AddOwner adds an owner to a task.
+	AddOwner(ctx context.Context, task *domain.Task, user *domain.User) (*domain.ResourceOwner, error)
+	// AddOwnerWithID adds an owner with id memberID to a task with taskID.
+	AddOwnerWithID(ctx context.Context, taskID, memberID string) (*domain.ResourceOwner, error)
+	// RemoveOwner removes an owner from a task.
+	RemoveOwner(ctx context.Context, task *domain.Task, user *domain.User) error
+	// RemoveOwnerWithID removes a member with id memberID from a task with taskID.
+	RemoveOwnerWithID(ctx context.Context, taskID, memberID string) error
+	// FindRuns retrieves a task runs according the filter. More fields can be applied. Filter can be nil.
+	FindRuns(ctx context.Context, task *domain.Task, filter *RunFilter) ([]domain.Run, error)
+	// FindRunsWithID retrieves runs of a task with taskID according the filter. More fields can be applied. Filter can be nil.
+	FindRunsWithID(ctx context.Context, taskID string, filter *RunFilter) ([]domain.Run, error)
+	// GetRun retrieves a refreshed instance if a task run.
+	GetRun(ctx context.Context, run *domain.Run) (*domain.Run, error)
+	// GetRunByID retrieves a specific task run by taskID and runID
+	GetRunByID(ctx context.Context, taskID, runID string) (*domain.Run, error)
+	// FindRunLogs return all log events for a task run.
+	FindRunLogs(ctx context.Context, run *domain.Run) ([]domain.LogEvent, error)
+	// FindRunLogsWithID return all log events for a run with runID of a task with taskID.
+	FindRunLogsWithID(ctx context.Context, taskID, runID string) ([]domain.LogEvent, error)
+	// RunManually manually start a run of the task now, overriding the current schedule.
+	RunManually(ctx context.Context, task *domain.Task) (*domain.Run, error)
+	// RunManuallyWithID manually start a run of a task with taskID now, overriding the current schedule.
+	RunManuallyWithID(ctx context.Context, taskID string) (*domain.Run, error)
+	// RetryRun retry a task run.
+	RetryRun(ctx context.Context, run *domain.Run) (*domain.Run, error)
+	// RetryRunWithID retry a run with runID of a task with taskID.
+	RetryRunWithID(ctx context.Context, taskID, runID string) (*domain.Run, error)
+	// CancelRun cancels a running task.
+	CancelRun(ctx context.Context, run *domain.Run) error
+	// CancelRunWithID cancels a running task.
+	CancelRunWithID(ctx context.Context, taskID, runID string) error
+	// FindLogs retrieves all logs for a task.
+	FindLogs(ctx context.Context, task *domain.Task) ([]domain.LogEvent, error)
+	// FindLogsWithID retrieves all logs for a task with taskID.
+	FindLogsWithID(ctx context.Context, taskID string) ([]domain.LogEvent, error)
+	// FindLabels retrieves labels of a task.
+	FindLabels(ctx context.Context, task *domain.Task) ([]domain.Label, error)
+	// FindLabelsWithID retrieves labels of a task with taskID.
+	FindLabelsWithID(ctx context.Context, taskID string) ([]domain.Label, error)
+	// AddLabel adds a label to a task.
+	AddLabel(ctx context.Context, task *domain.Task, label *domain.Label) (*domain.Label, error)
+	// AddLabelWithID adds a label with id labelID to a task with taskID.
+	AddLabelWithID(ctx context.Context, taskID, labelID string) (*domain.Label, error)
+	// RemoveLabel removes a label from a task.
+	RemoveLabel(ctx context.Context, task *domain.Task, label *domain.Label) error
+	// RemoveLabelWithID removes a label with id labelID from a task with taskID.
+	RemoveLabelWithID(ctx context.Context, taskID, labelID string) error
+}
+
+// tasksAPI implements TasksAPI
+type tasksAPI struct {
+	apiClient *domain.Client
+}
+
+// NewTasksAPI creates new instance of TasksAPI
+func NewTasksAPI(apiClient *domain.Client) TasksAPI {
+	return &tasksAPI{
+		apiClient: apiClient,
+	}
+}
+
+func (t *tasksAPI) FindTasks(ctx context.Context, filter *TaskFilter) ([]domain.Task, error) {
+	params := &domain.GetTasksParams{}
+	if filter != nil {
+		if filter.Name != "" {
+			params.Name = &filter.Name
+		}
+		if filter.User != "" {
+			params.User = &filter.User
+		}
+		if filter.OrgID != "" {
+			params.OrgID = &filter.OrgID
+		}
+		if filter.OrgName != "" {
+			params.Org = &filter.OrgName
+		}
+		if filter.Status != "" {
+			status := domain.GetTasksParamsStatus(filter.Status)
+			params.Status = &status
+		}
+		if filter.Limit > 0 {
+			params.Limit = &filter.Limit
+		}
+		if filter.After != "" {
+			params.After = &filter.After
+		}
+	}
+
+	response, err := t.apiClient.GetTasks(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return *response.Tasks, nil
+}
+
+func (t *tasksAPI) GetTask(ctx context.Context, task *domain.Task) (*domain.Task, error) {
+	return t.GetTaskByID(ctx, task.Id)
+}
+
+func (t *tasksAPI) GetTaskByID(ctx context.Context, taskID string) (*domain.Task, error) {
+	params := &domain.GetTasksIDAllParams{
+		TaskID: taskID,
+	}
+	return t.apiClient.GetTasksID(ctx, params)
+}
+
+func (t *tasksAPI) createTask(ctx context.Context, taskReq *domain.TaskCreateRequest) (*domain.Task, error) {
+	params := &domain.PostTasksAllParams{
+		Body: domain.PostTasksJSONRequestBody(*taskReq),
+	}
+	return t.apiClient.PostTasks(ctx, params)
+}
+
+func createTaskReqDetailed(name, flux string, every, cron *string, orgID string) *domain.TaskCreateRequest {
+	repetition := ""
+	if every != nil {
+		repetition = fmt.Sprintf("every: %s", *every)
+	} else if cron != nil {
+		repetition = fmt.Sprintf(`cron: "%s"`, *cron)
+	}
+	fullFlux := fmt.Sprintf(`option task = { name: "%s", %s } %s`, name, repetition, flux)
+	return createTaskReq(fullFlux, orgID)
+}
+func createTaskReq(flux string, orgID string) *domain.TaskCreateRequest {
+
+	status := domain.TaskStatusTypeActive
+	taskReq := &domain.TaskCreateRequest{
+		Flux:   flux,
+		Status: &status,
+		OrgID:  &orgID,
+	}
+	return taskReq
+}
+
+func (t *tasksAPI) CreateTask(ctx context.Context, task *domain.Task) (*domain.Task, error) {
+	taskReq := createTaskReqDetailed(task.Name, task.Flux, task.Every, task.Cron, task.OrgID)
+	taskReq.Description = task.Description
+	taskReq.Status = task.Status
+	return t.createTask(ctx, taskReq)
+}
+
+func (t *tasksAPI) CreateTaskWithEvery(ctx context.Context, name, flux, every, orgID string) (*domain.Task, error) {
+	taskReq := createTaskReqDetailed(name, flux, &every, nil, orgID)
+	return t.createTask(ctx, taskReq)
+}
+
+func (t *tasksAPI) CreateTaskWithCron(ctx context.Context, name, flux, cron, orgID string) (*domain.Task, error) {
+	taskReq := createTaskReqDetailed(name, flux, nil, &cron, orgID)
+	return t.createTask(ctx, taskReq)
+}
+
+func (t *tasksAPI) CreateTaskByFlux(ctx context.Context, flux, orgID string) (*domain.Task, error) {
+	taskReq := createTaskReq(flux, orgID)
+	return t.createTask(ctx, taskReq)
+}
+
+func (t *tasksAPI) DeleteTask(ctx context.Context, task *domain.Task) error {
+	return t.DeleteTaskWithID(ctx, task.Id)
+}
+
+func (t *tasksAPI) DeleteTaskWithID(ctx context.Context, taskID string) error {
+	params := &domain.DeleteTasksIDAllParams{
+		TaskID: taskID,
+	}
+	return t.apiClient.DeleteTasksID(ctx, params)
+}
+
+func (t *tasksAPI) UpdateTask(ctx context.Context, task *domain.Task) (*domain.Task, error) {
+	params := &domain.PatchTasksIDAllParams{
+		Body: domain.PatchTasksIDJSONRequestBody(domain.TaskUpdateRequest{
+			Description: task.Description,
+			Flux:        &task.Flux,
+			Name:        &task.Name,
+			Offset:      task.Offset,
+			Status:      task.Status,
+		}),
+		TaskID: task.Id,
+	}
+	if task.Every != nil {
+		params.Body.Every = task.Every
+	} else {
+		params.Body.Cron = task.Cron
+	}
+	return t.apiClient.PatchTasksID(ctx, params)
+}
+
+func (t *tasksAPI) FindMembers(ctx context.Context, task *domain.Task) ([]domain.ResourceMember, error) {
+	return t.FindMembersWithID(ctx, task.Id)
+}
+
+func (t *tasksAPI) FindMembersWithID(ctx context.Context, taskID string) ([]domain.ResourceMember, error) {
+	params := &domain.GetTasksIDMembersAllParams{
+		TaskID: taskID,
+	}
+	response, err := t.apiClient.GetTasksIDMembers(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return *response.Users, nil
+}
+
+func (t *tasksAPI) AddMember(ctx context.Context, task *domain.Task, user *domain.User) (*domain.ResourceMember, error) {
+	return t.AddMemberWithID(ctx, task.Id, *user.Id)
+}
+
+func (t *tasksAPI) AddMemberWithID(ctx context.Context, taskID, memberID string) (*domain.ResourceMember, error) {
+	params := &domain.PostTasksIDMembersAllParams{
+		TaskID: taskID,
+		Body:   domain.PostTasksIDMembersJSONRequestBody{Id: memberID},
+	}
+
+	return t.apiClient.PostTasksIDMembers(ctx, params)
+}
+
+func (t *tasksAPI) RemoveMember(ctx context.Context, task *domain.Task, user *domain.User) error {
+	return t.RemoveMemberWithID(ctx, task.Id, *user.Id)
+}
+
+func (t *tasksAPI) RemoveMemberWithID(ctx context.Context, taskID, memberID string) error {
+	params := &domain.DeleteTasksIDMembersIDAllParams{
+		TaskID: taskID,
+		UserID: memberID,
+	}
+	return t.apiClient.DeleteTasksIDMembersID(ctx, params)
+}
+
+func (t *tasksAPI) FindOwners(ctx context.Context, task *domain.Task) ([]domain.ResourceOwner, error) {
+	return t.FindOwnersWithID(ctx, task.Id)
+}
+
+func (t *tasksAPI) FindOwnersWithID(ctx context.Context, taskID string) ([]domain.ResourceOwner, error) {
+	params := &domain.GetTasksIDOwnersAllParams{
+		TaskID: taskID,
+	}
+	response, err := t.apiClient.GetTasksIDOwners(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return *response.Users, nil
+}
+
+func (t *tasksAPI) AddOwner(ctx context.Context, task *domain.Task, user *domain.User) (*domain.ResourceOwner, error) {
+	return t.AddOwnerWithID(ctx, task.Id, *user.Id)
+}
+
+func (t *tasksAPI) AddOwnerWithID(ctx context.Context, taskID, memberID string) (*domain.ResourceOwner, error) {
+	params := &domain.PostTasksIDOwnersAllParams{
+		Body:   domain.PostTasksIDOwnersJSONRequestBody{Id: memberID},
+		TaskID: taskID,
+	}
+	return t.apiClient.PostTasksIDOwners(ctx, params)
+}
+
+func (t *tasksAPI) RemoveOwner(ctx context.Context, task *domain.Task, user *domain.User) error {
+	return t.RemoveOwnerWithID(ctx, task.Id, *user.Id)
+}
+
+func (t *tasksAPI) RemoveOwnerWithID(ctx context.Context, taskID, memberID string) error {
+	params := &domain.DeleteTasksIDOwnersIDAllParams{
+		TaskID: taskID,
+		UserID: memberID,
+	}
+	return t.apiClient.DeleteTasksIDOwnersID(ctx, params)
+}
+
+func (t *tasksAPI) FindRuns(ctx context.Context, task *domain.Task, filter *RunFilter) ([]domain.Run, error) {
+	return t.FindRunsWithID(ctx, task.Id, filter)
+}
+
+func (t *tasksAPI) FindRunsWithID(ctx context.Context, taskID string, filter *RunFilter) ([]domain.Run, error) {
+	params := &domain.GetTasksIDRunsAllParams{TaskID: taskID}
+	if filter != nil {
+		if !filter.AfterTime.IsZero() {
+			params.AfterTime = &filter.AfterTime
+		}
+		if !filter.BeforeTime.IsZero() {
+			params.BeforeTime = &filter.BeforeTime
+		}
+		if filter.Limit > 0 {
+			params.Limit = &filter.Limit
+		}
+		if filter.After != "" {
+			params.After = &filter.After
+		}
+	}
+	response, err := t.apiClient.GetTasksIDRuns(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return *response.Runs, nil
+}
+
+func (t *tasksAPI) GetRun(ctx context.Context, run *domain.Run) (*domain.Run, error) {
+	return t.GetRunByID(ctx, *run.TaskID, *run.Id)
+}
+
+func (t *tasksAPI) GetRunByID(ctx context.Context, taskID, runID string) (*domain.Run, error) {
+	params := &domain.GetTasksIDRunsIDAllParams{
+		TaskID: taskID,
+		RunID:  runID,
+	}
+	return t.apiClient.GetTasksIDRunsID(ctx, params)
+}
+
+func (t *tasksAPI) FindRunLogs(ctx context.Context, run *domain.Run) ([]domain.LogEvent, error) {
+	return t.FindRunLogsWithID(ctx, *run.TaskID, *run.Id)
+}
+func (t *tasksAPI) FindRunLogsWithID(ctx context.Context, taskID, runID string) ([]domain.LogEvent, error) {
+	params := &domain.GetTasksIDRunsIDLogsAllParams{
+		TaskID: taskID,
+		RunID:  runID,
+	}
+	response, err := t.apiClient.GetTasksIDRunsIDLogs(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	if response.Events == nil {
+		return nil, fmt.Errorf("logs for task '%s' run '%s 'not found", taskID, runID)
+	}
+	return *response.Events, nil
+}
+
+func (t *tasksAPI) RunManually(ctx context.Context, task *domain.Task) (*domain.Run, error) {
+	return t.RunManuallyWithID(ctx, task.Id)
+}
+
+func (t *tasksAPI) RunManuallyWithID(ctx context.Context, taskID string) (*domain.Run, error) {
+	params := &domain.PostTasksIDRunsAllParams{
+		TaskID: taskID,
+	}
+	return t.apiClient.PostTasksIDRuns(ctx, params)
+}
+
+func (t *tasksAPI) RetryRun(ctx context.Context, run *domain.Run) (*domain.Run, error) {
+	return t.RetryRunWithID(ctx, *run.TaskID, *run.Id)
+}
+
+func (t *tasksAPI) RetryRunWithID(ctx context.Context, taskID, runID string) (*domain.Run, error) {
+	params := &domain.PostTasksIDRunsIDRetryAllParams{
+		TaskID: taskID,
+		RunID:  runID,
+	}
+	return t.apiClient.PostTasksIDRunsIDRetry(ctx, params)
+}
+
+func (t *tasksAPI) CancelRun(ctx context.Context, run *domain.Run) error {
+	return t.CancelRunWithID(ctx, *run.TaskID, *run.Id)
+}
+
+func (t *tasksAPI) CancelRunWithID(ctx context.Context, taskID, runID string) error {
+	params := &domain.DeleteTasksIDRunsIDAllParams{
+		TaskID: taskID,
+		RunID:  runID,
+	}
+	return t.apiClient.DeleteTasksIDRunsID(ctx, params)
+}
+
+func (t *tasksAPI) FindLogs(ctx context.Context, task *domain.Task) ([]domain.LogEvent, error) {
+	return t.FindLogsWithID(ctx, task.Id)
+}
+
+func (t *tasksAPI) FindLogsWithID(ctx context.Context, taskID string) ([]domain.LogEvent, error) {
+	params := &domain.GetTasksIDLogsAllParams{
+		TaskID: taskID,
+	}
+	response, err := t.apiClient.GetTasksIDLogs(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	if response.Events == nil {
+		return nil, fmt.Errorf("logs for task '%s' not found", taskID)
+	}
+	return *response.Events, nil
+}
+
+func (t *tasksAPI) FindLabels(ctx context.Context, task *domain.Task) ([]domain.Label, error) {
+	return t.FindLabelsWithID(ctx, task.Id)
+}
+
+func (t *tasksAPI) FindLabelsWithID(ctx context.Context, taskID string) ([]domain.Label, error) {
+	params := &domain.GetTasksIDLabelsAllParams{
+		TaskID: taskID,
+	}
+	response, err := t.apiClient.GetTasksIDLabels(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	if response.Labels == nil {
+		return nil, fmt.Errorf("lables for task '%s' not found", taskID)
+	}
+	return *response.Labels, nil
+}
+
+func (t *tasksAPI) AddLabel(ctx context.Context, task *domain.Task, label *domain.Label) (*domain.Label, error) {
+	return t.AddLabelWithID(ctx, task.Id, *label.Id)
+}
+
+func (t *tasksAPI) AddLabelWithID(ctx context.Context, taskID, labelID string) (*domain.Label, error) {
+	params := &domain.PostTasksIDLabelsAllParams{
+		Body:   domain.PostTasksIDLabelsJSONRequestBody{LabelID: &labelID},
+		TaskID: taskID,
+	}
+	response, err := t.apiClient.PostTasksIDLabels(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return response.Label, nil
+}
+
+func (t *tasksAPI) RemoveLabel(ctx context.Context, task *domain.Task, label *domain.Label) error {
+	return t.RemoveLabelWithID(ctx, task.Id, *label.Id)
+}
+
+func (t *tasksAPI) RemoveLabelWithID(ctx context.Context, taskID, labelID string) error {
+	params := &domain.DeleteTasksIDLabelsIDAllParams{
+		TaskID:  taskID,
+		LabelID: labelID,
+	}
+	return t.apiClient.DeleteTasksIDLabelsID(ctx, params)
+}

+ 241 - 0
vendor/github.com/influxdata/influxdb-client-go/api/users.go

@@ -0,0 +1,241 @@
+// Copyright 2020-2021 InfluxData, Inc. All rights reserved.
+// Use of this source code is governed by MIT
+// license that can be found in the LICENSE file.
+
+package api
+
+import (
+	"context"
+	"encoding/base64"
+	"fmt"
+	nethttp "net/http"
+	"net/http/cookiejar"
+	"sync"
+
+	"github.com/influxdata/influxdb-client-go/v2/api/http"
+	"github.com/influxdata/influxdb-client-go/v2/domain"
+	"golang.org/x/net/publicsuffix"
+)
+
+// UsersAPI provides methods for managing users in a InfluxDB server
+type UsersAPI interface {
+	// GetUsers returns all users
+	GetUsers(ctx context.Context) (*[]domain.User, error)
+	// FindUserByID returns user with userID
+	FindUserByID(ctx context.Context, userID string) (*domain.User, error)
+	// FindUserByName returns user with name userName
+	FindUserByName(ctx context.Context, userName string) (*domain.User, error)
+	// CreateUser creates new user
+	CreateUser(ctx context.Context, user *domain.User) (*domain.User, error)
+	// CreateUserWithName creates new user with userName
+	CreateUserWithName(ctx context.Context, userName string) (*domain.User, error)
+	// UpdateUser updates user
+	UpdateUser(ctx context.Context, user *domain.User) (*domain.User, error)
+	// UpdateUserPassword sets password for a user
+	UpdateUserPassword(ctx context.Context, user *domain.User, password string) error
+	// UpdateUserPasswordWithID sets password for a user with userID
+	UpdateUserPasswordWithID(ctx context.Context, userID string, password string) error
+	// DeleteUserWithID deletes an user with userID
+	DeleteUserWithID(ctx context.Context, userID string) error
+	// DeleteUser deletes an user
+	DeleteUser(ctx context.Context, user *domain.User) error
+	// Me returns actual user
+	Me(ctx context.Context) (*domain.User, error)
+	// MeUpdatePassword set password of actual user
+	MeUpdatePassword(ctx context.Context, oldPassword, newPassword string) error
+	// SignIn exchanges username and password credentials to establish an authenticated session with the InfluxDB server. The Client's authentication token is then ignored, it can be empty.
+	SignIn(ctx context.Context, username, password string) error
+	// SignOut signs out previously signed-in user
+	SignOut(ctx context.Context) error
+}
+
+// usersAPI implements UsersAPI
+type usersAPI struct {
+	apiClient       *domain.Client
+	httpService     http.Service
+	httpClient      *nethttp.Client
+	deleteCookieJar bool
+	lock            sync.Mutex
+}
+
+// NewUsersAPI creates new instance of UsersAPI
+func NewUsersAPI(apiClient *domain.Client, httpService http.Service, httpClient *nethttp.Client) UsersAPI {
+	return &usersAPI{
+		apiClient:   apiClient,
+		httpService: httpService,
+		httpClient:  httpClient,
+	}
+}
+
+func (u *usersAPI) GetUsers(ctx context.Context) (*[]domain.User, error) {
+	params := &domain.GetUsersParams{}
+	response, err := u.apiClient.GetUsers(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return userResponsesToUsers(response.Users), nil
+}
+
+func (u *usersAPI) FindUserByID(ctx context.Context, userID string) (*domain.User, error) {
+	params := &domain.GetUsersIDAllParams{
+		UserID: userID,
+	}
+	response, err := u.apiClient.GetUsersID(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return userResponseToUser(response), nil
+}
+
+func (u *usersAPI) FindUserByName(ctx context.Context, userName string) (*domain.User, error) {
+	users, err := u.GetUsers(ctx)
+	if err != nil {
+		return nil, err
+	}
+	var user *domain.User
+	for _, u := range *users {
+		if u.Name == userName {
+			user = &u
+			break
+		}
+	}
+	if user == nil {
+		return nil, fmt.Errorf("user '%s' not found", userName)
+	}
+	return user, nil
+}
+
+func (u *usersAPI) CreateUserWithName(ctx context.Context, userName string) (*domain.User, error) {
+	user := &domain.User{Name: userName}
+	return u.CreateUser(ctx, user)
+}
+
+func (u *usersAPI) CreateUser(ctx context.Context, user *domain.User) (*domain.User, error) {
+	params := &domain.PostUsersAllParams{
+		Body: domain.PostUsersJSONRequestBody(*user),
+	}
+	response, err := u.apiClient.PostUsers(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return userResponseToUser(response), nil
+}
+
+func (u *usersAPI) UpdateUser(ctx context.Context, user *domain.User) (*domain.User, error) {
+	params := &domain.PatchUsersIDAllParams{
+		Body:   domain.PatchUsersIDJSONRequestBody(*user),
+		UserID: *user.Id,
+	}
+	response, err := u.apiClient.PatchUsersID(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return userResponseToUser(response), nil
+}
+
+func (u *usersAPI) UpdateUserPassword(ctx context.Context, user *domain.User, password string) error {
+	return u.UpdateUserPasswordWithID(ctx, *user.Id, password)
+}
+
+func (u *usersAPI) UpdateUserPasswordWithID(ctx context.Context, userID string, password string) error {
+	params := &domain.PostUsersIDPasswordAllParams{
+		UserID: userID,
+		Body:   domain.PostUsersIDPasswordJSONRequestBody(domain.PasswordResetBody{Password: password}),
+	}
+	return u.apiClient.PostUsersIDPassword(ctx, params)
+}
+
+func (u *usersAPI) DeleteUser(ctx context.Context, user *domain.User) error {
+	return u.DeleteUserWithID(ctx, *user.Id)
+}
+
+func (u *usersAPI) DeleteUserWithID(ctx context.Context, userID string) error {
+	params := &domain.DeleteUsersIDAllParams{
+		UserID: userID,
+	}
+	return u.apiClient.DeleteUsersID(ctx, params)
+}
+
+func (u *usersAPI) Me(ctx context.Context) (*domain.User, error) {
+	params := &domain.GetMeParams{}
+	response, err := u.apiClient.GetMe(ctx, params)
+	if err != nil {
+		return nil, err
+	}
+	return userResponseToUser(response), nil
+}
+
+func (u *usersAPI) MeUpdatePassword(ctx context.Context, oldPassword, newPassword string) error {
+	u.lock.Lock()
+	defer u.lock.Unlock()
+	me, err := u.Me(ctx)
+	if err != nil {
+		return err
+	}
+	creds := base64.StdEncoding.EncodeToString([]byte(me.Name + ":" + oldPassword))
+	auth := u.httpService.Authorization()
+	defer u.httpService.SetAuthorization(auth)
+	u.httpService.SetAuthorization("Basic " + creds)
+	params := &domain.PutMePasswordAllParams{
+		Body: domain.PutMePasswordJSONRequestBody(domain.PasswordResetBody{Password: newPassword}),
+	}
+	return u.apiClient.PutMePassword(ctx, params)
+}
+
+func (u *usersAPI) SignIn(ctx context.Context, username, password string) error {
+	u.lock.Lock()
+	defer u.lock.Unlock()
+	if u.httpClient.Jar == nil {
+		jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
+		if err != nil {
+			return err
+		}
+		u.httpClient.Jar = jar
+		u.deleteCookieJar = true
+	}
+	creds := base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
+	u.httpService.SetAuthorization("Basic " + creds)
+	defer u.httpService.SetAuthorization("")
+	return u.apiClient.PostSignin(ctx, &domain.PostSigninParams{})
+}
+
+func (u *usersAPI) SignOut(ctx context.Context) error {
+	u.lock.Lock()
+	defer u.lock.Unlock()
+	err := u.apiClient.PostSignout(ctx, &domain.PostSignoutParams{})
+	if u.deleteCookieJar {
+		u.httpClient.Jar = nil
+	}
+	return err
+}
+
+func userResponseToUser(ur *domain.UserResponse) *domain.User {
+	if ur == nil {
+		return nil
+	}
+	user := &domain.User{
+		Id:     ur.Id,
+		Name:   ur.Name,
+		Status: userResponseStatusToUserStatus(ur.Status),
+	}
+	return user
+}
+
+func userResponseStatusToUserStatus(urs *domain.UserResponseStatus) *domain.UserStatus {
+	if urs == nil {
+		return nil
+	}
+	us := domain.UserStatus(*urs)
+	return &us
+}
+
+func userResponsesToUsers(urs *[]domain.UserResponse) *[]domain.User {
+	if urs == nil {
+		return nil
+	}
+	us := make([]domain.User, len(*urs))
+	for i, ur := range *urs {
+		us[i] = *userResponseToUser(&ur)
+	}
+	return &us
+}

+ 268 - 0
vendor/github.com/influxdata/influxdb-client-go/api/write.go

@@ -0,0 +1,268 @@
+// Copyright 2020-2021 InfluxData, Inc. All rights reserved.
+// Use of this source code is governed by MIT
+// license that can be found in the LICENSE file.
+
+package api
+
+import (
+	"context"
+	"strings"
+	"sync"
+	"sync/atomic"
+	"time"
+
+	http2 "github.com/influxdata/influxdb-client-go/v2/api/http"
+	"github.com/influxdata/influxdb-client-go/v2/api/write"
+	"github.com/influxdata/influxdb-client-go/v2/internal/log"
+	iwrite "github.com/influxdata/influxdb-client-go/v2/internal/write"
+)
+
+// WriteFailedCallback is synchronously notified in case non-blocking write fails.
+// batch contains complete payload, error holds detailed error information,
+// retryAttempts means number of retries, 0 if it failed during first write.
+// It must return true if WriteAPI should continue with retrying, false will discard the batch.
+type WriteFailedCallback func(batch string, error http2.Error, retryAttempts uint) bool
+
+// WriteAPI is Write client interface with non-blocking methods for writing time series data asynchronously in batches into an InfluxDB server.
+// WriteAPI can be used concurrently.
+// When using multiple goroutines for writing, use a single WriteAPI instance in all goroutines.
+type WriteAPI interface {
+	// WriteRecord writes asynchronously line protocol record into bucket.
+	// WriteRecord adds record into the buffer which is sent on the background when it reaches the batch size.
+	// Blocking alternative is available in the WriteAPIBlocking interface
+	WriteRecord(line string)
+	// WritePoint writes asynchronously Point into bucket.
+	// WritePoint adds Point into the buffer which is sent on the background when it reaches the batch size.
+	// Blocking alternative is available in the WriteAPIBlocking interface
+	WritePoint(point *write.Point)
+	// Flush forces all pending writes from the buffer to be sent
+	Flush()
+	// Errors returns a channel for reading errors which occurs during async writes.
+	// Must be called before performing any writes for errors to be collected.
+	// The chan is unbuffered and must be drained or the writer will block.
+	Errors() <-chan error
+	// SetWriteFailedCallback sets callback allowing custom handling of failed writes.
+	// If callback returns true, failed batch will be retried, otherwise discarded.
+	SetWriteFailedCallback(cb WriteFailedCallback)
+}
+
+// WriteAPIImpl provides main implementation for WriteAPI
+type WriteAPIImpl struct {
+	service     *iwrite.Service
+	writeBuffer []string
+
+	errCh        chan error
+	writeCh      chan *iwrite.Batch
+	bufferCh     chan string
+	writeStop    chan struct{}
+	bufferStop   chan struct{}
+	bufferFlush  chan struct{}
+	doneCh       chan struct{}
+	bufferInfoCh chan writeBuffInfoReq
+	writeInfoCh  chan writeBuffInfoReq
+	writeOptions *write.Options
+	closingMu    *sync.Mutex
+	// more appropriate Bool type from sync/atomic cannot be used because it is available since go 1.19
+	isErrChReader int32
+}
+
+type writeBuffInfoReq struct {
+	writeBuffLen int
+}
+
+// NewWriteAPI returns new non-blocking write client for writing data to  bucket belonging to org
+func NewWriteAPI(org string, bucket string, service http2.Service, writeOptions *write.Options) *WriteAPIImpl {
+	w := &WriteAPIImpl{
+		service:      iwrite.NewService(org, bucket, service, writeOptions),
+		errCh:        make(chan error, 1),
+		writeBuffer:  make([]string, 0, writeOptions.BatchSize()+1),
+		writeCh:      make(chan *iwrite.Batch),
+		bufferCh:     make(chan string),
+		bufferStop:   make(chan struct{}),
+		writeStop:    make(chan struct{}),
+		bufferFlush:  make(chan struct{}),
+		doneCh:       make(chan struct{}),
+		bufferInfoCh: make(chan writeBuffInfoReq),
+		writeInfoCh:  make(chan writeBuffInfoReq),
+		writeOptions: writeOptions,
+		closingMu:    &sync.Mutex{},
+	}
+
+	go w.bufferProc()
+	go w.writeProc()
+
+	return w
+}
+
+// SetWriteFailedCallback sets callback allowing custom handling of failed writes.
+// If callback returns true, failed batch will be retried, otherwise discarded.
+func (w *WriteAPIImpl) SetWriteFailedCallback(cb WriteFailedCallback) {
+	w.service.SetBatchErrorCallback(func(batch *iwrite.Batch, error2 http2.Error) bool {
+		return cb(batch.Batch, error2, batch.RetryAttempts)
+	})
+}
+
+// Errors returns a channel for reading errors which occurs during async writes.
+// Must be called before performing any writes for errors to be collected.
+// New error is skipped when channel is not read.
+func (w *WriteAPIImpl) Errors() <-chan error {
+	w.setErrChanRead()
+	return w.errCh
+}
+
+// Flush forces all pending writes from the buffer to be sent.
+// Flush also tries sending batches from retry queue without additional retrying.
+func (w *WriteAPIImpl) Flush() {
+	w.bufferFlush <- struct{}{}
+	w.waitForFlushing()
+	w.service.Flush()
+}
+
+func (w *WriteAPIImpl) waitForFlushing() {
+	for {
+		w.bufferInfoCh <- writeBuffInfoReq{}
+		writeBuffInfo := <-w.bufferInfoCh
+		if writeBuffInfo.writeBuffLen == 0 {
+			break
+		}
+		log.Info("Waiting buffer is flushed")
+		<-time.After(time.Millisecond)
+	}
+	for {
+		w.writeInfoCh <- writeBuffInfoReq{}
+		writeBuffInfo := <-w.writeInfoCh
+		if writeBuffInfo.writeBuffLen == 0 {
+			break
+		}
+		log.Info("Waiting buffer is flushed")
+		<-time.After(time.Millisecond)
+	}
+}
+
+func (w *WriteAPIImpl) bufferProc() {
+	log.Info("Buffer proc started")
+	ticker := time.NewTicker(time.Duration(w.writeOptions.FlushInterval()) * time.Millisecond)
+x:
+	for {
+		select {
+		case line := <-w.bufferCh:
+			w.writeBuffer = append(w.writeBuffer, line)
+			if len(w.writeBuffer) == int(w.writeOptions.BatchSize()) {
+				w.flushBuffer()
+			}
+		case <-ticker.C:
+			w.flushBuffer()
+		case <-w.bufferFlush:
+			w.flushBuffer()
+		case <-w.bufferStop:
+			ticker.Stop()
+			w.flushBuffer()
+			break x
+		case buffInfo := <-w.bufferInfoCh:
+			buffInfo.writeBuffLen = len(w.bufferInfoCh)
+			w.bufferInfoCh <- buffInfo
+		}
+	}
+	log.Info("Buffer proc finished")
+	w.doneCh <- struct{}{}
+}
+
+func (w *WriteAPIImpl) flushBuffer() {
+	if len(w.writeBuffer) > 0 {
+		log.Info("sending batch")
+		batch := iwrite.NewBatch(buffer(w.writeBuffer), w.writeOptions.MaxRetryTime())
+		w.writeCh <- batch
+		w.writeBuffer = w.writeBuffer[:0]
+	}
+}
+func (w *WriteAPIImpl) isErrChanRead() bool {
+	return atomic.LoadInt32(&w.isErrChReader) > 0
+}
+
+func (w *WriteAPIImpl) setErrChanRead() {
+	atomic.StoreInt32(&w.isErrChReader, 1)
+}
+
+func (w *WriteAPIImpl) writeProc() {
+	log.Info("Write proc started")
+x:
+	for {
+		select {
+		case batch := <-w.writeCh:
+			err := w.service.HandleWrite(context.Background(), batch)
+			if err != nil && w.isErrChanRead() {
+				select {
+				case w.errCh <- err:
+				default:
+					log.Warn("Cannot write error to error channel, it is not read")
+				}
+			}
+		case <-w.writeStop:
+			log.Info("Write proc: received stop")
+			break x
+		case buffInfo := <-w.writeInfoCh:
+			buffInfo.writeBuffLen = len(w.writeCh)
+			w.writeInfoCh <- buffInfo
+		}
+	}
+	log.Info("Write proc finished")
+	w.doneCh <- struct{}{}
+}
+
+// Close finishes outstanding write operations,
+// stop background routines and closes all channels
+func (w *WriteAPIImpl) Close() {
+	w.closingMu.Lock()
+	defer w.closingMu.Unlock()
+	if w.writeCh != nil {
+		// Flush outstanding metrics
+		w.Flush()
+
+		// stop and wait for buffer proc
+		close(w.bufferStop)
+		<-w.doneCh
+
+		close(w.bufferFlush)
+		close(w.bufferCh)
+
+		// stop and wait for write proc
+		close(w.writeStop)
+		<-w.doneCh
+
+		close(w.writeCh)
+		close(w.writeInfoCh)
+		close(w.bufferInfoCh)
+		w.writeCh = nil
+
+		close(w.errCh)
+		w.errCh = nil
+	}
+}
+
+// WriteRecord writes asynchronously line protocol record into bucket.
+// WriteRecord adds record into the buffer which is sent on the background when it reaches the batch size.
+// Blocking alternative is available in the WriteAPIBlocking interface
+func (w *WriteAPIImpl) WriteRecord(line string) {
+	b := []byte(line)
+	b = append(b, 0xa)
+	w.bufferCh <- string(b)
+}
+
+// WritePoint writes asynchronously Point into bucket.
+// WritePoint adds Point into the buffer which is sent on the background when it reaches the batch size.
+// Blocking alternative is available in the WriteAPIBlocking interface
+func (w *WriteAPIImpl) WritePoint(point *write.Point) {
+	line, err := w.service.EncodePoints(point)
+	if err != nil {
+		log.Errorf("point encoding error: %s\n", err.Error())
+		if w.errCh != nil {
+			w.errCh <- err
+		}
+	} else {
+		w.bufferCh <- line
+	}
+}
+
+func buffer(lines []string) string {
+	return strings.Join(lines, "")
+}

+ 135 - 0
vendor/github.com/influxdata/influxdb-client-go/api/writeAPIBlocking.go

@@ -0,0 +1,135 @@
+// Copyright 2020-2021 InfluxData, Inc. All rights reserved.
+// Use of this source code is governed by MIT
+// license that can be found in the LICENSE file.
+
+package api
+
+import (
+	"context"
+	"strings"
+	"sync"
+	"sync/atomic"
+
+	http2 "github.com/influxdata/influxdb-client-go/v2/api/http"
+	"github.com/influxdata/influxdb-client-go/v2/api/write"
+	iwrite "github.com/influxdata/influxdb-client-go/v2/internal/write"
+)
+
+// WriteAPIBlocking offers blocking methods for writing time series data synchronously into an InfluxDB server.
+// It doesn't implicitly create batches of points by default. Batches are created from array of points/records.
+//
+// Implicit batching is enabled with EnableBatching(). In this mode, each call to WritePoint or WriteRecord adds a line
+// to internal buffer. If length ot the buffer is equal to the batch-size (set in write.Options), the buffer is sent to the server
+// and the result of the operation is returned.
+// When a point is written to the buffer, nil error is always returned.
+// Flush() can be used to trigger sending of batch when it doesn't have the batch-size.
+//
+// Synchronous writing is intended to use for writing less frequent data, such as a weather sensing, or if there is a need to have explicit control of failed batches.
+
+//
+// WriteAPIBlocking can be used concurrently.
+// When using multiple goroutines for writing, use a single WriteAPIBlocking instance in all goroutines.
+type WriteAPIBlocking interface {
+	// WriteRecord writes line protocol record(s) into bucket.
+	// WriteRecord writes lines without implicit batching by default, batch is created from given number of records.
+	// Automatic batching can be enabled by EnableBatching()
+	// Individual arguments can also be batches (multiple records separated by newline).
+	// Non-blocking alternative is available in the WriteAPI interface
+	WriteRecord(ctx context.Context, line ...string) error
+	// WritePoint data point into bucket.
+	// WriteRecord writes points without implicit batching by default, batch is created from given number of points.
+	// Automatic batching can be enabled by EnableBatching().
+	// Non-blocking alternative is available in the WriteAPI interface
+	WritePoint(ctx context.Context, point ...*write.Point) error
+	// EnableBatching turns on implicit batching
+	// Batch size is controlled via write.Options
+	EnableBatching()
+	// Flush forces write of buffer if batching is enabled, even buffer doesn't have the batch-size.
+	Flush(ctx context.Context) error
+}
+
+// writeAPIBlocking implements WriteAPIBlocking interface
+type writeAPIBlocking struct {
+	service      *iwrite.Service
+	writeOptions *write.Options
+	// more appropriate Bool type from sync/atomic cannot be used because it is available since go 1.19
+	batching int32
+	batch    []string
+	mu       sync.Mutex
+}
+
+// NewWriteAPIBlocking creates new instance of blocking write client for writing data to bucket belonging to org
+func NewWriteAPIBlocking(org string, bucket string, service http2.Service, writeOptions *write.Options) WriteAPIBlocking {
+	return &writeAPIBlocking{service: iwrite.NewService(org, bucket, service, writeOptions), writeOptions: writeOptions}
+}
+
+// NewWriteAPIBlockingWithBatching creates new instance of blocking write client for writing data to bucket belonging to org with batching enabled
+func NewWriteAPIBlockingWithBatching(org string, bucket string, service http2.Service, writeOptions *write.Options) WriteAPIBlocking {
+	api := &writeAPIBlocking{service: iwrite.NewService(org, bucket, service, writeOptions), writeOptions: writeOptions}
+	api.EnableBatching()
+	return api
+}
+
+func (w *writeAPIBlocking) EnableBatching() {
+	if atomic.LoadInt32(&w.batching) == 0 {
+		w.mu.Lock()
+		w.batching = 1
+		w.batch = make([]string, 0, w.writeOptions.BatchSize())
+		w.mu.Unlock()
+	}
+}
+
+func (w *writeAPIBlocking) write(ctx context.Context, line string) error {
+	if atomic.LoadInt32(&w.batching) > 0 {
+		w.mu.Lock()
+		defer w.mu.Unlock()
+		w.batch = append(w.batch, line)
+		if len(w.batch) == int(w.writeOptions.BatchSize()) {
+			return w.flush(ctx)
+		}
+		return nil
+	}
+	err := w.service.WriteBatch(ctx, iwrite.NewBatch(line, w.writeOptions.MaxRetryTime()))
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func (w *writeAPIBlocking) WriteRecord(ctx context.Context, line ...string) error {
+	if len(line) == 0 {
+		return nil
+	}
+	return w.write(ctx, strings.Join(line, "\n"))
+}
+
+func (w *writeAPIBlocking) WritePoint(ctx context.Context, point ...*write.Point) error {
+	line, err := w.service.EncodePoints(point...)
+	if err != nil {
+		return err
+	}
+	return w.write(ctx, line)
+}
+
+// flush is unsychronized helper for creating and sending batch
+// Must be called from synchronized block
+func (w *writeAPIBlocking) flush(ctx context.Context) error {
+	if len(w.batch) > 0 {
+		body := strings.Join(w.batch, "\n")
+		w.batch = w.batch[:0]
+		b := iwrite.NewBatch(body, w.writeOptions.MaxRetryTime())
+		if err:= w.service.WriteBatch(ctx, b); err != nil {
+			return err
+		}
+	}
+	return nil
+}
+
+func (w *writeAPIBlocking) Flush(ctx context.Context) error {
+	if atomic.LoadInt32(&w.batching) > 0 {
+		w.mu.Lock()
+		defer w.mu.Unlock()
+		return w.flush(ctx)
+	}
+	return nil
+}

+ 6 - 0
vendor/vendor.json

@@ -703,6 +703,12 @@
 			"revision": "ebe99fcebbcedf6e7916320cce24c3e1832766ac",
 			"revisionTime": "2018-03-14T04:19:18Z"
 		},
+		{
+			"checksumSHA1": "K6BZr7t79Ks3yno+oHjlTvvMwRY=",
+			"path": "github.com/influxdata/influxdb-client-go/api",
+			"revision": "5971a9a0a9102b0c376dc6b5fe3f50906de04142",
+			"revisionTime": "2022-11-15T13:18:18Z"
+		},
 		{
 			"checksumSHA1": "R8JkoEsr84IjUvngtp9ljjZXWVE=",
 			"origin": "github.com/kataras/iris/vendor/github.com/iris-contrib/formBinder",