From 5f56b5cb33f9d1939b1d168f1c0d125ee0f1ddfe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 13:16:26 +0000 Subject: [PATCH] chore(deps): bump github.com/influxdata/influxdb-client-go/v2 Bumps [github.com/influxdata/influxdb-client-go/v2](https://github.com/influxdata/influxdb-client-go) from 2.13.0 to 2.14.0. - [Release notes](https://github.com/influxdata/influxdb-client-go/releases) - [Changelog](https://github.com/influxdata/influxdb-client-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/influxdata/influxdb-client-go/compare/v2.13.0...v2.14.0) --- updated-dependencies: - dependency-name: github.com/influxdata/influxdb-client-go/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/go-logfmt/logfmt/README.md | 82 +- .../influxdb-client-go/v2/CHANGELOG.md | 11 + .../influxdb-client-go/v2/api/http/error.go | 22 + .../influxdb-client-go/v2/api/http/service.go | 1 + .../influxdb-client-go/v2/domain/Readme.md | 4 +- .../v2/domain/checks.client.go | 762 ++++++++++++++++++ .../v2/domain/checks.types.go | 537 ++++++++++++ .../v2/domain/client.gen.go | 708 ---------------- .../influxdb-client-go/v2/domain/types.gen.go | 468 +---------- .../v2/internal/write/service.go | 19 +- .../influxdb-client-go/v2/version.go | 2 +- vendor/modules.txt | 2 +- 14 files changed, 1435 insertions(+), 1189 deletions(-) create mode 100644 vendor/github.com/influxdata/influxdb-client-go/v2/domain/checks.client.go create mode 100644 vendor/github.com/influxdata/influxdb-client-go/v2/domain/checks.types.go diff --git a/go.mod b/go.mod index 4322a6cafee..6829f1973fc 100644 --- a/go.mod +++ b/go.mod @@ -60,7 +60,7 @@ require ( github.com/gophercloud/gophercloud v1.14.0 github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 github.com/hashicorp/vault/api v1.14.0 - github.com/influxdata/influxdb-client-go/v2 v2.13.0 + github.com/influxdata/influxdb-client-go/v2 v2.14.0 github.com/jackc/pgx/v5 v5.6.0 github.com/joho/godotenv v1.5.1 github.com/jstemmer/go-junit-report/v2 v2.1.0 diff --git a/go.sum b/go.sum index e7cefad3489..c326918b0c0 100644 --- a/go.sum +++ b/go.sum @@ -1393,8 +1393,8 @@ github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+h github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/influxdata/influxdb-client-go/v2 v2.13.0 h1:ioBbLmR5NMbAjP4UVA5r9b5xGjpABD7j65pI8kFphDM= -github.com/influxdata/influxdb-client-go/v2 v2.13.0/go.mod h1:k+spCbt9hcvqvUiz0sr5D8LolXHqAAOfPw9v/RIRHl4= +github.com/influxdata/influxdb-client-go/v2 v2.14.0 h1:AjbBfJuq+QoaXNcrova8smSjwJdUHnwvfjMF71M1iI4= +github.com/influxdata/influxdb-client-go/v2 v2.14.0/go.mod h1:Ahpm3QXKMJslpXl3IftVLVezreAUtBOTZssDrjZEFHI= github.com/influxdata/line-protocol v0.0.0-20210922203350-b1ad95c89adf h1:7JTmneyiNEwVBOHSjoMxiWAqB992atOeepeFYegn5RU= github.com/influxdata/line-protocol v0.0.0-20210922203350-b1ad95c89adf/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= diff --git a/vendor/github.com/go-logfmt/logfmt/README.md b/vendor/github.com/go-logfmt/logfmt/README.md index 9794502f58b..71c57944e23 100644 --- a/vendor/github.com/go-logfmt/logfmt/README.md +++ b/vendor/github.com/go-logfmt/logfmt/README.md @@ -1,41 +1,41 @@ -# logfmt - -[![Go Reference](https://pkg.go.dev/badge/github.com/go-logfmt/logfmt.svg)](https://pkg.go.dev/github.com/go-logfmt/logfmt) -[![Go Report Card](https://goreportcard.com/badge/go-logfmt/logfmt)](https://goreportcard.com/report/go-logfmt/logfmt) -[![Github Actions](https://github.com/go-logfmt/logfmt/actions/workflows/test.yml/badge.svg)](https://github.com/go-logfmt/logfmt/actions/workflows/test.yml) -[![Coverage Status](https://coveralls.io/repos/github/go-logfmt/logfmt/badge.svg?branch=master)](https://coveralls.io/github/go-logfmt/logfmt?branch=main) - -Package logfmt implements utilities to marshal and unmarshal data in the [logfmt -format][fmt]. It provides an API similar to [encoding/json][json] and -[encoding/xml][xml]. - -[fmt]: https://brandur.org/logfmt -[json]: https://pkg.go.dev/encoding/json -[xml]: https://pkg.go.dev/encoding/xml - -The logfmt format was first documented by Brandur Leach in [this -article][origin]. The format has not been formally standardized. The most -authoritative public specification to date has been the documentation of a Go -Language [package][parser] written by Blake Mizerany and Keith Rarick. - -[origin]: https://brandur.org/logfmt -[parser]: https://pkg.go.dev/github.com/kr/logfmt - -## Goals - -This project attempts to conform as closely as possible to the prior art, while -also removing ambiguity where necessary to provide well behaved encoder and -decoder implementations. - -## Non-goals - -This project does not attempt to formally standardize the logfmt format. In the -event that logfmt is standardized this project would take conforming to the -standard as a goal. - -## Versioning - -This project publishes releases according to the Go language guidelines for -[developing and publishing modules][pub]. - -[pub]: https://go.dev/doc/modules/developing +# logfmt + +[![Go Reference](https://pkg.go.dev/badge/github.com/go-logfmt/logfmt.svg)](https://pkg.go.dev/github.com/go-logfmt/logfmt) +[![Go Report Card](https://goreportcard.com/badge/go-logfmt/logfmt)](https://goreportcard.com/report/go-logfmt/logfmt) +[![Github Actions](https://github.com/go-logfmt/logfmt/actions/workflows/test.yml/badge.svg)](https://github.com/go-logfmt/logfmt/actions/workflows/test.yml) +[![Coverage Status](https://coveralls.io/repos/github/go-logfmt/logfmt/badge.svg?branch=master)](https://coveralls.io/github/go-logfmt/logfmt?branch=main) + +Package logfmt implements utilities to marshal and unmarshal data in the [logfmt +format][fmt]. It provides an API similar to [encoding/json][json] and +[encoding/xml][xml]. + +[fmt]: https://brandur.org/logfmt +[json]: https://pkg.go.dev/encoding/json +[xml]: https://pkg.go.dev/encoding/xml + +The logfmt format was first documented by Brandur Leach in [this +article][origin]. The format has not been formally standardized. The most +authoritative public specification to date has been the documentation of a Go +Language [package][parser] written by Blake Mizerany and Keith Rarick. + +[origin]: https://brandur.org/logfmt +[parser]: https://pkg.go.dev/github.com/kr/logfmt + +## Goals + +This project attempts to conform as closely as possible to the prior art, while +also removing ambiguity where necessary to provide well behaved encoder and +decoder implementations. + +## Non-goals + +This project does not attempt to formally standardize the logfmt format. In the +event that logfmt is standardized this project would take conforming to the +standard as a goal. + +## Versioning + +This project publishes releases according to the Go language guidelines for +[developing and publishing modules][pub]. + +[pub]: https://go.dev/doc/modules/developing diff --git a/vendor/github.com/influxdata/influxdb-client-go/v2/CHANGELOG.md b/vendor/github.com/influxdata/influxdb-client-go/v2/CHANGELOG.md index 23d692c2d94..f627c881cab 100644 --- a/vendor/github.com/influxdata/influxdb-client-go/v2/CHANGELOG.md +++ b/vendor/github.com/influxdata/influxdb-client-go/v2/CHANGELOG.md @@ -1,3 +1,14 @@ +## 2.14.0 [2024-08-12] + +### Features + +- [#404](https://github.com/influxdata/influxdb-client-go/pull/404) Expose HTTP response headers in the Error type to aid analysis and debugging of error results. Add selected response headers to the error log. + + Also, unified errors returned by WriteAPI, which now always returns `http.Error` + +### Fixes +- [#403](https://github.com/influxdata/influxdb-client-go/pull/403) Custom checks de/serialization to allow calling server Check API + ## 2.13.0 [2023-12-05] ### Features diff --git a/vendor/github.com/influxdata/influxdb-client-go/v2/api/http/error.go b/vendor/github.com/influxdata/influxdb-client-go/v2/api/http/error.go index 2cbcae458d0..af1a2dee84c 100644 --- a/vendor/github.com/influxdata/influxdb-client-go/v2/api/http/error.go +++ b/vendor/github.com/influxdata/influxdb-client-go/v2/api/http/error.go @@ -6,6 +6,7 @@ package http import ( "fmt" + "net/http" "strconv" ) @@ -16,6 +17,7 @@ type Error struct { Message string Err error RetryAfter uint + Header http.Header } // Error fulfils error interface @@ -37,6 +39,25 @@ func (e *Error) Unwrap() error { return nil } +// HeaderToString generates a string value from the Header property. Useful in logging. +func (e *Error) HeaderToString(selected []string) string { + headerString := "" + if len(selected) == 0 { + for key := range e.Header { + k := http.CanonicalHeaderKey(key) + headerString += fmt.Sprintf("%s: %s\r\n", k, e.Header.Get(k)) + } + } else { + for _, candidate := range selected { + c := http.CanonicalHeaderKey(candidate) + if e.Header.Get(c) != "" { + headerString += fmt.Sprintf("%s: %s\n", c, e.Header.Get(c)) + } + } + } + return headerString +} + // NewError returns newly created Error initialised with nested error and default values func NewError(err error) *Error { return &Error{ @@ -45,5 +66,6 @@ func NewError(err error) *Error { Message: "", Err: err, RetryAfter: 0, + Header: http.Header{}, } } diff --git a/vendor/github.com/influxdata/influxdb-client-go/v2/api/http/service.go b/vendor/github.com/influxdata/influxdb-client-go/v2/api/http/service.go index 7e2bc46637b..ef1b8d13882 100644 --- a/vendor/github.com/influxdata/influxdb-client-go/v2/api/http/service.go +++ b/vendor/github.com/influxdata/influxdb-client-go/v2/api/http/service.go @@ -151,6 +151,7 @@ func (s *service) parseHTTPError(r *http.Response) *Error { perror := NewError(nil) perror.StatusCode = r.StatusCode + perror.Header = r.Header if v := r.Header.Get("Retry-After"); v != "" { r, err := strconv.ParseUint(v, 10, 32) diff --git a/vendor/github.com/influxdata/influxdb-client-go/v2/domain/Readme.md b/vendor/github.com/influxdata/influxdb-client-go/v2/domain/Readme.md index 8cc8a779655..5a2f007ec8f 100644 --- a/vendor/github.com/influxdata/influxdb-client-go/v2/domain/Readme.md +++ b/vendor/github.com/influxdata/influxdb-client-go/v2/domain/Readme.md @@ -16,8 +16,8 @@ to maintain full compatibility with the latest InfluxDB release ## Generate ### Generate types -`oapi-codegen -generate types -o types.gen.go -package domain -templates .\templates oss.yml` +`oapi-codegen -generate types -exclude-tags Checks -o types.gen.go -package domain -templates .\templates oss.yml` ### Generate client -`oapi-codegen -generate client -o client.gen.go -package domain -templates .\templates oss.yml` +`oapi-codegen -generate client -exclude-tags Checks -o client.gen.go -package domain -templates .\templates oss.yml` diff --git a/vendor/github.com/influxdata/influxdb-client-go/v2/domain/checks.client.go b/vendor/github.com/influxdata/influxdb-client-go/v2/domain/checks.client.go new file mode 100644 index 00000000000..e914645a74c --- /dev/null +++ b/vendor/github.com/influxdata/influxdb-client-go/v2/domain/checks.client.go @@ -0,0 +1,762 @@ +// Package domain provides primitives to interact with the openapi HTTP API. +// +// Code generated by version DO NOT EDIT. +package domain + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "github.com/oapi-codegen/runtime" + "io" + "net/http" + "net/url" +) + +var typeToCheck = map[string]func() Check{ + "deadman": func() Check { return &DeadmanCheck{} }, + "threshold": func() Check { return &ThresholdCheck{} }, + "custom": func() Check { return &CustomCheck{} }, +} + +// UnmarshalJSON will convert +func unmarshalCheckJSON(b []byte) (Check, error) { + var raw struct { + Type string `json:"type"` + } + if err := json.Unmarshal(b, &raw); err != nil { + m := "unable to detect the check type from json" + e := &Error{ + Code: ErrorCodeInvalid, + Message: &m, + } + return nil, e.Error() + } + factoryFunc, ok := typeToCheck[raw.Type] + if !ok { + return nil, fmt.Errorf("invalid check type %s", raw.Type) + } + check := factoryFunc() + err := json.Unmarshal(b, check) + return check, err +} + +// GetChecks calls the GET on /checks +// List all checks +func (c *Client) GetChecks(ctx context.Context, params *GetChecksParams) (*Checks, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./checks") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Offset != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "offset", runtime.ParamLocationQuery, *params.Offset); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "orgID", runtime.ParamLocationQuery, params.OrgID); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params.ZapTraceSpan != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) + if err != nil { + return nil, err + } + + req.Header.Set("Zap-Trace-Span", headerParam0) + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := io.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + type raw struct { + Checks *[]json.RawMessage `json:"checks,omitempty"` + + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` + } + response := &Checks{} + + switch rsp.StatusCode { + case 200: + var a raw + if err := unmarshalJSONResponse(bodyBytes, &a); err != nil { + return nil, err + } + if a.Checks != nil && len(*a.Checks) > 0 { + c := make([]Check, len(*a.Checks)) + response.Checks = &c + for i, m := range *a.Checks { + check, err := unmarshalCheckJSON(m) + if err != nil { + return nil, err + } + (*response.Checks)[i] = check + } + } + response.Links = a.Links + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// CreateCheck calls the POST on /checks +// Add new check +func (c *Client) CreateCheck(ctx context.Context, params *CreateCheckAllParams) (Check, error) { + var err error + var bodyReader io.Reader + buf, err := json.Marshal(params.Body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./checks") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), bodyReader) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", "application/json") + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := io.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + switch rsp.StatusCode { + case 201: + check, err := unmarshalCheckJSON(bodyBytes) + if err != nil { + return nil, err + } + return check, nil + default: + return nil, decodeError(bodyBytes, rsp) + } +} + +// DeleteChecksID calls the DELETE on /checks/{checkID} +// Delete a check +func (c *Client) DeleteChecksID(ctx context.Context, params *DeleteChecksIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./checks/%s", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return err + } + + if params.ZapTraceSpan != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) + if err != nil { + return err + } + + req.Header.Set("Zap-Trace-Span", headerParam0) + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return err + } + + defer func() { _ = rsp.Body.Close() }() + + if rsp.StatusCode > 299 { + bodyBytes, err := io.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetChecksID calls the GET on /checks/{checkID} +// Retrieve a check +func (c *Client) GetChecksID(ctx context.Context, params *GetChecksIDAllParams) (Check, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./checks/%s", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params.ZapTraceSpan != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) + if err != nil { + return nil, err + } + + req.Header.Set("Zap-Trace-Span", headerParam0) + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := io.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + switch rsp.StatusCode { + case 200: + check, err := unmarshalCheckJSON(bodyBytes) + if err != nil { + return nil, err + } + return check, nil + default: + return nil, decodeError(bodyBytes, rsp) + } +} + +// PatchChecksID calls the PATCH on /checks/{checkID} +// Update a check +func (c *Client) PatchChecksID(ctx context.Context, params *PatchChecksIDAllParams) (Check, error) { + var err error + var bodyReader io.Reader + buf, err := json.Marshal(params.Body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./checks/%s", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PATCH", queryURL.String(), bodyReader) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", "application/json") + + if params.ZapTraceSpan != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) + if err != nil { + return nil, err + } + + req.Header.Set("Zap-Trace-Span", headerParam0) + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := io.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + switch rsp.StatusCode { + case 200: + check, err := unmarshalCheckJSON(bodyBytes) + if err != nil { + return nil, err + } + return check, nil + default: + return nil, decodeError(bodyBytes, rsp) + } +} + +// PutChecksID calls the PUT on /checks/{checkID} +// Update a check +func (c *Client) PutChecksID(ctx context.Context, params *PutChecksIDAllParams) (Check, error) { + var err error + var bodyReader io.Reader + buf, err := json.Marshal(params.Body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./checks/%s", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), bodyReader) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", "application/json") + + if params.ZapTraceSpan != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) + if err != nil { + return nil, err + } + + req.Header.Set("Zap-Trace-Span", headerParam0) + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := io.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + switch rsp.StatusCode { + case 200: + check, err := unmarshalCheckJSON(bodyBytes) + if err != nil { + return nil, err + } + return check, nil + default: + return nil, decodeError(bodyBytes, rsp) + } +} + +// GetChecksIDLabels calls the GET on /checks/{checkID}/labels +// List all labels for a check +func (c *Client) GetChecksIDLabels(ctx context.Context, params *GetChecksIDLabelsAllParams) (*LabelsResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./checks/%s/labels", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params.ZapTraceSpan != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) + if err != nil { + return nil, err + } + + req.Header.Set("Zap-Trace-Span", headerParam0) + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := io.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LabelsResponse{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostChecksIDLabels calls the POST on /checks/{checkID}/labels +// Add a label to a check +func (c *Client) PostChecksIDLabels(ctx context.Context, params *PostChecksIDLabelsAllParams) (*LabelResponse, error) { + var err error + var bodyReader io.Reader + buf, err := json.Marshal(params.Body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./checks/%s/labels", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), bodyReader) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", "application/json") + + if params.ZapTraceSpan != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) + if err != nil { + return nil, err + } + + req.Header.Set("Zap-Trace-Span", headerParam0) + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := io.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LabelResponse{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteChecksIDLabelsID calls the DELETE on /checks/{checkID}/labels/{labelID} +// Delete label from a check +func (c *Client) DeleteChecksIDLabelsID(ctx context.Context, params *DeleteChecksIDLabelsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "labelID", runtime.ParamLocationPath, params.LabelID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./checks/%s/labels/%s", pathParam0, pathParam1) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return err + } + + if params.ZapTraceSpan != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) + if err != nil { + return err + } + + req.Header.Set("Zap-Trace-Span", headerParam0) + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return err + } + + defer func() { _ = rsp.Body.Close() }() + + if rsp.StatusCode > 299 { + bodyBytes, err := io.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetChecksIDQuery calls the GET on /checks/{checkID}/query +// Retrieve a check query +func (c *Client) GetChecksIDQuery(ctx context.Context, params *GetChecksIDQueryAllParams) (*FluxResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./checks/%s/query", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params.ZapTraceSpan != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) + if err != nil { + return nil, err + } + + req.Header.Set("Zap-Trace-Span", headerParam0) + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := io.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FluxResponse{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} diff --git a/vendor/github.com/influxdata/influxdb-client-go/v2/domain/checks.types.go b/vendor/github.com/influxdata/influxdb-client-go/v2/domain/checks.types.go new file mode 100644 index 00000000000..2bbcd891670 --- /dev/null +++ b/vendor/github.com/influxdata/influxdb-client-go/v2/domain/checks.types.go @@ -0,0 +1,537 @@ +// Package domain provides primitives to interact with the openapi HTTP API. +// +// Code generated by version DO NOT EDIT. +package domain + +import ( + "encoding/json" + "fmt" + "time" +) + +// Defines values for CheckBaseLastRunStatus. +const ( + CheckBaseLastRunStatusCanceled CheckBaseLastRunStatus = "canceled" + + CheckBaseLastRunStatusFailed CheckBaseLastRunStatus = "failed" + + CheckBaseLastRunStatusSuccess CheckBaseLastRunStatus = "success" +) + +// Defines values for CheckPatchStatus. +const ( + CheckPatchStatusActive CheckPatchStatus = "active" + + CheckPatchStatusInactive CheckPatchStatus = "inactive" +) + +// Defines values for CheckStatusLevel. +const ( + CheckStatusLevelCRIT CheckStatusLevel = "CRIT" + + CheckStatusLevelINFO CheckStatusLevel = "INFO" + + CheckStatusLevelOK CheckStatusLevel = "OK" + + CheckStatusLevelUNKNOWN CheckStatusLevel = "UNKNOWN" + + CheckStatusLevelWARN CheckStatusLevel = "WARN" +) + +// Defines values for DeadmanCheckType. +const ( + DeadmanCheckTypeDeadman DeadmanCheckType = "deadman" +) + +// Defines values for ThresholdCheckType. +const ( + ThresholdCheckTypeThreshold ThresholdCheckType = "threshold" +) + +// Defines values for CustomCheckType. +const ( + CustomCheckTypeCustom CustomCheckType = "custom" +) + +// CheckPatch defines model for CheckPatch. +type CheckPatch struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + Status *CheckPatchStatus `json:"status,omitempty"` +} + +// CheckPatchStatus defines model for CheckPatch.Status. +type CheckPatchStatus string + +// The state to record if check matches a criteria. +type CheckStatusLevel string + +// CustomCheckType defines model for CustomCheck.Type. +type CustomCheckType string + +// DeadmanCheckType defines model for DeadmanCheck.Type. +type DeadmanCheckType string + +// ThresholdCheckType defines model for ThresholdCheck.Type. +type ThresholdCheckType string + +// CreateCheckJSONRequestBody defines body for CreateCheck for application/json ContentType. +type CreateCheckJSONRequestBody CreateCheckJSONBody + +// PatchChecksIDJSONRequestBody defines body for PatchChecksID for application/json ContentType. +type PatchChecksIDJSONRequestBody PatchChecksIDJSONBody + +// PutChecksIDJSONRequestBody defines body for PutChecksID for application/json ContentType. +type PutChecksIDJSONRequestBody PutChecksIDJSONBody + +// PostChecksIDLabelsJSONRequestBody defines body for PostChecksIDLabels for application/json ContentType. +type PostChecksIDLabelsJSONRequestBody PostChecksIDLabelsJSONBody + +// Check defines model for Check. +type Check interface { + Type() string +} + +// Checks defines model for Checks. +type Checks struct { + Checks *[]Check `json:"checks,omitempty"` + + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` +} + +// CheckBase defines model for CheckBase. +type CheckBase struct { + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // An optional description of the check. + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Labels *Labels `json:"labels,omitempty"` + LastRunError *string `json:"lastRunError,omitempty"` + LastRunStatus *CheckBaseLastRunStatus `json:"lastRunStatus,omitempty"` + + // A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp)) of the latest scheduled and completed run. + LatestCompleted *time.Time `json:"latestCompleted,omitempty"` + Links *struct { + // URI of resource. + Labels *Link `json:"labels,omitempty"` + + // URI of resource. + Members *Link `json:"members,omitempty"` + + // URI of resource. + Owners *Link `json:"owners,omitempty"` + + // URI of resource. + Query *Link `json:"query,omitempty"` + + // URI of resource. + Self *Link `json:"self,omitempty"` + } `json:"links,omitempty"` + Name string `json:"name"` + + // The ID of the organization that owns this check. + OrgID string `json:"orgID"` + + // The ID of creator used to create this check. + OwnerID *string `json:"ownerID,omitempty"` + Query DashboardQuery `json:"query"` + + // `inactive` cancels scheduled runs and prevents manual runs of the task. + Status TaskStatusType `json:"status"` + + // The ID of the task associated with this check. + TaskID *string `json:"taskID,omitempty"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` +} + +type CheckBaseExtend struct { + CheckBase + // Embedded fields due to inline allOf schema + // Check repetition interval. + Every *string `json:"every,omitempty"` + + // Duration to delay after the schedule, before executing check. + Offset *string `json:"offset,omitempty"` + + // The template used to generate and write a status message. + StatusMessageTemplate *string `json:"statusMessageTemplate,omitempty"` + + // List of tags to write to each status. + Tags *[]struct { + Key *string `json:"key,omitempty"` + Value *string `json:"value,omitempty"` + } `json:"tags,omitempty"` +} + +// DeadmanCheck defines model for DeadmanCheck. +type DeadmanCheck struct { + CheckBaseExtend + // The state to record if check matches a criteria. + Level *CheckStatusLevel `json:"level,omitempty"` + + // If only zero values reported since time, trigger an alert + ReportZero *bool `json:"reportZero,omitempty"` + + // String duration for time that a series is considered stale and should not trigger deadman. + StaleTime *string `json:"staleTime,omitempty"` + + // String duration before deadman triggers. + TimeSince *string `json:"timeSince,omitempty"` +} + +func (d DeadmanCheck) Type() string { + return string(DeadmanCheckTypeDeadman) +} + +// MarshalJSON implement json.Marshaler interface. +func (d DeadmanCheck) MarshalJSON() ([]byte, error) { + type deadmanCheckAlias DeadmanCheck + return json.Marshal( + struct { + deadmanCheckAlias + Type string `json:"type"` + }{ + deadmanCheckAlias: deadmanCheckAlias(d), + Type: d.Type(), + }) +} + +// ThresholdCheck defines model for ThresholdCheck. +type ThresholdCheck struct { + // Embedded struct due to allOf(#/components/schemas/CheckBase) + CheckBaseExtend + Thresholds *[]Threshold `json:"thresholds,omitempty"` +} + +// MarshalJSON implement json.Marshaler interface. +func (t *ThresholdCheck) MarshalJSON() ([]byte, error) { + type thresholdCheckAlias ThresholdCheck + return json.Marshal( + struct { + thresholdCheckAlias + Type string `json:"type"` + }{ + thresholdCheckAlias: thresholdCheckAlias(*t), + Type: t.Type(), + }) +} + +type thresholdCheckDecode struct { + CheckBaseExtend + Thresholds []thresholdDecode `json:"thresholds"` +} + +type thresholdDecode struct { + ThresholdBase + Type string `json:"type"` + Value float32 `json:"value"` + Min float32 `json:"min"` + Max float32 `json:"max"` + Within bool `json:"within"` +} + +// UnmarshalJSON implement json.Unmarshaler interface. +func (t *ThresholdCheck) UnmarshalJSON(b []byte) error { + var tdRaws thresholdCheckDecode + if err := json.Unmarshal(b, &tdRaws); err != nil { + return err + } + t.CheckBaseExtend = tdRaws.CheckBaseExtend + a := make([]Threshold, 0, len(tdRaws.Thresholds)) + t.Thresholds = &a + for _, tdRaw := range tdRaws.Thresholds { + switch tdRaw.Type { + case "lesser": + td := &LesserThreshold{ + ThresholdBase: tdRaw.ThresholdBase, + Value: tdRaw.Value, + } + *t.Thresholds = append(*t.Thresholds, td) + case "greater": + td := &GreaterThreshold{ + ThresholdBase: tdRaw.ThresholdBase, + Value: tdRaw.Value, + } + *t.Thresholds = append(*t.Thresholds, td) + case "range": + td := &RangeThreshold{ + ThresholdBase: tdRaw.ThresholdBase, + Min: tdRaw.Min, + Max: tdRaw.Max, + Within: tdRaw.Within, + } + *t.Thresholds = append(*t.Thresholds, td) + default: + return fmt.Errorf("invalid threshold type %s", tdRaw.Type) + } + } + return nil +} + +func (t ThresholdCheck) Type() string { + return string(ThresholdCheckTypeThreshold) +} + +// Threshold defines model for Threshold. +type Threshold interface { + Type() string +} + +// ThresholdBase defines model for ThresholdBase. +type ThresholdBase struct { + // If true, only alert if all values meet threshold. + AllValues *bool `json:"allValues,omitempty"` + + // The state to record if check matches a criteria. + Level *CheckStatusLevel `json:"level,omitempty"` +} + +// LesserThreshold defines model for LesserThreshold. +type LesserThreshold struct { + // Embedded struct due to allOf(#/components/schemas/ThresholdBase) + ThresholdBase + // Embedded fields due to inline allOf schema + Typ LesserThresholdType `json:"type"` + Value float32 `json:"value"` +} + +func (t LesserThreshold) Type() string { + return string(LesserThresholdTypeLesser) +} + +// MarshalJSON implement json.Marshaler interface. +func (t LesserThreshold) MarshalJSON() ([]byte, error) { + type lesserThresholdAlias LesserThreshold + return json.Marshal( + struct { + lesserThresholdAlias + Type string `json:"type"` + }{ + lesserThresholdAlias: lesserThresholdAlias(t), + Type: t.Type(), + }) +} + +// GreaterThreshold defines model for GreaterThreshold. +type GreaterThreshold struct { + // Embedded struct due to allOf(#/components/schemas/ThresholdBase) + ThresholdBase + // Embedded fields due to inline allOf schema + Typ GreaterThresholdType `json:"type"` + Value float32 `json:"value"` +} + +func (t GreaterThreshold) Type() string { + return string(GreaterThresholdTypeGreater) +} + +// MarshalJSON implement json.Marshaler interface. +func (t GreaterThreshold) MarshalJSON() ([]byte, error) { + type greaterThresholdAlias GreaterThreshold + return json.Marshal( + struct { + greaterThresholdAlias + Type string `json:"type"` + }{ + greaterThresholdAlias: greaterThresholdAlias(t), + Type: t.Type(), + }) +} + +// RangeThreshold defines model for RangeThreshold. +type RangeThreshold struct { + // Embedded struct due to allOf(#/components/schemas/ThresholdBase) + ThresholdBase + // Embedded fields due to inline allOf schema + Max float32 `json:"max"` + Min float32 `json:"min"` + Typ RangeThresholdType `json:"type"` + Within bool `json:"within"` +} + +func (r RangeThreshold) Type() string { + return string(RangeThresholdTypeRange) +} + +// MarshalJSON implement json.Marshaler interface. +func (r RangeThreshold) MarshalJSON() ([]byte, error) { + type rangeThresholdAlias RangeThreshold + return json.Marshal( + struct { + rangeThresholdAlias + Type string `json:"type"` + }{ + rangeThresholdAlias: rangeThresholdAlias(r), + Type: r.Type(), + }) +} + +// CustomCheck defines model for CustomCheck. +type CustomCheck struct { + // Embedded struct due to allOf(#/components/schemas/CheckBase) + CheckBase +} + +func (c CustomCheck) Type() string { + return string(CustomCheckTypeCustom) +} + +// MarshalJSON implement json.Marshaler interface. +func (c CustomCheck) MarshalJSON() ([]byte, error) { + type customCheckAlias CustomCheck + return json.Marshal( + struct { + customCheckAlias + Type string `json:"type"` + }{ + customCheckAlias: customCheckAlias(c), + Type: c.Type(), + }) +} + +// GetChecksParams defines parameters for GetChecks. +type GetChecksParams struct { + // The offset for pagination. + // The number of records to skip. + Offset *Offset `json:"offset,omitempty"` + + // Limits the number of records returned. Default is `20`. + Limit *Limit `json:"limit,omitempty"` + + // Only show checks that belong to a specific organization ID. + OrgID string `json:"orgID"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// CreateCheckJSONBody defines parameters for CreateCheck. +type CreateCheckJSONBody Check + +// CreateCheckAllParams defines type for all parameters for CreateCheck. +type CreateCheckAllParams struct { + Body CreateCheckJSONRequestBody +} + +// DeleteChecksIDParams defines parameters for DeleteChecksID. +type DeleteChecksIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteChecksIDAllParams defines type for all parameters for DeleteChecksID. +type DeleteChecksIDAllParams struct { + DeleteChecksIDParams + + CheckID string +} + +// GetChecksIDParams defines parameters for GetChecksID. +type GetChecksIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetChecksIDAllParams defines type for all parameters for GetChecksID. +type GetChecksIDAllParams struct { + GetChecksIDParams + + CheckID string +} + +// PatchChecksIDJSONBody defines parameters for PatchChecksID. +type PatchChecksIDJSONBody CheckPatch + +// PatchChecksIDParams defines parameters for PatchChecksID. +type PatchChecksIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchChecksIDAllParams defines type for all parameters for PatchChecksID. +type PatchChecksIDAllParams struct { + PatchChecksIDParams + + CheckID string + + Body PatchChecksIDJSONRequestBody +} + +// PutChecksIDJSONBody defines parameters for PutChecksID. +type PutChecksIDJSONBody Check + +// PutChecksIDParams defines parameters for PutChecksID. +type PutChecksIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PutChecksIDAllParams defines type for all parameters for PutChecksID. +type PutChecksIDAllParams struct { + PutChecksIDParams + + CheckID string + + Body PutChecksIDJSONRequestBody +} + +// GetChecksIDLabelsParams defines parameters for GetChecksIDLabels. +type GetChecksIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetChecksIDLabelsAllParams defines type for all parameters for GetChecksIDLabels. +type GetChecksIDLabelsAllParams struct { + GetChecksIDLabelsParams + + CheckID string +} + +// PostChecksIDLabelsJSONBody defines parameters for PostChecksIDLabels. +type PostChecksIDLabelsJSONBody LabelMapping + +// PostChecksIDLabelsParams defines parameters for PostChecksIDLabels. +type PostChecksIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostChecksIDLabelsAllParams defines type for all parameters for PostChecksIDLabels. +type PostChecksIDLabelsAllParams struct { + PostChecksIDLabelsParams + + CheckID string + + Body PostChecksIDLabelsJSONRequestBody +} + +// DeleteChecksIDLabelsIDParams defines parameters for DeleteChecksIDLabelsID. +type DeleteChecksIDLabelsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteChecksIDLabelsIDAllParams defines type for all parameters for DeleteChecksIDLabelsID. +type DeleteChecksIDLabelsIDAllParams struct { + DeleteChecksIDLabelsIDParams + + CheckID string + + LabelID string +} + +// GetChecksIDQueryParams defines parameters for GetChecksIDQuery. +type GetChecksIDQueryParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetChecksIDQueryAllParams defines type for all parameters for GetChecksIDQuery. +type GetChecksIDQueryAllParams struct { + GetChecksIDQueryParams + + CheckID string +} diff --git a/vendor/github.com/influxdata/influxdb-client-go/v2/domain/client.gen.go b/vendor/github.com/influxdata/influxdb-client-go/v2/domain/client.gen.go index 12e0d799ab0..9b08c79657e 100644 --- a/vendor/github.com/influxdata/influxdb-client-go/v2/domain/client.gen.go +++ b/vendor/github.com/influxdata/influxdb-client-go/v2/domain/client.gen.go @@ -1558,714 +1558,6 @@ func (c *Client) DeleteBucketsIDOwnersID(ctx context.Context, params *DeleteBuck } -// GetChecks calls the GET on /checks -// List all checks -func (c *Client) GetChecks(ctx context.Context, params *GetChecksParams) (*Checks, error) { - var err error - - serverURL, err := url.Parse(c.APIEndpoint) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("./checks") - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - queryValues := queryURL.Query() - - if params.Offset != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "offset", runtime.ParamLocationQuery, *params.Offset); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Limit != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "orgID", runtime.ParamLocationQuery, params.OrgID); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - queryURL.RawQuery = queryValues.Encode() - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params.ZapTraceSpan != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) - if err != nil { - return nil, err - } - - req.Header.Set("Zap-Trace-Span", headerParam0) - } - - req = req.WithContext(ctx) - rsp, err := c.Client.Do(req) - if err != nil { - return nil, err - } - bodyBytes, err := io.ReadAll(rsp.Body) - - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &Checks{} - - switch rsp.StatusCode { - case 200: - if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { - return nil, err - } - default: - return nil, decodeError(bodyBytes, rsp) - } - return response, nil - -} - -// CreateCheck calls the POST on /checks -// Add new check -func (c *Client) CreateCheck(ctx context.Context, params *CreateCheckAllParams) (*Check, error) { - var err error - var bodyReader io.Reader - buf, err := json.Marshal(params.Body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - - serverURL, err := url.Parse(c.APIEndpoint) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("./checks") - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), bodyReader) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", "application/json") - - req = req.WithContext(ctx) - rsp, err := c.Client.Do(req) - if err != nil { - return nil, err - } - bodyBytes, err := io.ReadAll(rsp.Body) - - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &Check{} - - switch rsp.StatusCode { - case 201: - if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { - return nil, err - } - default: - return nil, decodeError(bodyBytes, rsp) - } - return response, nil - -} - -// DeleteChecksID calls the DELETE on /checks/{checkID} -// Delete a check -func (c *Client) DeleteChecksID(ctx context.Context, params *DeleteChecksIDAllParams) error { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) - if err != nil { - return err - } - - serverURL, err := url.Parse(c.APIEndpoint) - if err != nil { - return err - } - - operationPath := fmt.Sprintf("./checks/%s", pathParam0) - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return err - } - - if params.ZapTraceSpan != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) - if err != nil { - return err - } - - req.Header.Set("Zap-Trace-Span", headerParam0) - } - - req = req.WithContext(ctx) - rsp, err := c.Client.Do(req) - if err != nil { - return err - } - - defer func() { _ = rsp.Body.Close() }() - - if rsp.StatusCode > 299 { - bodyBytes, err := io.ReadAll(rsp.Body) - if err != nil { - return err - } - return decodeError(bodyBytes, rsp) - } - return nil - -} - -// GetChecksID calls the GET on /checks/{checkID} -// Retrieve a check -func (c *Client) GetChecksID(ctx context.Context, params *GetChecksIDAllParams) (*Check, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(c.APIEndpoint) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("./checks/%s", pathParam0) - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params.ZapTraceSpan != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) - if err != nil { - return nil, err - } - - req.Header.Set("Zap-Trace-Span", headerParam0) - } - - req = req.WithContext(ctx) - rsp, err := c.Client.Do(req) - if err != nil { - return nil, err - } - bodyBytes, err := io.ReadAll(rsp.Body) - - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &Check{} - - switch rsp.StatusCode { - case 200: - if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { - return nil, err - } - default: - return nil, decodeError(bodyBytes, rsp) - } - return response, nil - -} - -// PatchChecksID calls the PATCH on /checks/{checkID} -// Update a check -func (c *Client) PatchChecksID(ctx context.Context, params *PatchChecksIDAllParams) (*Check, error) { - var err error - var bodyReader io.Reader - buf, err := json.Marshal(params.Body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(c.APIEndpoint) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("./checks/%s", pathParam0) - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PATCH", queryURL.String(), bodyReader) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", "application/json") - - if params.ZapTraceSpan != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) - if err != nil { - return nil, err - } - - req.Header.Set("Zap-Trace-Span", headerParam0) - } - - req = req.WithContext(ctx) - rsp, err := c.Client.Do(req) - if err != nil { - return nil, err - } - bodyBytes, err := io.ReadAll(rsp.Body) - - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &Check{} - - switch rsp.StatusCode { - case 200: - if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { - return nil, err - } - default: - return nil, decodeError(bodyBytes, rsp) - } - return response, nil - -} - -// PutChecksID calls the PUT on /checks/{checkID} -// Update a check -func (c *Client) PutChecksID(ctx context.Context, params *PutChecksIDAllParams) (*Check, error) { - var err error - var bodyReader io.Reader - buf, err := json.Marshal(params.Body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(c.APIEndpoint) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("./checks/%s", pathParam0) - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("PUT", queryURL.String(), bodyReader) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", "application/json") - - if params.ZapTraceSpan != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) - if err != nil { - return nil, err - } - - req.Header.Set("Zap-Trace-Span", headerParam0) - } - - req = req.WithContext(ctx) - rsp, err := c.Client.Do(req) - if err != nil { - return nil, err - } - bodyBytes, err := io.ReadAll(rsp.Body) - - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &Check{} - - switch rsp.StatusCode { - case 200: - if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { - return nil, err - } - default: - return nil, decodeError(bodyBytes, rsp) - } - return response, nil - -} - -// GetChecksIDLabels calls the GET on /checks/{checkID}/labels -// List all labels for a check -func (c *Client) GetChecksIDLabels(ctx context.Context, params *GetChecksIDLabelsAllParams) (*LabelsResponse, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(c.APIEndpoint) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("./checks/%s/labels", pathParam0) - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params.ZapTraceSpan != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) - if err != nil { - return nil, err - } - - req.Header.Set("Zap-Trace-Span", headerParam0) - } - - req = req.WithContext(ctx) - rsp, err := c.Client.Do(req) - if err != nil { - return nil, err - } - bodyBytes, err := io.ReadAll(rsp.Body) - - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &LabelsResponse{} - - switch rsp.StatusCode { - case 200: - if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { - return nil, err - } - default: - return nil, decodeError(bodyBytes, rsp) - } - return response, nil - -} - -// PostChecksIDLabels calls the POST on /checks/{checkID}/labels -// Add a label to a check -func (c *Client) PostChecksIDLabels(ctx context.Context, params *PostChecksIDLabelsAllParams) (*LabelResponse, error) { - var err error - var bodyReader io.Reader - buf, err := json.Marshal(params.Body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(c.APIEndpoint) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("./checks/%s/labels", pathParam0) - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), bodyReader) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", "application/json") - - if params.ZapTraceSpan != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) - if err != nil { - return nil, err - } - - req.Header.Set("Zap-Trace-Span", headerParam0) - } - - req = req.WithContext(ctx) - rsp, err := c.Client.Do(req) - if err != nil { - return nil, err - } - bodyBytes, err := io.ReadAll(rsp.Body) - - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &LabelResponse{} - - switch rsp.StatusCode { - case 201: - if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { - return nil, err - } - default: - return nil, decodeError(bodyBytes, rsp) - } - return response, nil - -} - -// DeleteChecksIDLabelsID calls the DELETE on /checks/{checkID}/labels/{labelID} -// Delete label from a check -func (c *Client) DeleteChecksIDLabelsID(ctx context.Context, params *DeleteChecksIDLabelsIDAllParams) error { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) - if err != nil { - return err - } - - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "labelID", runtime.ParamLocationPath, params.LabelID) - if err != nil { - return err - } - - serverURL, err := url.Parse(c.APIEndpoint) - if err != nil { - return err - } - - operationPath := fmt.Sprintf("./checks/%s/labels/%s", pathParam0, pathParam1) - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return err - } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { - return err - } - - if params.ZapTraceSpan != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) - if err != nil { - return err - } - - req.Header.Set("Zap-Trace-Span", headerParam0) - } - - req = req.WithContext(ctx) - rsp, err := c.Client.Do(req) - if err != nil { - return err - } - - defer func() { _ = rsp.Body.Close() }() - - if rsp.StatusCode > 299 { - bodyBytes, err := io.ReadAll(rsp.Body) - if err != nil { - return err - } - return decodeError(bodyBytes, rsp) - } - return nil - -} - -// GetChecksIDQuery calls the GET on /checks/{checkID}/query -// Retrieve a check query -func (c *Client) GetChecksIDQuery(ctx context.Context, params *GetChecksIDQueryAllParams) (*FluxResponse, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "checkID", runtime.ParamLocationPath, params.CheckID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(c.APIEndpoint) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("./checks/%s/query", pathParam0) - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - if params.ZapTraceSpan != nil { - var headerParam0 string - - headerParam0, err = runtime.StyleParamWithLocation("simple", false, "Zap-Trace-Span", runtime.ParamLocationHeader, *params.ZapTraceSpan) - if err != nil { - return nil, err - } - - req.Header.Set("Zap-Trace-Span", headerParam0) - } - - req = req.WithContext(ctx) - rsp, err := c.Client.Do(req) - if err != nil { - return nil, err - } - bodyBytes, err := io.ReadAll(rsp.Body) - - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &FluxResponse{} - - switch rsp.StatusCode { - case 200: - if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { - return nil, err - } - default: - return nil, decodeError(bodyBytes, rsp) - } - return response, nil - -} - // GetConfig calls the GET on /config // Retrieve runtime configuration func (c *Client) GetConfig(ctx context.Context, params *GetConfigParams) (*Config, error) { diff --git a/vendor/github.com/influxdata/influxdb-client-go/v2/domain/types.gen.go b/vendor/github.com/influxdata/influxdb-client-go/v2/domain/types.gen.go index d8b1ca3b7fc..0a8928cf458 100644 --- a/vendor/github.com/influxdata/influxdb-client-go/v2/domain/types.gen.go +++ b/vendor/github.com/influxdata/influxdb-client-go/v2/domain/types.gen.go @@ -72,35 +72,6 @@ const ( BuilderAggregateFunctionTypeGroup BuilderAggregateFunctionType = "group" ) -// Defines values for CheckBaseLastRunStatus. -const ( - CheckBaseLastRunStatusCanceled CheckBaseLastRunStatus = "canceled" - - CheckBaseLastRunStatusFailed CheckBaseLastRunStatus = "failed" - - CheckBaseLastRunStatusSuccess CheckBaseLastRunStatus = "success" -) - -// Defines values for CheckPatchStatus. -const ( - CheckPatchStatusActive CheckPatchStatus = "active" - - CheckPatchStatusInactive CheckPatchStatus = "inactive" -) - -// Defines values for CheckStatusLevel. -const ( - CheckStatusLevelCRIT CheckStatusLevel = "CRIT" - - CheckStatusLevelINFO CheckStatusLevel = "INFO" - - CheckStatusLevelOK CheckStatusLevel = "OK" - - CheckStatusLevelUNKNOWN CheckStatusLevel = "UNKNOWN" - - CheckStatusLevelWARN CheckStatusLevel = "WARN" -) - // Defines values for CheckViewPropertiesShape. const ( CheckViewPropertiesShapeChronografV2 CheckViewPropertiesShape = "chronograf-v2" @@ -116,11 +87,6 @@ const ( ConstantVariablePropertiesTypeConstant ConstantVariablePropertiesType = "constant" ) -// Defines values for CustomCheckType. -const ( - CustomCheckTypeCustom CustomCheckType = "custom" -) - // Defines values for DashboardColorType. const ( DashboardColorTypeBackground DashboardColorType = "background" @@ -136,11 +102,6 @@ const ( DashboardColorTypeThreshold DashboardColorType = "threshold" ) -// Defines values for DeadmanCheckType. -const ( - DeadmanCheckTypeDeadman DeadmanCheckType = "deadman" -) - // Defines values for DialectAnnotations. const ( DialectAnnotationsDatatype DialectAnnotations = "datatype" @@ -726,11 +687,6 @@ const ( TemplateKindVariable TemplateKind = "Variable" ) -// Defines values for ThresholdCheckType. -const ( - ThresholdCheckTypeThreshold ThresholdCheckType = "threshold" -) - // Defines values for UserStatus. const ( UserStatusActive UserStatus = "active" @@ -1194,77 +1150,9 @@ type Cells []Cell // CellsWithViewProperties defines model for CellsWithViewProperties. type CellsWithViewProperties []CellWithViewProperties -// Check defines model for Check. -type Check struct { - // Embedded struct due to allOf(#/components/schemas/CheckDiscriminator) - CheckDiscriminator `yaml:",inline"` -} - -// CheckBase defines model for CheckBase. -type CheckBase struct { - CreatedAt *time.Time `json:"createdAt,omitempty"` - - // An optional description of the check. - Description *string `json:"description,omitempty"` - Id *string `json:"id,omitempty"` - Labels *Labels `json:"labels,omitempty"` - LastRunError *string `json:"lastRunError,omitempty"` - LastRunStatus *CheckBaseLastRunStatus `json:"lastRunStatus,omitempty"` - - // A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp)) of the latest scheduled and completed run. - LatestCompleted *time.Time `json:"latestCompleted,omitempty"` - Links *struct { - // URI of resource. - Labels *Link `json:"labels,omitempty"` - - // URI of resource. - Members *Link `json:"members,omitempty"` - - // URI of resource. - Owners *Link `json:"owners,omitempty"` - - // URI of resource. - Query *Link `json:"query,omitempty"` - - // URI of resource. - Self *Link `json:"self,omitempty"` - } `json:"links,omitempty"` - Name string `json:"name"` - - // The ID of the organization that owns this check. - OrgID string `json:"orgID"` - - // The ID of creator used to create this check. - OwnerID *string `json:"ownerID,omitempty"` - Query DashboardQuery `json:"query"` - - // `inactive` cancels scheduled runs and prevents manual runs of the task. - Status *TaskStatusType `json:"status,omitempty"` - - // The ID of the task associated with this check. - TaskID *string `json:"taskID,omitempty"` - UpdatedAt *time.Time `json:"updatedAt,omitempty"` -} - // CheckBaseLastRunStatus defines model for CheckBase.LastRunStatus. type CheckBaseLastRunStatus string -// CheckDiscriminator defines model for CheckDiscriminator. -type CheckDiscriminator interface{} - -// CheckPatch defines model for CheckPatch. -type CheckPatch struct { - Description *string `json:"description,omitempty"` - Name *string `json:"name,omitempty"` - Status *CheckPatchStatus `json:"status,omitempty"` -} - -// CheckPatchStatus defines model for CheckPatch.Status. -type CheckPatchStatus string - -// The state to record if check matches a criteria. -type CheckStatusLevel string - // CheckViewProperties defines model for CheckViewProperties. type CheckViewProperties struct { AdaptiveZoomHide *bool `json:"adaptiveZoomHide,omitempty"` @@ -1288,14 +1176,6 @@ type CheckViewPropertiesShape string // CheckViewPropertiesType defines model for CheckViewProperties.Type. type CheckViewPropertiesType string -// Checks defines model for Checks. -type Checks struct { - Checks *[]Check `json:"checks,omitempty"` - - // URI pointers for additional paged results. - Links *Links `json:"links,omitempty"` -} - // A color mapping is an object that maps time series data to a UI color scheme to allow the UI to render graphs consistent colors across reloads. type ColorMapping struct { AdditionalProperties map[string]string `json:"-"` @@ -1349,17 +1229,6 @@ type CreateDashboardRequest struct { OrgID string `json:"orgID"` } -// CustomCheck defines model for CustomCheck. -type CustomCheck struct { - // Embedded struct due to allOf(#/components/schemas/CheckBase) - CheckBase `yaml:",inline"` - // Embedded fields due to inline allOf schema - Type CustomCheckType `json:"type"` -} - -// CustomCheckType defines model for CustomCheck.Type. -type CustomCheckType string - // DBRP defines model for DBRP. type DBRP struct { // The ID of the bucket used as the target for the translation. @@ -1538,43 +1407,6 @@ type DateTimeLiteral struct { Value *time.Time `json:"value,omitempty"` } -// DeadmanCheck defines model for DeadmanCheck. -type DeadmanCheck struct { - // Embedded struct due to allOf(#/components/schemas/CheckBase) - CheckBase `yaml:",inline"` - // Embedded fields due to inline allOf schema - // Check repetition interval. - Every *string `json:"every,omitempty"` - - // The state to record if check matches a criteria. - Level *CheckStatusLevel `json:"level,omitempty"` - - // Duration to delay after the schedule, before executing check. - Offset *string `json:"offset,omitempty"` - - // If only zero values reported since time, trigger an alert - ReportZero *bool `json:"reportZero,omitempty"` - - // String duration for time that a series is considered stale and should not trigger deadman. - StaleTime *string `json:"staleTime,omitempty"` - - // The template used to generate and write a status message. - StatusMessageTemplate *string `json:"statusMessageTemplate,omitempty"` - - // List of tags to write to each status. - Tags *[]struct { - Key *string `json:"key,omitempty"` - Value *string `json:"value,omitempty"` - } `json:"tags,omitempty"` - - // String duration before deadman triggers. - TimeSince *string `json:"timeSince,omitempty"` - Type DeadmanCheckType `json:"type"` -} - -// DeadmanCheckType defines model for DeadmanCheck.Type. -type DeadmanCheckType string - // Indicates whether decimal places should be enforced, and how many digits it should show. type DecimalPlaces struct { // The number of digits after decimal to display @@ -1962,15 +1794,6 @@ type GeoViewPropertiesShape string // GeoViewPropertiesType defines model for GeoViewProperties.Type. type GeoViewPropertiesType string -// GreaterThreshold defines model for GreaterThreshold. -type GreaterThreshold struct { - // Embedded struct due to allOf(#/components/schemas/ThresholdBase) - ThresholdBase `yaml:",inline"` - // Embedded fields due to inline allOf schema - Type GreaterThresholdType `json:"type"` - Value float32 `json:"value"` -} - // GreaterThresholdType defines model for GreaterThreshold.Type. type GreaterThresholdType string @@ -2249,15 +2072,6 @@ type LatLonColumns struct { Lon LatLonColumn `json:"lon"` } -// LesserThreshold defines model for LesserThreshold. -type LesserThreshold struct { - // Embedded struct due to allOf(#/components/schemas/ThresholdBase) - ThresholdBase `yaml:",inline"` - // Embedded fields due to inline allOf schema - Type LesserThresholdType `json:"type"` - Value float32 `json:"value"` -} - // LesserThresholdType defines model for LesserThreshold.Type. type LesserThresholdType string @@ -2916,12 +2730,6 @@ type PostBucketRequest struct { SchemaType *SchemaType `json:"schemaType,omitempty"` } -// PostCheck defines model for PostCheck. -type PostCheck struct { - // Embedded struct due to allOf(#/components/schemas/CheckDiscriminator) - CheckDiscriminator `yaml:",inline"` -} - // PostNotificationEndpoint defines model for PostNotificationEndpoint. type PostNotificationEndpoint struct { // Embedded struct due to allOf(#/components/schemas/NotificationEndpointDiscriminator) @@ -3007,16 +2815,20 @@ type QueryType string // To use parameters in your query, pass a _`query`_ with `params` references (in dot notation)--for example: // // ```json -// query: "from(bucket: params.mybucket) |> range(start: params.rangeStart) |> limit(n:1)" +// +// query: "from(bucket: params.mybucket) |> range(start: params.rangeStart) |> limit(n:1)" +// // ``` // // and pass _`params`_ with the key-value pairs--for example: // // ```json -// params: { -// "mybucket": "environment", -// "rangeStart": "-30d" -// } +// +// params: { +// "mybucket": "environment", +// "rangeStart": "-30d" +// } +// // ``` // // During query execution, InfluxDB passes _`params`_ to your script and substitutes the values. @@ -3043,17 +2855,6 @@ type QueryVariableProperties struct { // QueryVariablePropertiesType defines model for QueryVariableProperties.Type. type QueryVariablePropertiesType string -// RangeThreshold defines model for RangeThreshold. -type RangeThreshold struct { - // Embedded struct due to allOf(#/components/schemas/ThresholdBase) - ThresholdBase `yaml:",inline"` - // Embedded fields due to inline allOf schema - Max float32 `json:"max"` - Min float32 `json:"min"` - Type RangeThresholdType `json:"type"` - Within bool `json:"within"` -} - // RangeThresholdType defines model for RangeThreshold.Type. type RangeThresholdType string @@ -4242,33 +4043,33 @@ type TemplateApply_EnvRefs struct { // the following Flux script retrieves `POSTGRES_USERNAME` and `POSTGRES_PASSWORD` // secrets and then uses them to connect to a PostgreSQL database: // -// ```js -// import "sql" -// import "influxdata/influxdb/secrets" +// ```js +// import "sql" +// import "influxdata/influxdb/secrets" // -// username = secrets.get(key: "POSTGRES_USERNAME") -// password = secrets.get(key: "POSTGRES_PASSWORD") +// username = secrets.get(key: "POSTGRES_USERNAME") +// password = secrets.get(key: "POSTGRES_PASSWORD") // -// sql.from( -// driverName: "postgres", -// dataSourceName: "postgresql://${username}:${password}@localhost:5432", -// query: "SELECT * FROM example_table", -// ) -// ``` +// sql.from( +// driverName: "postgres", +// dataSourceName: "postgresql://${username}:${password}@localhost:5432", +// query: "SELECT * FROM example_table", +// ) +// ``` // // To define secret values in your `/api/v2/templates/apply` request, // pass the `secrets` parameter with key-value pairs--for example: // -// ```json -// { -// ... -// "secrets": { -// "POSTGRES_USERNAME": "pguser", -// "POSTGRES_PASSWORD": "foo" -// } -// ... -// } -// ``` +// ```json +// { +// ... +// "secrets": { +// "POSTGRES_USERNAME": "pguser", +// "POSTGRES_PASSWORD": "foo" +// } +// ... +// } +// ``` // // InfluxDB stores the key-value pairs as secrets that you can access with `secrets.get()`. // Once stored, you can't view secret values in InfluxDB. @@ -4380,12 +4181,12 @@ type TemplateSummary struct { TemplateMetaName *string `json:"templateMetaName,omitempty"` } `json:"buckets,omitempty"` Checks *[]struct { - Id *string `json:"id,omitempty"` - Kind *TemplateKind `json:"kind,omitempty"` - New *CheckDiscriminator `json:"new,omitempty"` - Old *CheckDiscriminator `json:"old,omitempty"` - StateStatus *string `json:"stateStatus,omitempty"` - TemplateMetaName *string `json:"templateMetaName,omitempty"` + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + New *Check `json:"new,omitempty"` + Old *Check `json:"old,omitempty"` + StateStatus *string `json:"stateStatus,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` } `json:"checks,omitempty"` Dashboards *[]struct { Id *string `json:"id,omitempty"` @@ -4554,7 +4355,7 @@ type TemplateSummary struct { } `json:"buckets,omitempty"` Checks *[]struct { // Embedded struct due to allOf(#/components/schemas/CheckDiscriminator) - CheckDiscriminator `yaml:",inline"` + Check // Embedded fields due to inline allOf schema EnvReferences *TemplateEnvReferences `json:"envReferences,omitempty"` Kind *TemplateKind `json:"kind,omitempty"` @@ -4677,44 +4478,6 @@ type TestStatement struct { Type *NodeType `json:"type,omitempty"` } -// Threshold defines model for Threshold. -type Threshold interface{} - -// ThresholdBase defines model for ThresholdBase. -type ThresholdBase struct { - // If true, only alert if all values meet threshold. - AllValues *bool `json:"allValues,omitempty"` - - // The state to record if check matches a criteria. - Level *CheckStatusLevel `json:"level,omitempty"` -} - -// ThresholdCheck defines model for ThresholdCheck. -type ThresholdCheck struct { - // Embedded struct due to allOf(#/components/schemas/CheckBase) - CheckBase `yaml:",inline"` - // Embedded fields due to inline allOf schema - // Check repetition interval. - Every *string `json:"every,omitempty"` - - // Duration to delay after the schedule, before executing check. - Offset *string `json:"offset,omitempty"` - - // The template used to generate and write a status message. - StatusMessageTemplate *string `json:"statusMessageTemplate,omitempty"` - - // List of tags to write to each status. - Tags *[]struct { - Key *string `json:"key,omitempty"` - Value *string `json:"value,omitempty"` - } `json:"tags,omitempty"` - Thresholds *[]Threshold `json:"thresholds,omitempty"` - Type ThresholdCheckType `json:"type"` -} - -// ThresholdCheckType defines model for ThresholdCheck.Type. -type ThresholdCheckType string - // Uses operators to act on a single operand in an expression type UnaryExpression struct { Argument *Expression `json:"argument,omitempty"` @@ -5250,151 +5013,6 @@ type DeleteBucketsIDOwnersIDAllParams struct { UserID string } -// GetChecksParams defines parameters for GetChecks. -type GetChecksParams struct { - // The offset for pagination. - // The number of records to skip. - Offset *Offset `json:"offset,omitempty"` - - // Limits the number of records returned. Default is `20`. - Limit *Limit `json:"limit,omitempty"` - - // Only show checks that belong to a specific organization ID. - OrgID string `json:"orgID"` - - // OpenTracing span context - ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` -} - -// CreateCheckJSONBody defines parameters for CreateCheck. -type CreateCheckJSONBody PostCheck - -// CreateCheckAllParams defines type for all parameters for CreateCheck. -type CreateCheckAllParams struct { - Body CreateCheckJSONRequestBody -} - -// DeleteChecksIDParams defines parameters for DeleteChecksID. -type DeleteChecksIDParams struct { - // OpenTracing span context - ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` -} - -// DeleteChecksIDAllParams defines type for all parameters for DeleteChecksID. -type DeleteChecksIDAllParams struct { - DeleteChecksIDParams - - CheckID string -} - -// GetChecksIDParams defines parameters for GetChecksID. -type GetChecksIDParams struct { - // OpenTracing span context - ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` -} - -// GetChecksIDAllParams defines type for all parameters for GetChecksID. -type GetChecksIDAllParams struct { - GetChecksIDParams - - CheckID string -} - -// PatchChecksIDJSONBody defines parameters for PatchChecksID. -type PatchChecksIDJSONBody CheckPatch - -// PatchChecksIDParams defines parameters for PatchChecksID. -type PatchChecksIDParams struct { - // OpenTracing span context - ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` -} - -// PatchChecksIDAllParams defines type for all parameters for PatchChecksID. -type PatchChecksIDAllParams struct { - PatchChecksIDParams - - CheckID string - - Body PatchChecksIDJSONRequestBody -} - -// PutChecksIDJSONBody defines parameters for PutChecksID. -type PutChecksIDJSONBody Check - -// PutChecksIDParams defines parameters for PutChecksID. -type PutChecksIDParams struct { - // OpenTracing span context - ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` -} - -// PutChecksIDAllParams defines type for all parameters for PutChecksID. -type PutChecksIDAllParams struct { - PutChecksIDParams - - CheckID string - - Body PutChecksIDJSONRequestBody -} - -// GetChecksIDLabelsParams defines parameters for GetChecksIDLabels. -type GetChecksIDLabelsParams struct { - // OpenTracing span context - ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` -} - -// GetChecksIDLabelsAllParams defines type for all parameters for GetChecksIDLabels. -type GetChecksIDLabelsAllParams struct { - GetChecksIDLabelsParams - - CheckID string -} - -// PostChecksIDLabelsJSONBody defines parameters for PostChecksIDLabels. -type PostChecksIDLabelsJSONBody LabelMapping - -// PostChecksIDLabelsParams defines parameters for PostChecksIDLabels. -type PostChecksIDLabelsParams struct { - // OpenTracing span context - ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` -} - -// PostChecksIDLabelsAllParams defines type for all parameters for PostChecksIDLabels. -type PostChecksIDLabelsAllParams struct { - PostChecksIDLabelsParams - - CheckID string - - Body PostChecksIDLabelsJSONRequestBody -} - -// DeleteChecksIDLabelsIDParams defines parameters for DeleteChecksIDLabelsID. -type DeleteChecksIDLabelsIDParams struct { - // OpenTracing span context - ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` -} - -// DeleteChecksIDLabelsIDAllParams defines type for all parameters for DeleteChecksIDLabelsID. -type DeleteChecksIDLabelsIDAllParams struct { - DeleteChecksIDLabelsIDParams - - CheckID string - - LabelID string -} - -// GetChecksIDQueryParams defines parameters for GetChecksIDQuery. -type GetChecksIDQueryParams struct { - // OpenTracing span context - ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` -} - -// GetChecksIDQueryAllParams defines type for all parameters for GetChecksIDQuery. -type GetChecksIDQueryAllParams struct { - GetChecksIDQueryParams - - CheckID string -} - // GetConfigParams defines parameters for GetConfig. type GetConfigParams struct { // OpenTracing span context @@ -8016,18 +7634,6 @@ type PostBucketsIDMembersJSONRequestBody PostBucketsIDMembersJSONBody // PostBucketsIDOwnersJSONRequestBody defines body for PostBucketsIDOwners for application/json ContentType. type PostBucketsIDOwnersJSONRequestBody PostBucketsIDOwnersJSONBody -// CreateCheckJSONRequestBody defines body for CreateCheck for application/json ContentType. -type CreateCheckJSONRequestBody CreateCheckJSONBody - -// PatchChecksIDJSONRequestBody defines body for PatchChecksID for application/json ContentType. -type PatchChecksIDJSONRequestBody PatchChecksIDJSONBody - -// PutChecksIDJSONRequestBody defines body for PutChecksID for application/json ContentType. -type PutChecksIDJSONRequestBody PutChecksIDJSONBody - -// PostChecksIDLabelsJSONRequestBody defines body for PostChecksIDLabels for application/json ContentType. -type PostChecksIDLabelsJSONRequestBody PostChecksIDLabelsJSONBody - // PatchDashboardsIDJSONRequestBody defines body for PatchDashboardsID for application/json ContentType. type PatchDashboardsIDJSONRequestBody PatchDashboardsIDJSONBody diff --git a/vendor/github.com/influxdata/influxdb-client-go/v2/internal/write/service.go b/vendor/github.com/influxdata/influxdb-client-go/v2/internal/write/service.go index e47acf5726c..44ddf1c17d0 100644 --- a/vendor/github.com/influxdata/influxdb-client-go/v2/internal/write/service.go +++ b/vendor/github.com/influxdata/influxdb-client-go/v2/internal/write/service.go @@ -196,9 +196,24 @@ func (w *Service) HandleWrite(ctx context.Context, batch *Batch) error { w.retryAttempts++ log.Debugf("Write proc: next wait for write is %dms\n", w.retryDelay) } else { - log.Errorf("Write error: %s\n", perror.Error()) + logMessage := fmt.Sprintf("Write error: %s", perror.Error()) + logHeaders := perror.HeaderToString([]string{ + "date", + "trace-id", + "trace-sampled", + "X-Influxdb-Build", + "X-Influxdb-Request-ID", + "X-Influxdb-Version", + }) + if len(logHeaders) > 0 { + logMessage += fmt.Sprintf("\nSelected Response Headers:\n%s", logHeaders) + } + log.Error(logMessage) } - return fmt.Errorf("write failed (attempts %d): %w", batchToWrite.RetryAttempts, perror) + log.Errorf("Write failed (retry attempts %d): Status Code %d", + batchToWrite.RetryAttempts, + perror.StatusCode) + return perror } } diff --git a/vendor/github.com/influxdata/influxdb-client-go/v2/version.go b/vendor/github.com/influxdata/influxdb-client-go/v2/version.go index 7f50977e48c..7549a8a3510 100644 --- a/vendor/github.com/influxdata/influxdb-client-go/v2/version.go +++ b/vendor/github.com/influxdata/influxdb-client-go/v2/version.go @@ -13,7 +13,7 @@ import ( const ( // Version defines current version - Version = "2.13.0" + Version = "2.14.0" ) func init() { diff --git a/vendor/modules.txt b/vendor/modules.txt index af45eca4758..d7a72d5085a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -906,7 +906,7 @@ github.com/imdario/mergo # github.com/inconshreveable/mousetrap v1.1.0 ## explicit; go 1.18 github.com/inconshreveable/mousetrap -# github.com/influxdata/influxdb-client-go/v2 v2.13.0 +# github.com/influxdata/influxdb-client-go/v2 v2.14.0 ## explicit; go 1.17 github.com/influxdata/influxdb-client-go/v2 github.com/influxdata/influxdb-client-go/v2/api