diff --git a/.golangci.yaml b/.golangci.yaml index 0c840a3..f93a600 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -11,7 +11,6 @@ linters: - errorlint - forbidigo - forcetypeassert - - funlen - gocognit - goconst - gocyclo @@ -23,13 +22,11 @@ linters: - govet - importas - ineffassign - - lll - makezero - misspell - nakedret - nestif - nilerr - - nlreturn - prealloc - revive - staticcheck @@ -37,7 +34,6 @@ linters: - unconvert - unused - whitespace - - wsl linters-settings: gocognit: diff --git a/Taskfile.yml b/Taskfile.yml index 5feea90..77889ec 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -15,11 +15,11 @@ tasks: cmds: - rm -rf {{.GEN_OUT_DIR}} - GEN_OUT_DIR={{.GEN_OUT_DIR}} go run -tags=generator ./generator/... + - task: fmt-imports generate: cmds: - task: get-openapi-spec - task: go-generate - - task: fmt-imports test: cmds: - go test -v ./... diff --git a/client.go b/client.go index c615016..f69c929 100644 --- a/client.go +++ b/client.go @@ -77,11 +77,9 @@ type aivenClient struct { // OperationIDKey is the key used to store the operation ID in the context. type OperationIDKey struct{} -func (d *aivenClient) Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) { +func (d *aivenClient) Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) { ctx = context.WithValue(ctx, OperationIDKey{}, operationID) - var rsp *http.Response - var err error if d.Debug { @@ -105,7 +103,7 @@ func (d *aivenClient) Do(ctx context.Context, operationID, method, path string, }() } - rsp, err = d.do(ctx, method, path, v) + rsp, err = d.do(ctx, method, path, in, query...) if err != nil { return nil, err } @@ -122,11 +120,11 @@ func (d *aivenClient) Do(ctx context.Context, operationID, method, path string, return b, err } -func (d *aivenClient) do(ctx context.Context, method, path string, v any) (*http.Response, error) { +func (d *aivenClient) do(ctx context.Context, method, path string, in any, query ...[2]string) (*http.Response, error) { var body io.Reader - if !(v == nil || isEmpty(v)) { - b, err := json.Marshal(v) + if !(in == nil || isEmpty(in)) { + b, err := json.Marshal(in) if err != nil { return nil, err } @@ -143,13 +141,19 @@ func (d *aivenClient) do(ctx context.Context, method, path string, v any) (*http req.Header.Set("User-Agent", d.UserAgent) req.Header.Set("Authorization", "aivenv1 "+d.Token) - // TODO: BAD hack to get around pagination in most cases - // we should implement this properly at some point but for now - // that should be its own issue - query := req.URL.Query() - query.Add("limit", "999") - req.URL.RawQuery = query.Encode() + q := req.URL.Query() + for _, v := range query { + q.Set(v[0], v[1]) + } + + if !q.Has("limit") { + // TODO: BAD hack to get around pagination in most cases + // we should implement this properly at some point but for now + // that should be its own issue + q.Set("limit", "999") + } + req.URL.RawQuery = q.Encode() return d.doer.Do(req) } diff --git a/client_generated.go b/client_generated.go index 7a3d7bc..4414299 100644 --- a/client_generated.go +++ b/client_generated.go @@ -43,7 +43,7 @@ import ( ) type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } func newClient(doer doer) Client { diff --git a/client_test.go b/client_test.go index 9b6792f..68c02f3 100644 --- a/client_test.go +++ b/client_test.go @@ -8,11 +8,13 @@ import ( "net/http/httptest" "os" "strings" + "sync/atomic" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/aiven/go-client-codegen/handler/clickhouse" "github.com/aiven/go-client-codegen/handler/service" ) @@ -41,24 +43,44 @@ func TestNewClient(t *testing.T) { } func TestServiceCreate(t *testing.T) { + var callCount int64 + // Creates a test server - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - require.Equal(t, "/v1/project/foo/service", r.URL.Path) - - // Validates request - expectIn := new(service.ServiceCreateIn) - err := json.NewDecoder(r.Body).Decode(expectIn) - assert.NoError(t, err) - assert.Equal(t, "foo", expectIn.ServiceName) - assert.Equal(t, "kafka", expectIn.ServiceType) - assert.Regexp(t, `go-client-codegen/[0-9\.]+ unit-test`, r.Header["User-Agent"]) - - // Creates response - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - _, err = w.Write([]byte(`{"service": {"plan": "wow", "state": "RUNNING"}}`)) - require.NoError(t, err) - })) + mux := http.NewServeMux() + mux.HandleFunc( + "/v1/project/aiven-project/service", + func(w http.ResponseWriter, r *http.Request) { + // Validates request + expectIn := new(service.ServiceCreateIn) + err := json.NewDecoder(r.Body).Decode(expectIn) + assert.NoError(t, err) + assert.Equal(t, "my-clickhouse", expectIn.ServiceName) + assert.Equal(t, "clickhouse", expectIn.ServiceType) + assert.Regexp(t, `go-client-codegen/[0-9\.]+ unit-test`, r.Header["User-Agent"]) + + // Creates response + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + _, err = w.Write([]byte(`{"service": {"plan": "wow", "state": "RUNNING"}}`)) + require.NoError(t, err) + atomic.AddInt64(&callCount, 1) + }, + ) + mux.HandleFunc( + "/v1/project/aiven-project/service/my-clickhouse/clickhouse/query/stats", + func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, r.URL.RawQuery, "limit=1&order_by=max_time%3Aasc") + + // Creates response + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + _, err := w.Write([]byte(`{"queries": [{"calls": 1}]}`)) + require.NoError(t, err) + atomic.AddInt64(&callCount, 1) + }, + ) + + server := httptest.NewServer(mux) defer server.Close() // Points a new client to the server url @@ -68,12 +90,27 @@ func TestServiceCreate(t *testing.T) { // Makes create request in := &service.ServiceCreateIn{ - ServiceName: "foo", - ServiceType: "kafka", + ServiceName: "my-clickhouse", + ServiceType: "clickhouse", } - out, err := c.ServiceCreate(context.Background(), "foo", in) + + ctx := context.Background() + project := "aiven-project" + out, err := c.ServiceCreate(ctx, project, in) require.NoError(t, err) require.NotNil(t, out) assert.Equal(t, "wow", out.Plan) assert.Equal(t, service.ServiceStateTypeRunning, out.State) + + // Validates query params + stats, err := c.ServiceClickHouseQueryStats( + ctx, project, in.ServiceName, + clickhouse.ServiceClickHouseQueryStatsLimit(1), + clickhouse.ServiceClickHouseQueryStatsOrderByType(clickhouse.OrderByTypeMaxTimeasc), + ) + require.NoError(t, err) + assert.Len(t, stats, 1) + + // All calls are received + assert.EqualValues(t, 2, callCount) } diff --git a/generator/main.go b/generator/main.go index 43e74e4..0b120dd 100644 --- a/generator/main.go +++ b/generator/main.go @@ -43,15 +43,30 @@ var ( pathVersioning = regexp.MustCompile(`^/v[0-9]/`) ) +var strFormatters = map[SchemaType]string{ + SchemaTypeInteger: "%d", + SchemaTypeNumber: "%f", + SchemaTypeString: "%s", + SchemaTypeBoolean: "%t", +} + func main() { log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}) err := exec() if err != nil { - log.Err(err) + log.Err(err).Send() } } +const ( + doerName = "doer" + handlerSuffix = "Handler" + queryParamName = "query" + queryParamTypeName = "queryParam" + queryParamArraySize = 2 +) + // nolint:funlen,gocognit,gocyclo // It's a generator, it's supposed to be long, and we won't expand it. func exec() error { cfg := new(envConfig) @@ -105,7 +120,6 @@ func exec() error { if pkg == "" { log.Error().Msgf("%q id not found in config!", p.ID) - continue } @@ -121,12 +135,6 @@ func exec() error { return fmt.Errorf("param %q not found", ref.Ref) } - if param.In != ParameterInPath { - log.Printf("%q param %s in %q", p.OperationID, param.Name, param.In) - - continue - } - if param.Name == "version_id" { param.Schema.Type = SchemaTypeInteger } @@ -139,14 +147,13 @@ func exec() error { } } - const doerName = "doer" - ctx := jen.Id("ctx").Qual("context", "Context") doer := jen.Type().Id(doerName).Interface( jen.Id("Do").Params( ctx, jen.List(jen.Id("operationID"), jen.Id("method"), jen.Id("path")).String(), - jen.Id("v").Any(), + jen.Id("in").Any(), + jen.Id(queryParamName).Op("...").Add(fmtQueryParamType()), ).Parens(jen.List(jen.Index().Byte(), jen.Error())), ).Line() clientFields := make([]jen.Code, 0, len(pkgs)) @@ -154,12 +161,10 @@ func exec() error { clientTypeValues := make([]jen.Code, 0, len(pkgs)) for _, pkg := range sortedKeys(pkgs) { - const handlerType = "Handler" - paths := pkgs[pkg] fileName := strings.ToLower(pkg) - handlerName := pkg + handlerType - newHandler := "New" + handlerType + handlerName := pkg + handlerSuffix + newHandler := "New" + handlerSuffix scope := make(map[string]*Schema) for _, p := range paths { @@ -172,11 +177,12 @@ func exec() error { file := jen.NewFile(fileName) file.HeaderComment(generatedHeader) - handler := file.Type().Id(handlerType) + handler := file.Type().Id(handlerSuffix) file.Func().Id(newHandler).Params(jen.Id(doerName).Id(doerName)).Id(handlerName).Block( jen.Return(jen.Id(handlerName).Values(jen.Id(doerName))), ) file.Add(doer) + file.Type().Id(queryParamTypeName).Index(jen.Lit(queryParamArraySize)).String() file.Type().Id(handlerName).Struct(jen.Id(doerName).Id(doerName)) var typeMethods []jen.Code @@ -186,21 +192,38 @@ func exec() error { out := path.Out.OK.Content["application/json"] if out == nil && path.Out.NoContent.Content == nil { log.Printf("%q has no json response. Skipping", path.OperationID) - continue } + // Method's schemas and query params schemas := make([]*Schema, 0) - params := make([]jen.Code, 0, len(path.Parameters)) - params = append(params, ctx) + queryParams := make([]*Schema, 0) + + // Interface and implementation args + funcArgs := []jen.Code{ctx} + // Collects params: in path and in query + // Adds to schemas to render enums for _, p := range path.Parameters { - p.Schema.in = true p.Schema.required = true p.Schema.init(doc, scope, p.Name) - schemas = append(schemas, p.Schema) - param := jen.Id(strcase.ToLowerCamel(p.Schema.CamelName)).Add(getType(p.Schema)) - params = append(params, param) + + if p.inPath() { + schemas = append(schemas, p.Schema) + param := jen.Id(p.Schema.lowerCamel()).Add(getType(p.Schema)) + funcArgs = append(funcArgs, param) + continue + } + + queryParams = append(queryParams, p.Schema) + + // Adds param function (request modifier) + var code *jen.Statement + code, err = fmtQueryParam(path.FuncName, p) + if err != nil { + return err + } + file.Add(code) } in := path.In.Content["application/json"] @@ -213,14 +236,18 @@ func exec() error { } schemaIn.in = true - schemaIn.init(doc, scope, path.FuncName) schemas = append(schemas, schemaIn) - params = append(params, jen.Id("in").Id("*"+schemaIn.CamelName)) + funcArgs = append(funcArgs, jen.Id("in").Id("*"+schemaIn.CamelName)) } - typeMeth := jen.Id(path.FuncName).Params(params...) - structMeth := jen.Func().Params(jen.Id("h").Id("*" + handlerName)).Id(path.FuncName).Params(params...) + // Adds queryParams options + if len(queryParams) > 0 { + funcArgs = append(funcArgs, jen.Id(queryParamName).Op("...").Id(queryParamTypeName)) + } + + typeMeth := jen.Id(path.FuncName).Params(funcArgs...) + structMeth := jen.Func().Params(jen.Id("h").Id("*" + handlerName)).Id(path.FuncName).Params(funcArgs...) var rsp, schemaOut *Schema if out != nil { @@ -230,7 +257,6 @@ func exec() error { } schemaOut.out = true - schemaOut.init(doc, scope, path.FuncName) rsp = getResponse(schemaOut) } @@ -254,33 +280,36 @@ func exec() error { typeMethods = append(typeMethods, path.Comment(), typeMeth.Line()) + // Crates a go formattable path, i.e.: + // /foo/{foo}/ => /foo/%s/ paramIndex := -1 url := pathClean.ReplaceAllStringFunc(path.Path, func(_ string) string { paramIndex++ - - switch t := path.Parameters[paramIndex].Schema.Type; t { - case SchemaTypeInteger: - return "%d" - case SchemaTypeString: - return "%s" - default: + t, ok := strFormatters[path.Parameters[paramIndex].Schema.Type] + if !ok { panic(fmt.Sprintf("%s unexpected parameter type %s", path.OperationID, t)) } + return t }) - urlParams := make([]jen.Code, 0, len(params)) + + urlParams := make([]jen.Code, 0, len(funcArgs)) urlParams = append(urlParams, jen.Lit(url)) inObj := jen.Nil() - for _, s := range schemas { if s.isObject() { inObj = jen.Id("in") - continue } - v := jen.Id(strcase.ToLowerCamel(s.CamelName)) + v := jen.Id(s.lowerCamel()) + if s.isEnum() { + // Stringifies enums + v = jen.String().Call(v) + } + + // Escapes string values if s.Type == SchemaTypeString { - v = jen.Id("url.PathEscape").Call(v) + v = jen.Qual("net/url", "PathEscape").Call(v) } urlParams = append(urlParams, v) @@ -289,6 +318,7 @@ func exec() error { outObj := jen.Id("_") returnErr := jen.Return(jen.Err()) + // Formats "return" statement if rsp != nil { outObj = jen.Id("b") @@ -308,24 +338,48 @@ func exec() error { } } - block := []jen.Code{ - jen.Id("path").Op(":=").Qual("fmt", "Sprintf").Call(urlParams...), - jen.List(outObj, jen.Err()).Op(":=").Id("h.doer.Do").Call( - jen.Id("ctx"), - jen.Lit(path.OperationID), - jen.Lit(path.Method), - jen.Id("path"), - inObj, - ), + // The Doer call + callOpts := []jen.Code{ + jen.Id("ctx"), + jen.Lit(path.OperationID), + jen.Lit(path.Method), + jen.Id("path"), + inObj, } - ifErr := jen.If(jen.Err().Op("!=").Nil()).Block(returnErr) + var block []jen.Code + + // Adds unpacking for query params + if len(queryParams) > 1 { + q := jen.Id(queryParamName) + p := jen.Id("p") + v := jen.Id("v") + callOpts = append(callOpts, p.Clone().Op("...")) + block = append( + block, + p.Clone().Op(":=").Make(jen.Index().Index(jen.Lit(queryParamArraySize)).String(), jen.Lit(0), jen.Len(q)), + jen.For(jen.List(jen.Id("_"), v.Clone().Op(":=").Range().Add(jen.Id(queryParamName)))). + Block(p.Clone().Op("=").Append(p, v)), + ) + } + + //params := make([][2]string, 0, len(query)) + //for _, v := range query { + // params = append(params, v) + //} + + // Implementation (method's) body + block = append( + block, + jen.Id("path").Op(":=").Qual("fmt", "Sprintf").Call(urlParams...), + jen.List(outObj, jen.Err()).Op(":=").Id("h.doer.Do").Call(callOpts...), + ) + ifErr := jen.If(jen.Err().Op("!=").Nil()).Block(returnErr) if rsp == nil { block = append(block, jen.Return(jen.Err())) } else { block = append(block, ifErr) - outReturn := jen.Id("out") if rsp.CamelName != schemaOut.CamelName { @@ -377,7 +431,7 @@ func exec() error { pkgName := filepath.Join(cfg.Module, cfg.HandlerDir, fileName) clientFields = append(clientFields, jen.Qual(pkgName, handlerName)) clientValues[jen.Id(handlerName)] = jen.Qual(pkgName, newHandler).Call(jen.Id(doerName)) - clientTypeValues = append(clientTypeValues, jen.Qual(pkgName, handlerType)) + clientTypeValues = append(clientTypeValues, jen.Qual(pkgName, handlerSuffix)) } client := jen.NewFile(cfg.Package) @@ -543,3 +597,30 @@ var reComment = regexp.MustCompile(`\.?[\r\n]+\s*?`) func fmtComment(c string) string { return reComment.ReplaceAllString(c, ". ") } + +// fmtQueryParam returns a query param +func fmtQueryParam(funcName string, p *Parameter) (*jen.Statement, error) { + keyFuncName := funcName + p.Schema.CamelName + keyVarName := jen.Id(p.Schema.lowerCamel()) + + var value *jen.Statement + format, ok := strFormatters[p.Schema.Type] + if !ok { + return nil, fmt.Errorf("query param with type %q is not supported", p.Schema.Type) + } + value = jen.Qual("fmt", "Sprintf").Call(jen.Lit(format), keyVarName.Clone()) + + param := jen.Comment(fmt.Sprintf("%s %s", keyFuncName, fmtComment(p.Description))) + param.Line() + param.Func().Id(keyFuncName). + Params(keyVarName.Clone().Add(getType(p.Schema))).Params(jen.Id(queryParamTypeName)). + Block( + jen.Return(jen.Id(queryParamTypeName).Values(jen.Lit(p.Schema.name), value)), + ) + return param, nil +} + +// fmtQueryParamType literally returns: [2]string +func fmtQueryParamType() *jen.Statement { + return jen.Index(jen.Lit(queryParamArraySize)).String() +} diff --git a/generator/models.go b/generator/models.go index 50ab71d..1f16546 100644 --- a/generator/models.go +++ b/generator/models.go @@ -105,12 +105,15 @@ const ( type Parameter struct { Ref string `json:"$ref"` In ParameterIn `json:"in"` - Required bool `json:"required"` Name string `json:"name"` Description string `json:"description"` Schema *Schema `json:"schema"` } +func (p *Parameter) inPath() bool { + return p.In == ParameterInPath +} + // SchemaType represents a schema type. type SchemaType string @@ -346,6 +349,10 @@ func (s *Schema) isOut() bool { return s.root().out } +func (s *Schema) lowerCamel() string { + return strcase.ToLowerCamel(s.CamelName) +} + func getScalarType(s *Schema) *jen.Statement { switch s.Type { case SchemaTypeString: diff --git a/handler/account/account.go b/handler/account/account.go index 6e9a361..ad5253e 100644 --- a/handler/account/account.go +++ b/handler/account/account.go @@ -97,9 +97,10 @@ func NewHandler(doer doer) AccountHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type AccountHandler struct { doer doer } @@ -338,6 +339,7 @@ type AccountBillingGroupOut struct { BillingExtraText string `json:"billing_extra_text"` // Extra text to be included in all project invoices, e.g. purchase order or cost center number BillingGroupId string `json:"billing_group_id"` // Billing group ID BillingGroupName string `json:"billing_group_name"` // Billing group name + BillingType string `json:"billing_type"` // Method of charging/invoicing this project CardInfo CardInfoOut `json:"card_info"` // Credit card assigned to the project City string `json:"city"` // Address city Company string `json:"company"` // Name of a company diff --git a/handler/accountauthentication/accountauthentication.go b/handler/accountauthentication/accountauthentication.go index 1833bf7..887321a 100644 --- a/handler/accountauthentication/accountauthentication.go +++ b/handler/accountauthentication/accountauthentication.go @@ -42,9 +42,10 @@ func NewHandler(doer doer) AccountAuthenticationHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type AccountAuthenticationHandler struct { doer doer } diff --git a/handler/accountteam/accountteam.go b/handler/accountteam/accountteam.go index c68e828..273409f 100644 --- a/handler/accountteam/accountteam.go +++ b/handler/accountteam/accountteam.go @@ -67,9 +67,10 @@ func NewHandler(doer doer) AccountTeamHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type AccountTeamHandler struct { doer doer } diff --git a/handler/accountteammember/accountteammember.go b/handler/accountteammember/accountteammember.go index 4ea5cd9..3df7447 100644 --- a/handler/accountteammember/accountteammember.go +++ b/handler/accountteammember/accountteammember.go @@ -42,9 +42,10 @@ func NewHandler(doer doer) AccountTeamMemberHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type AccountTeamMemberHandler struct { doer doer } diff --git a/handler/applicationuser/applicationuser.go b/handler/applicationuser/applicationuser.go index 74b8774..35a417c 100644 --- a/handler/applicationuser/applicationuser.go +++ b/handler/applicationuser/applicationuser.go @@ -57,9 +57,10 @@ func NewHandler(doer doer) ApplicationUserHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type ApplicationUserHandler struct { doer doer } diff --git a/handler/billinggroup/billinggroup.go b/handler/billinggroup/billinggroup.go index e31cf50..52dbad4 100644 --- a/handler/billinggroup/billinggroup.go +++ b/handler/billinggroup/billinggroup.go @@ -82,9 +82,10 @@ func NewHandler(doer doer) BillingGroupHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type BillingGroupHandler struct { doer doer } @@ -292,6 +293,7 @@ type BillingGroupCreateOut struct { BillingExtraText string `json:"billing_extra_text"` // Extra text to be included in all project invoices, e.g. purchase order or cost center number BillingGroupId string `json:"billing_group_id"` // Billing group ID BillingGroupName string `json:"billing_group_name"` // Billing group name + BillingType string `json:"billing_type"` // Method of charging/invoicing this project CardInfo CardInfoOut `json:"card_info"` // Credit card assigned to the project City string `json:"city"` // Address city Company string `json:"company"` // Name of a company @@ -332,6 +334,7 @@ type BillingGroupGetOut struct { BillingExtraText string `json:"billing_extra_text"` // Extra text to be included in all project invoices, e.g. purchase order or cost center number BillingGroupId string `json:"billing_group_id"` // Billing group ID BillingGroupName string `json:"billing_group_name"` // Billing group name + BillingType string `json:"billing_type"` // Method of charging/invoicing this project CardInfo CardInfoOut `json:"card_info"` // Credit card assigned to the project City string `json:"city"` // Address city Company string `json:"company"` // Name of a company @@ -355,6 +358,7 @@ type BillingGroupOut struct { BillingExtraText string `json:"billing_extra_text"` // Extra text to be included in all project invoices, e.g. purchase order or cost center number BillingGroupId string `json:"billing_group_id"` // Billing group ID BillingGroupName string `json:"billing_group_name"` // Billing group name + BillingType string `json:"billing_type"` // Method of charging/invoicing this project CardInfo CardInfoOut `json:"card_info"` // Credit card assigned to the project City string `json:"city"` // Address city Company string `json:"company"` // Name of a company @@ -412,6 +416,7 @@ type BillingGroupUpdateOut struct { BillingExtraText string `json:"billing_extra_text"` // Extra text to be included in all project invoices, e.g. purchase order or cost center number BillingGroupId string `json:"billing_group_id"` // Billing group ID BillingGroupName string `json:"billing_group_name"` // Billing group name + BillingType string `json:"billing_type"` // Method of charging/invoicing this project CardInfo CardInfoOut `json:"card_info"` // Credit card assigned to the project City string `json:"city"` // Address city Company string `json:"company"` // Name of a company diff --git a/handler/clickhouse/clickhouse.go b/handler/clickhouse/clickhouse.go index f1435de..3e54030 100644 --- a/handler/clickhouse/clickhouse.go +++ b/handler/clickhouse/clickhouse.go @@ -38,7 +38,7 @@ type Handler interface { // ServiceClickHouseQueryStats return statistics on recent queries // GET /v1/project/{project}/service/{service_name}/clickhouse/query/stats // https://api.aiven.io/doc/#tag/Service:_ClickHouse/operation/ServiceClickHouseQueryStats - ServiceClickHouseQueryStats(ctx context.Context, project string, serviceName string) ([]QueryOutAlt, error) + ServiceClickHouseQueryStats(ctx context.Context, project string, serviceName string, query ...queryParam) ([]QueryOutAlt, error) // ServiceClickHouseTieredStorageSummary get the ClickHouse tiered storage summary // GET /v1/project/{project}/service/{service_name}/clickhouse/tiered-storage/summary @@ -51,9 +51,10 @@ func NewHandler(doer doer) ClickHouseHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type ClickHouseHandler struct { doer doer } @@ -107,9 +108,28 @@ func (h *ClickHouseHandler) ServiceClickHouseQuery(ctx context.Context, project } return out, nil } -func (h *ClickHouseHandler) ServiceClickHouseQueryStats(ctx context.Context, project string, serviceName string) ([]QueryOutAlt, error) { + +// ServiceClickHouseQueryStatsLimit Limit for number of results +func ServiceClickHouseQueryStatsLimit(limit int) queryParam { + return queryParam{"limit", fmt.Sprintf("%d", limit)} +} + +// ServiceClickHouseQueryStatsOffset Offset for retrieved results based on sort order +func ServiceClickHouseQueryStatsOffset(offset int) queryParam { + return queryParam{"offset", fmt.Sprintf("%d", offset)} +} + +// ServiceClickHouseQueryStatsOrderByType Order in which to sort retrieved results +func ServiceClickHouseQueryStatsOrderByType(orderByType OrderByType) queryParam { + return queryParam{"order_by", fmt.Sprintf("%s", orderByType)} +} +func (h *ClickHouseHandler) ServiceClickHouseQueryStats(ctx context.Context, project string, serviceName string, query ...queryParam) ([]QueryOutAlt, error) { + p := make([][2]string, 0, len(query)) + for _, v := range query { + p = append(p, v) + } path := fmt.Sprintf("/v1/project/%s/service/%s/clickhouse/query/stats", url.PathEscape(project), url.PathEscape(serviceName)) - b, err := h.doer.Do(ctx, "ServiceClickHouseQueryStats", "GET", path, nil) + b, err := h.doer.Do(ctx, "ServiceClickHouseQueryStats", "GET", path, nil, p...) if err != nil { return nil, err } @@ -161,6 +181,29 @@ type MetaOut struct { Name string `json:"name"` // Column name Type string `json:"type"` // Column type } +type OrderByType string + +const ( + OrderByTypeCallsasc OrderByType = "calls:asc" + OrderByTypeCallsdesc OrderByType = "calls:desc" + OrderByTypeMinTimeasc OrderByType = "min_time:asc" + OrderByTypeMinTimedesc OrderByType = "min_time:desc" + OrderByTypeMaxTimeasc OrderByType = "max_time:asc" + OrderByTypeMaxTimedesc OrderByType = "max_time:desc" + OrderByTypeMeanTimeasc OrderByType = "mean_time:asc" + OrderByTypeMeanTimedesc OrderByType = "mean_time:desc" + OrderByTypeP95Timeasc OrderByType = "p95_time:asc" + OrderByTypeP95Timedesc OrderByType = "p95_time:desc" + OrderByTypeStddevTimeasc OrderByType = "stddev_time:asc" + OrderByTypeStddevTimedesc OrderByType = "stddev_time:desc" + OrderByTypeTotalTimeasc OrderByType = "total_time:asc" + OrderByTypeTotalTimedesc OrderByType = "total_time:desc" +) + +func OrderByTypeChoices() []string { + return []string{"calls:asc", "calls:desc", "min_time:asc", "min_time:desc", "max_time:asc", "max_time:desc", "mean_time:asc", "mean_time:desc", "p95_time:asc", "p95_time:desc", "stddev_time:asc", "stddev_time:desc", "total_time:asc", "total_time:desc"} +} + type QueryOut struct { ClientName *string `json:"client_name,omitempty"` // Client name, if set Database *string `json:"database,omitempty"` diff --git a/handler/cloud/cloud.go b/handler/cloud/cloud.go index aa1a487..a548d35 100644 --- a/handler/cloud/cloud.go +++ b/handler/cloud/cloud.go @@ -26,9 +26,10 @@ func NewHandler(doer doer) CloudHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type CloudHandler struct { doer doer } diff --git a/handler/domain/domain.go b/handler/domain/domain.go index 58571dc..cf36d14 100644 --- a/handler/domain/domain.go +++ b/handler/domain/domain.go @@ -42,9 +42,10 @@ func NewHandler(doer doer) DomainHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type DomainHandler struct { doer doer } diff --git a/handler/flink/flink.go b/handler/flink/flink.go index b7b4cc9..f770533 100644 --- a/handler/flink/flink.go +++ b/handler/flink/flink.go @@ -21,9 +21,10 @@ func NewHandler(doer doer) FlinkHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type FlinkHandler struct { doer doer } diff --git a/handler/flinkapplication/flinkapplication.go b/handler/flinkapplication/flinkapplication.go index 6ceceae..ec906a8 100644 --- a/handler/flinkapplication/flinkapplication.go +++ b/handler/flinkapplication/flinkapplication.go @@ -42,9 +42,10 @@ func NewHandler(doer doer) FlinkApplicationHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type FlinkApplicationHandler struct { doer doer } diff --git a/handler/flinkapplicationdeployment/flinkapplicationdeployment.go b/handler/flinkapplicationdeployment/flinkapplicationdeployment.go index dd34dec..a43aa8d 100644 --- a/handler/flinkapplicationdeployment/flinkapplicationdeployment.go +++ b/handler/flinkapplicationdeployment/flinkapplicationdeployment.go @@ -47,9 +47,10 @@ func NewHandler(doer doer) FlinkApplicationDeploymentHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type FlinkApplicationDeploymentHandler struct { doer doer } diff --git a/handler/flinkapplicationversion/flinkapplicationversion.go b/handler/flinkapplicationversion/flinkapplicationversion.go index 1b9a972..100a857 100644 --- a/handler/flinkapplicationversion/flinkapplicationversion.go +++ b/handler/flinkapplicationversion/flinkapplicationversion.go @@ -37,9 +37,10 @@ func NewHandler(doer doer) FlinkApplicationVersionHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type FlinkApplicationVersionHandler struct { doer doer } diff --git a/handler/flinkjob/flinkjob.go b/handler/flinkjob/flinkjob.go index c78eff3..9ad7522 100644 --- a/handler/flinkjob/flinkjob.go +++ b/handler/flinkjob/flinkjob.go @@ -26,9 +26,10 @@ func NewHandler(doer doer) FlinkJobHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type FlinkJobHandler struct { doer doer } diff --git a/handler/kafka/kafka.go b/handler/kafka/kafka.go index fc7b874..ba83ba0 100644 --- a/handler/kafka/kafka.go +++ b/handler/kafka/kafka.go @@ -66,9 +66,10 @@ func NewHandler(doer doer) KafkaHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type KafkaHandler struct { doer doer } diff --git a/handler/kafkaconnect/kafkaconnect.go b/handler/kafkaconnect/kafkaconnect.go index 2a1dbb5..efb389d 100644 --- a/handler/kafkaconnect/kafkaconnect.go +++ b/handler/kafkaconnect/kafkaconnect.go @@ -71,9 +71,10 @@ func NewHandler(doer doer) KafkaConnectHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type KafkaConnectHandler struct { doer doer } diff --git a/handler/kafkamirrormaker/kafkamirrormaker.go b/handler/kafkamirrormaker/kafkamirrormaker.go index 3cbf2d6..99631f5 100644 --- a/handler/kafkamirrormaker/kafkamirrormaker.go +++ b/handler/kafkamirrormaker/kafkamirrormaker.go @@ -41,9 +41,10 @@ func NewHandler(doer doer) KafkaMirrorMakerHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type KafkaMirrorMakerHandler struct { doer doer } diff --git a/handler/kafkaschemaregistry/kafkaschemaregistry.go b/handler/kafkaschemaregistry/kafkaschemaregistry.go index 6f3b181..a645cfe 100644 --- a/handler/kafkaschemaregistry/kafkaschemaregistry.go +++ b/handler/kafkaschemaregistry/kafkaschemaregistry.go @@ -96,9 +96,10 @@ func NewHandler(doer doer) KafkaSchemaRegistryHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type KafkaSchemaRegistryHandler struct { doer doer } diff --git a/handler/kafkatopic/kafkatopic.go b/handler/kafkatopic/kafkatopic.go index 4771349..41402e2 100644 --- a/handler/kafkatopic/kafkatopic.go +++ b/handler/kafkatopic/kafkatopic.go @@ -51,9 +51,10 @@ func NewHandler(doer doer) KafkaTopicHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type KafkaTopicHandler struct { doer doer } @@ -416,10 +417,13 @@ const ( MessageFormatVersionType37Iv4 MessageFormatVersionType = "3.7-IV4" MessageFormatVersionType38 MessageFormatVersionType = "3.8" MessageFormatVersionType38Iv0 MessageFormatVersionType = "3.8-IV0" + MessageFormatVersionType39 MessageFormatVersionType = "3.9" + MessageFormatVersionType39Iv0 MessageFormatVersionType = "3.9-IV0" + MessageFormatVersionType39Iv1 MessageFormatVersionType = "3.9-IV1" ) func MessageFormatVersionTypeChoices() []string { - return []string{"0.8.0", "0.8.1", "0.8.2", "0.9.0", "0.10.0", "0.10.0-IV0", "0.10.0-IV1", "0.10.1", "0.10.1-IV0", "0.10.1-IV1", "0.10.1-IV2", "0.10.2", "0.10.2-IV0", "0.11.0", "0.11.0-IV0", "0.11.0-IV1", "0.11.0-IV2", "1.0", "1.0-IV0", "1.1", "1.1-IV0", "2.0", "2.0-IV0", "2.0-IV1", "2.1", "2.1-IV0", "2.1-IV1", "2.1-IV2", "2.2", "2.2-IV0", "2.2-IV1", "2.3", "2.3-IV0", "2.3-IV1", "2.4", "2.4-IV0", "2.4-IV1", "2.5", "2.5-IV0", "2.6", "2.6-IV0", "2.7", "2.7-IV0", "2.7-IV1", "2.7-IV2", "2.8", "2.8-IV0", "2.8-IV1", "3.0", "3.0-IV0", "3.0-IV1", "3.1", "3.1-IV0", "3.2", "3.2-IV0", "3.3", "3.3-IV0", "3.3-IV1", "3.3-IV2", "3.3-IV3", "3.4", "3.4-IV0", "3.5", "3.5-IV0", "3.5-IV1", "3.5-IV2", "3.6", "3.6-IV0", "3.6-IV1", "3.6-IV2", "3.7", "3.7-IV0", "3.7-IV1", "3.7-IV2", "3.7-IV3", "3.7-IV4", "3.8", "3.8-IV0"} + return []string{"0.8.0", "0.8.1", "0.8.2", "0.9.0", "0.10.0", "0.10.0-IV0", "0.10.0-IV1", "0.10.1", "0.10.1-IV0", "0.10.1-IV1", "0.10.1-IV2", "0.10.2", "0.10.2-IV0", "0.11.0", "0.11.0-IV0", "0.11.0-IV1", "0.11.0-IV2", "1.0", "1.0-IV0", "1.1", "1.1-IV0", "2.0", "2.0-IV0", "2.0-IV1", "2.1", "2.1-IV0", "2.1-IV1", "2.1-IV2", "2.2", "2.2-IV0", "2.2-IV1", "2.3", "2.3-IV0", "2.3-IV1", "2.4", "2.4-IV0", "2.4-IV1", "2.5", "2.5-IV0", "2.6", "2.6-IV0", "2.7", "2.7-IV0", "2.7-IV1", "2.7-IV2", "2.8", "2.8-IV0", "2.8-IV1", "3.0", "3.0-IV0", "3.0-IV1", "3.1", "3.1-IV0", "3.2", "3.2-IV0", "3.3", "3.3-IV0", "3.3-IV1", "3.3-IV2", "3.3-IV3", "3.4", "3.4-IV0", "3.5", "3.5-IV0", "3.5-IV1", "3.5-IV2", "3.6", "3.6-IV0", "3.6-IV1", "3.6-IV2", "3.7", "3.7-IV0", "3.7-IV1", "3.7-IV2", "3.7-IV3", "3.7-IV4", "3.8", "3.8-IV0", "3.9", "3.9-IV0", "3.9-IV1"} } type MessageOut struct { diff --git a/handler/mysql/mysql.go b/handler/mysql/mysql.go index 073c941..aa4fc3f 100644 --- a/handler/mysql/mysql.go +++ b/handler/mysql/mysql.go @@ -21,9 +21,10 @@ func NewHandler(doer doer) MySQLHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type MySQLHandler struct { doer doer } diff --git a/handler/opensearch/opensearch.go b/handler/opensearch/opensearch.go index e6fdef0..761c03b 100644 --- a/handler/opensearch/opensearch.go +++ b/handler/opensearch/opensearch.go @@ -57,9 +57,10 @@ func NewHandler(doer doer) OpenSearchHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type OpenSearchHandler struct { doer doer } diff --git a/handler/organization/organization.go b/handler/organization/organization.go index 4711d70..5edebdd 100644 --- a/handler/organization/organization.go +++ b/handler/organization/organization.go @@ -62,9 +62,10 @@ func NewHandler(doer doer) OrganizationHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type OrganizationHandler struct { doer doer } diff --git a/handler/organizationuser/organizationuser.go b/handler/organizationuser/organizationuser.go index 7a6a7fc..f6ddc98 100644 --- a/handler/organizationuser/organizationuser.go +++ b/handler/organizationuser/organizationuser.go @@ -77,9 +77,10 @@ func NewHandler(doer doer) OrganizationUserHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type OrganizationUserHandler struct { doer doer } diff --git a/handler/postgresql/postgresql.go b/handler/postgresql/postgresql.go index a1cca12..e3e3879 100644 --- a/handler/postgresql/postgresql.go +++ b/handler/postgresql/postgresql.go @@ -46,9 +46,10 @@ func NewHandler(doer doer) PostgreSQLHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type PostgreSQLHandler struct { doer doer } diff --git a/handler/privatelink/privatelink.go b/handler/privatelink/privatelink.go index 25a9552..8688bae 100644 --- a/handler/privatelink/privatelink.go +++ b/handler/privatelink/privatelink.go @@ -81,9 +81,10 @@ func NewHandler(doer doer) PrivatelinkHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type PrivatelinkHandler struct { doer doer } diff --git a/handler/project/project.go b/handler/project/project.go index 580a052..630724e 100644 --- a/handler/project/project.go +++ b/handler/project/project.go @@ -117,9 +117,10 @@ func NewHandler(doer doer) ProjectHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type ProjectHandler struct { doer doer } diff --git a/handler/projectbilling/projectbilling.go b/handler/projectbilling/projectbilling.go index 248cb5f..aded87d 100644 --- a/handler/projectbilling/projectbilling.go +++ b/handler/projectbilling/projectbilling.go @@ -37,9 +37,10 @@ func NewHandler(doer doer) ProjectBillingHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type ProjectBillingHandler struct { doer doer } diff --git a/handler/service/service.go b/handler/service/service.go index 26820b6..c2c3432 100644 --- a/handler/service/service.go +++ b/handler/service/service.go @@ -159,7 +159,7 @@ type Handler interface { // ServiceUpdate update service configuration // PUT /v1/project/{project}/service/{service_name} // https://api.aiven.io/doc/#tag/Service/operation/ServiceUpdate - ServiceUpdate(ctx context.Context, project string, serviceName string, in *ServiceUpdateIn) (*ServiceUpdateOut, error) + ServiceUpdate(ctx context.Context, project string, serviceName string, in *ServiceUpdateIn, query ...queryParam) (*ServiceUpdateOut, error) } func NewHandler(doer doer) ServiceHandler { @@ -167,9 +167,10 @@ func NewHandler(doer doer) ServiceHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type ServiceHandler struct { doer doer } @@ -503,7 +504,12 @@ func (h *ServiceHandler) ServiceTaskGet(ctx context.Context, project string, ser } return &out.Task, nil } -func (h *ServiceHandler) ServiceUpdate(ctx context.Context, project string, serviceName string, in *ServiceUpdateIn) (*ServiceUpdateOut, error) { + +// ServiceUpdateAllowUncleanPoweroff Allows or disallows powering off a service if some WAL segments are not available for a future restoration of the service, which might result in data loss when powering the service back on +func ServiceUpdateAllowUncleanPoweroff(allowUncleanPoweroff bool) queryParam { + return queryParam{"allow_unclean_poweroff", fmt.Sprintf("%t", allowUncleanPoweroff)} +} +func (h *ServiceHandler) ServiceUpdate(ctx context.Context, project string, serviceName string, in *ServiceUpdateIn, query ...queryParam) (*ServiceUpdateOut, error) { path := fmt.Sprintf("/v1/project/%s/service/%s", url.PathEscape(project), url.PathEscape(serviceName)) b, err := h.doer.Do(ctx, "ServiceUpdate", "PUT", path, in) if err != nil { @@ -792,6 +798,7 @@ const ( IntegrationTypeRsyslog IntegrationType = "rsyslog" IntegrationTypeSchemaRegistryProxy IntegrationType = "schema_registry_proxy" IntegrationTypeStresstester IntegrationType = "stresstester" + IntegrationTypeThanosDistributedQuery IntegrationType = "thanos_distributed_query" IntegrationTypeThanosMigrate IntegrationType = "thanos_migrate" IntegrationTypeThanoscompactor IntegrationType = "thanoscompactor" IntegrationTypeThanosquery IntegrationType = "thanosquery" @@ -801,7 +808,7 @@ const ( ) func IntegrationTypeChoices() []string { - return []string{"alertmanager", "autoscaler", "caching", "cassandra_cross_service_cluster", "clickhouse_credentials", "clickhouse_kafka", "clickhouse_postgresql", "dashboard", "datadog", "datasource", "external_aws_cloudwatch_logs", "external_aws_cloudwatch_metrics", "external_elasticsearch_logs", "external_google_cloud_logging", "external_opensearch_logs", "flink", "flink_external_bigquery", "flink_external_kafka", "flink_external_postgresql", "internal_connectivity", "jolokia", "kafka_connect", "kafka_connect_postgresql", "kafka_logs", "kafka_mirrormaker", "logs", "m3aggregator", "m3coordinator", "metrics", "opensearch_cross_cluster_replication", "opensearch_cross_cluster_search", "prometheus", "read_replica", "rsyslog", "schema_registry_proxy", "stresstester", "thanos_migrate", "thanoscompactor", "thanosquery", "thanosstore", "vector", "vmalert"} + return []string{"alertmanager", "autoscaler", "caching", "cassandra_cross_service_cluster", "clickhouse_credentials", "clickhouse_kafka", "clickhouse_postgresql", "dashboard", "datadog", "datasource", "external_aws_cloudwatch_logs", "external_aws_cloudwatch_metrics", "external_elasticsearch_logs", "external_google_cloud_logging", "external_opensearch_logs", "flink", "flink_external_bigquery", "flink_external_kafka", "flink_external_postgresql", "internal_connectivity", "jolokia", "kafka_connect", "kafka_connect_postgresql", "kafka_logs", "kafka_mirrormaker", "logs", "m3aggregator", "m3coordinator", "metrics", "opensearch_cross_cluster_replication", "opensearch_cross_cluster_search", "prometheus", "read_replica", "rsyslog", "schema_registry_proxy", "stresstester", "thanos_distributed_query", "thanos_migrate", "thanoscompactor", "thanosquery", "thanosstore", "vector", "vmalert"} } type KafkaAuthenticationMethodType string @@ -1652,10 +1659,11 @@ const ( TargetVersionType14 TargetVersionType = "14" TargetVersionType15 TargetVersionType = "15" TargetVersionType16 TargetVersionType = "16" + TargetVersionType17 TargetVersionType = "17" ) func TargetVersionTypeChoices() []string { - return []string{"13", "14", "15", "16"} + return []string{"13", "14", "15", "16", "17"} } type TaskType string diff --git a/handler/serviceintegration/serviceintegration.go b/handler/serviceintegration/serviceintegration.go index 4363918..b44a865 100644 --- a/handler/serviceintegration/serviceintegration.go +++ b/handler/serviceintegration/serviceintegration.go @@ -76,9 +76,10 @@ func NewHandler(doer doer) ServiceIntegrationHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type ServiceIntegrationHandler struct { doer doer } @@ -317,6 +318,7 @@ const ( IntegrationTypeRsyslog IntegrationType = "rsyslog" IntegrationTypeSchemaRegistryProxy IntegrationType = "schema_registry_proxy" IntegrationTypeStresstester IntegrationType = "stresstester" + IntegrationTypeThanosDistributedQuery IntegrationType = "thanos_distributed_query" IntegrationTypeThanosMigrate IntegrationType = "thanos_migrate" IntegrationTypeThanoscompactor IntegrationType = "thanoscompactor" IntegrationTypeThanosquery IntegrationType = "thanosquery" @@ -326,7 +328,7 @@ const ( ) func IntegrationTypeChoices() []string { - return []string{"alertmanager", "autoscaler", "caching", "cassandra_cross_service_cluster", "clickhouse_credentials", "clickhouse_kafka", "clickhouse_postgresql", "dashboard", "datadog", "datasource", "external_aws_cloudwatch_logs", "external_aws_cloudwatch_metrics", "external_elasticsearch_logs", "external_google_cloud_logging", "external_opensearch_logs", "flink", "flink_external_bigquery", "flink_external_kafka", "flink_external_postgresql", "internal_connectivity", "jolokia", "kafka_connect", "kafka_connect_postgresql", "kafka_logs", "kafka_mirrormaker", "logs", "m3aggregator", "m3coordinator", "metrics", "opensearch_cross_cluster_replication", "opensearch_cross_cluster_search", "prometheus", "read_replica", "rsyslog", "schema_registry_proxy", "stresstester", "thanos_migrate", "thanoscompactor", "thanosquery", "thanosstore", "vector", "vmalert"} + return []string{"alertmanager", "autoscaler", "caching", "cassandra_cross_service_cluster", "clickhouse_credentials", "clickhouse_kafka", "clickhouse_postgresql", "dashboard", "datadog", "datasource", "external_aws_cloudwatch_logs", "external_aws_cloudwatch_metrics", "external_elasticsearch_logs", "external_google_cloud_logging", "external_opensearch_logs", "flink", "flink_external_bigquery", "flink_external_kafka", "flink_external_postgresql", "internal_connectivity", "jolokia", "kafka_connect", "kafka_connect_postgresql", "kafka_logs", "kafka_mirrormaker", "logs", "m3aggregator", "m3coordinator", "metrics", "opensearch_cross_cluster_replication", "opensearch_cross_cluster_search", "prometheus", "read_replica", "rsyslog", "schema_registry_proxy", "stresstester", "thanos_distributed_query", "thanos_migrate", "thanoscompactor", "thanosquery", "thanosstore", "vector", "vmalert"} } type IntegrationTypeOut struct { diff --git a/handler/serviceuser/serviceuser.go b/handler/serviceuser/serviceuser.go index 7b34bd4..ad6cee2 100644 --- a/handler/serviceuser/serviceuser.go +++ b/handler/serviceuser/serviceuser.go @@ -42,9 +42,10 @@ func NewHandler(doer doer) ServiceUserHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type ServiceUserHandler struct { doer doer } diff --git a/handler/staticip/staticip.go b/handler/staticip/staticip.go index 7a210fd..08b0310 100644 --- a/handler/staticip/staticip.go +++ b/handler/staticip/staticip.go @@ -51,9 +51,10 @@ func NewHandler(doer doer) StaticIPHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type StaticIPHandler struct { doer doer } diff --git a/handler/thanos/thanos.go b/handler/thanos/thanos.go index 0bf1448..2506eff 100644 --- a/handler/thanos/thanos.go +++ b/handler/thanos/thanos.go @@ -21,9 +21,10 @@ func NewHandler(doer doer) ThanosHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type ThanosHandler struct { doer doer } diff --git a/handler/user/user.go b/handler/user/user.go index a1ca2a5..a4ca61a 100644 --- a/handler/user/user.go +++ b/handler/user/user.go @@ -152,9 +152,10 @@ func NewHandler(doer doer) UserHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type UserHandler struct { doer doer } diff --git a/handler/usergroup/usergroup.go b/handler/usergroup/usergroup.go index 5610643..cfa983f 100644 --- a/handler/usergroup/usergroup.go +++ b/handler/usergroup/usergroup.go @@ -52,9 +52,10 @@ func NewHandler(doer doer) UserGroupHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type UserGroupHandler struct { doer doer } diff --git a/handler/vpc/vpc.go b/handler/vpc/vpc.go index c630d61..929b51c 100644 --- a/handler/vpc/vpc.go +++ b/handler/vpc/vpc.go @@ -62,9 +62,10 @@ func NewHandler(doer doer) VpcHandler { } type doer interface { - Do(ctx context.Context, operationID, method, path string, v any) ([]byte, error) + Do(ctx context.Context, operationID, method, path string, in any, query ...[2]string) ([]byte, error) } +type queryParam [2]string type VpcHandler struct { doer doer }