From e2ebb418bf722397cc21a4e68232ecec738c5a2c Mon Sep 17 00:00:00 2001 From: Ales Pour Date: Thu, 29 Dec 2022 10:43:08 +0100 Subject: [PATCH 1/2] feat: implement mgmt API * feat: extend Filter, Params and Client * chore: run E2E test in CI --- .circleci/config.yml | 41 +- go.mod | 16 +- go.sum | 171 +- influxclient/authorizations.go | 118 + influxclient/authorizations_e2e_test.go | 206 + influxclient/buckets.go | 153 + influxclient/buckets_e2e_test.go | 399 + influxclient/client.go | 91 +- influxclient/client_query.go | 3 +- influxclient/client_test.go | 2 +- influxclient/e2e_test.go | 67 + influxclient/examples_test.go | 122 +- influxclient/filter.go | 58 + influxclient/labels.go | 126 + influxclient/labels_e2e_test.go | 161 + influxclient/model/Readme.md | 23 + influxclient/model/client.gen.go | 14852 +++++++++++++ influxclient/model/oss.yml | 17582 ++++++++++++++++ .../templates/client-with-responses.tmpl | 192 + influxclient/model/templates/client.tmpl | 89 + influxclient/model/templates/imports.tmpl | 33 + influxclient/model/templates/param-types.tmpl | 22 + .../model/templates/request-bodies.tmpl | 10 + influxclient/model/types.gen.go | 8860 ++++++++ influxclient/organization_test.go | 108 + influxclient/organizations.go | 224 + influxclient/organizations_e2e_test.go | 395 + influxclient/query_test.go | 2 +- influxclient/tasks.go | 466 + influxclient/tasks_e2e_test.go | 818 + influxclient/users.go | 201 + influxclient/users_e2e_test.go | 162 + scripts/influxdb-onboarding.sh | 39 + 33 files changed, 45744 insertions(+), 68 deletions(-) create mode 100644 influxclient/authorizations.go create mode 100644 influxclient/authorizations_e2e_test.go create mode 100644 influxclient/buckets.go create mode 100644 influxclient/buckets_e2e_test.go create mode 100644 influxclient/e2e_test.go create mode 100644 influxclient/filter.go create mode 100644 influxclient/labels.go create mode 100644 influxclient/labels_e2e_test.go create mode 100644 influxclient/model/Readme.md create mode 100644 influxclient/model/client.gen.go create mode 100644 influxclient/model/oss.yml create mode 100644 influxclient/model/templates/client-with-responses.tmpl create mode 100755 influxclient/model/templates/client.tmpl create mode 100755 influxclient/model/templates/imports.tmpl create mode 100755 influxclient/model/templates/param-types.tmpl create mode 100755 influxclient/model/templates/request-bodies.tmpl create mode 100644 influxclient/model/types.gen.go create mode 100644 influxclient/organization_test.go create mode 100644 influxclient/organizations.go create mode 100644 influxclient/organizations_e2e_test.go create mode 100644 influxclient/tasks.go create mode 100644 influxclient/tasks_e2e_test.go create mode 100644 influxclient/users.go create mode 100644 influxclient/users_e2e_test.go create mode 100755 scripts/influxdb-onboarding.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index e0cc072f..76327830 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,13 @@ # Golang CircleCI 2.0 configuration file # # Check https://circleci.com/docs/2.0/language-go/ for more details -version: 2 +version: 2.1 +commands: + influxdb-onboarding: + steps: + - run: + name: "Post onBoarding request to InfluxDB 2" + command: ./scripts/influxdb-onboarding.sh jobs: build: docker: @@ -14,7 +20,26 @@ jobs: - checkout - run: go get -v -t -d ./... - run: go vet ./... - - run: go get honnef.co/go/tools/cmd/staticcheck && staticcheck --checks="all" ./... + - run: go install honnef.co/go/tools/cmd/staticcheck@latest && staticcheck --checks="all" ./... + tests: + docker: + - image: cimg/go:1.17.2 + environment: + ENV: CI + GO111MODULE: "on" + - image: influxdb:latest + environment: + INFLUXD_HTTP_BIND_ADDRESS: :9999 + - image: influxdb:latest + name: influxdb_v2_onboarding + environment: + INFLUXD_HTTP_BIND_ADDRESS: :9999 + environment: + INFLUXDB_2_ONBOARDING_IP: influxdb_v2_onboarding + INFLUXDB_2_ONBOARDING_PORT: 9999 + steps: + - checkout + - influxdb-onboarding - run: name: "Create a temp directory for artifacts" command: | @@ -22,7 +47,7 @@ jobs: mkdir -p /tmp/test-results - run: command: | - gotestsum --junitfile /tmp/test-results/unit-tests.xml -- -race -coverprofile=coverage.txt -covermode=atomic ./... + gotestsum --junitfile /tmp/test-results/unit-tests.xml -- -race -tags=e2e -coverprofile=coverage.txt -covermode=atomic ./... bash <(curl -s https://codecov.io/bash) go tool cover -html=coverage.txt -o /tmp/artifacts/coverage.html - store_artifacts: @@ -31,4 +56,12 @@ jobs: path: /tmp/test-results destination: raw-test-output - store_test_results: - path: /tmp/test-results \ No newline at end of file + path: /tmp/test-results +workflows: + version: 2 + build-test: + jobs: + - build + - tests: + requires: + - build \ No newline at end of file diff --git a/go.mod b/go.mod index cf459d2b..0900eeca 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,20 @@ module github.com/influxdata/influxdb-client-go go 1.17 -require github.com/stretchr/testify v1.7.0 +require ( + github.com/deepmap/oapi-codegen v1.12.4 + github.com/google/go-cmp v0.5.9 + github.com/pkg/errors v0.9.1 + github.com/stretchr/testify v1.8.1 +) require ( - github.com/davecgh/go-spew v1.1.0 // indirect + github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/kr/pretty v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect + github.com/rogpeppe/go-internal v1.8.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index acb88a48..5eb951ac 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,174 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= +github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= +github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= +github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d/go.mod h1:tmAIfUFEirG/Y8jhZ9M+h36obRZAk/1fcSpXwAVlfqE= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/deepmap/oapi-codegen v1.12.4 h1:pPmn6qI9MuOtCz82WY2Xaw46EQjgvxednXXrP7g5Q2s= +github.com/deepmap/oapi-codegen v1.12.4/go.mod h1:3lgHGMu6myQ2vqbbTXH2H1o4eXFTGnFiDaOaKKl5yas= +github.com/getkin/kin-openapi v0.107.0/go.mod h1:9Dhr+FasATJZjS4iOLvB0hkaxgYdulrNYm2e9epLWOo= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= +github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= +github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= +github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/labstack/echo/v4 v4.9.1/go.mod h1:Pop5HLc+xoc4qhTZ1ip6C0RtP7Z+4VzRLWZZFKqbbjo= +github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/lestrrat-go/backoff/v2 v2.0.8/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y= +github.com/lestrrat-go/blackmagic v1.0.0/go.mod h1:TNgH//0vYSs8VXDCfkZLgIrVTTXQELZffUV0tz3MtdQ= +github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= +github.com/lestrrat-go/iter v1.0.1/go.mod h1:zIdgO1mRKhn8l9vrZJZz9TUMMFbQbLeTsbqPDrJ/OJc= +github.com/lestrrat-go/jwx v1.2.25/go.mod h1:zoNuZymNl5lgdcu6P7K6ie2QRll5HVfF4xwxBBK1NxY= +github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk= +github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= +github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= +github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20220411224347-583f2d630306/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/influxclient/authorizations.go b/influxclient/authorizations.go new file mode 100644 index 00000000..521355b7 --- /dev/null +++ b/influxclient/authorizations.go @@ -0,0 +1,118 @@ +// Copyright 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 influxclient provides client for InfluxDB server. +package influxclient + +import ( + "context" + "fmt" + + "github.com/influxdata/influxdb-client-go/influxclient/model" +) + +// AuthorizationsAPI holds methods related to authorization, as found under +// the /authorizations endpoint. +type AuthorizationsAPI struct { + client *model.Client +} + +// newAuthorizationsAPI creates new instance of AuthorizationsAPI +func newAuthorizationsAPI(client *model.Client) *AuthorizationsAPI { + return &AuthorizationsAPI{client: client} +} + +// Find returns all authorizations matching the given filter. +// Supported filters: +// - OrgName +// - OrgID +// - UserName +// - UserID +func (a *AuthorizationsAPI) Find(ctx context.Context, filter *Filter) ([]model.Authorization, error) { + return a.getAuthorizations(ctx, filter) +} + +// FindOne returns one authorizationsmatching the given filter. +// Supported filters: +// - OrgName +// - OrgID +// - UserName +// - UserID +func (a *AuthorizationsAPI) FindOne(ctx context.Context, filter *Filter) (*model.Authorization, error) { + authorizations, err := a.getAuthorizations(ctx, filter) + if err != nil { + return nil, err + } + if len(authorizations) > 0 { + return &(authorizations)[0], nil + } + return nil, fmt.Errorf("authorization not found") +} + +// Create creates a new authorization. The returned Authorization holds the new ID. +func (a *AuthorizationsAPI) Create(ctx context.Context, auth *model.Authorization) (*model.Authorization, error) { + if auth == nil { + return nil, fmt.Errorf("auth cannot be nil") + } + if auth.Permissions == nil { + return nil, fmt.Errorf("permissions are required") + } + params := &model.PostAuthorizationsAllParams{ + Body: model.PostAuthorizationsJSONRequestBody{ + OrgID: auth.OrgID, + UserID: auth.UserID, + Permissions: auth.Permissions, + }, + } + return a.client.PostAuthorizations(ctx, params) +} + +// SetStatus updates authorization status. +func (a *AuthorizationsAPI) SetStatus(ctx context.Context, authID string, status model.AuthorizationUpdateRequestStatus) (*model.Authorization, error) { + if authID == "" { + return nil, fmt.Errorf("authID is required") + } + params := &model.PatchAuthorizationsIDAllParams{ + AuthID: authID, + Body: model.PatchAuthorizationsIDJSONRequestBody{ + Status: &status, + }, + } + return a.client.PatchAuthorizationsID(ctx, params) +} + +// Delete deletes the organization with the given ID. +func (a *AuthorizationsAPI) Delete(ctx context.Context, authID string) error { + if authID == "" { + return fmt.Errorf("authID is required") + } + params := &model.DeleteAuthorizationsIDAllParams{ + AuthID: authID, + } + return a.client.DeleteAuthorizationsID(ctx, params) +} + +// getAuthorizations create request for GET on /authorizations according to the filter and validates returned structure +func (a *AuthorizationsAPI) getAuthorizations(ctx context.Context, filter *Filter) ([]model.Authorization, error) { + params := &model.GetAuthorizationsParams{} + if filter != nil { + if filter.OrgName != "" { + params.Org = &filter.OrgName + } + if filter.OrgID != "" { + params.OrgID = &filter.OrgID + } + if filter.UserName != "" { + params.User = &filter.UserName + } + if filter.UserID != "" { + params.UserID = &filter.UserID + } + } + response, err := a.client.GetAuthorizations(ctx, params) + if err != nil { + return nil, err + } + return *response.Authorizations, nil +} diff --git a/influxclient/authorizations_e2e_test.go b/influxclient/authorizations_e2e_test.go new file mode 100644 index 00000000..7e5c4317 --- /dev/null +++ b/influxclient/authorizations_e2e_test.go @@ -0,0 +1,206 @@ +// +build e2e + +// Copyright 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 influxclient_test + +import ( + "fmt" + "testing" + + . "github.com/influxdata/influxdb-client-go/influxclient" + "github.com/influxdata/influxdb-client-go/influxclient/model" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestAuthorizationsAPI(t *testing.T) { + client, ctx := newClient(t) + authAPI := client.AuthorizationsAPI() + + auths, err := authAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, auths) + assert.Len(t, auths, 1) + + auths, err = authAPI.Find(ctx, &Filter{}) + require.NoError(t, err) + require.NotNil(t, auths) + assert.Len(t, auths, 1) // only oboarded should exist + + authone, err := authAPI.FindOne(ctx, nil) + require.NoError(t, err) + require.NotNil(t, authone) // oboarded should exist + + org, err := client.OrganizationAPI().FindOne(ctx, &Filter{ + Name: orgName, + }) + require.NoError(t, err) + require.NotNil(t, org) + assert.Equal(t, orgName, org.Name) + + permissions := []model.Permission{ + { + Action: model.PermissionActionWrite, + Resource: model.Resource{ + Type: model.ResourceTypeBuckets, + }, + }, + } + + auth, err := authAPI.Create(ctx, &model.Authorization{ + OrgID: org.Id, + Permissions: &permissions, + }) + require.NoError(t, err) + require.NotNil(t, auth) + defer authAPI.Delete(ctx, fmt.Sprintf("%s", *auth.Id)) + assert.Equal(t, model.AuthorizationUpdateRequestStatusActive, *auth.Status) + + auths, err = authAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, auths) + assert.Len(t, auths, 2) + + auths, err = authAPI.Find(ctx, &Filter{ + UserName: userName, + }) + require.NoError(t, err) + require.NotNil(t, auths) + assert.Len(t, auths, 2) + + auths, err = authAPI.Find(ctx, &Filter{ + OrgID: *org.Id, + }) + require.NoError(t, err) + require.NotNil(t, auths) + assert.Len(t, auths, 2) + + auths, err = authAPI.Find(ctx, &Filter{ + OrgName: orgName, + }) + require.NoError(t, err) + require.NotNil(t, auths) + assert.Len(t, auths, 2) + + user, err := client.UsersAPI().FindOne(ctx, &Filter{ + Name: userName, + }) + require.NoError(t, err) + require.NotNil(t, user) + + auths, err = authAPI.Find(ctx, &Filter{ + UserID: *user.Id, + }) + require.NoError(t, err) + require.NotNil(t, auths) + assert.Len(t, auths, 2) + + auths, err = authAPI.Find(ctx, &Filter{ + OrgName: "not-existent-org", + }) + require.Error(t, err) + require.Nil(t, auths) + + auth, err = authAPI.SetStatus(ctx, *auth.Id, model.AuthorizationUpdateRequestStatusInactive) // default is active + require.NoError(t, err) + require.NotNil(t, auth) + assert.Equal(t, model.AuthorizationUpdateRequestStatusInactive, *auth.Status) + + auths, err = authAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, auths) + assert.Len(t, auths, 2) + + err = authAPI.Delete(ctx, *auth.Id) + require.NoError(t, err) + + auths, err = authAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, auths) + assert.Len(t, auths, 1) // only oboarded should exist + +} + +func TestAuthorizationsAPI_failing(t *testing.T) { + client, ctx := newClient(t) + authAPI := client.AuthorizationsAPI() + + auths, err := authAPI.Find(ctx, &Filter{ + UserName: "not-existing-user", + }) + assert.Error(t, err) + assert.Nil(t, auths) + + auths, err = authAPI.Find(ctx, &Filter{ + UserID: invalidID, + }) + assert.Error(t, err) + assert.Nil(t, auths) + + auths, err = authAPI.Find(ctx, &Filter{ + OrgID: notExistingID, + }) + assert.Error(t, err) + assert.Nil(t, auths) + + auths, err = authAPI.Find(ctx, &Filter{ + OrgName: "not-existing-org", + }) + assert.Error(t, err) + assert.Nil(t, auths) + + authone, err := authAPI.FindOne(ctx, &Filter{ + OrgName: "not-existing-org", + }) + assert.Error(t, err) + assert.Nil(t, authone) + + org, err := client.OrganizationAPI().FindOne(ctx, &Filter{ + Name: orgName, + }) + require.NoError(t, err) + require.NotNil(t, org) + + auth, err := authAPI.Create(ctx, nil) + assert.Error(t, err) + assert.Nil(t, auth) + + auth, err = authAPI.Create(ctx, &model.Authorization{ + OrgID: org.Id, + }) + assert.Error(t, err) + assert.Nil(t, auth) + + permissions := []model.Permission{ + { + Action: model.PermissionActionWrite, + Resource: model.Resource{ + Type: model.ResourceTypeBuckets, + }, + }, + } + + auth, err = authAPI.Create(ctx, &model.Authorization{ + OrgID: ¬ExistingID, + Permissions: &permissions, + }) + assert.Error(t, err) + assert.Nil(t, auth) + + auth, err = authAPI.SetStatus(ctx, notInitializedID, model.AuthorizationUpdateRequestStatusInactive) + assert.Error(t, err) + assert.Nil(t, auth) + + auth, err = authAPI.SetStatus(ctx, notExistingID, model.AuthorizationUpdateRequestStatusInactive) + assert.Error(t, err) + assert.Nil(t, auth) + + err = authAPI.Delete(ctx, notInitializedID) + assert.Error(t, err) + + err = authAPI.Delete(ctx, notExistingID) + assert.Error(t, err) +} diff --git a/influxclient/buckets.go b/influxclient/buckets.go new file mode 100644 index 00000000..37e2c1e5 --- /dev/null +++ b/influxclient/buckets.go @@ -0,0 +1,153 @@ +// Copyright 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 influxclient provides client for InfluxDB server. +package influxclient + +import ( + "context" + "fmt" + + "github.com/influxdata/influxdb-client-go/influxclient/model" +) + +// BucketsAPI provides methods for managing buckets in a InfluxDB server. +type BucketsAPI struct { + client *model.Client +} + +// newBucketsAPI returns new BucketsAPI instance +func newBucketsAPI(client *model.Client) *BucketsAPI { + return &BucketsAPI{client: client} +} + +// Find returns all buckets matching the given filter. +func (a *BucketsAPI) Find(ctx context.Context, filter *Filter) ([]model.Bucket, error) { + return a.getBuckets(ctx, filter) +} + +// FindOne returns one label that matches the given filter. +func (a *BucketsAPI) FindOne(ctx context.Context, filter *Filter) (*model.Bucket, error) { + buckets, err := a.getBuckets(ctx, filter) + if err != nil { + return nil, err + } + if len(buckets) > 0 { + return &(buckets[0]), nil + } + return nil, fmt.Errorf("bucket not found") +} + +// Create creates a new bucket with the given information. +// The label.Name field must be non-empty. +// The returned Bucket holds the ID of the new bucket. +func (a *BucketsAPI) Create(ctx context.Context, bucket *model.Bucket) (*model.Bucket, error) { + if bucket == nil { + return nil, fmt.Errorf("bucket cannot be nil") + } + if bucket.Name == "" { + return nil, fmt.Errorf("name is required") + } + if bucket.OrgID == nil { + return nil, fmt.Errorf("orgId is required") + } + params := &model.PostBucketsAllParams{ + Body: model.PostBucketsJSONRequestBody{ + OrgID: *(bucket.OrgID), + Name: bucket.Name, + }, + } + if bucket.Description != nil { + params.Body.Description = bucket.Description + } + if bucket.RetentionRules != nil { + params.Body.RetentionRules = &bucket.RetentionRules + } + if bucket.Rp != nil { + params.Body.Rp = bucket.Rp + } + if bucket.SchemaType != nil { + params.Body.SchemaType = bucket.SchemaType + } + return a.client.PostBuckets(ctx, params) +} + +// Update updates information about a bucket. +// The bucket ID and OrgID fields must be specified. +func (a *BucketsAPI) Update(ctx context.Context, bucket *model.Bucket) (*model.Bucket, error) { + if bucket == nil { + return nil, fmt.Errorf("bucket cannot be nil") + } + if bucket.Id == nil { + return nil, fmt.Errorf("bucket ID is required") + } + if bucket.OrgID == nil { + return nil, fmt.Errorf("orgId is required") + } + params := &model.PatchBucketsIDAllParams{ + BucketID: *(bucket.Id), + Body: model.PatchBucketsIDJSONRequestBody{ + Name: &bucket.Name, + }, + } + if bucket.Description != nil { + params.Body.Description = bucket.Description + } + if bucket.RetentionRules != nil { + rules := make(model.PatchRetentionRules, len(bucket.RetentionRules)) + for i, r := range bucket.RetentionRules { + var patchRuleType *model.PatchRetentionRuleType + if r.Type != nil && *r.Type != model.RetentionRuleTypeExpire { + return nil, fmt.Errorf("unsupported retention rule type: %v", r.Type) + } + rules[i] = model.PatchRetentionRule{ + EverySeconds: r.EverySeconds, + ShardGroupDurationSeconds: r.ShardGroupDurationSeconds, + Type: patchRuleType, + } + } + params.Body.RetentionRules = &rules + } + return a.client.PatchBucketsID(ctx, params) +} + +// Delete deletes the bucket with the given ID. +func (a *BucketsAPI) Delete(ctx context.Context, bucketID string) error { + params := &model.DeleteBucketsIDAllParams{ + BucketID: bucketID, + } + return a.client.DeleteBucketsID(ctx, params) +} + +// getBuckets create request for GET on /buckets according to the filter and validates returned structure +func (a *BucketsAPI) getBuckets(ctx context.Context, filter *Filter) ([]model.Bucket, error) { + params := &model.GetBucketsParams{} + if filter != nil { + if filter.ID != "" { + params.Id = &filter.ID + } + if filter.Name != "" { + params.Name = &filter.Name + } + if filter.OrgName != "" { + params.Org = &filter.OrgName + } + if filter.OrgID != "" { + params.OrgID = &filter.OrgID + } + if filter.Limit > 0 { + limit := model.Limit(filter.Limit) + params.Limit = &limit + } + if filter.Offset > 0 { + offset := model.Offset(filter.Offset) + params.Offset = &offset + } + } + response, err := a.client.GetBuckets(ctx, params) + if err != nil { + return nil, err + } + return *response.Buckets, nil +} diff --git a/influxclient/buckets_e2e_test.go b/influxclient/buckets_e2e_test.go new file mode 100644 index 00000000..2e47e261 --- /dev/null +++ b/influxclient/buckets_e2e_test.go @@ -0,0 +1,399 @@ +// +build e2e + +// 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 influxclient_test + +import ( + "fmt" + "strings" + "testing" + + . "github.com/influxdata/influxdb-client-go/influxclient" + "github.com/influxdata/influxdb-client-go/influxclient/model" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestBucketsAPI(t *testing.T) { + client, ctx := newClient(t) + bucketsAPI := client.BucketsAPI() + + // find without filter + buckets, err := bucketsAPI.Find(ctx, nil) + require.Nil(t, err, err) + require.NotNil(t, buckets) + // at least three buckets, my-bucket (created during onboarding) and two system buckets. + assert.True(t, len(buckets) > 2) + + // find + buckets, err = bucketsAPI.Find(ctx, &Filter{ + OrgName: orgName, + }) + require.Nil(t, err, err) + require.NotNil(t, buckets) + // at least three buckets, my-bucket and two system buckets. + assert.True(t, len(buckets) > 2) + + // test find existing bucket by name + buckets, err = bucketsAPI.Find(ctx, &Filter{ + Name: bucketName, + }) + require.Nil(t, err, err) + require.NotNil(t, buckets) + assert.Len(t, buckets, 1) + assert.Equal(t, bucketName, buckets[0].Name) + + // test find existing bucket by name + bucket, err := bucketsAPI.FindOne(ctx, &Filter{ + OrgName: orgName, + Name: bucketName, + }) + require.Nil(t, err, err) + require.NotNil(t, bucket) + assert.Equal(t, bucketName, bucket.Name) + + // test find non-existing bucket + bucket, err = bucketsAPI.FindOne(ctx, &Filter{ + Name: "not existing bucket", + }) + assert.Error(t, err) + assert.Nil(t, bucket) + + // test find non-existing bucket + buckets, err = bucketsAPI.Find(ctx, &Filter{ + Name: "not existing bucket", + }) + assert.NoError(t, err) + assert.NotNil(t, buckets) + assert.Len(t, buckets, 0) + + // create organization for bucket + org, err := client.OrganizationAPI().Create(ctx, &model.Organization{ + Name: "bucket-org", + }) + require.NoError(t, err) + require.NotNil(t, org) + defer client.OrganizationAPI().Delete(ctx, safeId(org.Id)) + + // test org buckets + buckets, err = bucketsAPI.Find(ctx, &Filter{ + OrgID: *org.Id, + }) + assert.NoError(t, err) + assert.NotNil(t, buckets) + //+2 for system buckets + assert.Len(t, buckets, 2) + + // create org bucket + name := "bucket-x" + b, err := bucketsAPI.Create(ctx, &model.Bucket{ + OrgID: org.Id, + Name: name, + RetentionRules: model.RetentionRules{ + { + EverySeconds: 3600 * 12, + }, + }, + }) + require.Nil(t, err, err) + require.NotNil(t, b) + defer bucketsAPI.Delete(ctx, safeId(b.Id)) + assert.Equal(t, name, b.Name) + assert.Len(t, b.RetentionRules, 1) + assert.Equal(t, b.RetentionRules[0].EverySeconds, int64(3600 * 12)) + + // Test update + desc := "bucket description" + b.Description = &desc + b.RetentionRules = []model.RetentionRule{{EverySeconds: 3600}} + b, err = bucketsAPI.Update(ctx, b) + require.Nil(t, err, err) + require.NotNil(t, b) + assert.Equal(t, name, b.Name) + assert.Equal(t, desc, *b.Description) + assert.Len(t, b.RetentionRules, 1) + assert.Equal(t, b.RetentionRules[0].EverySeconds, int64(3600)) + + // create org bucket with all options + namex := "bucket-x all" + descx := "Bucket X all" + rpx := "0" + schemaType := model.SchemaTypeImplicit + bx, err := bucketsAPI.Create(ctx, &model.Bucket{ + OrgID: org.Id, + Name: namex, + Description: &descx, + RetentionRules: model.RetentionRules{ + { + EverySeconds: 3600 * 12, + }, + }, + Rp: &rpx, + SchemaType: &schemaType, + }) + require.Nil(t, err, err) + require.NotNil(t, bx) + defer bucketsAPI.Delete(ctx, safeId(bx.Id)) + assert.Equal(t, namex, bx.Name) + assert.Equal(t, descx, *bx.Description) + assert.Len(t, bx.RetentionRules, 1) + assert.Equal(t, int64(3600 * 12), bx.RetentionRules[0].EverySeconds) + //assert.NotNil(t, bx.SchemaType, "%v", bx.SchemaType) + assert.Equal(t, rpx, *bx.Rp) + + // Find by ID + b, err = bucketsAPI.FindOne(ctx, &Filter{ + ID: *b.Id, + }) + require.Nil(t, err, err) + require.NotNil(t, b) + +/* TODO UsersAPI does not support these in v3 + // Test owners + userOwner, err := client.UsersAPI().CreateUserWithName(ctx, "bucket-owner") + require.Nil(t, err, err) + require.NotNil(t, userOwner) + + owners, err := bucketsAPI.GetOwners(ctx, b) + require.Nil(t, err, err) + require.NotNil(t, owners) + assert.Len(t, *owners, 0) + + owner, err := bucketsAPI.AddOwner(ctx, b, userOwner) + require.Nil(t, err, err) + require.NotNil(t, owner) + assert.Equal(t, *userOwner.Id, *owner.Id) + + owners, err = bucketsAPI.GetOwners(ctx, b) + require.Nil(t, err, err) + require.NotNil(t, owners) + assert.Len(t, *owners, 1) + + err = bucketsAPI.RemoveOwnerWithID(ctx, *b.Id, *(*owners)[0].Id) + require.Nil(t, err, err) + + owners, err = bucketsAPI.GetOwners(ctx, b) + require.Nil(t, err, err) + require.NotNil(t, owners) + assert.Len(t, *owners, 0) + + // Test members + userMember, err := client.UsersAPI().CreateUserWithName(ctx, "bucket-member") + require.Nil(t, err, err) + require.NotNil(t, userMember) + + members, err := bucketsAPI.GetMembers(ctx, b) + require.Nil(t, err, err) + require.NotNil(t, members) + assert.Len(t, *members, 0) + + member, err := bucketsAPI.AddMember(ctx, b, userMember) + require.Nil(t, err, err) + require.NotNil(t, member) + assert.Equal(t, *userMember.Id, *member.Id) + + members, err = bucketsAPI.GetMembers(ctx, b) + require.Nil(t, err, err) + require.NotNil(t, members) + assert.Len(t, *members, 1) + + err = bucketsAPI.RemoveMemberWithID(ctx, *b.Id, *(*members)[0].Id) + require.Nil(t, err, err) + + members, err = bucketsAPI.GetMembers(ctx, b) + require.Nil(t, err, err) + require.NotNil(t, members) + assert.Len(t, *members, 0) + + err = bucketsAPI.DeleteBucketWithID(ctx, *b.Id) + assert.Nil(t, err, err) + + err = client.UsersAPI().DeleteUser(ctx, userOwner) + assert.Nil(t, err, err) + + err = client.UsersAPI().DeleteUser(ctx, userMember) + assert.Nil(t, err, err) +*/ + + // attempt to create bucket with existing name should fail + bucket, err = bucketsAPI.Create(ctx, &model.Bucket{ + OrgID: org.Id, + Name: b.Name, + }) + assert.Error(t, err) + assert.Nil(t, bucket) + + // delete bucket + err = bucketsAPI.Delete(ctx, *b.Id) + assert.Nil(t, err, err) + + // trying to delete already deleted should fail + err = bucketsAPI.Delete(ctx, *b.Id) + assert.Error(t, err) +} + +func TestBucketsAPI_paging(t *testing.T) { + client, ctx := newClient(t) + bucketsAPI := client.BucketsAPI() + + // create organization for buckets + org, err := client.OrganizationAPI().Create(ctx, &model.Organization{ + Name: "bucket-paging-org", + }) + require.NoError(t, err) + require.NotNil(t, org) + defer client.OrganizationAPI().Delete(ctx, safeId(org.Id)) + + // collect all buckets including system ones created for new organization + buckets, err := bucketsAPI.Find(ctx, nil) + require.Nil(t, err, err) + // store #all buckets before creating new ones (typically 3 - 2x system buckets (_tasks, _monitoring) + initial bucket "my-bucket") + bucketsNum := len(buckets) + + // create new buckets inside org + for i := 0; i < 30; i++ { + name := fmt.Sprintf("bucket-%03d", i) + b, err := bucketsAPI.Create(ctx, &model.Bucket{ + OrgID: org.Id, + Name: name, + }) + require.Nil(t, err, err) + require.NotNil(t, b) + defer bucketsAPI.Delete(ctx, safeId(b.Id)) + assert.Equal(t, name, b.Name) + } + + // default page size is 20 + defaultPageSize := 20 + + // test paging, 1st page + buckets, err = bucketsAPI.Find(ctx, nil) + require.Nil(t, err, err) + require.NotNil(t, buckets) + assert.Len(t, buckets, defaultPageSize) + + // test paging, 2nd, last page + buckets, err = bucketsAPI.Find(ctx, &Filter{ + Offset: 20, + }) + require.Nil(t, err, err) + require.NotNil(t, buckets) + + // should return 15, but sometimes repeats system buckets also in 2nd page + assert.True(t, len(buckets) >= 10+bucketsNum, "Invalid len: %d >= %d", len(buckets), 10+bucketsNum) + + // test paging with increase limit to cover all buckets + buckets, err = bucketsAPI.Find(ctx, &Filter{ + Limit: 100, + }) + require.Nil(t, err, err) + require.NotNil(t, buckets) + assert.Len(t, buckets, 30+bucketsNum) + + // test filtering buckets by org id + buckets, err = bucketsAPI.Find(ctx, &Filter{ + OrgID: *org.Id, + Limit: 100, + }) + require.Nil(t, err, err) + require.NotNil(t, buckets) + //+2 for system buckets + assert.Len(t, buckets, 30+2) + + // test filtering buckets by org name + buckets, err = bucketsAPI.Find(ctx, &Filter{ + OrgName: org.Name, + Limit: 100, + }) + require.Nil(t, err, err) + require.NotNil(t, buckets) + //+2 for system buckets + assert.Len(t, buckets, 30+2) + + // delete buckets + for _, b := range buckets { + if strings.HasPrefix(b.Name, "bucket-") { + err = bucketsAPI.Delete(ctx, *b.Id) + assert.Nil(t, err, err) + } + } + + // check all created buckets deleted + buckets, err = bucketsAPI.Find(ctx, &Filter{ + OrgID: *org.Id, + Limit: 100, + }) + require.Nil(t, err, err) + require.NotNil(t, buckets) + assert.Len(t, buckets, 2) +} + +func TestBucketsAPI_failing(t *testing.T) { + client, ctx := newClient(t) + bucketsAPI := client.BucketsAPI() + + bucket, err := bucketsAPI.Create(ctx, nil) + assert.Error(t, err) + assert.Nil(t, bucket) + + bucket, err = bucketsAPI.Create(ctx, &model.Bucket{}) + assert.Error(t, err) + assert.Nil(t, bucket) + + bucket, err = bucketsAPI.Create(ctx, &model.Bucket{ + Name: "a bucket", + OrgID: nil, + }) + assert.Error(t, err) + assert.Nil(t, bucket) + + bucket, err = bucketsAPI.Update(ctx, nil) + assert.Error(t, err) + assert.Nil(t, bucket) + + bucket, err = bucketsAPI.Update(ctx, &model.Bucket{}) + assert.Error(t, err) + assert.Nil(t, bucket) + + bucket, err = bucketsAPI.Create(ctx, &model.Bucket{ + OrgID: &invalidID, + Name: "bucket-y", + }) + assert.Error(t, err) + assert.Nil(t, bucket) + + bucket, err = bucketsAPI.FindOne(ctx, &Filter{ + OrgID: invalidID, + }) + assert.Error(t, err) + assert.Nil(t, bucket) + + bucket, err = bucketsAPI.FindOne(ctx, &Filter{ + OrgID: invalidID, + }) + assert.Error(t, err) + assert.Nil(t, bucket) + + bucket, err = bucketsAPI.Create(ctx, &model.Bucket{ + OrgID: ¬InitializedID, + Name: "bucket-y", + }) + assert.Error(t, err) + assert.Nil(t, bucket) +} + +func TestBucketsAPI_skip(t *testing.T) { + t.Skip("Should fail but does not") + + client, ctx := newClient(t) + bucketsAPI := client.BucketsAPI() + + buckets, err := bucketsAPI.Find(ctx, &Filter{ + OrgID: invalidID, + }) + assert.NotNil(t, err, "Should fail because organization with id %s does not exist", invalidID) + assert.Nil(t, buckets, "Should be nil because organization with id %s does not exist", invalidID) +} diff --git a/influxclient/client.go b/influxclient/client.go index 7741a0af..0f98c526 100644 --- a/influxclient/client.go +++ b/influxclient/client.go @@ -16,6 +16,12 @@ import ( "net/http" "net/url" "strings" + + "github.com/influxdata/influxdb-client-go/influxclient/model" +) + +const ( + DefaultBatchSize = 5000 ) // Params holds the parameters for creating a new client. @@ -33,6 +39,11 @@ type Params struct { // Organization is name or ID of organization where data (buckets, users, tasks, etc.) belongs to Organization string + // BatchSize holds the default batch size used by PointWriter. + // If it's zero, DefaultBatchSize will be used. + // Note that this can be overridden with PointWriter.SetBatchSize. + BatchSize int + // HTTPClient is used to make API requests. // // This can be used to specify a custom TLS configuration @@ -51,6 +62,8 @@ type Client struct { authorization string // Cached base server API URL. apiURL *url.URL + // generated server client + apiClient *model.Client } // httpParams holds parameters for creating an HTTP request @@ -62,11 +75,17 @@ type httpParams struct { // HTTP request method, eg. POST httpMethod string // HTTP request headers - headers map[string]string + headers http.Header // HTTP POST/PUT body body io.Reader } +// apiCallDelegate delegates generated API client calls to client +type apiCallDelegate struct { + // Client + c *Client +} + // New creates new Client with given Params, where ServerURL and AuthToken are mandatory. func New(params Params) (*Client, error) { c := &Client{params: params} @@ -87,13 +106,28 @@ func New(params Params) (*Client, error) { } var err error // Prepare server API URL - c.apiURL, err = url.Parse(serverAddress + "api/v2/") + c.apiURL, err = url.Parse(serverAddress) if err != nil { return nil, fmt.Errorf("error parsing server URL: %w", err) } + // Create API client + c.apiClient, err = model.NewClient(c.apiURL.String(), &apiCallDelegate{c}) + if err != nil { + return nil, fmt.Errorf("error creating server API client: %w", err) + } + // Update server API URL + c.apiURL, err = url.Parse(c.apiClient.APIEndpoint) + if err != nil { + return nil, fmt.Errorf("error parsing API endpoint URL: %w", err) + } return c, nil } +// APIClient returns generates API client +func (c *Client) APIClient() *model.Client { + return c.apiClient +} + // makeAPICall issues an HTTP request to InfluxDB server API url according to parameters. // Additionally, sets Authorization header and User-Agent. // It returns http.Response or error. Error can be a *ServerError if server responded with error. @@ -109,7 +143,9 @@ func (c *Client) makeAPICall(ctx context.Context, params httpParams) (*http.Resp return nil, fmt.Errorf("error calling %s: %v", fullURL, err) } for k, v := range params.headers { - req.Header.Set(k, v) + for _, i := range v { + req.Header.Add(k, i) + } } req.Header.Set("User-Agent", userAgent) if c.authorization != "" { @@ -167,3 +203,52 @@ func (c *Client) resolveHTTPError(r *http.Response) error { return &httpError.ServerError } + +// Do makes API call for generated client +func (d *apiCallDelegate) Do(req *http.Request) (*http.Response, error) { + queryParams := req.URL.Query() + req.URL.RawQuery = "" + return d.c.makeAPICall(req.Context(), httpParams{ + endpointURL: req.URL, + headers: req.Header, + httpMethod: req.Method, + body: req.Body, + queryParams: queryParams, + }) +} + +// AuthorizationsAPI returns a value that can be used to interact with the +// authorization-related parts of the InfluxDB API. +func (c *Client) AuthorizationsAPI() *AuthorizationsAPI { + return newAuthorizationsAPI(c.apiClient) +} + +// BucketsAPI returns a value that can be used to interact with the +// bucket-related parts of the InfluxDB API. +func (c *Client) BucketsAPI() *BucketsAPI { + return newBucketsAPI(c.apiClient) +} + +// LabelsAPI returns a value that can be used to interact with the +// label-related parts of the InfluxDB API. +func (c *Client) LabelsAPI() *LabelsAPI { + return newLabelsAPI(c.apiClient) +} + +// OrganizationAPI returns a value that can be used to interact with the +// organization-related parts of the InfluxDB API. +func (c *Client) OrganizationAPI() *OrganizationAPI { + return newOrganizationAPI(c.apiClient) +} + +// TasksAPI returns a value that can be used to interact with the +// task-related parts of the InfluxDB API. +func (c *Client) TasksAPI() *TasksAPI { + return newTasksAPI(c.apiClient) +} + +// UsersAPI returns a value that can be used to interact with the +// user-related parts of the InfluxDB API. +func (c *Client) UsersAPI() *UsersAPI { + return newUsersAPI(c.apiClient) +} diff --git a/influxclient/client_query.go b/influxclient/client_query.go index 5a737fd9..92fc3b2b 100644 --- a/influxclient/client_query.go +++ b/influxclient/client_query.go @@ -9,6 +9,7 @@ import ( "context" "encoding/json" "fmt" + "net/http" "net/url" "reflect" "time" @@ -103,7 +104,7 @@ func (c *Client) Query(ctx context.Context, query string, queryParams interface{ resp, err := c.makeAPICall(ctx, httpParams{ endpointURL: queryURL, httpMethod: "POST", - headers: map[string]string{"Content-Type": "application/json"}, + headers: http.Header{"Content-Type": {"application/json"}}, queryParams: url.Values{"org": []string{c.params.Organization}}, body: bytes.NewReader(qrJSON), }) diff --git a/influxclient/client_test.go b/influxclient/client_test.go index 71fab8fb..4015e00b 100644 --- a/influxclient/client_test.go +++ b/influxclient/client_test.go @@ -6,13 +6,13 @@ package influxclient import ( "context" - "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" "net/url" "strings" "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/influxclient/e2e_test.go b/influxclient/e2e_test.go new file mode 100644 index 00000000..79f9a6ad --- /dev/null +++ b/influxclient/e2e_test.go @@ -0,0 +1,67 @@ +// +build e2e + +// Copyright 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 influxclient_test + +import ( + "context" + "fmt" + "os" + "testing" + + . "github.com/influxdata/influxdb-client-go/influxclient" + "github.com/stretchr/testify/require" +) + +var authToken string +var serverURL string +var orgName string +var bucketName string +var userName string + +func getEnvValue(key, defVal string) string { + if val, ok := os.LookupEnv(key); ok { + return val + } else { + return defVal + } +} + +const envPrefix = "INFLUXDB2" + +var notInitializedID string +var invalidID = "#1" +var notExistingID = "100000000000000" + +func init() { + authToken = getEnvValue(envPrefix + "_TOKEN", "my-token") + serverURL = getEnvValue(envPrefix + "_URL", "http://localhost:9999") + orgName = getEnvValue(envPrefix + "_ORG", "my-org") + bucketName = getEnvValue(envPrefix + "_BUCKET", "my-bucket") + userName = getEnvValue(envPrefix + "_USER", "my-user") + fmt.Printf("E2E testing values:\n server: %s\n token : %s\n org : %s\n user : %s\n bucket: %s\n", + serverURL, authToken, orgName, userName, bucketName) +} + +func newClient(t *testing.T) (*Client, context.Context) { + c, err := New(Params{ + ServerURL: serverURL, + AuthToken: authToken, + }) + require.NoError(t, err) + require.NotNil(t, c) + return c, context.Background() +} + +func safeId(ID interface{}) string { + switch v := ID.(type) { + case string: + return fmt.Sprintf("%s", v) + case *string: + return fmt.Sprintf("%s", *v) + default: panic("unsupported type") + } +} \ No newline at end of file diff --git a/influxclient/examples_test.go b/influxclient/examples_test.go index d58fa24f..2f9600fe 100644 --- a/influxclient/examples_test.go +++ b/influxclient/examples_test.go @@ -1,71 +1,91 @@ +// +build e2e + +// 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 influxclient_test import ( "context" "fmt" "os" - "text/tabwriter" - "time" "github.com/influxdata/influxdb-client-go/influxclient" + "github.com/influxdata/influxdb-client-go/influxclient/model" ) -func ExampleClient_Query() { - // Create client +func ExampleClient_newClient() { + // Create a new client using an InfluxDB server base URL and an authentication token + client, err := influxclient.New(influxclient.Params{ + ServerURL: serverURL, + AuthToken: authToken}) + + _ = err + _ = client + + // Output: +} + +func ExampleClient_newClientWithOptions() { + // Create a new client using an InfluxDB server base URL and an authentication token + // Create client and set batch size to 20 + client, err := influxclient.New(influxclient.Params{ + ServerURL: serverURL, + AuthToken: authToken, + BatchSize: 20}) + + _ = err + _ = client + + // Output: +} + +func ExampleClient_customServerAPICall() { + // This example shows how to perform custom server API invocation for any endpoint + // Here we will create a DBRP mapping which allows using buckets in legacy write and query (InfluxQL) endpoints + + // Create client. You need an admin token for creating DBRP mapping client, err := influxclient.New(influxclient.Params{ - ServerURL: "https://eu-central-1-1.aws.cloud2.influxdata.com/", - AuthToken: "my-token", - Organization: "my-org", - }) - - // Define query parameters - params := struct { - Since string `json:"since"` - GreaterThan float64 `json:"greaterThan"` - }{ - "-10m", - 23.0, + ServerURL: serverURL, + AuthToken: authToken}) + + // Get generated client for server API calls + apiClient := client.APIClient() + ctx := context.Background() + + // Get a bucket we would like to query using InfluxQL + b, err := client.BucketsAPI().FindOne(ctx, &influxclient.Filter{Name: bucketName}) + if err != nil { + panic(err) } - // Prepare a query - query := `from(bucket: "iot_center") - |> range(start: duration(v: params.since)) - |> filter(fn: (r) => r._measurement == "environment") - |> filter(fn: (r) => r._field == "Temperature") - |> filter(fn: (r) => r._value > params.greaterThan)` - - // Execute query - res, err := client.Query(context.Background(), query, params) + // Get an organization that will own the mapping + o, err := client.OrganizationAPI().FindOne(ctx, &influxclient.Filter{Name: orgName}) if err != nil { panic(err) } - // Make sure query result is always closed - defer res.Close() - - // Declare custom type for data - val := &struct { - Time time.Time `csv:"_time"` - Temp float64 `csv:"_value"` - Sensor string `csv:"sensor"` - }{} - - tw := tabwriter.NewWriter(os.Stdout, 10, 4, 2, ' ', 0) - fmt.Fprintf(tw, "Time\tTemp\tSensor\n") - - // Iterate over result set - for res.NextSection() { - for res.NextRow() { - err = res.Decode(val) - if err != nil { - fmt.Fprintf(tw, "%v\n", err) - continue - } - fmt.Fprintf(tw, "%s\t%.2f\t%s\n", val.Time.String(), val.Temp, val.Sensor) - } + yes := true + // Fill required fields of the DBRP struct + dbrp := model.DBRPCreate{ + BucketID: *b.Id, + Database: b.Name, + Default: &yes, + OrgID: o.Id, + RetentionPolicy: "autogen", } - tw.Flush() - if res.Err() != nil { - panic(res.Err()) + + params := &model.PostDBRPAllParams{ + Body: model.PostDBRPJSONRequestBody(dbrp), } + // Call server API + newDbrp, err := apiClient.PostDBRP(ctx, params) + if err != nil { + panic(err) + } + + // Check generated response + fmt.Fprintf(os.Stderr, "Created DBRP: %#v\n", newDbrp) + // Output: } diff --git a/influxclient/filter.go b/influxclient/filter.go new file mode 100644 index 00000000..d8ce66b8 --- /dev/null +++ b/influxclient/filter.go @@ -0,0 +1,58 @@ +package influxclient + +import "time" + +// The Filter can be used to select the entities returned by the Find operations. +// Not all filter kinds are supported by all endpoints: see the individual API +// documentation for details. +// +// Note that Filter also provides support for paging (using Offset +// and Limit) - this is only useful with filters that might return more +// than one entity. +// +// For example, to a maximum of 10 buckets that have find all buckets that are +// associated with the organization "example.com" starting 40 entries into +// the results: +// +// client.BucketsAPI().Find(ctx context.Context, &influxapi.Filter{ +// OrgName: "example.com", +// Limit: 10, +// Offset: 40, +// }) +type Filter struct { + // Filter by resource ID + ID string + + // Filter by resource name + Name string + + // Filter by organization name + OrgName string + + // Filter by organization ID + OrgID string + + // Filter by user ID + UserID string + + // Filter by user name + UserName string + + // Filter by status + Status string + + // Maximum number of returned entities in a single request + Limit uint + + // Starting offset for returning entities + Offset uint + + // After specifies that the search results should start after the item of given ID. + After string + + // BeforeTime selects items to those scheduled before this time. + BeforeTime time.Time + + // AfterTime selects items to those scheduled after this time. + AfterTime time.Time +} diff --git a/influxclient/labels.go b/influxclient/labels.go new file mode 100644 index 00000000..cfdcb2da --- /dev/null +++ b/influxclient/labels.go @@ -0,0 +1,126 @@ +// Copyright 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 influxclient provides client for InfluxDB server. +package influxclient + +import ( + "context" + "fmt" + + "github.com/influxdata/influxdb-client-go/influxclient/model" +) + +// LabelsAPI provides methods for managing labels in a InfluxDB server. +type LabelsAPI struct { + client *model.Client +} + +// newLabelsAPI returns new LabelsAPI instance +func newLabelsAPI(client *model.Client) *LabelsAPI { + return &LabelsAPI{client: client} +} + +// Find returns labels matching the given filter. +// Supported filters: +// - OrgID +func (a *LabelsAPI) Find(ctx context.Context, filter *Filter) ([]model.Label, error) { + return a.getLabels(ctx, filter) +} + +// FindOne returns one label matching the given filter. +// Supported filters: +// - OrgID +func (a *LabelsAPI) FindOne(ctx context.Context, filter *Filter) (*model.Label, error) { + labels, err := a.getLabels(ctx, filter) + if err != nil { + return nil, err + } + if len(labels) > 0 { + return &(labels[0]), nil + } + return nil, fmt.Errorf("label not found") +} + +// Create creates a new label with the given information. +// The label.Name field must be non-empty. +// The returned Label holds the ID of the new label. +func (a *LabelsAPI) Create(ctx context.Context, label *model.Label) (*model.Label, error) { + if label == nil { + return nil, fmt.Errorf("label cannot be nil") + } + if label.Name == nil { + return nil, fmt.Errorf("name is required") + } + if label.OrgID == nil { + return nil, fmt.Errorf("orgId is required") + } + params := &model.PostLabelsAllParams{ + Body: model.PostLabelsJSONRequestBody{ + Name: *(label.Name), + OrgID: *(label.OrgID), + }, + } + if label.Properties != nil { + params.Body.Properties = &model.LabelCreateRequest_Properties{ + AdditionalProperties: label.Properties.AdditionalProperties, + } + } + response, err := a.client.PostLabels(ctx, params) + if err != nil { + return nil, err + } + return response.Label, nil +} + +// Update updates the label's name and properties. +// If the name is empty, it won't be changed. If a property isn't mentioned, it won't be changed. +// A property can be removed by using an empty value for that property. +// +// Update returns the fully updated label. +func (a *LabelsAPI) Update(ctx context.Context, label *model.Label) (*model.Label, error) { + if label == nil { + return nil, fmt.Errorf("label cannot be nil") + } + if label.Id == nil { + return nil, fmt.Errorf("label ID is required") + } + params := &model.PatchLabelsIDAllParams{ + LabelID: *label.Id, + Body: model.PatchLabelsIDJSONRequestBody{ + Name: label.Name, + }, + } + if label.Properties != nil { + params.Body.Properties = &model.LabelUpdate_Properties{ + AdditionalProperties: label.Properties.AdditionalProperties, + } + } + response, err := a.client.PatchLabelsID(ctx, params) + if err != nil { + return nil, err + } + return response.Label, nil +} + +// Delete deletes the label with the given ID. +func (a *LabelsAPI) Delete(ctx context.Context, labelID string) error { + params := &model.DeleteLabelsIDAllParams{ + LabelID: labelID, + } + return a.client.DeleteLabelsID(ctx, params) +} + +// getLabels create request for GET on /labels according to the filter and validates returned structure +func (a *LabelsAPI) getLabels(ctx context.Context, filter *Filter) ([]model.Label, error) { + params := &model.GetLabelsParams{} + if filter != nil { + params.OrgID = &filter.OrgID + } + response, err := a.client.GetLabels(ctx, params) + if err != nil { + return nil, err + } + return *response.Labels, nil +} diff --git a/influxclient/labels_e2e_test.go b/influxclient/labels_e2e_test.go new file mode 100644 index 00000000..d8e57964 --- /dev/null +++ b/influxclient/labels_e2e_test.go @@ -0,0 +1,161 @@ +// +build e2e + +// 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 influxclient_test + +import ( + "testing" + + "github.com/google/go-cmp/cmp" + . "github.com/influxdata/influxdb-client-go/influxclient" + "github.com/influxdata/influxdb-client-go/influxclient/model" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestLabelsAPI(t *testing.T) { + client, ctx := newClient(t) + labelsAPI := client.LabelsAPI() + orgAPI := client.OrganizationAPI() + + org, err := orgAPI.FindOne(ctx, &Filter{ + OrgName: orgName, + }) + require.Nil(t, err, err) + require.NotNil(t, org) + + // find without filter + labels, err := labelsAPI.Find(ctx, nil) + require.Nil(t, err, err) + require.NotNil(t, labels) + assert.Len(t, labels, 0) + + // find + labels, err = labelsAPI.Find(ctx, &Filter{ + OrgID: *org.Id, + }) + require.Nil(t, err, err) + require.NotNil(t, labels) + assert.Len(t, labels, 0) + + // create label 1 without properties + label1Name := "Basic State" + label1, err := labelsAPI.Create(ctx, &model.Label{ + Name: &label1Name, + OrgID: org.Id, + }) + require.Nil(t, err, err) + require.NotNil(t, label1) + defer labelsAPI.Delete(ctx, safeId(label1.Id)) + assert.Equal(t, label1Name, *label1.Name) + require.Nil(t, label1.Properties) + + // create label 2 with properties + label2Name := "Active State" + props2 := map[string]string{"color": "#33ffddd", "description": "Marks state active"} + label2, err := labelsAPI.Create(ctx, &model.Label{ + Name: &label2Name, + OrgID: org.Id, + Properties: &model.Label_Properties{AdditionalProperties: props2}, + }) + require.Nil(t, err, err) + require.NotNil(t, label2) + defer labelsAPI.Delete(ctx, safeId(label2.Id)) + assert.Equal(t, label2Name, *label2.Name) + require.NotNil(t, label2.Properties) + diff := cmp.Diff([]model.Label{}, labels) + assert.Equal(t, props2, label2.Properties.AdditionalProperties, "diff: %s", diff) + + // find + labels, err = labelsAPI.Find(ctx, &Filter{OrgID: org.Name}) + require.Nil(t, err, err) + require.NotNil(t, labels) + assert.Len(t, labels, 2) + + // remove properties + label2.Properties.AdditionalProperties = map[string]string{"color": "", "description": ""} + label2, err = labelsAPI.Update(ctx, label2) + require.Nil(t, err, err) + require.NotNil(t, label2) + assert.Equal(t, label2Name, *label2.Name) + assert.Nil(t, label2.Properties) + + // delete label 2 + err = labelsAPI.Delete(ctx, *label2.Id) + require.Nil(t, err, err) + + // find + labels, err = labelsAPI.Find(ctx, &Filter{OrgID: org.Name}) + require.Nil(t, err, err) + require.NotNil(t, labels) + assert.Len(t, labels, 1) + + // find one + label, err := labelsAPI.FindOne(ctx, &Filter{OrgID: org.Name}) + require.Nil(t, err, err) + require.NotNil(t, label) + assert.Equal(t, label1.Name, label.Name) + assert.Equal(t, label1.Properties, label.Properties) + + // try to create label with existing name + label3, err := labelsAPI.Create(ctx, &model.Label{ + Name: label1.Name, + OrgID: org.Id, + }) + assert.Error(t, err) + assert.Nil(t, label3) + + // delete label + err = labelsAPI.Delete(ctx, *label1.Id) + require.Nil(t, err, err) + + // find + labels, err = labelsAPI.Find(ctx, &Filter{OrgID: org.Name}) + require.Nil(t, err, err) + require.NotNil(t, labels) + assert.Len(t, labels, 0) +} + +func TestLabelsAPI_failing(t *testing.T) { + client, ctx := newClient(t) + labelsAPI := client.LabelsAPI() + + label, err := labelsAPI.Create(ctx, nil) + assert.Error(t, err) + assert.Nil(t, label) + + label, err = labelsAPI.Create(ctx, &model.Label{}) + assert.Error(t, err) + assert.Nil(t, label) + + name := "a label" + label, err = labelsAPI.Create(ctx, &model.Label{ + Name: &name, + OrgID: nil, + }) + assert.Error(t, err) + assert.Nil(t, label) + + label, err = labelsAPI.Update(ctx, nil) + assert.Error(t, err) + assert.Nil(t, label) + + label, err = labelsAPI.Update(ctx, &model.Label{}) + assert.Error(t, err) + assert.Nil(t, label) + + err = labelsAPI.Delete(ctx, notExistingID) + require.Error(t, err) + + label, err = labelsAPI.FindOne(ctx, &Filter{ + ID: invalidID, + }) + assert.Error(t, err) + assert.Nil(t, label) + + err = labelsAPI.Delete(ctx, invalidID) + assert.Error(t, err) +} diff --git a/influxclient/model/Readme.md b/influxclient/model/Readme.md new file mode 100644 index 00000000..8cc8a779 --- /dev/null +++ b/influxclient/model/Readme.md @@ -0,0 +1,23 @@ +# Generated types and API client + +`oss.yml`must be periodically synced with latest changes and types and client must be re-generated +to maintain full compatibility with the latest InfluxDB release + + +## Install oapi generator +`git clone git@github.com:bonitoo-io/oapi-codegen.git` +`cd oapi-codegen` +`git checkout feat/template_helpers` +`go install ./cmd/oapi-codegen/oapi-codegen.go` + +## Download latest swagger +`wget https://raw.githubusercontent.com/influxdata/openapi/master/contracts/oss.yml` +`cd domain` + +## Generate +### Generate types +`oapi-codegen -generate types -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` + diff --git a/influxclient/model/client.gen.go b/influxclient/model/client.gen.go new file mode 100644 index 00000000..85b19225 --- /dev/null +++ b/influxclient/model/client.gen.go @@ -0,0 +1,14852 @@ +// Package model provides primitives to interact with the openapi HTTP API. +// +// Code generated by version DO NOT EDIT. +package model + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "mime" + "net/http" + "net/url" + "strings" + + "github.com/deepmap/oapi-codegen/pkg/runtime" + "github.com/pkg/errors" +) + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HTTPRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// Client which conforms to the OpenAPI3 specification for this service. +type Client struct { + // The endpoint of the server conforming to this interface, with scheme, + // https://api.deepmap.com for example. This can contain a path relative + // to the server, such as https://api.deepmap.com/dev-test, and all the + // paths in the swagger spec will be appended to the server. + Server string + + // Server + /api/v2/ + APIEndpoint string + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HTTPRequestDoer +} + +// Creates a new Client, with reasonable defaults +func NewClient(server string, doer HTTPRequestDoer) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + Client: doer, + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // API endpoint + client.APIEndpoint = client.Server + "api/v2/" + + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +func (e *Error) Error() error { + return fmt.Errorf("%s: %s", string(e.Code), *e.Message) +} + +func unmarshalJSONResponse(bodyBytes []byte, obj interface{}) error { + if err := json.Unmarshal(bodyBytes, obj); err != nil { + return err + } + return nil +} + +func isJSON(rsp *http.Response) bool { + ctype, _, _ := mime.ParseMediaType(rsp.Header.Get("Content-Type")) + return ctype == "application/json" +} + +func decodeError(body []byte, rsp *http.Response) error { + if isJSON(rsp) { + var serverError struct { + Error + V1Error *string `json:"error,omitempty"` + } + err := json.Unmarshal(body, &serverError) + if err != nil { + message := fmt.Sprintf("cannot decode error response: %v", err) + serverError.Message = &message + } + if serverError.V1Error != nil { + serverError.Message = serverError.V1Error + serverError.Code = ErrorCodeInvalid + } + if serverError.Message == nil && serverError.Code == "" { + serverError.Message = &rsp.Status + } + return serverError.Error.Error() + } else { + message := rsp.Status + if len(body) > 0 { + message = message + ": " + string(body) + } + return errors.New(message) + } +} + +// GetAuthorizations calls the GET on /authorizations +// List authorizations +func (c *Client) GetAuthorizations(ctx context.Context, params *GetAuthorizationsParams) (*Authorizations, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./authorizations") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.UserID != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "userID", runtime.ParamLocationQuery, *params.UserID); 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.User != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "user", runtime.ParamLocationQuery, *params.User); 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.OrgID != nil { + + 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) + } + } + } + + } + + if params.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Authorizations{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostAuthorizations calls the POST on /authorizations +// Create an authorization +func (c *Client) PostAuthorizations(ctx context.Context, params *PostAuthorizationsAllParams) (*Authorization, 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("./authorizations") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Authorization{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteAuthorizationsID calls the DELETE on /authorizations/{authID} +// Delete an authorization +func (c *Client) DeleteAuthorizationsID(ctx context.Context, params *DeleteAuthorizationsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authID", runtime.ParamLocationPath, params.AuthID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./authorizations/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetAuthorizationsID calls the GET on /authorizations/{authID} +// Retrieve an authorization +func (c *Client) GetAuthorizationsID(ctx context.Context, params *GetAuthorizationsIDAllParams) (*Authorization, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "authID", runtime.ParamLocationPath, params.AuthID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./authorizations/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Authorization{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchAuthorizationsID calls the PATCH on /authorizations/{authID} +// Update an authorization to be active or inactive +func (c *Client) PatchAuthorizationsID(ctx context.Context, params *PatchAuthorizationsIDAllParams) (*Authorization, 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, "authID", runtime.ParamLocationPath, params.AuthID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./authorizations/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Authorization{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetBuckets calls the GET on /buckets +// List buckets +func (c *Client) GetBuckets(ctx context.Context, params *GetBucketsParams) (*Buckets, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./buckets") + + 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 params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); 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.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); 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.OrgID != nil { + + 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) + } + } + } + + } + + if params.Name != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "name", runtime.ParamLocationQuery, *params.Name); 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.Id != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "id", runtime.ParamLocationQuery, *params.Id); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Buckets{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostBuckets calls the POST on /buckets +// Create a bucket +func (c *Client) PostBuckets(ctx context.Context, params *PostBucketsAllParams) (*Bucket, 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("./buckets") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Bucket{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteBucketsID calls the DELETE on /buckets/{bucketID} +// Delete a bucket +func (c *Client) DeleteBucketsID(ctx context.Context, params *DeleteBucketsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "bucketID", runtime.ParamLocationPath, params.BucketID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./buckets/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetBucketsID calls the GET on /buckets/{bucketID} +// Retrieve a bucket +func (c *Client) GetBucketsID(ctx context.Context, params *GetBucketsIDAllParams) (*Bucket, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "bucketID", runtime.ParamLocationPath, params.BucketID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./buckets/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Bucket{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchBucketsID calls the PATCH on /buckets/{bucketID} +// Update a bucket +func (c *Client) PatchBucketsID(ctx context.Context, params *PatchBucketsIDAllParams) (*Bucket, 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, "bucketID", runtime.ParamLocationPath, params.BucketID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./buckets/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Bucket{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetBucketsIDLabels calls the GET on /buckets/{bucketID}/labels +// List all labels for a bucket +func (c *Client) GetBucketsIDLabels(ctx context.Context, params *GetBucketsIDLabelsAllParams) (*LabelsResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "bucketID", runtime.ParamLocationPath, params.BucketID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./buckets/%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 := ioutil.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 + +} + +// PostBucketsIDLabels calls the POST on /buckets/{bucketID}/labels +// Add a label to a bucket +func (c *Client) PostBucketsIDLabels(ctx context.Context, params *PostBucketsIDLabelsAllParams) (*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, "bucketID", runtime.ParamLocationPath, params.BucketID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./buckets/%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 := ioutil.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 + +} + +// DeleteBucketsIDLabelsID calls the DELETE on /buckets/{bucketID}/labels/{labelID} +// Delete a label from a bucket +func (c *Client) DeleteBucketsIDLabelsID(ctx context.Context, params *DeleteBucketsIDLabelsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "bucketID", runtime.ParamLocationPath, params.BucketID) + 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("./buckets/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetBucketsIDMembers calls the GET on /buckets/{bucketID}/members +// List all users with member privileges for a bucket +func (c *Client) GetBucketsIDMembers(ctx context.Context, params *GetBucketsIDMembersAllParams) (*ResourceMembers, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "bucketID", runtime.ParamLocationPath, params.BucketID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./buckets/%s/members", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceMembers{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostBucketsIDMembers calls the POST on /buckets/{bucketID}/members +// Add a member to a bucket +func (c *Client) PostBucketsIDMembers(ctx context.Context, params *PostBucketsIDMembersAllParams) (*ResourceMember, 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, "bucketID", runtime.ParamLocationPath, params.BucketID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./buckets/%s/members", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceMember{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteBucketsIDMembersID calls the DELETE on /buckets/{bucketID}/members/{userID} +// Remove a member from a bucket +func (c *Client) DeleteBucketsIDMembersID(ctx context.Context, params *DeleteBucketsIDMembersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "bucketID", runtime.ParamLocationPath, params.BucketID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./buckets/%s/members/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetBucketsIDOwners calls the GET on /buckets/{bucketID}/owners +// List all owners of a bucket +func (c *Client) GetBucketsIDOwners(ctx context.Context, params *GetBucketsIDOwnersAllParams) (*ResourceOwners, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "bucketID", runtime.ParamLocationPath, params.BucketID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./buckets/%s/owners", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceOwners{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostBucketsIDOwners calls the POST on /buckets/{bucketID}/owners +// Add an owner to a bucket +func (c *Client) PostBucketsIDOwners(ctx context.Context, params *PostBucketsIDOwnersAllParams) (*ResourceOwner, 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, "bucketID", runtime.ParamLocationPath, params.BucketID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./buckets/%s/owners", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceOwner{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteBucketsIDOwnersID calls the DELETE on /buckets/{bucketID}/owners/{userID} +// Remove an owner from a bucket +func (c *Client) DeleteBucketsIDOwnersID(ctx context.Context, params *DeleteBucketsIDOwnersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "bucketID", runtime.ParamLocationPath, params.BucketID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./buckets/%s/owners/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// 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 := ioutil.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 := ioutil.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 := ioutil.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 := ioutil.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 := ioutil.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 := ioutil.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 := ioutil.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 := ioutil.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 := ioutil.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 := ioutil.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) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./config") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Config{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetDashboards calls the GET on /dashboards +// List all dashboards +func (c *Client) GetDashboards(ctx context.Context, params *GetDashboardsParams) (*Dashboards, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards") + + 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 params.Descending != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "descending", runtime.ParamLocationQuery, *params.Descending); 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.Owner != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "owner", runtime.ParamLocationQuery, *params.Owner); 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.SortBy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "sortBy", runtime.ParamLocationQuery, *params.SortBy); 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.Id != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "id", runtime.ParamLocationQuery, *params.Id); 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.OrgID != nil { + + 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) + } + } + } + + } + + if params.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Dashboards{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteDashboardsID calls the DELETE on /dashboards/{dashboardID} +// Delete a dashboard +func (c *Client) DeleteDashboardsID(ctx context.Context, params *DeleteDashboardsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./dashboards/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// PatchDashboardsID calls the PATCH on /dashboards/{dashboardID} +// Update a dashboard +func (c *Client) PatchDashboardsID(ctx context.Context, params *PatchDashboardsIDAllParams) (*Dashboard, 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, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Dashboard{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostDashboardsIDCells calls the POST on /dashboards/{dashboardID}/cells +// Create a dashboard cell +func (c *Client) PostDashboardsIDCells(ctx context.Context, params *PostDashboardsIDCellsAllParams) (*Cell, 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, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards/%s/cells", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Cell{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PutDashboardsIDCells calls the PUT on /dashboards/{dashboardID}/cells +// Replace cells in a dashboard +func (c *Client) PutDashboardsIDCells(ctx context.Context, params *PutDashboardsIDCellsAllParams) (*Dashboard, 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, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards/%s/cells", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Dashboard{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteDashboardsIDCellsID calls the DELETE on /dashboards/{dashboardID}/cells/{cellID} +// Delete a dashboard cell +func (c *Client) DeleteDashboardsIDCellsID(ctx context.Context, params *DeleteDashboardsIDCellsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "cellID", runtime.ParamLocationPath, params.CellID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./dashboards/%s/cells/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// PatchDashboardsIDCellsID calls the PATCH on /dashboards/{dashboardID}/cells/{cellID} +// Update the non-positional information related to a cell +func (c *Client) PatchDashboardsIDCellsID(ctx context.Context, params *PatchDashboardsIDCellsIDAllParams) (*Cell, 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, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "cellID", runtime.ParamLocationPath, params.CellID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards/%s/cells/%s", pathParam0, pathParam1) + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Cell{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetDashboardsIDCellsIDView calls the GET on /dashboards/{dashboardID}/cells/{cellID}/view +// Retrieve the view for a cell +func (c *Client) GetDashboardsIDCellsIDView(ctx context.Context, params *GetDashboardsIDCellsIDViewAllParams) (*View, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "cellID", runtime.ParamLocationPath, params.CellID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards/%s/cells/%s/view", pathParam0, pathParam1) + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &View{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchDashboardsIDCellsIDView calls the PATCH on /dashboards/{dashboardID}/cells/{cellID}/view +// Update the view for a cell +func (c *Client) PatchDashboardsIDCellsIDView(ctx context.Context, params *PatchDashboardsIDCellsIDViewAllParams) (*View, 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, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "cellID", runtime.ParamLocationPath, params.CellID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards/%s/cells/%s/view", pathParam0, pathParam1) + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &View{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetDashboardsIDLabels calls the GET on /dashboards/{dashboardID}/labels +// List all labels for a dashboard +func (c *Client) GetDashboardsIDLabels(ctx context.Context, params *GetDashboardsIDLabelsAllParams) (*LabelsResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards/%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 := ioutil.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 + +} + +// PostDashboardsIDLabels calls the POST on /dashboards/{dashboardID}/labels +// Add a label to a dashboard +func (c *Client) PostDashboardsIDLabels(ctx context.Context, params *PostDashboardsIDLabelsAllParams) (*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, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards/%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 := ioutil.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 + +} + +// DeleteDashboardsIDLabelsID calls the DELETE on /dashboards/{dashboardID}/labels/{labelID} +// Delete a label from a dashboard +func (c *Client) DeleteDashboardsIDLabelsID(ctx context.Context, params *DeleteDashboardsIDLabelsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + 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("./dashboards/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetDashboardsIDMembers calls the GET on /dashboards/{dashboardID}/members +// List all dashboard members +func (c *Client) GetDashboardsIDMembers(ctx context.Context, params *GetDashboardsIDMembersAllParams) (*ResourceMembers, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards/%s/members", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceMembers{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostDashboardsIDMembers calls the POST on /dashboards/{dashboardID}/members +// Add a member to a dashboard +func (c *Client) PostDashboardsIDMembers(ctx context.Context, params *PostDashboardsIDMembersAllParams) (*ResourceMember, 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, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards/%s/members", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceMember{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteDashboardsIDMembersID calls the DELETE on /dashboards/{dashboardID}/members/{userID} +// Remove a member from a dashboard +func (c *Client) DeleteDashboardsIDMembersID(ctx context.Context, params *DeleteDashboardsIDMembersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./dashboards/%s/members/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetDashboardsIDOwners calls the GET on /dashboards/{dashboardID}/owners +// List all dashboard owners +func (c *Client) GetDashboardsIDOwners(ctx context.Context, params *GetDashboardsIDOwnersAllParams) (*ResourceOwners, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards/%s/owners", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceOwners{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostDashboardsIDOwners calls the POST on /dashboards/{dashboardID}/owners +// Add an owner to a dashboard +func (c *Client) PostDashboardsIDOwners(ctx context.Context, params *PostDashboardsIDOwnersAllParams) (*ResourceOwner, 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, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dashboards/%s/owners", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceOwner{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteDashboardsIDOwnersID calls the DELETE on /dashboards/{dashboardID}/owners/{userID} +// Remove an owner from a dashboard +func (c *Client) DeleteDashboardsIDOwnersID(ctx context.Context, params *DeleteDashboardsIDOwnersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "dashboardID", runtime.ParamLocationPath, params.DashboardID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./dashboards/%s/owners/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetDBRPs calls the GET on /dbrps +// List database retention policy mappings +func (c *Client) GetDBRPs(ctx context.Context, params *GetDBRPsParams) (*DBRPs, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dbrps") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.OrgID != nil { + + 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) + } + } + } + + } + + if params.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); 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.Id != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "id", runtime.ParamLocationQuery, *params.Id); 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.BucketID != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "bucketID", runtime.ParamLocationQuery, *params.BucketID); 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.Default != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "default", runtime.ParamLocationQuery, *params.Default); 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.Db != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "db", runtime.ParamLocationQuery, *params.Db); 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.Rp != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "rp", runtime.ParamLocationQuery, *params.Rp); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DBRPs{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostDBRP calls the POST on /dbrps +// Add a database retention policy mapping +func (c *Client) PostDBRP(ctx context.Context, params *PostDBRPAllParams) (*DBRP, 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("./dbrps") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DBRP{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteDBRPID calls the DELETE on /dbrps/{dbrpID} +// Delete a database retention policy +func (c *Client) DeleteDBRPID(ctx context.Context, params *DeleteDBRPIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "dbrpID", runtime.ParamLocationPath, params.DbrpID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./dbrps/%s", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + queryValues := queryURL.Query() + + if params.OrgID != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "orgID", runtime.ParamLocationQuery, *params.OrgID); err != nil { + return err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); err != nil { + return err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + 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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetDBRPsID calls the GET on /dbrps/{dbrpID} +// Retrieve a database retention policy mapping +func (c *Client) GetDBRPsID(ctx context.Context, params *GetDBRPsIDAllParams) (*DBRPGet, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "dbrpID", runtime.ParamLocationPath, params.DbrpID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dbrps/%s", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.OrgID != nil { + + 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) + } + } + } + + } + + if params.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DBRPGet{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchDBRPID calls the PATCH on /dbrps/{dbrpID} +// Update a database retention policy mapping +func (c *Client) PatchDBRPID(ctx context.Context, params *PatchDBRPIDAllParams) (*DBRPGet, 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, "dbrpID", runtime.ParamLocationPath, params.DbrpID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./dbrps/%s", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.OrgID != nil { + + 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) + } + } + } + + } + + if params.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); 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("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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DBRPGet{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostDelete calls the POST on /delete +// Delete data +func (c *Client) PostDelete(ctx context.Context, params *PostDeleteAllParams) error { + var err error + var bodyReader io.Reader + buf, err := json.Marshal(params.Body) + if err != nil { + return err + } + bodyReader = bytes.NewReader(buf) + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./delete") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + queryValues := queryURL.Query() + + if params.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); err != nil { + return err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Bucket != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "bucket", runtime.ParamLocationQuery, *params.Bucket); err != nil { + return err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.OrgID != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "orgID", runtime.ParamLocationQuery, *params.OrgID); err != nil { + return err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.BucketID != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "bucketID", runtime.ParamLocationQuery, *params.BucketID); err != nil { + return err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("POST", queryURL.String(), bodyReader) + if err != nil { + return 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 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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetFlags calls the GET on /flags +// Return the feature flags for the currently authenticated user +func (c *Client) GetFlags(ctx context.Context, params *GetFlagsParams) (*Flags, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./flags") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Flags{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetHealth calls the GET on /health +// Retrieve the health of the instance +func (c *Client) GetHealth(ctx context.Context, params *GetHealthParams) (*HealthCheck, error) { + var err error + + serverURL, err := url.Parse(c.Server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./health") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &HealthCheck{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetLabels calls the GET on /labels +// List all labels +func (c *Client) GetLabels(ctx context.Context, params *GetLabelsParams) (*LabelsResponse, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./labels") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.OrgID != nil { + + 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 := ioutil.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 + +} + +// PostLabels calls the POST on /labels +// Create a label +func (c *Client) PostLabels(ctx context.Context, params *PostLabelsAllParams) (*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) + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./labels") + + 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 := ioutil.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 + +} + +// DeleteLabelsID calls the DELETE on /labels/{labelID} +// Delete a label +func (c *Client) DeleteLabelsID(ctx context.Context, params *DeleteLabelsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, 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("./labels/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetLabelsID calls the GET on /labels/{labelID} +// Retrieve a label +func (c *Client) GetLabelsID(ctx context.Context, params *GetLabelsIDAllParams) (*LabelResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "labelID", runtime.ParamLocationPath, params.LabelID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./labels/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LabelResponse{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchLabelsID calls the PATCH on /labels/{labelID} +// Update a label +func (c *Client) PatchLabelsID(ctx context.Context, params *PatchLabelsIDAllParams) (*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, "labelID", runtime.ParamLocationPath, params.LabelID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./labels/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LabelResponse{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetMe calls the GET on /me +// Retrieve the currently authenticated user +func (c *Client) GetMe(ctx context.Context, params *GetMeParams) (*UserResponse, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./me") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UserResponse{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PutMePassword calls the PUT on /me/password +// Update a password +func (c *Client) PutMePassword(ctx context.Context, params *PutMePasswordAllParams) error { + var err error + var bodyReader io.Reader + buf, err := json.Marshal(params.Body) + if err != nil { + return err + } + bodyReader = bytes.NewReader(buf) + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./me/password") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + req, err := http.NewRequest("PUT", queryURL.String(), bodyReader) + if err != nil { + return 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 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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetNotificationEndpoints calls the GET on /notificationEndpoints +// List all notification endpoints +func (c *Client) GetNotificationEndpoints(ctx context.Context, params *GetNotificationEndpointsParams) (*NotificationEndpoints, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationEndpoints") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &NotificationEndpoints{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// CreateNotificationEndpoint calls the POST on /notificationEndpoints +// Add a notification endpoint +func (c *Client) CreateNotificationEndpoint(ctx context.Context, params *CreateNotificationEndpointAllParams) (*NotificationEndpoint, 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("./notificationEndpoints") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &NotificationEndpoint{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteNotificationEndpointsID calls the DELETE on /notificationEndpoints/{endpointID} +// Delete a notification endpoint +func (c *Client) DeleteNotificationEndpointsID(ctx context.Context, params *DeleteNotificationEndpointsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "endpointID", runtime.ParamLocationPath, params.EndpointID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./notificationEndpoints/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetNotificationEndpointsID calls the GET on /notificationEndpoints/{endpointID} +// Retrieve a notification endpoint +func (c *Client) GetNotificationEndpointsID(ctx context.Context, params *GetNotificationEndpointsIDAllParams) (*NotificationEndpoint, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "endpointID", runtime.ParamLocationPath, params.EndpointID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationEndpoints/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &NotificationEndpoint{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchNotificationEndpointsID calls the PATCH on /notificationEndpoints/{endpointID} +// Update a notification endpoint +func (c *Client) PatchNotificationEndpointsID(ctx context.Context, params *PatchNotificationEndpointsIDAllParams) (*NotificationEndpoint, 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, "endpointID", runtime.ParamLocationPath, params.EndpointID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationEndpoints/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &NotificationEndpoint{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PutNotificationEndpointsID calls the PUT on /notificationEndpoints/{endpointID} +// Update a notification endpoint +func (c *Client) PutNotificationEndpointsID(ctx context.Context, params *PutNotificationEndpointsIDAllParams) (*NotificationEndpoint, 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, "endpointID", runtime.ParamLocationPath, params.EndpointID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationEndpoints/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &NotificationEndpoint{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetNotificationEndpointsIDLabels calls the GET on /notificationEndpoints/{endpointID}/labels +// List all labels for a notification endpoint +func (c *Client) GetNotificationEndpointsIDLabels(ctx context.Context, params *GetNotificationEndpointsIDLabelsAllParams) (*LabelsResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "endpointID", runtime.ParamLocationPath, params.EndpointID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationEndpoints/%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 := ioutil.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 + +} + +// PostNotificationEndpointIDLabels calls the POST on /notificationEndpoints/{endpointID}/labels +// Add a label to a notification endpoint +func (c *Client) PostNotificationEndpointIDLabels(ctx context.Context, params *PostNotificationEndpointIDLabelsAllParams) (*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, "endpointID", runtime.ParamLocationPath, params.EndpointID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationEndpoints/%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 := ioutil.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 + +} + +// DeleteNotificationEndpointsIDLabelsID calls the DELETE on /notificationEndpoints/{endpointID}/labels/{labelID} +// Delete a label from a notification endpoint +func (c *Client) DeleteNotificationEndpointsIDLabelsID(ctx context.Context, params *DeleteNotificationEndpointsIDLabelsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "endpointID", runtime.ParamLocationPath, params.EndpointID) + 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("./notificationEndpoints/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetNotificationRules calls the GET on /notificationRules +// List all notification rules +func (c *Client) GetNotificationRules(ctx context.Context, params *GetNotificationRulesParams) (*NotificationRules, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationRules") + + 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) + } + } + } + + if params.CheckID != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "checkID", runtime.ParamLocationQuery, *params.CheckID); 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.Tag != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tag", runtime.ParamLocationQuery, *params.Tag); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &NotificationRules{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// CreateNotificationRule calls the POST on /notificationRules +// Add a notification rule +func (c *Client) CreateNotificationRule(ctx context.Context, params *CreateNotificationRuleAllParams) (*NotificationRule, 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("./notificationRules") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &NotificationRule{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteNotificationRulesID calls the DELETE on /notificationRules/{ruleID} +// Delete a notification rule +func (c *Client) DeleteNotificationRulesID(ctx context.Context, params *DeleteNotificationRulesIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ruleID", runtime.ParamLocationPath, params.RuleID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./notificationRules/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetNotificationRulesID calls the GET on /notificationRules/{ruleID} +// Retrieve a notification rule +func (c *Client) GetNotificationRulesID(ctx context.Context, params *GetNotificationRulesIDAllParams) (*NotificationRule, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ruleID", runtime.ParamLocationPath, params.RuleID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationRules/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &NotificationRule{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchNotificationRulesID calls the PATCH on /notificationRules/{ruleID} +// Update a notification rule +func (c *Client) PatchNotificationRulesID(ctx context.Context, params *PatchNotificationRulesIDAllParams) (*NotificationRule, 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, "ruleID", runtime.ParamLocationPath, params.RuleID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationRules/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &NotificationRule{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PutNotificationRulesID calls the PUT on /notificationRules/{ruleID} +// Update a notification rule +func (c *Client) PutNotificationRulesID(ctx context.Context, params *PutNotificationRulesIDAllParams) (*NotificationRule, 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, "ruleID", runtime.ParamLocationPath, params.RuleID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationRules/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &NotificationRule{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetNotificationRulesIDLabels calls the GET on /notificationRules/{ruleID}/labels +// List all labels for a notification rule +func (c *Client) GetNotificationRulesIDLabels(ctx context.Context, params *GetNotificationRulesIDLabelsAllParams) (*LabelsResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ruleID", runtime.ParamLocationPath, params.RuleID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationRules/%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 := ioutil.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 + +} + +// PostNotificationRuleIDLabels calls the POST on /notificationRules/{ruleID}/labels +// Add a label to a notification rule +func (c *Client) PostNotificationRuleIDLabels(ctx context.Context, params *PostNotificationRuleIDLabelsAllParams) (*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, "ruleID", runtime.ParamLocationPath, params.RuleID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationRules/%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 := ioutil.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 + +} + +// DeleteNotificationRulesIDLabelsID calls the DELETE on /notificationRules/{ruleID}/labels/{labelID} +// Delete label from a notification rule +func (c *Client) DeleteNotificationRulesIDLabelsID(ctx context.Context, params *DeleteNotificationRulesIDLabelsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ruleID", runtime.ParamLocationPath, params.RuleID) + 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("./notificationRules/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetNotificationRulesIDQuery calls the GET on /notificationRules/{ruleID}/query +// Retrieve a notification rule query +func (c *Client) GetNotificationRulesIDQuery(ctx context.Context, params *GetNotificationRulesIDQueryAllParams) (*FluxResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ruleID", runtime.ParamLocationPath, params.RuleID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./notificationRules/%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 := ioutil.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 + +} + +// GetOrgs calls the GET on /orgs +// List organizations +func (c *Client) GetOrgs(ctx context.Context, params *GetOrgsParams) (*Organizations, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./orgs") + + 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 params.Descending != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "descending", runtime.ParamLocationQuery, *params.Descending); 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.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); 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.OrgID != nil { + + 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) + } + } + } + + } + + if params.UserID != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "userID", runtime.ParamLocationQuery, *params.UserID); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Organizations{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostOrgs calls the POST on /orgs +// Create an organization +func (c *Client) PostOrgs(ctx context.Context, params *PostOrgsAllParams) (*Organization, 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("./orgs") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Organization{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteOrgsID calls the DELETE on /orgs/{orgID} +// Delete an organization +func (c *Client) DeleteOrgsID(ctx context.Context, params *DeleteOrgsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./orgs/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetOrgsID calls the GET on /orgs/{orgID} +// Retrieve an organization +func (c *Client) GetOrgsID(ctx context.Context, params *GetOrgsIDAllParams) (*Organization, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./orgs/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Organization{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchOrgsID calls the PATCH on /orgs/{orgID} +// Update an organization +func (c *Client) PatchOrgsID(ctx context.Context, params *PatchOrgsIDAllParams) (*Organization, 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, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./orgs/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Organization{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetOrgsIDMembers calls the GET on /orgs/{orgID}/members +// List all members of an organization +func (c *Client) GetOrgsIDMembers(ctx context.Context, params *GetOrgsIDMembersAllParams) (*ResourceMembers, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./orgs/%s/members", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceMembers{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostOrgsIDMembers calls the POST on /orgs/{orgID}/members +// Add a member to an organization +func (c *Client) PostOrgsIDMembers(ctx context.Context, params *PostOrgsIDMembersAllParams) (*ResourceMember, 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, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./orgs/%s/members", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceMember{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteOrgsIDMembersID calls the DELETE on /orgs/{orgID}/members/{userID} +// Remove a member from an organization +func (c *Client) DeleteOrgsIDMembersID(ctx context.Context, params *DeleteOrgsIDMembersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./orgs/%s/members/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetOrgsIDOwners calls the GET on /orgs/{orgID}/owners +// List all owners of an organization +func (c *Client) GetOrgsIDOwners(ctx context.Context, params *GetOrgsIDOwnersAllParams) (*ResourceOwners, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./orgs/%s/owners", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceOwners{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostOrgsIDOwners calls the POST on /orgs/{orgID}/owners +// Add an owner to an organization +func (c *Client) PostOrgsIDOwners(ctx context.Context, params *PostOrgsIDOwnersAllParams) (*ResourceOwner, 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, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./orgs/%s/owners", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceOwner{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteOrgsIDOwnersID calls the DELETE on /orgs/{orgID}/owners/{userID} +// Remove an owner from an organization +func (c *Client) DeleteOrgsIDOwnersID(ctx context.Context, params *DeleteOrgsIDOwnersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./orgs/%s/owners/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetOrgsIDSecrets calls the GET on /orgs/{orgID}/secrets +// List all secret keys for an organization +func (c *Client) GetOrgsIDSecrets(ctx context.Context, params *GetOrgsIDSecretsAllParams) (*SecretKeysResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./orgs/%s/secrets", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SecretKeysResponse{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchOrgsIDSecrets calls the PATCH on /orgs/{orgID}/secrets +// Update secrets in an organization +func (c *Client) PatchOrgsIDSecrets(ctx context.Context, params *PatchOrgsIDSecretsAllParams) error { + var err error + var bodyReader io.Reader + buf, err := json.Marshal(params.Body) + if err != nil { + return err + } + bodyReader = bytes.NewReader(buf) + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./orgs/%s/secrets", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + req, err := http.NewRequest("PATCH", queryURL.String(), bodyReader) + if err != nil { + return 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 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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// PostOrgsIDSecrets calls the POST on /orgs/{orgID}/secrets/delete +// Delete secrets from an organization +func (c *Client) PostOrgsIDSecrets(ctx context.Context, params *PostOrgsIDSecretsAllParams) error { + var err error + var bodyReader io.Reader + buf, err := json.Marshal(params.Body) + if err != nil { + return err + } + bodyReader = bytes.NewReader(buf) + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./orgs/%s/secrets/delete", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + req, err := http.NewRequest("POST", queryURL.String(), bodyReader) + if err != nil { + return 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 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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// DeleteOrgsIDSecretsID calls the DELETE on /orgs/{orgID}/secrets/{secretID} +// Delete a secret from an organization +func (c *Client) DeleteOrgsIDSecretsID(ctx context.Context, params *DeleteOrgsIDSecretsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "orgID", runtime.ParamLocationPath, params.OrgID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "secretID", runtime.ParamLocationPath, params.SecretID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./orgs/%s/secrets/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetPing calls the GET on /ping +// Get the status and version of the instance +func (c *Client) GetPing(ctx context.Context) error { + var err error + + serverURL, err := url.Parse(c.Server) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./ping") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return err + } + + 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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// HeadPing calls the HEAD on /ping +// Get the status and version of the instance +func (c *Client) HeadPing(ctx context.Context) error { + var err error + + serverURL, err := url.Parse(c.Server) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./ping") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + req, err := http.NewRequest("HEAD", queryURL.String(), nil) + if err != nil { + return err + } + + 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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// PostQueryAnalyze calls the POST on /query/analyze +// Analyze a Flux query +func (c *Client) PostQueryAnalyze(ctx context.Context, params *PostQueryAnalyzeAllParams) (*AnalyzeQueryResponse, 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("./query/analyze") + + 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) + } + + if params.ContentType != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Content-Type", runtime.ParamLocationHeader, *params.ContentType) + if err != nil { + return nil, err + } + + req.Header.Set("Content-Type", headerParam1) + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AnalyzeQueryResponse{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostQueryAst calls the POST on /query/ast +// Generate a query Abstract Syntax Tree (AST) +func (c *Client) PostQueryAst(ctx context.Context, params *PostQueryAstAllParams) (*ASTResponse, 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("./query/ast") + + 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) + } + + if params.ContentType != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Content-Type", runtime.ParamLocationHeader, *params.ContentType) + if err != nil { + return nil, err + } + + req.Header.Set("Content-Type", headerParam1) + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ASTResponse{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetQuerySuggestions calls the GET on /query/suggestions +// Retrieve Flux query suggestions +func (c *Client) GetQuerySuggestions(ctx context.Context, params *GetQuerySuggestionsParams) (*FluxSuggestions, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./query/suggestions") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FluxSuggestions{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetQuerySuggestionsName calls the GET on /query/suggestions/{name} +// Retrieve a query suggestion for a branching suggestion +func (c *Client) GetQuerySuggestionsName(ctx context.Context, params *GetQuerySuggestionsNameAllParams) (*FluxSuggestion, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "name", runtime.ParamLocationPath, params.Name) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./query/suggestions/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FluxSuggestion{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetReady calls the GET on /ready +// Get the readiness of an instance at startup +func (c *Client) GetReady(ctx context.Context, params *GetReadyParams) (*Ready, error) { + var err error + + serverURL, err := url.Parse(c.Server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./ready") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Ready{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetRemoteConnections calls the GET on /remotes +// List all remote connections +func (c *Client) GetRemoteConnections(ctx context.Context, params *GetRemoteConnectionsParams) (*RemoteConnections, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./remotes") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + 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) + } + } + } + + if params.Name != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "name", runtime.ParamLocationQuery, *params.Name); 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.RemoteURL != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "remoteURL", runtime.ParamLocationQuery, *params.RemoteURL); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RemoteConnections{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostRemoteConnection calls the POST on /remotes +// Register a new remote connection +func (c *Client) PostRemoteConnection(ctx context.Context, params *PostRemoteConnectionAllParams) (*RemoteConnection, 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("./remotes") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RemoteConnection{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteRemoteConnectionByID calls the DELETE on /remotes/{remoteID} +// Delete a remote connection +func (c *Client) DeleteRemoteConnectionByID(ctx context.Context, params *DeleteRemoteConnectionByIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "remoteID", runtime.ParamLocationPath, params.RemoteID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./remotes/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetRemoteConnectionByID calls the GET on /remotes/{remoteID} +// Retrieve a remote connection +func (c *Client) GetRemoteConnectionByID(ctx context.Context, params *GetRemoteConnectionByIDAllParams) (*RemoteConnection, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "remoteID", runtime.ParamLocationPath, params.RemoteID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./remotes/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RemoteConnection{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchRemoteConnectionByID calls the PATCH on /remotes/{remoteID} +// Update a remote connection +func (c *Client) PatchRemoteConnectionByID(ctx context.Context, params *PatchRemoteConnectionByIDAllParams) (*RemoteConnection, 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, "remoteID", runtime.ParamLocationPath, params.RemoteID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./remotes/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RemoteConnection{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetReplications calls the GET on /replications +// List all replications +func (c *Client) GetReplications(ctx context.Context, params *GetReplicationsParams) (*Replications, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./replications") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + 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) + } + } + } + + if params.Name != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "name", runtime.ParamLocationQuery, *params.Name); 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.RemoteID != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "remoteID", runtime.ParamLocationQuery, *params.RemoteID); 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.LocalBucketID != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "localBucketID", runtime.ParamLocationQuery, *params.LocalBucketID); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Replications{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostReplication calls the POST on /replications +// Register a new replication +func (c *Client) PostReplication(ctx context.Context, params *PostReplicationAllParams) (*Replication, 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("./replications") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Validate != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "validate", runtime.ParamLocationQuery, *params.Validate); 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("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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Replication{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteReplicationByID calls the DELETE on /replications/{replicationID} +// Delete a replication +func (c *Client) DeleteReplicationByID(ctx context.Context, params *DeleteReplicationByIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "replicationID", runtime.ParamLocationPath, params.ReplicationID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./replications/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetReplicationByID calls the GET on /replications/{replicationID} +// Retrieve a replication +func (c *Client) GetReplicationByID(ctx context.Context, params *GetReplicationByIDAllParams) (*Replication, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "replicationID", runtime.ParamLocationPath, params.ReplicationID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./replications/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Replication{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchReplicationByID calls the PATCH on /replications/{replicationID} +// Update a replication +func (c *Client) PatchReplicationByID(ctx context.Context, params *PatchReplicationByIDAllParams) (*Replication, 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, "replicationID", runtime.ParamLocationPath, params.ReplicationID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./replications/%s", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Validate != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "validate", runtime.ParamLocationQuery, *params.Validate); 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("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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Replication{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostValidateReplicationByID calls the POST on /replications/{replicationID}/validate +// Validate a replication +func (c *Client) PostValidateReplicationByID(ctx context.Context, params *PostValidateReplicationByIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "replicationID", runtime.ParamLocationPath, params.ReplicationID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./replications/%s/validate", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + req, err := http.NewRequest("POST", 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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetResources calls the GET on /resources +// List all known resources +func (c *Client) GetResources(ctx context.Context, params *GetResourcesParams) (*[]string, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./resources") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &[]string{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostRestoreBucketMetadata calls the POST on /restore/bucketMetadata +// Create a new bucket pre-seeded with shard info from a backup. +func (c *Client) PostRestoreBucketMetadata(ctx context.Context, params *PostRestoreBucketMetadataAllParams) (*RestoredBucketMappings, 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("./restore/bucketMetadata") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RestoredBucketMappings{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetScrapers calls the GET on /scrapers +// List all scraper targets +func (c *Client) GetScrapers(ctx context.Context, params *GetScrapersParams) (*ScraperTargetResponses, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./scrapers") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Name != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "name", runtime.ParamLocationQuery, *params.Name); 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.Id != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "id", runtime.ParamLocationQuery, *params.Id); 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.OrgID != nil { + + 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) + } + } + } + + } + + if params.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ScraperTargetResponses{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostScrapers calls the POST on /scrapers +// Create a scraper target +func (c *Client) PostScrapers(ctx context.Context, params *PostScrapersAllParams) (*ScraperTargetResponse, 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("./scrapers") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ScraperTargetResponse{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteScrapersID calls the DELETE on /scrapers/{scraperTargetID} +// Delete a scraper target +func (c *Client) DeleteScrapersID(ctx context.Context, params *DeleteScrapersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "scraperTargetID", runtime.ParamLocationPath, params.ScraperTargetID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./scrapers/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetScrapersID calls the GET on /scrapers/{scraperTargetID} +// Retrieve a scraper target +func (c *Client) GetScrapersID(ctx context.Context, params *GetScrapersIDAllParams) (*ScraperTargetResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "scraperTargetID", runtime.ParamLocationPath, params.ScraperTargetID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./scrapers/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ScraperTargetResponse{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchScrapersID calls the PATCH on /scrapers/{scraperTargetID} +// Update a scraper target +func (c *Client) PatchScrapersID(ctx context.Context, params *PatchScrapersIDAllParams) (*ScraperTargetResponse, 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, "scraperTargetID", runtime.ParamLocationPath, params.ScraperTargetID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./scrapers/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ScraperTargetResponse{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetScrapersIDLabels calls the GET on /scrapers/{scraperTargetID}/labels +// List all labels for a scraper target +func (c *Client) GetScrapersIDLabels(ctx context.Context, params *GetScrapersIDLabelsAllParams) (*LabelsResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "scraperTargetID", runtime.ParamLocationPath, params.ScraperTargetID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./scrapers/%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 := ioutil.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 + +} + +// PostScrapersIDLabels calls the POST on /scrapers/{scraperTargetID}/labels +// Add a label to a scraper target +func (c *Client) PostScrapersIDLabels(ctx context.Context, params *PostScrapersIDLabelsAllParams) (*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, "scraperTargetID", runtime.ParamLocationPath, params.ScraperTargetID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./scrapers/%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 := ioutil.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 + +} + +// DeleteScrapersIDLabelsID calls the DELETE on /scrapers/{scraperTargetID}/labels/{labelID} +// Delete a label from a scraper target +func (c *Client) DeleteScrapersIDLabelsID(ctx context.Context, params *DeleteScrapersIDLabelsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "scraperTargetID", runtime.ParamLocationPath, params.ScraperTargetID) + 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("./scrapers/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetScrapersIDMembers calls the GET on /scrapers/{scraperTargetID}/members +// List all users with member privileges for a scraper target +func (c *Client) GetScrapersIDMembers(ctx context.Context, params *GetScrapersIDMembersAllParams) (*ResourceMembers, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "scraperTargetID", runtime.ParamLocationPath, params.ScraperTargetID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./scrapers/%s/members", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceMembers{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostScrapersIDMembers calls the POST on /scrapers/{scraperTargetID}/members +// Add a member to a scraper target +func (c *Client) PostScrapersIDMembers(ctx context.Context, params *PostScrapersIDMembersAllParams) (*ResourceMember, 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, "scraperTargetID", runtime.ParamLocationPath, params.ScraperTargetID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./scrapers/%s/members", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceMember{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteScrapersIDMembersID calls the DELETE on /scrapers/{scraperTargetID}/members/{userID} +// Remove a member from a scraper target +func (c *Client) DeleteScrapersIDMembersID(ctx context.Context, params *DeleteScrapersIDMembersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "scraperTargetID", runtime.ParamLocationPath, params.ScraperTargetID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./scrapers/%s/members/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetScrapersIDOwners calls the GET on /scrapers/{scraperTargetID}/owners +// List all owners of a scraper target +func (c *Client) GetScrapersIDOwners(ctx context.Context, params *GetScrapersIDOwnersAllParams) (*ResourceOwners, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "scraperTargetID", runtime.ParamLocationPath, params.ScraperTargetID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./scrapers/%s/owners", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceOwners{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostScrapersIDOwners calls the POST on /scrapers/{scraperTargetID}/owners +// Add an owner to a scraper target +func (c *Client) PostScrapersIDOwners(ctx context.Context, params *PostScrapersIDOwnersAllParams) (*ResourceOwner, 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, "scraperTargetID", runtime.ParamLocationPath, params.ScraperTargetID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./scrapers/%s/owners", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceOwner{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteScrapersIDOwnersID calls the DELETE on /scrapers/{scraperTargetID}/owners/{userID} +// Remove an owner from a scraper target +func (c *Client) DeleteScrapersIDOwnersID(ctx context.Context, params *DeleteScrapersIDOwnersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "scraperTargetID", runtime.ParamLocationPath, params.ScraperTargetID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./scrapers/%s/owners/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetSetup calls the GET on /setup +// Check if database has default user, org, bucket +func (c *Client) GetSetup(ctx context.Context, params *GetSetupParams) (*IsOnboarding, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./setup") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &IsOnboarding{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostSetup calls the POST on /setup +// Set up initial user, org and bucket +func (c *Client) PostSetup(ctx context.Context, params *PostSetupAllParams) (*OnboardingResponse, 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("./setup") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &OnboardingResponse{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostSignin calls the POST on /signin +// Create a user session. +func (c *Client) PostSignin(ctx context.Context, params *PostSigninParams) error { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./signin") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + req, err := http.NewRequest("POST", 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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// PostSignout calls the POST on /signout +// Expire the current UI session +func (c *Client) PostSignout(ctx context.Context, params *PostSignoutParams) error { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./signout") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + req, err := http.NewRequest("POST", 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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetSources calls the GET on /sources +// List all sources +func (c *Client) GetSources(ctx context.Context, params *GetSourcesParams) (*Sources, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./sources") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Sources{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostSources calls the POST on /sources +// Create a source +func (c *Client) PostSources(ctx context.Context, params *PostSourcesAllParams) (*Source, 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("./sources") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Source{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteSourcesID calls the DELETE on /sources/{sourceID} +// Delete a source +func (c *Client) DeleteSourcesID(ctx context.Context, params *DeleteSourcesIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "sourceID", runtime.ParamLocationPath, params.SourceID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./sources/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetSourcesID calls the GET on /sources/{sourceID} +// Retrieve a source +func (c *Client) GetSourcesID(ctx context.Context, params *GetSourcesIDAllParams) (*Source, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "sourceID", runtime.ParamLocationPath, params.SourceID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./sources/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Source{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchSourcesID calls the PATCH on /sources/{sourceID} +// Update a Source +func (c *Client) PatchSourcesID(ctx context.Context, params *PatchSourcesIDAllParams) (*Source, 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, "sourceID", runtime.ParamLocationPath, params.SourceID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./sources/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Source{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetSourcesIDBuckets calls the GET on /sources/{sourceID}/buckets +// Get buckets in a source +func (c *Client) GetSourcesIDBuckets(ctx context.Context, params *GetSourcesIDBucketsAllParams) (*Buckets, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "sourceID", runtime.ParamLocationPath, params.SourceID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./sources/%s/buckets", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Buckets{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetSourcesIDHealth calls the GET on /sources/{sourceID}/health +// Get the health of a source +func (c *Client) GetSourcesIDHealth(ctx context.Context, params *GetSourcesIDHealthAllParams) (*HealthCheck, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "sourceID", runtime.ParamLocationPath, params.SourceID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./sources/%s/health", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &HealthCheck{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// ListStacks calls the GET on /stacks +// List installed stacks +func (c *Client) ListStacks(ctx context.Context, params *ListStacksParams) (*struct { + Stacks *[]Stack `json:"stacks,omitempty"` +}, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./stacks") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + 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) + } + } + } + + if params.Name != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "name", runtime.ParamLocationQuery, *params.Name); 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.StackID != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "stackID", runtime.ParamLocationQuery, *params.StackID); 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 + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &struct { + Stacks *[]Stack `json:"stacks,omitempty"` + }{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// CreateStack calls the POST on /stacks +// Create a stack +func (c *Client) CreateStack(ctx context.Context, params *CreateStackAllParams) (*Stack, 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("./stacks") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Stack{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteStack calls the DELETE on /stacks/{stack_id} +// Delete a stack and associated resources +func (c *Client) DeleteStack(ctx context.Context, params *DeleteStackAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "stack_id", runtime.ParamLocationPath, params.StackId) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./stacks/%s", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "orgID", runtime.ParamLocationQuery, params.OrgID); err != nil { + return err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return err + } + + 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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// ReadStack calls the GET on /stacks/{stack_id} +// Retrieve a stack +func (c *Client) ReadStack(ctx context.Context, params *ReadStackAllParams) (*Stack, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "stack_id", runtime.ParamLocationPath, params.StackId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./stacks/%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 + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Stack{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// UpdateStack calls the PATCH on /stacks/{stack_id} +// Update a stack +func (c *Client) UpdateStack(ctx context.Context, params *UpdateStackAllParams) (*Stack, 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, "stack_id", runtime.ParamLocationPath, params.StackId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./stacks/%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") + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Stack{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// UninstallStack calls the POST on /stacks/{stack_id}/uninstall +// Uninstall a stack +func (c *Client) UninstallStack(ctx context.Context, params *UninstallStackAllParams) (*Stack, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "stack_id", runtime.ParamLocationPath, params.StackId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./stacks/%s/uninstall", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Stack{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetTasks calls the GET on /tasks +// List tasks +func (c *Client) GetTasks(ctx context.Context, params *GetTasksParams) (*Tasks, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Name != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "name", runtime.ParamLocationQuery, *params.Name); 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.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); 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.User != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "user", runtime.ParamLocationQuery, *params.User); 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.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); 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.OrgID != nil { + + 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) + } + } + } + + } + + if params.Status != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "status", runtime.ParamLocationQuery, *params.Status); 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 params.Type != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "type", runtime.ParamLocationQuery, *params.Type); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Tasks{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostTasks calls the POST on /tasks +// Create a task +func (c *Client) PostTasks(ctx context.Context, params *PostTasksAllParams) (*Task, 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("./tasks") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Task{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteTasksID calls the DELETE on /tasks/{taskID} +// Delete a task +func (c *Client) DeleteTasksID(ctx context.Context, params *DeleteTasksIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./tasks/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetTasksID calls the GET on /tasks/{taskID} +// Retrieve a task +func (c *Client) GetTasksID(ctx context.Context, params *GetTasksIDAllParams) (*Task, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Task{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchTasksID calls the PATCH on /tasks/{taskID} +// Update a task +func (c *Client) PatchTasksID(ctx context.Context, params *PatchTasksIDAllParams) (*Task, 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, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Task{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetTasksIDLabels calls the GET on /tasks/{taskID}/labels +// List labels for a task +func (c *Client) GetTasksIDLabels(ctx context.Context, params *GetTasksIDLabelsAllParams) (*LabelsResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%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 := ioutil.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 + +} + +// PostTasksIDLabels calls the POST on /tasks/{taskID}/labels +// Add a label to a task +func (c *Client) PostTasksIDLabels(ctx context.Context, params *PostTasksIDLabelsAllParams) (*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, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%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 := ioutil.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 + +} + +// DeleteTasksIDLabelsID calls the DELETE on /tasks/{taskID}/labels/{labelID} +// Delete a label from a task +func (c *Client) DeleteTasksIDLabelsID(ctx context.Context, params *DeleteTasksIDLabelsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + 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("./tasks/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetTasksIDLogs calls the GET on /tasks/{taskID}/logs +// Retrieve all logs for a task +func (c *Client) GetTasksIDLogs(ctx context.Context, params *GetTasksIDLogsAllParams) (*Logs, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%s/logs", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Logs{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetTasksIDMembers calls the GET on /tasks/{taskID}/members +// List all task members +func (c *Client) GetTasksIDMembers(ctx context.Context, params *GetTasksIDMembersAllParams) (*ResourceMembers, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%s/members", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceMembers{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostTasksIDMembers calls the POST on /tasks/{taskID}/members +// Add a member to a task +func (c *Client) PostTasksIDMembers(ctx context.Context, params *PostTasksIDMembersAllParams) (*ResourceMember, 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, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%s/members", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceMember{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteTasksIDMembersID calls the DELETE on /tasks/{taskID}/members/{userID} +// Remove a member from a task +func (c *Client) DeleteTasksIDMembersID(ctx context.Context, params *DeleteTasksIDMembersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./tasks/%s/members/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetTasksIDOwners calls the GET on /tasks/{taskID}/owners +// List all owners of a task +func (c *Client) GetTasksIDOwners(ctx context.Context, params *GetTasksIDOwnersAllParams) (*ResourceOwners, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%s/owners", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceOwners{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostTasksIDOwners calls the POST on /tasks/{taskID}/owners +// Add an owner for a task +func (c *Client) PostTasksIDOwners(ctx context.Context, params *PostTasksIDOwnersAllParams) (*ResourceOwner, 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, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%s/owners", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceOwner{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteTasksIDOwnersID calls the DELETE on /tasks/{taskID}/owners/{userID} +// Remove an owner from a task +func (c *Client) DeleteTasksIDOwnersID(ctx context.Context, params *DeleteTasksIDOwnersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./tasks/%s/owners/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetTasksIDRuns calls the GET on /tasks/{taskID}/runs +// List runs for a task +func (c *Client) GetTasksIDRuns(ctx context.Context, params *GetTasksIDRunsAllParams) (*Runs, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%s/runs", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); 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 params.AfterTime != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "afterTime", runtime.ParamLocationQuery, *params.AfterTime); 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.BeforeTime != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "beforeTime", runtime.ParamLocationQuery, *params.BeforeTime); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Runs{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostTasksIDRuns calls the POST on /tasks/{taskID}/runs +// Start a task run, overriding the schedule +func (c *Client) PostTasksIDRuns(ctx context.Context, params *PostTasksIDRunsAllParams) (*Run, 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, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%s/runs", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Run{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteTasksIDRunsID calls the DELETE on /tasks/{taskID}/runs/{runID} +// Cancel a running task +func (c *Client) DeleteTasksIDRunsID(ctx context.Context, params *DeleteTasksIDRunsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "runID", runtime.ParamLocationPath, params.RunID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./tasks/%s/runs/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetTasksIDRunsID calls the GET on /tasks/{taskID}/runs/{runID} +// Retrieve a run for a task. +func (c *Client) GetTasksIDRunsID(ctx context.Context, params *GetTasksIDRunsIDAllParams) (*Run, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "runID", runtime.ParamLocationPath, params.RunID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%s/runs/%s", pathParam0, pathParam1) + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Run{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetTasksIDRunsIDLogs calls the GET on /tasks/{taskID}/runs/{runID}/logs +// Retrieve all logs for a run +func (c *Client) GetTasksIDRunsIDLogs(ctx context.Context, params *GetTasksIDRunsIDLogsAllParams) (*Logs, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "runID", runtime.ParamLocationPath, params.RunID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%s/runs/%s/logs", pathParam0, pathParam1) + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Logs{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostTasksIDRunsIDRetry calls the POST on /tasks/{taskID}/runs/{runID}/retry +// Retry a task run +func (c *Client) PostTasksIDRunsIDRetry(ctx context.Context, params *PostTasksIDRunsIDRetryAllParams) (*Run, 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, "taskID", runtime.ParamLocationPath, params.TaskID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "runID", runtime.ParamLocationPath, params.RunID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./tasks/%s/runs/%s/retry", pathParam0, pathParam1) + + 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; charset=utf-8") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Run{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetTelegrafPlugins calls the GET on /telegraf/plugins +// List all Telegraf plugins +func (c *Client) GetTelegrafPlugins(ctx context.Context, params *GetTelegrafPluginsParams) (*TelegrafPlugins, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./telegraf/plugins") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Type != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "type", runtime.ParamLocationQuery, *params.Type); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &TelegrafPlugins{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetTelegrafs calls the GET on /telegrafs +// List all Telegraf configurations +func (c *Client) GetTelegrafs(ctx context.Context, params *GetTelegrafsParams) (*Telegrafs, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./telegrafs") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.OrgID != nil { + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Telegrafs{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostTelegrafs calls the POST on /telegrafs +// Create a Telegraf configuration +func (c *Client) PostTelegrafs(ctx context.Context, params *PostTelegrafsAllParams) (*Telegraf, 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("./telegrafs") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Telegraf{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteTelegrafsID calls the DELETE on /telegrafs/{telegrafID} +// Delete a Telegraf configuration +func (c *Client) DeleteTelegrafsID(ctx context.Context, params *DeleteTelegrafsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "telegrafID", runtime.ParamLocationPath, params.TelegrafID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./telegrafs/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetTelegrafsID calls the GET on /telegrafs/{telegrafID} +// Retrieve a Telegraf configuration +func (c *Client) GetTelegrafsID(ctx context.Context, params *GetTelegrafsIDAllParams) (*Telegraf, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "telegrafID", runtime.ParamLocationPath, params.TelegrafID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./telegrafs/%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) + } + + if params.Accept != nil { + var headerParam1 string + + headerParam1, err = runtime.StyleParamWithLocation("simple", false, "Accept", runtime.ParamLocationHeader, *params.Accept) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", headerParam1) + } + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return nil, err + } + bodyBytes, err := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Telegraf{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PutTelegrafsID calls the PUT on /telegrafs/{telegrafID} +// Update a Telegraf configuration +func (c *Client) PutTelegrafsID(ctx context.Context, params *PutTelegrafsIDAllParams) (*Telegraf, 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, "telegrafID", runtime.ParamLocationPath, params.TelegrafID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./telegrafs/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Telegraf{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetTelegrafsIDLabels calls the GET on /telegrafs/{telegrafID}/labels +// List all labels for a Telegraf config +func (c *Client) GetTelegrafsIDLabels(ctx context.Context, params *GetTelegrafsIDLabelsAllParams) (*LabelsResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "telegrafID", runtime.ParamLocationPath, params.TelegrafID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./telegrafs/%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 := ioutil.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 + +} + +// PostTelegrafsIDLabels calls the POST on /telegrafs/{telegrafID}/labels +// Add a label to a Telegraf config +func (c *Client) PostTelegrafsIDLabels(ctx context.Context, params *PostTelegrafsIDLabelsAllParams) (*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, "telegrafID", runtime.ParamLocationPath, params.TelegrafID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./telegrafs/%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 := ioutil.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 + +} + +// DeleteTelegrafsIDLabelsID calls the DELETE on /telegrafs/{telegrafID}/labels/{labelID} +// Delete a label from a Telegraf config +func (c *Client) DeleteTelegrafsIDLabelsID(ctx context.Context, params *DeleteTelegrafsIDLabelsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "telegrafID", runtime.ParamLocationPath, params.TelegrafID) + 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("./telegrafs/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetTelegrafsIDMembers calls the GET on /telegrafs/{telegrafID}/members +// List all users with member privileges for a Telegraf config +func (c *Client) GetTelegrafsIDMembers(ctx context.Context, params *GetTelegrafsIDMembersAllParams) (*ResourceMembers, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "telegrafID", runtime.ParamLocationPath, params.TelegrafID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./telegrafs/%s/members", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceMembers{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostTelegrafsIDMembers calls the POST on /telegrafs/{telegrafID}/members +// Add a member to a Telegraf config +func (c *Client) PostTelegrafsIDMembers(ctx context.Context, params *PostTelegrafsIDMembersAllParams) (*ResourceMember, 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, "telegrafID", runtime.ParamLocationPath, params.TelegrafID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./telegrafs/%s/members", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceMember{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteTelegrafsIDMembersID calls the DELETE on /telegrafs/{telegrafID}/members/{userID} +// Remove a member from a Telegraf config +func (c *Client) DeleteTelegrafsIDMembersID(ctx context.Context, params *DeleteTelegrafsIDMembersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "telegrafID", runtime.ParamLocationPath, params.TelegrafID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./telegrafs/%s/members/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetTelegrafsIDOwners calls the GET on /telegrafs/{telegrafID}/owners +// List all owners of a Telegraf configuration +func (c *Client) GetTelegrafsIDOwners(ctx context.Context, params *GetTelegrafsIDOwnersAllParams) (*ResourceOwners, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "telegrafID", runtime.ParamLocationPath, params.TelegrafID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./telegrafs/%s/owners", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceOwners{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostTelegrafsIDOwners calls the POST on /telegrafs/{telegrafID}/owners +// Add an owner to a Telegraf configuration +func (c *Client) PostTelegrafsIDOwners(ctx context.Context, params *PostTelegrafsIDOwnersAllParams) (*ResourceOwner, 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, "telegrafID", runtime.ParamLocationPath, params.TelegrafID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./telegrafs/%s/owners", 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResourceOwner{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteTelegrafsIDOwnersID calls the DELETE on /telegrafs/{telegrafID}/owners/{userID} +// Remove an owner from a Telegraf config +func (c *Client) DeleteTelegrafsIDOwnersID(ctx context.Context, params *DeleteTelegrafsIDOwnersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "telegrafID", runtime.ParamLocationPath, params.TelegrafID) + if err != nil { + return err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./telegrafs/%s/owners/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// ExportTemplate calls the POST on /templates/export +// Export a new template +func (c *Client) ExportTemplate(ctx context.Context, params *ExportTemplateAllParams) (*Template, 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("./templates/export") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Template{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetUsers calls the GET on /users +// List users +func (c *Client) GetUsers(ctx context.Context, params *GetUsersParams) (*Users, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./users") + + 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 params.After != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "after", runtime.ParamLocationQuery, *params.After); 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.Name != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "name", runtime.ParamLocationQuery, *params.Name); 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.Id != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "id", runtime.ParamLocationQuery, *params.Id); 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Users{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostUsers calls the POST on /users +// Create a user +func (c *Client) PostUsers(ctx context.Context, params *PostUsersAllParams) (*UserResponse, 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("./users") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UserResponse{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteUsersID calls the DELETE on /users/{userID} +// Delete a user +func (c *Client) DeleteUsersID(ctx context.Context, params *DeleteUsersIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./users/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetUsersID calls the GET on /users/{userID} +// Retrieve a user +func (c *Client) GetUsersID(ctx context.Context, params *GetUsersIDAllParams) (*UserResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./users/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UserResponse{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchUsersID calls the PATCH on /users/{userID} +// Update a user +func (c *Client) PatchUsersID(ctx context.Context, params *PatchUsersIDAllParams) (*UserResponse, 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, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./users/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UserResponse{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostUsersIDPassword calls the POST on /users/{userID}/password +// Update a password +func (c *Client) PostUsersIDPassword(ctx context.Context, params *PostUsersIDPasswordAllParams) error { + var err error + var bodyReader io.Reader + buf, err := json.Marshal(params.Body) + if err != nil { + return err + } + bodyReader = bytes.NewReader(buf) + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, params.UserID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./users/%s/password", pathParam0) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return err + } + + req, err := http.NewRequest("POST", queryURL.String(), bodyReader) + if err != nil { + return 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 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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetVariables calls the GET on /variables +// List all variables +func (c *Client) GetVariables(ctx context.Context, params *GetVariablesParams) (*Variables, error) { + var err error + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./variables") + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Org != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "org", runtime.ParamLocationQuery, *params.Org); 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.OrgID != nil { + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Variables{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PostVariables calls the POST on /variables +// Create a variable +func (c *Client) PostVariables(ctx context.Context, params *PostVariablesAllParams) (*Variable, 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("./variables") + + 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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Variable{} + + switch rsp.StatusCode { + case 201: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// DeleteVariablesID calls the DELETE on /variables/{variableID} +// Delete a variable +func (c *Client) DeleteVariablesID(ctx context.Context, params *DeleteVariablesIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "variableID", runtime.ParamLocationPath, params.VariableID) + if err != nil { + return err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return err + } + + operationPath := fmt.Sprintf("./variables/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +// GetVariablesID calls the GET on /variables/{variableID} +// Retrieve a variable +func (c *Client) GetVariablesID(ctx context.Context, params *GetVariablesIDAllParams) (*Variable, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "variableID", runtime.ParamLocationPath, params.VariableID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./variables/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Variable{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PatchVariablesID calls the PATCH on /variables/{variableID} +// Update a variable +func (c *Client) PatchVariablesID(ctx context.Context, params *PatchVariablesIDAllParams) (*Variable, 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, "variableID", runtime.ParamLocationPath, params.VariableID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./variables/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Variable{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// PutVariablesID calls the PUT on /variables/{variableID} +// Replace a variable +func (c *Client) PutVariablesID(ctx context.Context, params *PutVariablesIDAllParams) (*Variable, 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, "variableID", runtime.ParamLocationPath, params.VariableID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./variables/%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 := ioutil.ReadAll(rsp.Body) + + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &Variable{} + + switch rsp.StatusCode { + case 200: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil + +} + +// GetVariablesIDLabels calls the GET on /variables/{variableID}/labels +// List all labels for a variable +func (c *Client) GetVariablesIDLabels(ctx context.Context, params *GetVariablesIDLabelsAllParams) (*LabelsResponse, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "variableID", runtime.ParamLocationPath, params.VariableID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./variables/%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 := ioutil.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 + +} + +// PostVariablesIDLabels calls the POST on /variables/{variableID}/labels +// Add a label to a variable +func (c *Client) PostVariablesIDLabels(ctx context.Context, params *PostVariablesIDLabelsAllParams) (*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, "variableID", runtime.ParamLocationPath, params.VariableID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(c.APIEndpoint) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("./variables/%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 := ioutil.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 + +} + +// DeleteVariablesIDLabelsID calls the DELETE on /variables/{variableID}/labels/{labelID} +// Delete a label from a variable +func (c *Client) DeleteVariablesIDLabelsID(ctx context.Context, params *DeleteVariablesIDLabelsIDAllParams) error { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "variableID", runtime.ParamLocationPath, params.VariableID) + 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("./variables/%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 := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil + +} + +/* + + */ diff --git a/influxclient/model/oss.yml b/influxclient/model/oss.yml new file mode 100644 index 00000000..bb966ba6 --- /dev/null +++ b/influxclient/model/oss.yml @@ -0,0 +1,17582 @@ +openapi: 3.0.0 +info: + title: InfluxDB OSS API Service + version: 2.0.0 + description: | + The InfluxDB v2 API provides a programmatic interface for all interactions with InfluxDB. Access the InfluxDB API using the `/api/v2/` endpoint. +servers: + - url: /api/v2 +tags: + - name: Authorizations + description: | + Create and manage _API tokens_. + An _authorization_ contains a list of `read` and `write` + permissions for organization resources and provides an API token for authentication. + An authorization belongs to an organization and only contains permissions for that organization. + + An authorization is only visible to the user that created it. + Optionally, when creating an authorization, you can scope it to a specific user. + A _user session_ carries all the permissions granted by all the user's authorizations. + To create a user session, use the [`POST /api/v2/signin`](#operation/PostSignin) endpoint. + + ### Related endpoints + + - [Signin](#tag/Signin) + - [Signout](#tag/Signout) + + ### Related guides + + - [Authorize API requests](https://docs.influxdata.com/influxdb/v2.3/api-guide/api_intro/#authentication). + - [Manage API tokens](https://docs.influxdata.com/influxdb/v2.3/security/tokens/). + - [Assign a token to a specific user](https://docs.influxdata.com/influxdb/v2.3/security/tokens/create-token/). + - name: Buckets + description: | + Store your data in InfluxDB [buckets](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#bucket). + A bucket is a named location where time series data is stored. All buckets + have a [retention period](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#retention-period), + a duration of time that each data point persists. InfluxDB drops all + points with timestamps older than the bucket’s retention period. + A bucket belongs to an organization. + + ### Related guides + + - [Manage buckets](https://docs.influxdata.com/influxdb/v2.3/organizations/buckets/) + - name: Debug + description: | + Generate profiling and trace reports. + + Use routes under `/debug/pprof` to analyze the Go runtime of InfluxDB. + These endpoints generate [Go runtime profiles](https://pkg.go.dev/runtime/pprof) + and **trace** reports. + **Profiles** are collections of stack traces that show call sequences + leading to instances of a particular event, such as allocation. + + For more information about **pprof profile** and **trace** reports, + see the following resources: + - [Google pprof tool](https://github.com/google/pprof) + - [Golang diagnostics](https://go.dev/doc/diagnostics) + - name: Delete + description: | + Delete data from an InfluxDB bucket. + - name: Query + description: | + Retrieve data, analyze queries, and get query suggestions. + - name: Tasks + description: | + Process and analyze your data with tasks in the InfluxDB task engine. + With tasks, you can schedule Flux scripts to query, analyze, modify, and act on data. + + Use the `/api/v2/tasks` endpoints to create and manage tasks, retry task runs, and retrieve run logs. + + #### Related guides + + - [Get started with tasks](https://docs.influxdata.com/influxdb/v2.3/process-data/get-started/) + - [Common data processing tasks](https://docs.influxdata.com/influxdb/v2.3/process-data/common-tasks/) + - name: Templates + description: | + Export and apply InfluxDB **templates**. + Manage **stacks** of templated InfluxDB resources. + + InfluxDB templates are prepackaged configurations for + everything from dashboards and Telegraf to notifications and alerts. + Use InfluxDB templates to quickly configure a fresh instance of InfluxDB, + back up your dashboard configuration, or share your configuration with the + InfluxData community. + + Use the `/api/v2/templates` endpoints to export templates and apply templates. + + **InfluxDB stacks** are stateful InfluxDB templates that let you + add, update, and remove installed template resources over time, avoid duplicating + resources when applying the same or similar templates more than once, and + apply changes to distributed instances of InfluxDB OSS or InfluxDB Cloud. + + Use the `/api/v2/stacks` endpoints to manage installed template resources. + + #### Related guides + + - [InfluxDB stacks](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/stacks/) + - [InfluxDB templates](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/) + - name: Write + description: | + Write time series data to buckets. + - name: Authentication + description: | + Use one of the following schemes to authenticate to the InfluxDB API: + + - [Token authentication](#section/Authentication/TokenAuthentication) + - [Basic authentication](#section/Authentication/BasicAuthentication) + - [Querystring authentication](#section/Authentication/QuerystringAuthentication) + + x-traitTag: true + - name: Quick start + x-traitTag: true + description: | + See the [**API Quick Start**](https://docs.influxdata.com/influxdb/v2.3/api-guide/api_intro/) + to get up and running authenticating with tokens, writing to buckets, and querying data. + + [**InfluxDB API client libraries**](https://docs.influxdata.com/influxdb/v2.3/api-guide/client-libraries/) + are available for popular languages and ready to import into your application. + - name: Common parameters + x-traitTag: true + description: | + Many InfluxDB API endpoints require parameters to specify resources--for example, + writing to a **bucket** in an **organization**. + + ### Common query parameters + + | Query parameter | Value type | Description | + |:------------------------ |:--------------------- |:-------------------------------------------| + | `bucket` | string | The bucket name or ID ([find your bucket](https://docs.influxdata.com/influxdb/v2.3/organizations/buckets/view-buckets/). | + | `bucketID` | string | The bucket ID ([find your bucket](https://docs.influxdata.com/influxdb/v2.3/organizations/buckets/view-buckets/). | + | `org` | string | The organization name or ID ([find your organization](https://docs.influxdata.com/influxdb/v2.3/organizations/view-orgs/). | + | `orgID` | 16-byte string | The organization ID ([find your organization](https://docs.influxdata.com/influxdb/v2.3/organizations/view-orgs/). | + - name: Headers + x-traitTag: true + description: | + InfluxDB API endpoints use standard HTTP request and response headers. + + **Note**: Not all operations support all headers. + + ### Request headers + + | Header | Value type | Description | + |:------------------------ |:--------------------- |:-------------------------------------------| + | `Accept` | string | The content type that the client can understand. | + | `Authorization` | string | The authorization scheme and credential. | + | `Content-Encoding` | string | The compression applied to the line protocol in the request payload. | + | `Content-Length` | integer | The size of the entity-body, in bytes, sent to the database. | + | `Content-Type` | string | The format of the data in the request body. | + - name: Response codes + x-traitTag: true + description: | + InfluxDB API endpoints use standard HTTP status codes for success and failure responses. + The response body may include additional details. + For details about a specific operation's response, + see **Responses** and **Response Samples** for that operation. + + API operations may return the following HTTP status codes: + + |  Code  | Status | Description | + |:-----------:|:------------------------ |:--------------------- | + | `200` | Success | | + | `204` | No content | For a `POST` request, `204` indicates that InfluxDB accepted the request and request data is valid. Asynchronous operations, such as `write`, might not have completed yet. | + | `400` | Bad request | May indicate one of the following: | + | `401` | Unauthorized | May indicate one of the following: | + | `404` | Not found | Requested resource was not found. `message` in the response body provides details about the requested resource. | + | `413` | Request entity too large | Request payload exceeds the size limit. | + | `422` | Unprocessable entity | Request data is invalid. `code` and `message` in the response body provide details about the problem. | + | `429` | Too many requests | API token is temporarily over the request quota. The `Retry-After` header describes when to try the request again. | + | `500` | Internal server error | | + | `503` | Service unavailable | Server is temporarily unavailable to process the request. The `Retry-After` header describes when to try the request again. | +x-tagGroups: + - name: Overview + tags: + - Quick start + - Authentication + - Headers + - Response codes + - name: Popular endpoints + tags: + - Data I/O endpoints + - Security and access endpoints + - System information endpoints + - name: All endpoints + tags: [] +paths: + /signin: + post: + operationId: PostSignin + summary: Create a user session. + description: 'Authenticates ***Basic Auth*** credentials for a user. If successful, creates a new UI session for the user.' + tags: + - Signin + security: + - BasicAuthentication: [] + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '204': + description: Success. User authenticated. + '401': + description: Unauthorized access. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '403': + description: User account is disabled. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unsuccessful authentication. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /signout: + post: + operationId: PostSignout + summary: Expire the current UI session + tags: + - Signout + description: Expires the current UI session for the user. + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '204': + description: Session successfully expired + '401': + description: Unauthorized access + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unsuccessful session expiry + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /ping: + get: + operationId: GetPing + summary: Get the status and version of the instance + description: Returns the status and InfluxDB version of the instance. + servers: + - url: '' + tags: + - Ping + - System information endpoints + responses: + '204': + description: | + OK. + Headers contain InfluxDB version information. + headers: + X-Influxdb-Build: + schema: + type: string + description: The type of InfluxDB build. + X-Influxdb-Version: + schema: + type: integer + description: The version of InfluxDB. + head: + operationId: HeadPing + summary: Get the status and version of the instance + description: Returns the status and InfluxDB version of the instance. + servers: + - url: '' + tags: + - Ping + responses: + '204': + description: | + OK. + Headers contain InfluxDB version information. + headers: + X-Influxdb-Build: + schema: + type: string + description: The type of InfluxDB build. + X-Influxdb-Version: + schema: + type: integer + description: The version of InfluxDB. + /: + get: + operationId: GetRoutes + summary: List all top level routes + tags: + - Routes + - System information endpoints + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + default: + description: All routes + content: + application/json: + schema: + $ref: '#/components/schemas/Routes' + /dbrps: + get: + operationId: GetDBRPs + tags: + - DBRPs + summary: List database retention policy mappings + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: orgID + description: Specifies the organization ID to filter on + schema: + type: string + - in: query + name: org + description: Specifies the organization name to filter on + schema: + type: string + - in: query + name: id + description: Specifies the mapping ID to filter on + schema: + type: string + - in: query + name: bucketID + description: Specifies the bucket ID to filter on + schema: + type: string + - in: query + name: default + description: Specifies filtering on default + schema: + type: boolean + - in: query + name: db + description: Specifies the database to filter on + schema: + type: string + - in: query + name: rp + description: Specifies the retention policy to filter on + schema: + type: string + responses: + '200': + description: Success. Returns a list of database retention policy mappings. + content: + application/json: + schema: + $ref: '#/components/schemas/DBRPs' + '400': + description: Bad request. The request has one or more invalid parameters. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostDBRP + tags: + - DBRPs + summary: Add a database retention policy mapping + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: The database retention policy mapping to add + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/DBRPCreate' + responses: + '201': + description: Created. Returns the created database retention policy mapping. + content: + application/json: + schema: + $ref: '#/components/schemas/DBRP' + '400': + description: Bad request. The mapping in the request has one or more invalid IDs. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/dbrps/{dbrpID}': + get: + operationId: GetDBRPsID + tags: + - DBRPs + summary: Retrieve a database retention policy mapping + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: orgID + description: Specifies the organization ID of the mapping + schema: + type: string + - in: query + name: org + description: Specifies the organization name of the mapping + schema: + type: string + - in: path + name: dbrpID + schema: + type: string + required: true + description: The database retention policy mapping ID + responses: + '200': + description: The database retention policy requested + content: + application/json: + schema: + $ref: '#/components/schemas/DBRPGet' + '400': + description: if any of the IDs passed is invalid + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + operationId: PatchDBRPID + tags: + - DBRPs + summary: Update a database retention policy mapping + requestBody: + description: Database retention policy update to apply + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/DBRPUpdate' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: orgID + description: Specifies the organization ID of the mapping + schema: + type: string + - in: query + name: org + description: Specifies the organization name of the mapping + schema: + type: string + - in: path + name: dbrpID + schema: + type: string + required: true + description: The database retention policy mapping. + responses: + '200': + description: An updated mapping + content: + application/json: + schema: + $ref: '#/components/schemas/DBRPGet' + '400': + description: if any of the IDs passed is invalid + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '404': + description: The mapping was not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + operationId: DeleteDBRPID + tags: + - DBRPs + summary: Delete a database retention policy + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: orgID + description: Specifies the organization ID of the mapping + schema: + type: string + - in: query + name: org + description: Specifies the organization name of the mapping + schema: + type: string + - in: path + name: dbrpID + schema: + type: string + required: true + description: The database retention policy mapping + responses: + '204': + description: Delete has been accepted + '400': + description: if any of the IDs passed is invalid + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /telegraf/plugins: + get: + operationId: GetTelegrafPlugins + tags: + - Telegraf Plugins + summary: List all Telegraf plugins + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: type + description: The type of plugin desired. + schema: + type: string + responses: + '200': + description: A list of Telegraf plugins. + content: + application/json: + schema: + $ref: '#/components/schemas/TelegrafPlugins' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /telegrafs: + get: + operationId: GetTelegrafs + tags: + - Telegrafs + summary: List all Telegraf configurations + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: orgID + description: The organization ID the Telegraf config belongs to. + schema: + type: string + responses: + '200': + description: A list of Telegraf configurations + content: + application/json: + schema: + $ref: '#/components/schemas/Telegrafs' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostTelegrafs + tags: + - Telegrafs + summary: Create a Telegraf configuration + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: Telegraf configuration to create + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/TelegrafPluginRequest' + responses: + '201': + description: Telegraf configuration created + content: + application/json: + schema: + $ref: '#/components/schemas/Telegraf' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/telegrafs/{telegrafID}': + get: + operationId: GetTelegrafsID + tags: + - Telegrafs + summary: Retrieve a Telegraf configuration + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf configuration ID. + - in: header + name: Accept + required: false + schema: + type: string + default: application/toml + enum: + - application/toml + - application/json + - application/octet-stream + responses: + '200': + description: Telegraf configuration details + content: + application/toml: + example: |- + [agent] + interval = "10s" + schema: + type: string + application/json: + schema: + $ref: '#/components/schemas/Telegraf' + application/octet-stream: + example: |- + [agent] + interval = "10s" + schema: + type: string + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + put: + operationId: PutTelegrafsID + tags: + - Telegrafs + summary: Update a Telegraf configuration + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + requestBody: + description: Telegraf configuration update to apply + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/TelegrafPluginRequest' + responses: + '200': + description: An updated Telegraf configurations + content: + application/json: + schema: + $ref: '#/components/schemas/Telegraf' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + operationId: DeleteTelegrafsID + tags: + - Telegrafs + summary: Delete a Telegraf configuration + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf configuration ID. + responses: + '204': + description: Delete has been accepted + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/telegrafs/{telegrafID}/labels': + get: + operationId: GetTelegrafsIDLabels + tags: + - Telegrafs + summary: List all labels for a Telegraf config + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + responses: + '200': + description: A list of all labels for a Telegraf config + content: + application/json: + schema: + $ref: '#/components/schemas/LabelsResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostTelegrafsIDLabels + tags: + - Telegrafs + summary: Add a label to a Telegraf config + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/LabelMapping' + responses: + '201': + description: The label added to the Telegraf config + content: + application/json: + schema: + $ref: '#/components/schemas/LabelResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/telegrafs/{telegrafID}/labels/{labelID}': + delete: + operationId: DeleteTelegrafsIDLabelsID + tags: + - Telegrafs + summary: Delete a label from a Telegraf config + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The label ID. + responses: + '204': + description: Delete has been accepted + '404': + description: Telegraf config not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/telegrafs/{telegrafID}/members': + get: + operationId: GetTelegrafsIDMembers + tags: + - Telegrafs + summary: List all users with member privileges for a Telegraf config + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + responses: + '200': + description: A list of Telegraf config members + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceMembers' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostTelegrafsIDMembers + tags: + - Telegrafs + summary: Add a member to a Telegraf config + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + requestBody: + description: User to add as member + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddResourceMemberRequestBody' + responses: + '201': + description: Member added to Telegraf config + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceMember' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/telegrafs/{telegrafID}/members/{userID}': + delete: + operationId: DeleteTelegrafsIDMembersID + tags: + - Telegrafs + summary: Remove a member from a Telegraf config + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the member to remove. + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + responses: + '204': + description: Member removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/telegrafs/{telegrafID}/owners': + get: + operationId: GetTelegrafsIDOwners + tags: + - Telegrafs + summary: List all owners of a Telegraf configuration + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf configuration ID. + responses: + '200': + description: Returns Telegraf configuration owners as a ResourceOwners list + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceOwners' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostTelegrafsIDOwners + tags: + - Telegrafs + summary: Add an owner to a Telegraf configuration + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf configuration ID. + requestBody: + description: User to add as owner + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddResourceMemberRequestBody' + responses: + '201': + description: Telegraf configuration owner was added. Returns a ResourceOwner that references the User. + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceOwner' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/telegrafs/{telegrafID}/owners/{userID}': + delete: + operationId: DeleteTelegrafsIDOwnersID + tags: + - Telegrafs + summary: Remove an owner from a Telegraf config + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the owner to remove. + - in: path + name: telegrafID + schema: + type: string + required: true + description: The Telegraf config ID. + responses: + '204': + description: Owner removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/variables/{variableID}/labels': + get: + operationId: GetVariablesIDLabels + tags: + - Variables + summary: List all labels for a variable + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: variableID + schema: + type: string + required: true + description: The variable ID. + responses: + '200': + description: A list of all labels for a variable + content: + application/json: + schema: + $ref: '#/components/schemas/LabelsResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostVariablesIDLabels + tags: + - Variables + summary: Add a label to a variable + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: variableID + schema: + type: string + required: true + description: The variable ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/LabelMapping' + responses: + '201': + description: The newly added label + content: + application/json: + schema: + $ref: '#/components/schemas/LabelResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/variables/{variableID}/labels/{labelID}': + delete: + operationId: DeleteVariablesIDLabelsID + tags: + - Variables + summary: Delete a label from a variable + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: variableID + schema: + type: string + required: true + description: The variable ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The label ID to delete. + responses: + '204': + description: Delete has been accepted + '404': + description: Variable not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /write: + post: + operationId: PostWrite + tags: + - Data I/O endpoints + - Write + summary: Write data + description: | + Writes data to a bucket. + + Use this endpoint to send data in [line protocol](https://docs.influxdata.com/influxdb/v2.3/reference/syntax/line-protocol/) format to InfluxDB. + + #### InfluxDB Cloud + + - Takes the following steps when you send a write request: + + 1. Validates the request and queues the write. + 2. If the write is queued, responds with an HTTP `204` status code. + 3. Handles the write asynchronously and reaches eventual consistency. + + An HTTP `2xx` status code acknowledges that the write or delete is queued. + To ensure that InfluxDB Cloud handles writes and deletes in the order you request them, + wait for a response before you send the next request. + + Because writes are asynchronous, data might not yet be written + when you receive the response. + + #### InfluxDB OSS + + - Validates the request, handles the write synchronously, + and then responds with success or failure. + - If all points were written successfully, responds with HTTP `204` status code; + otherwise, returns the first line that failed. + + #### Required permissions + + - `write-buckets` or `write-bucket BUCKET_ID`. + + `BUCKET_ID` is the ID of the destination bucket. + + #### Rate limits (with InfluxDB Cloud) + + `write` rate limits apply. + For more information, see [limits and adjustable quotas](https://docs.influxdata.com/influxdb/cloud/account-management/limits/). + + #### Related guides + + - [Write data with the InfluxDB API](https://docs.influxdata.com/influxdb/v2.3/write-data/developer-tools/api). + - [Optimize writes to InfluxDB](https://docs.influxdata.com/influxdb/v2.3/write-data/best-practices/optimize-writes/). + - [Troubleshoot issues writing data](https://docs.influxdata.com/influxdb/v2.3/write-data/troubleshoot/) + requestBody: + description: | + Data in line protocol format. + + To send compressed data, do the following: + + 1. Use [GZIP](https://www.gzip.org/) to compress the line protocol data. + 2. In your request, send the compressed data and the + `Content-Encoding: gzip` header. + + #### Related guides + + - [Best practices for optimizing writes](https://docs.influxdata.com/influxdb/v2.3/write-data/best-practices/optimize-writes/). + required: true + content: + text/plain: + schema: + type: string + format: byte + examples: + plain-utf8: + value: | + airSensors,sensor_id=TLM0201 temperature=73.97038159354763,humidity=35.23103248356096,co=0.48445310567793615 1630424257000000000 + airSensors,sensor_id=TLM0202 temperature=75.30007505999716,humidity=35.651929918691714,co=0.5141876544505826 1630424257000000000 + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: header + name: Content-Encoding + description: | + The compression applied to the line protocol in the request payload. + To send a GZIP payload, pass `Content-Encoding: gzip` header. + schema: + type: string + description: | + Content coding. + Use `gzip` for compressed data or `identity` for unmodified, uncompressed data. + default: identity + enum: + - gzip + - identity + - in: header + name: Content-Type + description: | + The format of the data in the request body. + To send a line protocol payload, pass `Content-Type: text/plain; charset=utf-8`. + schema: + type: string + description: | + `text/plain` is the content type for line protocol. `UTF-8` is the default character set. + default: text/plain; charset=utf-8 + enum: + - text/plain + - text/plain; charset=utf-8 + - in: header + name: Content-Length + description: | + The size of the entity-body, in bytes, sent to InfluxDB. + If the length is greater than the `max body` configuration option, + the server responds with status code `413`. + schema: + type: integer + description: The length in decimal number of octets. + - in: header + name: Accept + description: | + The content type that the client can understand. + Writes only return a response body if they fail--for example, + due to a formatting problem or quota limit. + + #### InfluxDB Cloud + + - Returns only `application/json` for format and limit errors. + - Returns only `text/html` for some quota limit errors. + + #### InfluxDB OSS + + - Returns only `application/json` for format and limit errors. + + #### Related guides + - [Troubleshoot issues writing data](https://docs.influxdata.com/influxdb/v2.3/write-data/troubleshoot/). + schema: + type: string + description: Error content type. + default: application/json + enum: + - application/json + - in: query + name: org + description: | + The destination organization for writes. + InfluxDB writes all points in the batch to this organization. + If you pass both `orgID` and `org`, they must both be valid. + + #### InfluxDB Cloud + + - Doesn't require `org` or `orgID`. + - Writes to the bucket in the organization associated with the authorization (API token). + + #### InfluxDB OSS + + - Requires either `org` or `orgID`. + - InfluxDB writes all points in the batch to this organization. + required: true + schema: + type: string + description: The organization name or ID. + - in: query + name: orgID + description: | + The ID of the destination organization for writes. + If you pass both `orgID` and `org`, they must both be valid. + + #### InfluxDB Cloud + + - Doesn't require `org` or `orgID`. + - Writes to the bucket in the organization associated with the authorization (API token). + + + #### InfluxDB OSS + + - Requires either `org` or `orgID`. + - InfluxDB writes all points in the batch to this organization. + schema: + type: string + - in: query + name: bucket + description: | + The destination bucket for writes. + InfluxDB writes all points in the batch to this bucket. + required: true + schema: + type: string + description: The bucket name or ID. + - in: query + name: precision + description: The precision for unix timestamps in the line protocol batch. + schema: + $ref: '#/components/schemas/WritePrecision' + responses: + '204': + description: | + Success. + + #### InfluxDB Cloud + + - Validated and queued the request. + - Handles the write asynchronously - the write might not have completed yet. + + #### InfluxDB OSS + + - Successfully wrote all points in the batch. + + #### Related guides + + - [How to check for write errors](https://docs.influxdata.com/influxdb/v2.3/write-data/troubleshoot/). + '400': + description: | + Bad request. The response body contains detail about the error. + + InfluxDB returns this error if the line protocol data in the request is malformed. + The response body contains the first malformed line in the data, and indicates what was expected. + For partial writes, the number of points written and the number of points rejected are also included. + For more information, check the `rejected_points` measurement in your `_monitoring` bucket. + + #### InfluxDB Cloud + + - Returns this error for bucket schema conflicts. + + #### InfluxDB OSS + + - Returns this error if `org` or `orgID` doesn't match an organization. + content: + application/json: + schema: + $ref: '#/components/schemas/LineProtocolError' + examples: + measurementSchemaFieldTypeConflict: + summary: (Cloud) field type conflict thrown by an explicit bucket schema + value: + code: invalid + message: 'partial write error (2 written): unable to parse ''air_sensor,service=S1,sensor=L1 temperature="90.5",humidity=70.0 1632850122'': schema: field type for field "temperature" not permitted by schema; got String but expected Float' + orgNotFound: + summary: (OSS) organization not found + value: + code: invalid + message: 'failed to decode request body: organization not found' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '413': + description: | + The request payload is too large. + InfluxDB rejected the batch and did not write any data. + + #### InfluxDB Cloud: + + - Returns this error if the payload exceeds the 50MB size limit. + - Returns `Content-Type: text/html` for this error. + + #### InfluxDB OSS: + + - Returns this error only if the [Go (golang) `ioutil.ReadAll()`](https://pkg.go.dev/io/ioutil#ReadAll) function raises an error. + - Returns `Content-Type: application/json` for this error. + content: + application/json: + schema: + $ref: '#/components/schemas/LineProtocolLengthError' + examples: + dataExceedsSizeLimitOSS: + summary: InfluxDB OSS response + value: | + {"code":"request too large","message":"unable to read data: points batch is too large"} + text/html: + schema: + type: string + examples: + dataExceedsSizeLimit: + summary: InfluxDB Cloud response + value: | + + 413 Request Entity Too Large + +

413 Request Entity Too Large

+
+
nginx
+ + + '429': + description: | + Too many requests. + + #### InfluxDB Cloud + + - Returns this error if a **read** or **write** request exceeds your plan's [adjustable service quotas](https://docs.influxdata.com/influxdb/cloud/account-management/limits/#adjustable-service-quotas) + or if a **delete** request exceeds the maximum [global limit](https://docs.influxdata.com/influxdb/cloud/account-management/limits/#global-limits). + - For rate limits that reset automatically, returns a `Retry-After` header that describes when to try the write again. + - For limits that can't reset (for example, **cardinality limit**), doesn't return a `Retry-After` header. + + Rates (data-in (writes), queries (reads), and deletes) accrue within a fixed five-minute window. + Once a rate limit is exceeded, InfluxDB returns an error response until the current five-minute window resets. + + #### InfluxDB OSS + + - Doesn't return this error. + headers: + Retry-After: + description: Non-negative decimal integer indicating seconds to wait before retrying the request. + schema: + type: integer + format: int32 + '500': + $ref: '#/components/responses/InternalServerError' + '503': + description: | + Service unavailable. + + - Returns this error if + the server is temporarily unavailable to accept writes. + - Returns a `Retry-After` header that describes when to try the write again. + headers: + Retry-After: + description: Non-negative decimal integer indicating seconds to wait before retrying the request. + schema: + type: integer + format: int32 + default: + $ref: '#/components/responses/GeneralServerError' + /delete: + post: + operationId: PostDelete + tags: + - Data I/O endpoints + - Delete + summary: Delete data + description: | + Deletes data from a bucket. + + Use this endpoint to delete points from a bucket in a specified time range. + + #### InfluxDB Cloud + + - Does the following when you send a delete request: + + 1. Validates the request and queues the delete. + 2. Returns _success_ if queued; _error_ otherwise. + 3. Handles the delete asynchronously. + + #### InfluxDB OSS + + - Validates the request, handles the delete synchronously, + and then responds with success or failure. + + #### Required permissions + + - `write-buckets` or `write-bucket BUCKET_ID`. + + `BUCKET_ID` is the ID of the destination bucket. + + #### Rate limits (with InfluxDB Cloud) + + `write` rate limits apply. + For more information, see [limits and adjustable quotas](https://docs.influxdata.com/influxdb/cloud/account-management/limits/). + + #### Related guides + + - [Delete data](https://docs.influxdata.com/influxdb/v2.3/write-data/delete-data/). + - Learn how to use [delete predicate syntax](https://docs.influxdata.com/influxdb/v2.3/reference/syntax/delete-predicate/). + - Learn how InfluxDB handles [deleted tags](https://docs.influxdata.com/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagkeys/) + and [deleted fields](https://docs.influxdata.com/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementfieldkeys/). + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl --request POST INFLUX_URL/api/v2/delete?org=INFLUX_ORG&bucket=INFLUX_BUCKET \ + --header 'Authorization: Token INFLUX_API_TOKEN' \ + --header 'Content-Type: application/json' \ + --data '{ + "start": "2020-03-01T00:00:00Z", + "stop": "2020-11-14T00:00:00Z", + "predicate": "tag1=\"value1\" and (tag2=\"value2\" and tag3!=\"value3\")" + }' + requestBody: + description: | + Time range parameters and an optional **delete predicate expression**. + + To select points to delete within the specified time range, pass a + **delete predicate expression** in the `predicate` property of the request body. + If you don't pass a `predicate`, InfluxDB deletes all data with timestamps + in the specified time range. + + #### Related guides + + - [Delete data](https://docs.influxdata.com/influxdb/v2.3/write-data/delete-data/). + - Learn how to use [delete predicate syntax](https://docs.influxdata.com/influxdb/v2.3/reference/syntax/delete-predicate/). + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/DeletePredicateRequest' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: org + description: | + The organization to delete data from. + If you pass both `orgID` and `org`, they must both be valid. + + #### InfluxDB Cloud + + - Doesn't require `org` or `orgID`. + - Deletes data from the bucket in the organization associated with the authorization (API token). + + #### InfluxDB OSS + + - Requires either `org` or `orgID`. + schema: + type: string + description: The organization name or ID. + - in: query + name: bucket + description: | + The name or ID of the bucket to delete data from. + If you pass both `bucket` and `bucketID`, `bucketID` takes precedence. + schema: + type: string + description: The bucket name or ID. + - in: query + name: orgID + description: | + The ID of the organization to delete data from. + If you pass both `orgID` and `org`, they must both be valid. + + #### InfluxDB Cloud + + - Doesn't require `org` or `orgID`. + - Deletes data from the bucket in the organization associated with the authorization (API token). + + #### InfluxDB OSS + + - Requires either `org` or `orgID`. + schema: + type: string + description: The organization ID. + - in: query + name: bucketID + description: | + The ID of the bucket to delete data from. + If you pass both `bucket` and `bucketID`, `bucketID` takes precedence. + schema: + type: string + description: The bucket ID. + responses: + '204': + description: | + Success. + + #### InfluxDB Cloud + + - Validated and queued the request. + - Handles the delete asynchronously - the deletion might not have completed yet. + + An HTTP `2xx` status code acknowledges that the write or delete is queued. + To ensure that InfluxDB Cloud handles writes and deletes in the order you request them, + wait for a response before you send the next request. + + Because writes are asynchronous, data might not yet be written + when you receive the response. + + #### InfluxDB OSS + + - Deleted the data. + '400': + description: | + Bad request. + The response body contains detail about the error. + + #### InfluxDB OSS + + - Returns this error if `org` or `orgID` doesn't match an organization. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + orgNotFound: + summary: Organization not found + value: + code: invalid + message: 'failed to decode request body: organization not found' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + /labels: + post: + operationId: PostLabels + tags: + - Labels + summary: Create a label + requestBody: + description: The label to create. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/LabelCreateRequest' + responses: + '201': + description: Success. The label was created. + content: + application/json: + schema: + $ref: '#/components/schemas/LabelResponse' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + get: + operationId: GetLabels + tags: + - Labels + summary: List all labels + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: orgID + description: The organization ID. + schema: + type: string + responses: + '200': + description: Success. The response body contains a list of labels. + content: + application/json: + schema: + $ref: '#/components/schemas/LabelsResponse' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + '/labels/{labelID}': + get: + operationId: GetLabelsID + tags: + - Labels + summary: Retrieve a label + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to update. + responses: + '200': + description: Success. The response body contains the label. + content: + application/json: + schema: + $ref: '#/components/schemas/LabelResponse' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + patch: + operationId: PatchLabelsID + tags: + - Labels + summary: Update a label + requestBody: + description: A label update. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/LabelUpdate' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to update. + responses: + '200': + description: Success. The response body contains the updated label. + content: + application/json: + schema: + $ref: '#/components/schemas/LabelResponse' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + delete: + operationId: DeleteLabelsID + tags: + - Labels + summary: Delete a label + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + '204': + description: Success. The delete was accepted. + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + '/dashboards/{dashboardID}': + get: + operationId: GetDashboardsID + tags: + - Dashboards + summary: Retrieve a dashboard + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + - in: query + name: include + required: false + schema: + type: string + enum: + - properties + description: 'If `properties`, includes the cell view properties in the response.' + responses: + '200': + description: Retrieve a single dashboard + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/Dashboard' + - $ref: '#/components/schemas/DashboardWithViewProperties' + '404': + description: Dashboard not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + operationId: PatchDashboardsID + tags: + - Dashboards + summary: Update a dashboard + requestBody: + description: Patching of a dashboard + required: true + content: + application/json: + schema: + type: object + title: PatchDashboardRequest + properties: + name: + description: 'optional, when provided will replace the name' + type: string + description: + description: 'optional, when provided will replace the description' + type: string + cells: + description: 'optional, when provided will replace all existing cells with the cells provided' + $ref: '#/components/schemas/CellWithViewProperties' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + responses: + '200': + description: Updated dashboard + content: + application/json: + schema: + $ref: '#/components/schemas/Dashboard' + '404': + description: Dashboard not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + operationId: DeleteDashboardsID + tags: + - Dashboards + summary: Delete a dashboard + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + responses: + '204': + description: Delete has been accepted + '404': + description: Dashboard not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/dashboards/{dashboardID}/cells': + put: + operationId: PutDashboardsIDCells + tags: + - Cells + - Dashboards + summary: Replace cells in a dashboard + description: Replaces all cells in a dashboard. This is used primarily to update the positional information of all cells. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Cells' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + responses: + '201': + description: Replaced dashboard cells + content: + application/json: + schema: + $ref: '#/components/schemas/Dashboard' + '404': + description: Dashboard not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostDashboardsIDCells + tags: + - Cells + - Dashboards + summary: Create a dashboard cell + requestBody: + description: Cell that will be added + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateCell' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + responses: + '201': + description: Cell successfully added + content: + application/json: + schema: + $ref: '#/components/schemas/Cell' + '404': + description: Dashboard not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/dashboards/{dashboardID}/cells/{cellID}': + patch: + operationId: PatchDashboardsIDCellsID + tags: + - Cells + - Dashboards + summary: Update the non-positional information related to a cell + description: Updates the non positional information related to a cell. Updates to a single cell's positional data could cause grid conflicts. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CellUpdate' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + - in: path + name: cellID + schema: + type: string + required: true + description: The ID of the cell to update. + responses: + '200': + description: Updated dashboard cell + content: + application/json: + schema: + $ref: '#/components/schemas/Cell' + '404': + description: Cell or dashboard not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + operationId: DeleteDashboardsIDCellsID + tags: + - Cells + - Dashboards + summary: Delete a dashboard cell + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to delete. + - in: path + name: cellID + schema: + type: string + required: true + description: The ID of the cell to delete. + responses: + '204': + description: Cell successfully deleted + '404': + description: Cell or dashboard not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/dashboards/{dashboardID}/cells/{cellID}/view': + get: + operationId: GetDashboardsIDCellsIDView + tags: + - Cells + - Dashboards + - Views + summary: Retrieve the view for a cell + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + - in: path + name: cellID + schema: + type: string + required: true + description: The cell ID. + responses: + '200': + description: A dashboard cells view + content: + application/json: + schema: + $ref: '#/components/schemas/View' + '404': + description: Cell or dashboard not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + operationId: PatchDashboardsIDCellsIDView + tags: + - Cells + - Dashboards + - Views + summary: Update the view for a cell + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/View' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The ID of the dashboard to update. + - in: path + name: cellID + schema: + type: string + required: true + description: The ID of the cell to update. + responses: + '200': + description: Updated cell view + content: + application/json: + schema: + $ref: '#/components/schemas/View' + '404': + description: Cell or dashboard not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/dashboards/{dashboardID}/labels': + get: + operationId: GetDashboardsIDLabels + tags: + - Dashboards + summary: List all labels for a dashboard + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + responses: + '200': + description: A list of all labels for a dashboard + content: + application/json: + schema: + $ref: '#/components/schemas/LabelsResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostDashboardsIDLabels + tags: + - Dashboards + summary: Add a label to a dashboard + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/LabelMapping' + responses: + '201': + description: The label added to the dashboard + content: + application/json: + schema: + $ref: '#/components/schemas/LabelResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/dashboards/{dashboardID}/labels/{labelID}': + delete: + operationId: DeleteDashboardsIDLabelsID + tags: + - Dashboards + summary: Delete a label from a dashboard + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + '204': + description: Delete has been accepted + '404': + description: Dashboard not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/dashboards/{dashboardID}/members': + get: + operationId: GetDashboardsIDMembers + tags: + - Dashboards + summary: List all dashboard members + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + responses: + '200': + description: A list of users who have member privileges for a dashboard + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceMembers' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostDashboardsIDMembers + tags: + - Dashboards + summary: Add a member to a dashboard + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + requestBody: + description: User to add as member + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddResourceMemberRequestBody' + responses: + '201': + description: Added to dashboard members + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceMember' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/dashboards/{dashboardID}/members/{userID}': + delete: + operationId: DeleteDashboardsIDMembersID + tags: + - Dashboards + summary: Remove a member from a dashboard + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the member to remove. + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + responses: + '204': + description: Member removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/dashboards/{dashboardID}/owners': + get: + operationId: GetDashboardsIDOwners + tags: + - Dashboards + summary: List all dashboard owners + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + responses: + '200': + description: A list of users who have owner privileges for a dashboard + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceOwners' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostDashboardsIDOwners + tags: + - Dashboards + summary: Add an owner to a dashboard + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + requestBody: + description: User to add as owner + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddResourceMemberRequestBody' + responses: + '201': + description: Added to dashboard owners + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceOwner' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/dashboards/{dashboardID}/owners/{userID}': + delete: + operationId: DeleteDashboardsIDOwnersID + tags: + - Dashboards + summary: Remove an owner from a dashboard + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the owner to remove. + - in: path + name: dashboardID + schema: + type: string + required: true + description: The dashboard ID. + responses: + '204': + description: Owner removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /query/ast: + post: + operationId: PostQueryAst + tags: + - Query + summary: Generate a query Abstract Syntax Tree (AST) + description: | + Analyzes a Flux query and returns a complete package source [Abstract Syntax + Tree (AST)](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#abstract-syntax-tree-ast) + for the query. + + Use this endpoint for deep query analysis such as debugging unexpected query + results. + + A Flux query AST provides a semantic, tree-like representation with contextual + information about the query. The AST illustrates how the query is distributed + into different components for execution. + + #### Limitations + + - The endpoint doesn't validate values in the query--for example: + + The following sample Flux query has correct syntax, but contains an incorrect `from()` property key: + + ```js + from(foo: "iot_center") + |> range(start: -90d) + |> filter(fn: (r) => r._measurement == "environment") + ``` + + The following sample JSON shows how to pass the query in the request body: + + ```js + from(foo: "iot_center") + |> range(start: -90d) + |> filter(fn: (r) => r._measurement == "environment") + ``` + + The following code sample shows how to pass the query as JSON in the request body: + ```json + { "query": "from(foo: \"iot_center\")\ + |> range(start: -90d)\ + |> filter(fn: (r) => r._measurement == \"environment\")" + } + ``` + + Passing this to `/api/v2/query/ast` will return a successful response + with a generated AST. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: header + name: Content-Type + schema: + type: string + enum: + - application/json + requestBody: + description: The Flux query to analyze. + content: + application/json: + schema: + $ref: '#/components/schemas/LanguageRequest' + x-codeSamples: + - lang: Shell + label: 'cURL: Analyze and generate AST for the query' + source: | + curl --request POST "http://localhost:8086/api/v2/query/ast" \ + --header 'Content-Type: application/json' \ + --header 'Accept: application/json' \ + --header "Authorization: Token INFLUX_TOKEN" \ + --data-binary @- << EOL + { + "query": "from(bucket: \"INFLUX_BUCKET_NAME\")\ + |> range(start: -5m)\ + |> filter(fn: (r) => r._measurement == \"example-measurement\")" + } + EOL + responses: + '200': + description: | + Success. + The response body contains an Abstract Syntax Tree (AST) of the Flux query. + content: + application/json: + schema: + $ref: '#/components/schemas/ASTResponse' + examples: + successResponse: + value: + ast: + type: Package + package: main + files: + - type: File + location: + start: + line: 1 + column: 1 + end: + line: 1 + column: 109 + source: 'from(bucket: "example-bucket") |> range(start: -5m) |> filter(fn: (r) => r._measurement == "example-measurement")' + metadata: parser-type=rust + package: null + imports: null + body: + - type: ExpressionStatement + location: + start: + line: 1 + column: 1 + end: + line: 1 + column: 109 + source: 'from(bucket: "example-bucket") |> range(start: -5m) |> filter(fn: (r) => r._measurement == "example-measurement")' + expression: + type: PipeExpression + location: + start: + line: 1 + column: 1 + end: + line: 1 + column: 109 + source: 'from(bucket: "example-bucket") |> range(start: -5m) |> filter(fn: (r) => r._measurement == "example-measurement")' + argument: + type: PipeExpression + location: + start: + line: 1 + column: 1 + end: + line: 1 + column: 47 + source: 'from(bucket: "example-bucket") |> range(start: -5m)' + argument: + type: CallExpression + location: + start: + line: 1 + column: 1 + end: + line: 1 + column: 26 + source: 'from(bucket: "example-bucket")' + callee: + type: Identifier + location: + start: + line: 1 + column: 1 + end: + line: 1 + column: 5 + source: from + name: from + arguments: + - type: ObjectExpression + location: + start: + line: 1 + column: 6 + end: + line: 1 + column: 25 + source: 'bucket: "example-bucket"' + properties: + - type: Property + location: + start: + line: 1 + column: 6 + end: + line: 1 + column: 25 + source: 'bucket: "example-bucket"' + key: + type: Identifier + location: + start: + line: 1 + column: 6 + end: + line: 1 + column: 12 + source: bucket + name: bucket + value: + type: StringLiteral + location: + start: + line: 1 + column: 14 + end: + line: 1 + column: 25 + source: '"example-bucket"' + value: example-bucket + call: + type: CallExpression + location: + start: + line: 1 + column: 30 + end: + line: 1 + column: 47 + source: 'range(start: -5m)' + callee: + type: Identifier + location: + start: + line: 1 + column: 30 + end: + line: 1 + column: 35 + source: range + name: range + arguments: + - type: ObjectExpression + location: + start: + line: 1 + column: 36 + end: + line: 1 + column: 46 + source: 'start: -5m' + properties: + - type: Property + location: + start: + line: 1 + column: 36 + end: + line: 1 + column: 46 + source: 'start: -5m' + key: + type: Identifier + location: + start: + line: 1 + column: 36 + end: + line: 1 + column: 41 + source: start + name: start + value: + type: UnaryExpression + location: + start: + line: 1 + column: 43 + end: + line: 1 + column: 46 + source: '-5m' + operator: '-' + argument: + type: DurationLiteral + location: + start: + line: 1 + column: 44 + end: + line: 1 + column: 46 + source: 5m + values: + - magnitude: 5 + unit: m + call: + type: CallExpression + location: + start: + line: 1 + column: 51 + end: + line: 1 + column: 109 + source: 'filter(fn: (r) => r._measurement == "example-measurement")' + callee: + type: Identifier + location: + start: + line: 1 + column: 51 + end: + line: 1 + column: 57 + source: filter + name: filter + arguments: + - type: ObjectExpression + location: + start: + line: 1 + column: 58 + end: + line: 1 + column: 108 + source: 'fn: (r) => r._measurement == "example-measurement"' + properties: + - type: Property + location: + start: + line: 1 + column: 58 + end: + line: 1 + column: 108 + source: 'fn: (r) => r._measurement == "example-measurement"' + key: + type: Identifier + location: + start: + line: 1 + column: 58 + end: + line: 1 + column: 60 + source: fn + name: fn + value: + type: FunctionExpression + location: + start: + line: 1 + column: 62 + end: + line: 1 + column: 108 + source: (r) => r._measurement == "example-measurement" + params: + - type: Property + location: + start: + line: 1 + column: 63 + end: + line: 1 + column: 64 + source: r + key: + type: Identifier + location: + start: + line: 1 + column: 63 + end: + line: 1 + column: 64 + source: r + name: r + value: null + body: + type: BinaryExpression + location: + start: + line: 1 + column: 69 + end: + line: 1 + column: 108 + source: r._measurement == "example-measurement" + operator: '==' + left: + type: MemberExpression + location: + start: + line: 1 + column: 69 + end: + line: 1 + column: 83 + source: r._measurement + object: + type: Identifier + location: + start: + line: 1 + column: 69 + end: + line: 1 + column: 70 + source: r + name: r + property: + type: Identifier + location: + start: + line: 1 + column: 71 + end: + line: 1 + column: 83 + source: _measurement + name: _measurement + right: + type: StringLiteral + location: + start: + line: 1 + column: 87 + end: + line: 1 + column: 108 + source: '"example-measurement"' + value: example-measurement + '400': + description: | + Bad request. + InfluxDB is unable to parse the request. + The response body contains detail about the problem. + headers: + X-Platform-Error-Code: + description: | + The reason for the error. + schema: + type: string + example: invalid + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + invalidASTValue: + summary: Invalid AST + description: | + If the request body contains a missing property key in `from()`, + returns `invalid` and problem detail. + value: + code: invalid + message: 'invalid AST: loc 1:6-1:19: missing property key' + default: + description: Internal server error. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /query/suggestions: + get: + operationId: GetQuerySuggestions + tags: + - Query + summary: Retrieve Flux query suggestions + description: | + Retrieves a list of Flux query suggestions. Each suggestion contains a + [Flux function](https://docs.influxdata.com/flux/v0.x/stdlib/all-functions/) + name and parameters. + + Use this endpoint to retrieve a list of Flux query suggestions used in the + InfluxDB Flux Query Builder. Helper function names have an underscore (`_`) + prefix and aren't meant to be used directly in queries--for example: + + - **Recommended**: Use `top(n, columns=["_value"], tables=<-)` to sort + on a column and keep the top n records instead of `_sortLimit_`. + `top` uses the `_sortLimit` helper function. + + #### Limitations + + - Using `/api/v2/query/suggestions/` (note the trailing slash) with cURL + will result in a HTTP `301 Moved Permanently` status code. Please use + `/api/v2/query/suggestions` without a trailing slash. + + - When writing a query, avoid using `_functionName()` helper functions + exposed by this endpoint. + + #### Related Guides + + - [List of all Flux functions](https://docs.influxdata.com/influxdb/v2.3/flux/v0.x/stdlib/all-functions/). + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '200': + description: | + Success. + The response body contains a list of Flux query suggestions--function + names used in the Flux Query Builder autocomplete suggestions. + content: + application/json: + schema: + $ref: '#/components/schemas/FluxSuggestions' + examples: + successResponse: + value: + funcs: + - name: _fillEmpty + params: + createEmpty: bool + tables: stream + - name: _highestOrLowest + params: + _sortLimit: function + column: invalid + groupColumns: array + 'n': invalid + reducer: function + tables: stream + - name: _hourSelection + params: + location: object + start: int + stop: int + tables: stream + timeColumn: string + - name: _sortLimit + params: + columns: array + desc: bool + 'n': int + tables: stream + - name: _window + params: + createEmpty: bool + every: duration + location: object + offset: duration + period: duration + startColumn: string + stopColumn: string + tables: stream + timeColumn: string + - name: aggregateWindow + params: + column: invalid + createEmpty: bool + every: duration + fn: function + location: object + offset: duration + period: duration + tables: stream + timeDst: string + timeSrc: string + - name: bool + params: + v: invalid + - name: bottom + params: + columns: array + 'n': int + tables: stream + - name: buckets + params: + host: string + org: string + orgID: string + token: string + - name: bytes + params: + v: invalid + - name: cardinality + params: + bucket: string + bucketID: string + host: string + org: string + orgID: string + predicate: function + start: invalid + stop: invalid + token: string + - name: chandeMomentumOscillator + params: + columns: array + 'n': int + tables: stream + - name: columns + params: + column: string + tables: stream + - name: contains + params: + set: array + value: invalid + - name: count + params: + column: string + tables: stream + - name: cov + params: + 'on': array + pearsonr: bool + x: invalid + 'y': invalid + - name: covariance + params: + columns: array + pearsonr: bool + tables: stream + valueDst: string + - name: cumulativeSum + params: + columns: array + tables: stream + - name: derivative + params: + columns: array + initialZero: bool + nonNegative: bool + tables: stream + timeColumn: string + unit: duration + - name: die + params: + msg: string + - name: difference + params: + columns: array + initialZero: bool + keepFirst: bool + nonNegative: bool + tables: stream + - name: display + params: + v: invalid + - name: distinct + params: + column: string + tables: stream + - name: doubleEMA + params: + 'n': int + tables: stream + - name: drop + params: + columns: array + fn: function + tables: stream + - name: duplicate + params: + as: string + column: string + tables: stream + - name: duration + params: + v: invalid + - name: elapsed + params: + columnName: string + tables: stream + timeColumn: string + unit: duration + - name: exponentialMovingAverage + params: + 'n': int + tables: stream + - name: fill + params: + column: string + tables: stream + usePrevious: bool + value: invalid + - name: filter + params: + fn: function + onEmpty: string + tables: stream + - name: findColumn + params: + column: string + fn: function + tables: stream + - name: findRecord + params: + fn: function + idx: int + tables: stream + - name: first + params: + column: string + tables: stream + - name: float + params: + v: invalid + - name: from + params: + bucket: string + bucketID: string + host: string + org: string + orgID: string + token: string + - name: getColumn + params: + column: string + - name: getRecord + params: + idx: int + - name: group + params: + columns: array + mode: string + tables: stream + - name: highestAverage + params: + column: string + groupColumns: array + 'n': int + tables: stream + - name: highestCurrent + params: + column: string + groupColumns: array + 'n': int + tables: stream + - name: highestMax + params: + column: string + groupColumns: array + 'n': int + tables: stream + - name: histogram + params: + bins: array + column: string + countColumn: string + normalize: bool + tables: stream + upperBoundColumn: string + - name: histogramQuantile + params: + countColumn: string + minValue: float + quantile: float + tables: stream + upperBoundColumn: string + valueColumn: string + - name: holtWinters + params: + column: string + interval: duration + 'n': int + seasonality: int + tables: stream + timeColumn: string + withFit: bool + - name: hourSelection + params: + location: object + start: int + stop: int + tables: stream + timeColumn: string + - name: increase + params: + columns: array + tables: stream + - name: int + params: + v: invalid + - name: integral + params: + column: string + interpolate: string + tables: stream + timeColumn: string + unit: duration + - name: join + params: + method: string + 'on': array + tables: invalid + - name: kaufmansAMA + params: + column: string + 'n': int + tables: stream + - name: kaufmansER + params: + 'n': int + tables: stream + - name: keep + params: + columns: array + fn: function + tables: stream + - name: keyValues + params: + keyColumns: array + tables: stream + - name: keys + params: + column: string + tables: stream + - name: last + params: + column: string + tables: stream + - name: length + params: + arr: array + - name: limit + params: + 'n': int + offset: int + tables: stream + - name: linearBins + params: + count: int + infinity: bool + start: float + width: float + - name: logarithmicBins + params: + count: int + factor: float + infinity: bool + start: float + - name: lowestAverage + params: + column: string + groupColumns: array + 'n': int + tables: stream + - name: lowestCurrent + params: + column: string + groupColumns: array + 'n': int + tables: stream + - name: lowestMin + params: + column: string + groupColumns: array + 'n': int + tables: stream + - name: map + params: + fn: function + mergeKey: bool + tables: stream + - name: max + params: + column: string + tables: stream + - name: mean + params: + column: string + tables: stream + - name: median + params: + column: string + compression: float + method: string + tables: stream + - name: min + params: + column: string + tables: stream + - name: mode + params: + column: string + tables: stream + - name: movingAverage + params: + 'n': int + tables: stream + - name: now + params: {} + - name: pearsonr + params: + 'on': array + x: invalid + 'y': invalid + - name: pivot + params: + columnKey: array + rowKey: array + tables: stream + valueColumn: string + - name: quantile + params: + column: string + compression: float + method: string + q: float + tables: stream + - name: range + params: + start: invalid + stop: invalid + tables: stream + - name: reduce + params: + fn: function + identity: invalid + tables: stream + - name: relativeStrengthIndex + params: + columns: array + 'n': int + tables: stream + - name: rename + params: + columns: invalid + fn: function + tables: stream + - name: sample + params: + column: string + 'n': int + pos: int + tables: stream + - name: set + params: + key: string + tables: stream + value: string + - name: skew + params: + column: string + tables: stream + - name: sort + params: + columns: array + desc: bool + tables: stream + - name: spread + params: + column: string + tables: stream + - name: stateCount + params: + column: string + fn: function + tables: stream + - name: stateDuration + params: + column: string + fn: function + tables: stream + timeColumn: string + unit: duration + - name: stateTracking + params: + countColumn: string + durationColumn: string + durationUnit: duration + fn: function + tables: stream + timeColumn: string + - name: stddev + params: + column: string + mode: string + tables: stream + - name: string + params: + v: invalid + - name: sum + params: + column: string + tables: stream + - name: tableFind + params: + fn: function + tables: stream + - name: tail + params: + 'n': int + offset: int + tables: stream + - name: time + params: + v: invalid + - name: timeShift + params: + columns: array + duration: duration + tables: stream + - name: timeWeightedAvg + params: + tables: stream + unit: duration + - name: timedMovingAverage + params: + column: string + every: duration + period: duration + tables: stream + - name: to + params: + bucket: string + bucketID: string + fieldFn: function + host: string + measurementColumn: string + org: string + orgID: string + tables: stream + tagColumns: array + timeColumn: string + token: string + - name: toBool + params: + tables: stream + - name: toFloat + params: + tables: stream + - name: toInt + params: + tables: stream + - name: toString + params: + tables: stream + - name: toTime + params: + tables: stream + - name: toUInt + params: + tables: stream + - name: today + params: {} + - name: top + params: + columns: array + 'n': int + tables: stream + - name: tripleEMA + params: + 'n': int + tables: stream + - name: tripleExponentialDerivative + params: + 'n': int + tables: stream + - name: truncateTimeColumn + params: + tables: stream + timeColumn: invalid + unit: duration + - name: uint + params: + v: invalid + - name: union + params: + tables: array + - name: unique + params: + column: string + tables: stream + - name: wideTo + params: + bucket: string + bucketID: string + host: string + org: string + orgID: string + tables: stream + token: string + - name: window + params: + createEmpty: bool + every: duration + location: object + offset: duration + period: duration + startColumn: string + stopColumn: string + tables: stream + timeColumn: string + - name: yield + params: + name: string + tables: stream + '301': + description: | + Moved Permanently. + InfluxData has moved the URL of the endpoint. + Use `/api/v2/query/suggestions`. + content: + text/html: + schema: + properties: + body: + readOnly: true + description: Response message with URL of requested resource. + type: string + examples: + movedPermanently: + summary: Invalid URL + description: | + The URL has been permanently moved. Use `/api/v2/query/suggestions`. + value: | + Moved Permanently + default: + description: Internal server error. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl --request GET "https://cloud2.influxdata.com/api/v2/query/suggestions" \ + --header "Accept: application/json" \ + --header "Authorization: Token INFLUX_API_TOKEN" + '/query/suggestions/{name}': + get: + operationId: GetQuerySuggestionsName + tags: + - Query + summary: Retrieve a query suggestion for a branching suggestion + description: | + Retrieves a query suggestion that contains the name and parameters of the + requested function. + + Use this endpoint to pass a branching suggestion (a Flux function name) and + retrieve the parameters of the requested function. + + #### Limitations + + - Use `/api/v2/query/suggestions/{name}` (without a trailing slash). + `/api/v2/query/suggestions/{name}/` (note the trailing slash) results in a + HTTP `301 Moved Permanently` status. + + - The function `name` must exist and must be spelled correctly. + + #### Related Guides + + - [List of all Flux functions](https://docs.influxdata.com/influxdb/v2.3/flux/v0.x/stdlib/all-functions/). + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: name + schema: + type: string + required: true + description: | + A Flux Function name. + Only returns functions with this name. + responses: + '200': + description: | + Success. + The response body contains the function name and parameters. + content: + application/json: + schema: + $ref: '#/components/schemas/FluxSuggestion' + examples: + successResponse: + value: + name: sum + params: + column: string + tables: stream + '500': + description: | + Internal server error. + The value passed for _`name`_ may have been misspelled. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + internalError: + summary: Invalid function + description: | + The requested function doesn't exist. + value: + code: internal error + message: An internal error has occurred + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl --request GET "https://cloud2.influxdata.com/api/v2/query/suggestions/sum/" \ + --header "Accept: application/json" \ + --header "Authorization: Token INFLUX_API_TOKEN" + /query/analyze: + post: + operationId: PostQueryAnalyze + tags: + - Query + summary: Analyze a Flux query + description: | + Analyzes a [Flux query](https://docs.influxdata.com/flux/v0.x/) for syntax + errors and returns the list of errors. + + In the following sample query, `from()` is missing the property key. + + ```json + { "query": "from(: \"iot_center\")\ + |> range(start: -90d)\ + |> filter(fn: (r) => r._measurement == \"environment\")", + "type": "flux" + } + ``` + + If you pass this in a request to the `/api/v2/analyze` endpoint, + InfluxDB returns an `errors` list that contains an error object for the missing key. + + #### Limitations + + - The endpoint doesn't validate values in the query--for example: + + - The following sample query has correct syntax, but contains an incorrect `from()` property key: + + ```json + { "query": "from(foo: \"iot_center\")\ + |> range(start: -90d)\ + |> filter(fn: (r) => r._measurement == \"environment\")", + "type": "flux" + } + ``` + + If you pass this in a request to the `/api/v2/analyze` endpoint, + InfluxDB returns an empty `errors` list. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: header + name: Content-Type + schema: + type: string + enum: + - application/json + requestBody: + description: Flux query to analyze + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + responses: + '200': + description: | + Success. + The response body contains the list of `errors`. + If the query syntax is valid, the endpoint returns an empty `errors` list. + content: + application/json: + schema: + $ref: '#/components/schemas/AnalyzeQueryResponse' + examples: + missingQueryPropertyKey: + summary: Missing property key error + description: | + Returns an error object if the Flux query is missing a property key. + + The following sample query is missing the _`bucket`_ property key: + + ```json + { + "query": "from(: \"iot_center\")\ + + ... + + } + ``` + value: + errors: + - line: 1 + column: 6 + character: 0 + message: missing property key + '400': + description: | + Bad request. + InfluxDB is unable to parse the request. + The response body contains detail about the problem. + headers: + X-Platform-Error-Code: + description: | + The reason for the error. + schema: + type: string + example: invalid + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + invalidJSONStringValue: + summary: Invalid JSON + description: 'If the request body contains invalid JSON, returns `invalid` and problem detail.' + value: + code: invalid + message: 'invalid json: invalid character ''\'''' looking for beginning of value' + default: + description: Internal server error + headers: + X-Platform-Error-Code: + description: The reason for the error. + schema: + type: string + example: internal error + X-Influx-Error: + description: A string that describes the problem. + schema: + type: string + X-Influx-Reference: + description: The numeric reference code for the error type. + schema: + type: integer + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + emptyJSONObject: + summary: Empty JSON object in request body + description: | + If the request body contains an empty JSON object, returns `internal error`. + value: + code: internal error + message: An internal error has occurred - check server logs + x-codeSamples: + - lang: Shell + label: 'cURL: Analyze a Flux query' + source: | + curl -v --request POST \ + "http://localhost:8086/api/v2/query/analyze" \ + --header "Authorization: Token INFLUX_API_TOKEN" \ + --header 'Content-type: application/json' \ + --header 'Accept: application/json' \ + --data-binary @- << EOF + { "query": "from(bucket: \"iot_center\")\ + |> range(start: -90d)\ + |> filter(fn: (r) => r._measurement == \"environment\")", + "type": "flux" + } + EOF + /query: + post: + operationId: PostQuery + tags: + - Data I/O endpoints + - Query + summary: Query data + description: | + Retrieves data from buckets. + + Use this endpoint to send a Flux query request and retrieve data from a bucket. + + #### Rate limits (with InfluxDB Cloud) + + `read` rate limits apply. + For more information, see [limits and adjustable quotas](https://docs.influxdata.com/influxdb/cloud/account-management/limits/). + + #### Related guides + + - [Query with the InfluxDB API](https://docs.influxdata.com/influxdb/v2.3/query-data/execute-queries/influx-api/). + - [Get started with Flux](https://docs.influxdata.com/flux/v0.x/get-started/) + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: header + name: Accept-Encoding + description: The content encoding (usually a compression algorithm) that the client can understand. + schema: + type: string + description: 'The content coding. Use `gzip` for compressed data or `identity` for unmodified, uncompressed data.' + default: identity + enum: + - gzip + - identity + - in: header + name: Content-Type + schema: + type: string + enum: + - application/json + - application/vnd.flux + - in: query + name: org + description: | + The name or ID of the organization executing the query. + + #### InfluxDB Cloud + + - Doesn't use `org` or `orgID`. + - Queries the bucket in the organization associated with the authorization (API token). + + #### InfluxDB OSS + + - Requires either `org` or `orgID`. + schema: + type: string + - in: query + name: orgID + description: | + The ID of the organization executing the query. + + #### InfluxDB Cloud + + - Doesn't use `org` or `orgID`. + - Queries the bucket in the organization associated with the authorization (API token). + + #### InfluxDB OSS + + - Requires either `org` or `orgID`. + schema: + type: string + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl --request POST 'INFLUX_URL/api/v2/query?org=INFLUX_ORG' \ + --header 'Content-Type: application/vnd.flux' \ + --header 'Accept: application/csv \ + --header 'Authorization: Token INFLUX_API_TOKEN' \ + --data 'from(bucket: "example-bucket") + |> range(start: -5m) + |> filter(fn: (r) => r._measurement == "example-measurement")' + requestBody: + description: Flux query or specification to execute + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + application/vnd.flux: + schema: + type: string + example: | + from(bucket: "example-bucket") + |> range(start: -5m) + |> filter(fn: (r) => r._measurement == "example-measurement") + responses: + '200': + description: Success. The response body contains query results. + headers: + Content-Encoding: + description: Lists encodings (usually compression algorithms) that have been applied to the response payload. + schema: + type: string + description: | + The content coding: `gzip` for compressed data or `identity` for unmodified, uncompressed data. + default: identity + enum: + - gzip + - identity + Trace-Id: + description: 'The trace ID, if generated, of the request.' + schema: + type: string + description: Trace ID of a request. + content: + application/csv: + schema: + type: string + example: | + result,table,_start,_stop,_time,region,host,_value + mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43 + mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 + mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62 + '400': + description: | + Bad request. + The response body contains detail about the error. + + #### InfluxDB OSS + + - Returns this error if `org` or `orgID` doesn't match an organization. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + orgNotFound: + summary: Organization not found + value: + code: invalid + message: 'failed to decode request body: organization not found' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '429': + description: | + #### InfluxDB Cloud: + - returns this error if a **read** or **write** request exceeds your + plan's [adjustable service quotas](https://docs.influxdata.com/influxdb/v2.3/account-management/limits/#adjustable-service-quotas) + or if a **delete** request exceeds the maximum + [global limit](https://docs.influxdata.com/influxdb/v2.3/account-management/limits/#global-limits) + - returns `Retry-After` header that describes when to try the write again. + + #### InfluxDB OSS: + - doesn't return this error. + headers: + Retry-After: + description: Non-negative decimal integer indicating seconds to wait before retrying the request. + schema: + type: integer + format: int32 + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + /buckets: + get: + operationId: GetBuckets + tags: + - Buckets + summary: List buckets + description: | + Retrieves a list of [buckets](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#bucket). + + To limit which buckets are returned, pass query parameters in your request. + If no query parameters are passed, InfluxDB returns all buckets up to the + default `limit`. + + #### Limitations + + - Paging with an `offset` greater than the number of records will result in + an empty list of buckets--for example: + + The following request is paging to the 50th record, but the user only has + 10 buckets. + + ```sh + $ curl --request GET "INFLUX_URL/api/v2/scripts?limit=1&offset=50" + + $ { + "links": { + "prev": "/api/v2/buckets?descending=false\u0026limit=1\u0026offset=49\u0026orgID=ORG_ID", + "self": "/api/v2/buckets?descending=false\u0026limit=1\u0026offset=50\u0026orgID=ORG_ID" + }, + "buckets": [] + } + ``` + + #### Related Guides + + - [Manage buckets](https://docs.influxdata.com/influxdb/v2.3/organizations/buckets/) + parameters: + - $ref: '#/components/parameters/TraceSpan' + - $ref: '#/components/parameters/Offset' + - $ref: '#/components/parameters/Limit' + - $ref: '#/components/parameters/After' + - in: query + name: org + description: | + Organization name. + The name of the organization. + + #### InfluxDB Cloud + + - Doesn't use `org` or `orgID`. + - Creates a bucket in the organization associated with the authorization (API token). + + #### InfluxDB OSS + + - Accepts either `org` or `orgID`. + - InfluxDB creates the bucket within this organization. + schema: + type: string + - in: query + name: orgID + description: | + Organization ID. + The organization ID. + + #### InfluxDB Cloud + + - Doesn't use `org` or `orgID`. + - Creates a bucket in the organization associated with the authorization (API token). + + #### InfluxDB OSS + + - Accepts either `org` or `orgID`. + - InfluxDB creates the bucket within this organization. + schema: + type: string + - in: query + name: name + description: | + Bucket name. + Only returns buckets with this specific name. + schema: + type: string + - in: query + name: id + description: | + Bucket ID. + Only returns the bucket with this ID. + schema: + type: string + responses: + '200': + description: | + Success. + The response body contains a list of buckets. + content: + application/json: + schema: + $ref: '#/components/schemas/Buckets' + examples: + successResponse: + value: + links: + self: /api/v2/buckets?descending=false&limit=20&name=_monitoring&offset=0&orgID=ORG_ID + buckets: + - id: 77ca9dace40a9bfc + orgID: INFLUX_ORG_ID + type: system + schemaType: implicit + description: System bucket for monitoring logs + name: _monitoring + retentionRules: + - type: expire + everySeconds: 604800 + createdAt: '2022-03-15T17:22:33.72617939Z' + updatedAt: '2022-03-15T17:22:33.726179487Z' + links: + labels: /api/v2/buckets/77ca9dace40a9bfc/labels + members: /api/v2/buckets/77ca9dace40a9bfc/members + org: /api/v2/orgs/INFLUX_ORG_ID + owners: /api/v2/buckets/77ca9dace40a9bfc/owners + self: /api/v2/buckets/77ca9dace40a9bfc + write: /api/v2/write?org=ORG_ID&bucket=77ca9dace40a9bfc + labels: [] + '401': + $ref: '#/components/responses/AuthorizationError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl --request GET "http://localhost:8086/api/v2/buckets?name=_monitoring" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header "Accept: application/json" \ + --header "Content-Type: application/json" + post: + operationId: PostBuckets + tags: + - Buckets + summary: Create a bucket + description: | + Creates a [bucket](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#bucket) + and returns the created bucket along with metadata. The default data + [retention period](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#retention-period) + is 30 days. + + #### InfluxDB OSS + + - A single InfluxDB OSS instance supports active writes or queries for + approximately 20 buckets across all organizations at a given time. Reading + or writing to more than 20 buckets at a time can adversely affect + performance. + + #### Limitations + + - InfluxDB Cloud Free Plan allows users to create up to two buckets. + Exceeding the bucket quota will result in an HTTP `403` status code. + For additional information regarding InfluxDB Cloud offerings, see + [InfluxDB Cloud Pricing](https://www.influxdata.com/influxdb-cloud-pricing/). + + #### Related Guides + + - [Create bucket](https://docs.influxdata.com/influxdb/v2.3/organizations/buckets/create-bucket/) + - [Create bucket CLI reference](https://docs.influxdata.com/influxdb/v2.3/reference/cli/influx/bucket/create) + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: Bucket to create + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PostBucketRequest' + responses: + '201': + description: | + Success. + The bucket was created. + content: + application/json: + schema: + $ref: '#/components/schemas/Bucket' + examples: + successResponse: + value: + id: 37407e232b3911d8 + orgID: INFLUX_ORG_ID + type: user + schemaType: implicit + description: bucket holding air sensor data + name: air_sensor + retentionRules: + - type: expire + everySeconds: 2592000 + createdAt: '2022-08-03T23:04:41.073704121Z' + updatedAt: '2022-08-03T23:04:41.073704228Z' + links: + labels: /api/v2/buckets/37407e232b3911d8/labels + members: /api/v2/buckets/37407e232b3911d8/members + org: /api/v2/orgs/INFLUX_ORG_ID + owners: /api/v2/buckets/37407e232b3911d8/owners + self: /api/v2/buckets/37407e232b3911d8 + write: /api/v2/write?org=INFLUX_ORG_ID&bucket=37407e232b3911d8 + labels: [] + '400': + description: | + Bad request. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '401': + $ref: '#/components/responses/AuthorizationError' + '403': + description: | + Forbidden. + The bucket quota is exceeded. + headers: + X-Platform-Error-Code: + description: | + The reason for the error. + schema: + type: string + example: forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + quotaExceeded: + summary: Bucket quota exceeded + value: + code: forbidden + message: creating bucket would exceed quota + '422': + description: | + Unprocessable Entity. + The request body failed validation. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl --request POST "http://localhost:8086/api/v2/buckets \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header "Accept: application/json" \ + --header "Content-Type: application/json" \ + --data '{ + "name": "air_sensor", + "description": "bucket holding air sensor data", + "orgID": "INFLUX_ORG_ID", + "retentionRules": [ + { + "type": "expire", + "everySeconds": 2592000, + } + ] + }' + '/buckets/{bucketID}': + get: + operationId: GetBucketsID + tags: + - Buckets + summary: Retrieve a bucket + description: | + Retrieves a bucket. + + Use this endpoint to retrieve information for a specific bucket. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: bucketID + schema: + type: string + required: true + description: | + The ID of the bucket to retrieve. + responses: + '200': + description: | + Success. + The response body contains the bucket information. + content: + application/json: + schema: + $ref: '#/components/schemas/Bucket' + examples: + successResponse: + value: + id: 37407e232b3911d8 + orgID: bea7ea952287f70d + type: user + schemaType: implicit + description: bucket for air sensor data + name: air-sensor + retentionRules: + - type: expire + everySeconds: 2592000 + createdAt: '2022-08-03T23:04:41.073704121Z' + updatedAt: '2022-08-03T23:04:41.073704228Z' + links: + labels: /api/v2/buckets/37407e232b3911d8/labels + members: /api/v2/buckets/37407e232b3911d8/members + org: /api/v2/orgs/INFLUX_ORG_ID + owners: /api/v2/buckets/37407e232b3911d8/owners + self: /api/v2/buckets/37407e232b3911d8 + write: /api/v2/write?org=INFLUX_ORG_ID&bucket=37407e232b3911d8 + labels: [] + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + description: | + Not found. + Bucket not found. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + notFound: + summary: | + The requested bucket wasn't found. + value: + code: not found + message: bucket not found + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + operationId: PatchBucketsID + tags: + - Buckets + summary: Update a bucket + description: | + Updates a bucket. + + Use this endpoint to update properties + (`name`, `description`, and `retentionRules`) of a bucket. + + #### InfluxDB Cloud + + - Requires the `retentionRules` property in the request body. If you don't + provide `retentionRules`, InfluxDB responds with an HTTP `403` status code. + + #### InfluxDB OSS + + - Doesn't require `retentionRules`. + + #### Related Guides + + - [Update a bucket](https://docs.influxdata.com/influxdb/v2.3/organizations/buckets/update-bucket/) + requestBody: + description: The bucket update to apply. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PatchBucketRequest' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + responses: + '200': + description: An updated bucket + content: + application/json: + schema: + $ref: '#/components/schemas/Bucket' + examples: + successResponse: + value: + id: 37407e232b3911d8 + orgID: INFLUX_ORG_ID + type: user + schemaType: implicit + description: bucket holding air sensor data + name: air_sensor + retentionRules: + - type: expire + everySeconds: 2592000 + createdAt: '2022-08-03T23:04:41.073704121Z' + updatedAt: '2022-08-07T22:49:49.422962913Z' + links: + labels: /api/v2/buckets/37407e232b3911d8/labels + members: /api/v2/buckets/37407e232b3911d8/members + org: /api/v2/orgs/INFLUX_ORG_ID + owners: /api/v2/buckets/37407e232b3911d8/owners + self: /api/v2/buckets/37407e232b3911d8 + write: /api/v2/write?org=INFLUX_ORG_ID&bucket=37407e232b3911d8 + labels: [] + '400': + description: | + Bad Request. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + invalidJSONStringValue: + summary: Invalid JSON + description: | + If the request body contains invalid JSON, InfluxDB returns `invalid` + with detail about the problem. + value: + code: invalid + message: 'invalid json: invalid character ''\'''' looking for beginning of value' + '401': + $ref: '#/components/responses/AuthorizationError' + '403': + description: | + Forbidden. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + invalidRetention: + summary: | + The retention policy provided exceeds the max retention for the + organization. + value: + code: forbidden + message: provided retention exceeds orgs maximum retention duration + '404': + description: | + Not found. + Bucket not found. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + notFound: + summary: | + The requested bucket wasn't found. + value: + code: not found + message: bucket not found + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl --request PATCH "http://localhost:8086/api/v2/buckets/BUCKET_ID \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header "Accept: application/json" \ + --header "Content-Type: application/json" \ + --data '{ + "name": "air_sensor", + "description": "bucket holding air sensor data", + "retentionRules": [ + { + "type": "expire", + "everySeconds": 2592000 + } + ] + }' + delete: + operationId: DeleteBucketsID + tags: + - Buckets + summary: Delete a bucket + description: | + Deletes a bucket and all associated records. + + #### InfluxDB Cloud + + - Does the following when you send a delete request: + + 1. Validates the request and queues the delete. + 2. Returns an HTTP `204` status code if queued; _error_ otherwise. + 3. Handles the delete asynchronously. + + #### InfluxDB OSS + + - Validates the request, handles the delete synchronously, + and then responds with success or failure. + + #### Limitations + + - Only one bucket can be deleted per request. + + #### Related Guides + + - [Delete a bucket](https://docs.influxdata.com/influxdb/v2.3/organizations/buckets/delete-bucket/#delete-a-bucket-in-the-influxdb-ui) + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: bucketID + schema: + type: string + required: true + description: | + Bucket ID. + The ID of the bucket to delete. + responses: + '204': + description: | + Success. + + #### InfluxDB Cloud + - The bucket is queued for deletion. + + #### InfluxDB OSS + - The bucket is deleted. + '400': + description: | + Bad Request. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + invalidID: + summary: | + Invalid ID. + value: + code: invalid + message: id must have a length of 16 bytes + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + description: | + Not found. + Bucket not found. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + notFound: + summary: | + The requested bucket was not found. + value: + code: not found + message: bucket not found + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl --request DELETE "http://localhost:8086/api/v2/buckets/BUCKET_ID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header 'Accept: application/json' + '/buckets/{bucketID}/labels': + get: + operationId: GetBucketsIDLabels + tags: + - Buckets + summary: List all labels for a bucket + description: | + Retrieves a list of all labels for a bucket. + + Labels are objects that contain `labelID`, `name`, `description`, and `color` + key-value pairs. They may be used for grouping and filtering InfluxDB + resources. + Labels are also capable of grouping across different resources--for example, + you can apply a label named `air_sensor` to a bucket and a task to quickly + organize resources. + + #### Related guides + + - Use the [`/api/v2/labels` InfluxDB API endpoint](#tag/Labels) to retrieve and manage labels. + - [Manage labels in the InfluxDB UI](https://docs.influxdata.com/influxdb/v2.3/visualize-data/labels/) + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: bucketID + schema: + type: string + required: true + description: | + The ID of the bucket to retrieve labels for. + responses: + '200': + description: | + Success. + The response body contains a list of all labels for the bucket. + content: + application/json: + schema: + $ref: '#/components/schemas/LabelsResponse' + examples: + successResponse: + value: + links: + self: /api/v2/labels + labels: + - id: 09cbd068e7ebb000 + orgID: INFLUX_ORG_ID + name: production_buckets + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostBucketsIDLabels + tags: + - Buckets + summary: Add a label to a bucket + description: | + Adds a label to a bucket and returns the new label information. + + Labels are objects that contain `labelID`, `name`, `description`, and `color` + key-value pairs. They may be used for grouping and filtering across one or + more kinds of **resources**--for example, you can apply a label named + `air_sensor` to a bucket and a task to quickly organize resources. + + #### Limitations + + - Before adding a label to a bucket, you must create the label if you + haven't already. To create a label with the InfluxDB API, send a `POST` + request to the [`/api/v2/labels` endpoint](#operation/PostLabels)). + + #### Related guides + + - Use the [`/api/v2/labels` InfluxDB API endpoint](#tag/Labels) to retrieve and manage labels. + - [Manage labels in the InfluxDB UI](https://docs.influxdata.com/influxdb/v2.3/visualize-data/labels/) + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: bucketID + schema: + type: string + required: true + description: | + Bucket ID. + The ID of the bucket to label. + requestBody: + description: An object that contains a _`labelID`_ to add to the bucket. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/LabelMapping' + responses: + '201': + description: | + Success. + The response body contains the label information. + content: + application/json: + schema: + $ref: '#/components/schemas/LabelResponse' + examples: + successResponse: + value: + links: + self: /api/v2/labels + label: + id: 09cbd068e7ebb000 + orgID: INFLUX_ORG_ID + name: production_buckets + '400': + $ref: '#/components/responses/BadRequestError' + examples: + invalidRequest: + summary: The `labelID` is missing from the request body. + value: + code: invalid + message: label id is required + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '422': + description: | + Unprocessable entity. + Label already exists on the resource. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + conflictingResource: + summary: | + Label already exists on the resource. + value: + code: conflict + message: 'Cannot add label, label already exists on resource' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl --request POST "http://localhost:8086/api/v2/buckets/BUCKETS_ID/labels \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header "Accept: application/json" \ + --header "Content-Type: application/json" \ + --data '{ + "labelID": "09cbd068e7ebb000" + }' + '/buckets/{bucketID}/labels/{labelID}': + delete: + operationId: DeleteBucketsIDLabelsID + tags: + - Buckets + summary: Delete a label from a bucket + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + '204': + description: Delete has been accepted + '404': + description: Bucket not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/buckets/{bucketID}/members': + get: + operationId: GetBucketsIDMembers + tags: + - Buckets + summary: List all users with member privileges for a bucket + description: | + Retrieves a list of all users for a bucket. + + InfluxDB [users](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#user) have + permission to access InfluxDB. + + [Members](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#member) are users in + an organization with access to the specified resource. + + Use this endpoint to retrieve all users with access to a bucket. + + #### Related guides + + - [Manage users](https://docs.influxdata.com/influxdb/v2.3/users/) + - [Manage members](https://docs.influxdata.com/influxdb/v2.3/organizations/members/) + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: bucketID + schema: + type: string + required: true + description: | + The ID of the bucket to retrieve users for. + responses: + '200': + description: | + Success. + The response body contains a list of all users for the bucket. + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceMembers' + examples: + successResponse: + value: + links: + self: /api/v2/buckets/37407e232b3911d8/members + users: + - role: member + links: + self: /api/v2/users/791df274afd48a83 + id: 791df274afd48a83 + name: example_user_1 + status: active + - role: owner + links: + self: /api/v2/users/09cfb87051cbe000 + id: 09cfb87051cbe000 + name: example_user_2 + status: active + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostBucketsIDMembers + tags: + - Buckets + summary: Add a member to a bucket + description: | + Add a user to a bucket and return the new user information. + + InfluxDB [users](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#user) have + permission to access InfluxDB. + + [Members](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#member) are users in + an organization. + + Use this endpoint to give a user member privileges to a bucket. + + #### Related guides + + - [Manage users](https://docs.influxdata.com/influxdb/v2.3/users/) + - [Manage members](https://docs.influxdata.com/influxdb/v2.3/organizations/members/) + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: bucketID + schema: + type: string + required: true + description: | + The ID of the bucket to retrieve users for. + requestBody: + description: A user to add as a member to the bucket. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddResourceMemberRequestBody' + responses: + '201': + description: | + Success. + The response body contains the user information. + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceMember' + examples: + successResponse: + value: + role: member + links: + self: /api/v2/users/09cfb87051cbe000 + id: 09cfb87051cbe000 + name: example_user_1 + status: active + '400': + $ref: '#/components/responses/BadRequestError' + examples: + invalidRequest: + summary: The `userID` is missing from the request body. + value: + code: invalid + message: user id missing or invalid + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl --request POST "http://localhost:8086/api/v2/buckets/BUCKET_ID/members \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header "Accept: application/json" \ + --header "Content-Type: application/json" \ + --data '{ + "id": "09cfb87051cbe000" + } + '/buckets/{bucketID}/members/{userID}': + delete: + operationId: DeleteBucketsIDMembersID + tags: + - Buckets + summary: Remove a member from a bucket + description: | + Removes a member from a bucket. + + Use this endpoint to remove a user's member privileges from a bucket. This + removes the user's `read` and `write` permissions for the bucket. + + #### Related guides + + - [Manage users](https://docs.influxdata.com/influxdb/v2.3/users/) + - [Manage members](https://docs.influxdata.com/influxdb/v2.3/organizations/members/) + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: | + The ID of the user to remove. + - in: path + name: bucketID + schema: + type: string + required: true + description: | + The ID of the bucket to remove a user from. + responses: + '204': + description: | + Success. + The user is no longer a member of the bucket. + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/buckets/{bucketID}/owners': + get: + operationId: GetBucketsIDOwners + tags: + - Buckets + summary: List all owners of a bucket + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + responses: + '200': + description: A list of bucket owners + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceOwners' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostBucketsIDOwners + tags: + - Buckets + summary: Add an owner to a bucket + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + requestBody: + description: User to add as owner + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddResourceMemberRequestBody' + responses: + '201': + description: Success. The user is an owner of the bucket + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceOwner' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/buckets/{bucketID}/owners/{userID}': + delete: + operationId: DeleteBucketsIDOwnersID + tags: + - Buckets + summary: Remove an owner from a bucket + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the owner to remove. + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + responses: + '204': + description: Owner removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /orgs: + get: + operationId: GetOrgs + tags: + - Organizations + - Security and access endpoints + summary: List organizations + description: | + Retrieves a list of [organizations](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#organization/). + + To limit which organizations are returned, pass query parameters in your request. + If no query parameters are passed, InfluxDB returns all organizations up to the default `limit`. + + #### InfluxDB Cloud + + - Only returns the organization that owns the token passed in the request. + + #### Related guides + + - [View organizations](https://docs.influxdata.com/influxdb/v2.3/organizations/view-orgs/). + parameters: + - $ref: '#/components/parameters/TraceSpan' + - $ref: '#/components/parameters/Offset' + - $ref: '#/components/parameters/Limit' + - $ref: '#/components/parameters/Descending' + - in: query + name: org + schema: + type: string + description: | + An organization name. + Only returns organizations with this name. + - in: query + name: orgID + schema: + type: string + description: | + An organization ID. + Only returns the organization with this ID. + - in: query + name: userID + schema: + type: string + description: | + A user ID. + Only returns organizations where this user is a member or owner. + responses: + '200': + description: Success. The response body contains a list of organizations. + content: + application/json: + schema: + $ref: '#/components/schemas/Organizations' + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + post: + operationId: PostOrgs + tags: + - Organizations + summary: Create an organization + description: | + Creates an organization and returns the newly created organization. + + #### InfluxDB Cloud + + - Doesn't allow you to use this endpoint to create organizations. + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: The organization to create. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PostOrganizationRequest' + responses: + '201': + description: | + Success. The organization is created. + The response body contains the new organization. + content: + application/json: + schema: + $ref: '#/components/schemas/Organization' + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + '/orgs/{orgID}': + get: + operationId: GetOrgsID + tags: + - Organizations + - Security and access endpoints + summary: Retrieve an organization + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: orgID + schema: + type: string + required: true + description: The ID of the organization to get. + responses: + '200': + description: Organization details + content: + application/json: + schema: + $ref: '#/components/schemas/Organization' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + operationId: PatchOrgsID + tags: + - Organizations + summary: Update an organization + requestBody: + description: Organization update to apply + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PatchOrganizationRequest' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: orgID + schema: + type: string + required: true + description: The ID of the organization to get. + responses: + '200': + description: Organization updated + content: + application/json: + schema: + $ref: '#/components/schemas/Organization' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + operationId: DeleteOrgsID + tags: + - Organizations + summary: Delete an organization + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: orgID + schema: + type: string + required: true + description: The ID of the organization to delete. + responses: + '204': + description: Delete has been accepted + '404': + description: Organization not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/orgs/{orgID}/secrets': + get: + operationId: GetOrgsIDSecrets + tags: + - Secrets + - Security and access endpoints + summary: List all secret keys for an organization + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + responses: + '200': + description: A list of all secret keys + content: + application/json: + schema: + $ref: '#/components/schemas/SecretKeysResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + operationId: PatchOrgsIDSecrets + tags: + - Secrets + summary: Update secrets in an organization + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + requestBody: + description: Secret key value pairs to update/add + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Secrets' + responses: + '204': + description: Keys successfully patched + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/orgs/{orgID}/members': + get: + operationId: GetOrgsIDMembers + tags: + - Organizations + - Security and access endpoints + summary: List all members of an organization + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + responses: + '200': + description: A list of organization members + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceMembers' + '404': + description: Organization not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostOrgsIDMembers + tags: + - Organizations + summary: Add a member to an organization + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + requestBody: + description: User to add as member + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddResourceMemberRequestBody' + responses: + '201': + description: Added to organization created + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceMember' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/orgs/{orgID}/members/{userID}': + delete: + operationId: DeleteOrgsIDMembersID + tags: + - Organizations + - Security and access endpoints + summary: Remove a member from an organization + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the member to remove. + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + responses: + '204': + description: Member removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/orgs/{orgID}/owners': + get: + operationId: GetOrgsIDOwners + tags: + - Organizations + - Security and access endpoints + summary: List all owners of an organization + description: | + Retrieves a list of all owners of an organization. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: orgID + schema: + type: string + required: true + description: | + The ID of the organization to list owners for. + responses: + '200': + description: A list of organization owners + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceOwners' + '404': + description: Organization not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostOrgsIDOwners + tags: + - Organizations + summary: Add an owner to an organization + description: | + Adds an owner to an organization. + + Use this endpoint to assign the organization `owner` role to a user. + + #### InfluxDB Cloud + + - Doesn't use `owner` and `member` roles. + Use [`/api/v2/authorizations`](#tag/Authorizations) to assign user permissions. + + #### Required permissions + + - `write-orgs INFLUX_ORG_ID` + + `INFLUX_ORG_ID` is the ID of the organization that you want add an owner for. + + #### Related endpoints + + - [Authorizations](#tag/Authorizations) + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: orgID + schema: + type: string + required: true + description: The ID of the organization that you want to add an owner for. + requestBody: + description: The user to add as an owner of the organization. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddResourceMemberRequestBody' + responses: + '201': + description: | + Success. The user is an owner of the organization. + The response body contains the owner with role and user detail. + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceOwner' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/orgs/{orgID}/owners/{userID}': + delete: + operationId: DeleteOrgsIDOwnersID + tags: + - Organizations + - Security and access endpoints + summary: Remove an owner from an organization + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the owner to remove. + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + responses: + '204': + description: Owner removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/orgs/{orgID}/secrets/delete': + post: + deprecated: true + operationId: PostOrgsIDSecrets + tags: + - Secrets + - Security and access endpoints + summary: Delete secrets from an organization + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + requestBody: + description: Secret key to delete + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/SecretKeys' + responses: + '204': + description: Keys successfully patched + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/orgs/{orgID}/secrets/{secretID}': + delete: + operationId: DeleteOrgsIDSecretsID + tags: + - Secrets + - Security and access endpoints + summary: Delete a secret from an organization + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: orgID + schema: + type: string + required: true + description: The organization ID. + - in: path + name: secretID + schema: + type: string + required: true + description: The secret ID. + responses: + '204': + description: Keys successfully deleted + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /resources: + get: + operationId: GetResources + tags: + - Resources + - System information endpoints + summary: List all known resources + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '200': + description: All resources targets + content: + application/json: + schema: + type: array + items: + type: string + default: + description: Internal server error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /stacks: + get: + operationId: ListStacks + tags: + - Templates + summary: List installed stacks + description: | + Retrieves a list of installed InfluxDB stacks. + + To limit stacks in the response, pass query parameters in your request. + If no query parameters are passed, InfluxDB returns all installed stacks + for the organization. + parameters: + - in: query + name: orgID + required: true + schema: + type: string + description: | + The ID of the organization that owns the stacks. + Only returns stacks owned by this organization. + + #### InfluxDB Cloud + + - Doesn't require this parameter; + InfluxDB only returns resources allowed by the API token. + - in: query + name: name + schema: + type: string + description: | + The stack name. + Finds stack `events` with this name and returns the stacks. + + Repeatable. + To filter for more than one stack name, + repeat this parameter with each name--for example: + + - `http://localhost:8086/api/v2/stacks?&orgID=INFLUX_ORG_ID&name=project-stack-0&name=project-stack-1` + examples: + findStackByName: + summary: Find stacks with the event name + value: project-stack-0 + - in: query + name: stackID + schema: + type: string + description: | + The stack ID. + Only returns stacks with this ID. + + Repeatable. + To filter for more than one stack ID, + repeat this parameter with each ID--for example: + + - `http://localhost:8086/api/v2/stacks?&orgID=INFLUX_ORG_ID&stackID=09bd87cd33be3000&stackID=09bef35081fe3000` + examples: + findStackByID: + summary: Find a stack with the ID + value: 09bd87cd33be3000 + responses: + '200': + description: Success. The response body contains the list of stacks. + content: + application/json: + schema: + type: object + properties: + stacks: + type: array + items: + $ref: '#/components/schemas/Stack' + '400': + description: | + Bad request. + The response body contains detail about the error. + + #### InfluxDB OSS + + - Returns this error if an incorrect value is passed for `org` or `orgID`. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + orgIdMissing: + summary: The orgID query parameter is missing + value: + code: invalid + message: 'organization id[""] is invalid: id must have a length of 16 bytes' + orgProvidedNotFound: + summary: The org or orgID passed doesn't own the token passed in the header + value: + code: invalid + message: 'failed to decode request body: organization not found' + '401': + $ref: '#/components/responses/AuthorizationError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: CreateStack + tags: + - Templates + summary: Create a stack + description: | + Creates or initializes a stack. + + Use this endpoint to _manually_ initialize a new stack with the following + optional information: + + - Stack name + - Stack description + - URLs for template manifest files + + To automatically create a stack when applying templates, + use the [/api/v2/templates/apply endpoint](#operation/ApplyTemplate). + + #### Required permissions + + - `write` permission for the organization + + #### Related guides + + - [InfluxDB stacks](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/stacks/) + - [Use InfluxDB templates](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/use/#apply-templates-to-an-influxdb-instance) + requestBody: + description: The stack to create. + required: true + content: + application/json: + schema: + type: object + title: PostStackRequest + properties: + orgID: + type: string + name: + type: string + description: + type: string + urls: + type: array + items: + type: string + responses: + '201': + description: Success. Returns the newly created stack. + content: + application/json: + schema: + $ref: '#/components/schemas/Stack' + '401': + $ref: '#/components/responses/AuthorizationError' + '422': + description: | + Unprocessable entity. + + The error may indicate one of the following problems: + + - The request body isn't valid--the request is well-formed, but InfluxDB can't process it due to semantic errors. + - You passed a parameter combination that InfluxDB doesn't support. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/stacks/{stack_id}': + get: + operationId: ReadStack + tags: + - Templates + summary: Retrieve a stack + parameters: + - in: path + name: stack_id + required: true + schema: + type: string + description: The identifier of the stack. + responses: + '200': + description: Returns the stack. + content: + application/json: + schema: + $ref: '#/components/schemas/Stack' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + operationId: UpdateStack + tags: + - Templates + summary: Update a stack + parameters: + - in: path + name: stack_id + required: true + schema: + type: string + description: The identifier of the stack. + requestBody: + description: The stack to update. + required: true + content: + application/json: + schema: + type: object + title: PatchStackRequest + properties: + name: + type: string + nullable: true + description: + type: string + nullable: true + templateURLs: + type: array + items: + type: string + nullable: true + additionalResources: + type: array + items: + type: object + properties: + resourceID: + type: string + kind: + type: string + templateMetaName: + type: string + required: + - kind + - resourceID + responses: + '200': + description: Returns the updated stack. + content: + application/json: + schema: + $ref: '#/components/schemas/Stack' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + operationId: DeleteStack + tags: + - Templates + summary: Delete a stack and associated resources + parameters: + - in: path + name: stack_id + required: true + schema: + type: string + description: The identifier of the stack. + - in: query + name: orgID + required: true + schema: + type: string + description: The identifier of the organization. + responses: + '204': + description: The stack and its associated resources were deleted. + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/stacks/{stack_id}/uninstall': + post: + operationId: UninstallStack + tags: + - Templates + summary: Uninstall a stack + parameters: + - in: path + name: stack_id + required: true + schema: + type: string + description: The identifier of the stack. + responses: + '200': + description: Returns the uninstalled stack. + content: + application/json: + schema: + $ref: '#/components/schemas/Stack' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /templates/apply: + post: + operationId: ApplyTemplate + tags: + - Templates + summary: Apply or dry-run a template + description: | + Applies a template to + create or update a [stack](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/stacks/) of InfluxDB + [resources](https://docs.influxdata.com/influxdb/v2.3/reference/cli/influx/export/all/#resources). + The response contains the diff of changes and the stack ID. + + Use this endpoint to install an InfluxDB template to an organization. + Provide template URLs or template objects in your request. + To customize which template resources are installed, use the `actions` + parameter. + + By default, when you apply a template, InfluxDB installs the template to + create and update stack resources and then generates a diff of the changes. + If you pass `dryRun: true` in the request body, InfluxDB validates the + template and generates the resource diff, but doesn’t make any + changes to your instance. + + #### Custom values for templates + + - Some templates may contain [environment references](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/create/#include-user-definable-resource-names) for custom metadata. + To provide custom values for environment references, pass the _`envRefs`_ + property in the request body. + For more information and examples, see how to + [define environment references](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/use/#define-environment-references). + + - Some templates may contain queries that use + [secrets](https://docs.influxdata.com/influxdb/v2.3/security/secrets/). + To provide custom secret values, pass the _`secrets`_ property + in the request body. + Don't expose secret values in templates. + For more information, see [how to pass secrets when installing a template](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/use/#pass-secrets-when-installing-a-template). + + #### Required permissions + + - `write` permissions for resource types in the template. + + #### Rate limits (with InfluxDB Cloud) + + - Adjustable service quotas apply. + For more information, see [limits and adjustable quotas](https://docs.influxdata.com/influxdb/cloud/account-management/limits/). + + #### Related guides + + - [Use templates](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/use/) + - [Stacks](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/stacks/) + requestBody: + required: true + description: | + Parameters for applying templates. + content: + application/json: + schema: + $ref: '#/components/schemas/TemplateApply' + examples: + skipKindAction: + summary: Skip all bucket and task resources in the provided templates + value: + orgID: INFLUX_ORG_ID + actions: + - action: skipKind + properties: + kind: Bucket + - action: skipKind + properties: + kind: Task + templates: + - contents: + - '[object Object]': null + skipResourceAction: + summary: Skip specific resources in the provided templates + value: + orgID: INFLUX_ORG_ID + actions: + - action: skipResource + properties: + kind: Label + resourceTemplateName: foo-001 + - action: skipResource + properties: + kind: Bucket + resourceTemplateName: bar-020 + - action: skipResource + properties: + kind: Bucket + resourceTemplateName: baz-500 + templates: + - contents: + - apiVersion: influxdata.com/v2alpha1 + kind: Bucket + metadata: + name: baz-500 + templateObjectEnvRefs: + summary: envRefs for template objects + value: + orgID: INFLUX_ORG_ID + envRefs: + linux-cpu-label: MY_CPU_LABEL + docker-bucket: MY_DOCKER_BUCKET + docker-spec-1: MY_DOCKER_SPEC + templates: + - contents: + - apiVersion: influxdata.com/v2alpha1 + kind: Label + metadata: + name: + envRef: + key: linux-cpu-label + spec: + color: '#326BBA' + name: inputs.cpu + - contents: + - apiVersion: influxdata.com/v2alpha1 + kind: Bucket + metadata: + name: + envRef: + key: docker-bucket + application/x-jsonnet: + schema: + $ref: '#/components/schemas/TemplateApply' + text/yml: + schema: + $ref: '#/components/schemas/TemplateApply' + x-codeSamples: + - lang: Shell + label: 'cURL: Dry run with a remote template' + source: | + curl --request POST "http://localhost:8086/api/v2/templates/apply" \ + --header "Authorization: Token INFLUX_API_TOKEN" \ + --data @- << EOF + { + "dryRun": true, + "orgID": "INFLUX_ORG_ID", + "remotes": [ + { + "url": "https://raw.githubusercontent.com/influxdata/community-templates/master/linux_system/linux_system.yml" + } + ] + } + EOF + - lang: Shell + label: 'cURL: Apply with secret values' + source: | + curl "http://localhost:8086/api/v2/templates/apply" \ + --header "Authorization: Token INFLUX_API_TOKEN" \ + --data @- << EOF | jq . + { + "orgID": "INFLUX_ORG_ID", + "secrets": { + "SLACK_WEBHOOK": "YOUR_SECRET_WEBHOOK_URL" + }, + "remotes": [ + { + "url": "https://raw.githubusercontent.com/influxdata/community-templates/master/fortnite/fn-template.yml" + } + ] + } + EOF + - lang: Shell + label: 'cURL: Apply template objects with environment references' + source: | + curl --request POST "http://localhost:8086/api/v2/templates/apply" \ + --header "Authorization: Token INFLUX_API_TOKEN" \ + --data @- << EOF + { "orgID": "INFLUX_ORG_ID", + "envRefs": { + "linux-cpu-label": "MY_CPU_LABEL", + "docker-bucket": "MY_DOCKER_BUCKET", + "docker-spec-1": "MY_DOCKER_SPEC" + }, + "templates": [ + { "contents": [{ + "apiVersion": "influxdata.com/v2alpha1", + "kind": "Label", + "metadata": { + "name": { + "envRef": { + "key": "linux-cpu-label" + } + } + }, + "spec": { + "color": "#326BBA", + "name": "inputs.cpu" + } + }] + }, + "templates": [ + { "contents": [{ + "apiVersion": "influxdata.com/v2alpha1", + "kind": "Label", + "metadata": { + "name": { + "envRef": { + "key": "linux-cpu-label" + } + } + }, + "spec": { + "color": "#326BBA", + "name": "inputs.cpu" + } + }] + }, + { "contents": [{ + "apiVersion": "influxdata.com/v2alpha1", + "kind": "Bucket", + "metadata": { + "name": { + "envRef": { + "key": "docker-bucket" + } + } + } + }] + } + ] + } + EOF + responses: + '200': + description: | + Success. + The template dry run succeeded. + The response body contains a resource diff of changes that the + template would have made if installed. + No resources were created or updated. + The diff and summary won't contain IDs for resources + that didn't exist at the time of the dry run. + content: + application/json: + schema: + $ref: '#/components/schemas/TemplateSummary' + '201': + description: | + Success. + The template applied successfully. + The response body contains the stack ID, a diff, and a summary. + The diff compares the initial state to the state after the template installation. + The summary contains newly created resources. + content: + application/json: + schema: + $ref: '#/components/schemas/TemplateSummary' + '422': + description: | + Unprocessable entity. + + + The error may indicate one of the following problems: + + - The template failed validation. + - You passed a parameter combination that InfluxDB doesn't support. + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/TemplateSummary' + - type: object + required: + - message + - code + properties: + message: + type: string + code: + type: string + '500': + description: | + Internal server error. + + #### InfluxDB Cloud + + - Returns this error if creating one of the template + resources (bucket, dashboard, task, user) exceeds your plan’s + adjustable service quotas. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + createExceedsQuota: + summary: 'InfluxDB Cloud: Creating resource would exceed quota.' + value: + code: internal error + message: "resource_type=\"tasks\" err=\"failed to apply resource\"\n\tmetadata_name=\"alerting-gates-b84003\" err_msg=\"failed to create tasks[\\\"alerting-gates-b84003\\\"]: creating task would exceed quota\"" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /templates/export: + post: + operationId: ExportTemplate + tags: + - Templates + summary: Export a new template + requestBody: + description: Export resources as an InfluxDB template. + required: false + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/TemplateExportByID' + - $ref: '#/components/schemas/TemplateExportByName' + responses: + '200': + description: The template was created successfully. Returns the newly created template. + content: + application/json: + schema: + $ref: '#/components/schemas/Template' + application/x-yaml: + schema: + $ref: '#/components/schemas/Template' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/tasks/{taskID}/runs': + get: + operationId: GetTasksIDRuns + tags: + - Tasks + summary: List runs for a task + description: | + Retrieves a list of runs for a [task](https://docs.influxdata.com/influxdb/v2.3/process-data/). + + To limit which task runs are returned, pass query parameters in your request. + If no query parameters are passed, InfluxDB returns all task runs up to the default `limit`. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: | + The ID of the task to get runs for. + Only returns runs for this task. + - in: query + name: after + schema: + type: string + description: A task run ID. Only returns runs created after this run. + - in: query + name: limit + schema: + type: integer + minimum: 1 + maximum: 500 + default: 100 + description: | + Limits the number of task runs returned. Default is `100`. + - in: query + name: afterTime + schema: + type: string + format: date-time + description: | + A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp)). + Only returns runs scheduled after this time. + - in: query + name: beforeTime + schema: + type: string + format: date-time + description: | + A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp)). + Only returns runs scheduled before this time. + responses: + '200': + description: Success. The response body contains the list of task runs. + content: + application/json: + schema: + $ref: '#/components/schemas/Runs' + '401': + $ref: '#/components/responses/AuthorizationError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + post: + operationId: PostTasksIDRuns + tags: + - Data I/O endpoints + - Tasks + summary: 'Start a task run, overriding the schedule' + description: | + Schedules a task run to start immediately, ignoring scheduled runs. + + Use this endpoint to manually start a task run. + Scheduled runs will continue to run as scheduled. + This may result in concurrently running tasks. + + To _retry_ a previous run (and avoid creating a new run), + use the [`POST /api/v2/tasks/{taskID}/runs/{runID}/retry`](#operation/PostTasksIDRunsIDRetry) endpoint. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RunManually' + responses: + '201': + description: Success. The run is scheduled to start. + content: + application/json: + schema: + $ref: '#/components/schemas/Run' + '401': + $ref: '#/components/responses/AuthorizationError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + '/tasks/{taskID}/runs/{runID}': + get: + operationId: GetTasksIDRunsID + tags: + - Tasks + summary: Retrieve a run for a task. + description: | + Retrieves a specific run for a [task](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#task). + + Use this endpoint to retrieve detail and logs for a specific task run. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to retrieve runs for. + - in: path + name: runID + schema: + type: string + required: true + description: The ID of the run to retrieve. + responses: + '200': + description: Success. The response body contains the task run. + content: + application/json: + schema: + $ref: '#/components/schemas/Run' + examples: + runSuccess: + summary: A successful task run. + value: + links: + logs: /api/v2/tasks/0996e56b2f378000/runs/09b070dadaa7d000/logs + retry: /api/v2/tasks/0996e56b2f378000/runs/09b070dadaa7d000/retry + self: /api/v2/tasks/0996e56b2f378000/runs/09b070dadaa7d000 + task: /api/v2/tasks/0996e56b2f378000 + id: 09b070dadaa7d000 + taskID: 0996e56b2f378000 + status: success + scheduledFor: '2022-07-18T14:46:06Z' + startedAt: '2022-07-18T14:46:07.16222Z' + finishedAt: '2022-07-18T14:46:07.308254Z' + requestedAt: '2022-07-18T14:46:06Z' + log: + - runID: 09b070dadaa7d000 + time: '2022-07-18T14:46:07.101231Z' + message: 'Started task from script: "option task = {name: \"task1\", every: 30m} from(bucket: \"iot_center\") |> range(start: -90d) |> filter(fn: (r) => r._measurement == \"environment\") |> aggregateWindow(every: 1h, fn: mean)"' + - runID: 09b070dadaa7d000 + time: '2022-07-18T14:46:07.242859Z' + message: Completed(success) + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + delete: + operationId: DeleteTasksIDRunsID + tags: + - Tasks + summary: Cancel a running task + description: | + Cancels a running [task](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#task). + + Use this endpoint with InfluxDB OSS to cancel a running task. + + #### InfluxDB Cloud + + - Doesn't support this operation. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to cancel. + - in: path + name: runID + schema: + type: string + required: true + description: The ID of the task run to cancel. + responses: + '204': + description: | + Success. The `DELETE` is accepted and the run will be cancelled. + + #### InfluxDB Cloud + + - Doesn't support this operation. + - Doesn't return this status. + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '405': + description: | + Method not allowed. + + #### InfluxDB Cloud + + - Always returns this error; doesn't support cancelling tasks. + + #### InfluxDB OSS + + - Doesn't return this error. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + '/tasks/{taskID}/runs/{runID}/retry': + post: + operationId: PostTasksIDRunsIDRetry + tags: + - Tasks + summary: Retry a task run + description: | + Queues a task run to retry and returns the newly scheduled run. + + To manually start a _new_ task run, use the [`POST /api/v2/tasks/{taskID}/runs`](#operation/PostTasksIDRuns) endpoint. + + #### Limitations + + - The task must be _active_ (`status: "active"`). + requestBody: + content: + application/json; charset=utf-8: + schema: + type: object + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to retry. + - in: path + name: runID + schema: + type: string + required: true + description: The ID of the task run to retry. + responses: + '200': + description: Success. The response body contains the queued run. + content: + application/json: + schema: + $ref: '#/components/schemas/Run' + examples: + retryTaskRun: + summary: A task run scheduled to retry + value: + links: + logs: /api/v2/tasks/09a776832f381000/runs/09d60ffe08738000/logs + retry: /api/v2/tasks/09a776832f381000/runs/09d60ffe08738000/retry + self: /api/v2/tasks/09a776832f381000/runs/09d60ffe08738000 + task: /api/v2/tasks/09a776832f381000 + id: 09d60ffe08738000 + taskID: 09a776832f381000 + status: scheduled + scheduledFor: '2022-08-15T00:00:00Z' + requestedAt: '2022-08-16T20:05:11.84145Z' + '400': + description: | + Bad request. + The response body contains detail about the error. + + InfluxDB may return this error for the following reasons: + + - The task has `status: inactive`. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + inactiveTask: + summary: Can't retry an inactive task + value: + code: invalid + message: 'failed to retry run: inactive task' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + '/tasks/{taskID}/logs': + get: + operationId: GetTasksIDLogs + tags: + - Tasks + summary: Retrieve all logs for a task + description: | + Retrieves a list of all logs for a [task](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#task). + + When an InfluxDB task runs, a “run” record is created in the task’s history. + Logs associated with each run provide relevant log messages, timestamps, and the exit status of the run attempt. + + Use this endpoint to retrieve only the log events for a task, + without additional task metadata. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + responses: + '200': + description: | + Success. The response body contains an `events` list with logs for the task. + Each log event `message` contains detail about the event. + If a task run fails, InfluxDB logs an event with the reason for the failure. + content: + application/json: + schema: + $ref: '#/components/schemas/Logs' + examples: + taskSuccess: + summary: Events for a successful task run. + value: + events: + - runID: 09b070dadaa7d000 + time: '2022-07-18T14:46:07.101231Z' + message: 'Started task from script: "option task = {name: \"task1\", every: 30m} from(bucket: \"iot_center\") |> range(start: -90d) |> filter(fn: (r) => r._measurement == \"environment\") |> aggregateWindow(every: 1h, fn: mean)"' + - runID: 09b070dadaa7d000 + time: '2022-07-18T14:46:07.242859Z' + message: Completed(success) + taskFailure: + summary: Events for a failed task run. + value: + events: + - runID: 09a946fc3167d000 + time: '2022-07-13T07:06:54.198167Z' + message: 'Started task from script: "option task = {name: \"test task\", every: 3d, offset: 0s}"' + - runID: 09a946fc3167d000 + time: '2022-07-13T07:07:13.104037Z' + message: Completed(failed) + - runID: 09a946fc3167d000 + time: '2022-07-13T08:24:37.115323Z' + message: 'error exhausting result iterator: error in query specification while starting program: this Flux script returns no streaming data. Consider adding a "yield" or invoking streaming functions directly, without performing an assignment' + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + '/tasks/{taskID}/runs/{runID}/logs': + get: + operationId: GetTasksIDRunsIDLogs + tags: + - Tasks + summary: Retrieve all logs for a run + description: | + Retrieves all logs for a task run. + A log is a list of run events with `runID`, `time`, and `message` properties. + + Use this endpoint to help analyze task performance and troubleshoot failed task runs. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to get logs for. + - in: path + name: runID + schema: + type: string + required: true + description: The ID of the run to get logs for. + responses: + '200': + description: | + Success. The response body contains an `events` list with logs for the task run. + Each log event `message` contains detail about the event. + If a run fails, InfluxDB logs an event with the reason for the failure. + content: + application/json: + schema: + $ref: '#/components/schemas/Logs' + examples: + taskSuccess: + summary: Events for a successful task run. + value: + events: + - runID: 09b070dadaa7d000 + time: '2022-07-18T14:46:07.101231Z' + message: 'Started task from script: "option task = {name: \"task1\", every: 30m} from(bucket: \"iot_center\") |> range(start: -90d) |> filter(fn: (r) => r._measurement == \"environment\") |> aggregateWindow(every: 1h, fn: mean)"' + - runID: 09b070dadaa7d000 + time: '2022-07-18T14:46:07.242859Z' + message: Completed(success) + taskFailure: + summary: Events for a failed task. + value: + events: + - runID: 09a946fc3167d000 + time: '2022-07-13T07:06:54.198167Z' + message: 'Started task from script: "option task = {name: \"test task\", every: 3d, offset: 0s}"' + - runID: 09a946fc3167d000 + time: '2022-07-13T07:07:13.104037Z' + message: Completed(failed) + - runID: 09a946fc3167d000 + time: '2022-07-13T08:24:37.115323Z' + message: 'error exhausting result iterator: error in query specification while starting program: this Flux script returns no streaming data. Consider adding a "yield" or invoking streaming functions directly, without performing an assignment' + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + '/tasks/{taskID}/labels': + get: + operationId: GetTasksIDLabels + tags: + - Tasks + summary: List labels for a task + description: | + Retrieves a list of all labels for a task. + + Labels may be used for grouping and filtering tasks. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to retrieve labels for. + responses: + '200': + description: Success. The response body contains a list of all labels for the task. + content: + application/json: + schema: + $ref: '#/components/schemas/LabelsResponse' + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + post: + operationId: PostTasksIDLabels + tags: + - Tasks + summary: Add a label to a task + description: | + Adds a label to a task. + + Use this endpoint to add a label that you can use to filter tasks in the InfluxDB UI. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to label. + requestBody: + description: An object that contains a _`labelID`_ to add to the task. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/LabelMapping' + responses: + '201': + description: Success. The response body contains a list of all labels for the task. + content: + application/json: + schema: + $ref: '#/components/schemas/LabelResponse' + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + '/tasks/{taskID}/labels/{labelID}': + delete: + operationId: DeleteTasksIDLabelsID + tags: + - Tasks + summary: Delete a label from a task + description: | + Deletes a label from a task. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to delete the label from. + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + '204': + description: Success. The label is deleted. + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + /flags: + get: + operationId: GetFlags + tags: + - Users + summary: Return the feature flags for the currently authenticated user + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '200': + description: Feature flags for the currently authenticated user + content: + application/json: + schema: + $ref: '#/components/schemas/Flags' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /me: + get: + operationId: GetMe + tags: + - Users + summary: Retrieve the currently authenticated user + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '200': + description: Success. The response body contains the currently authenticated user. + content: + application/json: + schema: + $ref: '#/components/schemas/UserResponse' + '401': + $ref: '#/components/responses/AuthorizationError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + /me/password: + put: + operationId: PutMePassword + tags: + - Users + summary: Update a password + description: | + #### InfluxDB Cloud + + InfluxDB Cloud doesn't support changing user passwords through the API. + Use the InfluxDB Cloud user interface to update your password. + security: + - BasicAuthentication: [] + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: The new password. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PasswordResetBody' + responses: + '204': + description: Success. The password was updated. + '400': + description: | + Bad request. + InfluxDB Cloud doesn't support changing passwords through the API and always responds with this status. + default: + description: Unsuccessful authentication + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/tasks/{taskID}/members': + get: + operationId: GetTasksIDMembers + deprecated: true + tags: + - Tasks + summary: List all task members + description: | + **Deprecated**: Tasks don't use `owner` and `member` roles. + Use [`/api/v2/authorizations`](#tag/Authorizations) to assign user permissions. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + responses: + '200': + description: | + Success. The response body contains a list of `users` that have + the `member` role for a task. + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceMembers' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostTasksIDMembers + deprecated: true + tags: + - Tasks + summary: Add a member to a task + description: | + **Deprecated**: Tasks don't use `owner` and `member` roles. + Use [`/api/v2/authorizations`](#tag/Authorizations) to assign user permissions. + + Adds a user to members of a task and returns the newly created member with + role and user detail. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + requestBody: + description: A user to add as a member of the task. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddResourceMemberRequestBody' + responses: + '201': + description: Created. The user is added to task members. + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceMember' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/tasks/{taskID}/members/{userID}': + delete: + operationId: DeleteTasksIDMembersID + deprecated: true + tags: + - Tasks + summary: Remove a member from a task + description: | + **Deprecated**: Tasks don't use `owner` and `member` roles. + Use [`/api/v2/authorizations`](#tag/Authorizations) to assign user permissions. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the member to remove. + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + responses: + '204': + description: Member removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/tasks/{taskID}/owners': + get: + operationId: GetTasksIDOwners + deprecated: true + tags: + - Tasks + summary: List all owners of a task + description: | + **Deprecated**: Tasks don't use `owner` and `member` roles. + Use [`/api/v2/authorizations`](#tag/Authorizations) to assign user permissions. + + Retrieves all users that have owner permission for a task. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to retrieve owners for. + responses: + '200': + description: | + Success. + The response contains a list of `users` that have the `owner` role for the task. + + If the task has no owners, the response contains an empty `users` array. + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceOwners' + '401': + $ref: '#/components/responses/AuthorizationError' + '422': + description: | + Unprocessable entity. + + The error may indicate one of the following problems: + + - The request body isn't valid--the request is well-formed, but InfluxDB can't process it due to semantic errors. + - You passed a parameter combination that InfluxDB doesn't support. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostTasksIDOwners + deprecated: true + tags: + - Tasks + summary: Add an owner for a task + description: | + **Deprecated**: Tasks don't use `owner` and `member` roles. + Use [`/api/v2/authorizations`](#tag/Authorizations) to assign user permissions. + + Assigns a task `owner` role to a user. + + Use this endpoint to create a _resource owner_ for the task. + A _resource owner_ is a user with `role: owner` for a specific resource. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + requestBody: + description: A user to add as an owner of the task. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddResourceMemberRequestBody' + responses: + '201': + description: | + Created. The task `owner` role is assigned to the user. + The response body contains the resource owner with + role and user detail. + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceOwner' + examples: + createdOwner: + summary: User has the owner role for the resource + value: + role: owner + links: + logs: /api/v2/users/0772396d1f411000/logs + self: /api/v2/users/0772396d1f411000 + id: 0772396d1f411000 + name: USER_NAME + status: active + '401': + $ref: '#/components/responses/AuthorizationError' + '422': + description: | + Unprocessable entity. + + The error may indicate one of the following problems: + + - The request body isn't valid--the request is well-formed, but InfluxDB can't process it due to semantic errors. + - You passed a parameter combination that InfluxDB doesn't support. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/tasks/{taskID}/owners/{userID}': + delete: + operationId: DeleteTasksIDOwnersID + deprecated: true + tags: + - Tasks + summary: Remove an owner from a task + description: | + **Deprecated**: Tasks don't use `owner` and `member` roles. + Use [`/api/v2/authorizations`](#tag/Authorizations) to assign user permissions. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the owner to remove. + - in: path + name: taskID + schema: + type: string + required: true + description: The task ID. + responses: + '204': + description: Owner removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/users/{userID}/password': + post: + operationId: PostUsersIDPassword + tags: + - Security and access endpoints + - Users + summary: Update a password + description: | + #### InfluxDB Cloud + + InfluxDB Cloud doesn't support changing user passwords through the API. + Use the InfluxDB Cloud user interface to update your password. + security: + - BasicAuthentication: [] + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The user ID. + requestBody: + description: New password + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PasswordResetBody' + responses: + '204': + description: Password successfully updated + '400': + description: | + Bad request. + InfluxDB Cloud doesn't support changing passwords through the API and always responds with this status. + default: + description: Unsuccessful authentication + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /checks: + get: + operationId: GetChecks + tags: + - Checks + summary: List all checks + parameters: + - $ref: '#/components/parameters/TraceSpan' + - $ref: '#/components/parameters/Offset' + - $ref: '#/components/parameters/Limit' + - in: query + name: orgID + required: true + description: Only show checks that belong to a specific organization ID. + schema: + type: string + responses: + '200': + description: A list of checks + content: + application/json: + schema: + $ref: '#/components/schemas/Checks' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: CreateCheck + tags: + - Checks + summary: Add new check + requestBody: + description: Check to create + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PostCheck' + responses: + '201': + description: Check created + content: + application/json: + schema: + $ref: '#/components/schemas/Check' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/checks/{checkID}': + get: + operationId: GetChecksID + tags: + - Checks + summary: Retrieve a check + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + responses: + '200': + description: The check requested + content: + application/json: + schema: + $ref: '#/components/schemas/Check' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + put: + operationId: PutChecksID + tags: + - Checks + summary: Update a check + requestBody: + description: Check update to apply + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Check' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + responses: + '200': + description: An updated check + content: + application/json: + schema: + $ref: '#/components/schemas/Check' + '404': + description: The check was not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + operationId: PatchChecksID + tags: + - Checks + summary: Update a check + requestBody: + description: Check update to apply + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CheckPatch' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + responses: + '200': + description: An updated check + content: + application/json: + schema: + $ref: '#/components/schemas/Check' + '404': + description: The check was not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + operationId: DeleteChecksID + tags: + - Checks + summary: Delete a check + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + responses: + '204': + description: Delete has been accepted + '404': + description: The check was not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/checks/{checkID}/labels': + get: + operationId: GetChecksIDLabels + tags: + - Checks + summary: List all labels for a check + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + responses: + '200': + description: A list of all labels for a check + content: + application/json: + schema: + $ref: '#/components/schemas/LabelsResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostChecksIDLabels + tags: + - Checks + summary: Add a label to a check + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/LabelMapping' + responses: + '201': + description: The label was added to the check + content: + application/json: + schema: + $ref: '#/components/schemas/LabelResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/checks/{checkID}/labels/{labelID}': + delete: + operationId: DeleteChecksIDLabelsID + tags: + - Checks + summary: Delete label from a check + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + '204': + description: Delete has been accepted + '404': + description: Check or label not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /notificationRules: + get: + operationId: GetNotificationRules + tags: + - NotificationRules + summary: List all notification rules + parameters: + - $ref: '#/components/parameters/TraceSpan' + - $ref: '#/components/parameters/Offset' + - $ref: '#/components/parameters/Limit' + - in: query + name: orgID + required: true + description: Only show notification rules that belong to a specific organization ID. + schema: + type: string + - in: query + name: checkID + description: Only show notifications that belong to the specific check ID. + schema: + type: string + - in: query + name: tag + description: Only return notification rules that "would match" statuses which contain the tag key value pairs provided. + schema: + type: string + pattern: '^[a-zA-Z0-9_]+:[a-zA-Z0-9_]+$' + example: 'env:prod' + responses: + '200': + description: A list of notification rules + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRules' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: CreateNotificationRule + tags: + - NotificationRules + summary: Add a notification rule + requestBody: + description: Notification rule to create + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PostNotificationRule' + responses: + '201': + description: Notification rule created + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRule' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/checks/{checkID}/query': + get: + operationId: GetChecksIDQuery + tags: + - Checks + summary: Retrieve a check query + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: checkID + schema: + type: string + required: true + description: The check ID. + responses: + '200': + description: The check query requested + content: + application/json: + schema: + $ref: '#/components/schemas/FluxResponse' + '400': + description: Invalid request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '404': + description: Check not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/notificationRules/{ruleID}': + get: + operationId: GetNotificationRulesID + tags: + - NotificationRules + summary: Retrieve a notification rule + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + responses: + '200': + description: The notification rule requested + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRule' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + put: + operationId: PutNotificationRulesID + tags: + - NotificationRules + summary: Update a notification rule + requestBody: + description: Notification rule update to apply + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRule' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + responses: + '200': + description: An updated notification rule + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRule' + '404': + description: The notification rule was not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + operationId: PatchNotificationRulesID + tags: + - NotificationRules + summary: Update a notification rule + requestBody: + description: Notification rule update to apply + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRuleUpdate' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + responses: + '200': + description: An updated notification rule + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRule' + '404': + description: The notification rule was not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + operationId: DeleteNotificationRulesID + tags: + - NotificationRules + summary: Delete a notification rule + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + responses: + '204': + description: Delete has been accepted + '404': + description: The check was not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/notificationRules/{ruleID}/labels': + get: + operationId: GetNotificationRulesIDLabels + tags: + - NotificationRules + summary: List all labels for a notification rule + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + responses: + '200': + description: A list of all labels for a notification rule + content: + application/json: + schema: + $ref: '#/components/schemas/LabelsResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostNotificationRuleIDLabels + tags: + - NotificationRules + summary: Add a label to a notification rule + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/LabelMapping' + responses: + '201': + description: The label was added to the notification rule + content: + application/json: + schema: + $ref: '#/components/schemas/LabelResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/notificationRules/{ruleID}/labels/{labelID}': + delete: + operationId: DeleteNotificationRulesIDLabelsID + tags: + - NotificationRules + summary: Delete label from a notification rule + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + '204': + description: Delete has been accepted + '404': + description: Rule or label not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/notificationRules/{ruleID}/query': + get: + operationId: GetNotificationRulesIDQuery + tags: + - Rules + summary: Retrieve a notification rule query + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: ruleID + schema: + type: string + required: true + description: The notification rule ID. + responses: + '200': + description: The notification rule query requested + content: + application/json: + schema: + $ref: '#/components/schemas/FluxResponse' + '400': + description: Invalid request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '404': + description: Notification rule not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /notificationEndpoints: + get: + operationId: GetNotificationEndpoints + tags: + - NotificationEndpoints + summary: List all notification endpoints + parameters: + - $ref: '#/components/parameters/TraceSpan' + - $ref: '#/components/parameters/Offset' + - $ref: '#/components/parameters/Limit' + - in: query + name: orgID + required: true + description: Only show notification endpoints that belong to specific organization ID. + schema: + type: string + responses: + '200': + description: A list of notification endpoints + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationEndpoints' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: CreateNotificationEndpoint + tags: + - NotificationEndpoints + summary: Add a notification endpoint + requestBody: + description: Notification endpoint to create + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PostNotificationEndpoint' + responses: + '201': + description: Notification endpoint created + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationEndpoint' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/notificationEndpoints/{endpointID}': + get: + operationId: GetNotificationEndpointsID + tags: + - NotificationEndpoints + summary: Retrieve a notification endpoint + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + responses: + '200': + description: The notification endpoint requested + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationEndpoint' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + put: + operationId: PutNotificationEndpointsID + tags: + - NotificationEndpoints + summary: Update a notification endpoint + requestBody: + description: A new notification endpoint to replace the existing endpoint with + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationEndpoint' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + responses: + '200': + description: An updated notification endpoint + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationEndpoint' + '404': + description: The notification endpoint was not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + operationId: PatchNotificationEndpointsID + tags: + - NotificationEndpoints + summary: Update a notification endpoint + requestBody: + description: Check update to apply + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationEndpointUpdate' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + responses: + '200': + description: An updated notification endpoint + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationEndpoint' + '404': + description: The notification endpoint was not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + operationId: DeleteNotificationEndpointsID + tags: + - NotificationEndpoints + summary: Delete a notification endpoint + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + responses: + '204': + description: Delete has been accepted + '404': + description: The endpoint was not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/notificationEndpoints/{endpointID}/labels': + get: + operationId: GetNotificationEndpointsIDLabels + tags: + - NotificationEndpoints + summary: List all labels for a notification endpoint + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + responses: + '200': + description: A list of all labels for a notification endpoint + content: + application/json: + schema: + $ref: '#/components/schemas/LabelsResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostNotificationEndpointIDLabels + tags: + - NotificationEndpoints + summary: Add a label to a notification endpoint + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/LabelMapping' + responses: + '201': + description: The label was added to the notification endpoint + content: + application/json: + schema: + $ref: '#/components/schemas/LabelResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/notificationEndpoints/{endpointID}/labels/{labelID}': + delete: + operationId: DeleteNotificationEndpointsIDLabelsID + tags: + - NotificationEndpoints + summary: Delete a label from a notification endpoint + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: endpointID + schema: + type: string + required: true + description: The notification endpoint ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The ID of the label to delete. + responses: + '204': + description: Delete has been accepted + '404': + description: Endpoint or label not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /debug/pprof/all: + get: + operationId: GetDebugPprofAllProfiles + tags: + - Debug + - System information endpoints + summary: Retrieve all runtime profiles + description: | + Collects samples and returns reports for the following [Go runtime profiles](https://pkg.go.dev/runtime/pprof): + + - **allocs**: All past memory allocations + - **block**: Stack traces that led to blocking on synchronization primitives + - **cpu**: (Optional) Program counters sampled from the executing stack. + Include by passing the `cpu` query parameter with a [duration](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#duration) value. + Equivalent to the report from [`GET /debug/pprof/profile?seconds=NUMBER_OF_SECONDS`](#operation/GetDebugPprofProfile). + - **goroutine**: All current goroutines + - **heap**: Memory allocations for live objects + - **mutex**: Holders of contended mutexes + - **threadcreate**: Stack traces that led to the creation of new OS threads + x-codeSamples: + - lang: Shell + label: 'Shell: Get all profiles' + source: | + # Download and extract a `tar.gz` of all profiles after 10 seconds of CPU sampling. + + curl "http://localhost:8086/debug/pprof/all?cpu=10s" | tar -xz + + # x profiles/cpu.pb.gz + # x profiles/goroutine.pb.gz + # x profiles/block.pb.gz + # x profiles/mutex.pb.gz + # x profiles/heap.pb.gz + # x profiles/allocs.pb.gz + # x profiles/threadcreate.pb.gz + + # Analyze a profile. + + go tool pprof profiles/heap.pb.gz + - lang: Shell + label: 'Shell: Get all profiles except CPU' + source: | + # Download and extract a `tar.gz` of all profiles except CPU. + + curl http://localhost:8086/debug/pprof/all | tar -xz + + # x profiles/goroutine.pb.gz + # x profiles/block.pb.gz + # x profiles/mutex.pb.gz + # x profiles/heap.pb.gz + # x profiles/allocs.pb.gz + # x profiles/threadcreate.pb.gz + + # Analyze a profile. + + go tool pprof profiles/heap.pb.gz + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: cpu + description: | + Collects and returns CPU profiling data for the specified [duration](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#duration). + schema: + type: string + format: duration + externalDocs: + description: InfluxDB duration + url: 'https://docs.influxdata.com/influxdb/latest/reference/glossary/#duration' + responses: + '200': + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) reports. + content: + application/octet-stream: + schema: + description: | + GZIP compressed TAR file (`.tar.gz`) that contains + [Go runtime profile](https://pkg.go.dev/runtime/pprof) reports. + type: string + format: binary + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /debug/pprof/allocs: + get: + operationId: GetDebugPprofAllocs + tags: + - Debug + - System information endpoints + summary: Retrieve the memory allocations runtime profile + description: | + Returns a [Go runtime profile](https://pkg.go.dev/runtime/pprof) report of + all past memory allocations. + **allocs** is the same as the **heap** profile, + but changes the default [pprof](https://pkg.go.dev/runtime/pprof) + display to __-alloc_space__, + the total number of bytes allocated since the program began (including garbage-collected bytes). + x-codeSamples: + - lang: Shell + label: 'Shell: go tool pprof' + source: | + # Analyze the profile in interactive mode. + + go tool pprof http://localhost:8086/debug/pprof/allocs + + # `pprof` returns the following prompt: + # Entering interactive mode (type "help" for commands, "o" for options) + # (pprof) + + # At the prompt, get the top N memory allocations. + + (pprof) top10 + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: debug + description: | + - `0`: (Default) Return the report as a gzip-compressed protocol buffer. + - `1`: Return a response body with the report formatted as human-readable text. + The report contains comments that translate addresses to function names and line numbers for debugging. + + `debug=1` is mutually exclusive with the `seconds` query parameter. + schema: + type: integer + format: int64 + enum: + - 0 + - 1 + - in: query + name: seconds + description: | + Number of seconds to collect statistics. + + `seconds` is mutually exclusive with `debug=1`. + schema: + type: string + format: int64 + responses: + '200': + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report compatible + with [pprof](https://github.com/google/pprof) analysis and visualization tools. + If debug is enabled (`?debug=1`), response body contains a human-readable profile. + content: + application/octet-stream: + schema: + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report in protocol buffer format. + type: string + format: binary + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + text/plain: + schema: + description: | + Response body contains a report formatted in plain text. + The report contains comments that translate addresses to + function names and line numbers for debugging. + type: string + format: Go runtime profile + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /debug/pprof/block: + get: + operationId: GetDebugPprofBlock + tags: + - Debug + - System information endpoints + summary: Retrieve the block runtime profile + description: | + Collects samples and returns a [Go runtime profile](https://pkg.go.dev/runtime/pprof) + report of stack traces that led to blocking on synchronization primitives. + x-codeSamples: + - lang: Shell + label: 'Shell: go tool pprof' + source: | + # Analyze the profile in interactive mode. + + go tool pprof http://localhost:8086/debug/pprof/block + + # `pprof` returns the following prompt: + # Entering interactive mode (type "help" for commands, "o" for options) + # (pprof) + + # At the prompt, get the top N entries. + + (pprof) top10 + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: debug + description: | + - `0`: (Default) Return the report as a gzip-compressed protocol buffer. + - `1`: Return a response body with the report formatted as human-readable text. + The report contains comments that translate addresses to function names and line numbers for debugging. + + `debug=1` is mutually exclusive with the `seconds` query parameter. + schema: + type: integer + format: int64 + enum: + - 0 + - 1 + - in: query + name: seconds + description: | + Number of seconds to collect statistics. + + `seconds` is mutually exclusive with `debug=1`. + schema: + type: string + format: int64 + responses: + '200': + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report compatible + with [pprof](https://github.com/google/pprof) analysis and visualization tools. + If debug is enabled (`?debug=1`), response body contains a human-readable profile. + content: + application/octet-stream: + schema: + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report in protocol buffer format. + type: string + format: binary + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + text/plain: + schema: + description: | + Response body contains a report formatted in plain text. + The report contains comments that translate addresses to + function names and line numbers for debugging. + type: string + format: Go runtime profile + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /debug/pprof/cmdline: + get: + operationId: GetDebugPprofCmdline + tags: + - Debug + - System information endpoints + summary: Retrieve the command line invocation + description: | + Returns the command line that invoked InfluxDB. + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '200': + description: Command line invocation. + content: + text/plain: + schema: + type: string + format: Command line + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /debug/pprof/goroutine: + get: + operationId: GetDebugPprofGoroutine + tags: + - Debug + - System information endpoints + summary: Retrieve the goroutines runtime profile + description: | + Collects statistics and returns a [Go runtime profile](https://pkg.go.dev/runtime/pprof) + report of all current goroutines. + x-codeSamples: + - lang: Shell + label: 'Shell: go tool pprof' + source: | + # Analyze the profile in interactive mode. + + go tool pprof http://localhost:8086/debug/pprof/goroutine + + # `pprof` returns the following prompt: + # Entering interactive mode (type "help" for commands, "o" for options) + # (pprof) + + # At the prompt, get the top N entries. + + (pprof) top10 + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: debug + description: | + - `0`: (Default) Return the report as a gzip-compressed protocol buffer. + - `1`: Return a response body with the report formatted as + human-readable text with comments that translate addresses to + function names and line numbers for debugging. + + `debug=1` is mutually exclusive with the `seconds` query parameter. + schema: + type: integer + format: int64 + enum: + - 0 + - 1 + - in: query + name: seconds + description: | + Number of seconds to collect statistics. + + `seconds` is mutually exclusive with `debug=1`. + schema: + type: string + format: int64 + responses: + '200': + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report compatible + with [pprof](https://github.com/google/pprof) analysis and visualization tools. + If debug is enabled (`?debug=1`), response body contains a human-readable profile. + content: + application/octet-stream: + schema: + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report in protocol buffer format. + type: string + format: binary + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + text/plain: + schema: + description: | + Response body contains a report formatted in plain text. + The report contains comments that translate addresses to + function names and line numbers for debugging. + type: string + format: Go runtime profile + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /debug/pprof/heap: + get: + operationId: GetDebugPprofHeap + tags: + - Debug + - System information endpoints + summary: Retrieve the heap runtime profile + description: | + Collects statistics and returns a [Go runtime profile](https://pkg.go.dev/runtime/pprof) + report of memory allocations for live objects. + + To run **garbage collection** before sampling, + pass the `gc` query parameter with a value of `1`. + x-codeSamples: + - lang: Shell + label: 'Shell: go tool pprof' + source: | + # Analyze the profile in interactive mode. + + go tool pprof http://localhost:8086/debug/pprof/heap + + # `pprof` returns the following prompt: + # Entering interactive mode (type "help" for commands, "o" for options) + # (pprof) + + # At the prompt, get the top N memory-intensive nodes. + + (pprof) top10 + + # pprof displays the list: + # Showing nodes accounting for 142.46MB, 85.43% of 166.75MB total + # Dropped 895 nodes (cum <= 0.83MB) + # Showing top 10 nodes out of 143 + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: debug + description: | + - `0`: (Default) Return the report as a gzip-compressed protocol buffer. + - `1`: Return a response body with the report formatted as human-readable text. + The report contains comments that translate addresses to function names and line numbers for debugging. + + `debug=1` is mutually exclusive with the `seconds` query parameter. + schema: + type: integer + format: int64 + enum: + - 0 + - 1 + - in: query + name: seconds + description: | + Number of seconds to collect statistics. + + `seconds` is mutually exclusive with `debug=1`. + schema: + type: string + format: int64 + - in: query + name: gc + description: | + - `0`: (Default) don't force garbage collection before sampling. + - `1`: Force garbage collection before sampling. + schema: + type: integer + format: int64 + enum: + - 0 + - 1 + responses: + '200': + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report compatible + with [pprof](https://github.com/google/pprof) analysis and visualization tools. + If debug is enabled (`?debug=1`), response body contains a human-readable profile. + content: + application/octet-stream: + schema: + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report in protocol buffer format. + type: string + format: binary + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + text/plain: + schema: + description: | + Response body contains a report formatted in plain text. + The report contains comments that translate addresses to + function names and line numbers for debugging. + type: string + format: Go runtime profile + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + examples: + profileDebugResponse: + summary: Profile in plain text + value: "heap profile: 12431: 137356528 [149885081: 846795139976] @ heap/8192\n23: 17711104 [46: 35422208] @ 0x4c6df65 0x4ce03ec 0x4cdf3c5 0x4c6f4db 0x4c9edbc 0x4bdefb3 0x4bf822a 0x567d158 0x567ced9 0x406c0a1\n#\t0x4c6df64\tgithub.com/influxdata/influxdb/v2/tsdb/engine/tsm1.(*entry).add+0x1a4\t\t\t\t\t/Users/me/github/influxdb/tsdb/engine/tsm1/cache.go:97\n#\t0x4ce03eb\tgithub.com/influxdata/influxdb/v2/tsdb/engine/tsm1.(*partition).write+0x2ab\t\t\t\t/Users/me/github/influxdb/tsdb/engine/tsm1/ring.go:229\n#\t0x4cdf3c4\tgithub.com/influxdata/influxdb/v2/tsdb/engine/tsm1.(*ring).write+0xa4\t\t\t\t\t/Users/me/github/influxdb/tsdb/engine/tsm1/ring.go:95\n#\t0x4c6f4da\tgithub.com/influxdata/influxdb/v2/tsdb/engine/tsm1.(*Cache).WriteMulti+0x31a\t\t\t\t/Users/me/github/influxdb/tsdb/engine/tsm1/cache.go:343\n" + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /debug/pprof/mutex: + get: + operationId: GetDebugPprofMutex + tags: + - Debug + - System information endpoints + summary: Retrieve the mutual exclusion (mutex) runtime profile + description: | + Collects statistics and returns a [Go runtime profile](https://pkg.go.dev/runtime/pprof) report of + lock contentions. + The profile contains stack traces of holders of contended mutual exclusions (mutexes). + x-codeSamples: + - lang: Shell + label: 'Shell: go tool pprof' + source: | + # Analyze the profile in interactive mode. + + go tool pprof http://localhost:8086/debug/pprof/mutex + + # `pprof` returns the following prompt: + # Entering interactive mode (type "help" for commands, "o" for options) + # (pprof) + + # At the prompt, get the top N entries. + + (pprof) top10 + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: debug + description: | + - `0`: (Default) Return the report as a gzip-compressed protocol buffer. + - `1`: Return a response body with the report formatted as human-readable text. + The report contains comments that translate addresses to function names and line numbers for debugging. + + `debug=1` is mutually exclusive with the `seconds` query parameter. + schema: + type: integer + format: int64 + enum: + - 0 + - 1 + - in: query + name: seconds + description: | + Number of seconds to collect statistics. + + `seconds` is mutually exclusive with `debug=1`. + schema: + type: string + format: int64 + responses: + '200': + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report compatible + with [pprof](https://github.com/google/pprof) analysis and visualization tools. + If debug is enabled (`?debug=1`), response body contains a human-readable profile. + content: + application/octet-stream: + schema: + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report in protocol buffer format. + type: string + format: binary + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + text/plain: + schema: + description: | + Response body contains a report formatted in plain text. + The report contains comments that translate addresses to + function names and line numbers for debugging. + type: string + format: Go runtime profile + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /debug/pprof/profile: + get: + operationId: GetDebugPprofProfile + tags: + - Debug + - System information endpoints + summary: Retrieve the CPU runtime profile + description: | + Collects statistics and returns a [Go runtime profile](https://pkg.go.dev/runtime/pprof) + report of program counters on the executing stack. + x-codeSamples: + - lang: Shell + label: 'Shell: go tool pprof' + source: | + # Download the profile report. + + curl http://localhost:8086/debug/pprof/profile -o cpu + + # Analyze the profile in interactive mode. + + go tool pprof ./cpu + + # At the prompt, get the top N functions most often running + # or waiting during the sample period. + + (pprof) top10 + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: seconds + description: Number of seconds to collect profile data. Default is `30` seconds. + schema: + type: string + format: int64 + responses: + '200': + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report compatible + with [pprof](https://github.com/google/pprof) analysis and visualization tools. + content: + application/octet-stream: + schema: + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report in protocol buffer format. + type: string + format: binary + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /debug/pprof/threadcreate: + get: + operationId: GetDebugPprofThreadCreate + tags: + - Debug + - System information endpoints + summary: Retrieve the threadcreate runtime profile + description: | + Collects statistics and returns a [Go runtime profile](https://pkg.go.dev/runtime/pprof) + report of stack traces that led to the creation of new OS threads. + x-codeSamples: + - lang: Shell + label: 'Shell: go tool pprof' + source: | + # Analyze the profile in interactive mode. + + go tool pprof http://localhost:8086/debug/pprof/threadcreate + + # `pprof` returns the following prompt: + # Entering interactive mode (type "help" for commands, "o" for options) + # (pprof) + + # At the prompt, get the top N entries. + + (pprof) top10 + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: debug + description: | + - `0`: (Default) Return the report as a gzip-compressed protocol buffer. + - `1`: Return a response body with the report formatted as human-readable text. + The report contains comments that translate addresses to function names and line numbers for debugging. + + `debug=1` is mutually exclusive with the `seconds` query parameter. + schema: + type: integer + format: int64 + enum: + - 0 + - 1 + - in: query + name: seconds + description: | + Number of seconds to collect statistics. + + `seconds` is mutually exclusive with `debug=1`. + schema: + type: string + format: int64 + responses: + '200': + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report compatible + with [pprof](https://github.com/google/pprof) analysis and visualization tools. + If debug is enabled (`?debug=1`), response body contains a human-readable profile. + content: + application/octet-stream: + schema: + description: | + [Go runtime profile](https://pkg.go.dev/runtime/pprof) report in protocol buffer format. + type: string + format: binary + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + text/plain: + schema: + description: | + Response body contains a report formatted in plain text. + The report contains comments that translate addresses to + function names and line numbers for debugging. + type: string + format: Go runtime profile + externalDocs: + description: Golang pprof package + url: 'https://pkg.go.dev/net/http/pprof' + examples: + profileDebugResponse: + summary: Profile in plain text + value: "threadcreate profile: total 26\n25 @\n#\t0x0\n\n1 @ 0x403dda8 0x403e54b 0x403e810 0x403a90c 0x406c0a1\n#\t0x403dda7\truntime.allocm+0xc7\t\t\t/Users/me/.gvm/gos/go1.17/src/runtime/proc.go:1877\n#\t0x403e54a\truntime.newm+0x2a\t\t\t/Users/me/.gvm/gos/go1.17/src/runtime/proc.go:2201\n#\t0x403e80f\truntime.startTemplateThread+0x8f\t/Users/me/.gvm/gos/go1.17/src/runtime/proc.go:2271\n#\t0x403a90b\truntime.main+0x1cb\t\t\t/Users/me/.gvm/gos/go1.17/src/runtime/proc.go:234\n" + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /debug/pprof/trace: + get: + operationId: GetDebugPprofTrace + tags: + - Debug + - System information endpoints + summary: Retrieve the runtime execution trace + description: | + Collects profile data and returns trace execution events for the current program. + x-codeSamples: + - lang: Shell + label: 'Shell: go tool trace' + source: | + # Download the trace file. + + curl http://localhost:8086/debug/pprof/trace -o trace + + # Analyze the trace. + + go tool trace ./trace + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: seconds + description: Number of seconds to collect profile data. + schema: + type: string + format: int64 + responses: + '200': + description: | + [Trace file](https://pkg.go.dev/runtime/trace) compatible + with the [Golang `trace` command](https://pkg.go.dev/cmd/trace). + content: + application/octet-stream: + schema: + type: string + format: binary + externalDocs: + description: Golang trace package + url: 'https://pkg.go.dev/runtime/trace' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /health: + get: + operationId: GetHealth + tags: + - Health + - System information endpoints + summary: Retrieve the health of the instance + description: Returns the health of the instance. + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '200': + description: | + The instance is healthy. + The response body contains the health check items and status. + content: + application/json: + schema: + $ref: '#/components/schemas/HealthCheck' + '503': + description: The instance is unhealthy. + content: + application/json: + schema: + $ref: '#/components/schemas/HealthCheck' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /metrics: + get: + operationId: GetMetrics + tags: + - Metrics + - System information endpoints + summary: Retrieve workload performance metrics + description: | + Returns metrics about the workload performance of an InfluxDB instance. + + Use this endpoint to get performance, resource, and usage metrics. + + #### Related guides + + - For the list of metrics categories, see [InfluxDB OSS metrics](https://docs.influxdata.com/influxdb/v2.3/reference/internals/metrics/). + - Learn how to use InfluxDB to [scrape Prometheus metrics](https://docs.influxdata.com/influxdb/v2.3/write-data/developer-tools/scrape-prometheus-metrics/). + - Learn how InfluxDB [parses the Prometheus exposition format](https://docs.influxdata.com/influxdb/v2.3/reference/prometheus-metrics/). + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '200': + description: | + Success. The response body contains metrics in + [Prometheus plain-text exposition format](https://prometheus.io/docs/instrumenting/exposition_formats) + Metrics contain a name, an optional set of key-value pairs, and a value. + + The following descriptors precede each metric: + + - `HELP`: description of the metric + - `TYPE`: [Prometheus metric type](https://prometheus.io/docs/concepts/metric_types/) (`counter`, `gauge`, `histogram`, or `summary`) + content: + text/plain: + schema: + type: string + format: Prometheus text-based exposition + externalDocs: + description: Prometheus exposition formats + url: 'https://prometheus.io/docs/instrumenting/exposition_formats' + examples: + expositionResponse: + summary: Metrics in plain text + value: | + # HELP go_threads Number of OS threads created. + # TYPE go_threads gauge + go_threads 19 + # HELP http_api_request_duration_seconds Time taken to respond to HTTP request + # TYPE http_api_request_duration_seconds histogram + http_api_request_duration_seconds_bucket{handler="platform",method="GET",path="/:fallback_path",response_code="200",status="2XX",user_agent="curl",le="0.005"} 4 + http_api_request_duration_seconds_bucket{handler="platform",method="GET",path="/:fallback_path",response_code="200",status="2XX",user_agent="curl",le="0.01"} 4 + http_api_request_duration_seconds_bucket{handler="platform",method="GET",path="/:fallback_path",response_code="200",status="2XX",user_agent="curl",le="0.025"} 5 + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /ready: + get: + operationId: GetReady + tags: + - Ready + - System information endpoints + summary: Get the readiness of an instance at startup + servers: + - url: '' + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '200': + description: The instance is ready + content: + application/json: + schema: + $ref: '#/components/schemas/Ready' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /users: + get: + operationId: GetUsers + tags: + - Security and access endpoints + - Users + summary: List users + description: | + Retrieves a list of users. Default limit is `20`. + + To limit which users are returned, pass query parameters in your request. + + #### Required permissions + + - `read-user USER_ID` permission. + `USER_ID` is the ID of the user that you want to list. + - InfluxDB OSS requires an _[operator token](https://docs.influxdata.com/influxdb/latest/security/tokens/#operator-token))_ to list all users. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - $ref: '#/components/parameters/Offset' + - $ref: '#/components/parameters/Limit' + - $ref: '#/components/parameters/After' + - in: query + name: name + schema: + type: string + - in: query + name: id + schema: + type: string + responses: + '200': + description: Success. The response contains a list of `users`. + content: + application/json: + schema: + $ref: '#/components/schemas/Users' + '401': + description: | + Unauthorized. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + tokenNotAuthorized: + summary: 'API token doesn''t have `write:users` permission' + value: + code: unauthorized + message: 'write:users/09d8462ce0764000 is unauthorized' + '422': + description: | + Unprocessable entity. + + The error may indicate one of the following problems: + + - The request body isn't valid--the request is well-formed, but InfluxDB can't process it due to semantic errors. + - You passed a parameter combination that InfluxDB doesn't support. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + post: + operationId: PostUsers + tags: + - Users + summary: Create a user + description: | + Creates a user and returns the newly created user. + + #### Required permissions + + - `write-users`. Requires an InfluxDB API **Op** token. + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: The user to create. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/User' + responses: + '201': + description: | + Success. + The response contains the newly created user. + content: + application/json: + schema: + $ref: '#/components/schemas/UserResponse' + '401': + description: | + Unauthorized. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + tokenNotAuthorized: + summary: 'API token doesn''t have `write:users` permission' + value: + code: unauthorized + message: 'write:users/09d8462ce0764000 is unauthorized' + '422': + description: | + Unprocessable entity. + + The error may indicate one of the following problems: + + - The request body isn't valid--the request is well-formed, but InfluxDB can't process it due to semantic errors. + - You passed a parameter combination that InfluxDB doesn't support. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + x-codeSamples: + - label: 'cURL: create a user and set a password' + lang: Shell + source: | + # Create the user and assign the user ID to a variable. + USER_ID=$(curl --request POST \ + "http://localhost:8086/api/v2/users/" \ + --header "Authorization: Token INFLUX_OP_TOKEN" \ + --header 'Content-type: application/json' \ + --data-binary @- << EOF | jq -r '.id' + { + "name": "USER_NAME", + "status": "active" + } + EOF + ) + + # Pass the user ID and a password to set the password for the user. + curl request POST "http://localhost:8086/api/v2/users/$USER_ID/password/" \ + --header "Authorization: Token INFLUX_OP_TOKEN" \ + --header 'Content-type: application/json' \ + --data '{ "password": "USER_PASSWORD" }' + '/users/{userID}': + get: + operationId: GetUsersID + tags: + - Security and access endpoints + - Users + summary: Retrieve a user + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The user ID. + responses: + '200': + description: User details + content: + application/json: + schema: + $ref: '#/components/schemas/UserResponse' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + patch: + operationId: PatchUsersID + tags: + - Users + summary: Update a user + requestBody: + description: User update to apply + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/User' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the user to update. + responses: + '200': + description: User updated + content: + application/json: + schema: + $ref: '#/components/schemas/UserResponse' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + delete: + operationId: DeleteUsersID + tags: + - Users + summary: Delete a user + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of the user to delete. + responses: + '204': + description: User deleted + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /setup: + get: + operationId: GetSetup + tags: + - Setup + summary: 'Check if database has default user, org, bucket' + description: 'Returns `true` if no default user, organization, or bucket has been created.' + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '200': + description: allowed true or false + content: + application/json: + schema: + $ref: '#/components/schemas/IsOnboarding' + post: + operationId: PostSetup + tags: + - Setup + summary: 'Set up initial user, org and bucket' + description: 'Post an onboarding request to set up initial user, org and bucket.' + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: Source to create + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OnboardingRequest' + responses: + '201': + description: 'Created default user, bucket, org' + content: + application/json: + schema: + $ref: '#/components/schemas/OnboardingResponse' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /authorizations: + get: + operationId: GetAuthorizations + tags: + - Authorizations + - Security and access endpoints + summary: List authorizations + description: | + Retrieves a list of authorizations. + + To limit which authorizations are returned, pass query parameters in your request. + If no query parameters are passed, InfluxDB returns all authorizations. + + #### InfluxDB Cloud + + - Doesn't expose [API token](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#token) values in `GET /api/v2/authorizations` responses; returns `token: redacted` for all authorizations. + + #### InfluxDB OSS + + - Returns + [API token](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#token) values in authorizations. + - Requires an _[operator token](https://docs.influxdata.com/influxdb/latest/security/tokens/#operator-token))_ to view authorizations. + + #### Related guides + + - [View tokens](https://docs.influxdata.com/influxdb/v2.3/security/tokens/view-tokens/). + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: userID + schema: + type: string + description: | + A user ID. + Only returns authorizations scoped to this user. + - in: query + name: user + schema: + type: string + description: | + A user name. + Only returns authorizations scoped to this user. + - in: query + name: orgID + schema: + type: string + description: An organization ID. Only returns authorizations that belong to this organization. + - in: query + name: org + schema: + type: string + description: | + An organization name. + Only returns authorizations that belong to this organization. + responses: + '200': + description: Success. The response body contains a list of authorizations. + content: + application/json: + schema: + $ref: '#/components/schemas/Authorizations' + '400': + description: Invalid request + $ref: '#/components/responses/GeneralServerError' + '401': + $ref: '#/components/responses/AuthorizationError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + post: + operationId: PostAuthorizations + tags: + - Authorizations + summary: Create an authorization + description: | + Creates an authorization and returns the newly created authorization. + + Use this endpoint to generate an API token with resource permissions. + A permission sets `read` or `write` access to a `type` of resource. + + Keep the following in mind when creating and updating authorizations: + + - A permission with a resource `id` applies only to the resource specified by the ID. + - A permission that doesn't have a resource `id` applies to all resources of resource `type`. + - To scope an authorization to a specific user, provide the `userID` property. + + #### Related guides + + - [Create a token](https://docs.influxdata.com/influxdb/v2.3/security/tokens/create-token/). + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: The authorization to create. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AuthorizationPostRequest' + responses: + '201': + description: Created. The response body contains the newly created authorization. + content: + application/json: + schema: + $ref: '#/components/schemas/Authorization' + '400': + description: Invalid request + $ref: '#/components/responses/GeneralServerError' + '401': + $ref: '#/components/responses/AuthorizationError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + x-codeSample: + - lang: Shell + label: 'cURL: Create auth to read all buckets' + source: | + curl --request POST \ + "http://localhost:8086/api/v2/authorizations" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header 'Content-Type: application/json' \ + --data @- << EOF + { + "orgID": "INFLUX_ORG_ID", + "description": "iot_users read buckets", + "permissions": [ + {"action": "read", "resource": {"type": "buckets"}} + ] + } + EOF + - lang: Shell + - label: 'cURL: Create auth scoped to a user' + - source: | + curl --request POST \ + "http://localhost:8086/api/v2/authorizations" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header 'Content-Type: application/json' \ + --data @- << EOF + { + "orgID": "INFLUX_ORG_ID", + "userID": "INFLUX_USER_ID", + "description": "iot_user write to bucket", + "permissions": [ + {"action": "write", "resource": {"type": "buckets", "id: "INFLUX_BUCKET_ID"}} + ] + } + EOF + '/authorizations/{authID}': + get: + operationId: GetAuthorizationsID + tags: + - Authorizations + - Security and access endpoints + summary: Retrieve an authorization + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: authID + schema: + type: string + required: true + description: The ID of the authorization to get. + responses: + '200': + description: Authorization details + content: + application/json: + schema: + $ref: '#/components/schemas/Authorization' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + patch: + operationId: PatchAuthorizationsID + tags: + - Authorizations + summary: Update an authorization to be active or inactive + requestBody: + description: Authorization to update + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AuthorizationUpdateRequest' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: authID + schema: + type: string + required: true + description: The ID of the authorization to update. + responses: + '200': + description: The active or inactive authorization + content: + application/json: + schema: + $ref: '#/components/schemas/Authorization' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + delete: + operationId: DeleteAuthorizationsID + tags: + - Authorizations + summary: Delete an authorization + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: authID + schema: + type: string + required: true + description: The ID of the authorization to delete. + responses: + '204': + description: Authorization deleted + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /variables: + get: + operationId: GetVariables + tags: + - Variables + summary: List all variables + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: org + description: The name of the organization. + schema: + type: string + - in: query + name: orgID + description: The organization ID. + schema: + type: string + responses: + '200': + description: A list of variables for an organization + content: + application/json: + schema: + $ref: '#/components/schemas/Variables' + '400': + description: Invalid request + $ref: '#/components/responses/GeneralServerError' + default: + description: Internal server error + $ref: '#/components/responses/GeneralServerError' + post: + operationId: PostVariables + summary: Create a variable + tags: + - Variables + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: Variable to create + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Variable' + responses: + '201': + description: Variable created + content: + application/json: + schema: + $ref: '#/components/schemas/Variable' + default: + description: Internal server error + $ref: '#/components/responses/GeneralServerError' + '/variables/{variableID}': + get: + operationId: GetVariablesID + tags: + - Variables + summary: Retrieve a variable + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: variableID + required: true + schema: + type: string + description: The variable ID. + responses: + '200': + description: Variable found + content: + application/json: + schema: + $ref: '#/components/schemas/Variable' + '404': + description: Variable not found + $ref: '#/components/responses/GeneralServerError' + default: + description: Internal server error + $ref: '#/components/responses/GeneralServerError' + delete: + operationId: DeleteVariablesID + tags: + - Variables + summary: Delete a variable + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: variableID + required: true + schema: + type: string + description: The variable ID. + responses: + '204': + description: Variable deleted + default: + description: Internal server error + $ref: '#/components/responses/GeneralServerError' + patch: + operationId: PatchVariablesID + summary: Update a variable + tags: + - Variables + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: variableID + required: true + schema: + type: string + description: The variable ID. + requestBody: + description: Variable update to apply + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Variable' + responses: + '200': + description: Variable updated + content: + application/json: + schema: + $ref: '#/components/schemas/Variable' + default: + description: Internal server error + $ref: '#/components/responses/GeneralServerError' + put: + operationId: PutVariablesID + summary: Replace a variable + tags: + - Variables + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: variableID + required: true + schema: + type: string + description: The variable ID. + requestBody: + description: Variable to replace + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Variable' + responses: + '200': + description: Variable updated + content: + application/json: + schema: + $ref: '#/components/schemas/Variable' + default: + description: Internal server error + $ref: '#/components/responses/GeneralServerError' + /sources: + post: + operationId: PostSources + tags: + - Sources + summary: Create a source + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: Source to create + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Source' + responses: + '201': + description: Created Source + content: + application/json: + schema: + $ref: '#/components/schemas/Source' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + get: + operationId: GetSources + tags: + - Sources + summary: List all sources + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: org + description: The name of the organization. + schema: + type: string + responses: + '200': + description: A list of sources + content: + application/json: + schema: + $ref: '#/components/schemas/Sources' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/sources/{sourceID}': + delete: + operationId: DeleteSourcesID + tags: + - Sources + summary: Delete a source + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: sourceID + schema: + type: string + required: true + description: The source ID. + responses: + '204': + description: Delete has been accepted + '404': + description: View not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + operationId: PatchSourcesID + tags: + - Sources + summary: Update a Source + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: sourceID + schema: + type: string + required: true + description: The source ID. + requestBody: + description: Source update + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Source' + responses: + '200': + description: Created Source + content: + application/json: + schema: + $ref: '#/components/schemas/Source' + '404': + description: Source not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + get: + operationId: GetSourcesID + tags: + - Sources + summary: Retrieve a source + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: sourceID + schema: + type: string + required: true + description: The source ID. + responses: + '200': + description: A source + content: + application/json: + schema: + $ref: '#/components/schemas/Source' + '404': + description: Source not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/sources/{sourceID}/health': + get: + operationId: GetSourcesIDHealth + tags: + - Sources + summary: Get the health of a source + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: sourceID + schema: + type: string + required: true + description: The source ID. + responses: + '200': + description: The source is healthy + content: + application/json: + schema: + $ref: '#/components/schemas/HealthCheck' + '503': + description: The source is not healthy + content: + application/json: + schema: + $ref: '#/components/schemas/HealthCheck' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/sources/{sourceID}/buckets': + get: + operationId: GetSourcesIDBuckets + tags: + - Sources + - Buckets + summary: Get buckets in a source + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: sourceID + schema: + type: string + required: true + description: The source ID. + - in: query + name: org + description: The name of the organization. + schema: + type: string + responses: + '200': + description: A source + content: + application/json: + schema: + $ref: '#/components/schemas/Buckets' + '404': + description: Source not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /scrapers: + get: + operationId: GetScrapers + tags: + - Scraper Targets + summary: List all scraper targets + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: name + description: Specifies the name of the scraper target. + schema: + type: string + - in: query + name: id + description: 'List of scraper target IDs to return. If both `id` and `owner` are specified, only `id` is used.' + schema: + type: array + items: + type: string + - in: query + name: orgID + description: Specifies the organization ID of the scraper target. + schema: + type: string + - in: query + name: org + description: Specifies the organization name of the scraper target. + schema: + type: string + responses: + '200': + description: All scraper targets + content: + application/json: + schema: + $ref: '#/components/schemas/ScraperTargetResponses' + post: + operationId: PostScrapers + summary: Create a scraper target + tags: + - Scraper Targets + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: Scraper target to create + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ScraperTargetRequest' + responses: + '201': + description: Scraper target created + content: + application/json: + schema: + $ref: '#/components/schemas/ScraperTargetResponse' + default: + description: Internal server error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/scrapers/{scraperTargetID}': + get: + operationId: GetScrapersID + tags: + - Scraper Targets + summary: Retrieve a scraper target + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: scraperTargetID + required: true + schema: + type: string + description: The identifier of the scraper target. + responses: + '200': + description: The scraper target + content: + application/json: + schema: + $ref: '#/components/schemas/ScraperTargetResponse' + default: + description: Internal server error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + operationId: DeleteScrapersID + tags: + - Scraper Targets + summary: Delete a scraper target + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: scraperTargetID + required: true + schema: + type: string + description: The identifier of the scraper target. + responses: + '204': + description: Scraper target deleted + default: + description: Internal server error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + patch: + operationId: PatchScrapersID + summary: Update a scraper target + tags: + - Scraper Targets + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: scraperTargetID + required: true + schema: + type: string + description: The identifier of the scraper target. + requestBody: + description: Scraper target update to apply + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ScraperTargetRequest' + responses: + '200': + description: Scraper target updated + content: + application/json: + schema: + $ref: '#/components/schemas/ScraperTargetResponse' + default: + description: Internal server error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/scrapers/{scraperTargetID}/labels': + get: + operationId: GetScrapersIDLabels + tags: + - Scraper Targets + summary: List all labels for a scraper target + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + responses: + '200': + description: A list of labels for a scraper target. + content: + application/json: + schema: + $ref: '#/components/schemas/LabelsResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostScrapersIDLabels + tags: + - Scraper Targets + summary: Add a label to a scraper target + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + requestBody: + description: Label to add + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/LabelMapping' + responses: + '201': + description: The newly added label + content: + application/json: + schema: + $ref: '#/components/schemas/LabelResponse' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/scrapers/{scraperTargetID}/labels/{labelID}': + delete: + operationId: DeleteScrapersIDLabelsID + tags: + - Scraper Targets + summary: Delete a label from a scraper target + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + - in: path + name: labelID + schema: + type: string + required: true + description: The label ID. + responses: + '204': + description: Delete has been accepted + '404': + description: Scraper target not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/scrapers/{scraperTargetID}/members': + get: + operationId: GetScrapersIDMembers + tags: + - Scraper Targets + summary: List all users with member privileges for a scraper target + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + responses: + '200': + description: A list of scraper target members + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceMembers' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostScrapersIDMembers + tags: + - Scraper Targets + summary: Add a member to a scraper target + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + requestBody: + description: User to add as member + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddResourceMemberRequestBody' + responses: + '201': + description: Member added to scraper targets + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceMember' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/scrapers/{scraperTargetID}/members/{userID}': + delete: + operationId: DeleteScrapersIDMembersID + tags: + - Scraper Targets + summary: Remove a member from a scraper target + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of member to remove. + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + responses: + '204': + description: Member removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/scrapers/{scraperTargetID}/owners': + get: + operationId: GetScrapersIDOwners + tags: + - Scraper Targets + summary: List all owners of a scraper target + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + responses: + '200': + description: A list of scraper target owners + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceOwners' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + operationId: PostScrapersIDOwners + tags: + - Scraper Targets + summary: Add an owner to a scraper target + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + requestBody: + description: User to add as owner + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddResourceMemberRequestBody' + responses: + '201': + description: Scraper target owner added + content: + application/json: + schema: + $ref: '#/components/schemas/ResourceOwner' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '/scrapers/{scraperTargetID}/owners/{userID}': + delete: + operationId: DeleteScrapersIDOwnersID + tags: + - Scraper Targets + summary: Remove an owner from a scraper target + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: userID + schema: + type: string + required: true + description: The ID of owner to remove. + - in: path + name: scraperTargetID + schema: + type: string + required: true + description: The scraper target ID. + responses: + '204': + description: Owner removed + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /backup/kv: + get: + operationId: GetBackupKV + tags: + - Backup + summary: Download snapshot of metadata stored in the server's embedded KV store. Don't use with InfluxDB versions greater than InfluxDB 2.1.x. + description: | + Retrieves a snapshot of metadata stored in the server's embedded KV store. + InfluxDB versions greater than 2.1.x don't include metadata stored in embedded SQL; + avoid using this endpoint with versions greater than 2.1.x. + deprecated: true + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '200': + description: Success. The response contains a snapshot of KV metadata. + content: + application/octet-stream: + schema: + type: string + format: binary + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /backup/metadata: + get: + operationId: GetBackupMetadata + tags: + - Backup + summary: Download snapshot of all metadata in the server + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: header + name: Accept-Encoding + description: Indicates the content encoding (usually a compression algorithm) that the client can understand. + schema: + type: string + description: 'The content coding. Use `gzip` for compressed data or `identity` for unmodified, uncompressed data.' + default: identity + enum: + - gzip + - identity + responses: + '200': + description: Snapshot of metadata + headers: + Content-Encoding: + description: Lists any encodings (usually compression algorithms) that have been applied to the response payload. + schema: + type: string + description: | + The content coding: `gzip` for compressed data or `identity` for unmodified, uncompressed data. + default: identity + enum: + - gzip + - identity + content: + multipart/mixed: + schema: + $ref: '#/components/schemas/MetadataBackup' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + '/backup/shards/{shardID}': + get: + operationId: GetBackupShardId + tags: + - Backup + summary: Download snapshot of all TSM data in a shard + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: header + name: Accept-Encoding + description: Indicates the content encoding (usually a compression algorithm) that the client can understand. + schema: + type: string + description: 'The content coding. Use `gzip` for compressed data or `identity` for unmodified, uncompressed data.' + default: identity + enum: + - gzip + - identity + - in: path + name: shardID + schema: + type: integer + format: int64 + required: true + description: The shard ID. + - in: query + name: since + description: 'The earliest time [RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp) to include in the snapshot.' + schema: + type: string + format: date-time + examples: + RFC3339: + summary: RFC3339 date/time format + value: '2006-01-02T15:04:05Z07:00' + responses: + '200': + description: TSM snapshot. + headers: + Content-Encoding: + description: Lists any encodings (usually compression algorithms) that have been applied to the response payload. + schema: + type: string + description: | + The content coding: `gzip` for compressed data or `identity` for unmodified, uncompressed data. + default: identity + enum: + - gzip + - identity + content: + application/octet-stream: + schema: + type: string + format: binary + '404': + description: Shard not found. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /restore/kv: + post: + operationId: PostRestoreKV + tags: + - Restore + summary: Overwrite the embedded KV store on the server with a backed-up snapshot. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: header + name: Content-Encoding + description: | + The value tells InfluxDB what compression is applied to the line protocol in the request payload. + To make an API request with a GZIP payload, send `Content-Encoding: gzip` as a request header. + schema: + type: string + description: 'The content coding. Use `gzip` for compressed data or `identity` for unmodified, uncompressed data.' + default: identity + enum: + - gzip + - identity + - in: header + name: Content-Type + schema: + type: string + default: application/octet-stream + enum: + - application/octet-stream + requestBody: + description: Full KV snapshot. + required: true + content: + text/plain: + schema: + type: string + format: binary + responses: + '200': + description: KV store successfully overwritten. + content: + application/json: + schema: + type: object + properties: + token: + description: token is the root token for the instance after restore (this is overwritten during the restore) + type: string + '204': + description: KV store successfully overwritten. + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /restore/sql: + post: + operationId: PostRestoreSQL + tags: + - Restore + summary: Overwrite the embedded SQL store on the server with a backed-up snapshot. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: header + name: Content-Encoding + description: | + The value tells InfluxDB what compression is applied to the line protocol in the request payload. + To make an API request with a GZIP payload, send `Content-Encoding: gzip` as a request header. + schema: + type: string + description: Specifies that the line protocol in the body is encoded with gzip or not encoded with identity. + default: identity + enum: + - gzip + - identity + - in: header + name: Content-Type + schema: + type: string + default: application/octet-stream + enum: + - application/octet-stream + requestBody: + description: Full SQL snapshot. + required: true + content: + text/plain: + schema: + type: string + format: binary + responses: + '204': + description: SQL store successfully overwritten. + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + '/restore/bucket/{bucketID}': + post: + operationId: PostRestoreBucketID + tags: + - Restore + summary: Overwrite storage metadata for a bucket with shard info from a backup. + deprecated: true + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: bucketID + schema: + type: string + required: true + description: The bucket ID. + - in: header + name: Content-Type + schema: + type: string + default: application/octet-stream + enum: + - application/octet-stream + requestBody: + description: Database info serialized as protobuf. + required: true + content: + text/plain: + schema: + type: string + format: byte + responses: + '200': + description: ID mappings for shards in bucket. + content: + application/json: + schema: + type: string + format: byte + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /restore/bucketMetadata: + post: + operationId: PostRestoreBucketMetadata + tags: + - Restore + summary: Create a new bucket pre-seeded with shard info from a backup. + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: Metadata manifest for a bucket. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/BucketMetadataManifest' + responses: + '201': + description: ID mappings for shards in new bucket. + content: + application/json: + schema: + $ref: '#/components/schemas/RestoredBucketMappings' + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + '/restore/shards/{shardID}': + post: + operationId: PostRestoreShardId + tags: + - Restore + summary: Restore a TSM snapshot into a shard. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: header + name: Content-Encoding + description: | + The value tells InfluxDB what compression is applied to the line protocol in the request payload. + To make an API request with a GZIP payload, send `Content-Encoding: gzip` as a request header. + schema: + type: string + description: Specifies that the line protocol in the body is encoded with gzip or not encoded with identity. + default: identity + enum: + - gzip + - identity + - in: header + name: Content-Type + schema: + type: string + default: application/octet-stream + enum: + - application/octet-stream + - in: path + name: shardID + schema: + type: string + required: true + description: The shard ID. + requestBody: + description: TSM snapshot. + required: true + content: + text/plain: + schema: + type: string + format: binary + responses: + '204': + description: TSM snapshot successfully restored. + default: + description: Unexpected error + $ref: '#/components/responses/GeneralServerError' + /config: + get: + operationId: GetConfig + tags: + - Config + - System information endpoints + summary: Retrieve runtime configuration + description: | + Returns the active runtime configuration of the InfluxDB instance. + + In InfluxDB v2.2+, use this endpoint to view your active runtime configuration, + including flags and environment variables. + + #### Related guides + + - [View your runtime server configuration](https://docs.influxdata.com/influxdb/v2.3/reference/config-options/#view-your-runtime-server-configuration) + parameters: + - $ref: '#/components/parameters/TraceSpan' + responses: + '200': + description: | + Success. + The response body contains the active runtime configuration of the InfluxDB instance. + content: + application/json: + schema: + $ref: '#/components/schemas/Config' + '401': + $ref: '#/components/responses/GeneralServerError' + default: + $ref: '#/components/responses/GeneralServerError' + /remotes: + get: + operationId: GetRemoteConnections + tags: + - RemoteConnections + summary: List all remote connections + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: orgID + description: The organization ID. + required: true + schema: + type: string + - in: query + name: name + schema: + type: string + - in: query + name: remoteURL + schema: + type: string + format: uri + responses: + '200': + description: List of remote connections + content: + application/json: + schema: + $ref: '#/components/schemas/RemoteConnections' + '404': + $ref: '#/components/responses/GeneralServerError' + default: + $ref: '#/components/responses/GeneralServerError' + post: + operationId: PostRemoteConnection + tags: + - RemoteConnections + summary: Register a new remote connection + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/RemoteConnectionCreationRequest' + responses: + '201': + description: Remote connection saved + content: + application/json: + schema: + $ref: '#/components/schemas/RemoteConnection' + '400': + $ref: '#/components/responses/GeneralServerError' + default: + $ref: '#/components/responses/GeneralServerError' + '/remotes/{remoteID}': + get: + operationId: GetRemoteConnectionByID + tags: + - RemoteConnections + summary: Retrieve a remote connection + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: remoteID + schema: + type: string + required: true + responses: + '200': + description: Remote connection + content: + application/json: + schema: + $ref: '#/components/schemas/RemoteConnection' + '404': + $ref: '#/components/responses/GeneralServerError' + default: + $ref: '#/components/responses/GeneralServerError' + patch: + operationId: PatchRemoteConnectionByID + tags: + - RemoteConnections + summary: Update a remote connection + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: remoteID + schema: + type: string + required: true + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/RemoteConnectionUpdateRequest' + responses: + '200': + description: Updated information saved + content: + application/json: + schema: + $ref: '#/components/schemas/RemoteConnection' + '400': + $ref: '#/components/responses/GeneralServerError' + '404': + $ref: '#/components/responses/GeneralServerError' + default: + $ref: '#/components/responses/GeneralServerError' + delete: + operationId: DeleteRemoteConnectionByID + tags: + - RemoteConnections + summary: Delete a remote connection + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: remoteID + schema: + type: string + required: true + responses: + '204': + description: Remote connection info deleted. + '404': + $ref: '#/components/responses/GeneralServerError' + default: + $ref: '#/components/responses/GeneralServerError' + /replications: + get: + operationId: GetReplications + tags: + - Replications + summary: List all replications + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: orgID + description: The organization ID. + required: true + schema: + type: string + - in: query + name: name + schema: + type: string + - in: query + name: remoteID + schema: + type: string + - in: query + name: localBucketID + schema: + type: string + responses: + '200': + description: List of replications + content: + application/json: + schema: + $ref: '#/components/schemas/Replications' + '404': + $ref: '#/components/responses/GeneralServerError' + default: + $ref: '#/components/responses/GeneralServerError' + post: + operationId: PostReplication + tags: + - Replications + summary: Register a new replication + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: validate + description: 'If true, validate the replication, but don''t save it.' + schema: + type: boolean + default: false + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ReplicationCreationRequest' + responses: + '201': + description: Replication saved + content: + application/json: + schema: + $ref: '#/components/schemas/Replication' + '204': + description: 'Replication validated, but not saved' + '400': + $ref: '#/components/responses/GeneralServerError' + default: + $ref: '#/components/responses/GeneralServerError' + '/replications/{replicationID}': + get: + operationId: GetReplicationByID + tags: + - Replications + summary: Retrieve a replication + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: replicationID + schema: + type: string + required: true + responses: + '200': + description: Replication + content: + application/json: + schema: + $ref: '#/components/schemas/Replication' + '404': + $ref: '#/components/responses/GeneralServerError' + default: + $ref: '#/components/responses/GeneralServerError' + patch: + operationId: PatchReplicationByID + tags: + - Replications + summary: Update a replication + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: replicationID + schema: + type: string + required: true + - in: query + name: validate + description: 'If true, validate the updated information, but don''t save it.' + schema: + type: boolean + default: false + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ReplicationUpdateRequest' + responses: + '200': + description: Updated information saved + content: + application/json: + schema: + $ref: '#/components/schemas/Replication' + '204': + description: 'Updated replication validated, but not saved' + '400': + $ref: '#/components/responses/GeneralServerError' + '404': + $ref: '#/components/responses/GeneralServerError' + default: + $ref: '#/components/responses/GeneralServerError' + delete: + operationId: DeleteReplicationByID + tags: + - Replications + summary: Delete a replication + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: replicationID + schema: + type: string + required: true + responses: + '204': + description: Replication deleted. + '404': + $ref: '#/components/responses/GeneralServerError' + default: + $ref: '#/components/responses/GeneralServerError' + '/replications/{replicationID}/validate': + post: + operationId: PostValidateReplicationByID + tags: + - Replications + summary: Validate a replication + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: replicationID + schema: + type: string + required: true + responses: + '204': + description: Replication is valid + '400': + description: Replication failed validation + $ref: '#/components/responses/GeneralServerError' + default: + $ref: '#/components/responses/GeneralServerError' + /dashboards: + post: + operationId: PostDashboards + tags: + - Dashboards + summary: Create a dashboard + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: Dashboard to create + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateDashboardRequest' + responses: + '201': + description: Added dashboard + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/Dashboard' + - $ref: '#/components/schemas/DashboardWithViewProperties' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + get: + operationId: GetDashboards + tags: + - Dashboards + summary: List all dashboards + parameters: + - $ref: '#/components/parameters/TraceSpan' + - $ref: '#/components/parameters/Offset' + - $ref: '#/components/parameters/Limit' + - $ref: '#/components/parameters/Descending' + - in: query + name: owner + description: A user identifier. Returns only dashboards where this user has the `owner` role. + schema: + type: string + - in: query + name: sortBy + description: The column to sort by. + schema: + type: string + enum: + - ID + - CreatedAt + - UpdatedAt + - in: query + name: id + description: 'A list of dashboard identifiers. Returns only the listed dashboards. If both `id` and `owner` are specified, only `id` is used.' + schema: + type: array + items: + type: string + - in: query + name: orgID + description: The identifier of the organization. + schema: + type: string + - in: query + name: org + description: The name of the organization. + schema: + type: string + responses: + '200': + description: All dashboards + content: + application/json: + schema: + $ref: '#/components/schemas/Dashboards' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /tasks: + get: + operationId: GetTasks + tags: + - Data I/O endpoints + - Tasks + summary: List tasks + description: | + Retrieves a list of [tasks](https://docs.influxdata.com/influxdb/v2.3/process-data/). + + To limit which tasks are returned, pass query parameters in your request. + If no query parameters are passed, InfluxDB returns all tasks up to the default `limit`. + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: query + name: name + description: | + Task name. + Only returns tasks with this name. + Different tasks may have the same name. + schema: + type: string + - in: query + name: after + schema: + type: string + description: | + Task ID. + Only returns tasks created after this task. + - in: query + name: user + schema: + type: string + description: | + User ID. + Only returns tasks owned by this user. + - in: query + name: org + schema: + type: string + description: | + Organization name. + Only returns tasks owned by this organization. + - in: query + name: orgID + schema: + type: string + description: | + Organization ID. + Only returns tasks owned by this organization. + - in: query + name: status + schema: + type: string + enum: + - active + - inactive + description: | + Task status (`active` or `inactive`). + Only returns tasks with this status. + - in: query + name: limit + schema: + type: integer + minimum: 1 + maximum: 500 + default: 100 + description: | + Limits the number of tasks returned. + The minimum is `1`, the maximum is `500`, and the default is `100`. + - in: query + name: type + description: | + Task type (`basic` or `system`). + + The default (`system`) response contains all the metadata properties for tasks. + To reduce the payload size, pass `basic` to omit some task properties (`flux`, `createdAt`, `updatedAt`) from the response. + required: false + schema: + default: '' + type: string + enum: + - basic + - system + responses: + '200': + description: | + Success. + The response body contains the list of tasks. + content: + application/json: + schema: + $ref: '#/components/schemas/Tasks' + examples: + basicTypeTaskOutput: + summary: Basic output + description: Task fields returned with `?type=basic` + value: + links: + self: /api/v2/tasks?limit=100 + tasks: + - links: + labels: /api/v2/tasks/09956cbb6d378000/labels + logs: /api/v2/tasks/09956cbb6d378000/logs + members: /api/v2/tasks/09956cbb6d378000/members + owners: /api/v2/tasks/09956cbb6d378000/owners + runs: /api/v2/tasks/09956cbb6d378000/runs + self: /api/v2/tasks/09956cbb6d378000 + labels: [] + id: 09956cbb6d378000 + orgID: 48c88459ee424a04 + org: '' + ownerID: 0772396d1f411000 + name: task1 + status: active + flux: '' + every: 30m + latestCompleted: '2022-06-30T15:00:00Z' + lastRunStatus: success + systemTypeTaskOutput: + summary: System output + description: Task fields returned with `?type=system` + value: + links: + self: /api/v2/tasks?limit=100 + tasks: + - links: + labels: /api/v2/tasks/09956cbb6d378000/labels + logs: /api/v2/tasks/09956cbb6d378000/logs + members: /api/v2/tasks/09956cbb6d378000/members + owners: /api/v2/tasks/09956cbb6d378000/owners + runs: /api/v2/tasks/09956cbb6d378000/runs + self: /api/v2/tasks/09956cbb6d378000 + labels: [] + id: 09956cbb6d378000 + orgID: 48c88459ee424a04 + org: my-iot-center + ownerID: 0772396d1f411000 + name: task1 + description: IoT Center 90-day environment average. + status: active + flux: |- + option task = {name: "task1", every: 30m} + + from(bucket: "iot_center") + |> range(start: -90d) + |> filter(fn: (r) => r._measurement == "environment") + |> aggregateWindow(every: 1h, fn: mean) + every: 30m + latestCompleted: '2022-06-30T15:00:00Z' + lastRunStatus: success + createdAt: '2022-06-27T15:09:06Z' + updatedAt: '2022-06-28T18:10:15Z' + '401': + $ref: '#/components/responses/AuthorizationError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + x-codeSamples: + - lang: Shell + label: 'cURL: all tasks, basic output' + source: | + curl https://localhost:8086/api/v2/tasks/?limit=-1&type=basic \ + --header 'Content-Type: application/json' \ + --header 'Authorization: Token INFLUX_API_TOKEN' + post: + operationId: PostTasks + tags: + - Data I/O endpoints + - Tasks + summary: Create a task + description: | + Creates a [task](https://docs.influxdata.com/influxdb/v2.3/process-data/) and returns the created task. + + #### Related guides + + - [Get started with tasks](https://docs.influxdata.com/influxdb/v2.3/process-data/get-started/) + - [Create a task](https://docs.influxdata.com/influxdb/v2.3/process-data/manage-tasks/create-task/) + - [Common tasks](https://docs.influxdata.com/influxdb/v2.3/process-data/common-tasks/) + - [Task configuration options](https://docs.influxdata.com/influxdb/v2.3/process-data/task-options/) + parameters: + - $ref: '#/components/parameters/TraceSpan' + requestBody: + description: The task to create. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/TaskCreateRequest' + responses: + '201': + description: Success. The response body contains a `tasks` list with the new task. + content: + application/json: + schema: + $ref: '#/components/schemas/Task' + '400': + description: | + Bad request. + The response body contains detail about the error. + + #### InfluxDB OSS + + - Returns this error if an incorrect value is passed for `org` or `orgID`. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + orgProvidedNotFound: + summary: The org or orgID passed doesn't own the token passed in the header + value: + code: invalid + message: 'failed to decode request body: organization not found' + missingFluxError: + summary: Task in request body is missing Flux query + value: + code: invalid + message: 'failed to decode request: missing flux' + '401': + $ref: '#/components/responses/AuthorizationError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + description: Unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + x-codeSamples: + - lang: Shell + label: 'cURL: create a task' + source: | + curl http://localhost:8086/api/v2/tasks \ + --header "Content-type: application/json" \ + --header "Authorization: Token INFLUX_API_TOKEN" \ + --data-binary @- << EOF + { + "orgID": "INFLUX_ORG_ID", + "description": "IoT Center 30d environment average.", + "flux": "option task = {name: \"iot-center-task-1\", every: 30m}\ + from(bucket: \"iot_center\")\ + |> range(start: -30d)\ + |> filter(fn: (r) => r._measurement == \"environment\")\ + |> aggregateWindow(every: 1h, fn: mean)" + } + EOF + '/tasks/{taskID}': + get: + operationId: GetTasksID + tags: + - Data I/O endpoints + - Tasks + summary: Retrieve a task + description: | + Retrieves a [task](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#task). + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to retrieve. + responses: + '200': + description: Success. The response body contains the task. + content: + application/json: + schema: + $ref: '#/components/schemas/Task' + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + patch: + operationId: PatchTasksID + tags: + - Tasks + summary: Update a task + description: | + Updates a task and then cancels all scheduled runs of the task. + + Use this endpoint to set, modify, and clear task properties (for example: `cron`, `name`, `flux`, `status`). + Once InfluxDB applies the update, it cancels all previously scheduled runs of the task. + + To update a task, pass an object that contains the updated key-value pairs. + To activate or inactivate a task, set the `status` property. + _`"status": "inactive"`_ cancels scheduled runs and prevents manual runs of the task. + requestBody: + description: An object that contains updated task properties to apply. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/TaskUpdateRequest' + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to update. + responses: + '200': + description: Success. The response body contains the updated task. + content: + application/json: + schema: + $ref: '#/components/schemas/Task' + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' + delete: + operationId: DeleteTasksID + tags: + - Tasks + summary: Delete a task + description: | + Deletes a task and associated records. + + Use this endpoint to delete a task and all associated records (task runs, logs, and labels). + Once the task is deleted, InfluxDB cancels all scheduled runs of the task. + + If you want to disable a task instead of delete it, [update the task status to `inactive`](#operation/PatchTasksID). + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: taskID + schema: + type: string + required: true + description: The ID of the task to delete. + responses: + '204': + description: Success. The task and runs are deleted. Scheduled runs are canceled. + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/AuthorizationError' + '404': + $ref: '#/components/responses/ResourceNotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + default: + $ref: '#/components/responses/GeneralServerError' +components: + parameters: + TraceSpan: + in: header + name: Zap-Trace-Span + description: OpenTracing span context + example: + trace_id: '1' + span_id: '1' + baggage: + key: value + required: false + schema: + type: string + Offset: + in: query + name: offset + required: false + description: | + The offset for pagination. + The number of records to skip. + schema: + type: integer + minimum: 0 + Limit: + in: query + name: limit + required: false + description: | + Limits the number of records returned. Default is `20`. + schema: + type: integer + minimum: 1 + maximum: 100 + default: 20 + Descending: + in: query + name: descending + required: false + schema: + type: boolean + default: false + SortBy: + in: query + name: sortBy + required: false + schema: + type: string + After: + in: query + name: after + required: false + schema: + type: string + description: | + Resource ID to seek from. Results are not inclusive of this ID. Use `after` instead of `offset`. + schemas: + LanguageRequest: + description: Flux query to be analyzed. + type: object + required: + - query + properties: + query: + description: | + The Flux query script to be analyzed. + type: string + Query: + description: Query InfluxDB with the Flux language + type: object + required: + - query + properties: + extern: + $ref: '#/components/schemas/File' + query: + description: The query script to execute. + type: string + type: + description: The type of query. Must be "flux". + type: string + enum: + - flux + params: + type: object + additionalProperties: true + description: | + Key-value pairs passed as parameters during query execution. + + 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)" + ``` + + and pass _`params`_ with the key-value pairs--for example: + + ```json + params: { + "mybucket": "environment", + "rangeStart": "-30d" + } + ``` + + During query execution, InfluxDB passes _`params`_ to your script and substitutes the values. + + #### Limitations + + - If you use _`params`_, you can't use _`extern`_. + dialect: + $ref: '#/components/schemas/Dialect' + now: + description: | + Specifies the time that should be reported as `now` in the query. + Default is the server `now` time. + type: string + format: date-time + Package: + description: Represents a complete package source tree. + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + path: + description: Package import path + type: string + package: + description: Package name + type: string + files: + description: Package files + type: array + items: + $ref: '#/components/schemas/File' + File: + description: Represents a source from a single file + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + name: + description: The name of the file. + type: string + package: + $ref: '#/components/schemas/PackageClause' + imports: + description: A list of package imports + type: array + items: + $ref: '#/components/schemas/ImportDeclaration' + body: + description: List of Flux statements + type: array + items: + $ref: '#/components/schemas/Statement' + PackageClause: + description: Defines a package identifier + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + name: + $ref: '#/components/schemas/Identifier' + ImportDeclaration: + description: Declares a package import + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + as: + $ref: '#/components/schemas/Identifier' + path: + $ref: '#/components/schemas/StringLiteral' + DeletePredicateRequest: + description: The delete predicate request. + type: object + required: + - start + - stop + properties: + start: + description: | + A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp)). + The earliest time to delete from. + type: string + format: date-time + stop: + description: | + A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp)). + The latest time to delete from. + type: string + format: date-time + predicate: + description: | + An expression in [delete predicate syntax](https://docs.influxdata.com/influxdb/v2.3/reference/syntax/delete-predicate/). + example: tag1="value1" and (tag2="value2" and tag3!="value3") + type: string + Node: + oneOf: + - $ref: '#/components/schemas/Expression' + - $ref: '#/components/schemas/Block' + NodeType: + description: Type of AST node + type: string + Block: + description: A set of statements + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + body: + description: Block body + type: array + items: + $ref: '#/components/schemas/Statement' + Statement: + oneOf: + - $ref: '#/components/schemas/BadStatement' + - $ref: '#/components/schemas/VariableAssignment' + - $ref: '#/components/schemas/MemberAssignment' + - $ref: '#/components/schemas/ExpressionStatement' + - $ref: '#/components/schemas/ReturnStatement' + - $ref: '#/components/schemas/OptionStatement' + - $ref: '#/components/schemas/BuiltinStatement' + - $ref: '#/components/schemas/TestStatement' + BadStatement: + description: A placeholder for statements for which no correct statement nodes can be created + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + text: + description: Raw source text + type: string + VariableAssignment: + description: Represents the declaration of a variable + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + id: + $ref: '#/components/schemas/Identifier' + init: + $ref: '#/components/schemas/Expression' + MemberAssignment: + description: Object property assignment + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + member: + $ref: '#/components/schemas/MemberExpression' + init: + $ref: '#/components/schemas/Expression' + ExpressionStatement: + description: May consist of an expression that doesn't return a value and is executed solely for its side-effects + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + expression: + $ref: '#/components/schemas/Expression' + ReturnStatement: + description: Defines an expression to return + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + argument: + $ref: '#/components/schemas/Expression' + OptionStatement: + description: A single variable declaration + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + assignment: + oneOf: + - $ref: '#/components/schemas/VariableAssignment' + - $ref: '#/components/schemas/MemberAssignment' + BuiltinStatement: + description: Declares a builtin identifier and its type + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + id: + $ref: '#/components/schemas/Identifier' + TestStatement: + description: Declares a Flux test case + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + assignment: + $ref: '#/components/schemas/VariableAssignment' + Expression: + oneOf: + - $ref: '#/components/schemas/ArrayExpression' + - $ref: '#/components/schemas/DictExpression' + - $ref: '#/components/schemas/FunctionExpression' + - $ref: '#/components/schemas/BinaryExpression' + - $ref: '#/components/schemas/CallExpression' + - $ref: '#/components/schemas/ConditionalExpression' + - $ref: '#/components/schemas/LogicalExpression' + - $ref: '#/components/schemas/MemberExpression' + - $ref: '#/components/schemas/IndexExpression' + - $ref: '#/components/schemas/ObjectExpression' + - $ref: '#/components/schemas/ParenExpression' + - $ref: '#/components/schemas/PipeExpression' + - $ref: '#/components/schemas/UnaryExpression' + - $ref: '#/components/schemas/BooleanLiteral' + - $ref: '#/components/schemas/DateTimeLiteral' + - $ref: '#/components/schemas/DurationLiteral' + - $ref: '#/components/schemas/FloatLiteral' + - $ref: '#/components/schemas/IntegerLiteral' + - $ref: '#/components/schemas/PipeLiteral' + - $ref: '#/components/schemas/RegexpLiteral' + - $ref: '#/components/schemas/StringLiteral' + - $ref: '#/components/schemas/UnsignedIntegerLiteral' + - $ref: '#/components/schemas/Identifier' + ArrayExpression: + description: Used to create and directly specify the elements of an array object + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + elements: + description: Elements of the array + type: array + items: + $ref: '#/components/schemas/Expression' + DictExpression: + description: Used to create and directly specify the elements of a dictionary + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + elements: + description: Elements of the dictionary + type: array + items: + $ref: '#/components/schemas/DictItem' + DictItem: + description: A key-value pair in a dictionary. + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + key: + $ref: '#/components/schemas/Expression' + val: + $ref: '#/components/schemas/Expression' + FunctionExpression: + description: Function expression + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + params: + description: Function parameters + type: array + items: + $ref: '#/components/schemas/Property' + body: + $ref: '#/components/schemas/Node' + BinaryExpression: + description: uses binary operators to act on two operands in an expression + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + operator: + type: string + left: + $ref: '#/components/schemas/Expression' + right: + $ref: '#/components/schemas/Expression' + CallExpression: + description: Represents a function call + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + callee: + $ref: '#/components/schemas/Expression' + arguments: + description: Function arguments + type: array + items: + $ref: '#/components/schemas/Expression' + ConditionalExpression: + description: 'Selects one of two expressions, `Alternate` or `Consequent`, depending on a third boolean expression, `Test`' + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + test: + $ref: '#/components/schemas/Expression' + alternate: + $ref: '#/components/schemas/Expression' + consequent: + $ref: '#/components/schemas/Expression' + LogicalExpression: + description: Represents the rule conditions that collectively evaluate to either true or false + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + operator: + type: string + left: + $ref: '#/components/schemas/Expression' + right: + $ref: '#/components/schemas/Expression' + MemberExpression: + description: Represents accessing a property of an object + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + object: + $ref: '#/components/schemas/Expression' + property: + $ref: '#/components/schemas/PropertyKey' + IndexExpression: + description: Represents indexing into an array + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + array: + $ref: '#/components/schemas/Expression' + index: + $ref: '#/components/schemas/Expression' + ObjectExpression: + description: Allows the declaration of an anonymous object within a declaration + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + properties: + description: Object properties + type: array + items: + $ref: '#/components/schemas/Property' + ParenExpression: + description: Represents an expression wrapped in parenthesis + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + expression: + $ref: '#/components/schemas/Expression' + PipeExpression: + description: Call expression with pipe argument + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + argument: + $ref: '#/components/schemas/Expression' + call: + $ref: '#/components/schemas/CallExpression' + UnaryExpression: + description: Uses operators to act on a single operand in an expression + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + operator: + type: string + argument: + $ref: '#/components/schemas/Expression' + BooleanLiteral: + description: Represents boolean values + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + value: + type: boolean + DateTimeLiteral: + description: 'Represents an instant in time with nanosecond precision in [RFC3339Nano date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339nano-timestamp).' + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + value: + type: string + format: date-time + DurationLiteral: + description: Represents the elapsed time between two instants as an int64 nanosecond count with syntax of golang's time.Duration + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + values: + description: Duration values + type: array + items: + $ref: '#/components/schemas/Duration' + FloatLiteral: + description: Represents floating point numbers according to the double representations defined by the IEEE-754-1985 + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + value: + type: number + IntegerLiteral: + description: Represents integer numbers + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + value: + type: string + PipeLiteral: + description: 'Represents a specialized literal value, indicating the left hand value of a pipe expression' + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + RegexpLiteral: + description: Expressions begin and end with `/` and are regular expressions with syntax accepted by RE2 + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + value: + type: string + StringLiteral: + description: Expressions begin and end with double quote marks + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + value: + type: string + UnsignedIntegerLiteral: + description: Represents integer numbers + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + value: + type: string + Duration: + description: A pair consisting of length of time and the unit of time measured. It is the atomic unit from which all duration literals are composed. + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + magnitude: + type: integer + unit: + type: string + Property: + description: The value associated with a key + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + key: + $ref: '#/components/schemas/PropertyKey' + value: + $ref: '#/components/schemas/Expression' + PropertyKey: + oneOf: + - $ref: '#/components/schemas/Identifier' + - $ref: '#/components/schemas/StringLiteral' + Identifier: + description: A valid Flux identifier + type: object + properties: + type: + $ref: '#/components/schemas/NodeType' + name: + type: string + Dialect: + description: | + Options for tabular data output. + Default output is [annotated CSV](https://docs.influxdata.com/influxdb/v2.3/reference/syntax/annotated-csv/#csv-response-format) with headers. + + For more information about tabular data **dialect**, + see [W3 metadata vocabulary for tabular data](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#dialect-descriptions). + type: object + properties: + header: + description: 'If true, the results contain a header row.' + type: boolean + default: true + delimiter: + description: 'The separator used between cells. Default is a comma (`,`).' + type: string + default: ',' + maxLength: 1 + minLength: 1 + annotations: + description: | + Annotation rows to include in the results. + An _annotation_ is metadata associated with an object (column) in the data model. + + #### Related guides + + - See [Annotated CSV annotations](https://docs.influxdata.com/influxdb/v2.3/reference/syntax/annotated-csv/#annotations) for examples and more information. + + For more information about **annotations** in tabular data, + see [W3 metadata vocabulary for tabular data](https://www.w3.org/TR/2015/REC-tabular-data-model-20151217/#columns). + type: array + uniqueItems: true + items: + type: string + enum: + - group + - datatype + - default + commentPrefix: + description: The character prefixed to comment strings. Default is a number sign (`#`). + type: string + default: '#' + maxLength: 1 + minLength: 0 + dateTimeFormat: + description: | + The format for timestamps in results. + Default is [`RFC3339` date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp). + To include nanoseconds in timestamps, use `RFC3339Nano`. + + #### Example formatted date/time values + + | Format | Value | + |:------------|:----------------------------| + | `RFC3339` | `"2006-01-02T15:04:05Z07:00"` | + | `RFC3339Nano` | `"2006-01-02T15:04:05.999999999Z07:00"` | + type: string + default: RFC3339 + enum: + - RFC3339 + - RFC3339Nano + AuthorizationUpdateRequest: + properties: + status: + description: 'Status of the token. If `inactive`, requests using the token will be rejected.' + default: active + type: string + enum: + - active + - inactive + description: + type: string + description: A description of the token. + PostBucketRequest: + properties: + orgID: + description: | + Organization ID. + The ID of the organization. + type: string + name: + description: | + The name of the bucket. + type: string + description: + description: | + A description of the bucket. + type: string + rp: + description: | + Retention policy is an InfluxDB 1.x concept that represents the duration + of time that each data point in the retention policy persists. Use `rp` + for compatibility with InfluxDB 1.x. + The InfluxDB 2.x and Cloud equivalent is + [retention period](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#retention-period). + type: string + default: '0' + retentionRules: + $ref: '#/components/schemas/RetentionRules' + schemaType: + description: | + Schema Type. + Use `explicit` to enforce column names, tags, fields, and data types for + your data. + + #### InfluxDB Cloud + + - Default is `implicit`. + + #### InfluxDB OSS + + - Doesn't support `schemaType`. + $ref: '#/components/schemas/SchemaType' + default: implicit + required: + - orgID + - name + Bucket: + properties: + links: + type: object + readOnly: true + example: + labels: /api/v2/buckets/1/labels + members: /api/v2/buckets/1/members + org: /api/v2/orgs/2 + owners: /api/v2/buckets/1/owners + self: /api/v2/buckets/1 + write: /api/v2/write?org=2&bucket=1 + properties: + labels: + description: URL to retrieve labels for this bucket. + $ref: '#/components/schemas/Link' + members: + description: URL to retrieve members that can read this bucket. + $ref: '#/components/schemas/Link' + org: + description: URL to retrieve parent organization for this bucket. + $ref: '#/components/schemas/Link' + owners: + description: URL to retrieve owners that can read and write to this bucket. + $ref: '#/components/schemas/Link' + self: + description: URL for this bucket. + $ref: '#/components/schemas/Link' + write: + description: URL to write line protocol to this bucket. + $ref: '#/components/schemas/Link' + id: + readOnly: true + type: string + type: + readOnly: true + type: string + default: user + enum: + - user + - system + name: + type: string + description: + type: string + orgID: + type: string + rp: + type: string + schemaType: + $ref: '#/components/schemas/SchemaType' + default: implicit + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + retentionRules: + $ref: '#/components/schemas/RetentionRules' + labels: + $ref: '#/components/schemas/Labels' + required: + - name + - retentionRules + Buckets: + type: object + properties: + links: + readOnly: true + $ref: '#/components/schemas/Links' + buckets: + type: array + items: + $ref: '#/components/schemas/Bucket' + RetentionRules: + type: array + description: | + Retention rules to expire or retain data. + #### InfluxDB Cloud + + - `retentionRules` is required. + + #### InfluxDB OSS + + - `retentionRules` isn't required. + items: + $ref: '#/components/schemas/RetentionRule' + PatchBucketRequest: + type: object + description: | + An object that contains updated bucket properties to apply. + properties: + name: + type: string + description: | + The name of the bucket. + description: + description: | + A description of the bucket. + type: string + retentionRules: + $ref: '#/components/schemas/PatchRetentionRules' + PatchRetentionRules: + type: array + description: Updates to rules to expire or retain data. No rules means no updates. + items: + $ref: '#/components/schemas/PatchRetentionRule' + PatchRetentionRule: + type: object + properties: + type: + type: string + default: expire + enum: + - expire + everySeconds: + type: integer + format: int64 + description: | + The number of seconds to keep data. + Default duration is `2592000` (30 days). + `0` represents infinite retention. + example: 86400 + default: 2592000 + minimum: 0 + shardGroupDurationSeconds: + type: integer + format: int64 + description: | + The [shard group duration](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#shard). + The number of seconds that each shard group covers. + + #### InfluxDB Cloud + + - Doesn't use `shardGroupDurationsSeconds`. + + #### InfluxDB OSS + + - Default value depends on the [bucket retention period](https://docs.influxdata.com/influxdb/v2.3/reference/internals/shards/#shard-group-duration). + + #### Related guides + + - InfluxDB [shards and shard groups](https://docs.influxdata.com/influxdb/v2.3/reference/internals/shards/) + required: + - everySeconds + RetentionRule: + type: object + properties: + type: + type: string + default: expire + enum: + - expire + everySeconds: + type: integer + format: int64 + description: | + The duration in seconds for how long data will be kept in the database. + The default duration is 2592000 (30 days). + 0 represents infinite retention. + example: 86400 + default: 2592000 + minimum: 0 + shardGroupDurationSeconds: + type: integer + format: int64 + description: | + The shard group duration. + The duration or interval (in seconds) that each shard group covers. + + #### InfluxDB Cloud + + - Does not use `shardGroupDurationsSeconds`. + + #### InfluxDB OSS + + - Default value depends on the + [bucket retention period](https://docs.influxdata.com/influxdb/v2.3/v2.3/reference/internals/shards/#shard-group-duration). + required: + - everySeconds + Link: + type: string + format: uri + readOnly: true + description: URI of resource. + Links: + type: object + description: | + URI pointers for additional paged results. + properties: + next: + $ref: '#/components/schemas/Link' + self: + $ref: '#/components/schemas/Link' + prev: + $ref: '#/components/schemas/Link' + required: + - self + Logs: + type: object + properties: + events: + readOnly: true + type: array + items: + $ref: '#/components/schemas/LogEvent' + LogEvent: + type: object + properties: + time: + readOnly: true + description: 'The time ([RFC3339Nano date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339nano-timestamp)) that the event occurred.' + type: string + format: date-time + example: '2006-01-02T15:04:05.999999999Z07:00' + message: + readOnly: true + description: A description of the event that occurred. + type: string + example: Halt and catch fire + runID: + readOnly: true + description: The ID of the task run that generated the event. + type: string + Organization: + properties: + links: + type: object + readOnly: true + example: + self: /api/v2/orgs/1 + members: /api/v2/orgs/1/members + owners: /api/v2/orgs/1/owners + labels: /api/v2/orgs/1/labels + secrets: /api/v2/orgs/1/secrets + buckets: /api/v2/buckets?org=myorg + tasks: /api/v2/tasks?org=myorg + dashboards: /api/v2/dashboards?org=myorg + properties: + self: + $ref: '#/components/schemas/Link' + members: + $ref: '#/components/schemas/Link' + owners: + $ref: '#/components/schemas/Link' + labels: + $ref: '#/components/schemas/Link' + secrets: + $ref: '#/components/schemas/Link' + buckets: + $ref: '#/components/schemas/Link' + tasks: + $ref: '#/components/schemas/Link' + dashboards: + $ref: '#/components/schemas/Link' + id: + readOnly: true + type: string + name: + type: string + description: + type: string + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + status: + description: If inactive the organization is inactive. + default: active + type: string + enum: + - active + - inactive + required: + - name + Organizations: + type: object + properties: + links: + $ref: '#/components/schemas/Links' + orgs: + type: array + items: + $ref: '#/components/schemas/Organization' + PostOrganizationRequest: + type: object + properties: + name: + type: string + description: + type: string + required: + - name + PatchOrganizationRequest: + type: object + properties: + name: + type: string + description: New name to set on the organization + description: + type: string + description: New description to set on the organization + TemplateApply: + type: object + properties: + dryRun: + type: boolean + description: | + Only applies a dry run of the templates passed in the request. + + - Validates the template and generates a resource diff and summary. + - Doesn't install templates or make changes to the InfluxDB instance. + orgID: + type: string + description: | + Organization ID. + InfluxDB applies templates to this organization. + The organization owns all resources created by the template. + + To find your organization, see how to + [view organizations](https://docs.influxdata.com/influxdb/v2.3/organizations/view-orgs/). + stackID: + type: string + description: | + ID of the stack to update. + + To apply templates to an existing stack in the organization, use the `stackID` parameter. + If you apply templates without providing a stack ID, + InfluxDB initializes a new stack with all new resources. + + To find a stack ID, use the InfluxDB [`/api/v2/stacks` API endpoint](#operation/ListStacks) to list stacks. + + #### Related guides + + - [Stacks](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/stacks/) + - [View stacks](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/stacks/view/) + template: + type: object + description: | + A template object to apply. + A template object has a `contents` property + with an array of InfluxDB resource configurations. + + Pass `template` to apply only one template object. + If you use `template`, you can't use the `templates` parameter. + If you want to apply multiple template objects, use `templates` instead. + properties: + contentType: + type: string + sources: + type: array + items: + type: string + contents: + $ref: '#/components/schemas/Template' + templates: + type: array + description: | + A list of template objects to apply. + A template object has a `contents` property + with an array of InfluxDB resource configurations. + + Use the `templates` parameter to apply multiple template objects. + If you use `templates`, you can't use the `template` parameter. + items: + type: object + properties: + contentType: + type: string + sources: + type: array + items: + type: string + contents: + $ref: '#/components/schemas/Template' + envRefs: + type: object + description: | + An object with key-value pairs that map to **environment references** in templates. + + Environment references in templates are `envRef` objects with an `envRef.key` + property. + To substitute a custom environment reference value when applying templates, + pass `envRefs` with the `envRef.key` and the value. + + When you apply a template, InfluxDB replaces `envRef` objects in the template + with the values that you provide in the `envRefs` parameter. + For more examples, see how to [define environment references](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/use/#define-environment-references). + + The following template fields may use environment references: + + - `metadata.name` + - `spec.endpointName` + - `spec.associations.name` + + For more information about including environment references in template fields, see how to + [include user-definable resource names](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/create/#include-user-definable-resource-names). + additionalProperties: + oneOf: + - type: string + - type: integer + - type: number + - type: boolean + secrets: + type: object + description: | + An object with key-value pairs that map to **secrets** in queries. + + Queries may reference secrets stored in InfluxDB--for example, + 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" + + 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", + ) + ``` + + 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" + } + ... + } + ``` + + 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. + + #### Related guides + + - [How to pass secrets when installing a template](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/use/#pass-secrets-when-installing-a-template) + additionalProperties: + type: string + remotes: + type: array + description: | + A list of URLs for template files. + + To apply a template manifest file located at a URL, pass `remotes` + with an array that contains the URL. + items: + type: object + properties: + url: + type: string + contentType: + type: string + required: + - url + actions: + type: array + description: | + A list of `action` objects. + Actions let you customize how InfluxDB applies templates in the request. + + You can use the following actions to prevent creating or updating resources: + + - A `skipKind` action skips template resources of a specified `kind`. + - A `skipResource` action skips template resources with a specified `metadata.name` + and `kind`. + items: + oneOf: + - type: object + properties: + action: + type: string + enum: + - skipKind + properties: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + required: + - kind + - type: object + properties: + action: + type: string + enum: + - skipResource + properties: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + resourceTemplateName: + type: string + required: + - kind + - resourceTemplateName + TemplateKind: + type: string + enum: + - Bucket + - Check + - CheckDeadman + - CheckThreshold + - Dashboard + - Label + - NotificationEndpoint + - NotificationEndpointHTTP + - NotificationEndpointPagerDuty + - NotificationEndpointSlack + - NotificationRule + - Task + - Telegraf + - Variable + TemplateExportByID: + type: object + properties: + stackID: + type: string + orgIDs: + type: array + items: + type: object + properties: + orgID: + type: string + resourceFilters: + type: object + properties: + byLabel: + type: array + items: + type: string + byResourceKind: + type: array + items: + $ref: '#/components/schemas/TemplateKind' + resources: + type: array + items: + type: object + properties: + id: + type: string + kind: + $ref: '#/components/schemas/TemplateKind' + name: + type: string + description: 'if defined with id, name is used for resource exported by id. if defined independently, resources strictly matching name are exported' + required: + - id + - kind + TemplateExportByName: + type: object + properties: + stackID: + type: string + orgIDs: + type: array + items: + type: object + properties: + orgID: + type: string + resourceFilters: + type: object + properties: + byLabel: + type: array + items: + type: string + byResourceKind: + type: array + items: + $ref: '#/components/schemas/TemplateKind' + resources: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + name: + type: string + required: + - name + - kind + Template: + type: array + items: + type: object + description: | + A template entry. + Defines an InfluxDB resource in a template. + properties: + apiVersion: + type: string + example: influxdata.com/v2alpha1 + kind: + $ref: '#/components/schemas/TemplateKind' + metadata: + type: object + description: | + Metadata properties used for the resource when the template is applied. + properties: + name: + type: string + spec: + type: object + description: | + Configuration properties used for the resource when the template is applied. + Key-value pairs map to the specification for the resource. + + The following code samples show `spec` configurations for template resources: + + - A bucket: + + ```json + { "spec": { + "name": "iot_center", + "retentionRules": [{ + "everySeconds": 2.592e+06, + "type": "expire" + }] + } + } + ``` + + - A variable: + + ```json + { "spec": { + "language": "flux", + "name": "Node_Service", + "query": "import \"influxdata/influxdb/v1\"\r\nv1.tagValues(bucket: \"iot_center\", + tag: \"service\")", + "type": "query" + } + } + ``` + TemplateEnvReferences: + type: array + items: + type: object + properties: + resourceField: + type: string + description: Field the environment reference corresponds too + envRefKey: + type: string + description: Key identified as environment reference and is the key identified in the template + value: + description: Value provided to fulfill reference + nullable: true + oneOf: + - type: string + - type: integer + - type: number + - type: boolean + defaultValue: + description: Default value that will be provided for the reference when no value is provided + nullable: true + oneOf: + - type: string + - type: integer + - type: number + - type: boolean + required: + - resourceField + - envRefKey + TemplateSummary: + type: object + properties: + sources: + type: array + items: + type: string + stackID: + type: string + summary: + type: object + properties: + buckets: + type: array + items: + type: object + properties: + id: + type: string + orgID: + type: string + kind: + $ref: '#/components/schemas/TemplateKind' + templateMetaName: + type: string + name: + type: string + description: + type: string + retentionPeriod: + type: integer + labelAssociations: + type: array + items: + $ref: '#/components/schemas/TemplateSummaryLabel' + envReferences: + $ref: '#/components/schemas/TemplateEnvReferences' + checks: + type: array + items: + allOf: + - $ref: '#/components/schemas/CheckDiscriminator' + - type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + templateMetaName: + type: string + labelAssociations: + type: array + items: + $ref: '#/components/schemas/TemplateSummaryLabel' + envReferences: + $ref: '#/components/schemas/TemplateEnvReferences' + dashboards: + type: array + items: + type: object + properties: + id: + type: string + orgID: + type: string + kind: + $ref: '#/components/schemas/TemplateKind' + templateMetaName: + type: string + name: + type: string + description: + type: string + labelAssociations: + type: array + items: + $ref: '#/components/schemas/TemplateSummaryLabel' + charts: + type: array + items: + $ref: '#/components/schemas/TemplateChart' + envReferences: + $ref: '#/components/schemas/TemplateEnvReferences' + labels: + type: array + items: + $ref: '#/components/schemas/TemplateSummaryLabel' + labelMappings: + type: array + items: + type: object + properties: + status: + type: string + resourceTemplateMetaName: + type: string + resourceName: + type: string + resourceID: + type: string + resourceType: + type: string + labelTemplateMetaName: + type: string + labelName: + type: string + labelID: + type: string + missingEnvRefs: + type: array + items: + type: string + missingSecrets: + type: array + items: + type: string + notificationEndpoints: + type: array + items: + allOf: + - $ref: '#/components/schemas/NotificationEndpointDiscriminator' + - type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + templateMetaName: + type: string + labelAssociations: + type: array + items: + $ref: '#/components/schemas/TemplateSummaryLabel' + envReferences: + $ref: '#/components/schemas/TemplateEnvReferences' + notificationRules: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + templateMetaName: + type: string + name: + type: string + description: + type: string + endpointTemplateMetaName: + type: string + endpointID: + type: string + endpointType: + type: string + every: + type: string + offset: + type: string + messageTemplate: + type: string + status: + type: string + statusRules: + type: array + items: + type: object + properties: + currentLevel: + type: string + previousLevel: + type: string + tagRules: + type: array + items: + type: object + properties: + key: + type: string + value: + type: string + operator: + type: string + labelAssociations: + type: array + items: + $ref: '#/components/schemas/TemplateSummaryLabel' + envReferences: + $ref: '#/components/schemas/TemplateEnvReferences' + tasks: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + templateMetaName: + type: string + id: + type: string + name: + type: string + cron: + type: string + description: + type: string + every: + type: string + offset: + type: string + query: + type: string + status: + type: string + envReferences: + $ref: '#/components/schemas/TemplateEnvReferences' + telegrafConfigs: + type: array + items: + allOf: + - $ref: '#/components/schemas/TelegrafRequest' + - type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + templateMetaName: + type: string + labelAssociations: + type: array + items: + $ref: '#/components/schemas/TemplateSummaryLabel' + envReferences: + $ref: '#/components/schemas/TemplateEnvReferences' + variables: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + templateMetaName: + type: string + id: + type: string + orgID: + type: string + name: + type: string + description: + type: string + arguments: + $ref: '#/components/schemas/VariableProperties' + labelAssociations: + type: array + items: + $ref: '#/components/schemas/TemplateSummaryLabel' + envReferences: + $ref: '#/components/schemas/TemplateEnvReferences' + diff: + type: object + properties: + buckets: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + type: object + properties: + name: + type: string + description: + type: string + retentionRules: + $ref: '#/components/schemas/RetentionRules' + old: + type: object + properties: + name: + type: string + description: + type: string + retentionRules: + $ref: '#/components/schemas/RetentionRules' + checks: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + $ref: '#/components/schemas/CheckDiscriminator' + old: + $ref: '#/components/schemas/CheckDiscriminator' + dashboards: + type: array + items: + type: object + properties: + stateStatus: + type: string + id: + type: string + kind: + $ref: '#/components/schemas/TemplateKind' + templateMetaName: + type: string + new: + type: object + properties: + name: + type: string + description: + type: string + charts: + type: array + items: + $ref: '#/components/schemas/TemplateChart' + old: + type: object + properties: + name: + type: string + description: + type: string + charts: + type: array + items: + $ref: '#/components/schemas/TemplateChart' + labels: + type: array + items: + type: object + properties: + stateStatus: + type: string + kind: + $ref: '#/components/schemas/TemplateKind' + id: + type: string + templateMetaName: + type: string + new: + type: object + properties: + name: + type: string + color: + type: string + description: + type: string + old: + type: object + properties: + name: + type: string + color: + type: string + description: + type: string + labelMappings: + type: array + items: + type: object + properties: + status: + type: string + resourceType: + type: string + resourceID: + type: string + resourceTemplateMetaName: + type: string + resourceName: + type: string + labelID: + type: string + labelTemplateMetaName: + type: string + labelName: + type: string + notificationEndpoints: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + $ref: '#/components/schemas/NotificationEndpointDiscriminator' + old: + $ref: '#/components/schemas/NotificationEndpointDiscriminator' + notificationRules: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + type: object + properties: + name: + type: string + description: + type: string + endpointName: + type: string + endpointID: + type: string + endpointType: + type: string + every: + type: string + offset: + type: string + messageTemplate: + type: string + status: + type: string + statusRules: + type: array + items: + type: object + properties: + currentLevel: + type: string + previousLevel: + type: string + tagRules: + type: array + items: + type: object + properties: + key: + type: string + value: + type: string + operator: + type: string + old: + type: object + properties: + name: + type: string + description: + type: string + endpointName: + type: string + endpointID: + type: string + endpointType: + type: string + every: + type: string + offset: + type: string + messageTemplate: + type: string + status: + type: string + statusRules: + type: array + items: + type: object + properties: + currentLevel: + type: string + previousLevel: + type: string + tagRules: + type: array + items: + type: object + properties: + key: + type: string + value: + type: string + operator: + type: string + tasks: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + type: object + properties: + name: + type: string + cron: + type: string + description: + type: string + every: + type: string + offset: + type: string + query: + type: string + status: + type: string + old: + type: object + properties: + name: + type: string + cron: + type: string + description: + type: string + every: + type: string + offset: + type: string + query: + type: string + status: + type: string + telegrafConfigs: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + $ref: '#/components/schemas/TelegrafRequest' + old: + $ref: '#/components/schemas/TelegrafRequest' + variables: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + stateStatus: + type: string + id: + type: string + templateMetaName: + type: string + new: + type: object + properties: + name: + type: string + description: + type: string + args: + $ref: '#/components/schemas/VariableProperties' + old: + type: object + properties: + name: + type: string + description: + type: string + args: + $ref: '#/components/schemas/VariableProperties' + errors: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + reason: + type: string + fields: + type: array + items: + type: string + indexes: + type: array + items: + type: integer + TemplateSummaryLabel: + type: object + properties: + id: + type: string + orgID: + type: string + kind: + $ref: '#/components/schemas/TemplateKind' + templateMetaName: + type: string + name: + type: string + properties: + type: object + properties: + color: + type: string + description: + type: string + envReferences: + $ref: '#/components/schemas/TemplateEnvReferences' + TemplateChart: + type: object + properties: + xPos: + type: integer + yPos: + type: integer + height: + type: integer + width: + type: integer + properties: + $ref: '#/components/schemas/ViewProperties' + Stack: + type: object + properties: + id: + type: string + orgID: + type: string + createdAt: + type: string + format: date-time + readOnly: true + events: + type: array + items: + type: object + properties: + eventType: + type: string + name: + type: string + description: + type: string + sources: + type: array + items: + type: string + resources: + type: array + items: + type: object + properties: + apiVersion: + type: string + resourceID: + type: string + kind: + $ref: '#/components/schemas/TemplateKind' + templateMetaName: + type: string + associations: + type: array + items: + type: object + properties: + kind: + $ref: '#/components/schemas/TemplateKind' + metaName: + type: string + links: + type: object + properties: + self: + type: string + urls: + type: array + items: + type: string + updatedAt: + type: string + format: date-time + readOnly: true + Runs: + type: object + properties: + links: + $ref: '#/components/schemas/Links' + runs: + type: array + items: + $ref: '#/components/schemas/Run' + Run: + properties: + id: + readOnly: true + type: string + taskID: + readOnly: true + type: string + status: + readOnly: true + type: string + enum: + - scheduled + - started + - failed + - success + - canceled + scheduledFor: + description: 'The time [RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp) used for the run''s `now` option.' + type: string + format: date-time + log: + description: An array of logs associated with the run. + type: array + readOnly: true + items: + $ref: '#/components/schemas/LogEvent' + flux: + description: Flux used for the task + type: string + readOnly: true + startedAt: + readOnly: true + description: 'The time ([RFC3339Nano date/time format](https://go.dev/src/time/format.go)) the run started executing.' + type: string + format: date-time + example: '2006-01-02T15:04:05.999999999Z07:00' + finishedAt: + readOnly: true + description: 'The time ([RFC3339Nano date/time format](https://go.dev/src/time/format.go)) the run finished executing.' + type: string + format: date-time + example: '2006-01-02T15:04:05.999999999Z07:00' + requestedAt: + readOnly: true + description: 'The time ([RFC3339Nano date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339nano-timestamp)) the run was manually requested.' + type: string + format: date-time + example: '2006-01-02T15:04:05.999999999Z07:00' + links: + type: object + readOnly: true + example: + self: /api/v2/tasks/1/runs/1 + task: /api/v2/tasks/1 + retry: /api/v2/tasks/1/runs/1/retry + properties: + self: + type: string + format: uri + task: + type: string + format: uri + retry: + type: string + format: uri + RunManually: + properties: + scheduledFor: + nullable: true + description: | + The time [RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp) + used for the run's `now` option. + Default is the server _now_ time. + type: string + format: date-time + TaskStatusType: + type: string + enum: + - active + - inactive + description: | + `inactive` cancels scheduled runs and prevents manual runs of the task. + UserResponse: + properties: + id: + readOnly: true + type: string + description: | + The ID of the user. + name: + type: string + description: | + The name of the user. + status: + description: | + The status of a user. An inactive user won't have access to resources. + default: active + type: string + enum: + - active + - inactive + links: + type: object + readOnly: true + example: + self: /api/v2/users/1 + properties: + self: + type: string + format: uri + required: + - name + Flags: + type: object + additionalProperties: true + ResourceMember: + allOf: + - $ref: '#/components/schemas/UserResponse' + - type: object + properties: + role: + type: string + default: member + enum: + - member + ResourceMembers: + type: object + properties: + links: + type: object + properties: + self: + type: string + format: uri + users: + type: array + items: + $ref: '#/components/schemas/ResourceMember' + ResourceOwner: + allOf: + - $ref: '#/components/schemas/UserResponse' + - type: object + properties: + role: + type: string + default: owner + enum: + - owner + ResourceOwners: + type: object + properties: + links: + type: object + properties: + self: + type: string + format: uri + users: + type: array + items: + $ref: '#/components/schemas/ResourceOwner' + FluxSuggestions: + type: object + properties: + funcs: + type: array + items: + $ref: '#/components/schemas/FluxSuggestion' + FluxSuggestion: + type: object + properties: + name: + type: string + params: + type: object + additionalProperties: + type: string + Routes: + properties: + authorizations: + type: string + format: uri + buckets: + type: string + format: uri + dashboards: + type: string + format: uri + external: + type: object + properties: + statusFeed: + type: string + format: uri + variables: + type: string + format: uri + me: + type: string + format: uri + flags: + type: string + format: uri + orgs: + type: string + format: uri + query: + type: object + properties: + self: + type: string + format: uri + ast: + type: string + format: uri + analyze: + type: string + format: uri + suggestions: + type: string + format: uri + setup: + type: string + format: uri + signin: + type: string + format: uri + signout: + type: string + format: uri + sources: + type: string + format: uri + system: + type: object + properties: + metrics: + type: string + format: uri + debug: + type: string + format: uri + health: + type: string + format: uri + tasks: + type: string + format: uri + telegrafs: + type: string + format: uri + users: + type: string + format: uri + write: + type: string + format: uri + Error: + properties: + code: + description: code is the machine-readable error code. + readOnly: true + type: string + enum: + - internal error + - not found + - conflict + - invalid + - unprocessable entity + - empty value + - unavailable + - forbidden + - too many requests + - unauthorized + - method not allowed + - request too large + - unsupported media type + message: + readOnly: true + description: Human-readable message. + type: string + op: + readOnly: true + description: Describes the logical code operation when the error occurred. Useful for debugging. + type: string + err: + readOnly: true + description: Stack of errors that occurred during processing of the request. Useful for debugging. + type: string + required: + - code + LineProtocolError: + properties: + code: + description: Code is the machine-readable error code. + readOnly: true + type: string + enum: + - internal error + - not found + - conflict + - invalid + - empty value + - unavailable + message: + readOnly: true + description: Human-readable message. + type: string + op: + readOnly: true + description: Describes the logical code operation when the error occurred. Useful for debugging. + type: string + err: + readOnly: true + description: Stack of errors that occurred during processing of the request. Useful for debugging. + type: string + line: + readOnly: true + description: First line in the request body that contains malformed data. + type: integer + format: int32 + required: + - code + LineProtocolLengthError: + properties: + code: + description: Code is the machine-readable error code. + readOnly: true + type: string + enum: + - invalid + message: + readOnly: true + description: Human-readable message. + type: string + required: + - code + - message + Field: + type: object + properties: + value: + description: value is the value of the field. Meaning of the value is implied by the `type` key + type: string + type: + description: '`type` describes the field type. `func` is a function. `field` is a field reference.' + type: string + enum: + - func + - field + - integer + - number + - regex + - wildcard + alias: + description: Alias overrides the field name in the returned response. Applies only if type is `func` + type: string + args: + description: Args are the arguments to the function + type: array + items: + $ref: '#/components/schemas/Field' + BuilderConfig: + type: object + properties: + buckets: + type: array + items: + type: string + tags: + type: array + items: + $ref: '#/components/schemas/BuilderTagsType' + functions: + type: array + items: + $ref: '#/components/schemas/BuilderFunctionsType' + aggregateWindow: + type: object + properties: + period: + type: string + fillValues: + type: boolean + BuilderTagsType: + type: object + properties: + key: + type: string + values: + type: array + items: + type: string + aggregateFunctionType: + $ref: '#/components/schemas/BuilderAggregateFunctionType' + BuilderAggregateFunctionType: + type: string + enum: + - filter + - group + BuilderFunctionsType: + type: object + properties: + name: + type: string + DashboardQuery: + type: object + properties: + text: + type: string + description: The text of the Flux query. + editMode: + $ref: '#/components/schemas/QueryEditMode' + name: + type: string + builderConfig: + $ref: '#/components/schemas/BuilderConfig' + QueryEditMode: + type: string + enum: + - builder + - advanced + Axis: + type: object + description: Axis used in a visualization. + properties: + bounds: + type: array + minItems: 0 + maxItems: 2 + description: 'The extents of the axis in the form [lower, upper]. Clients determine whether bounds are inclusive or exclusive of their limits.' + items: + type: string + label: + description: Description of the axis. + type: string + prefix: + description: Label prefix for formatting axis values. + type: string + suffix: + description: Label suffix for formatting axis values. + type: string + base: + description: Radix for formatting axis values. + type: string + enum: + - '' + - '2' + - '10' + scale: + $ref: '#/components/schemas/AxisScale' + AxisScale: + description: 'Scale is the axis formatting scale. Supported: "log", "linear"' + type: string + enum: + - log + - linear + DashboardColor: + type: object + description: Defines an encoding of data value into color space. + required: + - id + - type + - hex + - name + - value + properties: + id: + description: The unique ID of the view color. + type: string + type: + description: Type is how the color is used. + type: string + enum: + - min + - max + - threshold + - scale + - text + - background + hex: + description: The hex number of the color + type: string + maxLength: 7 + minLength: 7 + name: + description: The user-facing name of the hex color. + type: string + value: + description: The data value mapped to this color. + type: number + format: float + RenamableField: + description: Describes a field that can be renamed and made visible or invisible. + type: object + properties: + internalName: + description: The calculated name of a field. + readOnly: true + type: string + displayName: + description: The name that a field is renamed to by the user. + type: string + visible: + description: Indicates whether this field should be visible on the table. + type: boolean + XYViewProperties: + type: object + required: + - type + - geom + - queries + - shape + - axes + - colors + - note + - showNoteWhenEmpty + - position + properties: + adaptiveZoomHide: + type: boolean + timeFormat: + type: string + type: + type: string + enum: + - xy + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + colorMapping: + description: An object that contains information about the color mapping + $ref: '#/components/schemas/ColorMapping' + shape: + type: string + enum: + - chronograf-v2 + note: + type: string + showNoteWhenEmpty: + description: 'If true, will display note when empty' + type: boolean + axes: + $ref: '#/components/schemas/Axes' + staticLegend: + $ref: '#/components/schemas/StaticLegend' + xColumn: + type: string + generateXAxisTicks: + type: array + items: + type: string + xTotalTicks: + type: integer + xTickStart: + type: number + format: float + xTickStep: + type: number + format: float + yColumn: + type: string + generateYAxisTicks: + type: array + items: + type: string + yTotalTicks: + type: integer + yTickStart: + type: number + format: float + yTickStep: + type: number + format: float + shadeBelow: + type: boolean + hoverDimension: + type: string + enum: + - auto + - x + - 'y' + - xy + position: + type: string + enum: + - overlaid + - stacked + geom: + $ref: '#/components/schemas/XYGeom' + legendColorizeRows: + type: boolean + legendHide: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + XYGeom: + type: string + enum: + - line + - step + - stacked + - bar + - monotoneX + - stepBefore + - stepAfter + BandViewProperties: + type: object + required: + - type + - geom + - queries + - shape + - axes + - colors + - note + - showNoteWhenEmpty + properties: + adaptiveZoomHide: + type: boolean + timeFormat: + type: string + type: + type: string + enum: + - band + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + shape: + type: string + enum: + - chronograf-v2 + note: + type: string + showNoteWhenEmpty: + description: 'If true, will display note when empty' + type: boolean + axes: + $ref: '#/components/schemas/Axes' + staticLegend: + $ref: '#/components/schemas/StaticLegend' + xColumn: + type: string + generateXAxisTicks: + type: array + items: + type: string + xTotalTicks: + type: integer + xTickStart: + type: number + format: float + xTickStep: + type: number + format: float + yColumn: + type: string + generateYAxisTicks: + type: array + items: + type: string + yTotalTicks: + type: integer + yTickStart: + type: number + format: float + yTickStep: + type: number + format: float + upperColumn: + type: string + mainColumn: + type: string + lowerColumn: + type: string + hoverDimension: + type: string + enum: + - auto + - x + - 'y' + - xy + geom: + $ref: '#/components/schemas/XYGeom' + legendColorizeRows: + type: boolean + legendHide: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + LinePlusSingleStatProperties: + type: object + required: + - type + - queries + - shape + - axes + - colors + - note + - showNoteWhenEmpty + - prefix + - suffix + - decimalPlaces + - position + properties: + adaptiveZoomHide: + type: boolean + timeFormat: + type: string + type: + type: string + enum: + - line-plus-single-stat + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + shape: + type: string + enum: + - chronograf-v2 + note: + type: string + showNoteWhenEmpty: + description: 'If true, will display note when empty' + type: boolean + axes: + $ref: '#/components/schemas/Axes' + staticLegend: + $ref: '#/components/schemas/StaticLegend' + xColumn: + type: string + generateXAxisTicks: + type: array + items: + type: string + xTotalTicks: + type: integer + xTickStart: + type: number + format: float + xTickStep: + type: number + format: float + yColumn: + type: string + generateYAxisTicks: + type: array + items: + type: string + yTotalTicks: + type: integer + yTickStart: + type: number + format: float + yTickStep: + type: number + format: float + shadeBelow: + type: boolean + hoverDimension: + type: string + enum: + - auto + - x + - 'y' + - xy + position: + type: string + enum: + - overlaid + - stacked + prefix: + type: string + suffix: + type: string + decimalPlaces: + $ref: '#/components/schemas/DecimalPlaces' + legendColorizeRows: + type: boolean + legendHide: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + MosaicViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - xColumn + - ySeriesColumns + - fillColumns + - xDomain + - yDomain + - xAxisLabel + - yAxisLabel + - xPrefix + - yPrefix + - xSuffix + - ySuffix + properties: + timeFormat: + type: string + type: + type: string + enum: + - mosaic + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + type: string + shape: + type: string + enum: + - chronograf-v2 + note: + type: string + showNoteWhenEmpty: + description: 'If true, will display note when empty' + type: boolean + xColumn: + type: string + generateXAxisTicks: + type: array + items: + type: string + xTotalTicks: + type: integer + xTickStart: + type: number + format: float + xTickStep: + type: number + format: float + yLabelColumnSeparator: + type: string + yLabelColumns: + type: array + items: + type: string + ySeriesColumns: + type: array + items: + type: string + fillColumns: + type: array + items: + type: string + xDomain: + type: array + items: + type: number + maxItems: 2 + yDomain: + type: array + items: + type: number + maxItems: 2 + xAxisLabel: + type: string + yAxisLabel: + type: string + xPrefix: + type: string + xSuffix: + type: string + yPrefix: + type: string + ySuffix: + type: string + hoverDimension: + type: string + enum: + - auto + - x + - 'y' + - xy + legendColorizeRows: + type: boolean + legendHide: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + ScatterViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - xColumn + - yColumn + - fillColumns + - symbolColumns + - xDomain + - yDomain + - xAxisLabel + - yAxisLabel + - xPrefix + - yPrefix + - xSuffix + - ySuffix + properties: + adaptiveZoomHide: + type: boolean + timeFormat: + type: string + type: + type: string + enum: + - scatter + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + type: string + shape: + type: string + enum: + - chronograf-v2 + note: + type: string + showNoteWhenEmpty: + description: 'If true, will display note when empty' + type: boolean + xColumn: + type: string + generateXAxisTicks: + type: array + items: + type: string + xTotalTicks: + type: integer + xTickStart: + type: number + format: float + xTickStep: + type: number + format: float + yColumn: + type: string + generateYAxisTicks: + type: array + items: + type: string + yTotalTicks: + type: integer + yTickStart: + type: number + format: float + yTickStep: + type: number + format: float + fillColumns: + type: array + items: + type: string + symbolColumns: + type: array + items: + type: string + xDomain: + type: array + items: + type: number + maxItems: 2 + yDomain: + type: array + items: + type: number + maxItems: 2 + xAxisLabel: + type: string + yAxisLabel: + type: string + xPrefix: + type: string + xSuffix: + type: string + yPrefix: + type: string + ySuffix: + type: string + legendColorizeRows: + type: boolean + legendHide: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + HeatmapViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - xColumn + - yColumn + - xDomain + - yDomain + - xAxisLabel + - yAxisLabel + - xPrefix + - yPrefix + - xSuffix + - ySuffix + - binSize + properties: + adaptiveZoomHide: + type: boolean + timeFormat: + type: string + type: + type: string + enum: + - heatmap + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + type: string + shape: + type: string + enum: + - chronograf-v2 + note: + type: string + showNoteWhenEmpty: + description: 'If true, will display note when empty' + type: boolean + xColumn: + type: string + generateXAxisTicks: + type: array + items: + type: string + xTotalTicks: + type: integer + xTickStart: + type: number + format: float + xTickStep: + type: number + format: float + yColumn: + type: string + generateYAxisTicks: + type: array + items: + type: string + yTotalTicks: + type: integer + yTickStart: + type: number + format: float + yTickStep: + type: number + format: float + xDomain: + type: array + items: + type: number + maxItems: 2 + yDomain: + type: array + items: + type: number + maxItems: 2 + xAxisLabel: + type: string + yAxisLabel: + type: string + xPrefix: + type: string + xSuffix: + type: string + yPrefix: + type: string + ySuffix: + type: string + binSize: + type: number + legendColorizeRows: + type: boolean + legendHide: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + SingleStatViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - prefix + - tickPrefix + - suffix + - tickSuffix + - decimalPlaces + properties: + type: + type: string + enum: + - single-stat + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + shape: + type: string + enum: + - chronograf-v2 + note: + type: string + showNoteWhenEmpty: + description: 'If true, will display note when empty' + type: boolean + prefix: + type: string + tickPrefix: + type: string + suffix: + type: string + tickSuffix: + type: string + staticLegend: + $ref: '#/components/schemas/StaticLegend' + decimalPlaces: + $ref: '#/components/schemas/DecimalPlaces' + HistogramViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - xColumn + - fillColumns + - xDomain + - xAxisLabel + - position + - binCount + properties: + type: + type: string + enum: + - histogram + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + shape: + type: string + enum: + - chronograf-v2 + note: + type: string + showNoteWhenEmpty: + description: 'If true, will display note when empty' + type: boolean + xColumn: + type: string + fillColumns: + type: array + items: + type: string + xDomain: + type: array + items: + type: number + format: float + xAxisLabel: + type: string + position: + type: string + enum: + - overlaid + - stacked + binCount: + type: integer + legendColorizeRows: + type: boolean + legendHide: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + GaugeViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - prefix + - tickPrefix + - suffix + - tickSuffix + - decimalPlaces + properties: + type: + type: string + enum: + - gauge + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + shape: + type: string + enum: + - chronograf-v2 + note: + type: string + showNoteWhenEmpty: + description: 'If true, will display note when empty' + type: boolean + prefix: + type: string + tickPrefix: + type: string + suffix: + type: string + tickSuffix: + type: string + decimalPlaces: + $ref: '#/components/schemas/DecimalPlaces' + TableViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - tableOptions + - fieldOptions + - timeFormat + - decimalPlaces + properties: + type: + type: string + enum: + - table + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + shape: + type: string + enum: + - chronograf-v2 + note: + type: string + showNoteWhenEmpty: + description: 'If true, will display note when empty' + type: boolean + tableOptions: + type: object + properties: + verticalTimeAxis: + description: verticalTimeAxis describes the orientation of the table by indicating whether the time axis will be displayed vertically + type: boolean + sortBy: + $ref: '#/components/schemas/RenamableField' + wrapping: + description: Wrapping describes the text wrapping style to be used in table views + type: string + enum: + - truncate + - wrap + - single-line + fixFirstColumn: + description: fixFirstColumn indicates whether the first column of the table should be locked + type: boolean + fieldOptions: + description: fieldOptions represent the fields retrieved by the query with customization options + type: array + items: + $ref: '#/components/schemas/RenamableField' + timeFormat: + description: timeFormat describes the display format for time values according to moment.js date formatting + type: string + decimalPlaces: + $ref: '#/components/schemas/DecimalPlaces' + SimpleTableViewProperties: + type: object + required: + - type + - showAll + - queries + - shape + - note + - showNoteWhenEmpty + properties: + type: + type: string + enum: + - simple-table + showAll: + type: boolean + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + shape: + type: string + enum: + - chronograf-v2 + note: + type: string + showNoteWhenEmpty: + description: 'If true, will display note when empty' + type: boolean + MarkdownViewProperties: + type: object + required: + - type + - shape + - note + properties: + type: + type: string + enum: + - markdown + shape: + type: string + enum: + - chronograf-v2 + note: + type: string + CheckViewProperties: + type: object + required: + - type + - shape + - checkID + - queries + - colors + properties: + adaptiveZoomHide: + type: boolean + type: + type: string + enum: + - check + shape: + type: string + enum: + - chronograf-v2 + checkID: + type: string + check: + $ref: '#/components/schemas/Check' + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + legendColorizeRows: + type: boolean + legendHide: + type: boolean + legendOpacity: + type: number + format: float + legendOrientationThreshold: + type: integer + GeoViewLayer: + type: object + oneOf: + - $ref: '#/components/schemas/GeoCircleViewLayer' + - $ref: '#/components/schemas/GeoHeatMapViewLayer' + - $ref: '#/components/schemas/GeoPointMapViewLayer' + - $ref: '#/components/schemas/GeoTrackMapViewLayer' + GeoViewLayerProperties: + type: object + required: + - type + properties: + type: + type: string + enum: + - heatmap + - circleMap + - pointMap + - trackMap + GeoCircleViewLayer: + allOf: + - $ref: '#/components/schemas/GeoViewLayerProperties' + - type: object + required: + - radiusField + - radiusDimension + - colorField + - colorDimension + - colors + properties: + radiusField: + type: string + description: Radius field + radiusDimension: + $ref: '#/components/schemas/Axis' + colorField: + type: string + description: Circle color field + colorDimension: + $ref: '#/components/schemas/Axis' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + radius: + description: Maximum radius size in pixels + type: integer + interpolateColors: + description: Interpolate circle color based on displayed value + type: boolean + GeoPointMapViewLayer: + allOf: + - $ref: '#/components/schemas/GeoViewLayerProperties' + - type: object + required: + - colorField + - colorDimension + - colors + properties: + colorField: + type: string + description: Marker color field + colorDimension: + $ref: '#/components/schemas/Axis' + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + isClustered: + description: Cluster close markers together + type: boolean + tooltipColumns: + description: An array for which columns to display in tooltip + type: array + items: + type: string + GeoTrackMapViewLayer: + allOf: + - $ref: '#/components/schemas/GeoViewLayerProperties' + - type: object + required: + - trackWidth + - speed + - randomColors + - trackPointVisualization + properties: + trackWidth: + description: Width of the track + type: integer + speed: + description: Speed of the track animation + type: integer + randomColors: + description: Assign different colors to different tracks + type: boolean + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + GeoHeatMapViewLayer: + allOf: + - $ref: '#/components/schemas/GeoViewLayerProperties' + - type: object + required: + - intensityField + - intensityDimension + - radius + - blur + - colors + properties: + intensityField: + type: string + description: Intensity field + intensityDimension: + $ref: '#/components/schemas/Axis' + radius: + description: Radius size in pixels + type: integer + blur: + description: Blur for heatmap points + type: integer + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + GeoViewProperties: + type: object + required: + - type + - shape + - queries + - note + - showNoteWhenEmpty + - center + - zoom + - allowPanAndZoom + - detectCoordinateFields + - layers + properties: + type: + type: string + enum: + - geo + queries: + type: array + items: + $ref: '#/components/schemas/DashboardQuery' + shape: + type: string + enum: + - chronograf-v2 + center: + description: Coordinates of the center of the map + type: object + required: + - lat + - lon + properties: + lat: + description: Latitude of the center of the map + type: number + format: double + lon: + description: Longitude of the center of the map + type: number + format: double + zoom: + description: Zoom level used for initial display of the map + type: number + format: double + minimum: 1 + maximum: 28 + allowPanAndZoom: + description: 'If true, map zoom and pan controls are enabled on the dashboard view' + type: boolean + default: true + detectCoordinateFields: + description: 'If true, search results get automatically regroupped so that lon,lat and value are treated as columns' + type: boolean + default: true + useS2CellID: + description: 'If true, S2 column is used to calculate lat/lon' + type: boolean + s2Column: + description: String to define the column + type: string + latLonColumns: + $ref: '#/components/schemas/LatLonColumns' + mapStyle: + description: 'Define map type - regular, satellite etc.' + type: string + note: + type: string + showNoteWhenEmpty: + description: 'If true, will display note when empty' + type: boolean + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: '#/components/schemas/DashboardColor' + layers: + description: List of individual layers shown in the map + type: array + items: + $ref: '#/components/schemas/GeoViewLayer' + LatLonColumns: + description: Object type to define lat/lon columns + type: object + required: + - lat + - lon + properties: + lat: + $ref: '#/components/schemas/LatLonColumn' + lon: + $ref: '#/components/schemas/LatLonColumn' + LatLonColumn: + description: Object type for key and column definitions + type: object + required: + - key + - column + properties: + key: + description: Key to determine whether the column is tag/field + type: string + column: + description: Column to look up Lat/Lon + type: string + Axes: + description: The viewport for a View's visualizations + type: object + required: + - x + - 'y' + properties: + x: + $ref: '#/components/schemas/Axis' + 'y': + $ref: '#/components/schemas/Axis' + StaticLegend: + description: StaticLegend represents the options specific to the static legend + type: object + properties: + colorizeRows: + type: boolean + heightRatio: + type: number + format: float + show: + type: boolean + opacity: + type: number + format: float + orientationThreshold: + type: integer + valueAxis: + type: string + widthRatio: + type: number + format: float + DecimalPlaces: + description: 'Indicates whether decimal places should be enforced, and how many digits it should show.' + type: object + properties: + isEnforced: + description: Indicates whether decimal point setting should be enforced + type: boolean + digits: + description: The number of digits after decimal to display + type: integer + format: int32 + ConstantVariableProperties: + properties: + type: + type: string + enum: + - constant + values: + type: array + items: + type: string + MapVariableProperties: + properties: + type: + type: string + enum: + - map + values: + type: object + additionalProperties: + type: string + QueryVariableProperties: + properties: + type: + type: string + enum: + - query + values: + type: object + properties: + query: + type: string + language: + type: string + VariableProperties: + type: object + oneOf: + - $ref: '#/components/schemas/QueryVariableProperties' + - $ref: '#/components/schemas/ConstantVariableProperties' + - $ref: '#/components/schemas/MapVariableProperties' + ViewProperties: + oneOf: + - $ref: '#/components/schemas/LinePlusSingleStatProperties' + - $ref: '#/components/schemas/XYViewProperties' + - $ref: '#/components/schemas/SingleStatViewProperties' + - $ref: '#/components/schemas/HistogramViewProperties' + - $ref: '#/components/schemas/GaugeViewProperties' + - $ref: '#/components/schemas/TableViewProperties' + - $ref: '#/components/schemas/SimpleTableViewProperties' + - $ref: '#/components/schemas/MarkdownViewProperties' + - $ref: '#/components/schemas/CheckViewProperties' + - $ref: '#/components/schemas/ScatterViewProperties' + - $ref: '#/components/schemas/HeatmapViewProperties' + - $ref: '#/components/schemas/MosaicViewProperties' + - $ref: '#/components/schemas/BandViewProperties' + - $ref: '#/components/schemas/GeoViewProperties' + View: + required: + - name + - properties + properties: + links: + type: object + readOnly: true + properties: + self: + type: string + id: + readOnly: true + type: string + name: + type: string + properties: + $ref: '#/components/schemas/ViewProperties' + Views: + type: object + properties: + links: + type: object + properties: + self: + type: string + views: + type: array + items: + $ref: '#/components/schemas/View' + CellUpdate: + type: object + properties: + x: + type: integer + format: int32 + 'y': + type: integer + format: int32 + w: + type: integer + format: int32 + h: + type: integer + format: int32 + CreateCell: + type: object + properties: + name: + type: string + x: + type: integer + format: int32 + 'y': + type: integer + format: int32 + w: + type: integer + format: int32 + h: + type: integer + format: int32 + usingView: + type: string + description: Makes a copy of the provided view. + AnalyzeQueryResponse: + type: object + properties: + errors: + type: array + items: + type: object + properties: + line: + type: integer + column: + type: integer + character: + type: integer + message: + type: string + CellWithViewProperties: + type: object + allOf: + - $ref: '#/components/schemas/Cell' + - type: object + properties: + name: + type: string + properties: + $ref: '#/components/schemas/ViewProperties' + Cell: + type: object + properties: + id: + type: string + links: + type: object + properties: + self: + type: string + view: + type: string + x: + type: integer + format: int32 + 'y': + type: integer + format: int32 + w: + type: integer + format: int32 + h: + type: integer + format: int32 + viewID: + type: string + description: The reference to a view from the views API. + CellsWithViewProperties: + type: array + items: + $ref: '#/components/schemas/CellWithViewProperties' + Cells: + type: array + items: + $ref: '#/components/schemas/Cell' + Secrets: + additionalProperties: + type: string + example: + apikey: abc123xyz + SecretKeys: + type: object + properties: + secrets: + type: array + items: + type: string + SecretKeysResponse: + allOf: + - $ref: '#/components/schemas/SecretKeys' + - type: object + properties: + links: + readOnly: true + type: object + properties: + self: + type: string + org: + type: string + CreateDashboardRequest: + properties: + orgID: + type: string + description: The ID of the organization that owns the dashboard. + name: + type: string + description: The user-facing name of the dashboard. + description: + type: string + description: The user-facing description of the dashboard. + required: + - orgID + - name + DashboardWithViewProperties: + type: object + allOf: + - $ref: '#/components/schemas/CreateDashboardRequest' + - type: object + properties: + links: + type: object + example: + self: /api/v2/dashboards/1 + cells: /api/v2/dashboards/1/cells + owners: /api/v2/dashboards/1/owners + members: /api/v2/dashboards/1/members + labels: /api/v2/dashboards/1/labels + org: /api/v2/labels/1 + properties: + self: + $ref: '#/components/schemas/Link' + cells: + $ref: '#/components/schemas/Link' + members: + $ref: '#/components/schemas/Link' + owners: + $ref: '#/components/schemas/Link' + labels: + $ref: '#/components/schemas/Link' + org: + $ref: '#/components/schemas/Link' + id: + readOnly: true + type: string + meta: + type: object + properties: + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + cells: + $ref: '#/components/schemas/CellsWithViewProperties' + labels: + $ref: '#/components/schemas/Labels' + Dashboard: + type: object + allOf: + - $ref: '#/components/schemas/CreateDashboardRequest' + - type: object + properties: + links: + type: object + example: + self: /api/v2/dashboards/1 + cells: /api/v2/dashboards/1/cells + owners: /api/v2/dashboards/1/owners + members: /api/v2/dashboards/1/members + labels: /api/v2/dashboards/1/labels + org: /api/v2/labels/1 + properties: + self: + $ref: '#/components/schemas/Link' + cells: + $ref: '#/components/schemas/Link' + members: + $ref: '#/components/schemas/Link' + owners: + $ref: '#/components/schemas/Link' + labels: + $ref: '#/components/schemas/Link' + org: + $ref: '#/components/schemas/Link' + id: + readOnly: true + type: string + meta: + type: object + properties: + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + cells: + $ref: '#/components/schemas/Cells' + labels: + $ref: '#/components/schemas/Labels' + Dashboards: + type: object + properties: + links: + $ref: '#/components/schemas/Links' + dashboards: + type: array + items: + $ref: '#/components/schemas/Dashboard' + TelegrafRequest: + type: object + properties: + name: + type: string + description: + type: string + metadata: + type: object + properties: + buckets: + type: array + items: + type: string + config: + type: string + orgID: + type: string + TelegrafPluginRequest: + type: object + properties: + name: + type: string + description: + type: string + plugins: + type: array + items: + type: object + properties: + type: + type: string + name: + type: string + alias: + type: string + description: + type: string + config: + type: string + metadata: + type: object + properties: + buckets: + type: array + items: + type: string + config: + type: string + orgID: + type: string + Telegraf: + type: object + allOf: + - $ref: '#/components/schemas/TelegrafRequest' + - type: object + properties: + id: + type: string + readOnly: true + links: + type: object + readOnly: true + example: + self: /api/v2/telegrafs/1 + lables: /api/v2/telegrafs/1/labels + owners: /api/v2/telegrafs/1/owners + members: /api/v2/telegrafs/1/members + properties: + self: + $ref: '#/components/schemas/Link' + labels: + $ref: '#/components/schemas/Link' + members: + $ref: '#/components/schemas/Link' + owners: + $ref: '#/components/schemas/Link' + labels: + readOnly: true + $ref: '#/components/schemas/Labels' + Telegrafs: + type: object + properties: + configurations: + type: array + items: + $ref: '#/components/schemas/Telegraf' + TelegrafPlugin: + type: object + properties: + type: + type: string + name: + type: string + description: + type: string + config: + type: string + TelegrafPlugins: + type: object + properties: + version: + type: string + os: + type: string + plugins: + type: array + items: + $ref: '#/components/schemas/TelegrafPlugin' + IsOnboarding: + type: object + properties: + allowed: + description: | + If `true`, the InfluxDB instance hasn't had initial setup; + `false` otherwise. + type: boolean + PasswordResetBody: + properties: + password: + type: string + required: + - password + AddResourceMemberRequestBody: + type: object + properties: + id: + type: string + description: | + The ID of the user to add to the resource. + name: + type: string + description: | + The name of the user to add to the resource. + required: + - id + Ready: + type: object + properties: + status: + type: string + enum: + - ready + started: + type: string + format: date-time + example: '2019-03-13T10:09:33.891196-04:00' + up: + type: string + example: 14m45.911966424s + HealthCheck: + type: object + required: + - name + - status + properties: + name: + type: string + message: + type: string + checks: + type: array + items: + $ref: '#/components/schemas/HealthCheck' + status: + type: string + enum: + - pass + - fail + version: + type: string + commit: + type: string + Labels: + type: array + items: + $ref: '#/components/schemas/Label' + Label: + type: object + properties: + id: + readOnly: true + type: string + orgID: + readOnly: true + type: string + name: + type: string + properties: + type: object + additionalProperties: + type: string + description: | + Key-value pairs associated with this label. + To remove a property, send an update with an empty value (`""`) for the key. + example: + color: ffb3b3 + description: this is a description + LabelCreateRequest: + type: object + required: + - orgID + - name + properties: + orgID: + type: string + name: + type: string + properties: + type: object + additionalProperties: + type: string + description: | + Key-value pairs associated with this label. + + To remove a property, send an update with an empty value (`""`) for the key. + example: + color: ffb3b3 + description: this is a description + LabelUpdate: + type: object + properties: + name: + type: string + properties: + type: object + additionalProperties: + type: string + description: | + Key-value pairs associated with this label. + + To remove a property, send an update with an empty value (`""`) for the key. + example: + color: ffb3b3 + description: this is a description + LabelMapping: + type: object + properties: + labelID: + description: | + Label ID. + The ID of the label to attach. + type: string + LabelsResponse: + type: object + properties: + labels: + $ref: '#/components/schemas/Labels' + links: + $ref: '#/components/schemas/Links' + LabelResponse: + type: object + properties: + label: + $ref: '#/components/schemas/Label' + links: + $ref: '#/components/schemas/Links' + ASTResponse: + description: Contains the AST for the supplied Flux query + type: object + properties: + ast: + $ref: '#/components/schemas/Package' + WritePrecision: + type: string + enum: + - ms + - s + - us + - ns + FluxResponse: + description: Rendered flux that backs the check or notification. + properties: + flux: + type: string + CheckPatch: + type: object + properties: + name: + type: string + description: + type: string + status: + type: string + enum: + - active + - inactive + CheckDiscriminator: + oneOf: + - $ref: '#/components/schemas/DeadmanCheck' + - $ref: '#/components/schemas/ThresholdCheck' + - $ref: '#/components/schemas/CustomCheck' + discriminator: + propertyName: type + mapping: + deadman: '#/components/schemas/DeadmanCheck' + threshold: '#/components/schemas/ThresholdCheck' + custom: '#/components/schemas/CustomCheck' + Check: + allOf: + - $ref: '#/components/schemas/CheckDiscriminator' + PostCheck: + allOf: + - $ref: '#/components/schemas/CheckDiscriminator' + Checks: + properties: + checks: + type: array + items: + $ref: '#/components/schemas/Check' + links: + $ref: '#/components/schemas/Links' + CheckBase: + properties: + id: + readOnly: true + type: string + name: + type: string + orgID: + description: The ID of the organization that owns this check. + type: string + taskID: + description: The ID of the task associated with this check. + type: string + ownerID: + description: The ID of creator used to create this check. + type: string + readOnly: true + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + query: + $ref: '#/components/schemas/DashboardQuery' + status: + $ref: '#/components/schemas/TaskStatusType' + description: + description: An optional description of the check. + type: string + latestCompleted: + type: string + description: 'A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp)) of the latest scheduled and completed run.' + format: date-time + readOnly: true + lastRunStatus: + readOnly: true + type: string + enum: + - failed + - success + - canceled + lastRunError: + readOnly: true + type: string + labels: + $ref: '#/components/schemas/Labels' + links: + type: object + readOnly: true + example: + self: /api/v2/checks/1 + labels: /api/v2/checks/1/labels + members: /api/v2/checks/1/members + owners: /api/v2/checks/1/owners + query: /api/v2/checks/1/query + properties: + self: + description: URL for this check + $ref: '#/components/schemas/Link' + labels: + description: URL to retrieve labels for this check + $ref: '#/components/schemas/Link' + members: + description: URL to retrieve members for this check + $ref: '#/components/schemas/Link' + owners: + description: URL to retrieve owners for this check + $ref: '#/components/schemas/Link' + query: + description: URL to retrieve flux script for this check + $ref: '#/components/schemas/Link' + required: + - name + - orgID + - query + ThresholdCheck: + allOf: + - $ref: '#/components/schemas/CheckBase' + - type: object + required: + - type + properties: + type: + type: string + enum: + - threshold + thresholds: + type: array + items: + $ref: '#/components/schemas/Threshold' + every: + description: Check repetition interval. + type: string + offset: + description: 'Duration to delay after the schedule, before executing check.' + type: string + tags: + description: List of tags to write to each status. + type: array + items: + type: object + properties: + key: + type: string + value: + type: string + statusMessageTemplate: + description: The template used to generate and write a status message. + type: string + Threshold: + oneOf: + - $ref: '#/components/schemas/GreaterThreshold' + - $ref: '#/components/schemas/LesserThreshold' + - $ref: '#/components/schemas/RangeThreshold' + discriminator: + propertyName: type + mapping: + greater: '#/components/schemas/GreaterThreshold' + lesser: '#/components/schemas/LesserThreshold' + range: '#/components/schemas/RangeThreshold' + DeadmanCheck: + allOf: + - $ref: '#/components/schemas/CheckBase' + - type: object + required: + - type + properties: + type: + type: string + enum: + - deadman + timeSince: + description: String duration before deadman triggers. + type: string + staleTime: + description: String duration for time that a series is considered stale and should not trigger deadman. + type: string + reportZero: + description: 'If only zero values reported since time, trigger an alert' + type: boolean + level: + $ref: '#/components/schemas/CheckStatusLevel' + every: + description: Check repetition interval. + type: string + offset: + description: 'Duration to delay after the schedule, before executing check.' + type: string + tags: + description: List of tags to write to each status. + type: array + items: + type: object + properties: + key: + type: string + value: + type: string + statusMessageTemplate: + description: The template used to generate and write a status message. + type: string + CustomCheck: + allOf: + - $ref: '#/components/schemas/CheckBase' + - type: object + properties: + type: + type: string + enum: + - custom + required: + - type + ThresholdBase: + properties: + level: + $ref: '#/components/schemas/CheckStatusLevel' + allValues: + description: 'If true, only alert if all values meet threshold.' + type: boolean + GreaterThreshold: + allOf: + - $ref: '#/components/schemas/ThresholdBase' + - type: object + required: + - type + - value + properties: + type: + type: string + enum: + - greater + value: + type: number + format: float + LesserThreshold: + allOf: + - $ref: '#/components/schemas/ThresholdBase' + - type: object + required: + - type + - value + properties: + type: + type: string + enum: + - lesser + value: + type: number + format: float + RangeThreshold: + allOf: + - $ref: '#/components/schemas/ThresholdBase' + - type: object + required: + - type + - min + - max + - within + properties: + type: + type: string + enum: + - range + min: + type: number + format: float + max: + type: number + format: float + within: + type: boolean + CheckStatusLevel: + description: The state to record if check matches a criteria. + type: string + enum: + - UNKNOWN + - OK + - INFO + - CRIT + - WARN + RuleStatusLevel: + description: The state to record if check matches a criteria. + type: string + enum: + - UNKNOWN + - OK + - INFO + - CRIT + - WARN + - ANY + NotificationRuleUpdate: + type: object + properties: + name: + type: string + description: + type: string + status: + type: string + enum: + - active + - inactive + NotificationRuleDiscriminator: + oneOf: + - $ref: '#/components/schemas/SlackNotificationRule' + - $ref: '#/components/schemas/SMTPNotificationRule' + - $ref: '#/components/schemas/PagerDutyNotificationRule' + - $ref: '#/components/schemas/HTTPNotificationRule' + - $ref: '#/components/schemas/TelegramNotificationRule' + discriminator: + propertyName: type + mapping: + slack: '#/components/schemas/SlackNotificationRule' + smtp: '#/components/schemas/SMTPNotificationRule' + pagerduty: '#/components/schemas/PagerDutyNotificationRule' + http: '#/components/schemas/HTTPNotificationRule' + telegram: '#/components/schemas/TelegramNotificationRule' + NotificationRule: + allOf: + - $ref: '#/components/schemas/NotificationRuleDiscriminator' + PostNotificationRule: + allOf: + - $ref: '#/components/schemas/NotificationRuleDiscriminator' + NotificationRules: + properties: + notificationRules: + type: array + items: + $ref: '#/components/schemas/NotificationRule' + links: + $ref: '#/components/schemas/Links' + NotificationRuleBase: + type: object + required: + - orgID + - status + - name + - statusRules + - endpointID + properties: + latestCompleted: + description: 'A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp)) of the latest scheduled and completed run.' + type: string + format: date-time + readOnly: true + lastRunStatus: + readOnly: true + type: string + enum: + - failed + - success + - canceled + lastRunError: + readOnly: true + type: string + id: + readOnly: true + type: string + endpointID: + type: string + orgID: + description: The ID of the organization that owns this notification rule. + type: string + taskID: + description: The ID of the task associated with this notification rule. + type: string + ownerID: + description: The ID of creator used to create this notification rule. + type: string + readOnly: true + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + status: + $ref: '#/components/schemas/TaskStatusType' + name: + description: Human-readable name describing the notification rule. + type: string + sleepUntil: + type: string + every: + description: The notification repetition interval. + type: string + offset: + description: 'Duration to delay after the schedule, before executing check.' + type: string + runbookLink: + type: string + limitEvery: + description: 'Don''t notify me more than times every seconds. If set, limit cannot be empty.' + type: integer + limit: + description: 'Don''t notify me more than times every seconds. If set, limitEvery cannot be empty.' + type: integer + tagRules: + description: List of tag rules the notification rule attempts to match. + type: array + items: + $ref: '#/components/schemas/TagRule' + description: + description: An optional description of the notification rule. + type: string + statusRules: + description: List of status rules the notification rule attempts to match. + type: array + minItems: 1 + items: + $ref: '#/components/schemas/StatusRule' + labels: + $ref: '#/components/schemas/Labels' + links: + type: object + readOnly: true + example: + self: /api/v2/notificationRules/1 + labels: /api/v2/notificationRules/1/labels + members: /api/v2/notificationRules/1/members + owners: /api/v2/notificationRules/1/owners + query: /api/v2/notificationRules/1/query + properties: + self: + description: URL for this endpoint. + $ref: '#/components/schemas/Link' + labels: + description: URL to retrieve labels for this notification rule. + $ref: '#/components/schemas/Link' + members: + description: URL to retrieve members for this notification rule. + $ref: '#/components/schemas/Link' + owners: + description: URL to retrieve owners for this notification rule. + $ref: '#/components/schemas/Link' + query: + description: URL to retrieve flux script for this notification rule. + $ref: '#/components/schemas/Link' + TagRule: + type: object + properties: + key: + type: string + value: + type: string + operator: + type: string + enum: + - equal + - notequal + - equalregex + - notequalregex + StatusRule: + type: object + properties: + currentLevel: + $ref: '#/components/schemas/RuleStatusLevel' + previousLevel: + $ref: '#/components/schemas/RuleStatusLevel' + count: + type: integer + period: + type: string + HTTPNotificationRuleBase: + type: object + required: + - type + properties: + type: + type: string + enum: + - http + url: + type: string + HTTPNotificationRule: + allOf: + - $ref: '#/components/schemas/NotificationRuleBase' + - $ref: '#/components/schemas/HTTPNotificationRuleBase' + SlackNotificationRuleBase: + type: object + required: + - type + - messageTemplate + properties: + type: + type: string + enum: + - slack + channel: + type: string + messageTemplate: + type: string + SlackNotificationRule: + allOf: + - $ref: '#/components/schemas/NotificationRuleBase' + - $ref: '#/components/schemas/SlackNotificationRuleBase' + SMTPNotificationRule: + allOf: + - $ref: '#/components/schemas/NotificationRuleBase' + - $ref: '#/components/schemas/SMTPNotificationRuleBase' + SMTPNotificationRuleBase: + type: object + required: + - type + - subjectTemplate + - to + properties: + type: + type: string + enum: + - smtp + subjectTemplate: + type: string + bodyTemplate: + type: string + to: + type: string + PagerDutyNotificationRule: + allOf: + - $ref: '#/components/schemas/NotificationRuleBase' + - $ref: '#/components/schemas/PagerDutyNotificationRuleBase' + PagerDutyNotificationRuleBase: + type: object + required: + - type + - messageTemplate + properties: + type: + type: string + enum: + - pagerduty + messageTemplate: + type: string + TelegramNotificationRule: + allOf: + - $ref: '#/components/schemas/NotificationRuleBase' + - $ref: '#/components/schemas/TelegramNotificationRuleBase' + TelegramNotificationRuleBase: + type: object + required: + - type + - messageTemplate + - channel + properties: + type: + description: The discriminator between other types of notification rules is "telegram". + type: string + enum: + - telegram + messageTemplate: + description: The message template as a flux interpolated string. + type: string + parseMode: + description: 'Parse mode of the message text per https://core.telegram.org/bots/api#formatting-options. Defaults to "MarkdownV2".' + type: string + enum: + - MarkdownV2 + - HTML + - Markdown + disableWebPagePreview: + description: Disables preview of web links in the sent messages when "true". Defaults to "false". + type: boolean + NotificationEndpointUpdate: + type: object + properties: + name: + type: string + description: + type: string + status: + type: string + enum: + - active + - inactive + NotificationEndpointDiscriminator: + oneOf: + - $ref: '#/components/schemas/SlackNotificationEndpoint' + - $ref: '#/components/schemas/PagerDutyNotificationEndpoint' + - $ref: '#/components/schemas/HTTPNotificationEndpoint' + - $ref: '#/components/schemas/TelegramNotificationEndpoint' + discriminator: + propertyName: type + mapping: + slack: '#/components/schemas/SlackNotificationEndpoint' + pagerduty: '#/components/schemas/PagerDutyNotificationEndpoint' + http: '#/components/schemas/HTTPNotificationEndpoint' + telegram: '#/components/schemas/TelegramNotificationEndpoint' + NotificationEndpoint: + allOf: + - $ref: '#/components/schemas/NotificationEndpointDiscriminator' + PostNotificationEndpoint: + allOf: + - $ref: '#/components/schemas/NotificationEndpointDiscriminator' + NotificationEndpoints: + properties: + notificationEndpoints: + type: array + items: + $ref: '#/components/schemas/NotificationEndpoint' + links: + $ref: '#/components/schemas/Links' + NotificationEndpointBase: + type: object + required: + - type + - name + properties: + id: + type: string + orgID: + type: string + userID: + type: string + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + description: + description: An optional description of the notification endpoint. + type: string + name: + type: string + status: + description: The status of the endpoint. + default: active + type: string + enum: + - active + - inactive + labels: + $ref: '#/components/schemas/Labels' + links: + type: object + readOnly: true + example: + self: /api/v2/notificationEndpoints/1 + labels: /api/v2/notificationEndpoints/1/labels + members: /api/v2/notificationEndpoints/1/members + owners: /api/v2/notificationEndpoints/1/owners + properties: + self: + description: URL for this endpoint. + $ref: '#/components/schemas/Link' + labels: + description: URL to retrieve labels for this endpoint. + $ref: '#/components/schemas/Link' + members: + description: URL to retrieve members for this endpoint. + $ref: '#/components/schemas/Link' + owners: + description: URL to retrieve owners for this endpoint. + $ref: '#/components/schemas/Link' + type: + $ref: '#/components/schemas/NotificationEndpointType' + SlackNotificationEndpoint: + type: object + allOf: + - $ref: '#/components/schemas/NotificationEndpointBase' + - type: object + properties: + url: + description: Specifies the URL of the Slack endpoint. Specify either `URL` or `Token`. + type: string + token: + description: Specifies the API token string. Specify either `URL` or `Token`. + type: string + PagerDutyNotificationEndpoint: + type: object + allOf: + - $ref: '#/components/schemas/NotificationEndpointBase' + - type: object + required: + - routingKey + properties: + clientURL: + type: string + routingKey: + type: string + HTTPNotificationEndpoint: + type: object + allOf: + - $ref: '#/components/schemas/NotificationEndpointBase' + - type: object + required: + - url + - authMethod + - method + properties: + url: + type: string + username: + type: string + password: + type: string + token: + type: string + method: + type: string + enum: + - POST + - GET + - PUT + authMethod: + type: string + enum: + - none + - basic + - bearer + contentTemplate: + type: string + headers: + type: object + description: Customized headers. + additionalProperties: + type: string + TelegramNotificationEndpoint: + type: object + allOf: + - $ref: '#/components/schemas/NotificationEndpointBase' + - type: object + required: + - token + - channel + properties: + token: + description: 'Specifies the Telegram bot token. See https://core.telegram.org/bots#creating-a-new-bot .' + type: string + channel: + description: 'The ID of the telegram channel; a chat_id in https://core.telegram.org/bots/api#sendmessage .' + type: string + NotificationEndpointType: + type: string + enum: + - slack + - pagerduty + - http + - telegram + DBRP: + type: object + properties: + id: + type: string + description: The ID of the DBRP mapping. + readOnly: true + orgID: + type: string + description: The ID of the organization. + bucketID: + type: string + description: The ID of the bucket used as the target for the translation. + database: + type: string + description: InfluxDB v1 database + retention_policy: + type: string + description: InfluxDB v1 retention policy + default: + type: boolean + description: Mapping represents the default retention policy for the database specified. + virtual: + type: boolean + description: 'Indicates an autogenerated, virtual mapping based on the bucket name. Currently only available in OSS.' + links: + $ref: '#/components/schemas/Links' + required: + - id + - orgID + - bucketID + - database + - retention_policy + - default + DBRPs: + properties: + content: + type: array + items: + $ref: '#/components/schemas/DBRP' + DBRPUpdate: + properties: + retention_policy: + type: string + description: InfluxDB v1 retention policy + default: + type: boolean + DBRPCreate: + type: object + properties: + orgID: + type: string + description: The ID of the organization. + org: + type: string + description: The name of the organization that owns this mapping. + bucketID: + type: string + description: The ID of the bucket used as the target for the translation. + database: + type: string + description: InfluxDB v1 database + retention_policy: + type: string + description: InfluxDB v1 retention policy + default: + type: boolean + description: Mapping represents the default retention policy for the database specified. + required: + - bucketID + - database + - retention_policy + DBRPGet: + type: object + properties: + content: + $ref: '#/components/schemas/DBRP' + required: true + SchemaType: + type: string + enum: + - implicit + - explicit + ColorMapping: + type: object + description: 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. + additionalProperties: + type: string + example: + series_id_1: '#edf529' + series_id_2: '#edf529' + measurement_birdmigration_europe: '#663cd0' + configcat_deployments-autopromotionblocker: '#663cd0' + Authorization: + required: + - orgID + - permissions + allOf: + - $ref: '#/components/schemas/AuthorizationUpdateRequest' + - type: object + properties: + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + orgID: + type: string + description: The ID of the organization. + permissions: + type: array + minItems: 1 + description: | + A list of permissions for an authorization. + An authorization must have at least one permission. + items: + $ref: '#/components/schemas/Permission' + id: + readOnly: true + type: string + token: + readOnly: true + type: string + description: | + The API token for authenticating InfluxDB API and CLI requests. + userID: + readOnly: true + type: string + description: The ID of the user that created and owns the token. + user: + readOnly: true + type: string + description: The name of the user that created and owns the token. + org: + readOnly: true + type: string + description: The name of the organization that the token is scoped to. + links: + type: object + readOnly: true + example: + self: /api/v2/authorizations/1 + user: /api/v2/users/12 + properties: + self: + readOnly: true + $ref: '#/components/schemas/Link' + user: + readOnly: true + $ref: '#/components/schemas/Link' + Authorizations: + type: object + properties: + links: + readOnly: true + $ref: '#/components/schemas/Links' + authorizations: + type: array + items: + $ref: '#/components/schemas/Authorization' + AuthorizationPostRequest: + required: + - orgID + - permissions + allOf: + - $ref: '#/components/schemas/AuthorizationUpdateRequest' + - type: object + properties: + orgID: + type: string + description: | + The ID of the organization that owns the authorization. + userID: + type: string + description: | + The ID of the user that the authorization is scoped to. + permissions: + type: array + minItems: 1 + description: | + A list of permissions for an authorization. + An authorization must have at least one permission. + items: + $ref: '#/components/schemas/Permission' + Permission: + required: + - action + - resource + properties: + action: + type: string + enum: + - read + - write + resource: + $ref: '#/components/schemas/Resource' + Resource: + type: object + required: + - type + properties: + type: + type: string + enum: + - authorizations + - buckets + - dashboards + - orgs + - sources + - tasks + - telegrafs + - users + - variables + - scrapers + - secrets + - labels + - views + - documents + - notificationRules + - notificationEndpoints + - checks + - dbrp + - notebooks + - annotations + - remotes + - replications + - instance + description: | + The type of resource. + In a `permission`, applies the permission to all resources of this type. + id: + type: string + description: | + The ID of a specific resource. + In a `permission`, applies the permission to only the resource with this ID. + name: + type: string + description: | + Optional: A name for the resource. + Not all resource types have a name field. + orgID: + type: string + description: | + The ID of the organization that owns the resource. + In a `permission`, applies the permission to all resources of `type` owned by this organization. + org: + type: string + description: | + Optional: The name of the organization with `orgID`. + User: + properties: + id: + readOnly: true + type: string + oauthID: + type: string + name: + type: string + status: + description: If inactive the user is inactive. + default: active + type: string + enum: + - active + - inactive + required: + - name + Users: + type: object + properties: + links: + type: object + properties: + self: + type: string + format: uri + users: + type: array + items: + $ref: '#/components/schemas/UserResponse' + OnboardingRequest: + type: object + properties: + username: + type: string + password: + type: string + org: + type: string + bucket: + type: string + retentionPeriodSeconds: + type: integer + format: int64 + retentionPeriodHrs: + type: integer + deprecated: true + description: | + Retention period *in nanoseconds* for the new bucket. This key's name has been misleading since OSS 2.0 GA, please transition to use `retentionPeriodSeconds` + token: + type: string + description: | + Authentication token to set on the initial user. If not specified, the server will generate a token. + required: + - username + - org + - bucket + OnboardingResponse: + type: object + properties: + user: + $ref: '#/components/schemas/UserResponse' + org: + $ref: '#/components/schemas/Organization' + bucket: + $ref: '#/components/schemas/Bucket' + auth: + $ref: '#/components/schemas/Authorization' + Variable: + type: object + required: + - name + - orgID + - arguments + properties: + links: + type: object + readOnly: true + properties: + self: + type: string + format: uri + org: + type: string + format: uri + labels: + type: string + format: uri + id: + readOnly: true + type: string + orgID: + type: string + name: + type: string + description: + type: string + selected: + type: array + items: + type: string + labels: + $ref: '#/components/schemas/Labels' + arguments: + $ref: '#/components/schemas/VariableProperties' + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + Variables: + type: object + example: + variables: + - id: '1221432' + name: ':ok:' + selected: + - hello + arguments: + type: constant + values: + - howdy + - hello + - hi + - yo + - oy + - id: '1221432' + name: ':ok:' + selected: + - c + arguments: + type: map + values: + a: fdjaklfdjkldsfjlkjdsa + b: dfaksjfkljekfajekdljfas + c: fdjksajfdkfeawfeea + - id: '1221432' + name: ':ok:' + selected: + - host + arguments: + type: query + query: 'from(bucket: "foo") |> showMeasurements()' + language: flux + properties: + variables: + type: array + items: + $ref: '#/components/schemas/Variable' + Source: + type: object + properties: + links: + type: object + properties: + self: + type: string + query: + type: string + health: + type: string + buckets: + type: string + id: + type: string + orgID: + type: string + default: + type: boolean + name: + type: string + type: + type: string + enum: + - v1 + - v2 + - self + url: + type: string + format: uri + insecureSkipVerify: + type: boolean + telegraf: + type: string + token: + type: string + username: + type: string + password: + type: string + sharedSecret: + type: string + metaUrl: + type: string + format: uri + defaultRP: + type: string + languages: + type: array + readOnly: true + items: + type: string + enum: + - flux + - influxql + Sources: + type: object + properties: + links: + type: object + properties: + self: + type: string + format: uri + sources: + type: array + items: + $ref: '#/components/schemas/Source' + ScraperTargetRequest: + type: object + properties: + name: + type: string + description: The name of the scraper target. + type: + type: string + description: The type of the metrics to be parsed. + enum: + - prometheus + url: + type: string + description: The URL of the metrics endpoint. + example: 'http://localhost:9090/metrics' + orgID: + type: string + description: The organization ID. + bucketID: + type: string + description: The ID of the bucket to write to. + allowInsecure: + type: boolean + description: Skip TLS verification on endpoint. + default: false + ScraperTargetResponse: + type: object + allOf: + - $ref: '#/components/schemas/ScraperTargetRequest' + - type: object + properties: + id: + type: string + readOnly: true + org: + type: string + description: The name of the organization. + bucket: + type: string + description: The bucket name. + links: + type: object + readOnly: true + example: + self: /api/v2/scrapers/1 + owners: /api/v2/scrapers/1/owners + members: /api/v2/scrapers/1/members + bucket: /api/v2/buckets/1 + organization: /api/v2/orgs/1 + properties: + self: + $ref: '#/components/schemas/Link' + members: + $ref: '#/components/schemas/Link' + owners: + $ref: '#/components/schemas/Link' + bucket: + $ref: '#/components/schemas/Link' + organization: + $ref: '#/components/schemas/Link' + ScraperTargetResponses: + type: object + properties: + configurations: + type: array + items: + $ref: '#/components/schemas/ScraperTargetResponse' + MetadataBackup: + type: object + properties: + kv: + type: string + format: binary + sql: + type: string + format: binary + buckets: + $ref: '#/components/schemas/BucketMetadataManifests' + required: + - kv + - sql + - buckets + BucketMetadataManifests: + type: array + items: + $ref: '#/components/schemas/BucketMetadataManifest' + BucketMetadataManifest: + type: object + properties: + organizationID: + type: string + organizationName: + type: string + bucketID: + type: string + bucketName: + type: string + description: + type: string + defaultRetentionPolicy: + type: string + retentionPolicies: + $ref: '#/components/schemas/RetentionPolicyManifests' + required: + - organizationID + - organizationName + - bucketID + - bucketName + - defaultRetentionPolicy + - retentionPolicies + RetentionPolicyManifests: + type: array + items: + $ref: '#/components/schemas/RetentionPolicyManifest' + RetentionPolicyManifest: + type: object + properties: + name: + type: string + replicaN: + type: integer + duration: + type: integer + format: int64 + shardGroupDuration: + type: integer + format: int64 + shardGroups: + $ref: '#/components/schemas/ShardGroupManifests' + subscriptions: + $ref: '#/components/schemas/SubscriptionManifests' + required: + - name + - replicaN + - duration + - shardGroupDuration + - shardGroups + - subscriptions + ShardGroupManifests: + type: array + items: + $ref: '#/components/schemas/ShardGroupManifest' + ShardGroupManifest: + type: object + properties: + id: + type: integer + format: int64 + startTime: + type: string + format: date-time + endTime: + type: string + format: date-time + deletedAt: + type: string + format: date-time + truncatedAt: + type: string + format: date-time + shards: + $ref: '#/components/schemas/ShardManifests' + required: + - id + - startTime + - endTime + - shards + ShardManifests: + type: array + items: + $ref: '#/components/schemas/ShardManifest' + ShardManifest: + type: object + properties: + id: + type: integer + format: int64 + shardOwners: + $ref: '#/components/schemas/ShardOwners' + required: + - id + - shardOwners + ShardOwners: + type: array + items: + $ref: '#/components/schemas/ShardOwner' + ShardOwner: + type: object + properties: + nodeID: + type: integer + format: int64 + description: The ID of the node that owns the shard. + required: + - nodeID + SubscriptionManifests: + type: array + items: + $ref: '#/components/schemas/SubscriptionManifest' + SubscriptionManifest: + type: object + properties: + name: + type: string + mode: + type: string + destinations: + type: array + items: + type: string + required: + - name + - mode + - destinations + RestoredBucketMappings: + type: object + properties: + id: + description: New ID of the restored bucket + type: string + name: + type: string + shardMappings: + $ref: '#/components/schemas/BucketShardMappings' + required: + - id + - name + - shardMappings + BucketShardMappings: + type: array + items: + $ref: '#/components/schemas/BucketShardMapping' + BucketShardMapping: + type: object + properties: + oldId: + type: integer + format: int64 + newId: + type: integer + format: int64 + required: + - oldId + - newId + Config: + type: object + properties: + config: + type: object + RemoteConnection: + type: object + properties: + id: + type: string + name: + type: string + orgID: + type: string + description: + type: string + remoteURL: + type: string + format: uri + remoteOrgID: + type: string + allowInsecureTLS: + type: boolean + default: false + required: + - id + - name + - orgID + - remoteURL + - remoteOrgID + - allowInsecureTLS + RemoteConnections: + type: object + properties: + remotes: + type: array + items: + $ref: '#/components/schemas/RemoteConnection' + RemoteConnectionCreationRequest: + type: object + properties: + name: + type: string + description: + type: string + orgID: + type: string + remoteURL: + type: string + format: uri + remoteAPIToken: + type: string + remoteOrgID: + type: string + allowInsecureTLS: + type: boolean + default: false + required: + - name + - orgID + - remoteURL + - remoteAPIToken + - remoteOrgID + - allowInsecureTLS + RemoteConnectionUpdateRequest: + type: object + properties: + name: + type: string + description: + type: string + remoteURL: + type: string + format: uri + remoteAPIToken: + type: string + remoteOrgID: + type: string + allowInsecureTLS: + type: boolean + default: false + Replication: + type: object + properties: + id: + type: string + name: + type: string + description: + type: string + orgID: + type: string + remoteID: + type: string + localBucketID: + type: string + remoteBucketID: + type: string + remoteBucketName: + type: string + maxQueueSizeBytes: + type: integer + format: int64 + currentQueueSizeBytes: + type: integer + format: int64 + latestResponseCode: + type: integer + latestErrorMessage: + type: string + dropNonRetryableData: + type: boolean + required: + - id + - name + - remoteID + - orgID + - localBucketID + - maxQueueSizeBytes + - currentQueueSizeBytes + Replications: + type: object + properties: + replications: + type: array + items: + $ref: '#/components/schemas/Replication' + ReplicationCreationRequest: + type: object + properties: + name: + type: string + description: + type: string + orgID: + type: string + remoteID: + type: string + localBucketID: + type: string + remoteBucketID: + type: string + remoteBucketName: + type: string + maxQueueSizeBytes: + type: integer + format: int64 + minimum: 33554430 + default: 67108860 + dropNonRetryableData: + type: boolean + default: false + maxAgeSeconds: + type: integer + format: int64 + minimum: 0 + default: 604800 + required: + - name + - orgID + - remoteID + - localBucketID + - maxQueueSizeBytes + - maxAgeSeconds + ReplicationUpdateRequest: + type: object + properties: + name: + type: string + description: + type: string + remoteID: + type: string + remoteBucketID: + type: string + remoteBucketName: + type: string + maxQueueSizeBytes: + type: integer + format: int64 + minimum: 33554430 + dropNonRetryableData: + type: boolean + maxAgeSeconds: + type: integer + format: int64 + minimum: 0 + Tasks: + type: object + properties: + links: + readOnly: true + $ref: '#/components/schemas/Links' + tasks: + type: array + items: + $ref: '#/components/schemas/Task' + Task: + type: object + properties: + id: + readOnly: true + type: string + orgID: + description: The ID of the organization that owns the task. + type: string + org: + description: The name of the organization that owns the task. + type: string + name: + description: The name of the task. + type: string + ownerID: + description: The ID of the user who owns the Task. + type: string + description: + description: The description of the task. + type: string + status: + $ref: '#/components/schemas/TaskStatusType' + labels: + $ref: '#/components/schemas/Labels' + authorizationID: + description: The ID of the authorization used when the task communicates with the query engine. + type: string + flux: + description: The Flux script that the task runs. + type: string + every: + description: 'An interval ([duration literal](https://docs.influxdata.com/flux/v0.x/spec/lexical-elements/#duration-literals))) at which the task runs. `every` also determines when the task first runs, depending on the specified time.' + type: string + format: duration + cron: + description: '[Cron expression](https://en.wikipedia.org/wiki/Cron#Overview) that defines the schedule on which the task runs. InfluxDB bases cron runs on the system time.' + type: string + offset: + description: 'A [duration](https://docs.influxdata.com/flux/v0.x/spec/lexical-elements/#duration-literals) to delay execution of the task after the scheduled time has elapsed. `0` removes the offset.' + type: string + format: duration + latestCompleted: + description: 'A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/flux/v0.x/data-types/basic/time/#time-syntax)) of the latest scheduled and completed run.' + type: string + format: date-time + readOnly: true + lastRunStatus: + readOnly: true + type: string + enum: + - failed + - success + - canceled + lastRunError: + readOnly: true + type: string + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true + links: + type: object + readOnly: true + example: + self: /api/v2/tasks/1 + owners: /api/v2/tasks/1/owners + members: /api/v2/tasks/1/members + labels: /api/v2/tasks/1/labels + runs: /api/v2/tasks/1/runs + logs: /api/v2/tasks/1/logs + properties: + self: + $ref: '#/components/schemas/Link' + owners: + $ref: '#/components/schemas/Link' + members: + $ref: '#/components/schemas/Link' + runs: + $ref: '#/components/schemas/Link' + logs: + $ref: '#/components/schemas/Link' + labels: + $ref: '#/components/schemas/Link' + required: + - id + - name + - orgID + - flux + TaskCreateRequest: + type: object + properties: + orgID: + description: The ID of the organization that owns this Task. + type: string + org: + description: The name of the organization that owns this Task. + type: string + status: + $ref: '#/components/schemas/TaskStatusType' + flux: + description: The Flux script to run for this task. + type: string + description: + description: An optional description of the task. + type: string + required: + - flux + TaskUpdateRequest: + type: object + properties: + status: + $ref: '#/components/schemas/TaskStatusType' + flux: + description: The Flux script that the task runs. + type: string + name: + description: Update the 'name' option in the flux script. + type: string + every: + description: Update the 'every' option in the flux script. + type: string + cron: + description: Update the 'cron' option in the flux script. + type: string + offset: + description: Update the 'offset' option in the flux script. + type: string + description: + description: Update the description of the task. + type: string + responses: + AuthorizationError: + description: | + Unauthorized. The error may indicate one of the following: + + * The `Authorization: Token` header is missing or malformed. + * The API token value is missing from the header. + * The token doesn't have sufficient permissions to write to this organization and bucket. + content: + application/json: + schema: + properties: + code: + description: | + The HTTP status code description. Default is `unauthorized`. + readOnly: true + type: string + enum: + - unauthorized + message: + readOnly: true + description: A human-readable message that may contain detail about the error. + type: string + examples: + tokenNotAuthorized: + summary: Token is not authorized to access a resource + value: + code: unauthorized + message: unauthorized access + BadRequestError: + description: | + Bad request. + The response body contains detail about the error. + + #### InfluxDB OSS + + - Returns this error if an incorrect value is passed for `org` or `orgID`. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + orgProvidedNotFound: + summary: The org or orgID passed doesn't own the token passed in the header + value: + code: invalid + message: 'failed to decode request body: organization not found' + GeneralServerError: + description: Non 2XX error response from server. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + InternalServerError: + description: | + Internal server error. + The server encountered an unexpected situation. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + ResourceNotFoundError: + description: | + Not found. + A requested resource was not found. + The response body contains the requested resource type and the name value + (if you passed it)--for example: + + - `"organization name \"my-org\" not found"` + - `"organization not found"`: indicates you passed an ID that did not match + an organization. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + org-not-found: + summary: Organization name not found + value: + code: not found + message: organization name "my-org" not found + bucket-not-found: + summary: Bucket name not found + value: + code: not found + message: bucket "air_sensor" not found + orgID-not-found: + summary: Organization ID not found + value: + code: not found + message: organization not found + securitySchemes: + TokenAuthentication: + type: apiKey + name: Authorization + in: header + description: | + Use the [Token authentication](#section/Authentication/TokenAuthentication) + scheme to authenticate to the InfluxDB API. + + + In your API requests, send an `Authorization` header. + For the header value, provide the word `Token` followed by a space and an InfluxDB API token. + The word `Token` is case-sensitive. + + + ### Syntax + + `Authorization: Token YOUR_INFLUX_API_TOKEN` + + + For more information and examples, see the following: + - [`/authorizations`](#tag/Authorizations) endpoint. + - [Authorize API requests](https://docs.influxdata.com/influxdb/v2.3/api-guide/api_intro/#authentication). + - [Manage API tokens](https://docs.influxdata.com/influxdb/v2.3/security/tokens/). + BasicAuthentication: + type: http + scheme: basic + description: | + Use the HTTP Basic authentication scheme for InfluxDB `/api/v2` API operations that support it. + + Username and password schemes require the following credentials: + - **username** + - **password** +security: + - TokenAuthentication: [] diff --git a/influxclient/model/templates/client-with-responses.tmpl b/influxclient/model/templates/client-with-responses.tmpl new file mode 100644 index 00000000..50929d7c --- /dev/null +++ b/influxclient/model/templates/client-with-responses.tmpl @@ -0,0 +1,192 @@ +{{/* Generate client methods */}} +{{range .}} +{{if (hasValidRequestAndResponse .) -}}{{/* skip non-JSON bodies*/}} +{{$hasParams := .RequiresParamObject -}} +{{$pathParams := .PathParams -}} +{{$opid := .OperationId -}} +{{$hasResponse := hasSingle2xxJSONResponse . -}} +{{$lenServers := 0 -}} +{{if .Spec.Servers}} +{{$lenServers = len .Spec.Servers -}} +{{end}} +{{$response2xx := get2xxResponseTypeDefinition . -}} +{{$hasBodyOrPathParams := or .HasBody (gt (len .PathParams) 0) -}} +{{$pathStr := genParamFmtString .Path -}} + +// {{$opid}} calls the {{.Method}} on {{.Path}} +// {{.Summary}} +func (c *Client) {{$opid}}(ctx context.Context, {{if $hasBodyOrPathParams}}params *{{$opid}}AllParams{{else}}{{if $hasParams}} params *{{$opid}}Params{{end}}{{end}}) ({{if $hasResponse}}*{{$response2xx.Schema.TypeDecl}},{{end}} error) { + var err error +{{if .HasBody -}} + var bodyReader io.Reader + buf, err := json.Marshal(params.Body) + if err != nil { + return {{if $hasResponse}}nil, {{end}}err + } + bodyReader = bytes.NewReader(buf) +{{end}} +{{range $paramIdx, $param := .PathParams}} + var pathParam{{$paramIdx}} string + {{if .IsPassThrough}} + pathParam{{$paramIdx}} = params.{{.GoVariableName|ucFirst}} + {{end}} + {{if .IsJson}} + var pathParamBuf{{$paramIdx}} []byte + pathParamBuf{{$paramIdx}}, err = json.Marshal(params.{{.GoVariableName|ucFirst}}) + if err != nil { + return {{if $hasResponse}}nil, {{end}}err + } + pathParam{{$paramIdx}} = string(pathParamBuf{{$paramIdx}}) + {{end}} + {{if .IsStyled}} + pathParam{{$paramIdx}}, err = runtime.StyleParamWithLocation("{{.Style}}", {{.Explode}}, "{{.ParamName}}", runtime.ParamLocationPath, params.{{.GoVariableName|ucFirst}}) + if err != nil { + return {{if $hasResponse}}nil, {{end}}err + } + {{end}} +{{end}} + serverURL, err := url.Parse(c.{{if eq $lenServers 0}}APIEndpoint{{else}}Server{{end}}) + if err != nil { + return {{if $hasResponse}}nil, {{end}}err + } + + operationPath := fmt.Sprintf("{{if eq (index $pathStr 0) '/'}}.{{end}}{{$pathStr}}"{{range $paramIdx, $param := .PathParams}}, pathParam{{$paramIdx}}{{end}}) + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return {{if $hasResponse}}nil, {{end}}err + } + +{{if .QueryParams}} + queryValues := queryURL.Query() +{{range $paramIdx, $param := .QueryParams}} + {{if not .Required}} if params.{{.GoName}} != nil { {{end}} + {{if .IsPassThrough}} + queryValues.Add("{{.ParamName}}", {{if not .Required}}*{{end}}params.{{.GoName}}) + {{end}} + {{if .IsJson}} + if queryParamBuf, err := json.Marshal({{if not .Required}}*{{end}}params.{{.GoName}}); err != nil { + return {{if $hasResponse}}nil, {{end}}err + } else { + queryValues.Add("{{.ParamName}}", string(queryParamBuf)) + } + + {{end}} + {{if .IsStyled}} + if queryFrag, err := runtime.StyleParamWithLocation("{{.Style}}", {{.Explode}}, "{{.ParamName}}", runtime.ParamLocationQuery, {{if not .Required}}*{{end}}params.{{.GoName}}); err != nil { + return {{if $hasResponse}}nil, {{end}}err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return {{if $hasResponse}}nil, {{end}}err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + {{end}} + {{if not .Required}}}{{end}} +{{end}} + queryURL.RawQuery = queryValues.Encode() +{{end}}{{/* if .QueryParams */}} + req, err := http.NewRequest("{{.Method}}", queryURL.String(), {{if .HasBody}}bodyReader{{else}}nil{{end}}) + if err != nil { + return {{if $hasResponse}}nil, {{end}}err + } + + {{if .HasBody}}req.Header.Add("Content-Type", "{{(index .Bodies 0).ContentType}}"){{end}} +{{range $paramIdx, $param := .HeaderParams}} + {{if not .Required}} if params.{{.GoName}} != nil { {{end}} + var headerParam{{$paramIdx}} string + {{if .IsPassThrough}} + headerParam{{$paramIdx}} = {{if not .Required}}*{{end}}params.{{.GoName}} + {{end}} + {{if .IsJson}} + var headerParamBuf{{$paramIdx}} []byte + headerParamBuf{{$paramIdx}}, err = json.Marshal({{if not .Required}}*{{end}}params.{{.GoName}}) + if err != nil { + return {{if $hasResponse}}nil, {{end}}err + } + headerParam{{$paramIdx}} = string(headerParamBuf{{$paramIdx}}) + {{end}} + {{if .IsStyled}} + headerParam{{$paramIdx}}, err = runtime.StyleParamWithLocation("{{.Style}}", {{.Explode}}, "{{.ParamName}}", runtime.ParamLocationHeader, {{if not .Required}}*{{end}}params.{{.GoName}}) + if err != nil { + return {{if $hasResponse}}nil, {{end}}err + } + {{end}} + req.Header.Set("{{.ParamName}}", headerParam{{$paramIdx}}) + {{if not .Required}}}{{end}} +{{end}} + +{{range $paramIdx, $param := .CookieParams}} + {{if not .Required}} if params.{{.GoName}} != nil { {{end}} + var cookieParam{{$paramIdx}} string + {{if .IsPassThrough}} + cookieParam{{$paramIdx}} = {{if not .Required}}*{{end}}params.{{.GoName}} + {{end}} + {{if .IsJson}} + var cookieParamBuf{{$paramIdx}} []byte + cookieParamBuf{{$paramIdx}}, err = json.Marshal({{if not .Required}}*{{end}}params.{{.GoName}}) + if err != nil { + return {{if $hasResponse}}nil, {{end}}err + } + cookieParam{{$paramIdx}} = url.QueryEscape(string(cookieParamBuf{{$paramIdx}})) + {{end}} + {{if .IsStyled}} + cookieParam{{$paramIdx}}, err = runtime.StyleParamWithLocation("simple", {{.Explode}}, "{{.ParamName}}", runtime.ParamLocationCookie, {{if not .Required}}*{{end}}params.{{.GoName}}) + if err != nil { + return {{if $hasResponse}}nil, {{end}}err + } + {{end}} + cookie{{$paramIdx}} := &http.Cookie{ + Name:"{{.ParamName}}", + Value:cookieParam{{$paramIdx}}, + } + req.AddCookie(cookie{{$paramIdx}}) + {{if not .Required}}}{{end}} +{{end}} + + req = req.WithContext(ctx) + rsp, err := c.Client.Do(req) + if err != nil { + return {{if $hasResponse}}nil, {{end}}err + } +{{if $hasResponse -}} + bodyBytes, err := ioutil.ReadAll(rsp.Body) +{{end}} + defer func() { _ = rsp.Body.Close() }() +{{if $hasResponse -}} + if err != nil { + return nil, err + } + + response := &{{$response2xx.Schema.TypeDecl}}{} + + switch(rsp.StatusCode) { + case {{$response2xx.ResponseName}}: + if err := unmarshalJSONResponse(bodyBytes, &response); err != nil { + return nil, err + } + default: + return nil, decodeError(bodyBytes, rsp) + } + return response, nil +{{else}} + if rsp.StatusCode > 299 { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + if err != nil { + return err + } + return decodeError(bodyBytes, rsp) + } + return nil +{{end}} +} + +{{end}}{{/* if */}} +{{end}}{{/* Range */}} + +/* + +*/ \ No newline at end of file diff --git a/influxclient/model/templates/client.tmpl b/influxclient/model/templates/client.tmpl new file mode 100755 index 00000000..523d3e32 --- /dev/null +++ b/influxclient/model/templates/client.tmpl @@ -0,0 +1,89 @@ + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HTTPRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// Client which conforms to the OpenAPI3 specification for this service. +type Client struct { + // The endpoint of the server conforming to this interface, with scheme, + // https://api.deepmap.com for example. This can contain a path relative + // to the server, such as https://api.deepmap.com/dev-test, and all the + // paths in the swagger spec will be appended to the server. + Server string + + // Server + /api/v2/ + APIEndpoint string + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HTTPRequestDoer +} + + +// Creates a new Client, with reasonable defaults +func NewClient(server string, doer HTTPRequestDoer) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + Client: doer, + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // API endpoint + client.APIEndpoint = client.Server + "api/v2/" + + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +func(e *Error) Error() error { + return fmt.Errorf("%s: %s", string(e.Code), *e.Message) +} + +func unmarshalJSONResponse(bodyBytes []byte, obj interface{}) error { + if err := json.Unmarshal(bodyBytes, obj); err != nil { + return err + } + return nil +} + +func isJSON(rsp *http.Response) bool { + ctype, _, _ := mime.ParseMediaType(rsp.Header.Get("Content-Type")) + return ctype == "application/json" +} + +func decodeError(body []byte, rsp *http.Response) error { + if isJSON(rsp) { + var serverError struct { + Error + V1Error *string `json:"error,omitempty"` + } + err := json.Unmarshal(body, &serverError) + if err != nil { + message := fmt.Sprintf("cannot decode error response: %v", err) + serverError.Message = &message + } + if serverError.V1Error != nil { + serverError.Message = serverError.V1Error + serverError.Code = ErrorCodeInvalid + } + if serverError.Message == nil && serverError.Code == "" { + serverError.Message = &rsp.Status + } + return serverError.Error.Error() + } else { + message := rsp.Status + if len(body) > 0 { + message = message + ": " + string(body) + } + return errors.New(message) + } +} diff --git a/influxclient/model/templates/imports.tmpl b/influxclient/model/templates/imports.tmpl new file mode 100755 index 00000000..f0203c17 --- /dev/null +++ b/influxclient/model/templates/imports.tmpl @@ -0,0 +1,33 @@ +// Package {{.PackageName}} provides primitives to interact with the openapi HTTP API. +// +// Code generated by {{.ModuleName}} version {{.Version}} DO NOT EDIT. +package {{.PackageName}} + +import ( + "bytes" + "compress/gzip" + "context" + "encoding/base64" + "encoding/json" + "encoding/xml" + "fmt" + "gopkg.in/yaml.v3" + "io" + "io/ioutil" + "net/http" + "net/url" + "path" + "strings" + "time" + + "github.com/deepmap/oapi-codegen/pkg/runtime" + openapi_types "github.com/deepmap/oapi-codegen/pkg/types" + ihttp "github.com/influxdata/influxdb-client-go/v2/api/http" + "github.com/getkin/kin-openapi/openapi3" + "github.com/go-chi/chi/v5" + "github.com/labstack/echo/v4" + "github.com/pkg/errors" + {{- range .ExternalImports}} + {{ . }} + {{- end}} +) diff --git a/influxclient/model/templates/param-types.tmpl b/influxclient/model/templates/param-types.tmpl new file mode 100755 index 00000000..534a58a4 --- /dev/null +++ b/influxclient/model/templates/param-types.tmpl @@ -0,0 +1,22 @@ +{{range .}}{{$opid := .OperationId}} +{{if (hasValidRequestAndResponse .) -}}{{/* skip non-JSON bodies*/}} +{{range .TypeDefinitions}} +// {{.TypeName}} defines parameters for {{$opid}}. +type {{.TypeName}} {{if and (opts.AliasTypes) (.CanAlias)}}={{end}} {{.Schema.TypeDecl}} +{{end}} +{{if or .HasBody (gt (len .PathParams) 0) -}} +// {{$opid}}AllParams defines type for all parameters for {{$opid}}. +type {{$opid}}AllParams struct { +{{if .RequiresParamObject -}} + {{$opid}}Params +{{end}} +{{range .PathParams}} +{{.GoVariableName|ucFirst}} {{.TypeDef}} +{{end}} +{{if (and .HasBody (len .Bodies))}} + Body {{$opid}}{{(index .Bodies 0).NameTag}}RequestBody +{{end}} +} +{{end}}{{/* if */}} +{{end}}{{/* if */}} +{{end}}{{/* Range */}} \ No newline at end of file diff --git a/influxclient/model/templates/request-bodies.tmpl b/influxclient/model/templates/request-bodies.tmpl new file mode 100755 index 00000000..8887d252 --- /dev/null +++ b/influxclient/model/templates/request-bodies.tmpl @@ -0,0 +1,10 @@ +{{range .}}{{$opid := .OperationId}} +{{if (hasValidRequestAndResponse .) -}}{{/* skip non-JSON bodies*/}} +{{range .Bodies}} +{{with .TypeDef $opid}} +// {{.TypeName}} defines body for {{$opid}} for application/json ContentType. +type {{.TypeName}} {{if and (opts.AliasTypes) (.CanAlias)}}={{end}} {{.Schema.TypeDecl}} +{{end}} +{{end}} +{{end}} +{{end}} diff --git a/influxclient/model/types.gen.go b/influxclient/model/types.gen.go new file mode 100644 index 00000000..0e344206 --- /dev/null +++ b/influxclient/model/types.gen.go @@ -0,0 +1,8860 @@ +// Package model provides primitives to interact with the openapi HTTP API. +// +// Code generated by version DO NOT EDIT. +package model + +import ( + "encoding/json" + "fmt" + "time" +) + +const ( + BasicAuthenticationScopes = "BasicAuthentication.Scopes" + TokenAuthenticationScopes = "TokenAuthentication.Scopes" +) + +// Defines values for AuthorizationUpdateRequestStatus. +const ( + AuthorizationUpdateRequestStatusActive AuthorizationUpdateRequestStatus = "active" + + AuthorizationUpdateRequestStatusInactive AuthorizationUpdateRequestStatus = "inactive" +) + +// Defines values for AxisBase. +const ( + AxisBaseEmpty AxisBase = "" + + AxisBaseN10 AxisBase = "10" + + AxisBaseN2 AxisBase = "2" +) + +// Defines values for AxisScale. +const ( + AxisScaleLinear AxisScale = "linear" + + AxisScaleLog AxisScale = "log" +) + +// Defines values for BandViewPropertiesHoverDimension. +const ( + BandViewPropertiesHoverDimensionAuto BandViewPropertiesHoverDimension = "auto" + + BandViewPropertiesHoverDimensionX BandViewPropertiesHoverDimension = "x" + + BandViewPropertiesHoverDimensionXy BandViewPropertiesHoverDimension = "xy" + + BandViewPropertiesHoverDimensionY BandViewPropertiesHoverDimension = "y" +) + +// Defines values for BandViewPropertiesShape. +const ( + BandViewPropertiesShapeChronografV2 BandViewPropertiesShape = "chronograf-v2" +) + +// Defines values for BandViewPropertiesType. +const ( + BandViewPropertiesTypeBand BandViewPropertiesType = "band" +) + +// Defines values for BucketType. +const ( + BucketTypeSystem BucketType = "system" + + BucketTypeUser BucketType = "user" +) + +// Defines values for BuilderAggregateFunctionType. +const ( + BuilderAggregateFunctionTypeFilter BuilderAggregateFunctionType = "filter" + + 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" +) + +// Defines values for CheckViewPropertiesType. +const ( + CheckViewPropertiesTypeCheck CheckViewPropertiesType = "check" +) + +// Defines values for ConstantVariablePropertiesType. +const ( + ConstantVariablePropertiesTypeConstant ConstantVariablePropertiesType = "constant" +) + +// Defines values for CustomCheckType. +const ( + CustomCheckTypeCustom CustomCheckType = "custom" +) + +// Defines values for DashboardColorType. +const ( + DashboardColorTypeBackground DashboardColorType = "background" + + DashboardColorTypeMax DashboardColorType = "max" + + DashboardColorTypeMin DashboardColorType = "min" + + DashboardColorTypeScale DashboardColorType = "scale" + + DashboardColorTypeText DashboardColorType = "text" + + DashboardColorTypeThreshold DashboardColorType = "threshold" +) + +// Defines values for DeadmanCheckType. +const ( + DeadmanCheckTypeDeadman DeadmanCheckType = "deadman" +) + +// Defines values for DialectAnnotations. +const ( + DialectAnnotationsDatatype DialectAnnotations = "datatype" + + DialectAnnotationsDefault DialectAnnotations = "default" + + DialectAnnotationsGroup DialectAnnotations = "group" +) + +// Defines values for DialectDateTimeFormat. +const ( + DialectDateTimeFormatRFC3339 DialectDateTimeFormat = "RFC3339" + + DialectDateTimeFormatRFC3339Nano DialectDateTimeFormat = "RFC3339Nano" +) + +// Defines values for ErrorCode. +const ( + ErrorCodeConflict ErrorCode = "conflict" + + ErrorCodeEmptyValue ErrorCode = "empty value" + + ErrorCodeForbidden ErrorCode = "forbidden" + + ErrorCodeInternalError ErrorCode = "internal error" + + ErrorCodeInvalid ErrorCode = "invalid" + + ErrorCodeMethodNotAllowed ErrorCode = "method not allowed" + + ErrorCodeNotFound ErrorCode = "not found" + + ErrorCodeRequestTooLarge ErrorCode = "request too large" + + ErrorCodeTooManyRequests ErrorCode = "too many requests" + + ErrorCodeUnauthorized ErrorCode = "unauthorized" + + ErrorCodeUnavailable ErrorCode = "unavailable" + + ErrorCodeUnprocessableEntity ErrorCode = "unprocessable entity" + + ErrorCodeUnsupportedMediaType ErrorCode = "unsupported media type" +) + +// Defines values for FieldType. +const ( + FieldTypeField FieldType = "field" + + FieldTypeFunc FieldType = "func" + + FieldTypeInteger FieldType = "integer" + + FieldTypeNumber FieldType = "number" + + FieldTypeRegex FieldType = "regex" + + FieldTypeWildcard FieldType = "wildcard" +) + +// Defines values for GaugeViewPropertiesShape. +const ( + GaugeViewPropertiesShapeChronografV2 GaugeViewPropertiesShape = "chronograf-v2" +) + +// Defines values for GaugeViewPropertiesType. +const ( + GaugeViewPropertiesTypeGauge GaugeViewPropertiesType = "gauge" +) + +// Defines values for GeoViewLayerPropertiesType. +const ( + GeoViewLayerPropertiesTypeCircleMap GeoViewLayerPropertiesType = "circleMap" + + GeoViewLayerPropertiesTypeHeatmap GeoViewLayerPropertiesType = "heatmap" + + GeoViewLayerPropertiesTypePointMap GeoViewLayerPropertiesType = "pointMap" + + GeoViewLayerPropertiesTypeTrackMap GeoViewLayerPropertiesType = "trackMap" +) + +// Defines values for GeoViewPropertiesShape. +const ( + GeoViewPropertiesShapeChronografV2 GeoViewPropertiesShape = "chronograf-v2" +) + +// Defines values for GeoViewPropertiesType. +const ( + GeoViewPropertiesTypeGeo GeoViewPropertiesType = "geo" +) + +// Defines values for GreaterThresholdType. +const ( + GreaterThresholdTypeGreater GreaterThresholdType = "greater" +) + +// Defines values for HTTPNotificationEndpointAuthMethod. +const ( + HTTPNotificationEndpointAuthMethodBasic HTTPNotificationEndpointAuthMethod = "basic" + + HTTPNotificationEndpointAuthMethodBearer HTTPNotificationEndpointAuthMethod = "bearer" + + HTTPNotificationEndpointAuthMethodNone HTTPNotificationEndpointAuthMethod = "none" +) + +// Defines values for HTTPNotificationEndpointMethod. +const ( + HTTPNotificationEndpointMethodGET HTTPNotificationEndpointMethod = "GET" + + HTTPNotificationEndpointMethodPOST HTTPNotificationEndpointMethod = "POST" + + HTTPNotificationEndpointMethodPUT HTTPNotificationEndpointMethod = "PUT" +) + +// Defines values for HTTPNotificationRuleBaseType. +const ( + HTTPNotificationRuleBaseTypeHttp HTTPNotificationRuleBaseType = "http" +) + +// Defines values for HealthCheckStatus. +const ( + HealthCheckStatusFail HealthCheckStatus = "fail" + + HealthCheckStatusPass HealthCheckStatus = "pass" +) + +// Defines values for HeatmapViewPropertiesShape. +const ( + HeatmapViewPropertiesShapeChronografV2 HeatmapViewPropertiesShape = "chronograf-v2" +) + +// Defines values for HeatmapViewPropertiesType. +const ( + HeatmapViewPropertiesTypeHeatmap HeatmapViewPropertiesType = "heatmap" +) + +// Defines values for HistogramViewPropertiesPosition. +const ( + HistogramViewPropertiesPositionOverlaid HistogramViewPropertiesPosition = "overlaid" + + HistogramViewPropertiesPositionStacked HistogramViewPropertiesPosition = "stacked" +) + +// Defines values for HistogramViewPropertiesShape. +const ( + HistogramViewPropertiesShapeChronografV2 HistogramViewPropertiesShape = "chronograf-v2" +) + +// Defines values for HistogramViewPropertiesType. +const ( + HistogramViewPropertiesTypeHistogram HistogramViewPropertiesType = "histogram" +) + +// Defines values for LesserThresholdType. +const ( + LesserThresholdTypeLesser LesserThresholdType = "lesser" +) + +// Defines values for LinePlusSingleStatPropertiesHoverDimension. +const ( + LinePlusSingleStatPropertiesHoverDimensionAuto LinePlusSingleStatPropertiesHoverDimension = "auto" + + LinePlusSingleStatPropertiesHoverDimensionX LinePlusSingleStatPropertiesHoverDimension = "x" + + LinePlusSingleStatPropertiesHoverDimensionXy LinePlusSingleStatPropertiesHoverDimension = "xy" + + LinePlusSingleStatPropertiesHoverDimensionY LinePlusSingleStatPropertiesHoverDimension = "y" +) + +// Defines values for LinePlusSingleStatPropertiesPosition. +const ( + LinePlusSingleStatPropertiesPositionOverlaid LinePlusSingleStatPropertiesPosition = "overlaid" + + LinePlusSingleStatPropertiesPositionStacked LinePlusSingleStatPropertiesPosition = "stacked" +) + +// Defines values for LinePlusSingleStatPropertiesShape. +const ( + LinePlusSingleStatPropertiesShapeChronografV2 LinePlusSingleStatPropertiesShape = "chronograf-v2" +) + +// Defines values for LinePlusSingleStatPropertiesType. +const ( + LinePlusSingleStatPropertiesTypeLinePlusSingleStat LinePlusSingleStatPropertiesType = "line-plus-single-stat" +) + +// Defines values for LineProtocolErrorCode. +const ( + LineProtocolErrorCodeConflict LineProtocolErrorCode = "conflict" + + LineProtocolErrorCodeEmptyValue LineProtocolErrorCode = "empty value" + + LineProtocolErrorCodeInternalError LineProtocolErrorCode = "internal error" + + LineProtocolErrorCodeInvalid LineProtocolErrorCode = "invalid" + + LineProtocolErrorCodeNotFound LineProtocolErrorCode = "not found" + + LineProtocolErrorCodeUnavailable LineProtocolErrorCode = "unavailable" +) + +// Defines values for LineProtocolLengthErrorCode. +const ( + LineProtocolLengthErrorCodeInvalid LineProtocolLengthErrorCode = "invalid" +) + +// Defines values for MapVariablePropertiesType. +const ( + MapVariablePropertiesTypeMap MapVariablePropertiesType = "map" +) + +// Defines values for MarkdownViewPropertiesShape. +const ( + MarkdownViewPropertiesShapeChronografV2 MarkdownViewPropertiesShape = "chronograf-v2" +) + +// Defines values for MarkdownViewPropertiesType. +const ( + MarkdownViewPropertiesTypeMarkdown MarkdownViewPropertiesType = "markdown" +) + +// Defines values for MosaicViewPropertiesHoverDimension. +const ( + MosaicViewPropertiesHoverDimensionAuto MosaicViewPropertiesHoverDimension = "auto" + + MosaicViewPropertiesHoverDimensionX MosaicViewPropertiesHoverDimension = "x" + + MosaicViewPropertiesHoverDimensionXy MosaicViewPropertiesHoverDimension = "xy" + + MosaicViewPropertiesHoverDimensionY MosaicViewPropertiesHoverDimension = "y" +) + +// Defines values for MosaicViewPropertiesShape. +const ( + MosaicViewPropertiesShapeChronografV2 MosaicViewPropertiesShape = "chronograf-v2" +) + +// Defines values for MosaicViewPropertiesType. +const ( + MosaicViewPropertiesTypeMosaic MosaicViewPropertiesType = "mosaic" +) + +// Defines values for NotificationEndpointBaseStatus. +const ( + NotificationEndpointBaseStatusActive NotificationEndpointBaseStatus = "active" + + NotificationEndpointBaseStatusInactive NotificationEndpointBaseStatus = "inactive" +) + +// Defines values for NotificationEndpointType. +const ( + NotificationEndpointTypeHttp NotificationEndpointType = "http" + + NotificationEndpointTypePagerduty NotificationEndpointType = "pagerduty" + + NotificationEndpointTypeSlack NotificationEndpointType = "slack" + + NotificationEndpointTypeTelegram NotificationEndpointType = "telegram" +) + +// Defines values for NotificationEndpointUpdateStatus. +const ( + NotificationEndpointUpdateStatusActive NotificationEndpointUpdateStatus = "active" + + NotificationEndpointUpdateStatusInactive NotificationEndpointUpdateStatus = "inactive" +) + +// Defines values for NotificationRuleBaseLastRunStatus. +const ( + NotificationRuleBaseLastRunStatusCanceled NotificationRuleBaseLastRunStatus = "canceled" + + NotificationRuleBaseLastRunStatusFailed NotificationRuleBaseLastRunStatus = "failed" + + NotificationRuleBaseLastRunStatusSuccess NotificationRuleBaseLastRunStatus = "success" +) + +// Defines values for NotificationRuleUpdateStatus. +const ( + NotificationRuleUpdateStatusActive NotificationRuleUpdateStatus = "active" + + NotificationRuleUpdateStatusInactive NotificationRuleUpdateStatus = "inactive" +) + +// Defines values for OrganizationStatus. +const ( + OrganizationStatusActive OrganizationStatus = "active" + + OrganizationStatusInactive OrganizationStatus = "inactive" +) + +// Defines values for PagerDutyNotificationRuleBaseType. +const ( + PagerDutyNotificationRuleBaseTypePagerduty PagerDutyNotificationRuleBaseType = "pagerduty" +) + +// Defines values for PatchRetentionRuleType. +const ( + PatchRetentionRuleTypeExpire PatchRetentionRuleType = "expire" +) + +// Defines values for PermissionAction. +const ( + PermissionActionRead PermissionAction = "read" + + PermissionActionWrite PermissionAction = "write" +) + +// Defines values for QueryType. +const ( + QueryTypeFlux QueryType = "flux" +) + +// Defines values for QueryEditMode. +const ( + QueryEditModeAdvanced QueryEditMode = "advanced" + + QueryEditModeBuilder QueryEditMode = "builder" +) + +// Defines values for QueryVariablePropertiesType. +const ( + QueryVariablePropertiesTypeQuery QueryVariablePropertiesType = "query" +) + +// Defines values for RangeThresholdType. +const ( + RangeThresholdTypeRange RangeThresholdType = "range" +) + +// Defines values for ReadyStatus. +const ( + ReadyStatusReady ReadyStatus = "ready" +) + +// Defines values for ResourceType. +const ( + ResourceTypeAnnotations ResourceType = "annotations" + + ResourceTypeAuthorizations ResourceType = "authorizations" + + ResourceTypeBuckets ResourceType = "buckets" + + ResourceTypeChecks ResourceType = "checks" + + ResourceTypeDashboards ResourceType = "dashboards" + + ResourceTypeDbrp ResourceType = "dbrp" + + ResourceTypeDocuments ResourceType = "documents" + + ResourceTypeInstance ResourceType = "instance" + + ResourceTypeLabels ResourceType = "labels" + + ResourceTypeNotebooks ResourceType = "notebooks" + + ResourceTypeNotificationEndpoints ResourceType = "notificationEndpoints" + + ResourceTypeNotificationRules ResourceType = "notificationRules" + + ResourceTypeOrgs ResourceType = "orgs" + + ResourceTypeRemotes ResourceType = "remotes" + + ResourceTypeReplications ResourceType = "replications" + + ResourceTypeScrapers ResourceType = "scrapers" + + ResourceTypeSecrets ResourceType = "secrets" + + ResourceTypeSources ResourceType = "sources" + + ResourceTypeTasks ResourceType = "tasks" + + ResourceTypeTelegrafs ResourceType = "telegrafs" + + ResourceTypeUsers ResourceType = "users" + + ResourceTypeVariables ResourceType = "variables" + + ResourceTypeViews ResourceType = "views" +) + +// Defines values for ResourceMemberRole. +const ( + ResourceMemberRoleMember ResourceMemberRole = "member" +) + +// Defines values for ResourceOwnerRole. +const ( + ResourceOwnerRoleOwner ResourceOwnerRole = "owner" +) + +// Defines values for RetentionRuleType. +const ( + RetentionRuleTypeExpire RetentionRuleType = "expire" +) + +// Defines values for RuleStatusLevel. +const ( + RuleStatusLevelANY RuleStatusLevel = "ANY" + + RuleStatusLevelCRIT RuleStatusLevel = "CRIT" + + RuleStatusLevelINFO RuleStatusLevel = "INFO" + + RuleStatusLevelOK RuleStatusLevel = "OK" + + RuleStatusLevelUNKNOWN RuleStatusLevel = "UNKNOWN" + + RuleStatusLevelWARN RuleStatusLevel = "WARN" +) + +// Defines values for RunStatus. +const ( + RunStatusCanceled RunStatus = "canceled" + + RunStatusFailed RunStatus = "failed" + + RunStatusScheduled RunStatus = "scheduled" + + RunStatusStarted RunStatus = "started" + + RunStatusSuccess RunStatus = "success" +) + +// Defines values for SMTPNotificationRuleBaseType. +const ( + SMTPNotificationRuleBaseTypeSmtp SMTPNotificationRuleBaseType = "smtp" +) + +// Defines values for ScatterViewPropertiesShape. +const ( + ScatterViewPropertiesShapeChronografV2 ScatterViewPropertiesShape = "chronograf-v2" +) + +// Defines values for ScatterViewPropertiesType. +const ( + ScatterViewPropertiesTypeScatter ScatterViewPropertiesType = "scatter" +) + +// Defines values for SchemaType. +const ( + SchemaTypeExplicit SchemaType = "explicit" + + SchemaTypeImplicit SchemaType = "implicit" +) + +// Defines values for ScraperTargetRequestType. +const ( + ScraperTargetRequestTypePrometheus ScraperTargetRequestType = "prometheus" +) + +// Defines values for SimpleTableViewPropertiesShape. +const ( + SimpleTableViewPropertiesShapeChronografV2 SimpleTableViewPropertiesShape = "chronograf-v2" +) + +// Defines values for SimpleTableViewPropertiesType. +const ( + SimpleTableViewPropertiesTypeSimpleTable SimpleTableViewPropertiesType = "simple-table" +) + +// Defines values for SingleStatViewPropertiesShape. +const ( + SingleStatViewPropertiesShapeChronografV2 SingleStatViewPropertiesShape = "chronograf-v2" +) + +// Defines values for SingleStatViewPropertiesType. +const ( + SingleStatViewPropertiesTypeSingleStat SingleStatViewPropertiesType = "single-stat" +) + +// Defines values for SlackNotificationRuleBaseType. +const ( + SlackNotificationRuleBaseTypeSlack SlackNotificationRuleBaseType = "slack" +) + +// Defines values for SourceLanguages. +const ( + SourceLanguagesFlux SourceLanguages = "flux" + + SourceLanguagesInfluxql SourceLanguages = "influxql" +) + +// Defines values for SourceType. +const ( + SourceTypeSelf SourceType = "self" + + SourceTypeV1 SourceType = "v1" + + SourceTypeV2 SourceType = "v2" +) + +// Defines values for TableViewPropertiesShape. +const ( + TableViewPropertiesShapeChronografV2 TableViewPropertiesShape = "chronograf-v2" +) + +// Defines values for TableViewPropertiesTableOptionsWrapping. +const ( + TableViewPropertiesTableOptionsWrappingSingleLine TableViewPropertiesTableOptionsWrapping = "single-line" + + TableViewPropertiesTableOptionsWrappingTruncate TableViewPropertiesTableOptionsWrapping = "truncate" + + TableViewPropertiesTableOptionsWrappingWrap TableViewPropertiesTableOptionsWrapping = "wrap" +) + +// Defines values for TableViewPropertiesType. +const ( + TableViewPropertiesTypeTable TableViewPropertiesType = "table" +) + +// Defines values for TagRuleOperator. +const ( + TagRuleOperatorEqual TagRuleOperator = "equal" + + TagRuleOperatorEqualregex TagRuleOperator = "equalregex" + + TagRuleOperatorNotequal TagRuleOperator = "notequal" + + TagRuleOperatorNotequalregex TagRuleOperator = "notequalregex" +) + +// Defines values for TaskLastRunStatus. +const ( + TaskLastRunStatusCanceled TaskLastRunStatus = "canceled" + + TaskLastRunStatusFailed TaskLastRunStatus = "failed" + + TaskLastRunStatusSuccess TaskLastRunStatus = "success" +) + +// Defines values for TaskStatusType. +const ( + TaskStatusTypeActive TaskStatusType = "active" + + TaskStatusTypeInactive TaskStatusType = "inactive" +) + +// Defines values for TelegramNotificationRuleBaseParseMode. +const ( + TelegramNotificationRuleBaseParseModeHTML TelegramNotificationRuleBaseParseMode = "HTML" + + TelegramNotificationRuleBaseParseModeMarkdown TelegramNotificationRuleBaseParseMode = "Markdown" + + TelegramNotificationRuleBaseParseModeMarkdownV2 TelegramNotificationRuleBaseParseMode = "MarkdownV2" +) + +// Defines values for TelegramNotificationRuleBaseType. +const ( + TelegramNotificationRuleBaseTypeTelegram TelegramNotificationRuleBaseType = "telegram" +) + +// Defines values for TemplateKind. +const ( + TemplateKindBucket TemplateKind = "Bucket" + + TemplateKindCheck TemplateKind = "Check" + + TemplateKindCheckDeadman TemplateKind = "CheckDeadman" + + TemplateKindCheckThreshold TemplateKind = "CheckThreshold" + + TemplateKindDashboard TemplateKind = "Dashboard" + + TemplateKindLabel TemplateKind = "Label" + + TemplateKindNotificationEndpoint TemplateKind = "NotificationEndpoint" + + TemplateKindNotificationEndpointHTTP TemplateKind = "NotificationEndpointHTTP" + + TemplateKindNotificationEndpointPagerDuty TemplateKind = "NotificationEndpointPagerDuty" + + TemplateKindNotificationEndpointSlack TemplateKind = "NotificationEndpointSlack" + + TemplateKindNotificationRule TemplateKind = "NotificationRule" + + TemplateKindTask TemplateKind = "Task" + + TemplateKindTelegraf TemplateKind = "Telegraf" + + TemplateKindVariable TemplateKind = "Variable" +) + +// Defines values for ThresholdCheckType. +const ( + ThresholdCheckTypeThreshold ThresholdCheckType = "threshold" +) + +// Defines values for UserStatus. +const ( + UserStatusActive UserStatus = "active" + + UserStatusInactive UserStatus = "inactive" +) + +// Defines values for UserResponseStatus. +const ( + UserResponseStatusActive UserResponseStatus = "active" + + UserResponseStatusInactive UserResponseStatus = "inactive" +) + +// Defines values for WritePrecision. +const ( + WritePrecisionMs WritePrecision = "ms" + + WritePrecisionNs WritePrecision = "ns" + + WritePrecisionS WritePrecision = "s" + + WritePrecisionUs WritePrecision = "us" +) + +// Defines values for XYGeom. +const ( + XYGeomBar XYGeom = "bar" + + XYGeomLine XYGeom = "line" + + XYGeomMonotoneX XYGeom = "monotoneX" + + XYGeomStacked XYGeom = "stacked" + + XYGeomStep XYGeom = "step" + + XYGeomStepAfter XYGeom = "stepAfter" + + XYGeomStepBefore XYGeom = "stepBefore" +) + +// Defines values for XYViewPropertiesHoverDimension. +const ( + XYViewPropertiesHoverDimensionAuto XYViewPropertiesHoverDimension = "auto" + + XYViewPropertiesHoverDimensionX XYViewPropertiesHoverDimension = "x" + + XYViewPropertiesHoverDimensionXy XYViewPropertiesHoverDimension = "xy" + + XYViewPropertiesHoverDimensionY XYViewPropertiesHoverDimension = "y" +) + +// Defines values for XYViewPropertiesPosition. +const ( + XYViewPropertiesPositionOverlaid XYViewPropertiesPosition = "overlaid" + + XYViewPropertiesPositionStacked XYViewPropertiesPosition = "stacked" +) + +// Defines values for XYViewPropertiesShape. +const ( + XYViewPropertiesShapeChronografV2 XYViewPropertiesShape = "chronograf-v2" +) + +// Defines values for XYViewPropertiesType. +const ( + XYViewPropertiesTypeXy XYViewPropertiesType = "xy" +) + +// Defines values for AuthorizationErrorCode. +const ( + AuthorizationErrorCodeUnauthorized AuthorizationErrorCode = "unauthorized" +) + +// Contains the AST for the supplied Flux query +type ASTResponse struct { + // Represents a complete package source tree. + Ast *Package `json:"ast,omitempty"` +} + +// AddResourceMemberRequestBody defines model for AddResourceMemberRequestBody. +type AddResourceMemberRequestBody struct { + // The ID of the user to add to the resource. + Id string `json:"id"` + + // The name of the user to add to the resource. + Name *string `json:"name,omitempty"` +} + +// AnalyzeQueryResponse defines model for AnalyzeQueryResponse. +type AnalyzeQueryResponse struct { + Errors *[]struct { + Character *int `json:"character,omitempty"` + Column *int `json:"column,omitempty"` + Line *int `json:"line,omitempty"` + Message *string `json:"message,omitempty"` + } `json:"errors,omitempty"` +} + +// Used to create and directly specify the elements of an array object +type ArrayExpression struct { + // Elements of the array + Elements *[]Expression `json:"elements,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Authorization defines model for Authorization. +type Authorization struct { + // Embedded struct due to allOf(#/components/schemas/AuthorizationUpdateRequest) + AuthorizationUpdateRequest `yaml:",inline"` + // Embedded fields due to inline allOf schema + CreatedAt *time.Time `json:"createdAt,omitempty"` + Id *string `json:"id,omitempty"` + Links *struct { + // URI of resource. + Self *Link `json:"self,omitempty"` + + // URI of resource. + User *Link `json:"user,omitempty"` + } `json:"links,omitempty"` + + // The name of the organization that the token is scoped to. + Org *string `json:"org,omitempty"` + + // The ID of the organization. + OrgID *string `json:"orgID,omitempty"` + + // A list of permissions for an authorization. + // An authorization must have at least one permission. + Permissions *[]Permission `json:"permissions,omitempty"` + + // The API token for authenticating InfluxDB API and CLI requests. + Token *string `json:"token,omitempty"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` + + // The name of the user that created and owns the token. + User *string `json:"user,omitempty"` + + // The ID of the user that created and owns the token. + UserID *string `json:"userID,omitempty"` +} + +// AuthorizationPostRequest defines model for AuthorizationPostRequest. +type AuthorizationPostRequest struct { + // Embedded struct due to allOf(#/components/schemas/AuthorizationUpdateRequest) + AuthorizationUpdateRequest `yaml:",inline"` + // Embedded fields due to inline allOf schema + // The ID of the organization that owns the authorization. + OrgID *string `json:"orgID,omitempty"` + + // A list of permissions for an authorization. + // An authorization must have at least one permission. + Permissions *[]Permission `json:"permissions,omitempty"` + + // The ID of the user that the authorization is scoped to. + UserID *string `json:"userID,omitempty"` +} + +// AuthorizationUpdateRequest defines model for AuthorizationUpdateRequest. +type AuthorizationUpdateRequest struct { + // A description of the token. + Description *string `json:"description,omitempty"` + + // Status of the token. If `inactive`, requests using the token will be rejected. + Status *AuthorizationUpdateRequestStatus `json:"status,omitempty"` +} + +// Status of the token. If `inactive`, requests using the token will be rejected. +type AuthorizationUpdateRequestStatus string + +// Authorizations defines model for Authorizations. +type Authorizations struct { + Authorizations *[]Authorization `json:"authorizations,omitempty"` + + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` +} + +// The viewport for a View's visualizations +type Axes struct { + // Axis used in a visualization. + X Axis `json:"x"` + + // Axis used in a visualization. + Y Axis `json:"y"` +} + +// Axis used in a visualization. +type Axis struct { + // Radix for formatting axis values. + Base *AxisBase `json:"base,omitempty"` + + // The extents of the axis in the form [lower, upper]. Clients determine whether bounds are inclusive or exclusive of their limits. + Bounds *[]string `json:"bounds,omitempty"` + + // Description of the axis. + Label *string `json:"label,omitempty"` + + // Label prefix for formatting axis values. + Prefix *string `json:"prefix,omitempty"` + + // Scale is the axis formatting scale. Supported: "log", "linear" + Scale *AxisScale `json:"scale,omitempty"` + + // Label suffix for formatting axis values. + Suffix *string `json:"suffix,omitempty"` +} + +// Radix for formatting axis values. +type AxisBase string + +// Scale is the axis formatting scale. Supported: "log", "linear" +type AxisScale string + +// A placeholder for statements for which no correct statement nodes can be created +type BadStatement struct { + // Raw source text + Text *string `json:"text,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// BandViewProperties defines model for BandViewProperties. +type BandViewProperties struct { + AdaptiveZoomHide *bool `json:"adaptiveZoomHide,omitempty"` + + // The viewport for a View's visualizations + Axes Axes `json:"axes"` + + // Colors define color encoding of data into a visualization + Colors []DashboardColor `json:"colors"` + GenerateXAxisTicks *[]string `json:"generateXAxisTicks,omitempty"` + GenerateYAxisTicks *[]string `json:"generateYAxisTicks,omitempty"` + Geom XYGeom `json:"geom"` + HoverDimension *BandViewPropertiesHoverDimension `json:"hoverDimension,omitempty"` + LegendColorizeRows *bool `json:"legendColorizeRows,omitempty"` + LegendHide *bool `json:"legendHide,omitempty"` + LegendOpacity *float32 `json:"legendOpacity,omitempty"` + LegendOrientationThreshold *int `json:"legendOrientationThreshold,omitempty"` + LowerColumn *string `json:"lowerColumn,omitempty"` + MainColumn *string `json:"mainColumn,omitempty"` + Note string `json:"note"` + Queries []DashboardQuery `json:"queries"` + Shape BandViewPropertiesShape `json:"shape"` + + // If true, will display note when empty + ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` + + // StaticLegend represents the options specific to the static legend + StaticLegend *StaticLegend `json:"staticLegend,omitempty"` + TimeFormat *string `json:"timeFormat,omitempty"` + Type BandViewPropertiesType `json:"type"` + UpperColumn *string `json:"upperColumn,omitempty"` + XColumn *string `json:"xColumn,omitempty"` + XTickStart *float32 `json:"xTickStart,omitempty"` + XTickStep *float32 `json:"xTickStep,omitempty"` + XTotalTicks *int `json:"xTotalTicks,omitempty"` + YColumn *string `json:"yColumn,omitempty"` + YTickStart *float32 `json:"yTickStart,omitempty"` + YTickStep *float32 `json:"yTickStep,omitempty"` + YTotalTicks *int `json:"yTotalTicks,omitempty"` +} + +// BandViewPropertiesHoverDimension defines model for BandViewProperties.HoverDimension. +type BandViewPropertiesHoverDimension string + +// BandViewPropertiesShape defines model for BandViewProperties.Shape. +type BandViewPropertiesShape string + +// BandViewPropertiesType defines model for BandViewProperties.Type. +type BandViewPropertiesType string + +// uses binary operators to act on two operands in an expression +type BinaryExpression struct { + Left *Expression `json:"left,omitempty"` + Operator *string `json:"operator,omitempty"` + Right *Expression `json:"right,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// A set of statements +type Block struct { + // Block body + Body *[]Statement `json:"body,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Represents boolean values +type BooleanLiteral struct { + // Type of AST node + Type *NodeType `json:"type,omitempty"` + Value *bool `json:"value,omitempty"` +} + +// Bucket defines model for Bucket. +type Bucket struct { + CreatedAt *time.Time `json:"createdAt,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Labels *Labels `json:"labels,omitempty"` + Links *struct { + // URI of resource. + Labels *Link `json:"labels,omitempty"` + + // URI of resource. + Members *Link `json:"members,omitempty"` + + // URI of resource. + Org *Link `json:"org,omitempty"` + + // URI of resource. + Owners *Link `json:"owners,omitempty"` + + // URI of resource. + Self *Link `json:"self,omitempty"` + + // URI of resource. + Write *Link `json:"write,omitempty"` + } `json:"links,omitempty"` + Name string `json:"name"` + OrgID *string `json:"orgID,omitempty"` + + // Retention rules to expire or retain data. + // #### InfluxDB Cloud + // + // - `retentionRules` is required. + // + // #### InfluxDB OSS + // + // - `retentionRules` isn't required. + RetentionRules RetentionRules `json:"retentionRules"` + Rp *string `json:"rp,omitempty"` + SchemaType *SchemaType `json:"schemaType,omitempty"` + Type *BucketType `json:"type,omitempty"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` +} + +// BucketType defines model for Bucket.Type. +type BucketType string + +// BucketMetadataManifest defines model for BucketMetadataManifest. +type BucketMetadataManifest struct { + BucketID string `json:"bucketID"` + BucketName string `json:"bucketName"` + DefaultRetentionPolicy string `json:"defaultRetentionPolicy"` + Description *string `json:"description,omitempty"` + OrganizationID string `json:"organizationID"` + OrganizationName string `json:"organizationName"` + RetentionPolicies RetentionPolicyManifests `json:"retentionPolicies"` +} + +// BucketMetadataManifests defines model for BucketMetadataManifests. +type BucketMetadataManifests []BucketMetadataManifest + +// BucketShardMapping defines model for BucketShardMapping. +type BucketShardMapping struct { + NewId int64 `json:"newId"` + OldId int64 `json:"oldId"` +} + +// BucketShardMappings defines model for BucketShardMappings. +type BucketShardMappings []BucketShardMapping + +// Buckets defines model for Buckets. +type Buckets struct { + Buckets *[]Bucket `json:"buckets,omitempty"` + + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` +} + +// BuilderAggregateFunctionType defines model for BuilderAggregateFunctionType. +type BuilderAggregateFunctionType string + +// BuilderConfig defines model for BuilderConfig. +type BuilderConfig struct { + AggregateWindow *struct { + FillValues *bool `json:"fillValues,omitempty"` + Period *string `json:"period,omitempty"` + } `json:"aggregateWindow,omitempty"` + Buckets *[]string `json:"buckets,omitempty"` + Functions *[]BuilderFunctionsType `json:"functions,omitempty"` + Tags *[]BuilderTagsType `json:"tags,omitempty"` +} + +// BuilderFunctionsType defines model for BuilderFunctionsType. +type BuilderFunctionsType struct { + Name *string `json:"name,omitempty"` +} + +// BuilderTagsType defines model for BuilderTagsType. +type BuilderTagsType struct { + AggregateFunctionType *BuilderAggregateFunctionType `json:"aggregateFunctionType,omitempty"` + Key *string `json:"key,omitempty"` + Values *[]string `json:"values,omitempty"` +} + +// Declares a builtin identifier and its type +type BuiltinStatement struct { + // A valid Flux identifier + Id *Identifier `json:"id,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Represents a function call +type CallExpression struct { + // Function arguments + Arguments *[]Expression `json:"arguments,omitempty"` + Callee *Expression `json:"callee,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Cell defines model for Cell. +type Cell struct { + H *int32 `json:"h,omitempty"` + Id *string `json:"id,omitempty"` + Links *struct { + Self *string `json:"self,omitempty"` + View *string `json:"view,omitempty"` + } `json:"links,omitempty"` + + // The reference to a view from the views API. + ViewID *string `json:"viewID,omitempty"` + W *int32 `json:"w,omitempty"` + X *int32 `json:"x,omitempty"` + Y *int32 `json:"y,omitempty"` +} + +// CellUpdate defines model for CellUpdate. +type CellUpdate struct { + H *int32 `json:"h,omitempty"` + W *int32 `json:"w,omitempty"` + X *int32 `json:"x,omitempty"` + Y *int32 `json:"y,omitempty"` +} + +// CellWithViewProperties defines model for CellWithViewProperties. +type CellWithViewProperties struct { + // Embedded struct due to allOf(#/components/schemas/Cell) + Cell `yaml:",inline"` + // Embedded fields due to inline allOf schema + Name *string `json:"name,omitempty"` + Properties *ViewProperties `json:"properties,omitempty"` +} + +// Cells defines model for Cells. +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"` + Check *Check `json:"check,omitempty"` + CheckID string `json:"checkID"` + + // Colors define color encoding of data into a visualization + Colors []DashboardColor `json:"colors"` + LegendColorizeRows *bool `json:"legendColorizeRows,omitempty"` + LegendHide *bool `json:"legendHide,omitempty"` + LegendOpacity *float32 `json:"legendOpacity,omitempty"` + LegendOrientationThreshold *int `json:"legendOrientationThreshold,omitempty"` + Queries []DashboardQuery `json:"queries"` + Shape CheckViewPropertiesShape `json:"shape"` + Type CheckViewPropertiesType `json:"type"` +} + +// CheckViewPropertiesShape defines model for CheckViewProperties.Shape. +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:"-"` +} + +// Selects one of two expressions, `Alternate` or `Consequent`, depending on a third boolean expression, `Test` +type ConditionalExpression struct { + Alternate *Expression `json:"alternate,omitempty"` + Consequent *Expression `json:"consequent,omitempty"` + Test *Expression `json:"test,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Config defines model for Config. +type Config struct { + Config *map[string]interface{} `json:"config,omitempty"` +} + +// ConstantVariableProperties defines model for ConstantVariableProperties. +type ConstantVariableProperties struct { + Type *ConstantVariablePropertiesType `json:"type,omitempty"` + Values *[]string `json:"values,omitempty"` +} + +// ConstantVariablePropertiesType defines model for ConstantVariableProperties.Type. +type ConstantVariablePropertiesType string + +// CreateCell defines model for CreateCell. +type CreateCell struct { + H *int32 `json:"h,omitempty"` + Name *string `json:"name,omitempty"` + + // Makes a copy of the provided view. + UsingView *string `json:"usingView,omitempty"` + W *int32 `json:"w,omitempty"` + X *int32 `json:"x,omitempty"` + Y *int32 `json:"y,omitempty"` +} + +// CreateDashboardRequest defines model for CreateDashboardRequest. +type CreateDashboardRequest struct { + // The user-facing description of the dashboard. + Description *string `json:"description,omitempty"` + + // The user-facing name of the dashboard. + Name string `json:"name"` + + // The ID of the organization that owns the dashboard. + 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. + BucketID string `json:"bucketID"` + + // InfluxDB v1 database + Database string `json:"database"` + + // Mapping represents the default retention policy for the database specified. + Default bool `json:"default"` + + // The ID of the DBRP mapping. + Id string `json:"id"` + + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` + + // The ID of the organization. + OrgID string `json:"orgID"` + + // InfluxDB v1 retention policy + RetentionPolicy string `json:"retention_policy"` + + // Indicates an autogenerated, virtual mapping based on the bucket name. Currently only available in OSS. + Virtual *bool `json:"virtual,omitempty"` +} + +// DBRPCreate defines model for DBRPCreate. +type DBRPCreate struct { + // The ID of the bucket used as the target for the translation. + BucketID string `json:"bucketID"` + + // InfluxDB v1 database + Database string `json:"database"` + + // Mapping represents the default retention policy for the database specified. + Default *bool `json:"default,omitempty"` + + // The name of the organization that owns this mapping. + Org *string `json:"org,omitempty"` + + // The ID of the organization. + OrgID *string `json:"orgID,omitempty"` + + // InfluxDB v1 retention policy + RetentionPolicy string `json:"retention_policy"` +} + +// DBRPGet defines model for DBRPGet. +type DBRPGet struct { + Content *DBRP `json:"content,omitempty"` +} + +// DBRPUpdate defines model for DBRPUpdate. +type DBRPUpdate struct { + Default *bool `json:"default,omitempty"` + + // InfluxDB v1 retention policy + RetentionPolicy *string `json:"retention_policy,omitempty"` +} + +// DBRPs defines model for DBRPs. +type DBRPs struct { + Content *[]DBRP `json:"content,omitempty"` +} + +// Dashboard defines model for Dashboard. +type Dashboard struct { + // Embedded struct due to allOf(#/components/schemas/CreateDashboardRequest) + CreateDashboardRequest `yaml:",inline"` + // Embedded fields due to inline allOf schema + Cells *Cells `json:"cells,omitempty"` + Id *string `json:"id,omitempty"` + Labels *Labels `json:"labels,omitempty"` + Links *struct { + // URI of resource. + Cells *Link `json:"cells,omitempty"` + + // URI of resource. + Labels *Link `json:"labels,omitempty"` + + // URI of resource. + Members *Link `json:"members,omitempty"` + + // URI of resource. + Org *Link `json:"org,omitempty"` + + // URI of resource. + Owners *Link `json:"owners,omitempty"` + + // URI of resource. + Self *Link `json:"self,omitempty"` + } `json:"links,omitempty"` + Meta *struct { + CreatedAt *time.Time `json:"createdAt,omitempty"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` + } `json:"meta,omitempty"` +} + +// Defines an encoding of data value into color space. +type DashboardColor struct { + // The hex number of the color + Hex string `json:"hex"` + + // The unique ID of the view color. + Id string `json:"id"` + + // The user-facing name of the hex color. + Name string `json:"name"` + + // Type is how the color is used. + Type DashboardColorType `json:"type"` + + // The data value mapped to this color. + Value float32 `json:"value"` +} + +// Type is how the color is used. +type DashboardColorType string + +// DashboardQuery defines model for DashboardQuery. +type DashboardQuery struct { + BuilderConfig *BuilderConfig `json:"builderConfig,omitempty"` + EditMode *QueryEditMode `json:"editMode,omitempty"` + Name *string `json:"name,omitempty"` + + // The text of the Flux query. + Text *string `json:"text,omitempty"` +} + +// DashboardWithViewProperties defines model for DashboardWithViewProperties. +type DashboardWithViewProperties struct { + // Embedded struct due to allOf(#/components/schemas/CreateDashboardRequest) + CreateDashboardRequest `yaml:",inline"` + // Embedded fields due to inline allOf schema + Cells *CellsWithViewProperties `json:"cells,omitempty"` + Id *string `json:"id,omitempty"` + Labels *Labels `json:"labels,omitempty"` + Links *struct { + // URI of resource. + Cells *Link `json:"cells,omitempty"` + + // URI of resource. + Labels *Link `json:"labels,omitempty"` + + // URI of resource. + Members *Link `json:"members,omitempty"` + + // URI of resource. + Org *Link `json:"org,omitempty"` + + // URI of resource. + Owners *Link `json:"owners,omitempty"` + + // URI of resource. + Self *Link `json:"self,omitempty"` + } `json:"links,omitempty"` + Meta *struct { + CreatedAt *time.Time `json:"createdAt,omitempty"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` + } `json:"meta,omitempty"` +} + +// Dashboards defines model for Dashboards. +type Dashboards struct { + Dashboards *[]Dashboard `json:"dashboards,omitempty"` + + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` +} + +// Represents an instant in time with nanosecond precision in [RFC3339Nano date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339nano-timestamp). +type DateTimeLiteral struct { + // Type of AST node + Type *NodeType `json:"type,omitempty"` + 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 + Digits *int32 `json:"digits,omitempty"` + + // Indicates whether decimal point setting should be enforced + IsEnforced *bool `json:"isEnforced,omitempty"` +} + +// The delete predicate request. +type DeletePredicateRequest struct { + // An expression in [delete predicate syntax](https://docs.influxdata.com/influxdb/v2.3/reference/syntax/delete-predicate/). + Predicate *string `json:"predicate,omitempty"` + + // A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp)). + // The earliest time to delete from. + Start time.Time `json:"start"` + + // A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp)). + // The latest time to delete from. + Stop time.Time `json:"stop"` +} + +// Options for tabular data output. +// Default output is [annotated CSV](https://docs.influxdata.com/influxdb/v2.3/reference/syntax/annotated-csv/#csv-response-format) with headers. +// +// For more information about tabular data **dialect**, +// see [W3 metadata vocabulary for tabular data](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#dialect-descriptions). +type Dialect struct { + // Annotation rows to include in the results. + // An _annotation_ is metadata associated with an object (column) in the data model. + // + // #### Related guides + // + // - See [Annotated CSV annotations](https://docs.influxdata.com/influxdb/v2.3/reference/syntax/annotated-csv/#annotations) for examples and more information. + // + // For more information about **annotations** in tabular data, + // see [W3 metadata vocabulary for tabular data](https://www.w3.org/TR/2015/REC-tabular-data-model-20151217/#columns). + Annotations *[]DialectAnnotations `json:"annotations,omitempty"` + + // The character prefixed to comment strings. Default is a number sign (`#`). + CommentPrefix *string `json:"commentPrefix,omitempty"` + + // The format for timestamps in results. + // Default is [`RFC3339` date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp). + // To include nanoseconds in timestamps, use `RFC3339Nano`. + // + // #### Example formatted date/time values + // + // | Format | Value | + // |:------------|:----------------------------| + // | `RFC3339` | `"2006-01-02T15:04:05Z07:00"` | + // | `RFC3339Nano` | `"2006-01-02T15:04:05.999999999Z07:00"` | + DateTimeFormat *DialectDateTimeFormat `json:"dateTimeFormat,omitempty"` + + // The separator used between cells. Default is a comma (`,`). + Delimiter *string `json:"delimiter,omitempty"` + + // If true, the results contain a header row. + Header *bool `json:"header,omitempty"` +} + +// DialectAnnotations defines model for Dialect.Annotations. +type DialectAnnotations string + +// The format for timestamps in results. +// Default is [`RFC3339` date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp). +// To include nanoseconds in timestamps, use `RFC3339Nano`. +// +// #### Example formatted date/time values +// +// | Format | Value | +// |:------------|:----------------------------| +// | `RFC3339` | `"2006-01-02T15:04:05Z07:00"` | +// | `RFC3339Nano` | `"2006-01-02T15:04:05.999999999Z07:00"` | +type DialectDateTimeFormat string + +// Used to create and directly specify the elements of a dictionary +type DictExpression struct { + // Elements of the dictionary + Elements *[]DictItem `json:"elements,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// A key-value pair in a dictionary. +type DictItem struct { + Key *Expression `json:"key,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` + Val *Expression `json:"val,omitempty"` +} + +// A pair consisting of length of time and the unit of time measured. It is the atomic unit from which all duration literals are composed. +type Duration struct { + Magnitude *int `json:"magnitude,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +// Represents the elapsed time between two instants as an int64 nanosecond count with syntax of golang's time.Duration +type DurationLiteral struct { + // Type of AST node + Type *NodeType `json:"type,omitempty"` + + // Duration values + Values *[]Duration `json:"values,omitempty"` +} + +// Error defines model for Error. +type Error struct { + // code is the machine-readable error code. + Code ErrorCode `json:"code"` + + // Stack of errors that occurred during processing of the request. Useful for debugging. + Err *string `json:"err,omitempty"` + + // Human-readable message. + Message *string `json:"message,omitempty"` + + // Describes the logical code operation when the error occurred. Useful for debugging. + Op *string `json:"op,omitempty"` +} + +// code is the machine-readable error code. +type ErrorCode string + +// Expression defines model for Expression. +type Expression interface{} + +// May consist of an expression that doesn't return a value and is executed solely for its side-effects +type ExpressionStatement struct { + Expression *Expression `json:"expression,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Field defines model for Field. +type Field struct { + // Alias overrides the field name in the returned response. Applies only if type is `func` + Alias *string `json:"alias,omitempty"` + + // Args are the arguments to the function + Args *[]Field `json:"args,omitempty"` + + // `type` describes the field type. `func` is a function. `field` is a field reference. + Type *FieldType `json:"type,omitempty"` + + // value is the value of the field. Meaning of the value is implied by the `type` key + Value *string `json:"value,omitempty"` +} + +// `type` describes the field type. `func` is a function. `field` is a field reference. +type FieldType string + +// Represents a source from a single file +type File struct { + // List of Flux statements + Body *[]Statement `json:"body,omitempty"` + + // A list of package imports + Imports *[]ImportDeclaration `json:"imports,omitempty"` + + // The name of the file. + Name *string `json:"name,omitempty"` + + // Defines a package identifier + Package *PackageClause `json:"package,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Flags defines model for Flags. +type Flags struct { + AdditionalProperties map[string]interface{} `json:"-"` +} + +// Represents floating point numbers according to the double representations defined by the IEEE-754-1985 +type FloatLiteral struct { + // Type of AST node + Type *NodeType `json:"type,omitempty"` + Value *float32 `json:"value,omitempty"` +} + +// Rendered flux that backs the check or notification. +type FluxResponse struct { + Flux *string `json:"flux,omitempty"` +} + +// FluxSuggestion defines model for FluxSuggestion. +type FluxSuggestion struct { + Name *string `json:"name,omitempty"` + Params *FluxSuggestion_Params `json:"params,omitempty"` +} + +// FluxSuggestion_Params defines model for FluxSuggestion.Params. +type FluxSuggestion_Params struct { + AdditionalProperties map[string]string `json:"-"` +} + +// FluxSuggestions defines model for FluxSuggestions. +type FluxSuggestions struct { + Funcs *[]FluxSuggestion `json:"funcs,omitempty"` +} + +// Function expression +type FunctionExpression struct { + Body *Node `json:"body,omitempty"` + + // Function parameters + Params *[]Property `json:"params,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// GaugeViewProperties defines model for GaugeViewProperties. +type GaugeViewProperties struct { + // Colors define color encoding of data into a visualization + Colors []DashboardColor `json:"colors"` + + // Indicates whether decimal places should be enforced, and how many digits it should show. + DecimalPlaces DecimalPlaces `json:"decimalPlaces"` + Note string `json:"note"` + Prefix string `json:"prefix"` + Queries []DashboardQuery `json:"queries"` + Shape GaugeViewPropertiesShape `json:"shape"` + + // If true, will display note when empty + ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` + Suffix string `json:"suffix"` + TickPrefix string `json:"tickPrefix"` + TickSuffix string `json:"tickSuffix"` + Type GaugeViewPropertiesType `json:"type"` +} + +// GaugeViewPropertiesShape defines model for GaugeViewProperties.Shape. +type GaugeViewPropertiesShape string + +// GaugeViewPropertiesType defines model for GaugeViewProperties.Type. +type GaugeViewPropertiesType string + +// GeoCircleViewLayer defines model for GeoCircleViewLayer. +type GeoCircleViewLayer struct { + // Embedded struct due to allOf(#/components/schemas/GeoViewLayerProperties) + GeoViewLayerProperties `yaml:",inline"` + // Embedded fields due to inline allOf schema + // Axis used in a visualization. + ColorDimension Axis `json:"colorDimension"` + + // Circle color field + ColorField string `json:"colorField"` + + // Colors define color encoding of data into a visualization + Colors []DashboardColor `json:"colors"` + + // Interpolate circle color based on displayed value + InterpolateColors *bool `json:"interpolateColors,omitempty"` + + // Maximum radius size in pixels + Radius *int `json:"radius,omitempty"` + + // Axis used in a visualization. + RadiusDimension Axis `json:"radiusDimension"` + + // Radius field + RadiusField string `json:"radiusField"` +} + +// GeoHeatMapViewLayer defines model for GeoHeatMapViewLayer. +type GeoHeatMapViewLayer struct { + // Embedded struct due to allOf(#/components/schemas/GeoViewLayerProperties) + GeoViewLayerProperties `yaml:",inline"` + // Embedded fields due to inline allOf schema + // Blur for heatmap points + Blur int `json:"blur"` + + // Colors define color encoding of data into a visualization + Colors []DashboardColor `json:"colors"` + + // Axis used in a visualization. + IntensityDimension Axis `json:"intensityDimension"` + + // Intensity field + IntensityField string `json:"intensityField"` + + // Radius size in pixels + Radius int `json:"radius"` +} + +// GeoPointMapViewLayer defines model for GeoPointMapViewLayer. +type GeoPointMapViewLayer struct { + // Embedded struct due to allOf(#/components/schemas/GeoViewLayerProperties) + GeoViewLayerProperties `yaml:",inline"` + // Embedded fields due to inline allOf schema + // Axis used in a visualization. + ColorDimension Axis `json:"colorDimension"` + + // Marker color field + ColorField string `json:"colorField"` + + // Colors define color encoding of data into a visualization + Colors []DashboardColor `json:"colors"` + + // Cluster close markers together + IsClustered *bool `json:"isClustered,omitempty"` + + // An array for which columns to display in tooltip + TooltipColumns *[]string `json:"tooltipColumns,omitempty"` +} + +// GeoTrackMapViewLayer defines model for GeoTrackMapViewLayer. +type GeoTrackMapViewLayer struct { + // Embedded struct due to allOf(#/components/schemas/GeoViewLayerProperties) + GeoViewLayerProperties `yaml:",inline"` + // Embedded fields due to inline allOf schema +} + +// GeoViewLayer defines model for GeoViewLayer. +type GeoViewLayer interface{} + +// GeoViewLayerProperties defines model for GeoViewLayerProperties. +type GeoViewLayerProperties struct { + Type GeoViewLayerPropertiesType `json:"type"` +} + +// GeoViewLayerPropertiesType defines model for GeoViewLayerProperties.Type. +type GeoViewLayerPropertiesType string + +// GeoViewProperties defines model for GeoViewProperties. +type GeoViewProperties struct { + // If true, map zoom and pan controls are enabled on the dashboard view + AllowPanAndZoom bool `json:"allowPanAndZoom"` + + // Coordinates of the center of the map + Center struct { + // Latitude of the center of the map + Lat float64 `json:"lat"` + + // Longitude of the center of the map + Lon float64 `json:"lon"` + } `json:"center"` + + // Colors define color encoding of data into a visualization + Colors *[]DashboardColor `json:"colors,omitempty"` + + // If true, search results get automatically regroupped so that lon,lat and value are treated as columns + DetectCoordinateFields bool `json:"detectCoordinateFields"` + + // Object type to define lat/lon columns + LatLonColumns *LatLonColumns `json:"latLonColumns,omitempty"` + + // List of individual layers shown in the map + Layers []GeoViewLayer `json:"layers"` + + // Define map type - regular, satellite etc. + MapStyle *string `json:"mapStyle,omitempty"` + Note string `json:"note"` + Queries []DashboardQuery `json:"queries"` + + // String to define the column + S2Column *string `json:"s2Column,omitempty"` + Shape GeoViewPropertiesShape `json:"shape"` + + // If true, will display note when empty + ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` + Type GeoViewPropertiesType `json:"type"` + + // If true, S2 column is used to calculate lat/lon + UseS2CellID *bool `json:"useS2CellID,omitempty"` + + // Zoom level used for initial display of the map + Zoom float64 `json:"zoom"` +} + +// GeoViewPropertiesShape defines model for GeoViewProperties.Shape. +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 + +// HTTPNotificationEndpoint defines model for HTTPNotificationEndpoint. +type HTTPNotificationEndpoint struct { + // Embedded struct due to allOf(#/components/schemas/NotificationEndpointBase) + NotificationEndpointBase `yaml:",inline"` + // Embedded fields due to inline allOf schema + AuthMethod HTTPNotificationEndpointAuthMethod `json:"authMethod"` + ContentTemplate *string `json:"contentTemplate,omitempty"` + + // Customized headers. + Headers *HTTPNotificationEndpoint_Headers `json:"headers,omitempty"` + Method HTTPNotificationEndpointMethod `json:"method"` + Password *string `json:"password,omitempty"` + Token *string `json:"token,omitempty"` + Url string `json:"url"` + Username *string `json:"username,omitempty"` +} + +// HTTPNotificationEndpointAuthMethod defines model for HTTPNotificationEndpoint.AuthMethod. +type HTTPNotificationEndpointAuthMethod string + +// HTTPNotificationEndpointMethod defines model for HTTPNotificationEndpoint.Method. +type HTTPNotificationEndpointMethod string + +// Customized headers. +type HTTPNotificationEndpoint_Headers struct { + AdditionalProperties map[string]string `json:"-"` +} + +// HTTPNotificationRule defines model for HTTPNotificationRule. +type HTTPNotificationRule struct { + // Embedded struct due to allOf(#/components/schemas/NotificationRuleBase) + NotificationRuleBase `yaml:",inline"` + // Embedded struct due to allOf(#/components/schemas/HTTPNotificationRuleBase) + HTTPNotificationRuleBase `yaml:",inline"` +} + +// HTTPNotificationRuleBase defines model for HTTPNotificationRuleBase. +type HTTPNotificationRuleBase struct { + Type HTTPNotificationRuleBaseType `json:"type"` + Url *string `json:"url,omitempty"` +} + +// HTTPNotificationRuleBaseType defines model for HTTPNotificationRuleBase.Type. +type HTTPNotificationRuleBaseType string + +// HealthCheck defines model for HealthCheck. +type HealthCheck struct { + Checks *[]HealthCheck `json:"checks,omitempty"` + Commit *string `json:"commit,omitempty"` + Message *string `json:"message,omitempty"` + Name string `json:"name"` + Status HealthCheckStatus `json:"status"` + Version *string `json:"version,omitempty"` +} + +// HealthCheckStatus defines model for HealthCheck.Status. +type HealthCheckStatus string + +// HeatmapViewProperties defines model for HeatmapViewProperties. +type HeatmapViewProperties struct { + AdaptiveZoomHide *bool `json:"adaptiveZoomHide,omitempty"` + BinSize float32 `json:"binSize"` + + // Colors define color encoding of data into a visualization + Colors []string `json:"colors"` + GenerateXAxisTicks *[]string `json:"generateXAxisTicks,omitempty"` + GenerateYAxisTicks *[]string `json:"generateYAxisTicks,omitempty"` + LegendColorizeRows *bool `json:"legendColorizeRows,omitempty"` + LegendHide *bool `json:"legendHide,omitempty"` + LegendOpacity *float32 `json:"legendOpacity,omitempty"` + LegendOrientationThreshold *int `json:"legendOrientationThreshold,omitempty"` + Note string `json:"note"` + Queries []DashboardQuery `json:"queries"` + Shape HeatmapViewPropertiesShape `json:"shape"` + + // If true, will display note when empty + ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` + TimeFormat *string `json:"timeFormat,omitempty"` + Type HeatmapViewPropertiesType `json:"type"` + XAxisLabel string `json:"xAxisLabel"` + XColumn string `json:"xColumn"` + XDomain []float32 `json:"xDomain"` + XPrefix string `json:"xPrefix"` + XSuffix string `json:"xSuffix"` + XTickStart *float32 `json:"xTickStart,omitempty"` + XTickStep *float32 `json:"xTickStep,omitempty"` + XTotalTicks *int `json:"xTotalTicks,omitempty"` + YAxisLabel string `json:"yAxisLabel"` + YColumn string `json:"yColumn"` + YDomain []float32 `json:"yDomain"` + YPrefix string `json:"yPrefix"` + YSuffix string `json:"ySuffix"` + YTickStart *float32 `json:"yTickStart,omitempty"` + YTickStep *float32 `json:"yTickStep,omitempty"` + YTotalTicks *int `json:"yTotalTicks,omitempty"` +} + +// HeatmapViewPropertiesShape defines model for HeatmapViewProperties.Shape. +type HeatmapViewPropertiesShape string + +// HeatmapViewPropertiesType defines model for HeatmapViewProperties.Type. +type HeatmapViewPropertiesType string + +// HistogramViewProperties defines model for HistogramViewProperties. +type HistogramViewProperties struct { + BinCount int `json:"binCount"` + + // Colors define color encoding of data into a visualization + Colors []DashboardColor `json:"colors"` + FillColumns []string `json:"fillColumns"` + LegendColorizeRows *bool `json:"legendColorizeRows,omitempty"` + LegendHide *bool `json:"legendHide,omitempty"` + LegendOpacity *float32 `json:"legendOpacity,omitempty"` + LegendOrientationThreshold *int `json:"legendOrientationThreshold,omitempty"` + Note string `json:"note"` + Position HistogramViewPropertiesPosition `json:"position"` + Queries []DashboardQuery `json:"queries"` + Shape HistogramViewPropertiesShape `json:"shape"` + + // If true, will display note when empty + ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` + Type HistogramViewPropertiesType `json:"type"` + XAxisLabel string `json:"xAxisLabel"` + XColumn string `json:"xColumn"` + XDomain []float32 `json:"xDomain"` +} + +// HistogramViewPropertiesPosition defines model for HistogramViewProperties.Position. +type HistogramViewPropertiesPosition string + +// HistogramViewPropertiesShape defines model for HistogramViewProperties.Shape. +type HistogramViewPropertiesShape string + +// HistogramViewPropertiesType defines model for HistogramViewProperties.Type. +type HistogramViewPropertiesType string + +// A valid Flux identifier +type Identifier struct { + Name *string `json:"name,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Declares a package import +type ImportDeclaration struct { + // A valid Flux identifier + As *Identifier `json:"as,omitempty"` + + // Expressions begin and end with double quote marks + Path *StringLiteral `json:"path,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Represents indexing into an array +type IndexExpression struct { + Array *Expression `json:"array,omitempty"` + Index *Expression `json:"index,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Represents integer numbers +type IntegerLiteral struct { + // Type of AST node + Type *NodeType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +// IsOnboarding defines model for IsOnboarding. +type IsOnboarding struct { + // If `true`, the InfluxDB instance hasn't had initial setup; + // `false` otherwise. + Allowed *bool `json:"allowed,omitempty"` +} + +// Label defines model for Label. +type Label struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + OrgID *string `json:"orgID,omitempty"` + + // Key-value pairs associated with this label. + // To remove a property, send an update with an empty value (`""`) for the key. + Properties *Label_Properties `json:"properties,omitempty"` +} + +// Key-value pairs associated with this label. +// To remove a property, send an update with an empty value (`""`) for the key. +type Label_Properties struct { + AdditionalProperties map[string]string `json:"-"` +} + +// LabelCreateRequest defines model for LabelCreateRequest. +type LabelCreateRequest struct { + Name string `json:"name"` + OrgID string `json:"orgID"` + + // Key-value pairs associated with this label. + // + // To remove a property, send an update with an empty value (`""`) for the key. + Properties *LabelCreateRequest_Properties `json:"properties,omitempty"` +} + +// Key-value pairs associated with this label. +// +// To remove a property, send an update with an empty value (`""`) for the key. +type LabelCreateRequest_Properties struct { + AdditionalProperties map[string]string `json:"-"` +} + +// LabelMapping defines model for LabelMapping. +type LabelMapping struct { + // Label ID. + // The ID of the label to attach. + LabelID *string `json:"labelID,omitempty"` +} + +// LabelResponse defines model for LabelResponse. +type LabelResponse struct { + Label *Label `json:"label,omitempty"` + + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` +} + +// LabelUpdate defines model for LabelUpdate. +type LabelUpdate struct { + Name *string `json:"name,omitempty"` + Properties *LabelUpdate_Properties `json:"properties,omitempty"` +} + +// LabelUpdate_Properties defines model for LabelUpdate.Properties. +type LabelUpdate_Properties struct { + AdditionalProperties map[string]string `json:"-"` +} + +// Labels defines model for Labels. +type Labels []Label + +// LabelsResponse defines model for LabelsResponse. +type LabelsResponse struct { + Labels *Labels `json:"labels,omitempty"` + + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` +} + +// Flux query to be analyzed. +type LanguageRequest struct { + // The Flux query script to be analyzed. + Query string `json:"query"` +} + +// Object type for key and column definitions +type LatLonColumn struct { + // Column to look up Lat/Lon + Column string `json:"column"` + + // Key to determine whether the column is tag/field + Key string `json:"key"` +} + +// Object type to define lat/lon columns +type LatLonColumns struct { + // Object type for key and column definitions + Lat LatLonColumn `json:"lat"` + + // Object type for key and column definitions + 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 + +// LinePlusSingleStatProperties defines model for LinePlusSingleStatProperties. +type LinePlusSingleStatProperties struct { + AdaptiveZoomHide *bool `json:"adaptiveZoomHide,omitempty"` + + // The viewport for a View's visualizations + Axes Axes `json:"axes"` + + // Colors define color encoding of data into a visualization + Colors []DashboardColor `json:"colors"` + + // Indicates whether decimal places should be enforced, and how many digits it should show. + DecimalPlaces DecimalPlaces `json:"decimalPlaces"` + GenerateXAxisTicks *[]string `json:"generateXAxisTicks,omitempty"` + GenerateYAxisTicks *[]string `json:"generateYAxisTicks,omitempty"` + HoverDimension *LinePlusSingleStatPropertiesHoverDimension `json:"hoverDimension,omitempty"` + LegendColorizeRows *bool `json:"legendColorizeRows,omitempty"` + LegendHide *bool `json:"legendHide,omitempty"` + LegendOpacity *float32 `json:"legendOpacity,omitempty"` + LegendOrientationThreshold *int `json:"legendOrientationThreshold,omitempty"` + Note string `json:"note"` + Position LinePlusSingleStatPropertiesPosition `json:"position"` + Prefix string `json:"prefix"` + Queries []DashboardQuery `json:"queries"` + ShadeBelow *bool `json:"shadeBelow,omitempty"` + Shape LinePlusSingleStatPropertiesShape `json:"shape"` + + // If true, will display note when empty + ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` + + // StaticLegend represents the options specific to the static legend + StaticLegend *StaticLegend `json:"staticLegend,omitempty"` + Suffix string `json:"suffix"` + TimeFormat *string `json:"timeFormat,omitempty"` + Type LinePlusSingleStatPropertiesType `json:"type"` + XColumn *string `json:"xColumn,omitempty"` + XTickStart *float32 `json:"xTickStart,omitempty"` + XTickStep *float32 `json:"xTickStep,omitempty"` + XTotalTicks *int `json:"xTotalTicks,omitempty"` + YColumn *string `json:"yColumn,omitempty"` + YTickStart *float32 `json:"yTickStart,omitempty"` + YTickStep *float32 `json:"yTickStep,omitempty"` + YTotalTicks *int `json:"yTotalTicks,omitempty"` +} + +// LinePlusSingleStatPropertiesHoverDimension defines model for LinePlusSingleStatProperties.HoverDimension. +type LinePlusSingleStatPropertiesHoverDimension string + +// LinePlusSingleStatPropertiesPosition defines model for LinePlusSingleStatProperties.Position. +type LinePlusSingleStatPropertiesPosition string + +// LinePlusSingleStatPropertiesShape defines model for LinePlusSingleStatProperties.Shape. +type LinePlusSingleStatPropertiesShape string + +// LinePlusSingleStatPropertiesType defines model for LinePlusSingleStatProperties.Type. +type LinePlusSingleStatPropertiesType string + +// LineProtocolError defines model for LineProtocolError. +type LineProtocolError struct { + // Code is the machine-readable error code. + Code LineProtocolErrorCode `json:"code"` + + // Stack of errors that occurred during processing of the request. Useful for debugging. + Err *string `json:"err,omitempty"` + + // First line in the request body that contains malformed data. + Line *int32 `json:"line,omitempty"` + + // Human-readable message. + Message *string `json:"message,omitempty"` + + // Describes the logical code operation when the error occurred. Useful for debugging. + Op *string `json:"op,omitempty"` +} + +// Code is the machine-readable error code. +type LineProtocolErrorCode string + +// LineProtocolLengthError defines model for LineProtocolLengthError. +type LineProtocolLengthError struct { + // Code is the machine-readable error code. + Code LineProtocolLengthErrorCode `json:"code"` + + // Human-readable message. + Message string `json:"message"` +} + +// Code is the machine-readable error code. +type LineProtocolLengthErrorCode string + +// URI of resource. +type Link string + +// URI pointers for additional paged results. +type Links struct { + // URI of resource. + Next *Link `json:"next,omitempty"` + + // URI of resource. + Prev *Link `json:"prev,omitempty"` + + // URI of resource. + Self Link `json:"self"` +} + +// LogEvent defines model for LogEvent. +type LogEvent struct { + // A description of the event that occurred. + Message *string `json:"message,omitempty"` + + // The ID of the task run that generated the event. + RunID *string `json:"runID,omitempty"` + + // The time ([RFC3339Nano date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339nano-timestamp)) that the event occurred. + Time *time.Time `json:"time,omitempty"` +} + +// Represents the rule conditions that collectively evaluate to either true or false +type LogicalExpression struct { + Left *Expression `json:"left,omitempty"` + Operator *string `json:"operator,omitempty"` + Right *Expression `json:"right,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Logs defines model for Logs. +type Logs struct { + Events *[]LogEvent `json:"events,omitempty"` +} + +// MapVariableProperties defines model for MapVariableProperties. +type MapVariableProperties struct { + Type *MapVariablePropertiesType `json:"type,omitempty"` + Values *MapVariableProperties_Values `json:"values,omitempty"` +} + +// MapVariablePropertiesType defines model for MapVariableProperties.Type. +type MapVariablePropertiesType string + +// MapVariableProperties_Values defines model for MapVariableProperties.Values. +type MapVariableProperties_Values struct { + AdditionalProperties map[string]string `json:"-"` +} + +// MarkdownViewProperties defines model for MarkdownViewProperties. +type MarkdownViewProperties struct { + Note string `json:"note"` + Shape MarkdownViewPropertiesShape `json:"shape"` + Type MarkdownViewPropertiesType `json:"type"` +} + +// MarkdownViewPropertiesShape defines model for MarkdownViewProperties.Shape. +type MarkdownViewPropertiesShape string + +// MarkdownViewPropertiesType defines model for MarkdownViewProperties.Type. +type MarkdownViewPropertiesType string + +// Object property assignment +type MemberAssignment struct { + Init *Expression `json:"init,omitempty"` + + // Represents accessing a property of an object + Member *MemberExpression `json:"member,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Represents accessing a property of an object +type MemberExpression struct { + Object *Expression `json:"object,omitempty"` + Property *PropertyKey `json:"property,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// MetadataBackup defines model for MetadataBackup. +type MetadataBackup struct { + Buckets BucketMetadataManifests `json:"buckets"` + Kv string `json:"kv"` + Sql string `json:"sql"` +} + +// MosaicViewProperties defines model for MosaicViewProperties. +type MosaicViewProperties struct { + // Colors define color encoding of data into a visualization + Colors []string `json:"colors"` + FillColumns []string `json:"fillColumns"` + GenerateXAxisTicks *[]string `json:"generateXAxisTicks,omitempty"` + HoverDimension *MosaicViewPropertiesHoverDimension `json:"hoverDimension,omitempty"` + LegendColorizeRows *bool `json:"legendColorizeRows,omitempty"` + LegendHide *bool `json:"legendHide,omitempty"` + LegendOpacity *float32 `json:"legendOpacity,omitempty"` + LegendOrientationThreshold *int `json:"legendOrientationThreshold,omitempty"` + Note string `json:"note"` + Queries []DashboardQuery `json:"queries"` + Shape MosaicViewPropertiesShape `json:"shape"` + + // If true, will display note when empty + ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` + TimeFormat *string `json:"timeFormat,omitempty"` + Type MosaicViewPropertiesType `json:"type"` + XAxisLabel string `json:"xAxisLabel"` + XColumn string `json:"xColumn"` + XDomain []float32 `json:"xDomain"` + XPrefix string `json:"xPrefix"` + XSuffix string `json:"xSuffix"` + XTickStart *float32 `json:"xTickStart,omitempty"` + XTickStep *float32 `json:"xTickStep,omitempty"` + XTotalTicks *int `json:"xTotalTicks,omitempty"` + YAxisLabel string `json:"yAxisLabel"` + YDomain []float32 `json:"yDomain"` + YLabelColumnSeparator *string `json:"yLabelColumnSeparator,omitempty"` + YLabelColumns *[]string `json:"yLabelColumns,omitempty"` + YPrefix string `json:"yPrefix"` + YSeriesColumns []string `json:"ySeriesColumns"` + YSuffix string `json:"ySuffix"` +} + +// MosaicViewPropertiesHoverDimension defines model for MosaicViewProperties.HoverDimension. +type MosaicViewPropertiesHoverDimension string + +// MosaicViewPropertiesShape defines model for MosaicViewProperties.Shape. +type MosaicViewPropertiesShape string + +// MosaicViewPropertiesType defines model for MosaicViewProperties.Type. +type MosaicViewPropertiesType string + +// Node defines model for Node. +type Node interface{} + +// Type of AST node +type NodeType string + +// NotificationEndpoint defines model for NotificationEndpoint. +type NotificationEndpoint struct { + // Embedded struct due to allOf(#/components/schemas/NotificationEndpointDiscriminator) + NotificationEndpointDiscriminator `yaml:",inline"` +} + +// NotificationEndpointBase defines model for NotificationEndpointBase. +type NotificationEndpointBase struct { + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // An optional description of the notification endpoint. + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Labels *Labels `json:"labels,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. + Self *Link `json:"self,omitempty"` + } `json:"links,omitempty"` + Name string `json:"name"` + OrgID *string `json:"orgID,omitempty"` + + // The status of the endpoint. + Status *NotificationEndpointBaseStatus `json:"status,omitempty"` + Type NotificationEndpointType `json:"type"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` + UserID *string `json:"userID,omitempty"` +} + +// The status of the endpoint. +type NotificationEndpointBaseStatus string + +// NotificationEndpointDiscriminator defines model for NotificationEndpointDiscriminator. +type NotificationEndpointDiscriminator interface{} + +// NotificationEndpointType defines model for NotificationEndpointType. +type NotificationEndpointType string + +// NotificationEndpointUpdate defines model for NotificationEndpointUpdate. +type NotificationEndpointUpdate struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + Status *NotificationEndpointUpdateStatus `json:"status,omitempty"` +} + +// NotificationEndpointUpdateStatus defines model for NotificationEndpointUpdate.Status. +type NotificationEndpointUpdateStatus string + +// NotificationEndpoints defines model for NotificationEndpoints. +type NotificationEndpoints struct { + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` + NotificationEndpoints *[]NotificationEndpoint `json:"notificationEndpoints,omitempty"` +} + +// NotificationRule defines model for NotificationRule. +type NotificationRule struct { + // Embedded struct due to allOf(#/components/schemas/NotificationRuleDiscriminator) + NotificationRuleDiscriminator `yaml:",inline"` +} + +// NotificationRuleBase defines model for NotificationRuleBase. +type NotificationRuleBase struct { + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // An optional description of the notification rule. + Description *string `json:"description,omitempty"` + EndpointID string `json:"endpointID"` + + // The notification repetition interval. + Every *string `json:"every,omitempty"` + Id *string `json:"id,omitempty"` + Labels *Labels `json:"labels,omitempty"` + LastRunError *string `json:"lastRunError,omitempty"` + LastRunStatus *NotificationRuleBaseLastRunStatus `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"` + + // Don't notify me more than times every seconds. If set, limitEvery cannot be empty. + Limit *int `json:"limit,omitempty"` + + // Don't notify me more than times every seconds. If set, limit cannot be empty. + LimitEvery *int `json:"limitEvery,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"` + + // Human-readable name describing the notification rule. + Name string `json:"name"` + + // Duration to delay after the schedule, before executing check. + Offset *string `json:"offset,omitempty"` + + // The ID of the organization that owns this notification rule. + OrgID string `json:"orgID"` + + // The ID of creator used to create this notification rule. + OwnerID *string `json:"ownerID,omitempty"` + RunbookLink *string `json:"runbookLink,omitempty"` + SleepUntil *string `json:"sleepUntil,omitempty"` + + // `inactive` cancels scheduled runs and prevents manual runs of the task. + Status TaskStatusType `json:"status"` + + // List of status rules the notification rule attempts to match. + StatusRules []StatusRule `json:"statusRules"` + + // List of tag rules the notification rule attempts to match. + TagRules *[]TagRule `json:"tagRules,omitempty"` + + // The ID of the task associated with this notification rule. + TaskID *string `json:"taskID,omitempty"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` +} + +// NotificationRuleBaseLastRunStatus defines model for NotificationRuleBase.LastRunStatus. +type NotificationRuleBaseLastRunStatus string + +// NotificationRuleDiscriminator defines model for NotificationRuleDiscriminator. +type NotificationRuleDiscriminator interface{} + +// NotificationRuleUpdate defines model for NotificationRuleUpdate. +type NotificationRuleUpdate struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + Status *NotificationRuleUpdateStatus `json:"status,omitempty"` +} + +// NotificationRuleUpdateStatus defines model for NotificationRuleUpdate.Status. +type NotificationRuleUpdateStatus string + +// NotificationRules defines model for NotificationRules. +type NotificationRules struct { + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` + NotificationRules *[]NotificationRule `json:"notificationRules,omitempty"` +} + +// Allows the declaration of an anonymous object within a declaration +type ObjectExpression struct { + // Object properties + Properties *[]Property `json:"properties,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// OnboardingRequest defines model for OnboardingRequest. +type OnboardingRequest struct { + Bucket string `json:"bucket"` + Org string `json:"org"` + Password *string `json:"password,omitempty"` + + // Retention period *in nanoseconds* for the new bucket. This key's name has been misleading since OSS 2.0 GA, please transition to use `retentionPeriodSeconds` + RetentionPeriodHrs *int `json:"retentionPeriodHrs,omitempty"` + RetentionPeriodSeconds *int64 `json:"retentionPeriodSeconds,omitempty"` + + // Authentication token to set on the initial user. If not specified, the server will generate a token. + Token *string `json:"token,omitempty"` + Username string `json:"username"` +} + +// OnboardingResponse defines model for OnboardingResponse. +type OnboardingResponse struct { + Auth *Authorization `json:"auth,omitempty"` + Bucket *Bucket `json:"bucket,omitempty"` + Org *Organization `json:"org,omitempty"` + User *UserResponse `json:"user,omitempty"` +} + +// A single variable declaration +type OptionStatement struct { + Assignment *interface{} `json:"assignment,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Organization defines model for Organization. +type Organization struct { + CreatedAt *time.Time `json:"createdAt,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Links *struct { + // URI of resource. + Buckets *Link `json:"buckets,omitempty"` + + // URI of resource. + Dashboards *Link `json:"dashboards,omitempty"` + + // 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. + Secrets *Link `json:"secrets,omitempty"` + + // URI of resource. + Self *Link `json:"self,omitempty"` + + // URI of resource. + Tasks *Link `json:"tasks,omitempty"` + } `json:"links,omitempty"` + Name string `json:"name"` + + // If inactive the organization is inactive. + Status *OrganizationStatus `json:"status,omitempty"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` +} + +// If inactive the organization is inactive. +type OrganizationStatus string + +// Organizations defines model for Organizations. +type Organizations struct { + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` + Orgs *[]Organization `json:"orgs,omitempty"` +} + +// Represents a complete package source tree. +type Package struct { + // Package files + Files *[]File `json:"files,omitempty"` + + // Package name + Package *string `json:"package,omitempty"` + + // Package import path + Path *string `json:"path,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Defines a package identifier +type PackageClause struct { + // A valid Flux identifier + Name *Identifier `json:"name,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// PagerDutyNotificationEndpoint defines model for PagerDutyNotificationEndpoint. +type PagerDutyNotificationEndpoint struct { + // Embedded struct due to allOf(#/components/schemas/NotificationEndpointBase) + NotificationEndpointBase `yaml:",inline"` + // Embedded fields due to inline allOf schema + ClientURL *string `json:"clientURL,omitempty"` + RoutingKey string `json:"routingKey"` +} + +// PagerDutyNotificationRule defines model for PagerDutyNotificationRule. +type PagerDutyNotificationRule struct { + // Embedded struct due to allOf(#/components/schemas/NotificationRuleBase) + NotificationRuleBase `yaml:",inline"` + // Embedded struct due to allOf(#/components/schemas/PagerDutyNotificationRuleBase) + PagerDutyNotificationRuleBase `yaml:",inline"` +} + +// PagerDutyNotificationRuleBase defines model for PagerDutyNotificationRuleBase. +type PagerDutyNotificationRuleBase struct { + MessageTemplate string `json:"messageTemplate"` + Type PagerDutyNotificationRuleBaseType `json:"type"` +} + +// PagerDutyNotificationRuleBaseType defines model for PagerDutyNotificationRuleBase.Type. +type PagerDutyNotificationRuleBaseType string + +// Represents an expression wrapped in parenthesis +type ParenExpression struct { + Expression *Expression `json:"expression,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// PasswordResetBody defines model for PasswordResetBody. +type PasswordResetBody struct { + Password string `json:"password"` +} + +// An object that contains updated bucket properties to apply. +type PatchBucketRequest struct { + // A description of the bucket. + Description *string `json:"description,omitempty"` + + // The name of the bucket. + Name *string `json:"name,omitempty"` + + // Updates to rules to expire or retain data. No rules means no updates. + RetentionRules *PatchRetentionRules `json:"retentionRules,omitempty"` +} + +// PatchOrganizationRequest defines model for PatchOrganizationRequest. +type PatchOrganizationRequest struct { + // New description to set on the organization + Description *string `json:"description,omitempty"` + + // New name to set on the organization + Name *string `json:"name,omitempty"` +} + +// PatchRetentionRule defines model for PatchRetentionRule. +type PatchRetentionRule struct { + // The number of seconds to keep data. + // Default duration is `2592000` (30 days). + // `0` represents infinite retention. + EverySeconds int64 `json:"everySeconds"` + + // The [shard group duration](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#shard). + // The number of seconds that each shard group covers. + // + // #### InfluxDB Cloud + // + // - Doesn't use `shardGroupDurationsSeconds`. + // + // #### InfluxDB OSS + // + // - Default value depends on the [bucket retention period](https://docs.influxdata.com/influxdb/v2.3/reference/internals/shards/#shard-group-duration). + // + // #### Related guides + // + // - InfluxDB [shards and shard groups](https://docs.influxdata.com/influxdb/v2.3/reference/internals/shards/) + ShardGroupDurationSeconds *int64 `json:"shardGroupDurationSeconds,omitempty"` + Type *PatchRetentionRuleType `json:"type,omitempty"` +} + +// PatchRetentionRuleType defines model for PatchRetentionRule.Type. +type PatchRetentionRuleType string + +// Updates to rules to expire or retain data. No rules means no updates. +type PatchRetentionRules []PatchRetentionRule + +// Permission defines model for Permission. +type Permission struct { + Action PermissionAction `json:"action"` + Resource Resource `json:"resource"` +} + +// PermissionAction defines model for Permission.Action. +type PermissionAction string + +// Call expression with pipe argument +type PipeExpression struct { + Argument *Expression `json:"argument,omitempty"` + + // Represents a function call + Call *CallExpression `json:"call,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Represents a specialized literal value, indicating the left hand value of a pipe expression +type PipeLiteral struct { + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// PostBucketRequest defines model for PostBucketRequest. +type PostBucketRequest struct { + // A description of the bucket. + Description *string `json:"description,omitempty"` + + // The name of the bucket. + Name string `json:"name"` + + // Organization ID. + // The ID of the organization. + OrgID string `json:"orgID"` + + // Retention rules to expire or retain data. + // #### InfluxDB Cloud + // + // - `retentionRules` is required. + // + // #### InfluxDB OSS + // + // - `retentionRules` isn't required. + RetentionRules *RetentionRules `json:"retentionRules,omitempty"` + + // Retention policy is an InfluxDB 1.x concept that represents the duration + // of time that each data point in the retention policy persists. Use `rp` + // for compatibility with InfluxDB 1.x. + // The InfluxDB 2.x and Cloud equivalent is + // [retention period](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#retention-period). + Rp *string `json:"rp,omitempty"` + 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) + NotificationEndpointDiscriminator `yaml:",inline"` +} + +// PostNotificationRule defines model for PostNotificationRule. +type PostNotificationRule struct { + // Embedded struct due to allOf(#/components/schemas/NotificationRuleDiscriminator) + NotificationRuleDiscriminator `yaml:",inline"` +} + +// PostOrganizationRequest defines model for PostOrganizationRequest. +type PostOrganizationRequest struct { + Description *string `json:"description,omitempty"` + Name string `json:"name"` +} + +// The value associated with a key +type Property struct { + Key *PropertyKey `json:"key,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` + Value *Expression `json:"value,omitempty"` +} + +// PropertyKey defines model for PropertyKey. +type PropertyKey interface{} + +// Query InfluxDB with the Flux language +type Query struct { + // Options for tabular data output. + // Default output is [annotated CSV](https://docs.influxdata.com/influxdb/v2.3/reference/syntax/annotated-csv/#csv-response-format) with headers. + // + // For more information about tabular data **dialect**, + // see [W3 metadata vocabulary for tabular data](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#dialect-descriptions). + Dialect *Dialect `json:"dialect,omitempty"` + + // Represents a source from a single file + Extern *File `json:"extern,omitempty"` + + // Specifies the time that should be reported as `now` in the query. + // Default is the server `now` time. + Now *time.Time `json:"now,omitempty"` + + // Key-value pairs passed as parameters during query execution. + // + // 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)" + // ``` + // + // and pass _`params`_ with the key-value pairs--for example: + // + // ```json + // params: { + // "mybucket": "environment", + // "rangeStart": "-30d" + // } + // ``` + // + // During query execution, InfluxDB passes _`params`_ to your script and substitutes the values. + // + // #### Limitations + // + // - If you use _`params`_, you can't use _`extern`_. + Params *Query_Params `json:"params,omitempty"` + + // The query script to execute. + Query string `json:"query"` + + // The type of query. Must be "flux". + Type *QueryType `json:"type,omitempty"` +} + +// The type of query. Must be "flux". +type QueryType string + +// Key-value pairs passed as parameters during query execution. +// +// 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)" +// ``` +// +// and pass _`params`_ with the key-value pairs--for example: +// +// ```json +// params: { +// "mybucket": "environment", +// "rangeStart": "-30d" +// } +// ``` +// +// During query execution, InfluxDB passes _`params`_ to your script and substitutes the values. +// +// #### Limitations +// +// - If you use _`params`_, you can't use _`extern`_. +type Query_Params struct { + AdditionalProperties map[string]interface{} `json:"-"` +} + +// QueryEditMode defines model for QueryEditMode. +type QueryEditMode string + +// QueryVariableProperties defines model for QueryVariableProperties. +type QueryVariableProperties struct { + Type *QueryVariablePropertiesType `json:"type,omitempty"` + Values *struct { + Language *string `json:"language,omitempty"` + Query *string `json:"query,omitempty"` + } `json:"values,omitempty"` +} + +// 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 + +// Ready defines model for Ready. +type Ready struct { + Started *time.Time `json:"started,omitempty"` + Status *ReadyStatus `json:"status,omitempty"` + Up *string `json:"up,omitempty"` +} + +// ReadyStatus defines model for Ready.Status. +type ReadyStatus string + +// Expressions begin and end with `/` and are regular expressions with syntax accepted by RE2 +type RegexpLiteral struct { + // Type of AST node + Type *NodeType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +// RemoteConnection defines model for RemoteConnection. +type RemoteConnection struct { + AllowInsecureTLS bool `json:"allowInsecureTLS"` + Description *string `json:"description,omitempty"` + Id string `json:"id"` + Name string `json:"name"` + OrgID string `json:"orgID"` + RemoteOrgID string `json:"remoteOrgID"` + RemoteURL string `json:"remoteURL"` +} + +// RemoteConnectionCreationRequest defines model for RemoteConnectionCreationRequest. +type RemoteConnectionCreationRequest struct { + AllowInsecureTLS bool `json:"allowInsecureTLS"` + Description *string `json:"description,omitempty"` + Name string `json:"name"` + OrgID string `json:"orgID"` + RemoteAPIToken string `json:"remoteAPIToken"` + RemoteOrgID string `json:"remoteOrgID"` + RemoteURL string `json:"remoteURL"` +} + +// RemoteConnectionUpdateRequest defines model for RemoteConnectionUpdateRequest. +type RemoteConnectionUpdateRequest struct { + AllowInsecureTLS *bool `json:"allowInsecureTLS,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + RemoteAPIToken *string `json:"remoteAPIToken,omitempty"` + RemoteOrgID *string `json:"remoteOrgID,omitempty"` + RemoteURL *string `json:"remoteURL,omitempty"` +} + +// RemoteConnections defines model for RemoteConnections. +type RemoteConnections struct { + Remotes *[]RemoteConnection `json:"remotes,omitempty"` +} + +// Describes a field that can be renamed and made visible or invisible. +type RenamableField struct { + // The name that a field is renamed to by the user. + DisplayName *string `json:"displayName,omitempty"` + + // The calculated name of a field. + InternalName *string `json:"internalName,omitempty"` + + // Indicates whether this field should be visible on the table. + Visible *bool `json:"visible,omitempty"` +} + +// Replication defines model for Replication. +type Replication struct { + CurrentQueueSizeBytes int64 `json:"currentQueueSizeBytes"` + Description *string `json:"description,omitempty"` + DropNonRetryableData *bool `json:"dropNonRetryableData,omitempty"` + Id string `json:"id"` + LatestErrorMessage *string `json:"latestErrorMessage,omitempty"` + LatestResponseCode *int `json:"latestResponseCode,omitempty"` + LocalBucketID string `json:"localBucketID"` + MaxQueueSizeBytes int64 `json:"maxQueueSizeBytes"` + Name string `json:"name"` + OrgID string `json:"orgID"` + RemoteBucketID *string `json:"remoteBucketID,omitempty"` + RemoteBucketName *string `json:"remoteBucketName,omitempty"` + RemoteID string `json:"remoteID"` +} + +// ReplicationCreationRequest defines model for ReplicationCreationRequest. +type ReplicationCreationRequest struct { + Description *string `json:"description,omitempty"` + DropNonRetryableData *bool `json:"dropNonRetryableData,omitempty"` + LocalBucketID string `json:"localBucketID"` + MaxAgeSeconds int64 `json:"maxAgeSeconds"` + MaxQueueSizeBytes int64 `json:"maxQueueSizeBytes"` + Name string `json:"name"` + OrgID string `json:"orgID"` + RemoteBucketID *string `json:"remoteBucketID,omitempty"` + RemoteBucketName *string `json:"remoteBucketName,omitempty"` + RemoteID string `json:"remoteID"` +} + +// ReplicationUpdateRequest defines model for ReplicationUpdateRequest. +type ReplicationUpdateRequest struct { + Description *string `json:"description,omitempty"` + DropNonRetryableData *bool `json:"dropNonRetryableData,omitempty"` + MaxAgeSeconds *int64 `json:"maxAgeSeconds,omitempty"` + MaxQueueSizeBytes *int64 `json:"maxQueueSizeBytes,omitempty"` + Name *string `json:"name,omitempty"` + RemoteBucketID *string `json:"remoteBucketID,omitempty"` + RemoteBucketName *string `json:"remoteBucketName,omitempty"` + RemoteID *string `json:"remoteID,omitempty"` +} + +// Replications defines model for Replications. +type Replications struct { + Replications *[]Replication `json:"replications,omitempty"` +} + +// Resource defines model for Resource. +type Resource struct { + // The ID of a specific resource. + // In a `permission`, applies the permission to only the resource with this ID. + Id *string `json:"id,omitempty"` + + // Optional: A name for the resource. + // Not all resource types have a name field. + Name *string `json:"name,omitempty"` + + // Optional: The name of the organization with `orgID`. + Org *string `json:"org,omitempty"` + + // The ID of the organization that owns the resource. + // In a `permission`, applies the permission to all resources of `type` owned by this organization. + OrgID *string `json:"orgID,omitempty"` + + // The type of resource. + // In a `permission`, applies the permission to all resources of this type. + Type ResourceType `json:"type"` +} + +// The type of resource. +// In a `permission`, applies the permission to all resources of this type. +type ResourceType string + +// ResourceMember defines model for ResourceMember. +type ResourceMember struct { + // Embedded struct due to allOf(#/components/schemas/UserResponse) + UserResponse `yaml:",inline"` + // Embedded fields due to inline allOf schema + Role *ResourceMemberRole `json:"role,omitempty"` +} + +// ResourceMemberRole defines model for ResourceMember.Role. +type ResourceMemberRole string + +// ResourceMembers defines model for ResourceMembers. +type ResourceMembers struct { + Links *struct { + Self *string `json:"self,omitempty"` + } `json:"links,omitempty"` + Users *[]ResourceMember `json:"users,omitempty"` +} + +// ResourceOwner defines model for ResourceOwner. +type ResourceOwner struct { + // Embedded struct due to allOf(#/components/schemas/UserResponse) + UserResponse `yaml:",inline"` + // Embedded fields due to inline allOf schema + Role *ResourceOwnerRole `json:"role,omitempty"` +} + +// ResourceOwnerRole defines model for ResourceOwner.Role. +type ResourceOwnerRole string + +// ResourceOwners defines model for ResourceOwners. +type ResourceOwners struct { + Links *struct { + Self *string `json:"self,omitempty"` + } `json:"links,omitempty"` + Users *[]ResourceOwner `json:"users,omitempty"` +} + +// RestoredBucketMappings defines model for RestoredBucketMappings. +type RestoredBucketMappings struct { + // New ID of the restored bucket + Id string `json:"id"` + Name string `json:"name"` + ShardMappings BucketShardMappings `json:"shardMappings"` +} + +// RetentionPolicyManifest defines model for RetentionPolicyManifest. +type RetentionPolicyManifest struct { + Duration int64 `json:"duration"` + Name string `json:"name"` + ReplicaN int `json:"replicaN"` + ShardGroupDuration int64 `json:"shardGroupDuration"` + ShardGroups ShardGroupManifests `json:"shardGroups"` + Subscriptions SubscriptionManifests `json:"subscriptions"` +} + +// RetentionPolicyManifests defines model for RetentionPolicyManifests. +type RetentionPolicyManifests []RetentionPolicyManifest + +// RetentionRule defines model for RetentionRule. +type RetentionRule struct { + // The duration in seconds for how long data will be kept in the database. + // The default duration is 2592000 (30 days). + // 0 represents infinite retention. + EverySeconds int64 `json:"everySeconds"` + + // The shard group duration. + // The duration or interval (in seconds) that each shard group covers. + // + // #### InfluxDB Cloud + // + // - Does not use `shardGroupDurationsSeconds`. + // + // #### InfluxDB OSS + // + // - Default value depends on the + // [bucket retention period](https://docs.influxdata.com/influxdb/v2.3/v2.3/reference/internals/shards/#shard-group-duration). + ShardGroupDurationSeconds *int64 `json:"shardGroupDurationSeconds,omitempty"` + Type *RetentionRuleType `json:"type,omitempty"` +} + +// RetentionRuleType defines model for RetentionRule.Type. +type RetentionRuleType string + +// Retention rules to expire or retain data. +// #### InfluxDB Cloud +// +// - `retentionRules` is required. +// +// #### InfluxDB OSS +// +// - `retentionRules` isn't required. +type RetentionRules []RetentionRule + +// Defines an expression to return +type ReturnStatement struct { + Argument *Expression `json:"argument,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Routes defines model for Routes. +type Routes struct { + Authorizations *string `json:"authorizations,omitempty"` + Buckets *string `json:"buckets,omitempty"` + Dashboards *string `json:"dashboards,omitempty"` + External *struct { + StatusFeed *string `json:"statusFeed,omitempty"` + } `json:"external,omitempty"` + Flags *string `json:"flags,omitempty"` + Me *string `json:"me,omitempty"` + Orgs *string `json:"orgs,omitempty"` + Query *struct { + Analyze *string `json:"analyze,omitempty"` + Ast *string `json:"ast,omitempty"` + Self *string `json:"self,omitempty"` + Suggestions *string `json:"suggestions,omitempty"` + } `json:"query,omitempty"` + Setup *string `json:"setup,omitempty"` + Signin *string `json:"signin,omitempty"` + Signout *string `json:"signout,omitempty"` + Sources *string `json:"sources,omitempty"` + System *struct { + Debug *string `json:"debug,omitempty"` + Health *string `json:"health,omitempty"` + Metrics *string `json:"metrics,omitempty"` + } `json:"system,omitempty"` + Tasks *string `json:"tasks,omitempty"` + Telegrafs *string `json:"telegrafs,omitempty"` + Users *string `json:"users,omitempty"` + Variables *string `json:"variables,omitempty"` + Write *string `json:"write,omitempty"` +} + +// The state to record if check matches a criteria. +type RuleStatusLevel string + +// Run defines model for Run. +type Run struct { + // The time ([RFC3339Nano date/time format](https://go.dev/src/time/format.go)) the run finished executing. + FinishedAt *time.Time `json:"finishedAt,omitempty"` + + // Flux used for the task + Flux *string `json:"flux,omitempty"` + Id *string `json:"id,omitempty"` + Links *struct { + Retry *string `json:"retry,omitempty"` + Self *string `json:"self,omitempty"` + Task *string `json:"task,omitempty"` + } `json:"links,omitempty"` + + // An array of logs associated with the run. + Log *[]LogEvent `json:"log,omitempty"` + + // The time ([RFC3339Nano date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339nano-timestamp)) the run was manually requested. + RequestedAt *time.Time `json:"requestedAt,omitempty"` + + // The time [RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp) used for the run's `now` option. + ScheduledFor *time.Time `json:"scheduledFor,omitempty"` + + // The time ([RFC3339Nano date/time format](https://go.dev/src/time/format.go)) the run started executing. + StartedAt *time.Time `json:"startedAt,omitempty"` + Status *RunStatus `json:"status,omitempty"` + TaskID *string `json:"taskID,omitempty"` +} + +// RunStatus defines model for Run.Status. +type RunStatus string + +// RunManually defines model for RunManually. +type RunManually struct { + // The time [RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp) + // used for the run's `now` option. + // Default is the server _now_ time. + ScheduledFor *time.Time `json:"scheduledFor"` +} + +// Runs defines model for Runs. +type Runs struct { + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` + Runs *[]Run `json:"runs,omitempty"` +} + +// SMTPNotificationRule defines model for SMTPNotificationRule. +type SMTPNotificationRule struct { + // Embedded struct due to allOf(#/components/schemas/NotificationRuleBase) + NotificationRuleBase `yaml:",inline"` + // Embedded struct due to allOf(#/components/schemas/SMTPNotificationRuleBase) + SMTPNotificationRuleBase `yaml:",inline"` +} + +// SMTPNotificationRuleBase defines model for SMTPNotificationRuleBase. +type SMTPNotificationRuleBase struct { + BodyTemplate *string `json:"bodyTemplate,omitempty"` + SubjectTemplate string `json:"subjectTemplate"` + To string `json:"to"` + Type SMTPNotificationRuleBaseType `json:"type"` +} + +// SMTPNotificationRuleBaseType defines model for SMTPNotificationRuleBase.Type. +type SMTPNotificationRuleBaseType string + +// ScatterViewProperties defines model for ScatterViewProperties. +type ScatterViewProperties struct { + AdaptiveZoomHide *bool `json:"adaptiveZoomHide,omitempty"` + + // Colors define color encoding of data into a visualization + Colors []string `json:"colors"` + FillColumns []string `json:"fillColumns"` + GenerateXAxisTicks *[]string `json:"generateXAxisTicks,omitempty"` + GenerateYAxisTicks *[]string `json:"generateYAxisTicks,omitempty"` + LegendColorizeRows *bool `json:"legendColorizeRows,omitempty"` + LegendHide *bool `json:"legendHide,omitempty"` + LegendOpacity *float32 `json:"legendOpacity,omitempty"` + LegendOrientationThreshold *int `json:"legendOrientationThreshold,omitempty"` + Note string `json:"note"` + Queries []DashboardQuery `json:"queries"` + Shape ScatterViewPropertiesShape `json:"shape"` + + // If true, will display note when empty + ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` + SymbolColumns []string `json:"symbolColumns"` + TimeFormat *string `json:"timeFormat,omitempty"` + Type ScatterViewPropertiesType `json:"type"` + XAxisLabel string `json:"xAxisLabel"` + XColumn string `json:"xColumn"` + XDomain []float32 `json:"xDomain"` + XPrefix string `json:"xPrefix"` + XSuffix string `json:"xSuffix"` + XTickStart *float32 `json:"xTickStart,omitempty"` + XTickStep *float32 `json:"xTickStep,omitempty"` + XTotalTicks *int `json:"xTotalTicks,omitempty"` + YAxisLabel string `json:"yAxisLabel"` + YColumn string `json:"yColumn"` + YDomain []float32 `json:"yDomain"` + YPrefix string `json:"yPrefix"` + YSuffix string `json:"ySuffix"` + YTickStart *float32 `json:"yTickStart,omitempty"` + YTickStep *float32 `json:"yTickStep,omitempty"` + YTotalTicks *int `json:"yTotalTicks,omitempty"` +} + +// ScatterViewPropertiesShape defines model for ScatterViewProperties.Shape. +type ScatterViewPropertiesShape string + +// ScatterViewPropertiesType defines model for ScatterViewProperties.Type. +type ScatterViewPropertiesType string + +// SchemaType defines model for SchemaType. +type SchemaType string + +// ScraperTargetRequest defines model for ScraperTargetRequest. +type ScraperTargetRequest struct { + // Skip TLS verification on endpoint. + AllowInsecure *bool `json:"allowInsecure,omitempty"` + + // The ID of the bucket to write to. + BucketID *string `json:"bucketID,omitempty"` + + // The name of the scraper target. + Name *string `json:"name,omitempty"` + + // The organization ID. + OrgID *string `json:"orgID,omitempty"` + + // The type of the metrics to be parsed. + Type *ScraperTargetRequestType `json:"type,omitempty"` + + // The URL of the metrics endpoint. + Url *string `json:"url,omitempty"` +} + +// The type of the metrics to be parsed. +type ScraperTargetRequestType string + +// ScraperTargetResponse defines model for ScraperTargetResponse. +type ScraperTargetResponse struct { + // Embedded struct due to allOf(#/components/schemas/ScraperTargetRequest) + ScraperTargetRequest `yaml:",inline"` + // Embedded fields due to inline allOf schema + // The bucket name. + Bucket *string `json:"bucket,omitempty"` + Id *string `json:"id,omitempty"` + Links *struct { + // URI of resource. + Bucket *Link `json:"bucket,omitempty"` + + // URI of resource. + Members *Link `json:"members,omitempty"` + + // URI of resource. + Organization *Link `json:"organization,omitempty"` + + // URI of resource. + Owners *Link `json:"owners,omitempty"` + + // URI of resource. + Self *Link `json:"self,omitempty"` + } `json:"links,omitempty"` + + // The name of the organization. + Org *string `json:"org,omitempty"` +} + +// ScraperTargetResponses defines model for ScraperTargetResponses. +type ScraperTargetResponses struct { + Configurations *[]ScraperTargetResponse `json:"configurations,omitempty"` +} + +// SecretKeys defines model for SecretKeys. +type SecretKeys struct { + Secrets *[]string `json:"secrets,omitempty"` +} + +// SecretKeysResponse defines model for SecretKeysResponse. +type SecretKeysResponse struct { + // Embedded struct due to allOf(#/components/schemas/SecretKeys) + SecretKeys `yaml:",inline"` + // Embedded fields due to inline allOf schema + Links *struct { + Org *string `json:"org,omitempty"` + Self *string `json:"self,omitempty"` + } `json:"links,omitempty"` +} + +// Secrets defines model for Secrets. +type Secrets struct { + AdditionalProperties map[string]string `json:"-"` +} + +// ShardGroupManifest defines model for ShardGroupManifest. +type ShardGroupManifest struct { + DeletedAt *time.Time `json:"deletedAt,omitempty"` + EndTime time.Time `json:"endTime"` + Id int64 `json:"id"` + Shards ShardManifests `json:"shards"` + StartTime time.Time `json:"startTime"` + TruncatedAt *time.Time `json:"truncatedAt,omitempty"` +} + +// ShardGroupManifests defines model for ShardGroupManifests. +type ShardGroupManifests []ShardGroupManifest + +// ShardManifest defines model for ShardManifest. +type ShardManifest struct { + Id int64 `json:"id"` + ShardOwners ShardOwners `json:"shardOwners"` +} + +// ShardManifests defines model for ShardManifests. +type ShardManifests []ShardManifest + +// ShardOwner defines model for ShardOwner. +type ShardOwner struct { + // The ID of the node that owns the shard. + NodeID int64 `json:"nodeID"` +} + +// ShardOwners defines model for ShardOwners. +type ShardOwners []ShardOwner + +// SimpleTableViewProperties defines model for SimpleTableViewProperties. +type SimpleTableViewProperties struct { + Note string `json:"note"` + Queries []DashboardQuery `json:"queries"` + Shape SimpleTableViewPropertiesShape `json:"shape"` + ShowAll bool `json:"showAll"` + + // If true, will display note when empty + ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` + Type SimpleTableViewPropertiesType `json:"type"` +} + +// SimpleTableViewPropertiesShape defines model for SimpleTableViewProperties.Shape. +type SimpleTableViewPropertiesShape string + +// SimpleTableViewPropertiesType defines model for SimpleTableViewProperties.Type. +type SimpleTableViewPropertiesType string + +// SingleStatViewProperties defines model for SingleStatViewProperties. +type SingleStatViewProperties struct { + // Colors define color encoding of data into a visualization + Colors []DashboardColor `json:"colors"` + + // Indicates whether decimal places should be enforced, and how many digits it should show. + DecimalPlaces DecimalPlaces `json:"decimalPlaces"` + Note string `json:"note"` + Prefix string `json:"prefix"` + Queries []DashboardQuery `json:"queries"` + Shape SingleStatViewPropertiesShape `json:"shape"` + + // If true, will display note when empty + ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` + + // StaticLegend represents the options specific to the static legend + StaticLegend *StaticLegend `json:"staticLegend,omitempty"` + Suffix string `json:"suffix"` + TickPrefix string `json:"tickPrefix"` + TickSuffix string `json:"tickSuffix"` + Type SingleStatViewPropertiesType `json:"type"` +} + +// SingleStatViewPropertiesShape defines model for SingleStatViewProperties.Shape. +type SingleStatViewPropertiesShape string + +// SingleStatViewPropertiesType defines model for SingleStatViewProperties.Type. +type SingleStatViewPropertiesType string + +// SlackNotificationEndpoint defines model for SlackNotificationEndpoint. +type SlackNotificationEndpoint struct { + // Embedded struct due to allOf(#/components/schemas/NotificationEndpointBase) + NotificationEndpointBase `yaml:",inline"` + // Embedded fields due to inline allOf schema + // Specifies the API token string. Specify either `URL` or `Token`. + Token *string `json:"token,omitempty"` + + // Specifies the URL of the Slack endpoint. Specify either `URL` or `Token`. + Url *string `json:"url,omitempty"` +} + +// SlackNotificationRule defines model for SlackNotificationRule. +type SlackNotificationRule struct { + // Embedded struct due to allOf(#/components/schemas/NotificationRuleBase) + NotificationRuleBase `yaml:",inline"` + // Embedded struct due to allOf(#/components/schemas/SlackNotificationRuleBase) + SlackNotificationRuleBase `yaml:",inline"` +} + +// SlackNotificationRuleBase defines model for SlackNotificationRuleBase. +type SlackNotificationRuleBase struct { + Channel *string `json:"channel,omitempty"` + MessageTemplate string `json:"messageTemplate"` + Type SlackNotificationRuleBaseType `json:"type"` +} + +// SlackNotificationRuleBaseType defines model for SlackNotificationRuleBase.Type. +type SlackNotificationRuleBaseType string + +// Source defines model for Source. +type Source struct { + Default *bool `json:"default,omitempty"` + DefaultRP *string `json:"defaultRP,omitempty"` + Id *string `json:"id,omitempty"` + InsecureSkipVerify *bool `json:"insecureSkipVerify,omitempty"` + Languages *[]SourceLanguages `json:"languages,omitempty"` + Links *struct { + Buckets *string `json:"buckets,omitempty"` + Health *string `json:"health,omitempty"` + Query *string `json:"query,omitempty"` + Self *string `json:"self,omitempty"` + } `json:"links,omitempty"` + MetaUrl *string `json:"metaUrl,omitempty"` + Name *string `json:"name,omitempty"` + OrgID *string `json:"orgID,omitempty"` + Password *string `json:"password,omitempty"` + SharedSecret *string `json:"sharedSecret,omitempty"` + Telegraf *string `json:"telegraf,omitempty"` + Token *string `json:"token,omitempty"` + Type *SourceType `json:"type,omitempty"` + Url *string `json:"url,omitempty"` + Username *string `json:"username,omitempty"` +} + +// SourceLanguages defines model for Source.Languages. +type SourceLanguages string + +// SourceType defines model for Source.Type. +type SourceType string + +// Sources defines model for Sources. +type Sources struct { + Links *struct { + Self *string `json:"self,omitempty"` + } `json:"links,omitempty"` + Sources *[]Source `json:"sources,omitempty"` +} + +// Stack defines model for Stack. +type Stack struct { + CreatedAt *time.Time `json:"createdAt,omitempty"` + Events *[]struct { + Description *string `json:"description,omitempty"` + EventType *string `json:"eventType,omitempty"` + Name *string `json:"name,omitempty"` + Resources *[]struct { + ApiVersion *string `json:"apiVersion,omitempty"` + Associations *[]struct { + Kind *TemplateKind `json:"kind,omitempty"` + MetaName *string `json:"metaName,omitempty"` + } `json:"associations,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + Links *struct { + Self *string `json:"self,omitempty"` + } `json:"links,omitempty"` + ResourceID *string `json:"resourceID,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"resources,omitempty"` + Sources *[]string `json:"sources,omitempty"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` + Urls *[]string `json:"urls,omitempty"` + } `json:"events,omitempty"` + Id *string `json:"id,omitempty"` + OrgID *string `json:"orgID,omitempty"` +} + +// Statement defines model for Statement. +type Statement interface{} + +// StaticLegend represents the options specific to the static legend +type StaticLegend struct { + ColorizeRows *bool `json:"colorizeRows,omitempty"` + HeightRatio *float32 `json:"heightRatio,omitempty"` + Opacity *float32 `json:"opacity,omitempty"` + OrientationThreshold *int `json:"orientationThreshold,omitempty"` + Show *bool `json:"show,omitempty"` + ValueAxis *string `json:"valueAxis,omitempty"` + WidthRatio *float32 `json:"widthRatio,omitempty"` +} + +// StatusRule defines model for StatusRule. +type StatusRule struct { + Count *int `json:"count,omitempty"` + + // The state to record if check matches a criteria. + CurrentLevel *RuleStatusLevel `json:"currentLevel,omitempty"` + Period *string `json:"period,omitempty"` + + // The state to record if check matches a criteria. + PreviousLevel *RuleStatusLevel `json:"previousLevel,omitempty"` +} + +// Expressions begin and end with double quote marks +type StringLiteral struct { + // Type of AST node + Type *NodeType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +// SubscriptionManifest defines model for SubscriptionManifest. +type SubscriptionManifest struct { + Destinations []string `json:"destinations"` + Mode string `json:"mode"` + Name string `json:"name"` +} + +// SubscriptionManifests defines model for SubscriptionManifests. +type SubscriptionManifests []SubscriptionManifest + +// TableViewProperties defines model for TableViewProperties. +type TableViewProperties struct { + // Colors define color encoding of data into a visualization + Colors []DashboardColor `json:"colors"` + + // Indicates whether decimal places should be enforced, and how many digits it should show. + DecimalPlaces DecimalPlaces `json:"decimalPlaces"` + + // fieldOptions represent the fields retrieved by the query with customization options + FieldOptions []RenamableField `json:"fieldOptions"` + Note string `json:"note"` + Queries []DashboardQuery `json:"queries"` + Shape TableViewPropertiesShape `json:"shape"` + + // If true, will display note when empty + ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` + TableOptions struct { + // fixFirstColumn indicates whether the first column of the table should be locked + FixFirstColumn *bool `json:"fixFirstColumn,omitempty"` + + // Describes a field that can be renamed and made visible or invisible. + SortBy *RenamableField `json:"sortBy,omitempty"` + + // verticalTimeAxis describes the orientation of the table by indicating whether the time axis will be displayed vertically + VerticalTimeAxis *bool `json:"verticalTimeAxis,omitempty"` + + // Wrapping describes the text wrapping style to be used in table views + Wrapping *TableViewPropertiesTableOptionsWrapping `json:"wrapping,omitempty"` + } `json:"tableOptions"` + + // timeFormat describes the display format for time values according to moment.js date formatting + TimeFormat string `json:"timeFormat"` + Type TableViewPropertiesType `json:"type"` +} + +// TableViewPropertiesShape defines model for TableViewProperties.Shape. +type TableViewPropertiesShape string + +// Wrapping describes the text wrapping style to be used in table views +type TableViewPropertiesTableOptionsWrapping string + +// TableViewPropertiesType defines model for TableViewProperties.Type. +type TableViewPropertiesType string + +// TagRule defines model for TagRule. +type TagRule struct { + Key *string `json:"key,omitempty"` + Operator *TagRuleOperator `json:"operator,omitempty"` + Value *string `json:"value,omitempty"` +} + +// TagRuleOperator defines model for TagRule.Operator. +type TagRuleOperator string + +// Task defines model for Task. +type Task struct { + // The ID of the authorization used when the task communicates with the query engine. + AuthorizationID *string `json:"authorizationID,omitempty"` + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // [Cron expression](https://en.wikipedia.org/wiki/Cron#Overview) that defines the schedule on which the task runs. InfluxDB bases cron runs on the system time. + Cron *string `json:"cron,omitempty"` + + // The description of the task. + Description *string `json:"description,omitempty"` + + // An interval ([duration literal](https://docs.influxdata.com/flux/v0.x/spec/lexical-elements/#duration-literals))) at which the task runs. `every` also determines when the task first runs, depending on the specified time. + Every *string `json:"every,omitempty"` + + // The Flux script that the task runs. + Flux string `json:"flux"` + Id string `json:"id"` + Labels *Labels `json:"labels,omitempty"` + LastRunError *string `json:"lastRunError,omitempty"` + LastRunStatus *TaskLastRunStatus `json:"lastRunStatus,omitempty"` + + // A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/flux/v0.x/data-types/basic/time/#time-syntax)) 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. + Logs *Link `json:"logs,omitempty"` + + // URI of resource. + Members *Link `json:"members,omitempty"` + + // URI of resource. + Owners *Link `json:"owners,omitempty"` + + // URI of resource. + Runs *Link `json:"runs,omitempty"` + + // URI of resource. + Self *Link `json:"self,omitempty"` + } `json:"links,omitempty"` + + // The name of the task. + Name string `json:"name"` + + // A [duration](https://docs.influxdata.com/flux/v0.x/spec/lexical-elements/#duration-literals) to delay execution of the task after the scheduled time has elapsed. `0` removes the offset. + Offset *string `json:"offset,omitempty"` + + // The name of the organization that owns the task. + Org *string `json:"org,omitempty"` + + // The ID of the organization that owns the task. + OrgID string `json:"orgID"` + + // The ID of the user who owns the Task. + OwnerID *string `json:"ownerID,omitempty"` + + // `inactive` cancels scheduled runs and prevents manual runs of the task. + Status *TaskStatusType `json:"status,omitempty"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` +} + +// TaskLastRunStatus defines model for Task.LastRunStatus. +type TaskLastRunStatus string + +// TaskCreateRequest defines model for TaskCreateRequest. +type TaskCreateRequest struct { + // An optional description of the task. + Description *string `json:"description,omitempty"` + + // The Flux script to run for this task. + Flux string `json:"flux"` + + // The name of the organization that owns this Task. + Org *string `json:"org,omitempty"` + + // The ID of the organization that owns this Task. + OrgID *string `json:"orgID,omitempty"` + + // `inactive` cancels scheduled runs and prevents manual runs of the task. + Status *TaskStatusType `json:"status,omitempty"` +} + +// `inactive` cancels scheduled runs and prevents manual runs of the task. +type TaskStatusType string + +// TaskUpdateRequest defines model for TaskUpdateRequest. +type TaskUpdateRequest struct { + // Update the 'cron' option in the flux script. + Cron *string `json:"cron,omitempty"` + + // Update the description of the task. + Description *string `json:"description,omitempty"` + + // Update the 'every' option in the flux script. + Every *string `json:"every,omitempty"` + + // The Flux script that the task runs. + Flux *string `json:"flux,omitempty"` + + // Update the 'name' option in the flux script. + Name *string `json:"name,omitempty"` + + // Update the 'offset' option in the flux script. + Offset *string `json:"offset,omitempty"` + + // `inactive` cancels scheduled runs and prevents manual runs of the task. + Status *TaskStatusType `json:"status,omitempty"` +} + +// Tasks defines model for Tasks. +type Tasks struct { + // URI pointers for additional paged results. + Links *Links `json:"links,omitempty"` + Tasks *[]Task `json:"tasks,omitempty"` +} + +// Telegraf defines model for Telegraf. +type Telegraf struct { + // Embedded struct due to allOf(#/components/schemas/TelegrafRequest) + TelegrafRequest `yaml:",inline"` + // Embedded fields due to inline allOf schema + Id *string `json:"id,omitempty"` + Labels *Labels `json:"labels,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. + Self *Link `json:"self,omitempty"` + } `json:"links,omitempty"` +} + +// TelegrafPlugin defines model for TelegrafPlugin. +type TelegrafPlugin struct { + Config *string `json:"config,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// TelegrafPluginRequest defines model for TelegrafPluginRequest. +type TelegrafPluginRequest struct { + Config *string `json:"config,omitempty"` + Description *string `json:"description,omitempty"` + Metadata *struct { + Buckets *[]string `json:"buckets,omitempty"` + } `json:"metadata,omitempty"` + Name *string `json:"name,omitempty"` + OrgID *string `json:"orgID,omitempty"` + Plugins *[]struct { + Alias *string `json:"alias,omitempty"` + Config *string `json:"config,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + } `json:"plugins,omitempty"` +} + +// TelegrafPlugins defines model for TelegrafPlugins. +type TelegrafPlugins struct { + Os *string `json:"os,omitempty"` + Plugins *[]TelegrafPlugin `json:"plugins,omitempty"` + Version *string `json:"version,omitempty"` +} + +// TelegrafRequest defines model for TelegrafRequest. +type TelegrafRequest struct { + Config *string `json:"config,omitempty"` + Description *string `json:"description,omitempty"` + Metadata *struct { + Buckets *[]string `json:"buckets,omitempty"` + } `json:"metadata,omitempty"` + Name *string `json:"name,omitempty"` + OrgID *string `json:"orgID,omitempty"` +} + +// Telegrafs defines model for Telegrafs. +type Telegrafs struct { + Configurations *[]Telegraf `json:"configurations,omitempty"` +} + +// TelegramNotificationEndpoint defines model for TelegramNotificationEndpoint. +type TelegramNotificationEndpoint struct { + // Embedded struct due to allOf(#/components/schemas/NotificationEndpointBase) + NotificationEndpointBase `yaml:",inline"` + // Embedded fields due to inline allOf schema + // The ID of the telegram channel; a chat_id in https://core.telegram.org/bots/api#sendmessage . + Channel string `json:"channel"` + + // Specifies the Telegram bot token. See https://core.telegram.org/bots#creating-a-new-bot . + Token string `json:"token"` +} + +// TelegramNotificationRule defines model for TelegramNotificationRule. +type TelegramNotificationRule struct { + // Embedded struct due to allOf(#/components/schemas/NotificationRuleBase) + NotificationRuleBase `yaml:",inline"` + // Embedded struct due to allOf(#/components/schemas/TelegramNotificationRuleBase) + TelegramNotificationRuleBase `yaml:",inline"` +} + +// TelegramNotificationRuleBase defines model for TelegramNotificationRuleBase. +type TelegramNotificationRuleBase struct { + // Disables preview of web links in the sent messages when "true". Defaults to "false". + DisableWebPagePreview *bool `json:"disableWebPagePreview,omitempty"` + + // The message template as a flux interpolated string. + MessageTemplate string `json:"messageTemplate"` + + // Parse mode of the message text per https://core.telegram.org/bots/api#formatting-options. Defaults to "MarkdownV2". + ParseMode *TelegramNotificationRuleBaseParseMode `json:"parseMode,omitempty"` + + // The discriminator between other types of notification rules is "telegram". + Type TelegramNotificationRuleBaseType `json:"type"` +} + +// Parse mode of the message text per https://core.telegram.org/bots/api#formatting-options. Defaults to "MarkdownV2". +type TelegramNotificationRuleBaseParseMode string + +// The discriminator between other types of notification rules is "telegram". +type TelegramNotificationRuleBaseType string + +// Template defines model for Template. +type Template []struct { + ApiVersion *string `json:"apiVersion,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + + // Metadata properties used for the resource when the template is applied. + Metadata *struct { + Name *string `json:"name,omitempty"` + } `json:"metadata,omitempty"` + + // Configuration properties used for the resource when the template is applied. + // Key-value pairs map to the specification for the resource. + // + // The following code samples show `spec` configurations for template resources: + // + // - A bucket: + // + // ```json + // { "spec": { + // "name": "iot_center", + // "retentionRules": [{ + // "everySeconds": 2.592e+06, + // "type": "expire" + // }] + // } + // } + // ``` + // + // - A variable: + // + // ```json + // { "spec": { + // "language": "flux", + // "name": "Node_Service", + // "query": "import \"influxdata/influxdb/v1\"\r\nv1.tagValues(bucket: \"iot_center\", + // tag: \"service\")", + // "type": "query" + // } + // } + // ``` + Spec *map[string]interface{} `json:"spec,omitempty"` +} + +// TemplateApply defines model for TemplateApply. +type TemplateApply struct { + // A list of `action` objects. + // Actions let you customize how InfluxDB applies templates in the request. + // + // You can use the following actions to prevent creating or updating resources: + // + // - A `skipKind` action skips template resources of a specified `kind`. + // - A `skipResource` action skips template resources with a specified `metadata.name` + // and `kind`. + Actions *[]interface{} `json:"actions,omitempty"` + + // Only applies a dry run of the templates passed in the request. + // + // - Validates the template and generates a resource diff and summary. + // - Doesn't install templates or make changes to the InfluxDB instance. + DryRun *bool `json:"dryRun,omitempty"` + + // An object with key-value pairs that map to **environment references** in templates. + // + // Environment references in templates are `envRef` objects with an `envRef.key` + // property. + // To substitute a custom environment reference value when applying templates, + // pass `envRefs` with the `envRef.key` and the value. + // + // When you apply a template, InfluxDB replaces `envRef` objects in the template + // with the values that you provide in the `envRefs` parameter. + // For more examples, see how to [define environment references](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/use/#define-environment-references). + // + // The following template fields may use environment references: + // + // - `metadata.name` + // - `spec.endpointName` + // - `spec.associations.name` + // + // For more information about including environment references in template fields, see how to + // [include user-definable resource names](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/create/#include-user-definable-resource-names). + EnvRefs *TemplateApply_EnvRefs `json:"envRefs,omitempty"` + + // Organization ID. + // InfluxDB applies templates to this organization. + // The organization owns all resources created by the template. + // + // To find your organization, see how to + // [view organizations](https://docs.influxdata.com/influxdb/v2.3/organizations/view-orgs/). + OrgID *string `json:"orgID,omitempty"` + + // A list of URLs for template files. + // + // To apply a template manifest file located at a URL, pass `remotes` + // with an array that contains the URL. + Remotes *[]struct { + ContentType *string `json:"contentType,omitempty"` + Url string `json:"url"` + } `json:"remotes,omitempty"` + + // An object with key-value pairs that map to **secrets** in queries. + // + // Queries may reference secrets stored in InfluxDB--for example, + // 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" + // + // 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", + // ) + // ``` + // + // 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" + // } + // ... + // } + // ``` + // + // 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. + // + // #### Related guides + // + // - [How to pass secrets when installing a template](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/use/#pass-secrets-when-installing-a-template) + Secrets *TemplateApply_Secrets `json:"secrets,omitempty"` + + // ID of the stack to update. + // + // To apply templates to an existing stack in the organization, use the `stackID` parameter. + // If you apply templates without providing a stack ID, + // InfluxDB initializes a new stack with all new resources. + // + // To find a stack ID, use the InfluxDB [`/api/v2/stacks` API endpoint](#operation/ListStacks) to list stacks. + // + // #### Related guides + // + // - [Stacks](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/stacks/) + // - [View stacks](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/stacks/view/) + StackID *string `json:"stackID,omitempty"` + + // A template object to apply. + // A template object has a `contents` property + // with an array of InfluxDB resource configurations. + // + // Pass `template` to apply only one template object. + // If you use `template`, you can't use the `templates` parameter. + // If you want to apply multiple template objects, use `templates` instead. + Template *struct { + ContentType *string `json:"contentType,omitempty"` + Contents *Template `json:"contents,omitempty"` + Sources *[]string `json:"sources,omitempty"` + } `json:"template,omitempty"` + + // A list of template objects to apply. + // A template object has a `contents` property + // with an array of InfluxDB resource configurations. + // + // Use the `templates` parameter to apply multiple template objects. + // If you use `templates`, you can't use the `template` parameter. + Templates *[]struct { + ContentType *string `json:"contentType,omitempty"` + Contents *Template `json:"contents,omitempty"` + Sources *[]string `json:"sources,omitempty"` + } `json:"templates,omitempty"` +} + +// An object with key-value pairs that map to **environment references** in templates. +// +// Environment references in templates are `envRef` objects with an `envRef.key` +// property. +// To substitute a custom environment reference value when applying templates, +// pass `envRefs` with the `envRef.key` and the value. +// +// When you apply a template, InfluxDB replaces `envRef` objects in the template +// with the values that you provide in the `envRefs` parameter. +// For more examples, see how to [define environment references](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/use/#define-environment-references). +// +// The following template fields may use environment references: +// +// - `metadata.name` +// - `spec.endpointName` +// - `spec.associations.name` +// +// For more information about including environment references in template fields, see how to +// [include user-definable resource names](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/create/#include-user-definable-resource-names). +type TemplateApply_EnvRefs struct { + AdditionalProperties map[string]interface{} `json:"-"` +} + +// An object with key-value pairs that map to **secrets** in queries. +// +// Queries may reference secrets stored in InfluxDB--for example, +// 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" +// +// 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", +// ) +// ``` +// +// 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" +// } +// ... +// } +// ``` +// +// 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. +// +// #### Related guides +// +// - [How to pass secrets when installing a template](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/use/#pass-secrets-when-installing-a-template) +type TemplateApply_Secrets struct { + AdditionalProperties map[string]string `json:"-"` +} + +// TemplateChart defines model for TemplateChart. +type TemplateChart struct { + Height *int `json:"height,omitempty"` + Properties *ViewProperties `json:"properties,omitempty"` + Width *int `json:"width,omitempty"` + XPos *int `json:"xPos,omitempty"` + YPos *int `json:"yPos,omitempty"` +} + +// TemplateEnvReferences defines model for TemplateEnvReferences. +type TemplateEnvReferences []struct { + // Default value that will be provided for the reference when no value is provided + DefaultValue *interface{} `json:"defaultValue"` + + // Key identified as environment reference and is the key identified in the template + EnvRefKey string `json:"envRefKey"` + + // Field the environment reference corresponds too + ResourceField string `json:"resourceField"` + + // Value provided to fulfill reference + Value *interface{} `json:"value"` +} + +// TemplateExportByID defines model for TemplateExportByID. +type TemplateExportByID struct { + OrgIDs *[]struct { + OrgID *string `json:"orgID,omitempty"` + ResourceFilters *struct { + ByLabel *[]string `json:"byLabel,omitempty"` + ByResourceKind *[]TemplateKind `json:"byResourceKind,omitempty"` + } `json:"resourceFilters,omitempty"` + } `json:"orgIDs,omitempty"` + Resources *[]struct { + Id string `json:"id"` + Kind TemplateKind `json:"kind"` + + // if defined with id, name is used for resource exported by id. if defined independently, resources strictly matching name are exported + Name *string `json:"name,omitempty"` + } `json:"resources,omitempty"` + StackID *string `json:"stackID,omitempty"` +} + +// TemplateExportByName defines model for TemplateExportByName. +type TemplateExportByName struct { + OrgIDs *[]struct { + OrgID *string `json:"orgID,omitempty"` + ResourceFilters *struct { + ByLabel *[]string `json:"byLabel,omitempty"` + ByResourceKind *[]TemplateKind `json:"byResourceKind,omitempty"` + } `json:"resourceFilters,omitempty"` + } `json:"orgIDs,omitempty"` + Resources *[]struct { + Kind TemplateKind `json:"kind"` + Name string `json:"name"` + } `json:"resources,omitempty"` + StackID *string `json:"stackID,omitempty"` +} + +// TemplateKind defines model for TemplateKind. +type TemplateKind string + +// TemplateSummary defines model for TemplateSummary. +type TemplateSummary struct { + Diff *struct { + Buckets *[]struct { + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + New *struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + + // Retention rules to expire or retain data. + // #### InfluxDB Cloud + // + // - `retentionRules` is required. + // + // #### InfluxDB OSS + // + // - `retentionRules` isn't required. + RetentionRules *RetentionRules `json:"retentionRules,omitempty"` + } `json:"new,omitempty"` + Old *struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + + // Retention rules to expire or retain data. + // #### InfluxDB Cloud + // + // - `retentionRules` is required. + // + // #### InfluxDB OSS + // + // - `retentionRules` isn't required. + RetentionRules *RetentionRules `json:"retentionRules,omitempty"` + } `json:"old,omitempty"` + StateStatus *string `json:"stateStatus,omitempty"` + 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"` + } `json:"checks,omitempty"` + Dashboards *[]struct { + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + New *struct { + Charts *[]TemplateChart `json:"charts,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + } `json:"new,omitempty"` + Old *struct { + Charts *[]TemplateChart `json:"charts,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + } `json:"old,omitempty"` + StateStatus *string `json:"stateStatus,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"dashboards,omitempty"` + LabelMappings *[]struct { + LabelID *string `json:"labelID,omitempty"` + LabelName *string `json:"labelName,omitempty"` + LabelTemplateMetaName *string `json:"labelTemplateMetaName,omitempty"` + ResourceID *string `json:"resourceID,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + ResourceTemplateMetaName *string `json:"resourceTemplateMetaName,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Status *string `json:"status,omitempty"` + } `json:"labelMappings,omitempty"` + Labels *[]struct { + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + New *struct { + Color *string `json:"color,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + } `json:"new,omitempty"` + Old *struct { + Color *string `json:"color,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + } `json:"old,omitempty"` + StateStatus *string `json:"stateStatus,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"labels,omitempty"` + NotificationEndpoints *[]struct { + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + New *NotificationEndpointDiscriminator `json:"new,omitempty"` + Old *NotificationEndpointDiscriminator `json:"old,omitempty"` + StateStatus *string `json:"stateStatus,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"notificationEndpoints,omitempty"` + NotificationRules *[]struct { + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + New *struct { + Description *string `json:"description,omitempty"` + EndpointID *string `json:"endpointID,omitempty"` + EndpointName *string `json:"endpointName,omitempty"` + EndpointType *string `json:"endpointType,omitempty"` + Every *string `json:"every,omitempty"` + MessageTemplate *string `json:"messageTemplate,omitempty"` + Name *string `json:"name,omitempty"` + Offset *string `json:"offset,omitempty"` + Status *string `json:"status,omitempty"` + StatusRules *[]struct { + CurrentLevel *string `json:"currentLevel,omitempty"` + PreviousLevel *string `json:"previousLevel,omitempty"` + } `json:"statusRules,omitempty"` + TagRules *[]struct { + Key *string `json:"key,omitempty"` + Operator *string `json:"operator,omitempty"` + Value *string `json:"value,omitempty"` + } `json:"tagRules,omitempty"` + } `json:"new,omitempty"` + Old *struct { + Description *string `json:"description,omitempty"` + EndpointID *string `json:"endpointID,omitempty"` + EndpointName *string `json:"endpointName,omitempty"` + EndpointType *string `json:"endpointType,omitempty"` + Every *string `json:"every,omitempty"` + MessageTemplate *string `json:"messageTemplate,omitempty"` + Name *string `json:"name,omitempty"` + Offset *string `json:"offset,omitempty"` + Status *string `json:"status,omitempty"` + StatusRules *[]struct { + CurrentLevel *string `json:"currentLevel,omitempty"` + PreviousLevel *string `json:"previousLevel,omitempty"` + } `json:"statusRules,omitempty"` + TagRules *[]struct { + Key *string `json:"key,omitempty"` + Operator *string `json:"operator,omitempty"` + Value *string `json:"value,omitempty"` + } `json:"tagRules,omitempty"` + } `json:"old,omitempty"` + StateStatus *string `json:"stateStatus,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"notificationRules,omitempty"` + Tasks *[]struct { + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + New *struct { + Cron *string `json:"cron,omitempty"` + Description *string `json:"description,omitempty"` + Every *string `json:"every,omitempty"` + Name *string `json:"name,omitempty"` + Offset *string `json:"offset,omitempty"` + Query *string `json:"query,omitempty"` + Status *string `json:"status,omitempty"` + } `json:"new,omitempty"` + Old *struct { + Cron *string `json:"cron,omitempty"` + Description *string `json:"description,omitempty"` + Every *string `json:"every,omitempty"` + Name *string `json:"name,omitempty"` + Offset *string `json:"offset,omitempty"` + Query *string `json:"query,omitempty"` + Status *string `json:"status,omitempty"` + } `json:"old,omitempty"` + StateStatus *string `json:"stateStatus,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"tasks,omitempty"` + TelegrafConfigs *[]struct { + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + New *TelegrafRequest `json:"new,omitempty"` + Old *TelegrafRequest `json:"old,omitempty"` + StateStatus *string `json:"stateStatus,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"telegrafConfigs,omitempty"` + Variables *[]struct { + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + New *struct { + Args *VariableProperties `json:"args,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + } `json:"new,omitempty"` + Old *struct { + Args *VariableProperties `json:"args,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + } `json:"old,omitempty"` + StateStatus *string `json:"stateStatus,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"variables,omitempty"` + } `json:"diff,omitempty"` + Errors *[]struct { + Fields *[]string `json:"fields,omitempty"` + Indexes *[]int `json:"indexes,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + Reason *string `json:"reason,omitempty"` + } `json:"errors,omitempty"` + Sources *[]string `json:"sources,omitempty"` + StackID *string `json:"stackID,omitempty"` + Summary *struct { + Buckets *[]struct { + Description *string `json:"description,omitempty"` + EnvReferences *TemplateEnvReferences `json:"envReferences,omitempty"` + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + LabelAssociations *[]TemplateSummaryLabel `json:"labelAssociations,omitempty"` + Name *string `json:"name,omitempty"` + OrgID *string `json:"orgID,omitempty"` + RetentionPeriod *int `json:"retentionPeriod,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"buckets,omitempty"` + Checks *[]struct { + // Embedded struct due to allOf(#/components/schemas/CheckDiscriminator) + CheckDiscriminator `yaml:",inline"` + // Embedded fields due to inline allOf schema + EnvReferences *TemplateEnvReferences `json:"envReferences,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + LabelAssociations *[]TemplateSummaryLabel `json:"labelAssociations,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"checks,omitempty"` + Dashboards *[]struct { + Charts *[]TemplateChart `json:"charts,omitempty"` + Description *string `json:"description,omitempty"` + EnvReferences *TemplateEnvReferences `json:"envReferences,omitempty"` + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + LabelAssociations *[]TemplateSummaryLabel `json:"labelAssociations,omitempty"` + Name *string `json:"name,omitempty"` + OrgID *string `json:"orgID,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"dashboards,omitempty"` + LabelMappings *[]struct { + LabelID *string `json:"labelID,omitempty"` + LabelName *string `json:"labelName,omitempty"` + LabelTemplateMetaName *string `json:"labelTemplateMetaName,omitempty"` + ResourceID *string `json:"resourceID,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + ResourceTemplateMetaName *string `json:"resourceTemplateMetaName,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Status *string `json:"status,omitempty"` + } `json:"labelMappings,omitempty"` + Labels *[]TemplateSummaryLabel `json:"labels,omitempty"` + MissingEnvRefs *[]string `json:"missingEnvRefs,omitempty"` + MissingSecrets *[]string `json:"missingSecrets,omitempty"` + NotificationEndpoints *[]struct { + // Embedded struct due to allOf(#/components/schemas/NotificationEndpointDiscriminator) + NotificationEndpointDiscriminator `yaml:",inline"` + // Embedded fields due to inline allOf schema + EnvReferences *TemplateEnvReferences `json:"envReferences,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + LabelAssociations *[]TemplateSummaryLabel `json:"labelAssociations,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"notificationEndpoints,omitempty"` + NotificationRules *[]struct { + Description *string `json:"description,omitempty"` + EndpointID *string `json:"endpointID,omitempty"` + EndpointTemplateMetaName *string `json:"endpointTemplateMetaName,omitempty"` + EndpointType *string `json:"endpointType,omitempty"` + EnvReferences *TemplateEnvReferences `json:"envReferences,omitempty"` + Every *string `json:"every,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + LabelAssociations *[]TemplateSummaryLabel `json:"labelAssociations,omitempty"` + MessageTemplate *string `json:"messageTemplate,omitempty"` + Name *string `json:"name,omitempty"` + Offset *string `json:"offset,omitempty"` + Status *string `json:"status,omitempty"` + StatusRules *[]struct { + CurrentLevel *string `json:"currentLevel,omitempty"` + PreviousLevel *string `json:"previousLevel,omitempty"` + } `json:"statusRules,omitempty"` + TagRules *[]struct { + Key *string `json:"key,omitempty"` + Operator *string `json:"operator,omitempty"` + Value *string `json:"value,omitempty"` + } `json:"tagRules,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"notificationRules,omitempty"` + Tasks *[]struct { + Cron *string `json:"cron,omitempty"` + Description *string `json:"description,omitempty"` + EnvReferences *TemplateEnvReferences `json:"envReferences,omitempty"` + Every *string `json:"every,omitempty"` + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Offset *string `json:"offset,omitempty"` + Query *string `json:"query,omitempty"` + Status *string `json:"status,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"tasks,omitempty"` + TelegrafConfigs *[]struct { + // Embedded struct due to allOf(#/components/schemas/TelegrafRequest) + TelegrafRequest `yaml:",inline"` + // Embedded fields due to inline allOf schema + EnvReferences *TemplateEnvReferences `json:"envReferences,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + LabelAssociations *[]TemplateSummaryLabel `json:"labelAssociations,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"telegrafConfigs,omitempty"` + Variables *[]struct { + Arguments *VariableProperties `json:"arguments,omitempty"` + Description *string `json:"description,omitempty"` + EnvReferences *TemplateEnvReferences `json:"envReferences,omitempty"` + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + LabelAssociations *[]TemplateSummaryLabel `json:"labelAssociations,omitempty"` + Name *string `json:"name,omitempty"` + OrgID *string `json:"orgID,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"variables,omitempty"` + } `json:"summary,omitempty"` +} + +// TemplateSummaryLabel defines model for TemplateSummaryLabel. +type TemplateSummaryLabel struct { + EnvReferences *TemplateEnvReferences `json:"envReferences,omitempty"` + Id *string `json:"id,omitempty"` + Kind *TemplateKind `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + OrgID *string `json:"orgID,omitempty"` + Properties *struct { + Color *string `json:"color,omitempty"` + Description *string `json:"description,omitempty"` + } `json:"properties,omitempty"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` +} + +// Declares a Flux test case +type TestStatement struct { + // Represents the declaration of a variable + Assignment *VariableAssignment `json:"assignment,omitempty"` + + // Type of AST node + 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"` + Operator *string `json:"operator,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// Represents integer numbers +type UnsignedIntegerLiteral struct { + // Type of AST node + Type *NodeType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +// User defines model for User. +type User struct { + Id *string `json:"id,omitempty"` + Name string `json:"name"` + OauthID *string `json:"oauthID,omitempty"` + + // If inactive the user is inactive. + Status *UserStatus `json:"status,omitempty"` +} + +// If inactive the user is inactive. +type UserStatus string + +// UserResponse defines model for UserResponse. +type UserResponse struct { + // The ID of the user. + Id *string `json:"id,omitempty"` + Links *struct { + Self *string `json:"self,omitempty"` + } `json:"links,omitempty"` + + // The name of the user. + Name string `json:"name"` + + // The status of a user. An inactive user won't have access to resources. + Status *UserResponseStatus `json:"status,omitempty"` +} + +// The status of a user. An inactive user won't have access to resources. +type UserResponseStatus string + +// Users defines model for Users. +type Users struct { + Links *struct { + Self *string `json:"self,omitempty"` + } `json:"links,omitempty"` + Users *[]UserResponse `json:"users,omitempty"` +} + +// Variable defines model for Variable. +type Variable struct { + Arguments VariableProperties `json:"arguments"` + CreatedAt *time.Time `json:"createdAt,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Labels *Labels `json:"labels,omitempty"` + Links *struct { + Labels *string `json:"labels,omitempty"` + Org *string `json:"org,omitempty"` + Self *string `json:"self,omitempty"` + } `json:"links,omitempty"` + Name string `json:"name"` + OrgID string `json:"orgID"` + Selected *[]string `json:"selected,omitempty"` + UpdatedAt *time.Time `json:"updatedAt,omitempty"` +} + +// Represents the declaration of a variable +type VariableAssignment struct { + // A valid Flux identifier + Id *Identifier `json:"id,omitempty"` + Init *Expression `json:"init,omitempty"` + + // Type of AST node + Type *NodeType `json:"type,omitempty"` +} + +// VariableProperties defines model for VariableProperties. +type VariableProperties interface{} + +// Variables defines model for Variables. +type Variables struct { + Variables *[]Variable `json:"variables,omitempty"` +} + +// View defines model for View. +type View struct { + Id *string `json:"id,omitempty"` + Links *struct { + Self *string `json:"self,omitempty"` + } `json:"links,omitempty"` + Name string `json:"name"` + Properties ViewProperties `json:"properties"` +} + +// ViewProperties defines model for ViewProperties. +type ViewProperties interface{} + +// WritePrecision defines model for WritePrecision. +type WritePrecision string + +// XYGeom defines model for XYGeom. +type XYGeom string + +// XYViewProperties defines model for XYViewProperties. +type XYViewProperties struct { + AdaptiveZoomHide *bool `json:"adaptiveZoomHide,omitempty"` + + // The viewport for a View's visualizations + Axes Axes `json:"axes"` + + // 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. + ColorMapping *ColorMapping `json:"colorMapping,omitempty"` + + // Colors define color encoding of data into a visualization + Colors []DashboardColor `json:"colors"` + GenerateXAxisTicks *[]string `json:"generateXAxisTicks,omitempty"` + GenerateYAxisTicks *[]string `json:"generateYAxisTicks,omitempty"` + Geom XYGeom `json:"geom"` + HoverDimension *XYViewPropertiesHoverDimension `json:"hoverDimension,omitempty"` + LegendColorizeRows *bool `json:"legendColorizeRows,omitempty"` + LegendHide *bool `json:"legendHide,omitempty"` + LegendOpacity *float32 `json:"legendOpacity,omitempty"` + LegendOrientationThreshold *int `json:"legendOrientationThreshold,omitempty"` + Note string `json:"note"` + Position XYViewPropertiesPosition `json:"position"` + Queries []DashboardQuery `json:"queries"` + ShadeBelow *bool `json:"shadeBelow,omitempty"` + Shape XYViewPropertiesShape `json:"shape"` + + // If true, will display note when empty + ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` + + // StaticLegend represents the options specific to the static legend + StaticLegend *StaticLegend `json:"staticLegend,omitempty"` + TimeFormat *string `json:"timeFormat,omitempty"` + Type XYViewPropertiesType `json:"type"` + XColumn *string `json:"xColumn,omitempty"` + XTickStart *float32 `json:"xTickStart,omitempty"` + XTickStep *float32 `json:"xTickStep,omitempty"` + XTotalTicks *int `json:"xTotalTicks,omitempty"` + YColumn *string `json:"yColumn,omitempty"` + YTickStart *float32 `json:"yTickStart,omitempty"` + YTickStep *float32 `json:"yTickStep,omitempty"` + YTotalTicks *int `json:"yTotalTicks,omitempty"` +} + +// XYViewPropertiesHoverDimension defines model for XYViewProperties.HoverDimension. +type XYViewPropertiesHoverDimension string + +// XYViewPropertiesPosition defines model for XYViewProperties.Position. +type XYViewPropertiesPosition string + +// XYViewPropertiesShape defines model for XYViewProperties.Shape. +type XYViewPropertiesShape string + +// XYViewPropertiesType defines model for XYViewProperties.Type. +type XYViewPropertiesType string + +// After defines model for After. +type After string + +// Descending defines model for Descending. +type Descending bool + +// Limit defines model for Limit. +type Limit int + +// Offset defines model for Offset. +type Offset int + +// TraceSpan defines model for TraceSpan. +type TraceSpan string + +// AuthorizationError defines model for AuthorizationError. +type AuthorizationError struct { + // The HTTP status code description. Default is `unauthorized`. + Code *AuthorizationErrorCode `json:"code,omitempty"` + + // A human-readable message that may contain detail about the error. + Message *string `json:"message,omitempty"` +} + +// The HTTP status code description. Default is `unauthorized`. +type AuthorizationErrorCode string + +// BadRequestError defines model for BadRequestError. +type BadRequestError Error + +// GeneralServerError defines model for GeneralServerError. +type GeneralServerError Error + +// InternalServerError defines model for InternalServerError. +type InternalServerError Error + +// ResourceNotFoundError defines model for ResourceNotFoundError. +type ResourceNotFoundError Error + +// GetAuthorizationsParams defines parameters for GetAuthorizations. +type GetAuthorizationsParams struct { + // A user ID. + // Only returns authorizations scoped to this user. + UserID *string `json:"userID,omitempty"` + + // A user name. + // Only returns authorizations scoped to this user. + User *string `json:"user,omitempty"` + + // An organization ID. Only returns authorizations that belong to this organization. + OrgID *string `json:"orgID,omitempty"` + + // An organization name. + // Only returns authorizations that belong to this organization. + Org *string `json:"org,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostAuthorizationsJSONBody defines parameters for PostAuthorizations. +type PostAuthorizationsJSONBody AuthorizationPostRequest + +// PostAuthorizationsParams defines parameters for PostAuthorizations. +type PostAuthorizationsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostAuthorizationsAllParams defines type for all parameters for PostAuthorizations. +type PostAuthorizationsAllParams struct { + PostAuthorizationsParams + + Body PostAuthorizationsJSONRequestBody +} + +// DeleteAuthorizationsIDParams defines parameters for DeleteAuthorizationsID. +type DeleteAuthorizationsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteAuthorizationsIDAllParams defines type for all parameters for DeleteAuthorizationsID. +type DeleteAuthorizationsIDAllParams struct { + DeleteAuthorizationsIDParams + + AuthID string +} + +// GetAuthorizationsIDParams defines parameters for GetAuthorizationsID. +type GetAuthorizationsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetAuthorizationsIDAllParams defines type for all parameters for GetAuthorizationsID. +type GetAuthorizationsIDAllParams struct { + GetAuthorizationsIDParams + + AuthID string +} + +// PatchAuthorizationsIDJSONBody defines parameters for PatchAuthorizationsID. +type PatchAuthorizationsIDJSONBody AuthorizationUpdateRequest + +// PatchAuthorizationsIDParams defines parameters for PatchAuthorizationsID. +type PatchAuthorizationsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchAuthorizationsIDAllParams defines type for all parameters for PatchAuthorizationsID. +type PatchAuthorizationsIDAllParams struct { + PatchAuthorizationsIDParams + + AuthID string + + Body PatchAuthorizationsIDJSONRequestBody +} + +// GetBucketsParams defines parameters for GetBuckets. +type GetBucketsParams 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"` + + // Resource ID to seek from. Results are not inclusive of this ID. Use `after` instead of `offset`. + After *After `json:"after,omitempty"` + + // Organization name. + // The name of the organization. + // + // #### InfluxDB Cloud + // + // - Doesn't use `org` or `orgID`. + // - Creates a bucket in the organization associated with the authorization (API token). + // + // #### InfluxDB OSS + // + // - Accepts either `org` or `orgID`. + // - InfluxDB creates the bucket within this organization. + Org *string `json:"org,omitempty"` + + // Organization ID. + // The organization ID. + // + // #### InfluxDB Cloud + // + // - Doesn't use `org` or `orgID`. + // - Creates a bucket in the organization associated with the authorization (API token). + // + // #### InfluxDB OSS + // + // - Accepts either `org` or `orgID`. + // - InfluxDB creates the bucket within this organization. + OrgID *string `json:"orgID,omitempty"` + + // Bucket name. + // Only returns buckets with this specific name. + Name *string `json:"name,omitempty"` + + // Bucket ID. + // Only returns the bucket with this ID. + Id *string `json:"id,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostBucketsJSONBody defines parameters for PostBuckets. +type PostBucketsJSONBody PostBucketRequest + +// PostBucketsParams defines parameters for PostBuckets. +type PostBucketsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostBucketsAllParams defines type for all parameters for PostBuckets. +type PostBucketsAllParams struct { + PostBucketsParams + + Body PostBucketsJSONRequestBody +} + +// DeleteBucketsIDParams defines parameters for DeleteBucketsID. +type DeleteBucketsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteBucketsIDAllParams defines type for all parameters for DeleteBucketsID. +type DeleteBucketsIDAllParams struct { + DeleteBucketsIDParams + + BucketID string +} + +// GetBucketsIDParams defines parameters for GetBucketsID. +type GetBucketsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetBucketsIDAllParams defines type for all parameters for GetBucketsID. +type GetBucketsIDAllParams struct { + GetBucketsIDParams + + BucketID string +} + +// PatchBucketsIDJSONBody defines parameters for PatchBucketsID. +type PatchBucketsIDJSONBody PatchBucketRequest + +// PatchBucketsIDParams defines parameters for PatchBucketsID. +type PatchBucketsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchBucketsIDAllParams defines type for all parameters for PatchBucketsID. +type PatchBucketsIDAllParams struct { + PatchBucketsIDParams + + BucketID string + + Body PatchBucketsIDJSONRequestBody +} + +// GetBucketsIDLabelsParams defines parameters for GetBucketsIDLabels. +type GetBucketsIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetBucketsIDLabelsAllParams defines type for all parameters for GetBucketsIDLabels. +type GetBucketsIDLabelsAllParams struct { + GetBucketsIDLabelsParams + + BucketID string +} + +// PostBucketsIDLabelsJSONBody defines parameters for PostBucketsIDLabels. +type PostBucketsIDLabelsJSONBody LabelMapping + +// PostBucketsIDLabelsParams defines parameters for PostBucketsIDLabels. +type PostBucketsIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostBucketsIDLabelsAllParams defines type for all parameters for PostBucketsIDLabels. +type PostBucketsIDLabelsAllParams struct { + PostBucketsIDLabelsParams + + BucketID string + + Body PostBucketsIDLabelsJSONRequestBody +} + +// DeleteBucketsIDLabelsIDParams defines parameters for DeleteBucketsIDLabelsID. +type DeleteBucketsIDLabelsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteBucketsIDLabelsIDAllParams defines type for all parameters for DeleteBucketsIDLabelsID. +type DeleteBucketsIDLabelsIDAllParams struct { + DeleteBucketsIDLabelsIDParams + + BucketID string + + LabelID string +} + +// GetBucketsIDMembersParams defines parameters for GetBucketsIDMembers. +type GetBucketsIDMembersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetBucketsIDMembersAllParams defines type for all parameters for GetBucketsIDMembers. +type GetBucketsIDMembersAllParams struct { + GetBucketsIDMembersParams + + BucketID string +} + +// PostBucketsIDMembersJSONBody defines parameters for PostBucketsIDMembers. +type PostBucketsIDMembersJSONBody AddResourceMemberRequestBody + +// PostBucketsIDMembersParams defines parameters for PostBucketsIDMembers. +type PostBucketsIDMembersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostBucketsIDMembersAllParams defines type for all parameters for PostBucketsIDMembers. +type PostBucketsIDMembersAllParams struct { + PostBucketsIDMembersParams + + BucketID string + + Body PostBucketsIDMembersJSONRequestBody +} + +// DeleteBucketsIDMembersIDParams defines parameters for DeleteBucketsIDMembersID. +type DeleteBucketsIDMembersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteBucketsIDMembersIDAllParams defines type for all parameters for DeleteBucketsIDMembersID. +type DeleteBucketsIDMembersIDAllParams struct { + DeleteBucketsIDMembersIDParams + + BucketID string + + UserID string +} + +// GetBucketsIDOwnersParams defines parameters for GetBucketsIDOwners. +type GetBucketsIDOwnersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetBucketsIDOwnersAllParams defines type for all parameters for GetBucketsIDOwners. +type GetBucketsIDOwnersAllParams struct { + GetBucketsIDOwnersParams + + BucketID string +} + +// PostBucketsIDOwnersJSONBody defines parameters for PostBucketsIDOwners. +type PostBucketsIDOwnersJSONBody AddResourceMemberRequestBody + +// PostBucketsIDOwnersParams defines parameters for PostBucketsIDOwners. +type PostBucketsIDOwnersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostBucketsIDOwnersAllParams defines type for all parameters for PostBucketsIDOwners. +type PostBucketsIDOwnersAllParams struct { + PostBucketsIDOwnersParams + + BucketID string + + Body PostBucketsIDOwnersJSONRequestBody +} + +// DeleteBucketsIDOwnersIDParams defines parameters for DeleteBucketsIDOwnersID. +type DeleteBucketsIDOwnersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteBucketsIDOwnersIDAllParams defines type for all parameters for DeleteBucketsIDOwnersID. +type DeleteBucketsIDOwnersIDAllParams struct { + DeleteBucketsIDOwnersIDParams + + BucketID string + + 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 + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetDashboardsParams defines parameters for GetDashboards. +type GetDashboardsParams 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"` + Descending *Descending `json:"descending,omitempty"` + + // A user identifier. Returns only dashboards where this user has the `owner` role. + Owner *string `json:"owner,omitempty"` + + // The column to sort by. + SortBy *GetDashboardsParamsSortBy `json:"sortBy,omitempty"` + + // A list of dashboard identifiers. Returns only the listed dashboards. If both `id` and `owner` are specified, only `id` is used. + Id *[]string `json:"id,omitempty"` + + // The identifier of the organization. + OrgID *string `json:"orgID,omitempty"` + + // The name of the organization. + Org *string `json:"org,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetDashboardsParamsSortBy defines parameters for GetDashboards. +type GetDashboardsParamsSortBy string + +// DeleteDashboardsIDParams defines parameters for DeleteDashboardsID. +type DeleteDashboardsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteDashboardsIDAllParams defines type for all parameters for DeleteDashboardsID. +type DeleteDashboardsIDAllParams struct { + DeleteDashboardsIDParams + + DashboardID string +} + +// PatchDashboardsIDJSONBody defines parameters for PatchDashboardsID. +type PatchDashboardsIDJSONBody struct { + Cells *CellWithViewProperties `json:"cells,omitempty"` + + // optional, when provided will replace the description + Description *string `json:"description,omitempty"` + + // optional, when provided will replace the name + Name *string `json:"name,omitempty"` +} + +// PatchDashboardsIDParams defines parameters for PatchDashboardsID. +type PatchDashboardsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchDashboardsIDAllParams defines type for all parameters for PatchDashboardsID. +type PatchDashboardsIDAllParams struct { + PatchDashboardsIDParams + + DashboardID string + + Body PatchDashboardsIDJSONRequestBody +} + +// PostDashboardsIDCellsJSONBody defines parameters for PostDashboardsIDCells. +type PostDashboardsIDCellsJSONBody CreateCell + +// PostDashboardsIDCellsParams defines parameters for PostDashboardsIDCells. +type PostDashboardsIDCellsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostDashboardsIDCellsAllParams defines type for all parameters for PostDashboardsIDCells. +type PostDashboardsIDCellsAllParams struct { + PostDashboardsIDCellsParams + + DashboardID string + + Body PostDashboardsIDCellsJSONRequestBody +} + +// PutDashboardsIDCellsJSONBody defines parameters for PutDashboardsIDCells. +type PutDashboardsIDCellsJSONBody Cells + +// PutDashboardsIDCellsParams defines parameters for PutDashboardsIDCells. +type PutDashboardsIDCellsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PutDashboardsIDCellsAllParams defines type for all parameters for PutDashboardsIDCells. +type PutDashboardsIDCellsAllParams struct { + PutDashboardsIDCellsParams + + DashboardID string + + Body PutDashboardsIDCellsJSONRequestBody +} + +// DeleteDashboardsIDCellsIDParams defines parameters for DeleteDashboardsIDCellsID. +type DeleteDashboardsIDCellsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteDashboardsIDCellsIDAllParams defines type for all parameters for DeleteDashboardsIDCellsID. +type DeleteDashboardsIDCellsIDAllParams struct { + DeleteDashboardsIDCellsIDParams + + DashboardID string + + CellID string +} + +// PatchDashboardsIDCellsIDJSONBody defines parameters for PatchDashboardsIDCellsID. +type PatchDashboardsIDCellsIDJSONBody CellUpdate + +// PatchDashboardsIDCellsIDParams defines parameters for PatchDashboardsIDCellsID. +type PatchDashboardsIDCellsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchDashboardsIDCellsIDAllParams defines type for all parameters for PatchDashboardsIDCellsID. +type PatchDashboardsIDCellsIDAllParams struct { + PatchDashboardsIDCellsIDParams + + DashboardID string + + CellID string + + Body PatchDashboardsIDCellsIDJSONRequestBody +} + +// GetDashboardsIDCellsIDViewParams defines parameters for GetDashboardsIDCellsIDView. +type GetDashboardsIDCellsIDViewParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetDashboardsIDCellsIDViewAllParams defines type for all parameters for GetDashboardsIDCellsIDView. +type GetDashboardsIDCellsIDViewAllParams struct { + GetDashboardsIDCellsIDViewParams + + DashboardID string + + CellID string +} + +// PatchDashboardsIDCellsIDViewJSONBody defines parameters for PatchDashboardsIDCellsIDView. +type PatchDashboardsIDCellsIDViewJSONBody View + +// PatchDashboardsIDCellsIDViewParams defines parameters for PatchDashboardsIDCellsIDView. +type PatchDashboardsIDCellsIDViewParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchDashboardsIDCellsIDViewAllParams defines type for all parameters for PatchDashboardsIDCellsIDView. +type PatchDashboardsIDCellsIDViewAllParams struct { + PatchDashboardsIDCellsIDViewParams + + DashboardID string + + CellID string + + Body PatchDashboardsIDCellsIDViewJSONRequestBody +} + +// GetDashboardsIDLabelsParams defines parameters for GetDashboardsIDLabels. +type GetDashboardsIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetDashboardsIDLabelsAllParams defines type for all parameters for GetDashboardsIDLabels. +type GetDashboardsIDLabelsAllParams struct { + GetDashboardsIDLabelsParams + + DashboardID string +} + +// PostDashboardsIDLabelsJSONBody defines parameters for PostDashboardsIDLabels. +type PostDashboardsIDLabelsJSONBody LabelMapping + +// PostDashboardsIDLabelsParams defines parameters for PostDashboardsIDLabels. +type PostDashboardsIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostDashboardsIDLabelsAllParams defines type for all parameters for PostDashboardsIDLabels. +type PostDashboardsIDLabelsAllParams struct { + PostDashboardsIDLabelsParams + + DashboardID string + + Body PostDashboardsIDLabelsJSONRequestBody +} + +// DeleteDashboardsIDLabelsIDParams defines parameters for DeleteDashboardsIDLabelsID. +type DeleteDashboardsIDLabelsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteDashboardsIDLabelsIDAllParams defines type for all parameters for DeleteDashboardsIDLabelsID. +type DeleteDashboardsIDLabelsIDAllParams struct { + DeleteDashboardsIDLabelsIDParams + + DashboardID string + + LabelID string +} + +// GetDashboardsIDMembersParams defines parameters for GetDashboardsIDMembers. +type GetDashboardsIDMembersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetDashboardsIDMembersAllParams defines type for all parameters for GetDashboardsIDMembers. +type GetDashboardsIDMembersAllParams struct { + GetDashboardsIDMembersParams + + DashboardID string +} + +// PostDashboardsIDMembersJSONBody defines parameters for PostDashboardsIDMembers. +type PostDashboardsIDMembersJSONBody AddResourceMemberRequestBody + +// PostDashboardsIDMembersParams defines parameters for PostDashboardsIDMembers. +type PostDashboardsIDMembersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostDashboardsIDMembersAllParams defines type for all parameters for PostDashboardsIDMembers. +type PostDashboardsIDMembersAllParams struct { + PostDashboardsIDMembersParams + + DashboardID string + + Body PostDashboardsIDMembersJSONRequestBody +} + +// DeleteDashboardsIDMembersIDParams defines parameters for DeleteDashboardsIDMembersID. +type DeleteDashboardsIDMembersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteDashboardsIDMembersIDAllParams defines type for all parameters for DeleteDashboardsIDMembersID. +type DeleteDashboardsIDMembersIDAllParams struct { + DeleteDashboardsIDMembersIDParams + + DashboardID string + + UserID string +} + +// GetDashboardsIDOwnersParams defines parameters for GetDashboardsIDOwners. +type GetDashboardsIDOwnersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetDashboardsIDOwnersAllParams defines type for all parameters for GetDashboardsIDOwners. +type GetDashboardsIDOwnersAllParams struct { + GetDashboardsIDOwnersParams + + DashboardID string +} + +// PostDashboardsIDOwnersJSONBody defines parameters for PostDashboardsIDOwners. +type PostDashboardsIDOwnersJSONBody AddResourceMemberRequestBody + +// PostDashboardsIDOwnersParams defines parameters for PostDashboardsIDOwners. +type PostDashboardsIDOwnersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostDashboardsIDOwnersAllParams defines type for all parameters for PostDashboardsIDOwners. +type PostDashboardsIDOwnersAllParams struct { + PostDashboardsIDOwnersParams + + DashboardID string + + Body PostDashboardsIDOwnersJSONRequestBody +} + +// DeleteDashboardsIDOwnersIDParams defines parameters for DeleteDashboardsIDOwnersID. +type DeleteDashboardsIDOwnersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteDashboardsIDOwnersIDAllParams defines type for all parameters for DeleteDashboardsIDOwnersID. +type DeleteDashboardsIDOwnersIDAllParams struct { + DeleteDashboardsIDOwnersIDParams + + DashboardID string + + UserID string +} + +// GetDBRPsParams defines parameters for GetDBRPs. +type GetDBRPsParams struct { + // Specifies the organization ID to filter on + OrgID *string `json:"orgID,omitempty"` + + // Specifies the organization name to filter on + Org *string `json:"org,omitempty"` + + // Specifies the mapping ID to filter on + Id *string `json:"id,omitempty"` + + // Specifies the bucket ID to filter on + BucketID *string `json:"bucketID,omitempty"` + + // Specifies filtering on default + Default *bool `json:"default,omitempty"` + + // Specifies the database to filter on + Db *string `json:"db,omitempty"` + + // Specifies the retention policy to filter on + Rp *string `json:"rp,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostDBRPJSONBody defines parameters for PostDBRP. +type PostDBRPJSONBody DBRPCreate + +// PostDBRPParams defines parameters for PostDBRP. +type PostDBRPParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostDBRPAllParams defines type for all parameters for PostDBRP. +type PostDBRPAllParams struct { + PostDBRPParams + + Body PostDBRPJSONRequestBody +} + +// DeleteDBRPIDParams defines parameters for DeleteDBRPID. +type DeleteDBRPIDParams struct { + // Specifies the organization ID of the mapping + OrgID *string `json:"orgID,omitempty"` + + // Specifies the organization name of the mapping + Org *string `json:"org,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteDBRPIDAllParams defines type for all parameters for DeleteDBRPID. +type DeleteDBRPIDAllParams struct { + DeleteDBRPIDParams + + DbrpID string +} + +// GetDBRPsIDParams defines parameters for GetDBRPsID. +type GetDBRPsIDParams struct { + // Specifies the organization ID of the mapping + OrgID *string `json:"orgID,omitempty"` + + // Specifies the organization name of the mapping + Org *string `json:"org,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetDBRPsIDAllParams defines type for all parameters for GetDBRPsID. +type GetDBRPsIDAllParams struct { + GetDBRPsIDParams + + DbrpID string +} + +// PatchDBRPIDJSONBody defines parameters for PatchDBRPID. +type PatchDBRPIDJSONBody DBRPUpdate + +// PatchDBRPIDParams defines parameters for PatchDBRPID. +type PatchDBRPIDParams struct { + // Specifies the organization ID of the mapping + OrgID *string `json:"orgID,omitempty"` + + // Specifies the organization name of the mapping + Org *string `json:"org,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchDBRPIDAllParams defines type for all parameters for PatchDBRPID. +type PatchDBRPIDAllParams struct { + PatchDBRPIDParams + + DbrpID string + + Body PatchDBRPIDJSONRequestBody +} + +// PostDeleteJSONBody defines parameters for PostDelete. +type PostDeleteJSONBody DeletePredicateRequest + +// PostDeleteParams defines parameters for PostDelete. +type PostDeleteParams struct { + // The organization to delete data from. + // If you pass both `orgID` and `org`, they must both be valid. + // + // #### InfluxDB Cloud + // + // - Doesn't require `org` or `orgID`. + // - Deletes data from the bucket in the organization associated with the authorization (API token). + // + // #### InfluxDB OSS + // + // - Requires either `org` or `orgID`. + Org *string `json:"org,omitempty"` + + // The name or ID of the bucket to delete data from. + // If you pass both `bucket` and `bucketID`, `bucketID` takes precedence. + Bucket *string `json:"bucket,omitempty"` + + // The ID of the organization to delete data from. + // If you pass both `orgID` and `org`, they must both be valid. + // + // #### InfluxDB Cloud + // + // - Doesn't require `org` or `orgID`. + // - Deletes data from the bucket in the organization associated with the authorization (API token). + // + // #### InfluxDB OSS + // + // - Requires either `org` or `orgID`. + OrgID *string `json:"orgID,omitempty"` + + // The ID of the bucket to delete data from. + // If you pass both `bucket` and `bucketID`, `bucketID` takes precedence. + BucketID *string `json:"bucketID,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostDeleteAllParams defines type for all parameters for PostDelete. +type PostDeleteAllParams struct { + PostDeleteParams + + Body PostDeleteJSONRequestBody +} + +// GetFlagsParams defines parameters for GetFlags. +type GetFlagsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetHealthParams defines parameters for GetHealth. +type GetHealthParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetLabelsParams defines parameters for GetLabels. +type GetLabelsParams struct { + // The organization ID. + OrgID *string `json:"orgID,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostLabelsJSONBody defines parameters for PostLabels. +type PostLabelsJSONBody LabelCreateRequest + +// PostLabelsAllParams defines type for all parameters for PostLabels. +type PostLabelsAllParams struct { + Body PostLabelsJSONRequestBody +} + +// DeleteLabelsIDParams defines parameters for DeleteLabelsID. +type DeleteLabelsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteLabelsIDAllParams defines type for all parameters for DeleteLabelsID. +type DeleteLabelsIDAllParams struct { + DeleteLabelsIDParams + + LabelID string +} + +// GetLabelsIDParams defines parameters for GetLabelsID. +type GetLabelsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetLabelsIDAllParams defines type for all parameters for GetLabelsID. +type GetLabelsIDAllParams struct { + GetLabelsIDParams + + LabelID string +} + +// PatchLabelsIDJSONBody defines parameters for PatchLabelsID. +type PatchLabelsIDJSONBody LabelUpdate + +// PatchLabelsIDParams defines parameters for PatchLabelsID. +type PatchLabelsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchLabelsIDAllParams defines type for all parameters for PatchLabelsID. +type PatchLabelsIDAllParams struct { + PatchLabelsIDParams + + LabelID string + + Body PatchLabelsIDJSONRequestBody +} + +// GetMeParams defines parameters for GetMe. +type GetMeParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PutMePasswordJSONBody defines parameters for PutMePassword. +type PutMePasswordJSONBody PasswordResetBody + +// PutMePasswordParams defines parameters for PutMePassword. +type PutMePasswordParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PutMePasswordAllParams defines type for all parameters for PutMePassword. +type PutMePasswordAllParams struct { + PutMePasswordParams + + Body PutMePasswordJSONRequestBody +} + +// GetNotificationEndpointsParams defines parameters for GetNotificationEndpoints. +type GetNotificationEndpointsParams 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 notification endpoints that belong to specific organization ID. + OrgID string `json:"orgID"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// CreateNotificationEndpointJSONBody defines parameters for CreateNotificationEndpoint. +type CreateNotificationEndpointJSONBody PostNotificationEndpoint + +// CreateNotificationEndpointAllParams defines type for all parameters for CreateNotificationEndpoint. +type CreateNotificationEndpointAllParams struct { + Body CreateNotificationEndpointJSONRequestBody +} + +// DeleteNotificationEndpointsIDParams defines parameters for DeleteNotificationEndpointsID. +type DeleteNotificationEndpointsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteNotificationEndpointsIDAllParams defines type for all parameters for DeleteNotificationEndpointsID. +type DeleteNotificationEndpointsIDAllParams struct { + DeleteNotificationEndpointsIDParams + + EndpointID string +} + +// GetNotificationEndpointsIDParams defines parameters for GetNotificationEndpointsID. +type GetNotificationEndpointsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetNotificationEndpointsIDAllParams defines type for all parameters for GetNotificationEndpointsID. +type GetNotificationEndpointsIDAllParams struct { + GetNotificationEndpointsIDParams + + EndpointID string +} + +// PatchNotificationEndpointsIDJSONBody defines parameters for PatchNotificationEndpointsID. +type PatchNotificationEndpointsIDJSONBody NotificationEndpointUpdate + +// PatchNotificationEndpointsIDParams defines parameters for PatchNotificationEndpointsID. +type PatchNotificationEndpointsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchNotificationEndpointsIDAllParams defines type for all parameters for PatchNotificationEndpointsID. +type PatchNotificationEndpointsIDAllParams struct { + PatchNotificationEndpointsIDParams + + EndpointID string + + Body PatchNotificationEndpointsIDJSONRequestBody +} + +// PutNotificationEndpointsIDJSONBody defines parameters for PutNotificationEndpointsID. +type PutNotificationEndpointsIDJSONBody NotificationEndpoint + +// PutNotificationEndpointsIDParams defines parameters for PutNotificationEndpointsID. +type PutNotificationEndpointsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PutNotificationEndpointsIDAllParams defines type for all parameters for PutNotificationEndpointsID. +type PutNotificationEndpointsIDAllParams struct { + PutNotificationEndpointsIDParams + + EndpointID string + + Body PutNotificationEndpointsIDJSONRequestBody +} + +// GetNotificationEndpointsIDLabelsParams defines parameters for GetNotificationEndpointsIDLabels. +type GetNotificationEndpointsIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetNotificationEndpointsIDLabelsAllParams defines type for all parameters for GetNotificationEndpointsIDLabels. +type GetNotificationEndpointsIDLabelsAllParams struct { + GetNotificationEndpointsIDLabelsParams + + EndpointID string +} + +// PostNotificationEndpointIDLabelsJSONBody defines parameters for PostNotificationEndpointIDLabels. +type PostNotificationEndpointIDLabelsJSONBody LabelMapping + +// PostNotificationEndpointIDLabelsParams defines parameters for PostNotificationEndpointIDLabels. +type PostNotificationEndpointIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostNotificationEndpointIDLabelsAllParams defines type for all parameters for PostNotificationEndpointIDLabels. +type PostNotificationEndpointIDLabelsAllParams struct { + PostNotificationEndpointIDLabelsParams + + EndpointID string + + Body PostNotificationEndpointIDLabelsJSONRequestBody +} + +// DeleteNotificationEndpointsIDLabelsIDParams defines parameters for DeleteNotificationEndpointsIDLabelsID. +type DeleteNotificationEndpointsIDLabelsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteNotificationEndpointsIDLabelsIDAllParams defines type for all parameters for DeleteNotificationEndpointsIDLabelsID. +type DeleteNotificationEndpointsIDLabelsIDAllParams struct { + DeleteNotificationEndpointsIDLabelsIDParams + + EndpointID string + + LabelID string +} + +// GetNotificationRulesParams defines parameters for GetNotificationRules. +type GetNotificationRulesParams 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 notification rules that belong to a specific organization ID. + OrgID string `json:"orgID"` + + // Only show notifications that belong to the specific check ID. + CheckID *string `json:"checkID,omitempty"` + + // Only return notification rules that "would match" statuses which contain the tag key value pairs provided. + Tag *string `json:"tag,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// CreateNotificationRuleJSONBody defines parameters for CreateNotificationRule. +type CreateNotificationRuleJSONBody PostNotificationRule + +// CreateNotificationRuleAllParams defines type for all parameters for CreateNotificationRule. +type CreateNotificationRuleAllParams struct { + Body CreateNotificationRuleJSONRequestBody +} + +// DeleteNotificationRulesIDParams defines parameters for DeleteNotificationRulesID. +type DeleteNotificationRulesIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteNotificationRulesIDAllParams defines type for all parameters for DeleteNotificationRulesID. +type DeleteNotificationRulesIDAllParams struct { + DeleteNotificationRulesIDParams + + RuleID string +} + +// GetNotificationRulesIDParams defines parameters for GetNotificationRulesID. +type GetNotificationRulesIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetNotificationRulesIDAllParams defines type for all parameters for GetNotificationRulesID. +type GetNotificationRulesIDAllParams struct { + GetNotificationRulesIDParams + + RuleID string +} + +// PatchNotificationRulesIDJSONBody defines parameters for PatchNotificationRulesID. +type PatchNotificationRulesIDJSONBody NotificationRuleUpdate + +// PatchNotificationRulesIDParams defines parameters for PatchNotificationRulesID. +type PatchNotificationRulesIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchNotificationRulesIDAllParams defines type for all parameters for PatchNotificationRulesID. +type PatchNotificationRulesIDAllParams struct { + PatchNotificationRulesIDParams + + RuleID string + + Body PatchNotificationRulesIDJSONRequestBody +} + +// PutNotificationRulesIDJSONBody defines parameters for PutNotificationRulesID. +type PutNotificationRulesIDJSONBody NotificationRule + +// PutNotificationRulesIDParams defines parameters for PutNotificationRulesID. +type PutNotificationRulesIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PutNotificationRulesIDAllParams defines type for all parameters for PutNotificationRulesID. +type PutNotificationRulesIDAllParams struct { + PutNotificationRulesIDParams + + RuleID string + + Body PutNotificationRulesIDJSONRequestBody +} + +// GetNotificationRulesIDLabelsParams defines parameters for GetNotificationRulesIDLabels. +type GetNotificationRulesIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetNotificationRulesIDLabelsAllParams defines type for all parameters for GetNotificationRulesIDLabels. +type GetNotificationRulesIDLabelsAllParams struct { + GetNotificationRulesIDLabelsParams + + RuleID string +} + +// PostNotificationRuleIDLabelsJSONBody defines parameters for PostNotificationRuleIDLabels. +type PostNotificationRuleIDLabelsJSONBody LabelMapping + +// PostNotificationRuleIDLabelsParams defines parameters for PostNotificationRuleIDLabels. +type PostNotificationRuleIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostNotificationRuleIDLabelsAllParams defines type for all parameters for PostNotificationRuleIDLabels. +type PostNotificationRuleIDLabelsAllParams struct { + PostNotificationRuleIDLabelsParams + + RuleID string + + Body PostNotificationRuleIDLabelsJSONRequestBody +} + +// DeleteNotificationRulesIDLabelsIDParams defines parameters for DeleteNotificationRulesIDLabelsID. +type DeleteNotificationRulesIDLabelsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteNotificationRulesIDLabelsIDAllParams defines type for all parameters for DeleteNotificationRulesIDLabelsID. +type DeleteNotificationRulesIDLabelsIDAllParams struct { + DeleteNotificationRulesIDLabelsIDParams + + RuleID string + + LabelID string +} + +// GetNotificationRulesIDQueryParams defines parameters for GetNotificationRulesIDQuery. +type GetNotificationRulesIDQueryParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetNotificationRulesIDQueryAllParams defines type for all parameters for GetNotificationRulesIDQuery. +type GetNotificationRulesIDQueryAllParams struct { + GetNotificationRulesIDQueryParams + + RuleID string +} + +// GetOrgsParams defines parameters for GetOrgs. +type GetOrgsParams 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"` + Descending *Descending `json:"descending,omitempty"` + + // An organization name. + // Only returns organizations with this name. + Org *string `json:"org,omitempty"` + + // An organization ID. + // Only returns the organization with this ID. + OrgID *string `json:"orgID,omitempty"` + + // A user ID. + // Only returns organizations where this user is a member or owner. + UserID *string `json:"userID,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostOrgsJSONBody defines parameters for PostOrgs. +type PostOrgsJSONBody PostOrganizationRequest + +// PostOrgsParams defines parameters for PostOrgs. +type PostOrgsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostOrgsAllParams defines type for all parameters for PostOrgs. +type PostOrgsAllParams struct { + PostOrgsParams + + Body PostOrgsJSONRequestBody +} + +// DeleteOrgsIDParams defines parameters for DeleteOrgsID. +type DeleteOrgsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteOrgsIDAllParams defines type for all parameters for DeleteOrgsID. +type DeleteOrgsIDAllParams struct { + DeleteOrgsIDParams + + OrgID string +} + +// GetOrgsIDParams defines parameters for GetOrgsID. +type GetOrgsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetOrgsIDAllParams defines type for all parameters for GetOrgsID. +type GetOrgsIDAllParams struct { + GetOrgsIDParams + + OrgID string +} + +// PatchOrgsIDJSONBody defines parameters for PatchOrgsID. +type PatchOrgsIDJSONBody PatchOrganizationRequest + +// PatchOrgsIDParams defines parameters for PatchOrgsID. +type PatchOrgsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchOrgsIDAllParams defines type for all parameters for PatchOrgsID. +type PatchOrgsIDAllParams struct { + PatchOrgsIDParams + + OrgID string + + Body PatchOrgsIDJSONRequestBody +} + +// GetOrgsIDMembersParams defines parameters for GetOrgsIDMembers. +type GetOrgsIDMembersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetOrgsIDMembersAllParams defines type for all parameters for GetOrgsIDMembers. +type GetOrgsIDMembersAllParams struct { + GetOrgsIDMembersParams + + OrgID string +} + +// PostOrgsIDMembersJSONBody defines parameters for PostOrgsIDMembers. +type PostOrgsIDMembersJSONBody AddResourceMemberRequestBody + +// PostOrgsIDMembersParams defines parameters for PostOrgsIDMembers. +type PostOrgsIDMembersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostOrgsIDMembersAllParams defines type for all parameters for PostOrgsIDMembers. +type PostOrgsIDMembersAllParams struct { + PostOrgsIDMembersParams + + OrgID string + + Body PostOrgsIDMembersJSONRequestBody +} + +// DeleteOrgsIDMembersIDParams defines parameters for DeleteOrgsIDMembersID. +type DeleteOrgsIDMembersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteOrgsIDMembersIDAllParams defines type for all parameters for DeleteOrgsIDMembersID. +type DeleteOrgsIDMembersIDAllParams struct { + DeleteOrgsIDMembersIDParams + + OrgID string + + UserID string +} + +// GetOrgsIDOwnersParams defines parameters for GetOrgsIDOwners. +type GetOrgsIDOwnersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetOrgsIDOwnersAllParams defines type for all parameters for GetOrgsIDOwners. +type GetOrgsIDOwnersAllParams struct { + GetOrgsIDOwnersParams + + OrgID string +} + +// PostOrgsIDOwnersJSONBody defines parameters for PostOrgsIDOwners. +type PostOrgsIDOwnersJSONBody AddResourceMemberRequestBody + +// PostOrgsIDOwnersParams defines parameters for PostOrgsIDOwners. +type PostOrgsIDOwnersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostOrgsIDOwnersAllParams defines type for all parameters for PostOrgsIDOwners. +type PostOrgsIDOwnersAllParams struct { + PostOrgsIDOwnersParams + + OrgID string + + Body PostOrgsIDOwnersJSONRequestBody +} + +// DeleteOrgsIDOwnersIDParams defines parameters for DeleteOrgsIDOwnersID. +type DeleteOrgsIDOwnersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteOrgsIDOwnersIDAllParams defines type for all parameters for DeleteOrgsIDOwnersID. +type DeleteOrgsIDOwnersIDAllParams struct { + DeleteOrgsIDOwnersIDParams + + OrgID string + + UserID string +} + +// GetOrgsIDSecretsParams defines parameters for GetOrgsIDSecrets. +type GetOrgsIDSecretsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetOrgsIDSecretsAllParams defines type for all parameters for GetOrgsIDSecrets. +type GetOrgsIDSecretsAllParams struct { + GetOrgsIDSecretsParams + + OrgID string +} + +// PatchOrgsIDSecretsJSONBody defines parameters for PatchOrgsIDSecrets. +type PatchOrgsIDSecretsJSONBody Secrets + +// PatchOrgsIDSecretsParams defines parameters for PatchOrgsIDSecrets. +type PatchOrgsIDSecretsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchOrgsIDSecretsAllParams defines type for all parameters for PatchOrgsIDSecrets. +type PatchOrgsIDSecretsAllParams struct { + PatchOrgsIDSecretsParams + + OrgID string + + Body PatchOrgsIDSecretsJSONRequestBody +} + +// PostOrgsIDSecretsJSONBody defines parameters for PostOrgsIDSecrets. +type PostOrgsIDSecretsJSONBody SecretKeys + +// PostOrgsIDSecretsParams defines parameters for PostOrgsIDSecrets. +type PostOrgsIDSecretsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostOrgsIDSecretsAllParams defines type for all parameters for PostOrgsIDSecrets. +type PostOrgsIDSecretsAllParams struct { + PostOrgsIDSecretsParams + + OrgID string + + Body PostOrgsIDSecretsJSONRequestBody +} + +// DeleteOrgsIDSecretsIDParams defines parameters for DeleteOrgsIDSecretsID. +type DeleteOrgsIDSecretsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteOrgsIDSecretsIDAllParams defines type for all parameters for DeleteOrgsIDSecretsID. +type DeleteOrgsIDSecretsIDAllParams struct { + DeleteOrgsIDSecretsIDParams + + OrgID string + + SecretID string +} + +// PostQueryAnalyzeJSONBody defines parameters for PostQueryAnalyze. +type PostQueryAnalyzeJSONBody Query + +// PostQueryAnalyzeParams defines parameters for PostQueryAnalyze. +type PostQueryAnalyzeParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` + ContentType *PostQueryAnalyzeParamsContentType `json:"Content-Type,omitempty"` +} + +// PostQueryAnalyzeParamsContentType defines parameters for PostQueryAnalyze. +type PostQueryAnalyzeParamsContentType string + +// PostQueryAnalyzeAllParams defines type for all parameters for PostQueryAnalyze. +type PostQueryAnalyzeAllParams struct { + PostQueryAnalyzeParams + + Body PostQueryAnalyzeJSONRequestBody +} + +// PostQueryAstJSONBody defines parameters for PostQueryAst. +type PostQueryAstJSONBody LanguageRequest + +// PostQueryAstParams defines parameters for PostQueryAst. +type PostQueryAstParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` + ContentType *PostQueryAstParamsContentType `json:"Content-Type,omitempty"` +} + +// PostQueryAstParamsContentType defines parameters for PostQueryAst. +type PostQueryAstParamsContentType string + +// PostQueryAstAllParams defines type for all parameters for PostQueryAst. +type PostQueryAstAllParams struct { + PostQueryAstParams + + Body PostQueryAstJSONRequestBody +} + +// GetQuerySuggestionsParams defines parameters for GetQuerySuggestions. +type GetQuerySuggestionsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetQuerySuggestionsNameParams defines parameters for GetQuerySuggestionsName. +type GetQuerySuggestionsNameParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetQuerySuggestionsNameAllParams defines type for all parameters for GetQuerySuggestionsName. +type GetQuerySuggestionsNameAllParams struct { + GetQuerySuggestionsNameParams + + Name string +} + +// GetReadyParams defines parameters for GetReady. +type GetReadyParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetRemoteConnectionsParams defines parameters for GetRemoteConnections. +type GetRemoteConnectionsParams struct { + // The organization ID. + OrgID string `json:"orgID"` + Name *string `json:"name,omitempty"` + RemoteURL *string `json:"remoteURL,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostRemoteConnectionJSONBody defines parameters for PostRemoteConnection. +type PostRemoteConnectionJSONBody RemoteConnectionCreationRequest + +// PostRemoteConnectionAllParams defines type for all parameters for PostRemoteConnection. +type PostRemoteConnectionAllParams struct { + Body PostRemoteConnectionJSONRequestBody +} + +// DeleteRemoteConnectionByIDParams defines parameters for DeleteRemoteConnectionByID. +type DeleteRemoteConnectionByIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteRemoteConnectionByIDAllParams defines type for all parameters for DeleteRemoteConnectionByID. +type DeleteRemoteConnectionByIDAllParams struct { + DeleteRemoteConnectionByIDParams + + RemoteID string +} + +// GetRemoteConnectionByIDParams defines parameters for GetRemoteConnectionByID. +type GetRemoteConnectionByIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetRemoteConnectionByIDAllParams defines type for all parameters for GetRemoteConnectionByID. +type GetRemoteConnectionByIDAllParams struct { + GetRemoteConnectionByIDParams + + RemoteID string +} + +// PatchRemoteConnectionByIDJSONBody defines parameters for PatchRemoteConnectionByID. +type PatchRemoteConnectionByIDJSONBody RemoteConnectionUpdateRequest + +// PatchRemoteConnectionByIDParams defines parameters for PatchRemoteConnectionByID. +type PatchRemoteConnectionByIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchRemoteConnectionByIDAllParams defines type for all parameters for PatchRemoteConnectionByID. +type PatchRemoteConnectionByIDAllParams struct { + PatchRemoteConnectionByIDParams + + RemoteID string + + Body PatchRemoteConnectionByIDJSONRequestBody +} + +// GetReplicationsParams defines parameters for GetReplications. +type GetReplicationsParams struct { + // The organization ID. + OrgID string `json:"orgID"` + Name *string `json:"name,omitempty"` + RemoteID *string `json:"remoteID,omitempty"` + LocalBucketID *string `json:"localBucketID,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostReplicationJSONBody defines parameters for PostReplication. +type PostReplicationJSONBody ReplicationCreationRequest + +// PostReplicationParams defines parameters for PostReplication. +type PostReplicationParams struct { + // If true, validate the replication, but don't save it. + Validate *bool `json:"validate,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostReplicationAllParams defines type for all parameters for PostReplication. +type PostReplicationAllParams struct { + PostReplicationParams + + Body PostReplicationJSONRequestBody +} + +// DeleteReplicationByIDParams defines parameters for DeleteReplicationByID. +type DeleteReplicationByIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteReplicationByIDAllParams defines type for all parameters for DeleteReplicationByID. +type DeleteReplicationByIDAllParams struct { + DeleteReplicationByIDParams + + ReplicationID string +} + +// GetReplicationByIDParams defines parameters for GetReplicationByID. +type GetReplicationByIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetReplicationByIDAllParams defines type for all parameters for GetReplicationByID. +type GetReplicationByIDAllParams struct { + GetReplicationByIDParams + + ReplicationID string +} + +// PatchReplicationByIDJSONBody defines parameters for PatchReplicationByID. +type PatchReplicationByIDJSONBody ReplicationUpdateRequest + +// PatchReplicationByIDParams defines parameters for PatchReplicationByID. +type PatchReplicationByIDParams struct { + // If true, validate the updated information, but don't save it. + Validate *bool `json:"validate,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchReplicationByIDAllParams defines type for all parameters for PatchReplicationByID. +type PatchReplicationByIDAllParams struct { + PatchReplicationByIDParams + + ReplicationID string + + Body PatchReplicationByIDJSONRequestBody +} + +// PostValidateReplicationByIDParams defines parameters for PostValidateReplicationByID. +type PostValidateReplicationByIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostValidateReplicationByIDAllParams defines type for all parameters for PostValidateReplicationByID. +type PostValidateReplicationByIDAllParams struct { + PostValidateReplicationByIDParams + + ReplicationID string +} + +// GetResourcesParams defines parameters for GetResources. +type GetResourcesParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostRestoreBucketMetadataJSONBody defines parameters for PostRestoreBucketMetadata. +type PostRestoreBucketMetadataJSONBody BucketMetadataManifest + +// PostRestoreBucketMetadataParams defines parameters for PostRestoreBucketMetadata. +type PostRestoreBucketMetadataParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostRestoreBucketMetadataAllParams defines type for all parameters for PostRestoreBucketMetadata. +type PostRestoreBucketMetadataAllParams struct { + PostRestoreBucketMetadataParams + + Body PostRestoreBucketMetadataJSONRequestBody +} + +// GetScrapersParams defines parameters for GetScrapers. +type GetScrapersParams struct { + // Specifies the name of the scraper target. + Name *string `json:"name,omitempty"` + + // List of scraper target IDs to return. If both `id` and `owner` are specified, only `id` is used. + Id *[]string `json:"id,omitempty"` + + // Specifies the organization ID of the scraper target. + OrgID *string `json:"orgID,omitempty"` + + // Specifies the organization name of the scraper target. + Org *string `json:"org,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostScrapersJSONBody defines parameters for PostScrapers. +type PostScrapersJSONBody ScraperTargetRequest + +// PostScrapersParams defines parameters for PostScrapers. +type PostScrapersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostScrapersAllParams defines type for all parameters for PostScrapers. +type PostScrapersAllParams struct { + PostScrapersParams + + Body PostScrapersJSONRequestBody +} + +// DeleteScrapersIDParams defines parameters for DeleteScrapersID. +type DeleteScrapersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteScrapersIDAllParams defines type for all parameters for DeleteScrapersID. +type DeleteScrapersIDAllParams struct { + DeleteScrapersIDParams + + ScraperTargetID string +} + +// GetScrapersIDParams defines parameters for GetScrapersID. +type GetScrapersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetScrapersIDAllParams defines type for all parameters for GetScrapersID. +type GetScrapersIDAllParams struct { + GetScrapersIDParams + + ScraperTargetID string +} + +// PatchScrapersIDJSONBody defines parameters for PatchScrapersID. +type PatchScrapersIDJSONBody ScraperTargetRequest + +// PatchScrapersIDParams defines parameters for PatchScrapersID. +type PatchScrapersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchScrapersIDAllParams defines type for all parameters for PatchScrapersID. +type PatchScrapersIDAllParams struct { + PatchScrapersIDParams + + ScraperTargetID string + + Body PatchScrapersIDJSONRequestBody +} + +// GetScrapersIDLabelsParams defines parameters for GetScrapersIDLabels. +type GetScrapersIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetScrapersIDLabelsAllParams defines type for all parameters for GetScrapersIDLabels. +type GetScrapersIDLabelsAllParams struct { + GetScrapersIDLabelsParams + + ScraperTargetID string +} + +// PostScrapersIDLabelsJSONBody defines parameters for PostScrapersIDLabels. +type PostScrapersIDLabelsJSONBody LabelMapping + +// PostScrapersIDLabelsParams defines parameters for PostScrapersIDLabels. +type PostScrapersIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostScrapersIDLabelsAllParams defines type for all parameters for PostScrapersIDLabels. +type PostScrapersIDLabelsAllParams struct { + PostScrapersIDLabelsParams + + ScraperTargetID string + + Body PostScrapersIDLabelsJSONRequestBody +} + +// DeleteScrapersIDLabelsIDParams defines parameters for DeleteScrapersIDLabelsID. +type DeleteScrapersIDLabelsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteScrapersIDLabelsIDAllParams defines type for all parameters for DeleteScrapersIDLabelsID. +type DeleteScrapersIDLabelsIDAllParams struct { + DeleteScrapersIDLabelsIDParams + + ScraperTargetID string + + LabelID string +} + +// GetScrapersIDMembersParams defines parameters for GetScrapersIDMembers. +type GetScrapersIDMembersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetScrapersIDMembersAllParams defines type for all parameters for GetScrapersIDMembers. +type GetScrapersIDMembersAllParams struct { + GetScrapersIDMembersParams + + ScraperTargetID string +} + +// PostScrapersIDMembersJSONBody defines parameters for PostScrapersIDMembers. +type PostScrapersIDMembersJSONBody AddResourceMemberRequestBody + +// PostScrapersIDMembersParams defines parameters for PostScrapersIDMembers. +type PostScrapersIDMembersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostScrapersIDMembersAllParams defines type for all parameters for PostScrapersIDMembers. +type PostScrapersIDMembersAllParams struct { + PostScrapersIDMembersParams + + ScraperTargetID string + + Body PostScrapersIDMembersJSONRequestBody +} + +// DeleteScrapersIDMembersIDParams defines parameters for DeleteScrapersIDMembersID. +type DeleteScrapersIDMembersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteScrapersIDMembersIDAllParams defines type for all parameters for DeleteScrapersIDMembersID. +type DeleteScrapersIDMembersIDAllParams struct { + DeleteScrapersIDMembersIDParams + + ScraperTargetID string + + UserID string +} + +// GetScrapersIDOwnersParams defines parameters for GetScrapersIDOwners. +type GetScrapersIDOwnersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetScrapersIDOwnersAllParams defines type for all parameters for GetScrapersIDOwners. +type GetScrapersIDOwnersAllParams struct { + GetScrapersIDOwnersParams + + ScraperTargetID string +} + +// PostScrapersIDOwnersJSONBody defines parameters for PostScrapersIDOwners. +type PostScrapersIDOwnersJSONBody AddResourceMemberRequestBody + +// PostScrapersIDOwnersParams defines parameters for PostScrapersIDOwners. +type PostScrapersIDOwnersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostScrapersIDOwnersAllParams defines type for all parameters for PostScrapersIDOwners. +type PostScrapersIDOwnersAllParams struct { + PostScrapersIDOwnersParams + + ScraperTargetID string + + Body PostScrapersIDOwnersJSONRequestBody +} + +// DeleteScrapersIDOwnersIDParams defines parameters for DeleteScrapersIDOwnersID. +type DeleteScrapersIDOwnersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteScrapersIDOwnersIDAllParams defines type for all parameters for DeleteScrapersIDOwnersID. +type DeleteScrapersIDOwnersIDAllParams struct { + DeleteScrapersIDOwnersIDParams + + ScraperTargetID string + + UserID string +} + +// GetSetupParams defines parameters for GetSetup. +type GetSetupParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostSetupJSONBody defines parameters for PostSetup. +type PostSetupJSONBody OnboardingRequest + +// PostSetupParams defines parameters for PostSetup. +type PostSetupParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostSetupAllParams defines type for all parameters for PostSetup. +type PostSetupAllParams struct { + PostSetupParams + + Body PostSetupJSONRequestBody +} + +// PostSigninParams defines parameters for PostSignin. +type PostSigninParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostSignoutParams defines parameters for PostSignout. +type PostSignoutParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetSourcesParams defines parameters for GetSources. +type GetSourcesParams struct { + // The name of the organization. + Org *string `json:"org,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostSourcesJSONBody defines parameters for PostSources. +type PostSourcesJSONBody Source + +// PostSourcesParams defines parameters for PostSources. +type PostSourcesParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostSourcesAllParams defines type for all parameters for PostSources. +type PostSourcesAllParams struct { + PostSourcesParams + + Body PostSourcesJSONRequestBody +} + +// DeleteSourcesIDParams defines parameters for DeleteSourcesID. +type DeleteSourcesIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteSourcesIDAllParams defines type for all parameters for DeleteSourcesID. +type DeleteSourcesIDAllParams struct { + DeleteSourcesIDParams + + SourceID string +} + +// GetSourcesIDParams defines parameters for GetSourcesID. +type GetSourcesIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetSourcesIDAllParams defines type for all parameters for GetSourcesID. +type GetSourcesIDAllParams struct { + GetSourcesIDParams + + SourceID string +} + +// PatchSourcesIDJSONBody defines parameters for PatchSourcesID. +type PatchSourcesIDJSONBody Source + +// PatchSourcesIDParams defines parameters for PatchSourcesID. +type PatchSourcesIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchSourcesIDAllParams defines type for all parameters for PatchSourcesID. +type PatchSourcesIDAllParams struct { + PatchSourcesIDParams + + SourceID string + + Body PatchSourcesIDJSONRequestBody +} + +// GetSourcesIDBucketsParams defines parameters for GetSourcesIDBuckets. +type GetSourcesIDBucketsParams struct { + // The name of the organization. + Org *string `json:"org,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetSourcesIDBucketsAllParams defines type for all parameters for GetSourcesIDBuckets. +type GetSourcesIDBucketsAllParams struct { + GetSourcesIDBucketsParams + + SourceID string +} + +// GetSourcesIDHealthParams defines parameters for GetSourcesIDHealth. +type GetSourcesIDHealthParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetSourcesIDHealthAllParams defines type for all parameters for GetSourcesIDHealth. +type GetSourcesIDHealthAllParams struct { + GetSourcesIDHealthParams + + SourceID string +} + +// ListStacksParams defines parameters for ListStacks. +type ListStacksParams struct { + // The ID of the organization that owns the stacks. + // Only returns stacks owned by this organization. + // + // #### InfluxDB Cloud + // + // - Doesn't require this parameter; + // InfluxDB only returns resources allowed by the API token. + OrgID string `json:"orgID"` + + // The stack name. + // Finds stack `events` with this name and returns the stacks. + // + // Repeatable. + // To filter for more than one stack name, + // repeat this parameter with each name--for example: + // + // - `http://localhost:8086/api/v2/stacks?&orgID=INFLUX_ORG_ID&name=project-stack-0&name=project-stack-1` + Name *string `json:"name,omitempty"` + + // The stack ID. + // Only returns stacks with this ID. + // + // Repeatable. + // To filter for more than one stack ID, + // repeat this parameter with each ID--for example: + // + // - `http://localhost:8086/api/v2/stacks?&orgID=INFLUX_ORG_ID&stackID=09bd87cd33be3000&stackID=09bef35081fe3000` + StackID *string `json:"stackID,omitempty"` +} + +// CreateStackJSONBody defines parameters for CreateStack. +type CreateStackJSONBody struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + OrgID *string `json:"orgID,omitempty"` + Urls *[]string `json:"urls,omitempty"` +} + +// CreateStackAllParams defines type for all parameters for CreateStack. +type CreateStackAllParams struct { + Body CreateStackJSONRequestBody +} + +// DeleteStackParams defines parameters for DeleteStack. +type DeleteStackParams struct { + // The identifier of the organization. + OrgID string `json:"orgID"` +} + +// DeleteStackAllParams defines type for all parameters for DeleteStack. +type DeleteStackAllParams struct { + DeleteStackParams + + StackId string +} + +// ReadStackAllParams defines type for all parameters for ReadStack. +type ReadStackAllParams struct { + StackId string +} + +// UpdateStackJSONBody defines parameters for UpdateStack. +type UpdateStackJSONBody struct { + AdditionalResources *[]struct { + Kind string `json:"kind"` + ResourceID string `json:"resourceID"` + TemplateMetaName *string `json:"templateMetaName,omitempty"` + } `json:"additionalResources,omitempty"` + Description *string `json:"description"` + Name *string `json:"name"` + TemplateURLs *[]string `json:"templateURLs"` +} + +// UpdateStackAllParams defines type for all parameters for UpdateStack. +type UpdateStackAllParams struct { + StackId string + + Body UpdateStackJSONRequestBody +} + +// UninstallStackAllParams defines type for all parameters for UninstallStack. +type UninstallStackAllParams struct { + StackId string +} + +// GetTasksParams defines parameters for GetTasks. +type GetTasksParams struct { + // Task name. + // Only returns tasks with this name. + // Different tasks may have the same name. + Name *string `json:"name,omitempty"` + + // Task ID. + // Only returns tasks created after this task. + After *string `json:"after,omitempty"` + + // User ID. + // Only returns tasks owned by this user. + User *string `json:"user,omitempty"` + + // Organization name. + // Only returns tasks owned by this organization. + Org *string `json:"org,omitempty"` + + // Organization ID. + // Only returns tasks owned by this organization. + OrgID *string `json:"orgID,omitempty"` + + // Task status (`active` or `inactive`). + // Only returns tasks with this status. + Status *GetTasksParamsStatus `json:"status,omitempty"` + + // Limits the number of tasks returned. + // The minimum is `1`, the maximum is `500`, and the default is `100`. + Limit *int `json:"limit,omitempty"` + + // Task type (`basic` or `system`). + // + // The default (`system`) response contains all the metadata properties for tasks. + // To reduce the payload size, pass `basic` to omit some task properties (`flux`, `createdAt`, `updatedAt`) from the response. + Type *GetTasksParamsType `json:"type,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTasksParamsStatus defines parameters for GetTasks. +type GetTasksParamsStatus string + +// GetTasksParamsType defines parameters for GetTasks. +type GetTasksParamsType string + +// PostTasksJSONBody defines parameters for PostTasks. +type PostTasksJSONBody TaskCreateRequest + +// PostTasksParams defines parameters for PostTasks. +type PostTasksParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostTasksAllParams defines type for all parameters for PostTasks. +type PostTasksAllParams struct { + PostTasksParams + + Body PostTasksJSONRequestBody +} + +// DeleteTasksIDParams defines parameters for DeleteTasksID. +type DeleteTasksIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteTasksIDAllParams defines type for all parameters for DeleteTasksID. +type DeleteTasksIDAllParams struct { + DeleteTasksIDParams + + TaskID string +} + +// GetTasksIDParams defines parameters for GetTasksID. +type GetTasksIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTasksIDAllParams defines type for all parameters for GetTasksID. +type GetTasksIDAllParams struct { + GetTasksIDParams + + TaskID string +} + +// PatchTasksIDJSONBody defines parameters for PatchTasksID. +type PatchTasksIDJSONBody TaskUpdateRequest + +// PatchTasksIDParams defines parameters for PatchTasksID. +type PatchTasksIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchTasksIDAllParams defines type for all parameters for PatchTasksID. +type PatchTasksIDAllParams struct { + PatchTasksIDParams + + TaskID string + + Body PatchTasksIDJSONRequestBody +} + +// GetTasksIDLabelsParams defines parameters for GetTasksIDLabels. +type GetTasksIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTasksIDLabelsAllParams defines type for all parameters for GetTasksIDLabels. +type GetTasksIDLabelsAllParams struct { + GetTasksIDLabelsParams + + TaskID string +} + +// PostTasksIDLabelsJSONBody defines parameters for PostTasksIDLabels. +type PostTasksIDLabelsJSONBody LabelMapping + +// PostTasksIDLabelsParams defines parameters for PostTasksIDLabels. +type PostTasksIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostTasksIDLabelsAllParams defines type for all parameters for PostTasksIDLabels. +type PostTasksIDLabelsAllParams struct { + PostTasksIDLabelsParams + + TaskID string + + Body PostTasksIDLabelsJSONRequestBody +} + +// DeleteTasksIDLabelsIDParams defines parameters for DeleteTasksIDLabelsID. +type DeleteTasksIDLabelsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteTasksIDLabelsIDAllParams defines type for all parameters for DeleteTasksIDLabelsID. +type DeleteTasksIDLabelsIDAllParams struct { + DeleteTasksIDLabelsIDParams + + TaskID string + + LabelID string +} + +// GetTasksIDLogsParams defines parameters for GetTasksIDLogs. +type GetTasksIDLogsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTasksIDLogsAllParams defines type for all parameters for GetTasksIDLogs. +type GetTasksIDLogsAllParams struct { + GetTasksIDLogsParams + + TaskID string +} + +// GetTasksIDMembersParams defines parameters for GetTasksIDMembers. +type GetTasksIDMembersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTasksIDMembersAllParams defines type for all parameters for GetTasksIDMembers. +type GetTasksIDMembersAllParams struct { + GetTasksIDMembersParams + + TaskID string +} + +// PostTasksIDMembersJSONBody defines parameters for PostTasksIDMembers. +type PostTasksIDMembersJSONBody AddResourceMemberRequestBody + +// PostTasksIDMembersParams defines parameters for PostTasksIDMembers. +type PostTasksIDMembersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostTasksIDMembersAllParams defines type for all parameters for PostTasksIDMembers. +type PostTasksIDMembersAllParams struct { + PostTasksIDMembersParams + + TaskID string + + Body PostTasksIDMembersJSONRequestBody +} + +// DeleteTasksIDMembersIDParams defines parameters for DeleteTasksIDMembersID. +type DeleteTasksIDMembersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteTasksIDMembersIDAllParams defines type for all parameters for DeleteTasksIDMembersID. +type DeleteTasksIDMembersIDAllParams struct { + DeleteTasksIDMembersIDParams + + TaskID string + + UserID string +} + +// GetTasksIDOwnersParams defines parameters for GetTasksIDOwners. +type GetTasksIDOwnersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTasksIDOwnersAllParams defines type for all parameters for GetTasksIDOwners. +type GetTasksIDOwnersAllParams struct { + GetTasksIDOwnersParams + + TaskID string +} + +// PostTasksIDOwnersJSONBody defines parameters for PostTasksIDOwners. +type PostTasksIDOwnersJSONBody AddResourceMemberRequestBody + +// PostTasksIDOwnersParams defines parameters for PostTasksIDOwners. +type PostTasksIDOwnersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostTasksIDOwnersAllParams defines type for all parameters for PostTasksIDOwners. +type PostTasksIDOwnersAllParams struct { + PostTasksIDOwnersParams + + TaskID string + + Body PostTasksIDOwnersJSONRequestBody +} + +// DeleteTasksIDOwnersIDParams defines parameters for DeleteTasksIDOwnersID. +type DeleteTasksIDOwnersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteTasksIDOwnersIDAllParams defines type for all parameters for DeleteTasksIDOwnersID. +type DeleteTasksIDOwnersIDAllParams struct { + DeleteTasksIDOwnersIDParams + + TaskID string + + UserID string +} + +// GetTasksIDRunsParams defines parameters for GetTasksIDRuns. +type GetTasksIDRunsParams struct { + // A task run ID. Only returns runs created after this run. + After *string `json:"after,omitempty"` + + // Limits the number of task runs returned. Default is `100`. + Limit *int `json:"limit,omitempty"` + + // A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp)). + // Only returns runs scheduled after this time. + AfterTime *time.Time `json:"afterTime,omitempty"` + + // A timestamp ([RFC3339 date/time format](https://docs.influxdata.com/influxdb/v2.3/reference/glossary/#rfc3339-timestamp)). + // Only returns runs scheduled before this time. + BeforeTime *time.Time `json:"beforeTime,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTasksIDRunsAllParams defines type for all parameters for GetTasksIDRuns. +type GetTasksIDRunsAllParams struct { + GetTasksIDRunsParams + + TaskID string +} + +// PostTasksIDRunsJSONBody defines parameters for PostTasksIDRuns. +type PostTasksIDRunsJSONBody RunManually + +// PostTasksIDRunsParams defines parameters for PostTasksIDRuns. +type PostTasksIDRunsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostTasksIDRunsAllParams defines type for all parameters for PostTasksIDRuns. +type PostTasksIDRunsAllParams struct { + PostTasksIDRunsParams + + TaskID string + + Body PostTasksIDRunsJSONRequestBody +} + +// DeleteTasksIDRunsIDParams defines parameters for DeleteTasksIDRunsID. +type DeleteTasksIDRunsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteTasksIDRunsIDAllParams defines type for all parameters for DeleteTasksIDRunsID. +type DeleteTasksIDRunsIDAllParams struct { + DeleteTasksIDRunsIDParams + + TaskID string + + RunID string +} + +// GetTasksIDRunsIDParams defines parameters for GetTasksIDRunsID. +type GetTasksIDRunsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTasksIDRunsIDAllParams defines type for all parameters for GetTasksIDRunsID. +type GetTasksIDRunsIDAllParams struct { + GetTasksIDRunsIDParams + + TaskID string + + RunID string +} + +// GetTasksIDRunsIDLogsParams defines parameters for GetTasksIDRunsIDLogs. +type GetTasksIDRunsIDLogsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTasksIDRunsIDLogsAllParams defines type for all parameters for GetTasksIDRunsIDLogs. +type GetTasksIDRunsIDLogsAllParams struct { + GetTasksIDRunsIDLogsParams + + TaskID string + + RunID string +} + +// PostTasksIDRunsIDRetryJSONBody defines parameters for PostTasksIDRunsIDRetry. +type PostTasksIDRunsIDRetryJSONBody map[string]interface{} + +// PostTasksIDRunsIDRetryParams defines parameters for PostTasksIDRunsIDRetry. +type PostTasksIDRunsIDRetryParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostTasksIDRunsIDRetryAllParams defines type for all parameters for PostTasksIDRunsIDRetry. +type PostTasksIDRunsIDRetryAllParams struct { + PostTasksIDRunsIDRetryParams + + TaskID string + + RunID string + + Body PostTasksIDRunsIDRetryJSONRequestBody +} + +// GetTelegrafPluginsParams defines parameters for GetTelegrafPlugins. +type GetTelegrafPluginsParams struct { + // The type of plugin desired. + Type *string `json:"type,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTelegrafsParams defines parameters for GetTelegrafs. +type GetTelegrafsParams struct { + // The organization ID the Telegraf config belongs to. + OrgID *string `json:"orgID,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostTelegrafsJSONBody defines parameters for PostTelegrafs. +type PostTelegrafsJSONBody TelegrafPluginRequest + +// PostTelegrafsParams defines parameters for PostTelegrafs. +type PostTelegrafsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostTelegrafsAllParams defines type for all parameters for PostTelegrafs. +type PostTelegrafsAllParams struct { + PostTelegrafsParams + + Body PostTelegrafsJSONRequestBody +} + +// DeleteTelegrafsIDParams defines parameters for DeleteTelegrafsID. +type DeleteTelegrafsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteTelegrafsIDAllParams defines type for all parameters for DeleteTelegrafsID. +type DeleteTelegrafsIDAllParams struct { + DeleteTelegrafsIDParams + + TelegrafID string +} + +// GetTelegrafsIDParams defines parameters for GetTelegrafsID. +type GetTelegrafsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` + Accept *GetTelegrafsIDParamsAccept `json:"Accept,omitempty"` +} + +// GetTelegrafsIDParamsAccept defines parameters for GetTelegrafsID. +type GetTelegrafsIDParamsAccept string + +// GetTelegrafsIDAllParams defines type for all parameters for GetTelegrafsID. +type GetTelegrafsIDAllParams struct { + GetTelegrafsIDParams + + TelegrafID string +} + +// PutTelegrafsIDJSONBody defines parameters for PutTelegrafsID. +type PutTelegrafsIDJSONBody TelegrafPluginRequest + +// PutTelegrafsIDParams defines parameters for PutTelegrafsID. +type PutTelegrafsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PutTelegrafsIDAllParams defines type for all parameters for PutTelegrafsID. +type PutTelegrafsIDAllParams struct { + PutTelegrafsIDParams + + TelegrafID string + + Body PutTelegrafsIDJSONRequestBody +} + +// GetTelegrafsIDLabelsParams defines parameters for GetTelegrafsIDLabels. +type GetTelegrafsIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTelegrafsIDLabelsAllParams defines type for all parameters for GetTelegrafsIDLabels. +type GetTelegrafsIDLabelsAllParams struct { + GetTelegrafsIDLabelsParams + + TelegrafID string +} + +// PostTelegrafsIDLabelsJSONBody defines parameters for PostTelegrafsIDLabels. +type PostTelegrafsIDLabelsJSONBody LabelMapping + +// PostTelegrafsIDLabelsParams defines parameters for PostTelegrafsIDLabels. +type PostTelegrafsIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostTelegrafsIDLabelsAllParams defines type for all parameters for PostTelegrafsIDLabels. +type PostTelegrafsIDLabelsAllParams struct { + PostTelegrafsIDLabelsParams + + TelegrafID string + + Body PostTelegrafsIDLabelsJSONRequestBody +} + +// DeleteTelegrafsIDLabelsIDParams defines parameters for DeleteTelegrafsIDLabelsID. +type DeleteTelegrafsIDLabelsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteTelegrafsIDLabelsIDAllParams defines type for all parameters for DeleteTelegrafsIDLabelsID. +type DeleteTelegrafsIDLabelsIDAllParams struct { + DeleteTelegrafsIDLabelsIDParams + + TelegrafID string + + LabelID string +} + +// GetTelegrafsIDMembersParams defines parameters for GetTelegrafsIDMembers. +type GetTelegrafsIDMembersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTelegrafsIDMembersAllParams defines type for all parameters for GetTelegrafsIDMembers. +type GetTelegrafsIDMembersAllParams struct { + GetTelegrafsIDMembersParams + + TelegrafID string +} + +// PostTelegrafsIDMembersJSONBody defines parameters for PostTelegrafsIDMembers. +type PostTelegrafsIDMembersJSONBody AddResourceMemberRequestBody + +// PostTelegrafsIDMembersParams defines parameters for PostTelegrafsIDMembers. +type PostTelegrafsIDMembersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostTelegrafsIDMembersAllParams defines type for all parameters for PostTelegrafsIDMembers. +type PostTelegrafsIDMembersAllParams struct { + PostTelegrafsIDMembersParams + + TelegrafID string + + Body PostTelegrafsIDMembersJSONRequestBody +} + +// DeleteTelegrafsIDMembersIDParams defines parameters for DeleteTelegrafsIDMembersID. +type DeleteTelegrafsIDMembersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteTelegrafsIDMembersIDAllParams defines type for all parameters for DeleteTelegrafsIDMembersID. +type DeleteTelegrafsIDMembersIDAllParams struct { + DeleteTelegrafsIDMembersIDParams + + TelegrafID string + + UserID string +} + +// GetTelegrafsIDOwnersParams defines parameters for GetTelegrafsIDOwners. +type GetTelegrafsIDOwnersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetTelegrafsIDOwnersAllParams defines type for all parameters for GetTelegrafsIDOwners. +type GetTelegrafsIDOwnersAllParams struct { + GetTelegrafsIDOwnersParams + + TelegrafID string +} + +// PostTelegrafsIDOwnersJSONBody defines parameters for PostTelegrafsIDOwners. +type PostTelegrafsIDOwnersJSONBody AddResourceMemberRequestBody + +// PostTelegrafsIDOwnersParams defines parameters for PostTelegrafsIDOwners. +type PostTelegrafsIDOwnersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostTelegrafsIDOwnersAllParams defines type for all parameters for PostTelegrafsIDOwners. +type PostTelegrafsIDOwnersAllParams struct { + PostTelegrafsIDOwnersParams + + TelegrafID string + + Body PostTelegrafsIDOwnersJSONRequestBody +} + +// DeleteTelegrafsIDOwnersIDParams defines parameters for DeleteTelegrafsIDOwnersID. +type DeleteTelegrafsIDOwnersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteTelegrafsIDOwnersIDAllParams defines type for all parameters for DeleteTelegrafsIDOwnersID. +type DeleteTelegrafsIDOwnersIDAllParams struct { + DeleteTelegrafsIDOwnersIDParams + + TelegrafID string + + UserID string +} + +// ExportTemplateJSONBody defines parameters for ExportTemplate. +type ExportTemplateJSONBody interface{} + +// ExportTemplateAllParams defines type for all parameters for ExportTemplate. +type ExportTemplateAllParams struct { + Body ExportTemplateJSONRequestBody +} + +// GetUsersParams defines parameters for GetUsers. +type GetUsersParams 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"` + + // Resource ID to seek from. Results are not inclusive of this ID. Use `after` instead of `offset`. + After *After `json:"after,omitempty"` + Name *string `json:"name,omitempty"` + Id *string `json:"id,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostUsersJSONBody defines parameters for PostUsers. +type PostUsersJSONBody User + +// PostUsersParams defines parameters for PostUsers. +type PostUsersParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostUsersAllParams defines type for all parameters for PostUsers. +type PostUsersAllParams struct { + PostUsersParams + + Body PostUsersJSONRequestBody +} + +// DeleteUsersIDParams defines parameters for DeleteUsersID. +type DeleteUsersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteUsersIDAllParams defines type for all parameters for DeleteUsersID. +type DeleteUsersIDAllParams struct { + DeleteUsersIDParams + + UserID string +} + +// GetUsersIDParams defines parameters for GetUsersID. +type GetUsersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetUsersIDAllParams defines type for all parameters for GetUsersID. +type GetUsersIDAllParams struct { + GetUsersIDParams + + UserID string +} + +// PatchUsersIDJSONBody defines parameters for PatchUsersID. +type PatchUsersIDJSONBody User + +// PatchUsersIDParams defines parameters for PatchUsersID. +type PatchUsersIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchUsersIDAllParams defines type for all parameters for PatchUsersID. +type PatchUsersIDAllParams struct { + PatchUsersIDParams + + UserID string + + Body PatchUsersIDJSONRequestBody +} + +// PostUsersIDPasswordJSONBody defines parameters for PostUsersIDPassword. +type PostUsersIDPasswordJSONBody PasswordResetBody + +// PostUsersIDPasswordParams defines parameters for PostUsersIDPassword. +type PostUsersIDPasswordParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostUsersIDPasswordAllParams defines type for all parameters for PostUsersIDPassword. +type PostUsersIDPasswordAllParams struct { + PostUsersIDPasswordParams + + UserID string + + Body PostUsersIDPasswordJSONRequestBody +} + +// GetVariablesParams defines parameters for GetVariables. +type GetVariablesParams struct { + // The name of the organization. + Org *string `json:"org,omitempty"` + + // The organization ID. + OrgID *string `json:"orgID,omitempty"` + + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostVariablesJSONBody defines parameters for PostVariables. +type PostVariablesJSONBody Variable + +// PostVariablesParams defines parameters for PostVariables. +type PostVariablesParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostVariablesAllParams defines type for all parameters for PostVariables. +type PostVariablesAllParams struct { + PostVariablesParams + + Body PostVariablesJSONRequestBody +} + +// DeleteVariablesIDParams defines parameters for DeleteVariablesID. +type DeleteVariablesIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteVariablesIDAllParams defines type for all parameters for DeleteVariablesID. +type DeleteVariablesIDAllParams struct { + DeleteVariablesIDParams + + VariableID string +} + +// GetVariablesIDParams defines parameters for GetVariablesID. +type GetVariablesIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetVariablesIDAllParams defines type for all parameters for GetVariablesID. +type GetVariablesIDAllParams struct { + GetVariablesIDParams + + VariableID string +} + +// PatchVariablesIDJSONBody defines parameters for PatchVariablesID. +type PatchVariablesIDJSONBody Variable + +// PatchVariablesIDParams defines parameters for PatchVariablesID. +type PatchVariablesIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PatchVariablesIDAllParams defines type for all parameters for PatchVariablesID. +type PatchVariablesIDAllParams struct { + PatchVariablesIDParams + + VariableID string + + Body PatchVariablesIDJSONRequestBody +} + +// PutVariablesIDJSONBody defines parameters for PutVariablesID. +type PutVariablesIDJSONBody Variable + +// PutVariablesIDParams defines parameters for PutVariablesID. +type PutVariablesIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PutVariablesIDAllParams defines type for all parameters for PutVariablesID. +type PutVariablesIDAllParams struct { + PutVariablesIDParams + + VariableID string + + Body PutVariablesIDJSONRequestBody +} + +// GetVariablesIDLabelsParams defines parameters for GetVariablesIDLabels. +type GetVariablesIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// GetVariablesIDLabelsAllParams defines type for all parameters for GetVariablesIDLabels. +type GetVariablesIDLabelsAllParams struct { + GetVariablesIDLabelsParams + + VariableID string +} + +// PostVariablesIDLabelsJSONBody defines parameters for PostVariablesIDLabels. +type PostVariablesIDLabelsJSONBody LabelMapping + +// PostVariablesIDLabelsParams defines parameters for PostVariablesIDLabels. +type PostVariablesIDLabelsParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// PostVariablesIDLabelsAllParams defines type for all parameters for PostVariablesIDLabels. +type PostVariablesIDLabelsAllParams struct { + PostVariablesIDLabelsParams + + VariableID string + + Body PostVariablesIDLabelsJSONRequestBody +} + +// DeleteVariablesIDLabelsIDParams defines parameters for DeleteVariablesIDLabelsID. +type DeleteVariablesIDLabelsIDParams struct { + // OpenTracing span context + ZapTraceSpan *TraceSpan `json:"Zap-Trace-Span,omitempty"` +} + +// DeleteVariablesIDLabelsIDAllParams defines type for all parameters for DeleteVariablesIDLabelsID. +type DeleteVariablesIDLabelsIDAllParams struct { + DeleteVariablesIDLabelsIDParams + + VariableID string + + LabelID string +} + +// PostAuthorizationsJSONRequestBody defines body for PostAuthorizations for application/json ContentType. +type PostAuthorizationsJSONRequestBody PostAuthorizationsJSONBody + +// PatchAuthorizationsIDJSONRequestBody defines body for PatchAuthorizationsID for application/json ContentType. +type PatchAuthorizationsIDJSONRequestBody PatchAuthorizationsIDJSONBody + +// PostBucketsJSONRequestBody defines body for PostBuckets for application/json ContentType. +type PostBucketsJSONRequestBody PostBucketsJSONBody + +// PatchBucketsIDJSONRequestBody defines body for PatchBucketsID for application/json ContentType. +type PatchBucketsIDJSONRequestBody PatchBucketsIDJSONBody + +// PostBucketsIDLabelsJSONRequestBody defines body for PostBucketsIDLabels for application/json ContentType. +type PostBucketsIDLabelsJSONRequestBody PostBucketsIDLabelsJSONBody + +// PostBucketsIDMembersJSONRequestBody defines body for PostBucketsIDMembers for application/json ContentType. +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 + +// PostDashboardsIDCellsJSONRequestBody defines body for PostDashboardsIDCells for application/json ContentType. +type PostDashboardsIDCellsJSONRequestBody PostDashboardsIDCellsJSONBody + +// PutDashboardsIDCellsJSONRequestBody defines body for PutDashboardsIDCells for application/json ContentType. +type PutDashboardsIDCellsJSONRequestBody PutDashboardsIDCellsJSONBody + +// PatchDashboardsIDCellsIDJSONRequestBody defines body for PatchDashboardsIDCellsID for application/json ContentType. +type PatchDashboardsIDCellsIDJSONRequestBody PatchDashboardsIDCellsIDJSONBody + +// PatchDashboardsIDCellsIDViewJSONRequestBody defines body for PatchDashboardsIDCellsIDView for application/json ContentType. +type PatchDashboardsIDCellsIDViewJSONRequestBody PatchDashboardsIDCellsIDViewJSONBody + +// PostDashboardsIDLabelsJSONRequestBody defines body for PostDashboardsIDLabels for application/json ContentType. +type PostDashboardsIDLabelsJSONRequestBody PostDashboardsIDLabelsJSONBody + +// PostDashboardsIDMembersJSONRequestBody defines body for PostDashboardsIDMembers for application/json ContentType. +type PostDashboardsIDMembersJSONRequestBody PostDashboardsIDMembersJSONBody + +// PostDashboardsIDOwnersJSONRequestBody defines body for PostDashboardsIDOwners for application/json ContentType. +type PostDashboardsIDOwnersJSONRequestBody PostDashboardsIDOwnersJSONBody + +// PostDBRPJSONRequestBody defines body for PostDBRP for application/json ContentType. +type PostDBRPJSONRequestBody PostDBRPJSONBody + +// PatchDBRPIDJSONRequestBody defines body for PatchDBRPID for application/json ContentType. +type PatchDBRPIDJSONRequestBody PatchDBRPIDJSONBody + +// PostDeleteJSONRequestBody defines body for PostDelete for application/json ContentType. +type PostDeleteJSONRequestBody PostDeleteJSONBody + +// PostLabelsJSONRequestBody defines body for PostLabels for application/json ContentType. +type PostLabelsJSONRequestBody PostLabelsJSONBody + +// PatchLabelsIDJSONRequestBody defines body for PatchLabelsID for application/json ContentType. +type PatchLabelsIDJSONRequestBody PatchLabelsIDJSONBody + +// PutMePasswordJSONRequestBody defines body for PutMePassword for application/json ContentType. +type PutMePasswordJSONRequestBody PutMePasswordJSONBody + +// CreateNotificationEndpointJSONRequestBody defines body for CreateNotificationEndpoint for application/json ContentType. +type CreateNotificationEndpointJSONRequestBody CreateNotificationEndpointJSONBody + +// PatchNotificationEndpointsIDJSONRequestBody defines body for PatchNotificationEndpointsID for application/json ContentType. +type PatchNotificationEndpointsIDJSONRequestBody PatchNotificationEndpointsIDJSONBody + +// PutNotificationEndpointsIDJSONRequestBody defines body for PutNotificationEndpointsID for application/json ContentType. +type PutNotificationEndpointsIDJSONRequestBody PutNotificationEndpointsIDJSONBody + +// PostNotificationEndpointIDLabelsJSONRequestBody defines body for PostNotificationEndpointIDLabels for application/json ContentType. +type PostNotificationEndpointIDLabelsJSONRequestBody PostNotificationEndpointIDLabelsJSONBody + +// CreateNotificationRuleJSONRequestBody defines body for CreateNotificationRule for application/json ContentType. +type CreateNotificationRuleJSONRequestBody CreateNotificationRuleJSONBody + +// PatchNotificationRulesIDJSONRequestBody defines body for PatchNotificationRulesID for application/json ContentType. +type PatchNotificationRulesIDJSONRequestBody PatchNotificationRulesIDJSONBody + +// PutNotificationRulesIDJSONRequestBody defines body for PutNotificationRulesID for application/json ContentType. +type PutNotificationRulesIDJSONRequestBody PutNotificationRulesIDJSONBody + +// PostNotificationRuleIDLabelsJSONRequestBody defines body for PostNotificationRuleIDLabels for application/json ContentType. +type PostNotificationRuleIDLabelsJSONRequestBody PostNotificationRuleIDLabelsJSONBody + +// PostOrgsJSONRequestBody defines body for PostOrgs for application/json ContentType. +type PostOrgsJSONRequestBody PostOrgsJSONBody + +// PatchOrgsIDJSONRequestBody defines body for PatchOrgsID for application/json ContentType. +type PatchOrgsIDJSONRequestBody PatchOrgsIDJSONBody + +// PostOrgsIDMembersJSONRequestBody defines body for PostOrgsIDMembers for application/json ContentType. +type PostOrgsIDMembersJSONRequestBody PostOrgsIDMembersJSONBody + +// PostOrgsIDOwnersJSONRequestBody defines body for PostOrgsIDOwners for application/json ContentType. +type PostOrgsIDOwnersJSONRequestBody PostOrgsIDOwnersJSONBody + +// PatchOrgsIDSecretsJSONRequestBody defines body for PatchOrgsIDSecrets for application/json ContentType. +type PatchOrgsIDSecretsJSONRequestBody PatchOrgsIDSecretsJSONBody + +// PostOrgsIDSecretsJSONRequestBody defines body for PostOrgsIDSecrets for application/json ContentType. +type PostOrgsIDSecretsJSONRequestBody PostOrgsIDSecretsJSONBody + +// PostQueryAnalyzeJSONRequestBody defines body for PostQueryAnalyze for application/json ContentType. +type PostQueryAnalyzeJSONRequestBody PostQueryAnalyzeJSONBody + +// PostQueryAstJSONRequestBody defines body for PostQueryAst for application/json ContentType. +type PostQueryAstJSONRequestBody PostQueryAstJSONBody + +// PostRemoteConnectionJSONRequestBody defines body for PostRemoteConnection for application/json ContentType. +type PostRemoteConnectionJSONRequestBody PostRemoteConnectionJSONBody + +// PatchRemoteConnectionByIDJSONRequestBody defines body for PatchRemoteConnectionByID for application/json ContentType. +type PatchRemoteConnectionByIDJSONRequestBody PatchRemoteConnectionByIDJSONBody + +// PostReplicationJSONRequestBody defines body for PostReplication for application/json ContentType. +type PostReplicationJSONRequestBody PostReplicationJSONBody + +// PatchReplicationByIDJSONRequestBody defines body for PatchReplicationByID for application/json ContentType. +type PatchReplicationByIDJSONRequestBody PatchReplicationByIDJSONBody + +// PostRestoreBucketMetadataJSONRequestBody defines body for PostRestoreBucketMetadata for application/json ContentType. +type PostRestoreBucketMetadataJSONRequestBody PostRestoreBucketMetadataJSONBody + +// PostScrapersJSONRequestBody defines body for PostScrapers for application/json ContentType. +type PostScrapersJSONRequestBody PostScrapersJSONBody + +// PatchScrapersIDJSONRequestBody defines body for PatchScrapersID for application/json ContentType. +type PatchScrapersIDJSONRequestBody PatchScrapersIDJSONBody + +// PostScrapersIDLabelsJSONRequestBody defines body for PostScrapersIDLabels for application/json ContentType. +type PostScrapersIDLabelsJSONRequestBody PostScrapersIDLabelsJSONBody + +// PostScrapersIDMembersJSONRequestBody defines body for PostScrapersIDMembers for application/json ContentType. +type PostScrapersIDMembersJSONRequestBody PostScrapersIDMembersJSONBody + +// PostScrapersIDOwnersJSONRequestBody defines body for PostScrapersIDOwners for application/json ContentType. +type PostScrapersIDOwnersJSONRequestBody PostScrapersIDOwnersJSONBody + +// PostSetupJSONRequestBody defines body for PostSetup for application/json ContentType. +type PostSetupJSONRequestBody PostSetupJSONBody + +// PostSourcesJSONRequestBody defines body for PostSources for application/json ContentType. +type PostSourcesJSONRequestBody PostSourcesJSONBody + +// PatchSourcesIDJSONRequestBody defines body for PatchSourcesID for application/json ContentType. +type PatchSourcesIDJSONRequestBody PatchSourcesIDJSONBody + +// CreateStackJSONRequestBody defines body for CreateStack for application/json ContentType. +type CreateStackJSONRequestBody CreateStackJSONBody + +// UpdateStackJSONRequestBody defines body for UpdateStack for application/json ContentType. +type UpdateStackJSONRequestBody UpdateStackJSONBody + +// PostTasksJSONRequestBody defines body for PostTasks for application/json ContentType. +type PostTasksJSONRequestBody PostTasksJSONBody + +// PatchTasksIDJSONRequestBody defines body for PatchTasksID for application/json ContentType. +type PatchTasksIDJSONRequestBody PatchTasksIDJSONBody + +// PostTasksIDLabelsJSONRequestBody defines body for PostTasksIDLabels for application/json ContentType. +type PostTasksIDLabelsJSONRequestBody PostTasksIDLabelsJSONBody + +// PostTasksIDMembersJSONRequestBody defines body for PostTasksIDMembers for application/json ContentType. +type PostTasksIDMembersJSONRequestBody PostTasksIDMembersJSONBody + +// PostTasksIDOwnersJSONRequestBody defines body for PostTasksIDOwners for application/json ContentType. +type PostTasksIDOwnersJSONRequestBody PostTasksIDOwnersJSONBody + +// PostTasksIDRunsJSONRequestBody defines body for PostTasksIDRuns for application/json ContentType. +type PostTasksIDRunsJSONRequestBody PostTasksIDRunsJSONBody + +// PostTasksIDRunsIDRetryJSONRequestBody defines body for PostTasksIDRunsIDRetry for application/json ContentType. +type PostTasksIDRunsIDRetryJSONRequestBody PostTasksIDRunsIDRetryJSONBody + +// PostTelegrafsJSONRequestBody defines body for PostTelegrafs for application/json ContentType. +type PostTelegrafsJSONRequestBody PostTelegrafsJSONBody + +// PutTelegrafsIDJSONRequestBody defines body for PutTelegrafsID for application/json ContentType. +type PutTelegrafsIDJSONRequestBody PutTelegrafsIDJSONBody + +// PostTelegrafsIDLabelsJSONRequestBody defines body for PostTelegrafsIDLabels for application/json ContentType. +type PostTelegrafsIDLabelsJSONRequestBody PostTelegrafsIDLabelsJSONBody + +// PostTelegrafsIDMembersJSONRequestBody defines body for PostTelegrafsIDMembers for application/json ContentType. +type PostTelegrafsIDMembersJSONRequestBody PostTelegrafsIDMembersJSONBody + +// PostTelegrafsIDOwnersJSONRequestBody defines body for PostTelegrafsIDOwners for application/json ContentType. +type PostTelegrafsIDOwnersJSONRequestBody PostTelegrafsIDOwnersJSONBody + +// ExportTemplateJSONRequestBody defines body for ExportTemplate for application/json ContentType. +type ExportTemplateJSONRequestBody ExportTemplateJSONBody + +// PostUsersJSONRequestBody defines body for PostUsers for application/json ContentType. +type PostUsersJSONRequestBody PostUsersJSONBody + +// PatchUsersIDJSONRequestBody defines body for PatchUsersID for application/json ContentType. +type PatchUsersIDJSONRequestBody PatchUsersIDJSONBody + +// PostUsersIDPasswordJSONRequestBody defines body for PostUsersIDPassword for application/json ContentType. +type PostUsersIDPasswordJSONRequestBody PostUsersIDPasswordJSONBody + +// PostVariablesJSONRequestBody defines body for PostVariables for application/json ContentType. +type PostVariablesJSONRequestBody PostVariablesJSONBody + +// PatchVariablesIDJSONRequestBody defines body for PatchVariablesID for application/json ContentType. +type PatchVariablesIDJSONRequestBody PatchVariablesIDJSONBody + +// PutVariablesIDJSONRequestBody defines body for PutVariablesID for application/json ContentType. +type PutVariablesIDJSONRequestBody PutVariablesIDJSONBody + +// PostVariablesIDLabelsJSONRequestBody defines body for PostVariablesIDLabels for application/json ContentType. +type PostVariablesIDLabelsJSONRequestBody PostVariablesIDLabelsJSONBody + +// Getter for additional properties for ColorMapping. Returns the specified +// element and whether it was found +func (a ColorMapping) Get(fieldName string) (value string, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for ColorMapping +func (a *ColorMapping) Set(fieldName string, value string) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]string) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for ColorMapping to handle AdditionalProperties +func (a *ColorMapping) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]string) + for fieldName, fieldBuf := range object { + var fieldVal string + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for ColorMapping to handle AdditionalProperties +func (a ColorMapping) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for Flags. Returns the specified +// element and whether it was found +func (a Flags) Get(fieldName string) (value interface{}, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for Flags +func (a *Flags) Set(fieldName string, value interface{}) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]interface{}) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for Flags to handle AdditionalProperties +func (a *Flags) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]interface{}) + for fieldName, fieldBuf := range object { + var fieldVal interface{} + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for Flags to handle AdditionalProperties +func (a Flags) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for FluxSuggestion_Params. Returns the specified +// element and whether it was found +func (a FluxSuggestion_Params) Get(fieldName string) (value string, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for FluxSuggestion_Params +func (a *FluxSuggestion_Params) Set(fieldName string, value string) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]string) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for FluxSuggestion_Params to handle AdditionalProperties +func (a *FluxSuggestion_Params) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]string) + for fieldName, fieldBuf := range object { + var fieldVal string + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for FluxSuggestion_Params to handle AdditionalProperties +func (a FluxSuggestion_Params) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for HTTPNotificationEndpoint_Headers. Returns the specified +// element and whether it was found +func (a HTTPNotificationEndpoint_Headers) Get(fieldName string) (value string, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for HTTPNotificationEndpoint_Headers +func (a *HTTPNotificationEndpoint_Headers) Set(fieldName string, value string) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]string) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for HTTPNotificationEndpoint_Headers to handle AdditionalProperties +func (a *HTTPNotificationEndpoint_Headers) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]string) + for fieldName, fieldBuf := range object { + var fieldVal string + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for HTTPNotificationEndpoint_Headers to handle AdditionalProperties +func (a HTTPNotificationEndpoint_Headers) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for Label_Properties. Returns the specified +// element and whether it was found +func (a Label_Properties) Get(fieldName string) (value string, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for Label_Properties +func (a *Label_Properties) Set(fieldName string, value string) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]string) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for Label_Properties to handle AdditionalProperties +func (a *Label_Properties) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]string) + for fieldName, fieldBuf := range object { + var fieldVal string + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for Label_Properties to handle AdditionalProperties +func (a Label_Properties) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for LabelCreateRequest_Properties. Returns the specified +// element and whether it was found +func (a LabelCreateRequest_Properties) Get(fieldName string) (value string, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for LabelCreateRequest_Properties +func (a *LabelCreateRequest_Properties) Set(fieldName string, value string) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]string) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for LabelCreateRequest_Properties to handle AdditionalProperties +func (a *LabelCreateRequest_Properties) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]string) + for fieldName, fieldBuf := range object { + var fieldVal string + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for LabelCreateRequest_Properties to handle AdditionalProperties +func (a LabelCreateRequest_Properties) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for LabelUpdate_Properties. Returns the specified +// element and whether it was found +func (a LabelUpdate_Properties) Get(fieldName string) (value string, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for LabelUpdate_Properties +func (a *LabelUpdate_Properties) Set(fieldName string, value string) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]string) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for LabelUpdate_Properties to handle AdditionalProperties +func (a *LabelUpdate_Properties) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]string) + for fieldName, fieldBuf := range object { + var fieldVal string + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for LabelUpdate_Properties to handle AdditionalProperties +func (a LabelUpdate_Properties) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for MapVariableProperties_Values. Returns the specified +// element and whether it was found +func (a MapVariableProperties_Values) Get(fieldName string) (value string, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for MapVariableProperties_Values +func (a *MapVariableProperties_Values) Set(fieldName string, value string) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]string) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for MapVariableProperties_Values to handle AdditionalProperties +func (a *MapVariableProperties_Values) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]string) + for fieldName, fieldBuf := range object { + var fieldVal string + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for MapVariableProperties_Values to handle AdditionalProperties +func (a MapVariableProperties_Values) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for Query_Params. Returns the specified +// element and whether it was found +func (a Query_Params) Get(fieldName string) (value interface{}, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for Query_Params +func (a *Query_Params) Set(fieldName string, value interface{}) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]interface{}) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for Query_Params to handle AdditionalProperties +func (a *Query_Params) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]interface{}) + for fieldName, fieldBuf := range object { + var fieldVal interface{} + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for Query_Params to handle AdditionalProperties +func (a Query_Params) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for Secrets. Returns the specified +// element and whether it was found +func (a Secrets) Get(fieldName string) (value string, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for Secrets +func (a *Secrets) Set(fieldName string, value string) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]string) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for Secrets to handle AdditionalProperties +func (a *Secrets) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]string) + for fieldName, fieldBuf := range object { + var fieldVal string + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for Secrets to handle AdditionalProperties +func (a Secrets) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for TemplateApply_EnvRefs. Returns the specified +// element and whether it was found +func (a TemplateApply_EnvRefs) Get(fieldName string) (value interface{}, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for TemplateApply_EnvRefs +func (a *TemplateApply_EnvRefs) Set(fieldName string, value interface{}) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]interface{}) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for TemplateApply_EnvRefs to handle AdditionalProperties +func (a *TemplateApply_EnvRefs) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]interface{}) + for fieldName, fieldBuf := range object { + var fieldVal interface{} + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for TemplateApply_EnvRefs to handle AdditionalProperties +func (a TemplateApply_EnvRefs) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// Getter for additional properties for TemplateApply_Secrets. Returns the specified +// element and whether it was found +func (a TemplateApply_Secrets) Get(fieldName string) (value string, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for TemplateApply_Secrets +func (a *TemplateApply_Secrets) Set(fieldName string, value string) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]string) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for TemplateApply_Secrets to handle AdditionalProperties +func (a *TemplateApply_Secrets) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]string) + for fieldName, fieldBuf := range object { + var fieldVal string + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for TemplateApply_Secrets to handle AdditionalProperties +func (a TemplateApply_Secrets) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} diff --git a/influxclient/organization_test.go b/influxclient/organization_test.go new file mode 100644 index 00000000..88600e2e --- /dev/null +++ b/influxclient/organization_test.go @@ -0,0 +1,108 @@ +package influxclient + +import ( + "context" + "net/http" + "net/http/httptest" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestOrganizationAPI_Find(t *testing.T) { + var findTests = []struct { + testName string + filter *Filter + response string + orgCount int + statusCode int + errorMessage string + }{ + { + testName: "Find 1 no filter", + filter: nil, + response: ` { + "links": { + "next": "http://example.com", + "prev": "http://example.com", + "self": "http://example.com" + }, + "orgs": [ + { + "createdAt": "2019-08-24T14:15:22Z", + "description": "string", + "id": "123456", + "links": { + "buckets": "/api/v2/buckets?org=myorg", + "dashboards": "/api/v2/dashboards?org=myorg", + "labels": "/api/v2/orgs/1/labels", + "members": "/api/v2/orgs/1/members", + "owners": "/api/v2/orgs/1/owners", + "secrets": "/api/v2/orgs/1/secrets", + "self": "/api/v2/orgs/1", + "tasks": "/api/v2/tasks?org=myorg" + }, + "name": "my-org", + "status": "active", + "updatedAt": "2019-08-24T14:15:22Z" + } +] +}`, + orgCount: 1, + statusCode: 200, + errorMessage: "", + }, + { + testName: "Empty resultset", + filter: nil, + response: ` { + "links": { + "next": "http://example.com", + "prev": "http://example.com", + "self": "http://example.com" + }, + "orgs": [] +}`, + orgCount: 0, + statusCode: 200, + errorMessage: "", + }, + { + testName: "Find nothing", + filter: nil, + response: `{"code": "not found", "message": "organization name \"myorg\" not found"}`, + orgCount: 0, + statusCode: 400, + errorMessage: `not found: organization name "myorg" not found`, + }, + } + for _, test := range findTests { + t.Run(test.testName, func(t *testing.T) { + ctx := context.Background() + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(test.statusCode) + if len(test.response) > 0 { + w.Write([]byte(test.response)) + } + })) + defer server.Close() + c, err := New(Params{ + ServerURL: server.URL, + }) + require.NoError(t, err) + orgsAPI := c.OrganizationAPI() + + orgList, err := orgsAPI.Find(ctx, test.filter) + if test.errorMessage != "" { + require.Error(t, err) + assert.Equal(t, test.errorMessage, err.Error()) + } else { + require.NoError(t, err) + require.NotNil(t, orgList) + assert.Len(t, orgList, test.orgCount) + } + }) + } +} diff --git a/influxclient/organizations.go b/influxclient/organizations.go new file mode 100644 index 00000000..083877fb --- /dev/null +++ b/influxclient/organizations.go @@ -0,0 +1,224 @@ +// Copyright 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 influxclient provides client for InfluxDB server. +package influxclient + +import ( + "context" + "fmt" + + "github.com/influxdata/influxdb-client-go/influxclient/model" +) + +// OrganizationAPI holds methods related to organization, as found under +// the /orgs endpoint. +type OrganizationAPI struct { + client *model.Client +} + +// newOrganizationAPI returns new OrganizationAPI instance +func newOrganizationAPI(client *model.Client) *OrganizationAPI { + return &OrganizationAPI{client: client} +} + +// Find returns all organizations matching the given filter. +// Supported filters: +// - OrgName +// - OrgID +// - UserID +func (o *OrganizationAPI) Find(ctx context.Context, filter *Filter) ([]model.Organization, error) { + return o.getOrganizations(ctx, filter) +} + +// getOrganizations create request for GET on /orgs according to the filter and validates returned structure +func (o *OrganizationAPI) getOrganizations(ctx context.Context, filter *Filter) ([]model.Organization, error) { + params := &model.GetOrgsParams{} + if filter != nil { + if filter.OrgName != "" { + params.Org = &filter.OrgName + } + if filter.OrgID != "" { + params.OrgID = &filter.OrgID + } + if filter.UserID != "" { + params.UserID = &filter.UserID + } + if filter.Limit > 0 { + limit := model.Limit(filter.Limit) + params.Limit = &limit + } + if filter.Offset > 0 { + offset := model.Offset(filter.Offset) + params.Offset = &offset + } + } + response, err := o.client.GetOrgs(ctx, params) + if err != nil { + return nil, err + } + return *response.Orgs, nil +} + +// FindOne returns one organization matching the given filter. +// Supported filters: +// - OrgName +// - OrgID +// - UserID +func (o *OrganizationAPI) FindOne(ctx context.Context, filter *Filter) (*model.Organization, error) { + organizations, err := o.getOrganizations(ctx, filter) + if err != nil { + return nil, err + } + if len(organizations) > 0 { + return &(organizations)[0], nil + } + return nil, fmt.Errorf("organization not found") +} + +// Create creates a new organization. The returned Organization holds the new ID. +func (o *OrganizationAPI) Create(ctx context.Context, org *model.Organization) (*model.Organization, error) { + if org == nil { + return nil, fmt.Errorf("org cannot be nil") + } + if org.Name == "" { + return nil, fmt.Errorf("name is required") + } + params := &model.PostOrgsAllParams{ + Body: model.PostOrgsJSONRequestBody{ + Name: org.Name, + Description: org.Description, + }, + } + return o.client.PostOrgs(ctx, params) +} + +// Update updates information about the organization. The org.ID field must hold the ID +// of the organization to be changed. +func (o *OrganizationAPI) Update(ctx context.Context, org *model.Organization) (*model.Organization, error) { + if org == nil { + return nil, fmt.Errorf("org cannot be nil") + } + if org.Id == nil { + return nil, fmt.Errorf("org ID is required") + } + if org.Name == "" { + return nil, fmt.Errorf("name is required") + } + params := &model.PatchOrgsIDAllParams{ + OrgID: *org.Id, + Body: model.PatchOrgsIDJSONRequestBody{ + Name: &org.Name, + Description: org.Description, + }, + } + return o.client.PatchOrgsID(ctx, params) +} + +// Delete deletes the organization with the given ID. +func (o *OrganizationAPI) Delete(ctx context.Context, orgID string) error { + if orgID == "" { + return fmt.Errorf("orgID is required") + } + params := &model.DeleteOrgsIDAllParams{ + OrgID: orgID, + } + return o.client.DeleteOrgsID(ctx, params) +} + +// Members returns all members of the organization with the given ID. +func (o *OrganizationAPI) Members(ctx context.Context, orgID string) ([]model.ResourceMember, error) { + if orgID == "" { + return nil, fmt.Errorf("orgID is required") + } + params := &model.GetOrgsIDMembersAllParams{ + OrgID: orgID, + } + response,err := o.client.GetOrgsIDMembers(ctx, params) + if err != nil { + return nil, err + } + return *response.Users, nil +} + +// AddMember adds the user with the given ID to the organization with the given ID. +func (o *OrganizationAPI) AddMember(ctx context.Context, orgID, userID string) error { + if orgID == "" { + return fmt.Errorf("orgID is required") + } + if userID == "" { + return fmt.Errorf("userID is required") + } + params := &model.PostOrgsIDMembersAllParams{ + OrgID: orgID, + Body: model.PostOrgsIDMembersJSONRequestBody{ + Id: userID, + }, + } + _, err := o.client.PostOrgsIDMembers(ctx, params) + return err +} + +// RemoveMember removes the user with the given ID from the organization with the given ID. +func (o *OrganizationAPI) RemoveMember(ctx context.Context, orgID, userID string) error { + if orgID == "" { + return fmt.Errorf("orgID is required") + } + if userID == "" { + return fmt.Errorf("userID is required") + } + params := &model.DeleteOrgsIDMembersIDAllParams{ + OrgID: orgID, + UserID: userID, + } + return o.client.DeleteOrgsIDMembersID(ctx, params) +} + +// Owners returns all the owners of the organization with the given id. +func (o *OrganizationAPI) Owners(ctx context.Context, orgID string) ([]model.ResourceOwner, error) { + if orgID == "" { + return nil, fmt.Errorf("orgID is required") + } + params := &model.GetOrgsIDOwnersAllParams{ + OrgID: orgID, + } + response, err := o.client.GetOrgsIDOwners(ctx, params) + if err != nil { + return nil, err + } + return *response.Users, nil +} + +// AddOwner adds an owner with the given userID to the organization with the given id. +func (o *OrganizationAPI) AddOwner(ctx context.Context, orgID, userID string) error { + if orgID == "" { + return fmt.Errorf("orgID is required") + } + if userID == "" { + return fmt.Errorf("userID is required") + } + params := &model.PostOrgsIDOwnersAllParams{ + OrgID: orgID, + Body: model.PostOrgsIDOwnersJSONRequestBody{ + Id: userID, + }, + } + _, err := o.client.PostOrgsIDOwners(ctx, params) + return err +} + +// RemoveOwner Remove removes the user with the given userID from the organization with the given id. +func (o *OrganizationAPI) RemoveOwner(ctx context.Context, orgID, userID string) error { + if orgID == "" { + return fmt.Errorf("orgID is required") + } + if userID == "" { + return fmt.Errorf("userID is required") + } + params := &model.DeleteOrgsIDOwnersIDAllParams{ + OrgID: orgID, + UserID: userID, + } + return o.client.DeleteOrgsIDOwnersID(ctx, params) +} diff --git a/influxclient/organizations_e2e_test.go b/influxclient/organizations_e2e_test.go new file mode 100644 index 00000000..5e28aeed --- /dev/null +++ b/influxclient/organizations_e2e_test.go @@ -0,0 +1,395 @@ +// +build e2e + +// 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 influxclient_test + +import ( + "fmt" + "testing" + + . "github.com/influxdata/influxdb-client-go/influxclient" + "github.com/influxdata/influxdb-client-go/influxclient/model" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestOrganizationsAPI(t *testing.T) { + client, ctx := newClient(t) + orgsAPI := client.OrganizationAPI() + usersAPI := client.UsersAPI() + + // find onboarded orgs + orgs, err := orgsAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, orgs) + assert.Len(t, orgs, 1) + + // find onboarded org + org, err := orgsAPI.FindOne(ctx, nil) + require.NoError(t, err) + require.NotNil(t, orgs) + + user2Name := "user-01" + org2Name := "my-org-2" + org2Description := "my-org 2 description" + + // create new org + org2, err := orgsAPI.Create(ctx, &model.Organization{ + Name: org2Name, + }) + require.NoError(t, err) + require.NotNil(t, org2) + defer orgsAPI.Delete(ctx, safeId(org2.Id)) + assert.Equal(t, org2Name, org2.Name) + + // attempt to to create org with existing name + _, err = orgsAPI.Create(ctx, &model.Organization{ + Name: org2.Name, + }) + assert.Error(t, err) + + // update + org2.Description = &org2Description + org2, err = orgsAPI.Update(ctx, org2) + require.NoError(t, err) + require.NotNil(t, org2) + assert.Equal(t, org2Description, *org2.Description) + + // find more + orgs, err = orgsAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, orgs) + assert.Len(t, orgs, 2) + + // create authorization for new org + permissions := []model.Permission{ + { + Action: model.PermissionActionWrite, + Resource: model.Resource{ + Type: model.ResourceTypeBuckets, + }, + }, + } + auth2, err := client.AuthorizationsAPI().Create(ctx, &model.Authorization{ + OrgID: org2.Id, + Permissions: &permissions, + }) + require.NoError(t, err) + require.NotNil(t, auth2) + defer client.AuthorizationsAPI().Delete(ctx, safeId(auth2.Id)) + + // create client with new auth token without permission + clientOrg2, err := New(Params{ ServerURL: serverURL, AuthToken: *auth2.Token}) + require.NoError(t, err) + + orgs2, err := clientOrg2.OrganizationAPI().Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, orgs2) + assert.Len(t, orgs2, 0) + + // find org using token without org permission + orgx, err := clientOrg2.OrganizationAPI().FindOne(ctx, &Filter{ + Name: org.Name, + }) + assert.Error(t, err) + assert.Nil(t, orgx) + + err = client.AuthorizationsAPI().Delete(ctx, *auth2.Id) + require.NoError(t, err) + + // members + members, err := orgsAPI.Members(ctx, *org2.Id) + require.NoError(t, err) + require.NotNil(t, members) + require.Len(t, members, 0) + + user, err := usersAPI.Create(ctx, &model.User{ + Name: user2Name, + }) + require.NoError(t, err) + require.NotNil(t, user) + defer usersAPI.Delete(ctx, safeId(user.Id)) + + err = orgsAPI.AddMember(ctx, *org2.Id, *user.Id) + require.NoError(t, err) + + members, err = orgsAPI.Members(ctx, *org2.Id) + require.NoError(t, err) + require.NotNil(t, members) + require.Len(t, members, 1) + + org, err = orgsAPI.FindOne(ctx, &Filter{ + OrgID: *org2.Id, + }) + require.NoError(t, err) + require.NotNil(t, org) + assert.Equal(t, org2.Name, org.Name) + + orgs, err = orgsAPI.Find(ctx, &Filter{ + UserID: *user.Id, + }) + require.NoError(t, err) + require.NotNil(t, orgs) + require.Len(t, orgs, 1) + assert.Equal(t, org2.Name, orgs[0].Name) + + org3Name := "my-org-3" + org3, err := orgsAPI.Create(ctx, &model.Organization{ + Name: org3Name, + }) + require.NoError(t, err) + require.NotNil(t, org3) + defer orgsAPI.Delete(ctx, safeId(org3.Id)) + assert.Equal(t, org3Name, org3.Name) + + orgs, err = orgsAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, orgs) + assert.Len(t, orgs, 3) + + owners, err := orgsAPI.Owners(ctx, *org3.Id) + assert.NoError(t, err) + assert.NotNil(t, owners) + assert.Len(t, owners, 1) + + err = orgsAPI.AddOwner(ctx, *org3.Id, *user.Id) + assert.NoError(t, err) + + owners, err = orgsAPI.Owners(ctx, *org3.Id) + require.NoError(t, err) + require.NotNil(t, owners) + assert.Len(t, owners, 2) + + u, err := usersAPI.FindOne(ctx, &Filter{ + Name: user2Name, + }) + require.NoError(t, err) + require.NotNil(t, u) + + err = orgsAPI.RemoveOwner(ctx, *org3.Id, *u.Id) + require.NoError(t, err) + + owners, err = orgsAPI.Owners(ctx, *org3.Id) + require.NoError(t, err) + require.NotNil(t, owners) + assert.Len(t, owners, 1) + + orgs, err = orgsAPI.Find(ctx, &Filter{ + UserID: *user.Id, + }) + require.NoError(t, err) + require.NotNil(t, orgs) + require.Len(t, orgs, 1) + + err = orgsAPI.RemoveMember(ctx, *org2.Id, *user.Id) + require.NoError(t, err) + + members, err = orgsAPI.Members(ctx, *org2.Id) + require.NoError(t, err) + require.NotNil(t, members) + require.Len(t, members, 0) + + err = usersAPI.Delete(ctx, *user.Id) + require.NoError(t, err) + + err = orgsAPI.Delete(ctx, *org3.Id) + require.NoError(t, err) + + err = orgsAPI.Delete(ctx, *org2.Id) + assert.NoError(t, err) + + orgs, err = orgsAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, orgs) + assert.Len(t, orgs, 1) +} + +func TestOrganizationAPI_pagination(t *testing.T) { + client, ctx := newClient(t) + orgsAPI := client.OrganizationAPI() + + for i := 0; i < 50; i++ { + org, err := orgsAPI.Create(ctx, &model.Organization{ + Name: fmt.Sprintf("org-%02d", i+1), + }) + require.NoError(t, err) + require.NotNil(t, org) + defer orgsAPI.Delete(ctx, safeId(org.Id)) + } + + orgs, err := orgsAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, orgs) + require.Len(t, orgs, 20) + + orgs, err = orgsAPI.Find(ctx, &Filter{ + Offset: 20, + }) + require.NoError(t, err) + require.NotNil(t, orgs) + require.Len(t, orgs, 20) + + orgs, err = orgsAPI.Find(ctx, &Filter{ + Offset: 40, + }) + require.NoError(t, err) + require.NotNil(t, orgs) + require.Len(t, orgs, 11) + + orgs, err = orgsAPI.Find(ctx, &Filter{ + Limit: 100, + }) + require.NoError(t, err) + require.NotNil(t, orgs) + require.Len(t, orgs, 51) +} + +func TestOrganizationAPI_failing(t *testing.T) { + client, ctx := newClient(t) + orgsAPI := client.OrganizationAPI() + + // try nil input + org, err := orgsAPI.Create(ctx, nil) + assert.Error(t, err) + require.Nil(t, org) + + // try empty org name + org, err = orgsAPI.Create(ctx, &model.Organization{}) + assert.Error(t, err) + require.Nil(t, org) + + org, err = orgsAPI.Create(ctx, &model.Organization{ + Name: "failing", + }) + require.NoError(t, err) + assert.NotNil(t, org) + defer orgsAPI.Delete(ctx, safeId(org.Id)) + + err = orgsAPI.AddMember(ctx, *org.Id, notExistingID) + assert.Error(t, err) + + err = orgsAPI.AddMember(ctx, *org.Id, notInitializedID) + assert.Error(t, err) + + // get members with invalid org id + members, err := orgsAPI.Members(ctx, invalidID) + assert.Error(t, err) + assert.Nil(t, members) + + // get member with not existing id + members, err = orgsAPI.Members(ctx, notExistingID) + assert.Error(t, err) + assert.Nil(t, members) + + members, err = orgsAPI.Members(ctx, notInitializedID) + assert.Error(t, err) + assert.Nil(t, members) + + //get owners with invalid id + owners, err := orgsAPI.Owners(ctx, invalidID) + assert.Error(t, err) + assert.Nil(t, owners) + + owners, err = orgsAPI.Owners(ctx, notInitializedID) + assert.Error(t, err) + assert.Nil(t, owners) + + //get owners with not existing id + owners, err = orgsAPI.Owners(ctx, notExistingID) + assert.Error(t, err) + assert.Nil(t, owners) + + // add owner with invalid ID + err = orgsAPI.AddOwner(ctx, *org.Id, notExistingID) + assert.Error(t, err) + + err = orgsAPI.AddOwner(ctx, notInitializedID, notExistingID) + assert.Error(t, err) + + err = orgsAPI.AddOwner(ctx, *org.Id, notInitializedID) + assert.Error(t, err) + + // update with nil input + _, err = orgsAPI.Update(ctx, nil) + assert.Error(t, err) + + // update with nil org ID + _, err = orgsAPI.Update(ctx, &model.Organization{ + Id: nil, + Name: org.Name, + }) + assert.Error(t, err) + + // update with empty name + _, err = orgsAPI.Update(ctx, &model.Organization{ + Id: org.Id, + Name: "", + }) + assert.Error(t, err) + + // update with not existing id + _, err = orgsAPI.Update(ctx, &model.Organization{ + Id: ¬ExistingID, + Name: org.Name, + }) + assert.Error(t, err) + + // remove owner with invalid ID + err = orgsAPI.RemoveOwner(ctx, notExistingID, notExistingID) + assert.Error(t, err) + + err = orgsAPI.RemoveOwner(ctx, notInitializedID, notExistingID) + assert.Error(t, err) + + err = orgsAPI.RemoveOwner(ctx, notExistingID, notInitializedID) + assert.Error(t, err) + + // remove invalid memberID + err = orgsAPI.RemoveMember(ctx, notExistingID, notExistingID) + assert.Error(t, err) + + err = orgsAPI.RemoveMember(ctx, notInitializedID, notExistingID) + assert.Error(t, err) + + err = orgsAPI.RemoveMember(ctx, notExistingID, notInitializedID) + assert.Error(t, err) + + // delete not existent org + err = orgsAPI.Delete(ctx, notExistingID) + assert.Error(t, err) + + // delete invalid org + err = orgsAPI.Delete(ctx, invalidID) + assert.Error(t, err) + + // delete invalid org + err = orgsAPI.Delete(ctx, notInitializedID) + assert.Error(t, err) +} + +func TestOrganizationAPI_skip(t *testing.T) { + t.Skip("Should fail but doesn't") + + // https://github.com/influxdata/influxdb/issues/19110 + + client, ctx := newClient(t) + orgsAPI := client.OrganizationAPI() + + // find by not existing org ID + o, err := orgsAPI.FindOne(ctx, &Filter{ + ID: notExistingID, + }) + assert.NotNil(t, err, "Should fail when filtering by non-existent ID") + assert.Nil(t, o, "Should be nil when filtering by non-existent ID") + + // find by not existing user ID + orgs, err := orgsAPI.Find(ctx, &Filter{ + UserID: notExistingID, + }) + assert.NotNil(t, err, "Should fail when filtering by non-existent user ID") + assert.Nil(t, o, "Should be nil when filtering by non-existent user ID") + assert.Len(t, orgs, 0) +} diff --git a/influxclient/query_test.go b/influxclient/query_test.go index 9cf7db23..417c4265 100644 --- a/influxclient/query_test.go +++ b/influxclient/query_test.go @@ -12,7 +12,7 @@ import ( "time" "github.com/influxdata/influxdb-client-go/annotatedcsv" - influxclient "github.com/influxdata/influxdb-client-go/influxclient" + "github.com/influxdata/influxdb-client-go/influxclient" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/influxclient/tasks.go b/influxclient/tasks.go new file mode 100644 index 00000000..602ac368 --- /dev/null +++ b/influxclient/tasks.go @@ -0,0 +1,466 @@ +// Copyright 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 influxclient provides client for InfluxDB server. +package influxclient + +import ( + "context" + "fmt" + + "github.com/influxdata/influxdb-client-go/influxclient/model" +) + +// TasksAPI holds methods related to organization, as found under +// the /tasks endpoint. +type TasksAPI struct { + client *model.Client +} + +// newTasksAPI returns new TasksAPI instance +func newTasksAPI(client *model.Client) *TasksAPI { + return &TasksAPI{client: client} +} + +// Find returns all tasks matching the given filter. +// Supported filters: +// After +// Name +// OrgName +// OrgID +// UserName +// Status +// Limit +func (a *TasksAPI) Find(ctx context.Context, filter *Filter) ([]model.Task, error) { + return a.getTasks(ctx, filter) +} + +// FindOne returns one task matching the given filter. +// Supported filters: +// After +// Name +// OrgName +// OrgID +// UserName +// Status +// Limit +func (a *TasksAPI) FindOne(ctx context.Context, filter *Filter) (*model.Task, error){ + tasks, err := a.getTasks(ctx, filter) + if err != nil { + return nil, err + } + if len(tasks) > 0 { + return &(tasks)[0], nil + } + return nil, fmt.Errorf("task not found") +} + +// Create creates a new task according the the task object. +// Set OrgId, Name, Description, Flux, Status and Every or Cron properties. +// Every and Cron are mutually exclusive. Every has higher priority. +func (a *TasksAPI) Create(ctx context.Context, task *model.Task) (*model.Task, error) { + if task == nil { + return nil, fmt.Errorf("task cannot be nil") + } + if task.OrgID == "" && task.Org == nil { + return nil, fmt.Errorf("either orgID or org is required") + } + if task.Flux == "" { + return nil, fmt.Errorf("flux is required") + } + var repetition string + if task.Every != nil { + repetition = fmt.Sprintf("every: %s", *task.Every) + } else if task.Cron != nil { + repetition = fmt.Sprintf(`cron: "%s"`, *task.Cron) + } + var flux string + if repetition != "" { + flux = fmt.Sprintf("option task = { name: \"%s\", %s }\n\n%s", task.Name, repetition, task.Flux) + } else { + flux = task.Flux + } + params := &model.PostTasksAllParams{ + Body: model.PostTasksJSONRequestBody{ + Description: task.Description, + Flux: flux, + Status: task.Status, + }, + } + if task.OrgID != "" { + params.Body.OrgID = &task.OrgID + } else { + params.Body.Org = task.Org + } + return a.client.PostTasks(ctx, params) +} + +// Update updates a task. The task.ID field must be specified. +// The complete task information is returned. +func (a *TasksAPI) Update(ctx context.Context, task *model.Task) (*model.Task, error) { + if task == nil { + return nil, fmt.Errorf("task cannot be nil") + } + if task.Id == "" { + return nil, fmt.Errorf("task ID is required") + } + params := &model.PatchTasksIDAllParams{ + TaskID: task.Id, + Body: model.PatchTasksIDJSONRequestBody{ + Name: &task.Name, + Description: task.Description, + Offset: task.Offset, + Flux: &task.Flux, + Status: task.Status, + }, + } + if task.Every != nil { + params.Body.Every = task.Every + } else if task.Cron != nil { + params.Body.Cron = task.Cron + } + return a.client.PatchTasksID(ctx, params) +} + +// Delete deletes the task with the given ID. +func (a *TasksAPI) Delete(ctx context.Context, taskID string) error { + if taskID == "" { + return fmt.Errorf("taskID is required") + } + params := &model.DeleteTasksIDAllParams{ + TaskID: taskID, + } + return a.client.DeleteTasksID(ctx, params) +} + +// FindRuns returns a task runs according the filter. +// Supported filters: +// After +// AfterTime +// BeforeTime +// Limit +func (a *TasksAPI) FindRuns(ctx context.Context, taskID string, filter *Filter) ([]model.Run, error){ + if taskID == "" { + return nil, fmt.Errorf("taskID is required") + } + params := &model.GetTasksIDRunsAllParams{ + TaskID: taskID, + } + if filter != nil { + if filter.After != "" { + params.After = &filter.After + } + if !filter.AfterTime.IsZero() { + params.AfterTime = &filter.AfterTime + } + if !filter.BeforeTime.IsZero() { + params.BeforeTime = &filter.BeforeTime + } + if filter.Limit > 0 { + iLimit := int(filter.Limit) + params.Limit = &iLimit + } + } + response, err := a.client.GetTasksIDRuns(ctx, params) + if err != nil { + return nil, err + } + return *response.Runs, nil +} + +// FindOneRun returns one task run that matches the given filter. +// Supported filters: +// ID +// TODO or just pass runID instead of a filter? +func (a *TasksAPI) FindOneRun(ctx context.Context, taskID string, filter *Filter) (*model.Run, error) { + if taskID == "" { + return nil, fmt.Errorf("taskID is required") + } + if filter == nil { + return nil, fmt.Errorf("filter cannot be nil") + } + if filter.ID == "" { + return nil, fmt.Errorf("ID is required") + } + params := &model.GetTasksIDRunsIDAllParams{ + TaskID: taskID, + RunID: filter.ID, + } + return a.client.GetTasksIDRunsID(ctx, params) +} + +// FindRunLogs return all log events for a task run with given ID. +func (a *TasksAPI) FindRunLogs(ctx context.Context, taskID, runID string) ([]model.LogEvent, error) { + if taskID == "" { + return nil, fmt.Errorf("taskID is required") + } + if runID == "" { + return nil, fmt.Errorf("runID is required") + } + params := &model.GetTasksIDRunsIDLogsAllParams{ + TaskID: taskID, + RunID: runID, + } + response, err := a.client.GetTasksIDRunsIDLogs(ctx, params) + if err != nil { + return nil, err + } + return *response.Events, nil +} + +// RunManually manually start a run of a task with given ID now, overriding the current schedule. +func (a *TasksAPI) RunManually(ctx context.Context, taskID string) (*model.Run, error) { + if taskID == "" { + return nil, fmt.Errorf("taskID is required") + } + params := &model.PostTasksIDRunsAllParams{ + TaskID: taskID, + Body: model.PostTasksIDRunsJSONRequestBody{ + // ScheduledFor not set for immediate execution + }, + } + return a.client.PostTasksIDRuns(ctx, params) +} + +// CancelRun cancels a running task with given ID and given run ID. +func (a *TasksAPI) CancelRun(ctx context.Context, taskID, runID string) error { + if taskID == "" { + return fmt.Errorf("taskID is required") + } + if runID == "" { + return fmt.Errorf("runID is required") + } + params := &model.DeleteTasksIDRunsIDAllParams{ + TaskID: taskID, + RunID: runID, + } + return a.client.DeleteTasksIDRunsID(ctx, params) +} + +// RetryRun retry a run with given ID of a task with given ID. +func (a *TasksAPI) RetryRun(ctx context.Context, taskID, runID string) (*model.Run, error) { + if taskID == "" { + return nil, fmt.Errorf("taskID is required") + } + if runID == "" { + return nil, fmt.Errorf("runID is required") + } + params := &model.PostTasksIDRunsIDRetryAllParams{ + TaskID: taskID, + RunID: runID, + } + return a.client.PostTasksIDRunsIDRetry(ctx, params) +} + +// FindLogs retrieves all logs for a task with given ID. +func (a *TasksAPI) FindLogs(ctx context.Context, taskID string) ([]model.LogEvent, error) { + if taskID == "" { + return nil, fmt.Errorf("taskID is required") + } + params := &model.GetTasksIDLogsAllParams{ + TaskID: taskID, + } + response, err := a.client.GetTasksIDLogs(ctx, params) + if err != nil { + return nil, err + } + return *response.Events, nil +} + +// FindLabels retrieves labels of a task with given ID. +func (a *TasksAPI) FindLabels(ctx context.Context, taskID string) ([]model.Label, error) { + if taskID == "" { + return nil, fmt.Errorf("taskID is required") + } + params := &model.GetTasksIDLabelsAllParams{ + TaskID: taskID, + } + response, err := a.client.GetTasksIDLabels(ctx, params) + if err != nil { + return nil, err + } + return *response.Labels, nil +} + +// AddLabel adds a label with given ID to a task with given ID. +func (a *TasksAPI) AddLabel(ctx context.Context, taskID, labelID string) (*model.Label, error) { + if taskID == "" { + return nil, fmt.Errorf("taskID is required") + } + if labelID == "" { + return nil, fmt.Errorf("labelID is required") + } + params := &model.PostTasksIDLabelsAllParams{ + TaskID: taskID, + Body: model.PostTasksIDLabelsJSONRequestBody{ + LabelID: &labelID, + }, + } + response, err := a.client.PostTasksIDLabels(ctx, params) + if err != nil { + return nil, err + } + return response.Label, nil +} + +// RemoveLabel removes a label with given ID from a task with given ID. +func (a *TasksAPI) RemoveLabel(ctx context.Context, taskID, labelID string) error { + if taskID == "" { + return fmt.Errorf("taskID is required") + } + if labelID == "" { + return fmt.Errorf("labelID is required") + } + params := &model.DeleteTasksIDLabelsIDAllParams{ + TaskID: taskID, + LabelID: labelID, + } + return a.client.DeleteTasksIDLabelsID(ctx, params) +} + +// Members returns all members of the task with the given ID. +func (a *TasksAPI) Members(ctx context.Context, taskID string) ([]model.ResourceMember, error) { + if taskID == "" { + return nil, fmt.Errorf("taskID is required") + } + params := &model.GetTasksIDMembersAllParams{ + TaskID: taskID, + } + response, err := a.client.GetTasksIDMembers(ctx, params) + if err != nil { + return nil, err + } + return *response.Users, nil +} + +// AddMember adds the user with the given ID to the task with the given ID. +func (a *TasksAPI) AddMember(ctx context.Context, taskID, userID string) error { + if taskID == "" { + return fmt.Errorf("taskID is required") + } + if userID == "" { + return fmt.Errorf("userID is required") + } + params := &model.PostTasksIDMembersAllParams{ + TaskID: taskID, + Body: model.PostTasksIDMembersJSONRequestBody{ + Id: userID, + }, + } + _, err := a.client.PostTasksIDMembers(ctx, params) + return err +} + +// RemoveMember removes the user with the given ID from the task with the given ID. +func (a *TasksAPI) RemoveMember(ctx context.Context, taskID, userID string) error { + if taskID == "" { + return fmt.Errorf("taskID is required") + } + if userID == "" { + return fmt.Errorf("userID is required") + } + params := &model.DeleteTasksIDMembersIDAllParams{ + TaskID: taskID, + UserID: userID, + } + return a.client.DeleteTasksIDMembersID(ctx, params) +} + +// Owners returns all the owners of the task with the given id. +func (a *TasksAPI) Owners(ctx context.Context, taskID string) ([]model.ResourceOwner, error) { + if taskID == "" { + return nil, fmt.Errorf("taskID is required") + } + params := &model.GetTasksIDOwnersAllParams{ + TaskID: taskID, + } + response, err := a.client.GetTasksIDOwners(ctx, params) + if err != nil { + return nil, err + } + return *response.Users, nil +} + +// AddOwner adds an owner with the given userID to the task with the given id. +func (a *TasksAPI) AddOwner(ctx context.Context, taskID, userID string) error { + if taskID == "" { + return fmt.Errorf("taskID is required") + } + if userID == "" { + return fmt.Errorf("userID is required") + } + params := &model.PostTasksIDOwnersAllParams{ + TaskID: taskID, + Body: model.PostTasksIDOwnersJSONRequestBody{ + Id: userID, + }, + } + _, err := a.client.PostTasksIDOwners(ctx, params) + return err +} + +// RemoveOwner removes the user with the given userID from the task with the given id. +func (a *TasksAPI) RemoveOwner(ctx context.Context, taskID, userID string) error { + if taskID == "" { + return fmt.Errorf("taskID is required") + } + if userID == "" { + return fmt.Errorf("userID is required") + } + params := &model.DeleteTasksIDOwnersIDAllParams{ + TaskID: taskID, + UserID: userID, + } + return a.client.DeleteTasksIDOwnersID(ctx, params) +} + +// getTasks returns list of tasks matching specified filter. +func (a *TasksAPI) getTasks(ctx context.Context, filter *Filter) ([]model.Task, error) { + if filter != nil && filter.ID != "" { + return a.getTasksByID(ctx, filter.ID) + } + params := &model.GetTasksParams{} + if filter != nil { + if filter.After != "" { + params.After = &filter.After + } + if filter.Name != "" { + params.Name = &filter.Name + } + if filter.UserName != "" { + params.User = &filter.UserName + } + if filter.OrgID != "" { + params.OrgID = &filter.OrgID + } + if filter.OrgName != "" { + params.Org = &filter.OrgName + } + if filter.Status != "" { + status := model.GetTasksParamsStatus(filter.Status) + params.Status = &status + } + if filter.Limit > 0 { + iLimit := int(filter.Limit) + params.Limit = &iLimit + } + } + response, err := a.client.GetTasks(ctx, params) + if err != nil { + return nil, err + } + return *response.Tasks, nil +} + +// getTask returns tasks with matching ID, ie. just one. +func (a *TasksAPI) getTasksByID(ctx context.Context, taskID string) ([]model.Task, error) { + params := &model.GetTasksIDAllParams{ + TaskID: taskID, + } + response, err := a.client.GetTasksID(ctx, params) + if err != nil { + return nil, err + } + return []model.Task{*response}, nil +} diff --git a/influxclient/tasks_e2e_test.go b/influxclient/tasks_e2e_test.go new file mode 100644 index 00000000..d08368aa --- /dev/null +++ b/influxclient/tasks_e2e_test.go @@ -0,0 +1,818 @@ +// +build e2e + +// Copyright 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 influxclient_test + +import ( + "fmt" + "testing" + "time" + + . "github.com/influxdata/influxdb-client-go/influxclient" + "github.com/influxdata/influxdb-client-go/influxclient/model" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +const taskFluxTemplate = `from(bucket: "%s") |> range(start: -task.every) |> last()` + +func TestTasksAPI_CRUDTask(t *testing.T) { + client, ctx := newClient(t) + tasksAPI := client.TasksAPI() + + tasks, err := tasksAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, tasks) + require.Len(t, tasks, 0) + + org, err := client.OrganizationAPI().FindOne(ctx, &Filter{ + OrgName: orgName, + }) + require.NoError(t, err) + require.NotNil(t, org) + + taskDescription := "Example task" + taskStatus := model.TaskStatusTypeInactive + taskEvery := "5s" + taskFlux := fmt.Sprintf(taskFluxTemplate, bucketName) + newTask := &model.Task{ + Description: &taskDescription, + Every: &taskEvery, + Flux: taskFlux, + Name: "task 01", + OrgID: *org.Id, + Status: &taskStatus, + } + + task1, err := tasksAPI.Create(ctx, newTask) + require.NoError(t, err) + require.NotNil(t, task1) + defer tasksAPI.Delete(ctx, safeId(task1.Id)) + + assert.Equal(t, "task 01", task1.Name, task1.Name) + if assert.NotNil(t, task1.Description) { + assert.Equal(t, taskDescription, *task1.Description) + } + if assert.NotNil(t, task1.Every) { + assert.Equal(t, "5s", *task1.Every) + } + if assert.NotNil(t, task1.Status) { + assert.Equal(t, taskStatus, *task1.Status) + } + assert.Equal(t, *org.Id, task1.OrgID, task1.OrgID) + + task2Every := "1h" + task2, err := tasksAPI.Create(ctx, &model.Task{ + Name: "task 02", + Every: &task2Every, + Flux: taskFlux, + OrgID: *org.Id, + }) + require.NoError(t, err) + require.NotNil(t, task2) + defer tasksAPI.Delete(ctx, safeId(task2.Id)) + + assert.Equal(t, "task 02", task2.Name) + assert.Nil(t, task2.Description) + if assert.NotNil(t, task2.Every) { + assert.Equal(t, "1h", *task2.Every) + } + if assert.NotNil(t, task2.Status) { + assert.Equal(t, model.TaskStatusTypeActive, *task2.Status) + } + assert.Equal(t, *org.Id, task2.OrgID, task2.OrgID) + + task3Cron := "*/1 * * * *" + task3, err := tasksAPI.Create(ctx, &model.Task{ + Name: "task 03", + Cron: &task3Cron, + Flux: taskFlux, + OrgID: *org.Id, + }) + require.NoError(t, err) + require.NotNil(t, task3) + defer tasksAPI.Delete(ctx, safeId(task3.Id)) + + assert.Equal(t, "task 03", task3.Name, task3.Name) + assert.Nil(t, task3.Description) + if assert.NotNil(t, task3.Cron) { + assert.Equal(t, "*/1 * * * *", *task3.Cron) + } + if assert.NotNil(t, task3.Status) { + assert.Equal(t, model.TaskStatusTypeActive, *task3.Status) + } + assert.Equal(t, *org.Id, task3.OrgID, task3.OrgID) + + tasks, err = tasksAPI.Find(ctx, nil) + require.NoError(t, err) + assert.Len(t, tasks, 3) + + tasks, err = tasksAPI.Find(ctx, &Filter{}) + require.NoError(t, err) + assert.Len(t, tasks, 3) + + task3.Every = &taskEvery + task3.Description = &taskDescription + task3.Status = &taskStatus + task3.Name = "task 03x" + task, err := tasksAPI.Update(ctx, task3) + require.NoError(t, err) + require.NotNil(t, task) + + assert.Equal(t, "task 03x", task.Name, task.Name) + if assert.NotNil(t, task.Description) { + assert.Equal(t, taskDescription, *task.Description) + } + if assert.NotNil(t, task.Every) { + assert.Equal(t, taskEvery, *task3.Every) + } + if assert.NotNil(t, task3.Status) { + assert.Equal(t, taskStatus, *task3.Status) + } + + flux := fmt.Sprintf(`import "types" +option task = { + name: "task 04", + every: 1h, +} + +from(bucket: "%s") + |> range(start: -task.every) + |> filter(fn: (r) => r._measurement == "mem" and r.host == "myHost")`, bucketName) + //task4, err := tasksAPI.CreateTaskByFlux(ctx, flux, *org.Id) + task4, err := tasksAPI.Create(ctx, &model.Task{ + OrgID: *org.Id, + Flux: flux, + }) + require.NoError(t, err) + require.NotNil(t, task4) + defer tasksAPI.Delete(ctx, safeId(task4.Id)) + + assert.Equal(t, "task 04", task4.Name, task4.Name) + assert.Nil(t, task4.Description) + if assert.NotNil(t, task4.Every) { + assert.Equal(t, "1h", *task4.Every) + } + if assert.NotNil(t, task4.Status) { + assert.Equal(t, model.TaskStatusTypeActive, *task4.Status) + } + assert.Equal(t, *org.Id, task4.OrgID) + + err = tasksAPI.Delete(ctx, task1.Id) + assert.NoError(t, err) + + err = tasksAPI.Delete(ctx, task2.Id) + assert.NoError(t, err) + + err = tasksAPI.Delete(ctx, task3.Id) + assert.NoError(t, err) + + err = tasksAPI.Delete(ctx, task4.Id) + assert.NoError(t, err) + + tasks, err = tasksAPI.Find(ctx, nil) + require.NoError(t, err) + assert.Len(t, tasks, 0) +} + +func TestTasksAPI_GetTasks(t *testing.T) { + client, ctx := newClient(t) + tasksAPI := client.TasksAPI() + + tasks, err := tasksAPI.Find(ctx, nil) + require.NoError(t, err) + require.Len(t, tasks, 0) + + taskOrg, err := client.OrganizationAPI().Create(ctx, &model.Organization{ + Name: "task-org", + }) + require.NoError(t, err) + require.NotNil(t, taskOrg) + defer client.OrganizationAPI().Delete(ctx, safeId(taskOrg.Id)) + + taskEvery := "1h" + taskFlux := fmt.Sprintf(taskFluxTemplate, bucketName) + newtasks := make([]*model.Task, 30) + for i := 0; i < 30; i++ { + newtasks[i], err = tasksAPI.Create(ctx, &model.Task{ + Name: fmt.Sprintf("task %02d", i+1), + Every: &taskEvery, + Flux: taskFlux, + OrgID: *taskOrg.Id, + }) + require.NoError(t, err) + require.NotNil(t, newtasks[i]) + defer tasksAPI.Delete(ctx, safeId(newtasks[i].Id)) + } + + tasks, err = tasksAPI.Find(ctx, &Filter{ + Limit: 15, + }) + require.NoError(t, err) + assert.Len(t, tasks, 15) + + tasks, err = tasksAPI.Find(ctx, &Filter{ + After: tasks[14].Id, + }) + require.NoError(t, err) + assert.Len(t, tasks, 15) + + tasks, err = tasksAPI.Find(ctx, &Filter{ + Limit: 100, + }) + require.NoError(t, err) + assert.Len(t, tasks, 30) + + for i := 0; i < 30; i++ { + err = tasksAPI.Delete(ctx, newtasks[i].Id) + assert.NoError(t, err) + } + + err = client.OrganizationAPI().Delete(ctx, *taskOrg.Id) + assert.NoError(t, err) + +} + +func TestTasksAPI_FindTasks(t *testing.T) { + client, ctx := newClient(t) + tasksAPI := client.TasksAPI() + + tasks, err := tasksAPI.Find(ctx, nil) + require.NoError(t, err) + require.Len(t, tasks, 0) + + taskOrg, err := client.OrganizationAPI().Create(ctx, &model.Organization{ + Name: "task-org", + }) + require.NoError(t, err) + require.NotNil(t, taskOrg) + defer client.OrganizationAPI().Delete(ctx, safeId(taskOrg.Id)) + + user, err := client.UsersAPI().FindOne(ctx, &Filter{ + Name: userName, + }) + require.NoError(t, err) + require.NotNil(t, user) + + taskEvery := "1h" + taskFlux := fmt.Sprintf(taskFluxTemplate, bucketName) + task1, err := tasksAPI.Create(ctx, &model.Task{ + Name:"task 01", + Flux: taskFlux, + Every: &taskEvery, + OrgID: *taskOrg.Id, + }) + require.NoError(t, err) + require.NotNil(t, task1) + defer tasksAPI.Delete(ctx, safeId(task1.Id)) + + tasks, err = tasksAPI.Find(ctx, &Filter{ + Name: task1.Name, + }) + require.NoError(t, err) + assert.Len(t, tasks, 1) + + task2Every := "1m" + task2, err := tasksAPI.Create(ctx, &model.Task{ + Name:"task 01", + Flux:taskFlux, + Every: &task2Every, + OrgID: *taskOrg.Id, + }) + require.NoError(t, err) + require.NotNil(t, task2) + defer tasksAPI.Delete(ctx, safeId(task2.Id)) + + tasks, err = tasksAPI.Find(ctx, &Filter{ + Name: "task 01", + }) + require.NoError(t, err) + assert.Len(t, tasks, 2) + + tasks, err = tasksAPI.Find(ctx, &Filter{ + OrgName: "task-org", + }) + require.NoError(t, err) + assert.Len(t, tasks, 2) + + tasks, err = tasksAPI.Find(ctx, &Filter{ + OrgName: orgName, + }) + require.NoError(t, err) + assert.Len(t, tasks, 0) + + tasks, err = tasksAPI.Find(ctx, &Filter{ + OrgID: *taskOrg.Id, + }) + require.NoError(t, err) + assert.Len(t, tasks, 2) + + tasks, err = tasksAPI.Find(ctx, &Filter{ + UserName: *user.Id, + }) + require.NoError(t, err) + assert.Len(t, tasks, 2) // TODO how come??? + + tasks, err = tasksAPI.Find(ctx, &Filter{ + Status: string(model.TaskStatusTypeActive), + }) + require.NoError(t, err) + assert.Len(t, tasks, 2) + + task, err := tasksAPI.FindOne(ctx, &Filter{ + ID: task1.Id, + }) + require.NoError(t, err) + assert.NotNil(t, task) + + err = tasksAPI.Delete(ctx, task1.Id) + assert.NoError(t, err) + + err = tasksAPI.Delete(ctx, task2.Id) + assert.NoError(t, err) + + err = client.OrganizationAPI().Delete(ctx, *taskOrg.Id) + assert.NoError(t, err) +} + +func TestTasksAPI_MembersOwners(t *testing.T) { + client, ctx := newClient(t) + tasksAPI := client.TasksAPI() + + tasks, err := tasksAPI.Find(ctx, nil) + require.NoError(t, err) + require.Len(t, tasks, 0) + + org, err := client.OrganizationAPI().FindOne(ctx, &Filter{ + Name: orgName, + }) + require.NoError(t, err) + require.NotNil(t, org) + + // Test owners + userOwner, err := client.UsersAPI().Create(ctx, &model.User{ + Name: "bucket-owner", + }) + require.Nil(t, err, err) + require.NotNil(t, userOwner) + defer client.UsersAPI().Delete(ctx, safeId(userOwner.Id)) + + taskEvery := "1h" + taskFlux := fmt.Sprintf(taskFluxTemplate, bucketName) + task, err := tasksAPI.Create(ctx, &model.Task{ + Name: "task 01", + Flux: taskFlux, + Every: &taskEvery, + OrgID: *org.Id, + }) + require.NoError(t, err) + require.NotNil(t, task) + defer tasksAPI.Delete(ctx, safeId(task.Id)) + + owners, err := tasksAPI.Owners(ctx, task.Id) + require.Nil(t, err, err) + require.NotNil(t, owners) + assert.Len(t, owners, 0) + + /*owner, */err = tasksAPI.AddOwner(ctx, task.Id, *userOwner.Id) + require.Nil(t, err, err) + /*require.NotNil(t, owner) + assert.Equal(t, *userOwner.Id, *owner.Id)*/ + + owners, err = tasksAPI.Owners(ctx, task.Id) + require.Nil(t, err, err) + require.NotNil(t, owners) + assert.Len(t, owners, 1) + + err = tasksAPI.RemoveOwner(ctx, task.Id, *owners[0].Id) + require.Nil(t, err, err) + + owners, err = tasksAPI.Owners(ctx, task.Id) + require.Nil(t, err, err) + require.NotNil(t, owners) + assert.Len(t, owners, 0) + + // Test members + userMember, err := client.UsersAPI().Create(ctx, &model.User{ + Name: "bucket-member", + }) + require.Nil(t, err, err) + require.NotNil(t, userMember) + defer client.UsersAPI().Delete(ctx, safeId(userMember.Id)) + + members, err := tasksAPI.Members(ctx, task.Id) + require.Nil(t, err, err) + require.NotNil(t, members) + assert.Len(t, members, 0) + + /*member, */err = tasksAPI.AddMember(ctx, task.Id, *userMember.Id) + require.Nil(t, err, err) + /*require.NotNil(t, member) + assert.Equal(t, *userMember.Id, *member.Id)*/ + + members, err = tasksAPI.Members(ctx, task.Id) + require.Nil(t, err, err) + require.NotNil(t, members) + assert.Len(t, members, 1) + + err = tasksAPI.RemoveMember(ctx, task.Id, *members[0].Id) + require.Nil(t, err, err) + + members, err = tasksAPI.Members(ctx, task.Id) + require.Nil(t, err, err) + require.NotNil(t, members) + assert.Len(t, members, 0) + + err = tasksAPI.Delete(ctx, task.Id) + assert.Nil(t, err, err) + + err = client.UsersAPI().Delete(ctx, *userOwner.Id) + assert.Nil(t, err, err) + + err = client.UsersAPI().Delete(ctx, *userMember.Id) + assert.Nil(t, err, err) +} + +func TestTasksAPI_Labels(t *testing.T) { + client, ctx := newClient(t) + tasksAPI := client.TasksAPI() + labelsAPI := client.LabelsAPI() + + tasks, err := tasksAPI.Find(ctx, nil) + require.NoError(t, err) + require.Len(t, tasks, 0) + + org, err := client.OrganizationAPI().FindOne(ctx, &Filter{ + Name: orgName, + }) + require.NoError(t, err) + require.NotNil(t, org) + + taskEvery := "1h" + taskFlux := fmt.Sprintf(taskFluxTemplate, bucketName) + task, err := tasksAPI.Create(ctx, &model.Task{ + Name:"task 01", + Flux: taskFlux, + Every: &taskEvery, + OrgID: *org.Id, + }) + require.NoError(t, err) + require.NotNil(t, task) + defer tasksAPI.Delete(ctx, safeId(task.Id)) + + labels, err := tasksAPI.FindLabels(ctx, task.Id) + require.Nil(t, err, err) + require.NotNil(t, labels) + assert.Len(t, labels, 0) + + labelName := "red-label" + label, err := labelsAPI.Create(ctx, &model.Label{ + OrgID: org.Id, + Name: &labelName, + }) + assert.NoError(t, err) + assert.NotNil(t, label) + defer labelsAPI.Delete(ctx, safeId(label.Id)) + + labelx, err := tasksAPI.AddLabel(ctx, task.Id, *label.Id) + require.Nil(t, err, err) + require.NotNil(t, labelx) + + labels, err = tasksAPI.FindLabels(ctx, task.Id) + require.Nil(t, err, err) + require.NotNil(t, labels) + assert.Len(t, labels, 1) + + err = tasksAPI.RemoveLabel(ctx, task.Id, *label.Id) + require.Nil(t, err, err) + + labels, err = tasksAPI.FindLabels(ctx, task.Id) + require.Nil(t, err, err) + require.NotNil(t, labels) + assert.Len(t, labels, 0) + + err = labelsAPI.Delete(ctx, *label.Id) + assert.Nil(t, err, err) + + err = tasksAPI.Delete(ctx, task.Id) + assert.Nil(t, err, err) +} + +func TestTasksAPI_Runs(t *testing.T) { + client, ctx := newClient(t) + tasksAPI := client.TasksAPI() + + tasks, err := tasksAPI.Find(ctx, nil) + require.NoError(t, err) + require.Len(t, tasks, 0) + + org, err := client.OrganizationAPI().FindOne(ctx, &Filter{ + Name: orgName, + }) + require.NoError(t, err) + require.NotNil(t, org) + + start := time.Now() + taskEvery := "1s" + taskFlux := fmt.Sprintf(taskFluxTemplate, bucketName) + task, err := tasksAPI.Create(ctx, &model.Task{ + Name: "rapid task", + Flux: taskFlux, + Every: &taskEvery, + OrgID: *org.Id, + }) + require.NoError(t, err) + require.NotNil(t, task) + defer tasksAPI.Delete(ctx, safeId(task.Id)) + // wait for task to run 10x + <-time.After(time.Second * 10 + time.Second * 1/*give it a little more time to finish at least 10 runs*/) + + logs, err := tasksAPI.FindLogs(ctx, task.Id) + require.NoError(t, err) + assert.True(t, len(logs) > 0) + + runs, err := tasksAPI.FindRuns(ctx, task.Id, nil) + require.NoError(t, err) + runsCount := len(runs) + assert.True(t, runsCount > 0) + + runs, err = tasksAPI.FindRuns(ctx, task.Id, &Filter{ + Limit: 5, + }) + require.NoError(t, err) + assert.Len(t, runs, 5) + + runs, err = tasksAPI.FindRuns(ctx, task.Id, &Filter{ + Limit: 5, + After: *runs[4].Id, + }) + require.NoError(t, err) + require.NotNil(t, runs) + //assert.Len(t, runs, 5) // https://github.com/influxdata/influxdb/issues/13577 + + runs, err = tasksAPI.FindRuns(ctx, task.Id, &Filter{ + AfterTime: start, + BeforeTime: start.Add(5 * time.Second), + }) + require.NoError(t, err) + //assert.Len(t, runs, 5) // https://github.com/influxdata/influxdb/issues/13577 + assert.True(t, len(runs) > 0) + + runs, err = tasksAPI.FindRuns(ctx, task.Id, &Filter{ + AfterTime: start.Add(5 * time.Second), + }) + require.NoError(t, err) + //assert.Len(t, runs, 5) // https://github.com/influxdata/influxdb/issues/13577 + assert.True(t, len(runs) > 0) + + logs, err = tasksAPI.FindRunLogs(ctx, task.Id, *runs[0].Id) + require.NoError(t, err) + assert.True(t, len(logs) > 0) + + err = tasksAPI.Delete(ctx, task.Id) + assert.NoError(t, err) + + task, err = tasksAPI.Create(ctx, &model.Task{ + Name:"task", + Flux: taskFlux, + Every: &taskEvery, + OrgID: *org.Id, + }) + require.NoError(t, err) + require.NotNil(t, task) + defer tasksAPI.Delete(ctx, safeId(task.Id)) + //wait for tasks to start and be running + <-time.After(1500 * time.Millisecond) + + // we should get a running run + runs, err = tasksAPI.FindRuns(ctx, task.Id, nil) + require.NoError(t, err) + if assert.True(t, len(runs) > 0) { + _ = tasksAPI.CancelRun(ctx, task.Id, *runs[0].Id) + } + + runm, err := tasksAPI.RunManually(ctx, task.Id) + require.NoError(t, err) + require.NotNil(t, runm) + + run, err := tasksAPI.FindOneRun(ctx, *runm.TaskID, &Filter{ID: *runm.Id}) + require.NoError(t, err) + require.NotNil(t, run) + + run2, err := tasksAPI.RetryRun(ctx, task.Id, *run.Id) + require.NoError(t, err) + require.NotNil(t, run2) + + err = tasksAPI.Delete(ctx, task.Id) + assert.NoError(t, err) +} + +func TestTasksAPI_Failures(t *testing.T) { + client, ctx := newClient(t) + tasksAPI := client.TasksAPI() + + taskFlux := fmt.Sprintf(taskFluxTemplate, bucketName) + + _, err := tasksAPI.Find(ctx, &Filter{ID: invalidID}) + assert.Error(t, err) + + _, err = tasksAPI.Find(ctx, &Filter{ID: notExistingID}) + assert.Error(t, err) + + _, err = tasksAPI.Find(ctx, &Filter{OrgID: invalidID}) + assert.Error(t, err) + + org, err := client.OrganizationAPI().FindOne(ctx, &Filter{ + Name: orgName, + }) + require.NoError(t, err) + require.NotNil(t, org) + + _, err = tasksAPI.Create(ctx, nil) + assert.Error(t, err) + + _, err = tasksAPI.Create(ctx, &model.Task{}) + assert.Error(t, err) + + // empty org / orgId + every := "4s" + _, err = tasksAPI.Create(ctx, &model.Task{Name: "", Flux: taskFlux, Every: &every}) + assert.Error(t, err) + + // empty name + _, err = tasksAPI.Create(ctx, &model.Task{Name: "", Flux: taskFlux, Every: &every, OrgID: *org.Id}) + assert.Error(t, err) + + // invalid flux + _, err = tasksAPI.Create(ctx,&model.Task{Name: "Task", Flux: "x := null", Every: &every, OrgID: *org.Id}) + assert.Error(t, err) + + // empty flux + _, err = tasksAPI.Create(ctx,&model.Task{Name: "Task", Flux: "", Every: &every, OrgID: *org.Id}) + assert.Error(t, err) + + // invalid every + every = "4g" + _, err = tasksAPI.Create(ctx,&model.Task{Name: "Task", Flux: taskFlux, Every: &every, OrgID: *org.Id}) + assert.Error(t, err) + + // invalid org + every = "4s" + _, err = tasksAPI.Create(ctx,&model.Task{Name: "Task" , Flux: taskFlux, Every: &every, OrgID: invalidID}) + assert.Error(t, err) + + // invalid cron + cron := "0 * *" + _, err = tasksAPI.Create(ctx,&model.Task{Name: "Task", Flux: taskFlux, Cron: &cron, OrgID: *org.Id}) + assert.Error(t, err) + + _, err = tasksAPI.Update(ctx, nil) + assert.Error(t, err) + + _, err = tasksAPI.Update(ctx, &model.Task{ + Id: notExistingID, + Flux: taskFlux, + Name: "task 01", + }) + assert.Error(t, err) + + _, err = tasksAPI.Update(ctx, &model.Task{ + Id: "", + Flux: taskFlux, + Name: "task 01", + }) + assert.Error(t, err) + + // delete with id + err = tasksAPI.Delete(ctx, notExistingID) + assert.Error(t, err) + + err = tasksAPI.Delete(ctx, notInitializedID) + assert.Error(t, err) + + _, err = tasksAPI.Members(ctx, invalidID) + assert.Error(t, err) + + _, err = tasksAPI.Members(ctx, notInitializedID) + assert.Error(t, err) + + /*_,*/ err = tasksAPI.AddMember(ctx, notExistingID, invalidID) + assert.Error(t, err) + + /*_,*/ err = tasksAPI.AddMember(ctx, notExistingID, notInitializedID) + assert.Error(t, err) + + /*_,*/ err = tasksAPI.AddMember(ctx, notInitializedID, notExistingID) + assert.Error(t, err) + + err = tasksAPI.RemoveMember(ctx, notExistingID, invalidID) + assert.Error(t, err) + + _, err = tasksAPI.Owners(ctx, invalidID) + assert.Error(t, err) + + _, err = tasksAPI.Owners(ctx, notInitializedID) + assert.Error(t, err) + + /*_,*/ err = tasksAPI.AddOwner(ctx, notExistingID, invalidID) + assert.Error(t, err) + + /*_,*/ err = tasksAPI.AddOwner(ctx, notExistingID, notInitializedID) + assert.Error(t, err) + + /*_,*/ err = tasksAPI.AddOwner(ctx, notInitializedID, notExistingID) + assert.Error(t, err) + + err = tasksAPI.RemoveOwner(ctx, notExistingID, invalidID) + assert.Error(t, err) + + err = tasksAPI.RemoveOwner(ctx, notExistingID, notInitializedID) + assert.Error(t, err) + + err = tasksAPI.RemoveOwner(ctx, notInitializedID, notExistingID) + assert.Error(t, err) + + _, err = tasksAPI.FindRuns(ctx, notExistingID, nil) + assert.Error(t, err) + + _, err = tasksAPI.FindRuns(ctx, notInitializedID, nil) + assert.Error(t, err) + + _, err = tasksAPI.FindOneRun(ctx, notInitializedID, &Filter{ID: invalidID}) + assert.Error(t, err) + + _, err = tasksAPI.FindOneRun(ctx, notExistingID, nil) + assert.Error(t, err) + + _, err = tasksAPI.FindOneRun(ctx, notExistingID, &Filter{ID: invalidID}) + assert.Error(t, err) + + _, err = tasksAPI.FindOneRun(ctx, notExistingID, &Filter{ID: notInitializedID}) + assert.Error(t, err) + + _, err = tasksAPI.FindRunLogs(ctx, notExistingID, invalidID) + assert.Error(t, err) + + _, err = tasksAPI.FindRunLogs(ctx, notInitializedID, invalidID) + assert.Error(t, err) + + _, err = tasksAPI.FindRunLogs(ctx, invalidID, notInitializedID) + assert.Error(t, err) + + _, err = tasksAPI.RunManually(ctx, notExistingID) + assert.Error(t, err) + + _, err = tasksAPI.RunManually(ctx, notInitializedID) + assert.Error(t, err) + + _, err = tasksAPI.RetryRun(ctx, notExistingID, invalidID) + assert.Error(t, err) + + _, err = tasksAPI.RetryRun(ctx, notExistingID, notInitializedID) + assert.Error(t, err) + + _, err = tasksAPI.RetryRun(ctx, notInitializedID, notExistingID) + assert.Error(t, err) + + err = tasksAPI.CancelRun(ctx, notExistingID, invalidID) + assert.Error(t, err) + + err = tasksAPI.CancelRun(ctx, notInitializedID, notExistingID) + assert.Error(t, err) + + err = tasksAPI.CancelRun(ctx, notExistingID, notInitializedID) + assert.Error(t, err) + + _, err = tasksAPI.FindLogs(ctx, notExistingID) + assert.Error(t, err) + + _, err = tasksAPI.FindLogs(ctx, notInitializedID) + assert.Error(t, err) + + _, err = tasksAPI.FindLabels(ctx, notInitializedID) + assert.Error(t, err) + + _, err = tasksAPI.FindLabels(ctx, invalidID) + assert.Error(t, err) + + _, err = tasksAPI.AddLabel(ctx, notInitializedID, notExistingID) + assert.Error(t, err) + + _, err = tasksAPI.AddLabel(ctx, notExistingID, notInitializedID) + assert.Error(t, err) + + _, err = tasksAPI.AddLabel(ctx, notExistingID, invalidID) + assert.Error(t, err) + + err = tasksAPI.RemoveLabel(ctx, notExistingID, invalidID) + assert.Error(t, err) + + err = tasksAPI.RemoveLabel(ctx, notInitializedID, notExistingID) + assert.Error(t, err) + + err = tasksAPI.RemoveLabel(ctx, notExistingID, notInitializedID) + assert.Error(t, err) +} diff --git a/influxclient/users.go b/influxclient/users.go new file mode 100644 index 00000000..75cfa491 --- /dev/null +++ b/influxclient/users.go @@ -0,0 +1,201 @@ +// Copyright 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 influxclient provides client for InfluxDB server. +package influxclient + +import ( + "context" + "fmt" + + "github.com/influxdata/influxdb-client-go/influxclient/model" +) + +// UsersAPI holds methods related to user, as found under +// the /users endpoint. +type UsersAPI struct { + client *model.Client +} + +// newUsersAPI returns new UsersPI instance +func newUsersAPI(client *model.Client) *UsersAPI { + return &UsersAPI{client: client} +} + + +// Find returns all users matching the given filter. +// Supported filters: +// - ID +// - Name +func (a *UsersAPI) Find(ctx context.Context, filter *Filter) ([]model.User, error) { + return a.getUsers(ctx, filter) +} + +// FindOne returns one user matching the given filter. +// Supported filters: +// - ID +// - Name +func (a *UsersAPI) FindOne(ctx context.Context, filter *Filter) (*model.User, error) { + users, err := a.getUsers(ctx, filter) + if err != nil { + return nil, err + } + if len(users) > 0 { + return &(users[0]), nil + } + return nil, fmt.Errorf("user not found") +} + +// Create creates a user. The user.Name must not be empty. +func (a *UsersAPI) Create(ctx context.Context, user *model.User) (*model.User, error) { + if user == nil { + return nil, fmt.Errorf("user cannot be nil") + } + if user.Name == "" { + return nil, fmt.Errorf("name is required") + } + params := &model.PostUsersAllParams{ + Body: model.PostUsersJSONRequestBody{ + Name: user.Name, + }, + } + if user.Status != nil { + params.Body.Status = user.Status + } + response, err := a.client.PostUsers(ctx, params) + if err != nil { + return nil, err + } + return userResponseToUser(response), nil +} + +// Update updates a user. The user.ID field must be specified. +// The complete user information is returned. +func (a *UsersAPI) Update(ctx context.Context, user *model.User) (*model.User, error) { + if user == nil { + return nil, fmt.Errorf("user cannot be nil") + } + if user.Id == nil { + return nil, fmt.Errorf("user ID is required") + } + if user.Name == "" { + return nil, fmt.Errorf("name is required") + } + params := &model.PatchUsersIDAllParams { + UserID: *user.Id, + Body: model.PatchUsersIDJSONRequestBody{ + Name: user.Name, + }, + } + if user.Status != nil { + params.Body.Status = user.Status + } + response, err := a.client.PatchUsersID(ctx, params) + if err != nil { + return nil, err + } + return userResponseToUser(response), nil +} + +// Delete deletes the user with the given ID. +func (a *UsersAPI) Delete(ctx context.Context, userID string) error { + params := &model.DeleteUsersIDAllParams{ + UserID: userID, + } + return a.client.DeleteUsersID(ctx, params) +} + +// SetPassword sets the password for the user with the given ID. +func (a *UsersAPI) SetPassword(ctx context.Context, userID, password string) error { + params := &model.PostUsersIDPasswordAllParams{ + UserID: userID, + Body: model.PostUsersIDPasswordJSONRequestBody{ + Password: password, + }, + } + return a.client.PostUsersIDPassword(ctx, params) +} + +// SetMyPassword sets the password associated with the current user. +// The oldPassword parameter must match the previously set password +// for the user. +func (a *UsersAPI) SetMyPassword(ctx context.Context, oldPassword, newPassword string) error { + _, err := a.getMe(ctx) + if err != nil { + return err + } + params := &model.PutMePasswordAllParams{ + Body: model.PutMePasswordJSONRequestBody{ + Password: newPassword, + }, + } + return a.client.PutMePassword(ctx, params) +} + +// getUsers create request for GET on /users according to the filter and validates returned structure +func (a *UsersAPI) getUsers(ctx context.Context, filter *Filter) ([]model.User, error) { + params := &model.GetUsersParams{} + if filter != nil { + if filter.ID != "" { + params.Id = &filter.ID + } + if filter.Name != "" { + params.Name = &filter.Name + } + if filter.Limit > 0 { + limit := model.Limit(filter.Limit) + params.Limit = &limit + } + if filter.Offset > 0 { + offset := model.Offset(filter.Offset) + params.Offset = &offset + } + } + response, err := a.client.GetUsers(ctx, params) + if err != nil { + return nil, err + } + return userResponsesToUsers(response.Users), nil +} + +// getMe retrieves currently authenticated user information. +func (a *UsersAPI) getMe(ctx context.Context) (*model.User, error) { + params := &model.GetMeParams{} + response, err := a.client.GetMe(ctx, params) + if err != nil { + return nil, err + } + return userResponseToUser(response), nil +} + +func userResponseToUser(ur *model.UserResponse) *model.User { + if ur == nil { + return nil + } + user := &model.User{ + Id: ur.Id, + Name: ur.Name, + Status: userResponseStatusToUserStatus(ur.Status), + } + return user +} + +func userResponseStatusToUserStatus(urs *model.UserResponseStatus) *model.UserStatus { + if urs == nil { + return nil + } + us := model.UserStatus(*urs) + return &us +} + +func userResponsesToUsers(urs *[]model.UserResponse) []model.User { + if urs == nil { + return nil + } + us := make([]model.User, len(*urs)) + for i, ur := range *urs { + us[i] = *userResponseToUser(&ur) + } + return us +} diff --git a/influxclient/users_e2e_test.go b/influxclient/users_e2e_test.go new file mode 100644 index 00000000..c5c7961e --- /dev/null +++ b/influxclient/users_e2e_test.go @@ -0,0 +1,162 @@ +// +build e2e + +// Copyright 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 influxclient_test + +import ( + "fmt" + "testing" + + . "github.com/influxdata/influxdb-client-go/influxclient" + "github.com/influxdata/influxdb-client-go/influxclient/model" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestUsersAPI(t *testing.T) { + client, ctx := newClient(t) + usersAPI := client.UsersAPI() + + users, err := usersAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, users) + assert.Len(t, users, 1) + + // create user + user, err := usersAPI.Create(ctx, &model.User{ + Name: "user-01", + }) + require.NoError(t, err) + require.NotNil(t, user) + defer usersAPI.Delete(ctx, fmt.Sprintf("%s", *user.Id)) + + // try to create duplicate user + user2, err := usersAPI.Create(ctx, &model.User{ + Name: "user-01", + }) + assert.Error(t, err) + assert.Nil(t, user2) + + // find + users, err = usersAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, users) + assert.Len(t, users, 2) + + // update + status := model.UserStatusInactive // default is active + user.Status = &status + user, err = usersAPI.Update(ctx, user) + require.NoError(t, err) + require.NotNil(t, user) + assert.Equal(t, status, *user.Status) + + user2 = &model.User{ + Id: user.Id, + Name: "my-user2", + } + + // update username + user2, err = usersAPI.Update(ctx, user2) + assert.NoError(t, err) + assert.NotNil(t, user2) + + // find by ID + user, err = usersAPI.FindOne(ctx, &Filter{ + ID: *user2.Id, + }) + require.NoError(t, err) + require.NotNil(t, user) + + // find by name + user, err = usersAPI.FindOne(ctx, &Filter{ + Name: user.Name, + }) + require.NoError(t, err) + require.NotNil(t, user) + + // update password + err = usersAPI.SetPassword(ctx, *user.Id, "my-password2") + require.NoError(t, err) + + // delete user + err = usersAPI.Delete(ctx, *user.Id) + require.NoError(t, err) + + // verify there's just onboarded user + users, err = usersAPI.Find(ctx, nil) + require.NoError(t, err) + require.NotNil(t, users) + assert.Len(t, users, 1) + + // it fails, https://github.com/influxdata/influxdb/pull/15981 + //err = usersAPI.MeUpdatePassword(ctx, "my-password", "my-new-password") + //assert.NoError(t, err) + + //err = usersAPI.MeUpdatePassword(ctx, "my-new-password", "my-password") + //assert.NoError(t, err) +} + +func TestUsersAPI_failing(t *testing.T) { + client, ctx := newClient(t) + usersAPI := client.UsersAPI() + + // user cannot be nil + user, err := usersAPI.Create(ctx, nil) + require.Error(t, err) + assert.Nil(t, user) + + // user name must not be empty + user, err = usersAPI.Create(ctx, &model.User{}) + require.Error(t, err) + assert.Nil(t, user) + + user, err = usersAPI.Update(ctx, &model.User{ + Id: nil, + Name: "john doe", + }) + require.Error(t, err) + assert.Nil(t, user) + + user, err = usersAPI.Update(ctx, nil) + require.Error(t, err) + assert.Nil(t, user) + + user, err = usersAPI.Update(ctx, &model.User{ + Id: ¬ExistingID, + Name: "", + }) + require.Error(t, err) + assert.Nil(t, user) + + user, err = usersAPI.Update(ctx, &model.User{ + Id: ¬ExistingID, + Name: "john doe", + }) + require.Error(t, err) + assert.Nil(t, user) + + user, err = usersAPI.FindOne(ctx, &Filter{ + ID: invalidID, + }) + assert.Error(t, err) + assert.Nil(t, user) + + user, err = usersAPI.FindOne(ctx, &Filter{ + Name: "not-existing-name", + }) + assert.Error(t, err) + assert.Nil(t, user) + + err = usersAPI.Delete(ctx, invalidID) + assert.Error(t, err) + + err = usersAPI.SetPassword(ctx, invalidID, "pass") + assert.Error(t, err) + + err = usersAPI.SetMyPassword(ctx, "wrong", "better") + assert.Error(t, err) +} diff --git a/scripts/influxdb-onboarding.sh b/scripts/influxdb-onboarding.sh new file mode 100755 index 00000000..f8cc067f --- /dev/null +++ b/scripts/influxdb-onboarding.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# +# The MIT License +# +# 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. +# + +set -e + +echo "Wait to start InfluxDB 2.x" +wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:9999/metrics + +echo +echo "Post onBoarding request, to setup initial user (my-user@my-password), org (my-org) and bucketSetup (my-bucket)" +echo +curl -i -X POST http://localhost:9999/api/v2/setup -H 'accept: application/json' \ + -d '{ + "username": "my-user", + "password": "my-password", + "org": "my-org", + "bucket": "my-bucket", + "token": "my-token" + }' From f6ba934552dbd943162d9d648d17bd8d0654aca8 Mon Sep 17 00:00:00 2001 From: Ales Pour Date: Thu, 29 Dec 2022 12:32:02 +0100 Subject: [PATCH 2/2] test: add mgmt and query examples tests --- influxclient/examples_test.go | 360 +++++++++++++++++++++++++++++++++- 1 file changed, 354 insertions(+), 6 deletions(-) diff --git a/influxclient/examples_test.go b/influxclient/examples_test.go index 2f9600fe..e83674a9 100644 --- a/influxclient/examples_test.go +++ b/influxclient/examples_test.go @@ -10,6 +10,8 @@ import ( "context" "fmt" "os" + "text/tabwriter" + "time" "github.com/influxdata/influxdb-client-go/influxclient" "github.com/influxdata/influxdb-client-go/influxclient/model" @@ -55,12 +57,13 @@ func ExampleClient_customServerAPICall() { ctx := context.Background() // Get a bucket we would like to query using InfluxQL - b, err := client.BucketsAPI().FindOne(ctx, &influxclient.Filter{Name: bucketName}) + bucket, err := client.BucketsAPI().FindOne(ctx, &influxclient.Filter{Name: bucketName}) if err != nil { panic(err) } + // Get an organization that will own the mapping - o, err := client.OrganizationAPI().FindOne(ctx, &influxclient.Filter{Name: orgName}) + org, err := client.OrganizationAPI().FindOne(ctx, &influxclient.Filter{Name: orgName}) if err != nil { panic(err) } @@ -68,10 +71,10 @@ func ExampleClient_customServerAPICall() { yes := true // Fill required fields of the DBRP struct dbrp := model.DBRPCreate{ - BucketID: *b.Id, - Database: b.Name, + BucketID: *bucket.Id, + Database: bucket.Name, Default: &yes, - OrgID: o.Id, + OrgID: org.Id, RetentionPolicy: "autogen", } @@ -83,9 +86,354 @@ func ExampleClient_customServerAPICall() { if err != nil { panic(err) } + defer apiClient.DeleteDBRPID(ctx, &model.DeleteDBRPIDAllParams{ + DeleteDBRPIDParams: model.DeleteDBRPIDParams{OrgID: org.Id}, DbrpID: safeId(newDbrp.Id), + }) // only for E2E tests // Check generated response - fmt.Fprintf(os.Stderr, "Created DBRP: %#v\n", newDbrp) + fmt.Fprintf(os.Stderr, "\tCreated DBRP: %#v\n", newDbrp) + + // Output: +} + +func ExampleClient_Query() { + // Create client + client, err := influxclient.New(influxclient.Params{ + ServerURL: "https://eu-central-1-1.aws.cloud2.influxdata.com/", + AuthToken: "my-token", + Organization: "my-org", + }) + + // Define query parameters + params := struct { + Since string `json:"since"` + GreaterThan float64 `json:"greaterThan"` + }{ + "-10m", + 23.0, + } + // Prepare a query + query := `from(bucket: "iot_center") + |> range(start: duration(v: params.since)) + |> filter(fn: (r) => r._measurement == "environment") + |> filter(fn: (r) => r._field == "Temperature") + |> filter(fn: (r) => r._value > params.greaterThan)` + + // Execute query + res, err := client.Query(context.Background(), query, params) + if err != nil { + panic(err) + } + + // Make sure query result is always closed + defer res.Close() + + // Declare custom type for data + val := &struct { + Time time.Time `csv:"_time"` + Temp float64 `csv:"_value"` + Sensor string `csv:"sensor"` + }{} + + tw := tabwriter.NewWriter(os.Stdout, 10, 4, 2, ' ', 0) + fmt.Fprintf(tw, "Time\tTemp\tSensor\n") + + // Iterate over result set + for res.NextSection() { + for res.NextRow() { + err = res.Decode(val) + if err != nil { + fmt.Fprintf(tw, "%v\n", err) + continue + } + fmt.Fprintf(tw, "%s\t%.2f\t%s\n", val.Time.String(), val.Temp, val.Sensor) + } + } + tw.Flush() + if res.Err() != nil { + panic(res.Err()) + } +} + +func ExampleBucketsAPI() { + // Create a new client using an InfluxDB server base URL and an authentication token + client, err := influxclient.New(influxclient.Params{ + ServerURL: serverURL, + AuthToken: authToken}) + + // Get Buckets API client + bucketsAPI := client.BucketsAPI() + ctx := context.Background() + + // Get organization that will own new bucket + org, err := client.OrganizationAPI().FindOne(ctx, &influxclient.Filter{Name: orgName}) + if err != nil { + panic(err) + } + + // Create bucket with 1 day retention policy + bucket, err := bucketsAPI.Create(ctx, &model.Bucket{ + OrgID: org.Id, + Name: "bucket-sensors", + RetentionRules: []model.RetentionRule{ + { + EverySeconds: 3600 * 24, + }, + }, + }) + if err != nil { + panic(err) + } + defer bucketsAPI.Delete(ctx, safeId(bucket.Id)) // only for E2E tests + + // Update description of the bucket + desc := "Bucket for sensor data" + bucket.Description = &desc + bucket, err = bucketsAPI.Update(ctx, bucket) + if err != nil { + panic(err) + } + + // Output: +} + +func ExampleOrganizationsAPI() { + // Create a new client using an InfluxDB server base URL and an authentication token + client, err := influxclient.New(influxclient.Params{ + ServerURL: serverURL, + AuthToken: authToken}) + + // Get Organizations API client + orgAPI := client.OrganizationAPI() + ctx := context.Background() + + // Create new organization + org, err := orgAPI.Create(ctx, &model.Organization{Name: orgName+"-2"}) + if err != nil { + panic(err) + } + defer orgAPI.Delete(ctx, safeId(org.Id)) // only for E2E tests + + orgDescription := "My second org" + org.Description = &orgDescription + org, err = orgAPI.Update(ctx, org) + if err != nil { + panic(err) + } + + // Create new user to add to org + newUser, err := client.UsersAPI().Create(ctx, &model.User{Name: userName+"-2"}) + if err != nil { + panic(err) + } + defer client.UsersAPI().Delete(ctx, safeId(newUser.Id)) // only for E2E tests + + // Add new user to organization + err = orgAPI.AddMember(ctx, *org.Id, *newUser.Id) + if err != nil { + panic(err) + } + + // Output: +} + +func ExampleAuthorizationsAPI() { + // Create a new client using an InfluxDB server base URL and an authentication token + client, err := influxclient.New(influxclient.Params{ + ServerURL: serverURL, + AuthToken: authToken}) + ctx := context.Background() + + // Find user to grant permission + user, err := client.UsersAPI().FindOne(ctx, &influxclient.Filter{Name: userName}) + if err != nil { + panic(err) + } + + // Find organization + org, err := client.OrganizationAPI().FindOne(ctx, &influxclient.Filter{Name: "my-org"}) + if err != nil { + panic(err) + } + + // group permissions + permissions := []model.Permission{ + { + Action: model.PermissionActionWrite, + Resource: model.Resource{ + Type: model.ResourceTypeBuckets, + }, + }, + { + Action: model.PermissionActionRead, + Resource: model.Resource{ + Type: model.ResourceTypeBuckets, + }, + }, + } + + // create authorization object using info above + auth := &model.Authorization{ + OrgID: org.Id, + Permissions: &permissions, + UserID: user.Id, + } + + // grant permission and create token + authCreated, err := client.AuthorizationsAPI().Create(ctx, auth) + if err != nil { + panic(err) + } + defer client.AuthorizationsAPI().Delete(ctx, safeId(authCreated.Id)) // only for E2E tests + + // Use token + fmt.Fprintf(os.Stderr, "\tToken: %v\n", *authCreated.Token) + + // Output: +} + +func ExampleUsersAPI() { + // Create a new client using an InfluxDB server base URL and an authentication token + client, err := influxclient.New(influxclient.Params{ + ServerURL: serverURL, + AuthToken: authToken}) + ctx := context.Background() + + // Find organization + org, err := client.OrganizationAPI().FindOne(ctx, &influxclient.Filter{Name: orgName}) + if err != nil { + panic(err) + } + + // Get users API client + usersAPI := client.UsersAPI() + + // Create new user + user, err := usersAPI.Create(ctx, &model.User{Name: "user-01"}) + if err != nil { + panic(err) + } + defer usersAPI.Delete(ctx, safeId(user.Id)) // only for E2E tests + + // Set user password + err = usersAPI.SetPassword(ctx, *user.Id, "pass-at-least-8-chars") + if err != nil { + panic(err) + } + + // Add user to organization + err = client.OrganizationAPI().AddMember(ctx, *org.Id, *user.Id) + if err != nil { + panic(err) + } + + // Output: +} + +func ExampleLabelsAPI() { + // Create a new client using an InfluxDB server base URL and an authentication token + client, err := influxclient.New(influxclient.Params{ + ServerURL: serverURL, + AuthToken: authToken}) + + // Get Labels API client + labelsAPI := client.LabelsAPI() + ctx := context.Background() + + // Get organization that will own label + org, err := client.OrganizationAPI().FindOne(ctx, &influxclient.Filter{Name: orgName}) + if err != nil { + panic(err) + } + + labelName := "Active State" + props := map[string]string{"color": "33ffdd", "description": "Marks org active"} + label, err := labelsAPI.Create(ctx, &model.Label{ + OrgID: org.Id, + Name: &labelName, + Properties: &model.Label_Properties{ + AdditionalProperties: props, + }, + }) + if err != nil { + panic(err) + } + defer labelsAPI.Delete(ctx, safeId(label.Id)) // only for E2E tests + + // Change color property + label.Properties.AdditionalProperties = map[string]string{"color": "ff1122"} + label, err = labelsAPI.Update(ctx, label) + if err != nil { + panic(err) + } + + // Output: +} + +func ExampleTasksAPI() { + // Create a new client using an InfluxDB server base URL and an authentication token + client, err := influxclient.New(influxclient.Params{ + ServerURL: serverURL, + AuthToken: authToken}) + + // Get Delete API client + tasksAPI := client.TasksAPI() + ctx := context.Background() + + // Get organization that will own task + org, err := client.OrganizationAPI().FindOne(ctx, &influxclient.Filter{Name: orgName}) + if err != nil { + panic(err) + } + + // task flux script from https://www.influxdata.com/blog/writing-tasks-and-setting-up-alerts-for-influxdb-cloud/ + flux := `fruitCollected = from(bucket: "farming") + |> range(start: -task.every) + |> filter(fn: (r) => r["_measurement"] == "totalFruitsCollected") + |> filter(fn: (r) => r["_field"] == "fruits") + |> group(columns: ["farmName"]) + |> aggregateWindow(fn: sum, every: task.every) + |> map(fn: (r) => ({ + _time: r._time, _stop: r._stop, _start: r._start, _measurement: "fruitCollectionRate", _field: "fruits", _value: r._value, farmName: r.farmName, + })) + +fruitCollected + |> to(bucket: "farming") +` + every := "1h" + task, err := tasksAPI.Create(ctx, &model.Task{ + OrgID: *org.Id, + Name: "fruitCollectedRate", + Flux: flux, + Every: &every, + }) + if err != nil { + panic(err) + } + defer tasksAPI.Delete(ctx, safeId(task.Id)) // only for E2E tests + + // Force running a task + run, err := tasksAPI.RunManually(ctx, task.Id) + if err != nil { + panic(err) + } + + // Print run info + fmt.Fprint(os.Stderr, "\tForced run scheduled for ", *run.ScheduledFor, " with status ", *run.Status, "\n") + //wait for tasks to start and be running + <-time.After(1500 * time.Millisecond) + + // Find logs + logs, err := tasksAPI.FindRunLogs(ctx, task.Id, *run.Id) + if err != nil { + panic(err) + } + + // Print logs + fmt.Fprintln(os.Stderr, "\tLogs:") + for _, logEvent := range logs { + fmt.Fprint(os.Stderr,"\t Time:", *logEvent.Time, ", Message: ", *logEvent.Message, "\n") + } // Output: }