diff --git a/README.md b/README.md index bd2d1f1..c7a5ce0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,85 @@ -# influxdb3 -InfluxDB V3 Go SDK +# InfluxDB v3 Cloud Dedicated Management API Client Library + +The InfluxDB v3 Management API client library lets you manage an InfluxDB Cloud Dedicated instance and integrate functions such as creating and managing databases, permissions, and tokens into your workflow or application. + +## Generated types and API client + +This library is generated from the [OpenAPI spec](https://github.com/influxdata/docs-v2/blob/master/api-docs/cloud-dedicated/management/openapi.yml) + +### Generate + +#### Generate types +`oapi-codegen -generate types -o types.gen.go -package influxdb3 openapi.yml` + +#### Generate client +`oapi-codegen -generate client -o client.gen.go -package influxdb3 openapi.yml` + + +## Usage + +### Environment variables + +```bash +export INFLUXDB_BASE_URL="https://console.influxdata.com/api/v0" +export INFLUXDB_ACCOUNT_ID="4ade9b2e-0a52-4a46-b3b8-1b43ea493a98" +export INFLUXDB_CLUSTER_ID="a379c48a-791e-47fe-ba64-628ba19507e8" +export INFLUXDB_TOKEN="1e0f14063eb14a9e94fe765bf999a90cb7962f8e0f394110b91053ea26cdce5071d6bca29e4d4684bed463cf2ea9f381" +``` + +### Sample code to list database tokens + +```go +package main + +import ( + "context" + "io" + "net/http" + + "github.com/caarlos0/env/v11" + influxdb3 "github.com/komminarlabs/influxdb3" +) + +type InfluxdbConfig struct { + AccountId influxdb3.UuidV4 `env:"INFLUXDB_ACCOUNT_ID"` + BaseURL string `env:"INFLUXDB_BASE_URL"` + ClusterId influxdb3.UuidV4 `env:"INFLUXDB_CLUSTER_ID"` + Token string `env:"INFLUXDB_TOKEN"` +} + +func main() { + cfg := InfluxdbConfig{} + opts := env.Options{RequiredIfNoDef: true} + + err := env.ParseWithOptions(&cfg, opts) + if err != nil { + panic(err) + } + + ctx := context.Background() + client, err := influxdb3.NewClient(cfg.BaseURL, influxdb3.WithRequestEditorFn(func(ctx context.Context, req *http.Request) error { + req.Header.Set("Accept", "application/json") + req.Header.Set("Authorization", "Bearer "+cfg.Token) + return nil + + })) + if err != nil { + panic(err) + } + + resp, err := client.GetDatabaseTokens(ctx, cfg.AccountId, cfg.ClusterId) + if err != nil { + panic(err) + } + defer resp.Body.Close() + + if resp.StatusCode == http.StatusOK { + bodyBytes, err := io.ReadAll(resp.Body) + if err != nil { + panic(err) + } + bodyString := string(bodyBytes) + println(bodyString) + } +} +``` diff --git a/client.gen.go b/client.gen.go new file mode 100644 index 0000000..b1fe6a0 --- /dev/null +++ b/client.gen.go @@ -0,0 +1,2460 @@ +// Package influxdb3 provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/deepmap/oapi-codegen version v1.16.3 DO NOT EDIT. +package influxdb3 + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strings" + + "github.com/oapi-codegen/runtime" +) + +// RequestEditorFn is the function signature for the RequestEditor callback function +type RequestEditorFn func(ctx context.Context, req *http.Request) error + +// 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 + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HttpRequestDoer + + // A list of callbacks for modifying requests which are generated before sending over + // the network. + RequestEditors []RequestEditorFn +} + +// ClientOption allows setting custom parameters during construction +type ClientOption func(*Client) error + +// Creates a new Client, with reasonable defaults +func NewClient(server string, opts ...ClientOption) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + } + // mutate client and add all optional params + for _, o := range opts { + if err := o(&client); err != nil { + return nil, err + } + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +// WithHTTPClient allows overriding the default Doer, which is +// automatically created using http.Client. This is useful for tests. +func WithHTTPClient(doer HttpRequestDoer) ClientOption { + return func(c *Client) error { + c.Client = doer + return nil + } +} + +// WithRequestEditorFn allows setting up a callback function, which will be +// called right before sending the request. This can be used to mutate the request. +func WithRequestEditorFn(fn RequestEditorFn) ClientOption { + return func(c *Client) error { + c.RequestEditors = append(c.RequestEditors, fn) + return nil + } +} + +// The interface specification for the client above. +type ClientInterface interface { + // GetClusterDatabases request + GetClusterDatabases(ctx context.Context, accountId UuidV4, clusterId UuidV4, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateClusterDatabaseWithBody request with any body + CreateClusterDatabaseWithBody(ctx context.Context, accountId UuidV4, clusterId UuidV4, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + CreateClusterDatabase(ctx context.Context, accountId UuidV4, clusterId UuidV4, body CreateClusterDatabaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteClusterDatabase request + DeleteClusterDatabase(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateClusterDatabaseWithBody request with any body + UpdateClusterDatabaseWithBody(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateClusterDatabase(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, body UpdateClusterDatabaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateClusterDatabaseTableWithBody request with any body + CreateClusterDatabaseTableWithBody(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + CreateClusterDatabaseTable(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, body CreateClusterDatabaseTableJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetDatabaseTokens request + GetDatabaseTokens(ctx context.Context, accountId UuidV4, clusterId UuidV4, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateDatabaseTokenWithBody request with any body + CreateDatabaseTokenWithBody(ctx context.Context, accountId UuidV4, clusterId UuidV4, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + CreateDatabaseToken(ctx context.Context, accountId UuidV4, clusterId UuidV4, body CreateDatabaseTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteDatabaseToken request + DeleteDatabaseToken(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetDatabaseToken request + GetDatabaseToken(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateDatabaseTokenWithBody request with any body + UpdateDatabaseTokenWithBody(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateDatabaseToken(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, body UpdateDatabaseTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +func (c *Client) GetClusterDatabases(ctx context.Context, accountId UuidV4, clusterId UuidV4, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetClusterDatabasesRequest(c.Server, accountId, clusterId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateClusterDatabaseWithBody(ctx context.Context, accountId UuidV4, clusterId UuidV4, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateClusterDatabaseRequestWithBody(c.Server, accountId, clusterId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateClusterDatabase(ctx context.Context, accountId UuidV4, clusterId UuidV4, body CreateClusterDatabaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateClusterDatabaseRequest(c.Server, accountId, clusterId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteClusterDatabase(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteClusterDatabaseRequest(c.Server, accountId, clusterId, databaseName) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateClusterDatabaseWithBody(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateClusterDatabaseRequestWithBody(c.Server, accountId, clusterId, databaseName, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateClusterDatabase(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, body UpdateClusterDatabaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateClusterDatabaseRequest(c.Server, accountId, clusterId, databaseName, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateClusterDatabaseTableWithBody(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateClusterDatabaseTableRequestWithBody(c.Server, accountId, clusterId, databaseName, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateClusterDatabaseTable(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, body CreateClusterDatabaseTableJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateClusterDatabaseTableRequest(c.Server, accountId, clusterId, databaseName, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetDatabaseTokens(ctx context.Context, accountId UuidV4, clusterId UuidV4, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetDatabaseTokensRequest(c.Server, accountId, clusterId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateDatabaseTokenWithBody(ctx context.Context, accountId UuidV4, clusterId UuidV4, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateDatabaseTokenRequestWithBody(c.Server, accountId, clusterId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateDatabaseToken(ctx context.Context, accountId UuidV4, clusterId UuidV4, body CreateDatabaseTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateDatabaseTokenRequest(c.Server, accountId, clusterId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteDatabaseToken(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteDatabaseTokenRequest(c.Server, accountId, clusterId, tokenId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetDatabaseToken(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetDatabaseTokenRequest(c.Server, accountId, clusterId, tokenId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateDatabaseTokenWithBody(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateDatabaseTokenRequestWithBody(c.Server, accountId, clusterId, tokenId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateDatabaseToken(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, body UpdateDatabaseTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateDatabaseTokenRequest(c.Server, accountId, clusterId, tokenId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewGetClusterDatabasesRequest generates requests for GetClusterDatabases +func NewGetClusterDatabasesRequest(server string, accountId UuidV4, clusterId UuidV4) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountId", runtime.ParamLocationPath, accountId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "clusterId", runtime.ParamLocationPath, clusterId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/accounts/%s/clusters/%s/databases", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + 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 + } + + return req, nil +} + +// NewCreateClusterDatabaseRequest calls the generic CreateClusterDatabase builder with application/json body +func NewCreateClusterDatabaseRequest(server string, accountId UuidV4, clusterId UuidV4, body CreateClusterDatabaseJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateClusterDatabaseRequestWithBody(server, accountId, clusterId, "application/json", bodyReader) +} + +// NewCreateClusterDatabaseRequestWithBody generates requests for CreateClusterDatabase with any type of body +func NewCreateClusterDatabaseRequestWithBody(server string, accountId UuidV4, clusterId UuidV4, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountId", runtime.ParamLocationPath, accountId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "clusterId", runtime.ParamLocationPath, clusterId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/accounts/%s/clusters/%s/databases", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteClusterDatabaseRequest generates requests for DeleteClusterDatabase +func NewDeleteClusterDatabaseRequest(server string, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountId", runtime.ParamLocationPath, accountId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "clusterId", runtime.ParamLocationPath, clusterId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "databaseName", runtime.ParamLocationPath, databaseName) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/accounts/%s/clusters/%s/databases/%s", pathParam0, pathParam1, pathParam2) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateClusterDatabaseRequest calls the generic UpdateClusterDatabase builder with application/json body +func NewUpdateClusterDatabaseRequest(server string, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, body UpdateClusterDatabaseJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateClusterDatabaseRequestWithBody(server, accountId, clusterId, databaseName, "application/json", bodyReader) +} + +// NewUpdateClusterDatabaseRequestWithBody generates requests for UpdateClusterDatabase with any type of body +func NewUpdateClusterDatabaseRequestWithBody(server string, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountId", runtime.ParamLocationPath, accountId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "clusterId", runtime.ParamLocationPath, clusterId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "databaseName", runtime.ParamLocationPath, databaseName) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/accounts/%s/clusters/%s/databases/%s", pathParam0, pathParam1, pathParam2) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewCreateClusterDatabaseTableRequest calls the generic CreateClusterDatabaseTable builder with application/json body +func NewCreateClusterDatabaseTableRequest(server string, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, body CreateClusterDatabaseTableJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateClusterDatabaseTableRequestWithBody(server, accountId, clusterId, databaseName, "application/json", bodyReader) +} + +// NewCreateClusterDatabaseTableRequestWithBody generates requests for CreateClusterDatabaseTable with any type of body +func NewCreateClusterDatabaseTableRequestWithBody(server string, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountId", runtime.ParamLocationPath, accountId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "clusterId", runtime.ParamLocationPath, clusterId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "databaseName", runtime.ParamLocationPath, databaseName) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/accounts/%s/clusters/%s/databases/%s/tables", pathParam0, pathParam1, pathParam2) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetDatabaseTokensRequest generates requests for GetDatabaseTokens +func NewGetDatabaseTokensRequest(server string, accountId UuidV4, clusterId UuidV4) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountId", runtime.ParamLocationPath, accountId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "clusterId", runtime.ParamLocationPath, clusterId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/accounts/%s/clusters/%s/tokens", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + 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 + } + + return req, nil +} + +// NewCreateDatabaseTokenRequest calls the generic CreateDatabaseToken builder with application/json body +func NewCreateDatabaseTokenRequest(server string, accountId UuidV4, clusterId UuidV4, body CreateDatabaseTokenJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateDatabaseTokenRequestWithBody(server, accountId, clusterId, "application/json", bodyReader) +} + +// NewCreateDatabaseTokenRequestWithBody generates requests for CreateDatabaseToken with any type of body +func NewCreateDatabaseTokenRequestWithBody(server string, accountId UuidV4, clusterId UuidV4, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountId", runtime.ParamLocationPath, accountId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "clusterId", runtime.ParamLocationPath, clusterId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/accounts/%s/clusters/%s/tokens", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteDatabaseTokenRequest generates requests for DeleteDatabaseToken +func NewDeleteDatabaseTokenRequest(server string, accountId UuidV4, clusterId UuidV4, tokenId UuidV4) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountId", runtime.ParamLocationPath, accountId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "clusterId", runtime.ParamLocationPath, clusterId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "tokenId", runtime.ParamLocationPath, tokenId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/accounts/%s/clusters/%s/tokens/%s", pathParam0, pathParam1, pathParam2) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetDatabaseTokenRequest generates requests for GetDatabaseToken +func NewGetDatabaseTokenRequest(server string, accountId UuidV4, clusterId UuidV4, tokenId UuidV4) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountId", runtime.ParamLocationPath, accountId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "clusterId", runtime.ParamLocationPath, clusterId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "tokenId", runtime.ParamLocationPath, tokenId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/accounts/%s/clusters/%s/tokens/%s", pathParam0, pathParam1, pathParam2) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + 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 + } + + return req, nil +} + +// NewUpdateDatabaseTokenRequest calls the generic UpdateDatabaseToken builder with application/json body +func NewUpdateDatabaseTokenRequest(server string, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, body UpdateDatabaseTokenJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateDatabaseTokenRequestWithBody(server, accountId, clusterId, tokenId, "application/json", bodyReader) +} + +// NewUpdateDatabaseTokenRequestWithBody generates requests for UpdateDatabaseToken with any type of body +func NewUpdateDatabaseTokenRequestWithBody(server string, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "accountId", runtime.ParamLocationPath, accountId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "clusterId", runtime.ParamLocationPath, clusterId) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "tokenId", runtime.ParamLocationPath, tokenId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/accounts/%s/clusters/%s/tokens/%s", pathParam0, pathParam1, pathParam2) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // GetClusterDatabasesWithResponse request + GetClusterDatabasesWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, reqEditors ...RequestEditorFn) (*GetClusterDatabasesResponse, error) + + // CreateClusterDatabaseWithBodyWithResponse request with any body + CreateClusterDatabaseWithBodyWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateClusterDatabaseResponse, error) + + CreateClusterDatabaseWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, body CreateClusterDatabaseJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateClusterDatabaseResponse, error) + + // DeleteClusterDatabaseWithResponse request + DeleteClusterDatabaseWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, reqEditors ...RequestEditorFn) (*DeleteClusterDatabaseResponse, error) + + // UpdateClusterDatabaseWithBodyWithResponse request with any body + UpdateClusterDatabaseWithBodyWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateClusterDatabaseResponse, error) + + UpdateClusterDatabaseWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, body UpdateClusterDatabaseJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateClusterDatabaseResponse, error) + + // CreateClusterDatabaseTableWithBodyWithResponse request with any body + CreateClusterDatabaseTableWithBodyWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateClusterDatabaseTableResponse, error) + + CreateClusterDatabaseTableWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, body CreateClusterDatabaseTableJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateClusterDatabaseTableResponse, error) + + // GetDatabaseTokensWithResponse request + GetDatabaseTokensWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, reqEditors ...RequestEditorFn) (*GetDatabaseTokensResponse, error) + + // CreateDatabaseTokenWithBodyWithResponse request with any body + CreateDatabaseTokenWithBodyWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateDatabaseTokenResponse, error) + + CreateDatabaseTokenWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, body CreateDatabaseTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateDatabaseTokenResponse, error) + + // DeleteDatabaseTokenWithResponse request + DeleteDatabaseTokenWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, reqEditors ...RequestEditorFn) (*DeleteDatabaseTokenResponse, error) + + // GetDatabaseTokenWithResponse request + GetDatabaseTokenWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, reqEditors ...RequestEditorFn) (*GetDatabaseTokenResponse, error) + + // UpdateDatabaseTokenWithBodyWithResponse request with any body + UpdateDatabaseTokenWithBodyWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateDatabaseTokenResponse, error) + + UpdateDatabaseTokenWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, body UpdateDatabaseTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateDatabaseTokenResponse, error) +} + +type GetClusterDatabasesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + + // MaxColumnsPerTable The maximum number of columns per table for the cluster database + MaxColumnsPerTable ClusterDatabaseMaxColumnsPerTable `json:"maxColumnsPerTable"` + + // MaxTables The maximum number of tables for the cluster database + MaxTables ClusterDatabaseMaxTables `json:"maxTables"` + + // Name The name of the cluster database + Name ClusterDatabaseName `json:"name"` + + // PartitionTemplate A template for [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) a cluster database. + // + // Each template part is evaluated in sequence, concatinating the final + // partition key from the output of each part, delimited by the partition + // key delimiter `|`. + // + // For example, using the partition template below: + // + // ```json + // [ + // { + // "type": "time", + // "value": "%Y" + // }, + // { + // "type": "tag", + // "value": "bananas" + // }, + // { + // "type": "tag", + // "value": "plátanos" + // }, + // { + // "type": "bucket", + // "value": { + // "tagName": "c", + // "numberOfBuckets": 10 + // } + // } + // ] + // ``` + // + // The following partition keys are derived: + // + // * `time=2023-01-01, a=bananas, b=plátanos, c=ananas` -> `2023|bananas|plátanos|5` + // * `time=2023-01-01, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01, another=cat, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01` -> `2023|!|!|!` + // * `time=2023-01-01, a=cat|dog, b=!, c=!` -> `2023|cat%7Cdog|%21|8` + // * `time=2023-01-01, a=%50, c=%50` -> `2023|%2550|!|9` + // * `time=2023-01-01, a=, c=` -> `2023|^|!|0` + // * `time=2023-01-01, a=` -> `2023|#|!|!` + // * `time=2023-01-01, c=` -> `2023|!|!|` + // + // When using the default [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) template (YYYY-MM-DD) there is no + // encoding necessary, as the derived partition key contains a single part, and + // no reserved characters. [`TemplatePart::Bucket`] parts by definition will + // always be within the part length limit and contain no restricted characters + // so are also not percent-encoded and/or truncated. + PartitionTemplate *ClusterDatabasePartitionTemplate `json:"partitionTemplate,omitempty"` + + // RetentionPeriod The retention period of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) in nanoseconds, if applicable + // + // If the retention period is not set or is set to 0, the database will have infinite retention + RetentionPeriod ClusterDatabaseRetentionPeriod `json:"retentionPeriod"` + } + JSON400 *BadRequest + JSON401 *Unauthorized + JSON403 *Forbidden + JSON404 *NotFound + JSON500 *InternalServerError +} + +// Status returns HTTPResponse.Status +func (r GetClusterDatabasesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetClusterDatabasesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CreateClusterDatabaseResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + + // MaxColumnsPerTable The maximum number of columns per table for the cluster database + MaxColumnsPerTable ClusterDatabaseMaxColumnsPerTable `json:"maxColumnsPerTable"` + + // MaxTables The maximum number of tables for the cluster database + MaxTables ClusterDatabaseMaxTables `json:"maxTables"` + + // Name The name of the cluster database + Name ClusterDatabaseName `json:"name"` + + // PartitionTemplate A template for [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) a cluster database. + // + // Each template part is evaluated in sequence, concatinating the final + // partition key from the output of each part, delimited by the partition + // key delimiter `|`. + // + // For example, using the partition template below: + // + // ```json + // [ + // { + // "type": "time", + // "value": "%Y" + // }, + // { + // "type": "tag", + // "value": "bananas" + // }, + // { + // "type": "tag", + // "value": "plátanos" + // }, + // { + // "type": "bucket", + // "value": { + // "tagName": "c", + // "numberOfBuckets": 10 + // } + // } + // ] + // ``` + // + // The following partition keys are derived: + // + // * `time=2023-01-01, a=bananas, b=plátanos, c=ananas` -> `2023|bananas|plátanos|5` + // * `time=2023-01-01, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01, another=cat, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01` -> `2023|!|!|!` + // * `time=2023-01-01, a=cat|dog, b=!, c=!` -> `2023|cat%7Cdog|%21|8` + // * `time=2023-01-01, a=%50, c=%50` -> `2023|%2550|!|9` + // * `time=2023-01-01, a=, c=` -> `2023|^|!|0` + // * `time=2023-01-01, a=` -> `2023|#|!|!` + // * `time=2023-01-01, c=` -> `2023|!|!|` + // + // When using the default [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) template (YYYY-MM-DD) there is no + // encoding necessary, as the derived partition key contains a single part, and + // no reserved characters. [`TemplatePart::Bucket`] parts by definition will + // always be within the part length limit and contain no restricted characters + // so are also not percent-encoded and/or truncated. + PartitionTemplate *ClusterDatabasePartitionTemplate `json:"partitionTemplate,omitempty"` + + // RetentionPeriod The retention period of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) in nanoseconds, if applicable + // + // If the retention period is not set or is set to 0, the database will have infinite retention + RetentionPeriod ClusterDatabaseRetentionPeriod `json:"retentionPeriod"` + } + JSON400 *BadRequest + JSON401 *Unauthorized + JSON403 *Forbidden + JSON404 *NotFound + JSON409 *Conflict + JSON500 *InternalServerError +} + +// Status returns HTTPResponse.Status +func (r CreateClusterDatabaseResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateClusterDatabaseResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteClusterDatabaseResponse struct { + Body []byte + HTTPResponse *http.Response + JSON400 *BadRequest + JSON401 *Unauthorized + JSON403 *Forbidden + JSON404 *NotFound + JSON500 *InternalServerError +} + +// Status returns HTTPResponse.Status +func (r DeleteClusterDatabaseResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteClusterDatabaseResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpdateClusterDatabaseResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + + // MaxColumnsPerTable The maximum number of columns per table for the cluster database + MaxColumnsPerTable ClusterDatabaseMaxColumnsPerTable `json:"maxColumnsPerTable"` + + // MaxTables The maximum number of tables for the cluster database + MaxTables ClusterDatabaseMaxTables `json:"maxTables"` + + // Name The name of the cluster database + Name ClusterDatabaseName `json:"name"` + + // RetentionPeriod The retention period of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) in nanoseconds, if applicable + // + // If the retention period is not set or is set to 0, the database will have infinite retention + RetentionPeriod ClusterDatabaseRetentionPeriod `json:"retentionPeriod"` + } + JSON400 *BadRequest + JSON401 *Unauthorized + JSON403 *Forbidden + JSON404 *NotFound + JSON500 *InternalServerError +} + +// Status returns HTTPResponse.Status +func (r UpdateClusterDatabaseResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateClusterDatabaseResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CreateClusterDatabaseTableResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + + // DatabaseName The name of the cluster database + DatabaseName ClusterDatabaseName `json:"databaseName"` + + // Name The name of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) table + Name ClusterDatabaseTableName `json:"name"` + + // PartitionTemplate A template for [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) a cluster database. + // + // Each template part is evaluated in sequence, concatinating the final + // partition key from the output of each part, delimited by the partition + // key delimiter `|`. + // + // For example, using the partition template below: + // + // ```json + // [ + // { + // "type": "time", + // "value": "%Y" + // }, + // { + // "type": "tag", + // "value": "bananas" + // }, + // { + // "type": "tag", + // "value": "plátanos" + // }, + // { + // "type": "bucket", + // "value": { + // "tagName": "c", + // "numberOfBuckets": 10 + // } + // } + // ] + // ``` + // + // The following partition keys are derived: + // + // * `time=2023-01-01, a=bananas, b=plátanos, c=ananas` -> `2023|bananas|plátanos|5` + // * `time=2023-01-01, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01, another=cat, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01` -> `2023|!|!|!` + // * `time=2023-01-01, a=cat|dog, b=!, c=!` -> `2023|cat%7Cdog|%21|8` + // * `time=2023-01-01, a=%50, c=%50` -> `2023|%2550|!|9` + // * `time=2023-01-01, a=, c=` -> `2023|^|!|0` + // * `time=2023-01-01, a=` -> `2023|#|!|!` + // * `time=2023-01-01, c=` -> `2023|!|!|` + // + // When using the default [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) template (YYYY-MM-DD) there is no + // encoding necessary, as the derived partition key contains a single part, and + // no reserved characters. [`TemplatePart::Bucket`] parts by definition will + // always be within the part length limit and contain no restricted characters + // so are also not percent-encoded and/or truncated. + PartitionTemplate *ClusterDatabasePartitionTemplate `json:"partitionTemplate,omitempty"` + } + JSON400 *BadRequest + JSON401 *Unauthorized + JSON403 *Forbidden + JSON404 *NotFound + JSON409 *Conflict + JSON500 *InternalServerError +} + +// Status returns HTTPResponse.Status +func (r CreateClusterDatabaseTableResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateClusterDatabaseTableResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetDatabaseTokensResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + CreatedAt DatabaseTokenCreatedAt `json:"createdAt"` + + // Description The description of the database token + Description DatabaseTokenDescription `json:"description"` + Id UuidV4 `json:"id"` + + // Permissions The list of permissions the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) allows + Permissions DatabaseTokenPermissions `json:"permissions"` + } + JSON400 *BadRequest + JSON401 *Unauthorized + JSON403 *Forbidden + JSON404 *NotFound + JSON500 *InternalServerError +} + +// Status returns HTTPResponse.Status +func (r GetDatabaseTokensResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetDatabaseTokensResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CreateDatabaseTokenResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + // AccessToken The access token that can be used to authenticate query and write requests to the cluster + // + // The access token is never stored by InfluxDB and is only returned once when the token is created. If the access token is lost, a new token must be created. + AccessToken DatabaseTokenAccessToken `json:"accessToken"` + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + CreatedAt DatabaseTokenCreatedAt `json:"createdAt"` + + // Description The description of the database token + Description DatabaseTokenDescription `json:"description"` + Id UuidV4 `json:"id"` + + // Permissions The list of permissions the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) allows + Permissions DatabaseTokenPermissions `json:"permissions"` + } + JSON400 *BadRequest + JSON401 *Unauthorized + JSON403 *Forbidden + JSON404 *NotFound + JSON409 *Conflict + JSON500 *InternalServerError +} + +// Status returns HTTPResponse.Status +func (r CreateDatabaseTokenResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateDatabaseTokenResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteDatabaseTokenResponse struct { + Body []byte + HTTPResponse *http.Response + JSON400 *BadRequest + JSON401 *Unauthorized + JSON403 *Forbidden + JSON404 *NotFound + JSON500 *InternalServerError +} + +// Status returns HTTPResponse.Status +func (r DeleteDatabaseTokenResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteDatabaseTokenResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetDatabaseTokenResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + CreatedAt DatabaseTokenCreatedAt `json:"createdAt"` + + // Description The description of the database token + Description DatabaseTokenDescription `json:"description"` + Id UuidV4 `json:"id"` + + // Permissions The list of permissions the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) allows + Permissions DatabaseTokenPermissions `json:"permissions"` + } + JSON400 *BadRequest + JSON401 *Unauthorized + JSON403 *Forbidden + JSON404 *NotFound + JSON500 *InternalServerError +} + +// Status returns HTTPResponse.Status +func (r GetDatabaseTokenResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetDatabaseTokenResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpdateDatabaseTokenResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + CreatedAt DatabaseTokenCreatedAt `json:"createdAt"` + + // Description The description of the database token + Description DatabaseTokenDescription `json:"description"` + Id UuidV4 `json:"id"` + + // Permissions The list of permissions the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) allows + Permissions DatabaseTokenPermissions `json:"permissions"` + } + JSON400 *BadRequest + JSON401 *Unauthorized + JSON403 *Forbidden + JSON404 *NotFound + JSON409 *Conflict + JSON500 *InternalServerError +} + +// Status returns HTTPResponse.Status +func (r UpdateDatabaseTokenResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateDatabaseTokenResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// GetClusterDatabasesWithResponse request returning *GetClusterDatabasesResponse +func (c *ClientWithResponses) GetClusterDatabasesWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, reqEditors ...RequestEditorFn) (*GetClusterDatabasesResponse, error) { + rsp, err := c.GetClusterDatabases(ctx, accountId, clusterId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetClusterDatabasesResponse(rsp) +} + +// CreateClusterDatabaseWithBodyWithResponse request with arbitrary body returning *CreateClusterDatabaseResponse +func (c *ClientWithResponses) CreateClusterDatabaseWithBodyWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateClusterDatabaseResponse, error) { + rsp, err := c.CreateClusterDatabaseWithBody(ctx, accountId, clusterId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateClusterDatabaseResponse(rsp) +} + +func (c *ClientWithResponses) CreateClusterDatabaseWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, body CreateClusterDatabaseJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateClusterDatabaseResponse, error) { + rsp, err := c.CreateClusterDatabase(ctx, accountId, clusterId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateClusterDatabaseResponse(rsp) +} + +// DeleteClusterDatabaseWithResponse request returning *DeleteClusterDatabaseResponse +func (c *ClientWithResponses) DeleteClusterDatabaseWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, reqEditors ...RequestEditorFn) (*DeleteClusterDatabaseResponse, error) { + rsp, err := c.DeleteClusterDatabase(ctx, accountId, clusterId, databaseName, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteClusterDatabaseResponse(rsp) +} + +// UpdateClusterDatabaseWithBodyWithResponse request with arbitrary body returning *UpdateClusterDatabaseResponse +func (c *ClientWithResponses) UpdateClusterDatabaseWithBodyWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateClusterDatabaseResponse, error) { + rsp, err := c.UpdateClusterDatabaseWithBody(ctx, accountId, clusterId, databaseName, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateClusterDatabaseResponse(rsp) +} + +func (c *ClientWithResponses) UpdateClusterDatabaseWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, body UpdateClusterDatabaseJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateClusterDatabaseResponse, error) { + rsp, err := c.UpdateClusterDatabase(ctx, accountId, clusterId, databaseName, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateClusterDatabaseResponse(rsp) +} + +// CreateClusterDatabaseTableWithBodyWithResponse request with arbitrary body returning *CreateClusterDatabaseTableResponse +func (c *ClientWithResponses) CreateClusterDatabaseTableWithBodyWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateClusterDatabaseTableResponse, error) { + rsp, err := c.CreateClusterDatabaseTableWithBody(ctx, accountId, clusterId, databaseName, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateClusterDatabaseTableResponse(rsp) +} + +func (c *ClientWithResponses) CreateClusterDatabaseTableWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, databaseName ClusterDatabaseName, body CreateClusterDatabaseTableJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateClusterDatabaseTableResponse, error) { + rsp, err := c.CreateClusterDatabaseTable(ctx, accountId, clusterId, databaseName, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateClusterDatabaseTableResponse(rsp) +} + +// GetDatabaseTokensWithResponse request returning *GetDatabaseTokensResponse +func (c *ClientWithResponses) GetDatabaseTokensWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, reqEditors ...RequestEditorFn) (*GetDatabaseTokensResponse, error) { + rsp, err := c.GetDatabaseTokens(ctx, accountId, clusterId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetDatabaseTokensResponse(rsp) +} + +// CreateDatabaseTokenWithBodyWithResponse request with arbitrary body returning *CreateDatabaseTokenResponse +func (c *ClientWithResponses) CreateDatabaseTokenWithBodyWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateDatabaseTokenResponse, error) { + rsp, err := c.CreateDatabaseTokenWithBody(ctx, accountId, clusterId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateDatabaseTokenResponse(rsp) +} + +func (c *ClientWithResponses) CreateDatabaseTokenWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, body CreateDatabaseTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateDatabaseTokenResponse, error) { + rsp, err := c.CreateDatabaseToken(ctx, accountId, clusterId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateDatabaseTokenResponse(rsp) +} + +// DeleteDatabaseTokenWithResponse request returning *DeleteDatabaseTokenResponse +func (c *ClientWithResponses) DeleteDatabaseTokenWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, reqEditors ...RequestEditorFn) (*DeleteDatabaseTokenResponse, error) { + rsp, err := c.DeleteDatabaseToken(ctx, accountId, clusterId, tokenId, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteDatabaseTokenResponse(rsp) +} + +// GetDatabaseTokenWithResponse request returning *GetDatabaseTokenResponse +func (c *ClientWithResponses) GetDatabaseTokenWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, reqEditors ...RequestEditorFn) (*GetDatabaseTokenResponse, error) { + rsp, err := c.GetDatabaseToken(ctx, accountId, clusterId, tokenId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetDatabaseTokenResponse(rsp) +} + +// UpdateDatabaseTokenWithBodyWithResponse request with arbitrary body returning *UpdateDatabaseTokenResponse +func (c *ClientWithResponses) UpdateDatabaseTokenWithBodyWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateDatabaseTokenResponse, error) { + rsp, err := c.UpdateDatabaseTokenWithBody(ctx, accountId, clusterId, tokenId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateDatabaseTokenResponse(rsp) +} + +func (c *ClientWithResponses) UpdateDatabaseTokenWithResponse(ctx context.Context, accountId UuidV4, clusterId UuidV4, tokenId UuidV4, body UpdateDatabaseTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateDatabaseTokenResponse, error) { + rsp, err := c.UpdateDatabaseToken(ctx, accountId, clusterId, tokenId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateDatabaseTokenResponse(rsp) +} + +// ParseGetClusterDatabasesResponse parses an HTTP response from a GetClusterDatabasesWithResponse call +func ParseGetClusterDatabasesResponse(rsp *http.Response) (*GetClusterDatabasesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetClusterDatabasesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + + // MaxColumnsPerTable The maximum number of columns per table for the cluster database + MaxColumnsPerTable ClusterDatabaseMaxColumnsPerTable `json:"maxColumnsPerTable"` + + // MaxTables The maximum number of tables for the cluster database + MaxTables ClusterDatabaseMaxTables `json:"maxTables"` + + // Name The name of the cluster database + Name ClusterDatabaseName `json:"name"` + + // PartitionTemplate A template for [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) a cluster database. + // + // Each template part is evaluated in sequence, concatinating the final + // partition key from the output of each part, delimited by the partition + // key delimiter `|`. + // + // For example, using the partition template below: + // + // ```json + // [ + // { + // "type": "time", + // "value": "%Y" + // }, + // { + // "type": "tag", + // "value": "bananas" + // }, + // { + // "type": "tag", + // "value": "plátanos" + // }, + // { + // "type": "bucket", + // "value": { + // "tagName": "c", + // "numberOfBuckets": 10 + // } + // } + // ] + // ``` + // + // The following partition keys are derived: + // + // * `time=2023-01-01, a=bananas, b=plátanos, c=ananas` -> `2023|bananas|plátanos|5` + // * `time=2023-01-01, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01, another=cat, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01` -> `2023|!|!|!` + // * `time=2023-01-01, a=cat|dog, b=!, c=!` -> `2023|cat%7Cdog|%21|8` + // * `time=2023-01-01, a=%50, c=%50` -> `2023|%2550|!|9` + // * `time=2023-01-01, a=, c=` -> `2023|^|!|0` + // * `time=2023-01-01, a=` -> `2023|#|!|!` + // * `time=2023-01-01, c=` -> `2023|!|!|` + // + // When using the default [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) template (YYYY-MM-DD) there is no + // encoding necessary, as the derived partition key contains a single part, and + // no reserved characters. [`TemplatePart::Bucket`] parts by definition will + // always be within the part length limit and contain no restricted characters + // so are also not percent-encoded and/or truncated. + PartitionTemplate *ClusterDatabasePartitionTemplate `json:"partitionTemplate,omitempty"` + + // RetentionPeriod The retention period of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) in nanoseconds, if applicable + // + // If the retention period is not set or is set to 0, the database will have infinite retention + RetentionPeriod ClusterDatabaseRetentionPeriod `json:"retentionPeriod"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalServerError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseCreateClusterDatabaseResponse parses an HTTP response from a CreateClusterDatabaseWithResponse call +func ParseCreateClusterDatabaseResponse(rsp *http.Response) (*CreateClusterDatabaseResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateClusterDatabaseResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + + // MaxColumnsPerTable The maximum number of columns per table for the cluster database + MaxColumnsPerTable ClusterDatabaseMaxColumnsPerTable `json:"maxColumnsPerTable"` + + // MaxTables The maximum number of tables for the cluster database + MaxTables ClusterDatabaseMaxTables `json:"maxTables"` + + // Name The name of the cluster database + Name ClusterDatabaseName `json:"name"` + + // PartitionTemplate A template for [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) a cluster database. + // + // Each template part is evaluated in sequence, concatinating the final + // partition key from the output of each part, delimited by the partition + // key delimiter `|`. + // + // For example, using the partition template below: + // + // ```json + // [ + // { + // "type": "time", + // "value": "%Y" + // }, + // { + // "type": "tag", + // "value": "bananas" + // }, + // { + // "type": "tag", + // "value": "plátanos" + // }, + // { + // "type": "bucket", + // "value": { + // "tagName": "c", + // "numberOfBuckets": 10 + // } + // } + // ] + // ``` + // + // The following partition keys are derived: + // + // * `time=2023-01-01, a=bananas, b=plátanos, c=ananas` -> `2023|bananas|plátanos|5` + // * `time=2023-01-01, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01, another=cat, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01` -> `2023|!|!|!` + // * `time=2023-01-01, a=cat|dog, b=!, c=!` -> `2023|cat%7Cdog|%21|8` + // * `time=2023-01-01, a=%50, c=%50` -> `2023|%2550|!|9` + // * `time=2023-01-01, a=, c=` -> `2023|^|!|0` + // * `time=2023-01-01, a=` -> `2023|#|!|!` + // * `time=2023-01-01, c=` -> `2023|!|!|` + // + // When using the default [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) template (YYYY-MM-DD) there is no + // encoding necessary, as the derived partition key contains a single part, and + // no reserved characters. [`TemplatePart::Bucket`] parts by definition will + // always be within the part length limit and contain no restricted characters + // so are also not percent-encoded and/or truncated. + PartitionTemplate *ClusterDatabasePartitionTemplate `json:"partitionTemplate,omitempty"` + + // RetentionPeriod The retention period of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) in nanoseconds, if applicable + // + // If the retention period is not set or is set to 0, the database will have infinite retention + RetentionPeriod ClusterDatabaseRetentionPeriod `json:"retentionPeriod"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest Conflict + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalServerError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseDeleteClusterDatabaseResponse parses an HTTP response from a DeleteClusterDatabaseWithResponse call +func ParseDeleteClusterDatabaseResponse(rsp *http.Response) (*DeleteClusterDatabaseResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteClusterDatabaseResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalServerError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseUpdateClusterDatabaseResponse parses an HTTP response from a UpdateClusterDatabaseWithResponse call +func ParseUpdateClusterDatabaseResponse(rsp *http.Response) (*UpdateClusterDatabaseResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateClusterDatabaseResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + + // MaxColumnsPerTable The maximum number of columns per table for the cluster database + MaxColumnsPerTable ClusterDatabaseMaxColumnsPerTable `json:"maxColumnsPerTable"` + + // MaxTables The maximum number of tables for the cluster database + MaxTables ClusterDatabaseMaxTables `json:"maxTables"` + + // Name The name of the cluster database + Name ClusterDatabaseName `json:"name"` + + // RetentionPeriod The retention period of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) in nanoseconds, if applicable + // + // If the retention period is not set or is set to 0, the database will have infinite retention + RetentionPeriod ClusterDatabaseRetentionPeriod `json:"retentionPeriod"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalServerError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseCreateClusterDatabaseTableResponse parses an HTTP response from a CreateClusterDatabaseTableWithResponse call +func ParseCreateClusterDatabaseTableResponse(rsp *http.Response) (*CreateClusterDatabaseTableResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateClusterDatabaseTableResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + + // DatabaseName The name of the cluster database + DatabaseName ClusterDatabaseName `json:"databaseName"` + + // Name The name of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) table + Name ClusterDatabaseTableName `json:"name"` + + // PartitionTemplate A template for [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) a cluster database. + // + // Each template part is evaluated in sequence, concatinating the final + // partition key from the output of each part, delimited by the partition + // key delimiter `|`. + // + // For example, using the partition template below: + // + // ```json + // [ + // { + // "type": "time", + // "value": "%Y" + // }, + // { + // "type": "tag", + // "value": "bananas" + // }, + // { + // "type": "tag", + // "value": "plátanos" + // }, + // { + // "type": "bucket", + // "value": { + // "tagName": "c", + // "numberOfBuckets": 10 + // } + // } + // ] + // ``` + // + // The following partition keys are derived: + // + // * `time=2023-01-01, a=bananas, b=plátanos, c=ananas` -> `2023|bananas|plátanos|5` + // * `time=2023-01-01, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01, another=cat, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01` -> `2023|!|!|!` + // * `time=2023-01-01, a=cat|dog, b=!, c=!` -> `2023|cat%7Cdog|%21|8` + // * `time=2023-01-01, a=%50, c=%50` -> `2023|%2550|!|9` + // * `time=2023-01-01, a=, c=` -> `2023|^|!|0` + // * `time=2023-01-01, a=` -> `2023|#|!|!` + // * `time=2023-01-01, c=` -> `2023|!|!|` + // + // When using the default [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) template (YYYY-MM-DD) there is no + // encoding necessary, as the derived partition key contains a single part, and + // no reserved characters. [`TemplatePart::Bucket`] parts by definition will + // always be within the part length limit and contain no restricted characters + // so are also not percent-encoded and/or truncated. + PartitionTemplate *ClusterDatabasePartitionTemplate `json:"partitionTemplate,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest Conflict + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalServerError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetDatabaseTokensResponse parses an HTTP response from a GetDatabaseTokensWithResponse call +func ParseGetDatabaseTokensResponse(rsp *http.Response) (*GetDatabaseTokensResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetDatabaseTokensResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + CreatedAt DatabaseTokenCreatedAt `json:"createdAt"` + + // Description The description of the database token + Description DatabaseTokenDescription `json:"description"` + Id UuidV4 `json:"id"` + + // Permissions The list of permissions the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) allows + Permissions DatabaseTokenPermissions `json:"permissions"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalServerError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseCreateDatabaseTokenResponse parses an HTTP response from a CreateDatabaseTokenWithResponse call +func ParseCreateDatabaseTokenResponse(rsp *http.Response) (*CreateDatabaseTokenResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateDatabaseTokenResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + // AccessToken The access token that can be used to authenticate query and write requests to the cluster + // + // The access token is never stored by InfluxDB and is only returned once when the token is created. If the access token is lost, a new token must be created. + AccessToken DatabaseTokenAccessToken `json:"accessToken"` + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + CreatedAt DatabaseTokenCreatedAt `json:"createdAt"` + + // Description The description of the database token + Description DatabaseTokenDescription `json:"description"` + Id UuidV4 `json:"id"` + + // Permissions The list of permissions the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) allows + Permissions DatabaseTokenPermissions `json:"permissions"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest Conflict + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalServerError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseDeleteDatabaseTokenResponse parses an HTTP response from a DeleteDatabaseTokenWithResponse call +func ParseDeleteDatabaseTokenResponse(rsp *http.Response) (*DeleteDatabaseTokenResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteDatabaseTokenResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalServerError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetDatabaseTokenResponse parses an HTTP response from a GetDatabaseTokenWithResponse call +func ParseGetDatabaseTokenResponse(rsp *http.Response) (*GetDatabaseTokenResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetDatabaseTokenResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + CreatedAt DatabaseTokenCreatedAt `json:"createdAt"` + + // Description The description of the database token + Description DatabaseTokenDescription `json:"description"` + Id UuidV4 `json:"id"` + + // Permissions The list of permissions the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) allows + Permissions DatabaseTokenPermissions `json:"permissions"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalServerError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseUpdateDatabaseTokenResponse parses an HTTP response from a UpdateDatabaseTokenWithResponse call +func ParseUpdateDatabaseTokenResponse(rsp *http.Response) (*UpdateDatabaseTokenResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateDatabaseTokenResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + AccountId UuidV4 `json:"accountId"` + ClusterId UuidV4 `json:"clusterId"` + CreatedAt DatabaseTokenCreatedAt `json:"createdAt"` + + // Description The description of the database token + Description DatabaseTokenDescription `json:"description"` + Id UuidV4 `json:"id"` + + // Permissions The list of permissions the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) allows + Permissions DatabaseTokenPermissions `json:"permissions"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest Conflict + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalServerError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..fb2de89 --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module github.com/komminarlabs/influxdb3 + +go 1.22.2 + +require github.com/oapi-codegen/runtime v1.1.1 + +require ( + github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect + github.com/google/uuid v1.5.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..1ab0184 --- /dev/null +++ b/go.sum @@ -0,0 +1,21 @@ +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/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/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= +github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro= +github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg= +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/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.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +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/openapi.yml b/openapi.yml new file mode 100644 index 0000000..6aa4041 --- /dev/null +++ b/openapi.yml @@ -0,0 +1,1952 @@ +openapi: 3.1.0 +info: + title: InfluxDB Cloud Dedicated Management API + description: | + The InfluxDB v3 Management API lets you manage an InfluxDB Cloud Dedicated instance and integrate functions such as creating and managing databases, permissions, and tokens into your workflow or application. + + This documentation is generated from the + InfluxDB OpenAPI specification. + summary: | + The Management API for InfluxDB Cloud Dedicated provides a programmatic interface for managing an InfluxDB Cloud Dedicated instance. + license: + name: MIT + url: https://opensource.org/licenses/MIT + version: '' +servers: + - url: https://{baseurl}/api/v0 + description: InfluxDB Cloud Dedicated Management API URL + variables: + baseurl: + enum: + - console.influxdata.com + default: console.influxdata.com + description: InfluxDB Cloud Dedicated Console URL +security: + - bearerAuthManagementToken: [] + bearerAuthJwt: [] +tags: + - name: Authentication + x-traitTag: true + description: | + The InfluxDB Management API endpoints require the following credentials: + + - `ACCOUNT_ID`: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the cluster belongs to. To view account ID and cluster ID, [list cluster details](/influxdb/cloud-dedicated/admin/clusters/list/#detailed-output-in-json). + - `CLUSTER_ID`: The ID of the [cluster](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that you want to manage. To view account ID and cluster ID, [list cluster details](/influxdb/cloud-dedicated/admin/clusters/list/#detailed-output-in-json). + - `Authorization MANAGEMENT_TOKEN`: the `Authorization` HTTP header with a [management token](/influxdb/cloud-dedicated/admin/tokens/management/). + + See how to [create a management token](/influxdb/cloud-dedicated/admin/tokens/management/). + + By default, management tokens in InfluxDB v3 are short-lived tokens issued by an OAuth2 identity provider that grant a specific user administrative access to your InfluxDB cluster. However, for automation purposes, you can manually create management tokens that authenticate directly with your InfluxDB cluster and do not require human interaction with your identity provider. + + + - name: Database tokens + description: Manage database read/write tokens for a cluster + - name: Databases + description: Manage databases for a cluster + - name: Example + x-traitTag: true + description: | + The following example script shows how to use `curl` to make database and token management requests: + + ```shell + #!/bin/bash + + # Usage: + # Note the leading space in the command below to keep secrets out of the shell history + # + # ``` + # MANAGEMENT_TOKEN= ACCOUNT_ID= CLUSTER_ID= ./scripts/test_http_api_v0_endpoints.sh + # ``` + + # Env var validation + if [ -z "${MANAGEMENT_TOKEN}" ]; then + echo " + [Error]: ❌ + \$MANAGEMENT_TOKEN env var is required. + " + exit 1 + fi + + if [ -z "${ACCOUNT_ID}" ]; then + echo " + [Error]: ❌ + \$ACCOUNT_ID env var is required. + " + exit 1 + fi + + if [ -z "${CLUSTER_ID}" ]; then + echo " + [Error]: ❌ + \$CLUSTER_ID env var is required. + " + exit 1 + fi + + HOST="https://console.influxdata.com" + + # Database request functions + list_databases () { + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/databases" \ + --header "Accept: application/json" \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + ) + echo "$response" + } + + create_database () { + local databaseName=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/databases" \ + --header "Accept: application/json" \ + --header 'Content-Type: application/json' \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + --data '{ + "name": "'$databaseName'", + "maxTables": 75, + "maxColumnsPerTable": 90, + "retentionPeriod": 600000000000, + "partitionTemplate": [ + { + "type": "tag", + "value": "abc" + }, + { + "type": "bucket", + "value": { + "tagName": "def", + "numberOfBuckets": 5 + } + } + ] + }' \ + ) + echo "$response" + } + + update_database () { + local databaseName=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/databases/$databaseName" \ + --request PATCH \ + --header "Accept: application/json" \ + --header 'Content-Type: application/json' \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + --data '{ + "maxTables": 150, + "maxColumnsPerTable": 180, + "retentionPeriod": 1200000000000 + }' \ + ) + echo "$response" + } + + delete_database () { + local databaseName=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/databases/$databaseName" \ + --request DELETE \ + --header "Accept: application/json" \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + ) + echo "$response" + } + + # Token request functions + list_tokens () { + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/tokens" \ + --header "Accept: application/json" \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + ) + echo "$response" + } + + create_token () { + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/tokens" \ + --header "Accept: application/json" \ + --header 'Content-Type: application/json' \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + --data '{ + "description": "my test token", + "permissions": [ + { + "action": "write", + "resource": "database_one" + }, + { + "action": "read", + "resource": "database_two" + } + ] + }' \ + ) + echo "$response" + } + + get_token () { + local token_id=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/tokens/$tokenId" \ + --header "Accept: application/json" \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + ) + echo "$response" + } + + update_token () { + local token_id=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/tokens/$tokenId" \ + --request PATCH \ + --header "Accept: application/json" \ + --header 'Content-Type: application/json' \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + --data '{ + "description": "my updated test token", + "permissions": [ + { + "action": "database_one", + "resource": "read" + } + ] + }' \ + ) + echo "$response" + } + + delete_token () { + local token_id=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/tokens/$tokenId" \ + --request DELETE \ + --header "Accept: application/json" \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + ) + echo "$response" + } + + + # Test database endpoints + databaseName="test_database_$RANDOM" + + printf "\n🏗️ Creating database... 🏗️\n\n" + response="$(create_database $databaseName)" + echo $response | jq + printf "\n🏗️ Creating database successful 🏗️\n\n" + + printf "\n⬆️ Updating database... ⬆️\n\n" + response="$(update_database $databaseName)" + echo $response | jq + printf "\n⬆️ Updating database successful ⬆️\n\n" + + printf "\n⬇️ Listing databases... ⬇️\n\n" + response="$(list_databases)" + echo $response | jq + printf "\n⬇️ Listing databases successful ⬇️\n\n" + + printf "\n🗑️ Deleting database... 🗑️\n\n" + response="$(delete_database $databaseName)" + echo $response | jq + printf "\n🗑️ Deleting database successful 🗑️\n\n" + + + # Test token endpoints + printf "\n🏗️ Creating token... 🏗️\n\n" + response="$(create_token)" + echo $response | jq + tokenId=$(echo $response | jq '.id') + printf "\n🏗️ Creating token successful 🏗️\n\n" + + printf "\n⬇️ Getting token... ⬇️\n\n" + response="$(get_token $tokenId)" + echo $response | jq + printf "\n⬇️ Getting token successful ⬇️\n\n" + + printf "\n⬆️ Updating token... ⬆️\n\n" + response="$(update_token $tokenId)" + echo $response | jq + printf "\n⬆️ Updating token successful ⬆️\n\n" + + printf "\n📋 Listing tokens... 📋\n\n" + response="$(list_tokens)" + echo $response | jq + printf "\n📋 Listing tokens successful 📋\n\n" + + printf "\n🗑️ Deleting token... 🗑️\n\n" + response="$(delete_token $tokenId)" + echo $response | jq + printf "\n🗑️ Deleting token successful 🗑️\n\n" + ``` + - name: Tables + description: Manage tables in a database +paths: + /accounts/{accountId}/clusters/{clusterId}/databases: + get: + operationId: GetClusterDatabases + summary: Get all databases for a cluster + parameters: + - name: accountId + in: path + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) to get the [databases](/influxdb/cloud-dedicated/admin/databases/) for + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: clusterId + in: path + description: The ID of the cluster to get the [databases](/influxdb/cloud-dedicated/admin/databases/) for + required: true + schema: + $ref: '#/components/schemas/UuidV4' + responses: + '200': + description: The cluster databases were successfully retrieved + content: + application/json: + schema: + type: array + items: + type: object + properties: + accountId: + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the database belongs to + $ref: '#/components/schemas/UuidV4' + clusterId: + description: The ID of the cluster that the database belongs to + $ref: '#/components/schemas/UuidV4' + name: + $ref: '#/components/schemas/ClusterDatabaseName' + maxTables: + $ref: '#/components/schemas/ClusterDatabaseMaxTables' + maxColumnsPerTable: + $ref: '#/components/schemas/ClusterDatabaseMaxColumnsPerTable' + retentionPeriod: + $ref: '#/components/schemas/ClusterDatabaseRetentionPeriod' + partitionTemplate: + $ref: '#/components/schemas/ClusterDatabasePartitionTemplate' + required: + - accountId + - clusterId + - name + - maxTables + - maxColumnsPerTable + - retentionPeriod + example: + - accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + name: DatabaseOne + maxTables: 500 + maxColumnsPerTable: 200 + retentionPeriod: 0 + - accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + name: DatabaseTwo + maxTables: 100 + maxColumnsPerTable: 50 + retentionPeriod: 300000000000 + partitionTemplate: + - type: time + value: '%Y' + - type: tag + value: bananas + - type: tag + value: plátanos + - type: bucket + value: + tagName: c + numberOfBuckets: 10 + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/InternalServerError' + x-codeSamples: + - label: '' + lang: Shell + source: | + HOST="https://console.influxdata.com" + + list_databases () { + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/databases" \ + --header "Accept: application/json" \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + ) + echo "$response" + } + tags: + - Databases + post: + operationId: CreateClusterDatabase + summary: Create a database + tags: + - Databases + parameters: + - name: accountId + in: path + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) to create the database for + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: clusterId + in: path + description: The ID of the cluster to create the database for + required: true + schema: + $ref: '#/components/schemas/UuidV4' + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + $ref: '#/components/schemas/ClusterDatabaseName' + maxTables: + $ref: '#/components/schemas/ClusterDatabaseMaxTables' + maxColumnsPerTable: + $ref: '#/components/schemas/ClusterDatabaseMaxColumnsPerTable' + retentionPeriod: + $ref: '#/components/schemas/ClusterDatabaseRetentionPeriod' + partitionTemplate: + $ref: '#/components/schemas/ClusterDatabasePartitionTemplate' + required: + - name + examples: + requiredFieldsOnly: + summary: Required Fields Only + value: + name: DatabaseOne + allFields: + summary: All Fields + value: + name: DatabaseTwo + maxTables: 100 + maxColumnsPerTable: 50 + retentionPeriod: 300000000000 + partitionTemplate: + - type: time + value: '%Y' + - type: tag + value: bananas + - type: tag + value: plátanos + - type: bucket + value: + tagName: c + numberOfBuckets: 10 + responses: + '200': + description: The cluster database was successfully created + content: + application/json: + schema: + type: object + properties: + accountId: + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the database belongs to + $ref: '#/components/schemas/UuidV4' + clusterId: + description: The ID of the cluster that the database belongs to + $ref: '#/components/schemas/UuidV4' + name: + $ref: '#/components/schemas/ClusterDatabaseName' + maxTables: + $ref: '#/components/schemas/ClusterDatabaseMaxTables' + maxColumnsPerTable: + $ref: '#/components/schemas/ClusterDatabaseMaxColumnsPerTable' + retentionPeriod: + $ref: '#/components/schemas/ClusterDatabaseRetentionPeriod' + partitionTemplate: + $ref: '#/components/schemas/ClusterDatabasePartitionTemplate' + required: + - accountId + - clusterId + - name + - maxTables + - maxColumnsPerTable + - retentionPeriod + examples: + requiredFieldsOnly: + summary: Required Fields Only + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + name: DatabaseOne + maxTables: 500 + maxColumnsPerTable: 200 + retentionPeriod: 0 + allFields: + summary: All Fields + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + name: DatabaseTwo + maxTables: 100 + maxColumnsPerTable: 50 + retentionPeriod: 300000000000 + partitionTemplate: + - type: time + value: '%Y' + - type: tag + value: a + - type: tag + value: c + - type: bucket + value: + tagName: c + numberOfBuckets: 10 + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/InternalServerError' + x-codeSamples: + - label: cURL + lang: Shell + source: | + HOST="https://console.influxdata.com" + + create_database () { + local databaseName=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/databases" \ + --header "Accept: application/json" \ + --header 'Content-Type: application/json' \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + --data '{ + "name": "'$databaseName'", + "maxTables": 75, + "maxColumnsPerTable": 90, + "retentionPeriod": 600000000000, + "partitionTemplate": [ + { + "type": "tag", + "value": "abc" + }, + { + "type": "bucket", + "value": { + "tagName": "def", + "numberOfBuckets": 5 + } + } + ] + }' \ + ) + echo "$response" + } + /accounts/{accountId}/clusters/{clusterId}/databases/{databaseName}: + patch: + operationId: UpdateClusterDatabase + summary: Update a database + tags: + - Databases + parameters: + - name: accountId + in: path + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the database belongs to + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: clusterId + in: path + description: The ID of the cluster that the database belongs to + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: databaseName + in: path + description: The name of the database to update + required: true + schema: + $ref: '#/components/schemas/ClusterDatabaseName' + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + maxTables: + $ref: '#/components/schemas/ClusterDatabaseMaxTables' + maxColumnsPerTable: + $ref: '#/components/schemas/ClusterDatabaseMaxColumnsPerTable' + retentionPeriod: + $ref: '#/components/schemas/ClusterDatabaseRetentionPeriod' + minProperties: 1 + examples: + allFields: + summary: Update All Fields + value: + maxTables: 300 + maxColumnsPerTable: 150 + retentionPeriod: 600000000000 + maxTablsOnly: + summary: Update Max Tables Only + value: + maxTables: 300 + maxColumnsPerTableOnly: + summary: Update Max Columns Per Table Only + value: + maxColumnsPerTable: 150 + retentionPeriodOnly: + summary: Update Retention Period Only + value: + retentionPeriod: 600000000000 + responses: + '200': + description: The cluster database was successfully updated. + content: + application/json: + schema: + type: object + properties: + accountId: + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the database belongs to + $ref: '#/components/schemas/UuidV4' + clusterId: + description: The ID of the cluster that the database belongs to + $ref: '#/components/schemas/UuidV4' + name: + $ref: '#/components/schemas/ClusterDatabaseName' + maxTables: + $ref: '#/components/schemas/ClusterDatabaseMaxTables' + maxColumnsPerTable: + $ref: '#/components/schemas/ClusterDatabaseMaxColumnsPerTable' + retentionPeriod: + $ref: '#/components/schemas/ClusterDatabaseRetentionPeriod' + required: + - accountId + - clusterId + - maxTables + - maxColumnsPerTable + - retentionPeriod + - name + examples: + allFields: + summary: Update All Fields + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + name: DatabaseOne + maxTables: 300 + maxColumnsPerTable: 150 + retentionPeriod: 600000000000 + maxTablsOnly: + summary: Update Max Tables Only + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + name: DatabaseOne + maxTables: 300 + maxColumnsPerTable: 200 + retentionPeriod: 0 + maxColumnsPerTableOnly: + summary: Update Max Columns Per Table Only + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + name: DatabaseOne + maxTables: 500 + maxColumnsPerTable: 150 + retentionPeriod: 0 + retentionPeriodOnly: + summary: Update Retention Period Only + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + name: DatabaseOne + maxTables: 500 + maxColumnsPerTable: 200 + retentionPeriod: 600000000000 + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/InternalServerError' + x-codeSamples: + - label: cURL + lang: Shell + source: | + HOST="https://console.influxdata.com" + + update_database () { + local databaseName=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/databases/$databaseName" \ + --request PATCH \ + --header "Accept: application/json" \ + --header 'Content-Type: application/json' \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + --data '{ + "maxTables": 150, + "maxColumnsPerTable": 180, + "retentionPeriod": 1200000000000 + }' \ + ) + echo "$response" + } + delete: + operationId: DeleteClusterDatabase + summary: Delete a database + tags: + - Databases + parameters: + - name: accountId + in: path + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the database belongs to + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: clusterId + in: path + description: The ID of the cluster that the database belongs to + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: databaseName + in: path + description: The name of the database to delete + required: true + schema: + $ref: '#/components/schemas/ClusterDatabaseName' + responses: + '204': + description: The cluster database was successfully deleted + $ref: '#/components/responses/NoContent' + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/InternalServerError' + x-codeSamples: + - label: cURL + lang: Shell + source: | + HOST="https://console.influxdata.com" + + delete_database () { + local databaseName=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/databases/$databaseName" \ + --request DELETE \ + --header "Accept: application/json" \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + ) + echo "$response" + } + /accounts/{accountId}/clusters/{clusterId}/databases/{databaseName}/tables: + post: + operationId: CreateClusterDatabaseTable + summary: Create a database table + tags: + - Tables + parameters: + - name: accountId + in: path + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) to create the database table for + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: clusterId + in: path + description: The ID of the cluster to create the database table for + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: databaseName + in: path + description: The name of the database to create the database table for + required: true + schema: + $ref: '#/components/schemas/ClusterDatabaseName' + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + $ref: '#/components/schemas/ClusterDatabaseTableName' + partitionTemplate: + $ref: '#/components/schemas/ClusterDatabasePartitionTemplate' + required: + - name + examples: + requiredFieldsOnly: + summary: Required Fields Only + value: + name: TableOne + allFields: + summary: All Fields + value: + name: TableTwo + partitionTemplate: + - type: time + value: '%Y' + - type: tag + value: bananas + - type: tag + value: plátanos + - type: bucket + value: + tagName: c + numberOfBuckets: 10 + responses: + '200': + description: The cluster database table was successfully created + content: + application/json: + schema: + type: object + properties: + accountId: + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the database table belongs to + $ref: '#/components/schemas/UuidV4' + clusterId: + description: The ID of the cluster that the database table belongs to + $ref: '#/components/schemas/UuidV4' + databaseName: + description: The name of the database that the database table belongs to + $ref: '#/components/schemas/ClusterDatabaseName' + name: + description: The name of the database table + $ref: '#/components/schemas/ClusterDatabaseTableName' + partitionTemplate: + $ref: '#/components/schemas/ClusterDatabasePartitionTemplate' + required: + - accountId + - clusterId + - databaseName + - name + examples: + requiredFieldsOnly: + summary: Required Fields Only + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + databaseName: DatabaseOne + name: TableOne + allFields: + summary: All Fields + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + databaseName: DatabaseOne + name: TableTwo + partitionTemplate: + - type: time + value: '%Y' + - type: tag + value: a + - type: tag + value: c + - type: bucket + value: + tagName: c + numberOfBuckets: 10 + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/InternalServerError' + /accounts/{accountId}/clusters/{clusterId}/tokens: + get: + operationId: GetDatabaseTokens + summary: Get all database tokens for a cluster + tags: + - Database tokens + parameters: + - name: accountId + in: path + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) to get the [database tokens](/influxdb/cloud-dedicated/admin/tokens/database/) for + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: clusterId + in: path + description: The ID of the cluster to get the [database tokens](/influxdb/cloud-dedicated/admin/tokens/database/) for + required: true + schema: + $ref: '#/components/schemas/UuidV4' + responses: + '200': + description: The database tokens were successfully retrieved + content: + application/json: + schema: + type: array + items: + type: object + properties: + accountId: + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + $ref: '#/components/schemas/UuidV4' + clusterId: + description: The ID of the cluster that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + $ref: '#/components/schemas/UuidV4' + id: + description: The ID of the database token + $ref: '#/components/schemas/UuidV4' + description: + $ref: '#/components/schemas/DatabaseTokenDescription' + permissions: + $ref: '#/components/schemas/DatabaseTokenPermissions' + createdAt: + $ref: '#/components/schemas/DatabaseTokenCreatedAt' + required: + - accountId + - clusterId + - id + - description + - permissions + - createdAt + example: + - accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 55555555-5555-4555-8555-555555555555 + description: Limited Access Token + permissions: + - action: read + resource: DatabaseOne + - action: write + resource: DatabaseTwo + createdAt: '2023-12-21T17:32:28.000Z' + - accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 66666666-6666-4666-8666-666666666666 + description: Full Access Token + permissions: + - action: write + resource: '*' + createdAt: '2024-03-02T04:20:19.000Z' + - accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 77777777-7777-4777-8777-777777777777 + description: No Access Token + permissions: [] + createdAt: '2024-03-02T04:20:19.000Z' + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/InternalServerError' + x-codeSamples: + - label: cURL + lang: Shell + source: | + HOST="https://console.influxdata.com" + + list_tokens () { + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/tokens" \ + --header "Accept: application/json" \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + ) + echo "$response" + } + post: + operationId: CreateDatabaseToken + summary: Create a database token + tags: + - Database tokens + description: | + Create a [database token](/influxdb/cloud-dedicated/admin/tokens/database/) for a cluster. + + The token returned on the `accessToken` property in the response can be used to authenticate query and write requests to the cluster. + + ### Notable behaviors + + - InfluxDB might take some time--from a few seconds to a few minutes--to activate and synchronize new tokens. If a new database token doesn't immediately work (you receive a `401 Unauthorized` error) for querying or writing, wait and then try your request again. + + - Token strings are viewable _only_ on token creation and aren't stored by InfluxDB; you can't recover a lost token. + + #### Store secure tokens in a secret store + + We recommend storing database tokens in a **secure secret store**. + For example, see how to [authenticate Telegraf using tokens in your OS secret store](https://github.com/influxdata/telegraf/tree/master/plugins/secretstores/os). + + If you lose a token, [delete the token from InfluxDB](/influxdb/cloud-dedicated/admin/tokens/database/delete/) and create a new one. + + parameters: + - name: accountId + in: path + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) to create the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) for + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: clusterId + in: path + description: The ID of the cluster to create the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) for + required: true + schema: + $ref: '#/components/schemas/UuidV4' + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + description: + $ref: '#/components/schemas/DatabaseTokenDescription' + permissions: + $ref: '#/components/schemas/DatabaseTokenPermissions' + required: + - description + examples: + limitedAccessToken: + summary: Limited Access Token + value: + description: Limited Access Token + permissions: + - action: read + resource: DatabaseOne + - action: write + resource: DatabaseTwo + fullAccessToken: + summary: Full Access Token + value: + description: Full Access Token + permissions: + - action: write + resource: '*' + noAccessToken: + summary: No Access Token + value: + description: No Access Token + permissions: [] + responses: + '200': + description: The database token was successfully created + content: + application/json: + schema: + type: object + properties: + accountId: + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + $ref: '#/components/schemas/UuidV4' + clusterId: + description: The ID of the cluster that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + $ref: '#/components/schemas/UuidV4' + id: + description: The ID of the database token + $ref: '#/components/schemas/UuidV4' + description: + $ref: '#/components/schemas/DatabaseTokenDescription' + permissions: + $ref: '#/components/schemas/DatabaseTokenPermissions' + createdAt: + $ref: '#/components/schemas/DatabaseTokenCreatedAt' + accessToken: + $ref: '#/components/schemas/DatabaseTokenAccessToken' + required: + - accountId + - clusterId + - id + - description + - permissions + - createdAt + - accessToken + examples: + limitedAccessToken: + summary: Limited Access Token + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 55555555-5555-4555-8555-555555555555 + description: Limited Access Token + permissions: + - action: read + resource: DatabaseOne + - action: write + resource: DatabaseTwo + createdAt: '2023-12-21T17:32:28.000Z' + accessToken: apiv1_5555555555555555555555555555555555555555555555555555555555555555 + fullAccessToken: + summary: Full Access Token + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 66666666-6666-4666-8666-666666666666 + description: Full Access Token + permissions: + - action: write + resource: '*' + createdAt: '2024-03-02T04:20:19.000Z' + accessToken: apiv1_6666666666666666666666666666666666666666666666666666666666666666 + noAccessToken: + summary: No Access Token + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 66666666-6666-4666-8666-666666666666 + description: No Access Token + permissions: [] + createdAt: '2024-03-02T04:20:19.000Z' + accessToken: apiv1_7777777777777777777777777777777777777777777777777777777777777777 + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/InternalServerError' + x-codeSamples: + - label: cURL + lang: Shell + source: | + HOST="https://console.influxdata.com" + + create_token () { + local description=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/tokens" \ + --header "Accept: application/json" \ + --header 'Content-Type: application/json' \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + --data '{ + "description": "'$description'", + "permissions": [ + { + "action": "read", + "resource": "DatabaseOne" + }, + { + "action": "write", + "resource": "DatabaseTwo" + } + ] + }' \ + ) + echo "$response" + } + /accounts/{accountId}/clusters/{clusterId}/tokens/{tokenId}: + get: + operationId: GetDatabaseToken + summary: Get a database token + tags: + - Database tokens + parameters: + - name: accountId + in: path + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: clusterId + in: path + description: The ID of the cluster that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: tokenId + in: path + description: The ID of the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) to get + required: true + schema: + $ref: '#/components/schemas/UuidV4' + responses: + '200': + description: The database token was successfully retrieved. + content: + application/json: + schema: + type: object + properties: + accountId: + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + $ref: '#/components/schemas/UuidV4' + clusterId: + description: The ID of the cluster that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + $ref: '#/components/schemas/UuidV4' + id: + description: The ID of the database token + $ref: '#/components/schemas/UuidV4' + description: + $ref: '#/components/schemas/DatabaseTokenDescription' + permissions: + $ref: '#/components/schemas/DatabaseTokenPermissions' + createdAt: + $ref: '#/components/schemas/DatabaseTokenCreatedAt' + required: + - accountId + - clusterId + - id + - description + - permissions + - createdAt + examples: + limitedAccessToken: + summary: Limited Access Token + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 55555555-5555-4555-8555-555555555555 + description: Limited Access Token + permissions: + - action: read + resource: DatabaseOne + - action: write + resource: DatabaseTwo + createdAt: '2023-12-21T17:32:28.000Z' + fullAccessToken: + summary: Full Access Token + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 66666666-6666-4666-8666-666666666666 + description: Full Access Token + permissions: + - action: write + resource: '*' + createdAt: '2024-03-02T04:20:19.000Z' + noAccessToken: + summary: No Access Token + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 77777777-7777-4777-8777-777777777777 + description: No Access Token + permissions: [] + createdAt: '2024-03-02T04:20:19.000Z' + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/InternalServerError' + x-codeSamples: + - label: cURL + lang: Shell + source: | + HOST="https://console.influxdata.com" + + get_token () { + local tokenId=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/tokens/$tokenId" \ + --header "Accept: application/json" \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + ) + echo "$response" + } + patch: + operationId: UpdateDatabaseToken + summary: Update a database token + tags: + - Database tokens + parameters: + - name: accountId + in: path + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: clusterId + in: path + description: The ID of the cluster that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: tokenId + in: path + description: The ID of the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) to update + required: true + schema: + $ref: '#/components/schemas/UuidV4' + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + description: + $ref: '#/components/schemas/DatabaseTokenDescription' + permissions: + $ref: '#/components/schemas/DatabaseTokenPermissions' + minProperties: 1 + examples: + allFields: + summary: Update All Fields + value: + description: Updated Limited Access Token + permissions: + - action: write + resource: DatabaseOne + - action: read + resource: DatabaseTwo + - action: write + resource: DatabaseThree + descriptionOnly: + summary: Update Description Only + value: + description: Updated Limited Access Token + permissionsOnly: + summary: Update Permissions Only + value: + permissions: + - action: write + resource: DatabaseOne + - action: read + resource: DatabaseTwo + - action: write + resource: DatabaseThree + removeAllPermissions: + summary: Remove All Permissions + value: + permissions: [] + responses: + '200': + description: The database token was successfully updated + content: + application/json: + schema: + type: object + properties: + accountId: + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + $ref: '#/components/schemas/UuidV4' + clusterId: + description: The ID of the cluster that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + $ref: '#/components/schemas/UuidV4' + id: + description: The ID of the database token + $ref: '#/components/schemas/UuidV4' + description: + $ref: '#/components/schemas/DatabaseTokenDescription' + permissions: + $ref: '#/components/schemas/DatabaseTokenPermissions' + createdAt: + $ref: '#/components/schemas/DatabaseTokenCreatedAt' + required: + - accountId + - clusterId + - id + - description + - permissions + - createdAt + examples: + allFields: + summary: Update All Fields + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 55555555-5555-4555-8555-555555555555 + description: Updated Limited Access Token + permissions: + - action: write + resource: DatabaseOne + - action: read + resource: DatabaseTwo + - action: write + resource: DatabaseThree + createdAt: '2023-12-21T17:32:28.000Z' + descriptionOnly: + summary: Update Description Only + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 55555555-5555-4555-8555-555555555555 + description: Updated Limited Access Token + permissions: + - action: read + resource: DatabaseOne + - action: write + resource: DatabaseTwo + createdAt: '2023-12-21T17:32:28.000Z' + permissionsOnly: + summary: Update Permissions Only + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 55555555-5555-4555-8555-555555555555 + description: Limited Access Token + permissions: + - action: write + resource: DatabaseOne + - action: read + resource: DatabaseTwo + - action: write + resource: DatabaseThree + createdAt: '2023-12-21T17:32:28.000Z' + removeAllPermissions: + summary: Remove All Permissions + value: + accountId: 11111111-1111-4111-8111-111111111111 + clusterId: 33333333-3333-4333-8333-333333333333 + id: 55555555-5555-4555-8555-555555555555 + description: Limited Access Token + permissions: [] + createdAt: '2023-12-21T17:32:28.000Z' + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/InternalServerError' + x-codeSamples: + - label: cURL + lang: Shell + source: | + HOST="https://console.influxdata.com" + + update_token () { + local tokenId=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/tokens/$tokenId" \ + --request PATCH \ + --header "Accept: application/json" \ + --header 'Content-Type: application/json' \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + --data '{ + "description": "Updated Limited Access Token", + "permissions": [ + { + "action": "write", + "resource": "DatabaseOne" + }, + { + "action": "read", + "resource": "DatabaseTwo" + }, + { + "action": "write", + "resource": "DatabaseThree" + } + ] + }' \ + ) + echo "$response" + } + delete: + operationId: DeleteDatabaseToken + summary: Delete a database token + tags: + - Database tokens + parameters: + - name: accountId + in: path + description: The ID of the [account](/influxdb/cloud-dedicated/get-started/setup/#request-an-influxdb-cloud-dedicated-cluster) that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: clusterId + in: path + description: The ID of the cluster that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) belongs to + required: true + schema: + $ref: '#/components/schemas/UuidV4' + - name: tokenId + in: path + description: The ID of the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) to delete + required: true + schema: + $ref: '#/components/schemas/UuidV4' + responses: + '204': + description: The database token was successfully deleted + $ref: '#/components/responses/NoContent' + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/InternalServerError' + x-codeSamples: + - label: cURL + lang: Shell + source: | + HOST="https://console.influxdata.com" + + delete_token () { + local tokenId=$1 + local response=$( \ + curl \ + --location "$HOST/api/v0/accounts/$ACCOUNT_ID/clusters/$CLUSTER_ID/tokens/$tokenId" \ + --request DELETE \ + --header "Accept: application/json" \ + --header "Authorization: Bearer $MANAGEMENT_TOKEN" \ + ) + echo "$response" + } +components: + schemas: + Error: + type: object + properties: + code: + type: integer + message: + type: string + examples: + - code: 400 + message: bad request + - code: 401 + message: unauthorized + - code: 403 + message: forbidden + - code: 404 + message: not found + - code: 409 + message: conflict + - code: 500 + message: internal server error + required: + - code + - message + DateTimeRfc3339: + type: string + format: date-time + examples: + - '2023-12-21T17:32:28Z' + UuidV4: + type: string + format: uuid + examples: + - 11111111-1111-4111-8111-111111111111 + - 22222222-1111-4111-8111-111111111111 + ClusterDatabaseName: + description: The name of the cluster database + type: string + examples: + - DatabaseOne + - DatabaseTwo + maxLength: 64 + minLength: 1 + ClusterDatabaseRetentionPeriod: + description: | + The retention period of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) in nanoseconds, if applicable + + If the retention period is not set or is set to 0, the database will have infinite retention + type: integer + format: int64 + default: 0 + examples: + - 300000000000 + - 600000000000 + minimum: 0 + ClusterDatabaseMaxTables: + description: The maximum number of tables for the cluster database + type: integer + format: int32 + default: 500 + examples: + - 100 + - 300 + minimum: 1 + ClusterDatabaseMaxColumnsPerTable: + description: The maximum number of columns per table for the cluster database + type: integer + format: int32 + default: 200 + examples: + - 50 + - 150 + minimum: 1 + ClusterDatabasePartitionTemplate: + description: | + A template for [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) a cluster database. + + Each template part is evaluated in sequence, concatinating the final + partition key from the output of each part, delimited by the partition + key delimiter `|`. + + For example, using the partition template below: + + ```json + [ + { + "type": "time", + "value": "%Y" + }, + { + "type": "tag", + "value": "bananas" + }, + { + "type": "tag", + "value": "plátanos" + }, + { + "type": "bucket", + "value": { + "tagName": "c", + "numberOfBuckets": 10 + } + } + ] + ``` + + The following partition keys are derived: + + * `time=2023-01-01, a=bananas, b=plátanos, c=ananas` -> `2023|bananas|plátanos|5` + * `time=2023-01-01, b=plátanos` -> `2023|!|plátanos|!` + * `time=2023-01-01, another=cat, b=plátanos` -> `2023|!|plátanos|!` + * `time=2023-01-01` -> `2023|!|!|!` + * `time=2023-01-01, a=cat|dog, b=!, c=!` -> `2023|cat%7Cdog|%21|8` + * `time=2023-01-01, a=%50, c=%50` -> `2023|%2550|!|9` + * `time=2023-01-01, a=, c=` -> `2023|^|!|0` + * `time=2023-01-01, a=` -> `2023|#|!|!` + * `time=2023-01-01, c=` -> `2023|!|!|` + + When using the default [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) template (YYYY-MM-DD) there is no + encoding necessary, as the derived partition key contains a single part, and + no reserved characters. [`TemplatePart::Bucket`] parts by definition will + always be within the part length limit and contain no restricted characters + so are also not percent-encoded and/or truncated. + type: array + items: + $ref: '#/components/schemas/ClusterDatabasePartitionTemplatePart' + examples: + - - type: time + value: '%Y' + - type: tag + value: bananas + - type: tag + value: plátanos + - type: bucket + value: + tagName: c + numberOfBuckets: 10 + maxItems: 8 + minItems: 1 + uniqueItems: true + ClusterDatabasePartitionTemplatePart: + description: A sub-part of a `PartitionTemplate` + anyOf: + - $ref: '#/components/schemas/ClusterDatabasePartitionTemplatePartTagValue' + - $ref: '#/components/schemas/ClusterDatabasePartitionTemplatePartTimeFormat' + - $ref: '#/components/schemas/ClusterDatabasePartitionTemplatePartBucket' + examples: + - type: time + value: '%Y' + - type: tag + value: bananas + - type: tag + value: plátanos + - type: bucket + value: + tagName: c + numberOfBuckets: 10 + ClusterDatabasePartitionTemplatePartTagValue: + description: | + A tag value matcher that extracts a string value from the specified tag name + + If a row does not contain a value for the specified tag name, the NULL/missing partition key part `!` is rendered. + type: object + properties: + type: + type: string + enum: + - tag + value: + type: string + minLength: 1 + examples: + - type: tag + value: bananas + - type: tag + value: plátanos + ClusterDatabasePartitionTemplatePartTimeFormat: + description: A time format matcher that accepts a "strftime"-like format string and evaluates it against the "time" column + type: object + properties: + type: + type: string + enum: + - time + value: + type: string + minLength: 1 + examples: + - type: time + value: '%Y' + ClusterDatabasePartitionTemplatePartBucket: + description: | + A bucketing matcher that sorts data through a uniform hash function on the values of the given tag name. + + If a row does not contain a value for the specified tag name, the NULL/missing partition key part `!` is rendered. + type: object + properties: + type: + type: string + enum: + - bucket + value: + type: object + properties: + tagName: + description: The name of the tag used to derive the bucket the data belongs in + type: string + minLength: 1 + numberOfBuckets: + description: The number of buckets tag values are distributed across + type: integer + format: int32 + maximum: 100000 + minimum: 1 + examples: + - type: bucket + value: + tagName: c + numberOfBuckets: 10 + ClusterDatabaseTableName: + description: The name of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) table + type: string + examples: + - TableOne + - TableTwo + minLength: 1 + DatabaseTokenDescription: + description: The description of the database token + type: string + examples: + - Limited Access Token + - Full Access Token + DatabaseTokenResourceAllDatabases: + description: A resource value for a [database token](/influxdb/cloud-dedicated/admin/tokens/database/) permission that refers to all databases + type: string + enum: + - '*' + DatabaseTokenPermissionAction: + description: The action the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) permission allows + type: string + DatabaseTokenPermissionResource: + description: The resource the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) permission applies to + anyOf: + - $ref: '#/components/schemas/ClusterDatabaseName' + - $ref: '#/components/schemas/DatabaseTokenResourceAllDatabases' + examples: + - DatabaseOne + - DatabaseTwo + - '*' + DatabaseTokenPermission: + description: The description of the database token + type: object + properties: + action: + $ref: '#/components/schemas/DatabaseTokenPermissionAction' + resource: + $ref: '#/components/schemas/DatabaseTokenPermissionResource' + examples: + - action: read + resource: DatabaseOne + - action: write + resource: DatabaseTwo + - action: write + resource: '*' + DatabaseTokenPermissions: + description: The list of permissions the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) allows + type: array + items: + $ref: '#/components/schemas/DatabaseTokenPermission' + examples: + - - action: read + resource: DatabaseOne + - action: write + resource: DatabaseTwo + - - action: write + resource: '*' + DatabaseTokenCreatedAt: + description: | + The date and time that the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) was created + + Uses RFC3339 format + $ref: '#/components/schemas/DateTimeRfc3339' + examples: + - '2023-12-21T17:32:28.000Z' + - '2024-03-02T04:20:19.000Z' + DatabaseTokenAccessToken: + description: | + The access token that can be used to authenticate query and write requests to the cluster + + The access token is never stored by InfluxDB and is only returned once when the token is created. If the access token is lost, a new token must be created. + type: string + examples: + - apiv1_5555555555555555555555555555555555555555555555555555555555555555 + - apiv1_6666666666666666666666666666666666666666666666666666666666666666 + minLength: 64 + responses: + BadRequest: + description: Bad Request + content: + application/json: + schema: + properties: + code: + type: integer + enum: + - 400 + $ref: '#/components/schemas/Error' + example: + code: 400 + message: bad request + Unauthorized: + description: Unauthorized + content: + application/json: + schema: + properties: + code: + type: integer + enum: + - 401 + $ref: '#/components/schemas/Error' + example: + code: 401 + message: unauthorized + Forbidden: + description: Forbidden + content: + application/json: + schema: + properties: + code: + type: integer + enum: + - 403 + $ref: '#/components/schemas/Error' + example: + code: 403 + message: forbidden + NotFound: + description: Not Found + content: + application/json: + schema: + properties: + code: + type: integer + enum: + - 404 + $ref: '#/components/schemas/Error' + example: + code: 404 + message: not found + Conflict: + description: Conflict + content: + application/json: + schema: + properties: + code: + type: integer + enum: + - 409 + $ref: '#/components/schemas/Error' + example: + code: 409 + message: conflict + InternalServerError: + description: Internal Server Error + content: + application/json: + schema: + properties: + code: + type: integer + enum: + - 500 + $ref: '#/components/schemas/Error' + example: + code: 500 + message: internal server error + NoContent: + description: No Content + securitySchemes: + bearerAuthManagementToken: + type: http + scheme: bearer + bearerFormat: Management Token + bearerAuthJwt: + type: http + scheme: bearer + bearerFormat: JWT +x-tagGroups: + - name: Using the Management API + tags: + - Authentication + - Examples + - name: All endpoints + tags: + - Database tokens + - Databases + - Tables diff --git a/types.gen.go b/types.gen.go new file mode 100644 index 0000000..0505991 --- /dev/null +++ b/types.gen.go @@ -0,0 +1,535 @@ +// Package influxdb3 provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/deepmap/oapi-codegen version v1.16.3 DO NOT EDIT. +package influxdb3 + +import ( + "encoding/json" + "time" + + "github.com/oapi-codegen/runtime" + openapi_types "github.com/oapi-codegen/runtime/types" +) + +const ( + BearerAuthJwtScopes = "bearerAuthJwt.Scopes" + BearerAuthManagementTokenScopes = "bearerAuthManagementToken.Scopes" +) + +// Defines values for ClusterDatabasePartitionTemplatePartBucketType. +const ( + Bucket ClusterDatabasePartitionTemplatePartBucketType = "bucket" +) + +// Defines values for ClusterDatabasePartitionTemplatePartTagValueType. +const ( + Tag ClusterDatabasePartitionTemplatePartTagValueType = "tag" +) + +// Defines values for ClusterDatabasePartitionTemplatePartTimeFormatType. +const ( + Time ClusterDatabasePartitionTemplatePartTimeFormatType = "time" +) + +// Defines values for DatabaseTokenResourceAllDatabases. +const ( + Asterisk DatabaseTokenResourceAllDatabases = "*" +) + +// ClusterDatabaseMaxColumnsPerTable The maximum number of columns per table for the cluster database +type ClusterDatabaseMaxColumnsPerTable = int32 + +// ClusterDatabaseMaxTables The maximum number of tables for the cluster database +type ClusterDatabaseMaxTables = int32 + +// ClusterDatabaseName The name of the cluster database +type ClusterDatabaseName = string + +// ClusterDatabasePartitionTemplate A template for [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) a cluster database. +// +// Each template part is evaluated in sequence, concatinating the final +// partition key from the output of each part, delimited by the partition +// key delimiter `|`. +// +// For example, using the partition template below: +// +// ```json +// [ +// +// { +// "type": "time", +// "value": "%Y" +// }, +// { +// "type": "tag", +// "value": "bananas" +// }, +// { +// "type": "tag", +// "value": "plátanos" +// }, +// { +// "type": "bucket", +// "value": { +// "tagName": "c", +// "numberOfBuckets": 10 +// } +// } +// +// ] +// ``` +// +// The following partition keys are derived: +// +// - `time=2023-01-01, a=bananas, b=plátanos, c=ananas` -> `2023|bananas|plátanos|5` +// - `time=2023-01-01, b=plátanos` -> `2023|!|plátanos|!` +// - `time=2023-01-01, another=cat, b=plátanos` -> `2023|!|plátanos|!` +// - `time=2023-01-01` -> `2023|!|!|!` +// - `time=2023-01-01, a=cat|dog, b=!, c=!` -> `2023|cat%7Cdog|%21|8` +// - `time=2023-01-01, a=%50, c=%50` -> `2023|%2550|!|9` +// - `time=2023-01-01, a=, c=` -> `2023|^|!|0` +// - `time=2023-01-01, a=` -> `2023|#|!|!` +// - `time=2023-01-01, c=` -> `2023|!|!|` +// +// When using the default [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) template (YYYY-MM-DD) there is no +// encoding necessary, as the derived partition key contains a single part, and +// no reserved characters. [`TemplatePart::Bucket`] parts by definition will +// always be within the part length limit and contain no restricted characters +// so are also not percent-encoded and/or truncated. +type ClusterDatabasePartitionTemplate = []ClusterDatabasePartitionTemplatePart + +// ClusterDatabasePartitionTemplatePart A sub-part of a `PartitionTemplate` +type ClusterDatabasePartitionTemplatePart struct { + union json.RawMessage +} + +// ClusterDatabasePartitionTemplatePartBucket A bucketing matcher that sorts data through a uniform hash function on the values of the given tag name. +// +// If a row does not contain a value for the specified tag name, the NULL/missing partition key part `!` is rendered. +type ClusterDatabasePartitionTemplatePartBucket struct { + Type *ClusterDatabasePartitionTemplatePartBucketType `json:"type,omitempty"` + Value *struct { + // NumberOfBuckets The number of buckets tag values are distributed across + NumberOfBuckets *int32 `json:"numberOfBuckets,omitempty"` + + // TagName The name of the tag used to derive the bucket the data belongs in + TagName *string `json:"tagName,omitempty"` + } `json:"value,omitempty"` +} + +// ClusterDatabasePartitionTemplatePartBucketType defines model for ClusterDatabasePartitionTemplatePartBucket.Type. +type ClusterDatabasePartitionTemplatePartBucketType string + +// ClusterDatabasePartitionTemplatePartTagValue A tag value matcher that extracts a string value from the specified tag name +// +// If a row does not contain a value for the specified tag name, the NULL/missing partition key part `!` is rendered. +type ClusterDatabasePartitionTemplatePartTagValue struct { + Type *ClusterDatabasePartitionTemplatePartTagValueType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +// ClusterDatabasePartitionTemplatePartTagValueType defines model for ClusterDatabasePartitionTemplatePartTagValue.Type. +type ClusterDatabasePartitionTemplatePartTagValueType string + +// ClusterDatabasePartitionTemplatePartTimeFormat A time format matcher that accepts a "strftime"-like format string and evaluates it against the "time" column +type ClusterDatabasePartitionTemplatePartTimeFormat struct { + Type *ClusterDatabasePartitionTemplatePartTimeFormatType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +// ClusterDatabasePartitionTemplatePartTimeFormatType defines model for ClusterDatabasePartitionTemplatePartTimeFormat.Type. +type ClusterDatabasePartitionTemplatePartTimeFormatType string + +// ClusterDatabaseRetentionPeriod The retention period of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) in nanoseconds, if applicable +// +// If the retention period is not set or is set to 0, the database will have infinite retention +type ClusterDatabaseRetentionPeriod = int64 + +// ClusterDatabaseTableName The name of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) table +type ClusterDatabaseTableName = string + +// DatabaseTokenAccessToken The access token that can be used to authenticate query and write requests to the cluster +// +// The access token is never stored by InfluxDB and is only returned once when the token is created. If the access token is lost, a new token must be created. +type DatabaseTokenAccessToken = string + +// DatabaseTokenCreatedAt defines model for DatabaseTokenCreatedAt. +type DatabaseTokenCreatedAt = DateTimeRfc3339 + +// DatabaseTokenDescription The description of the database token +type DatabaseTokenDescription = string + +// DatabaseTokenPermission The description of the database token +type DatabaseTokenPermission struct { + // Action The action the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) permission allows + Action *DatabaseTokenPermissionAction `json:"action,omitempty"` + + // Resource The resource the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) permission applies to + Resource *DatabaseTokenPermissionResource `json:"resource,omitempty"` +} + +// DatabaseTokenPermissionAction The action the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) permission allows +type DatabaseTokenPermissionAction = string + +// DatabaseTokenPermissionResource The resource the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) permission applies to +type DatabaseTokenPermissionResource struct { + union json.RawMessage +} + +// DatabaseTokenPermissions The list of permissions the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) allows +type DatabaseTokenPermissions = []DatabaseTokenPermission + +// DatabaseTokenResourceAllDatabases A resource value for a [database token](/influxdb/cloud-dedicated/admin/tokens/database/) permission that refers to all databases +type DatabaseTokenResourceAllDatabases string + +// DateTimeRfc3339 defines model for DateTimeRfc3339. +type DateTimeRfc3339 = time.Time + +// Error defines model for Error. +type Error struct { + Code int `json:"code"` + Message string `json:"message"` +} + +// UuidV4 defines model for UuidV4. +type UuidV4 = openapi_types.UUID + +// BadRequest defines model for BadRequest. +type BadRequest = Error + +// Conflict defines model for Conflict. +type Conflict = Error + +// Forbidden defines model for Forbidden. +type Forbidden = Error + +// InternalServerError defines model for InternalServerError. +type InternalServerError = Error + +// NotFound defines model for NotFound. +type NotFound = Error + +// Unauthorized defines model for Unauthorized. +type Unauthorized = Error + +// CreateClusterDatabaseJSONBody defines parameters for CreateClusterDatabase. +type CreateClusterDatabaseJSONBody struct { + // MaxColumnsPerTable The maximum number of columns per table for the cluster database + MaxColumnsPerTable *ClusterDatabaseMaxColumnsPerTable `json:"maxColumnsPerTable,omitempty"` + + // MaxTables The maximum number of tables for the cluster database + MaxTables *ClusterDatabaseMaxTables `json:"maxTables,omitempty"` + + // Name The name of the cluster database + Name ClusterDatabaseName `json:"name"` + + // PartitionTemplate A template for [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) a cluster database. + // + // Each template part is evaluated in sequence, concatinating the final + // partition key from the output of each part, delimited by the partition + // key delimiter `|`. + // + // For example, using the partition template below: + // + // ```json + // [ + // { + // "type": "time", + // "value": "%Y" + // }, + // { + // "type": "tag", + // "value": "bananas" + // }, + // { + // "type": "tag", + // "value": "plátanos" + // }, + // { + // "type": "bucket", + // "value": { + // "tagName": "c", + // "numberOfBuckets": 10 + // } + // } + // ] + // ``` + // + // The following partition keys are derived: + // + // * `time=2023-01-01, a=bananas, b=plátanos, c=ananas` -> `2023|bananas|plátanos|5` + // * `time=2023-01-01, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01, another=cat, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01` -> `2023|!|!|!` + // * `time=2023-01-01, a=cat|dog, b=!, c=!` -> `2023|cat%7Cdog|%21|8` + // * `time=2023-01-01, a=%50, c=%50` -> `2023|%2550|!|9` + // * `time=2023-01-01, a=, c=` -> `2023|^|!|0` + // * `time=2023-01-01, a=` -> `2023|#|!|!` + // * `time=2023-01-01, c=` -> `2023|!|!|` + // + // When using the default [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) template (YYYY-MM-DD) there is no + // encoding necessary, as the derived partition key contains a single part, and + // no reserved characters. [`TemplatePart::Bucket`] parts by definition will + // always be within the part length limit and contain no restricted characters + // so are also not percent-encoded and/or truncated. + PartitionTemplate *ClusterDatabasePartitionTemplate `json:"partitionTemplate,omitempty"` + + // RetentionPeriod The retention period of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) in nanoseconds, if applicable + // + // If the retention period is not set or is set to 0, the database will have infinite retention + RetentionPeriod *ClusterDatabaseRetentionPeriod `json:"retentionPeriod,omitempty"` +} + +// UpdateClusterDatabaseJSONBody defines parameters for UpdateClusterDatabase. +type UpdateClusterDatabaseJSONBody struct { + // MaxColumnsPerTable The maximum number of columns per table for the cluster database + MaxColumnsPerTable *ClusterDatabaseMaxColumnsPerTable `json:"maxColumnsPerTable,omitempty"` + + // MaxTables The maximum number of tables for the cluster database + MaxTables *ClusterDatabaseMaxTables `json:"maxTables,omitempty"` + + // RetentionPeriod The retention period of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) in nanoseconds, if applicable + // + // If the retention period is not set or is set to 0, the database will have infinite retention + RetentionPeriod *ClusterDatabaseRetentionPeriod `json:"retentionPeriod,omitempty"` +} + +// CreateClusterDatabaseTableJSONBody defines parameters for CreateClusterDatabaseTable. +type CreateClusterDatabaseTableJSONBody struct { + // Name The name of the [cluster database](/influxdb/cloud-dedicated/admin/databases/) table + Name ClusterDatabaseTableName `json:"name"` + + // PartitionTemplate A template for [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) a cluster database. + // + // Each template part is evaluated in sequence, concatinating the final + // partition key from the output of each part, delimited by the partition + // key delimiter `|`. + // + // For example, using the partition template below: + // + // ```json + // [ + // { + // "type": "time", + // "value": "%Y" + // }, + // { + // "type": "tag", + // "value": "bananas" + // }, + // { + // "type": "tag", + // "value": "plátanos" + // }, + // { + // "type": "bucket", + // "value": { + // "tagName": "c", + // "numberOfBuckets": 10 + // } + // } + // ] + // ``` + // + // The following partition keys are derived: + // + // * `time=2023-01-01, a=bananas, b=plátanos, c=ananas` -> `2023|bananas|plátanos|5` + // * `time=2023-01-01, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01, another=cat, b=plátanos` -> `2023|!|plátanos|!` + // * `time=2023-01-01` -> `2023|!|!|!` + // * `time=2023-01-01, a=cat|dog, b=!, c=!` -> `2023|cat%7Cdog|%21|8` + // * `time=2023-01-01, a=%50, c=%50` -> `2023|%2550|!|9` + // * `time=2023-01-01, a=, c=` -> `2023|^|!|0` + // * `time=2023-01-01, a=` -> `2023|#|!|!` + // * `time=2023-01-01, c=` -> `2023|!|!|` + // + // When using the default [partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/) template (YYYY-MM-DD) there is no + // encoding necessary, as the derived partition key contains a single part, and + // no reserved characters. [`TemplatePart::Bucket`] parts by definition will + // always be within the part length limit and contain no restricted characters + // so are also not percent-encoded and/or truncated. + PartitionTemplate *ClusterDatabasePartitionTemplate `json:"partitionTemplate,omitempty"` +} + +// CreateDatabaseTokenJSONBody defines parameters for CreateDatabaseToken. +type CreateDatabaseTokenJSONBody struct { + // Description The description of the database token + Description DatabaseTokenDescription `json:"description"` + + // Permissions The list of permissions the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) allows + Permissions *DatabaseTokenPermissions `json:"permissions,omitempty"` +} + +// UpdateDatabaseTokenJSONBody defines parameters for UpdateDatabaseToken. +type UpdateDatabaseTokenJSONBody struct { + // Description The description of the database token + Description *DatabaseTokenDescription `json:"description,omitempty"` + + // Permissions The list of permissions the [database token](/influxdb/cloud-dedicated/admin/tokens/database/) allows + Permissions *DatabaseTokenPermissions `json:"permissions,omitempty"` +} + +// CreateClusterDatabaseJSONRequestBody defines body for CreateClusterDatabase for application/json ContentType. +type CreateClusterDatabaseJSONRequestBody CreateClusterDatabaseJSONBody + +// UpdateClusterDatabaseJSONRequestBody defines body for UpdateClusterDatabase for application/json ContentType. +type UpdateClusterDatabaseJSONRequestBody UpdateClusterDatabaseJSONBody + +// CreateClusterDatabaseTableJSONRequestBody defines body for CreateClusterDatabaseTable for application/json ContentType. +type CreateClusterDatabaseTableJSONRequestBody CreateClusterDatabaseTableJSONBody + +// CreateDatabaseTokenJSONRequestBody defines body for CreateDatabaseToken for application/json ContentType. +type CreateDatabaseTokenJSONRequestBody CreateDatabaseTokenJSONBody + +// UpdateDatabaseTokenJSONRequestBody defines body for UpdateDatabaseToken for application/json ContentType. +type UpdateDatabaseTokenJSONRequestBody UpdateDatabaseTokenJSONBody + +// AsClusterDatabasePartitionTemplatePartTagValue returns the union data inside the ClusterDatabasePartitionTemplatePart as a ClusterDatabasePartitionTemplatePartTagValue +func (t ClusterDatabasePartitionTemplatePart) AsClusterDatabasePartitionTemplatePartTagValue() (ClusterDatabasePartitionTemplatePartTagValue, error) { + var body ClusterDatabasePartitionTemplatePartTagValue + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromClusterDatabasePartitionTemplatePartTagValue overwrites any union data inside the ClusterDatabasePartitionTemplatePart as the provided ClusterDatabasePartitionTemplatePartTagValue +func (t *ClusterDatabasePartitionTemplatePart) FromClusterDatabasePartitionTemplatePartTagValue(v ClusterDatabasePartitionTemplatePartTagValue) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeClusterDatabasePartitionTemplatePartTagValue performs a merge with any union data inside the ClusterDatabasePartitionTemplatePart, using the provided ClusterDatabasePartitionTemplatePartTagValue +func (t *ClusterDatabasePartitionTemplatePart) MergeClusterDatabasePartitionTemplatePartTagValue(v ClusterDatabasePartitionTemplatePartTagValue) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(t.union, b) + t.union = merged + return err +} + +// AsClusterDatabasePartitionTemplatePartTimeFormat returns the union data inside the ClusterDatabasePartitionTemplatePart as a ClusterDatabasePartitionTemplatePartTimeFormat +func (t ClusterDatabasePartitionTemplatePart) AsClusterDatabasePartitionTemplatePartTimeFormat() (ClusterDatabasePartitionTemplatePartTimeFormat, error) { + var body ClusterDatabasePartitionTemplatePartTimeFormat + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromClusterDatabasePartitionTemplatePartTimeFormat overwrites any union data inside the ClusterDatabasePartitionTemplatePart as the provided ClusterDatabasePartitionTemplatePartTimeFormat +func (t *ClusterDatabasePartitionTemplatePart) FromClusterDatabasePartitionTemplatePartTimeFormat(v ClusterDatabasePartitionTemplatePartTimeFormat) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeClusterDatabasePartitionTemplatePartTimeFormat performs a merge with any union data inside the ClusterDatabasePartitionTemplatePart, using the provided ClusterDatabasePartitionTemplatePartTimeFormat +func (t *ClusterDatabasePartitionTemplatePart) MergeClusterDatabasePartitionTemplatePartTimeFormat(v ClusterDatabasePartitionTemplatePartTimeFormat) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(t.union, b) + t.union = merged + return err +} + +// AsClusterDatabasePartitionTemplatePartBucket returns the union data inside the ClusterDatabasePartitionTemplatePart as a ClusterDatabasePartitionTemplatePartBucket +func (t ClusterDatabasePartitionTemplatePart) AsClusterDatabasePartitionTemplatePartBucket() (ClusterDatabasePartitionTemplatePartBucket, error) { + var body ClusterDatabasePartitionTemplatePartBucket + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromClusterDatabasePartitionTemplatePartBucket overwrites any union data inside the ClusterDatabasePartitionTemplatePart as the provided ClusterDatabasePartitionTemplatePartBucket +func (t *ClusterDatabasePartitionTemplatePart) FromClusterDatabasePartitionTemplatePartBucket(v ClusterDatabasePartitionTemplatePartBucket) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeClusterDatabasePartitionTemplatePartBucket performs a merge with any union data inside the ClusterDatabasePartitionTemplatePart, using the provided ClusterDatabasePartitionTemplatePartBucket +func (t *ClusterDatabasePartitionTemplatePart) MergeClusterDatabasePartitionTemplatePartBucket(v ClusterDatabasePartitionTemplatePartBucket) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(t.union, b) + t.union = merged + return err +} + +func (t ClusterDatabasePartitionTemplatePart) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *ClusterDatabasePartitionTemplatePart) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsClusterDatabaseName returns the union data inside the DatabaseTokenPermissionResource as a ClusterDatabaseName +func (t DatabaseTokenPermissionResource) AsClusterDatabaseName() (ClusterDatabaseName, error) { + var body ClusterDatabaseName + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromClusterDatabaseName overwrites any union data inside the DatabaseTokenPermissionResource as the provided ClusterDatabaseName +func (t *DatabaseTokenPermissionResource) FromClusterDatabaseName(v ClusterDatabaseName) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeClusterDatabaseName performs a merge with any union data inside the DatabaseTokenPermissionResource, using the provided ClusterDatabaseName +func (t *DatabaseTokenPermissionResource) MergeClusterDatabaseName(v ClusterDatabaseName) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(t.union, b) + t.union = merged + return err +} + +// AsDatabaseTokenResourceAllDatabases returns the union data inside the DatabaseTokenPermissionResource as a DatabaseTokenResourceAllDatabases +func (t DatabaseTokenPermissionResource) AsDatabaseTokenResourceAllDatabases() (DatabaseTokenResourceAllDatabases, error) { + var body DatabaseTokenResourceAllDatabases + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromDatabaseTokenResourceAllDatabases overwrites any union data inside the DatabaseTokenPermissionResource as the provided DatabaseTokenResourceAllDatabases +func (t *DatabaseTokenPermissionResource) FromDatabaseTokenResourceAllDatabases(v DatabaseTokenResourceAllDatabases) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeDatabaseTokenResourceAllDatabases performs a merge with any union data inside the DatabaseTokenPermissionResource, using the provided DatabaseTokenResourceAllDatabases +func (t *DatabaseTokenPermissionResource) MergeDatabaseTokenResourceAllDatabases(v DatabaseTokenResourceAllDatabases) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(t.union, b) + t.union = merged + return err +} + +func (t DatabaseTokenPermissionResource) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *DatabaseTokenPermissionResource) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +}