diff --git a/client_test.go b/client_test.go index 9d9b0c2..2c36e75 100644 --- a/client_test.go +++ b/client_test.go @@ -187,8 +187,7 @@ func TestServiceCreateErrorsRetries(t *testing.T) { } ctx := context.Background() - project := "aiven-project" - out, err := c.ServiceCreate(ctx, project, in) + out, err := c.ServiceCreate(ctx, "aiven-project", in) assert.Nil(t, out) assert.Equal(t, err.Error(), tt.ErrorExpect) diff --git a/config.yaml b/config.yaml index cc4275a..ab030d0 100644 --- a/config.yaml +++ b/config.yaml @@ -183,7 +183,6 @@ Organization: - OrganizationAuthenticationConfigGet - OrganizationAuthenticationConfigUpdate - OrganizationGet - - OrganizationProjectsList - OrganizationUpdate - PermissionsGet - PermissionsUpdate @@ -200,7 +199,6 @@ OrganizationUser: - OrganizationUserList - OrganizationUserPasswordReset - OrganizationUserRevokeToken - - OrganizationUserSet - OrganizationUserTokensList - OrganizationUserUpdate PostgreSQL: diff --git a/generator/config_check.go b/generator/config_check.go index a30a86b..8874219 100644 --- a/generator/config_check.go +++ b/generator/config_check.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "strings" ) func checkDuplicateEndpoints(config map[string][]string) error { @@ -19,15 +20,7 @@ func checkDuplicateEndpoints(config map[string][]string) error { } if len(duplicates) > 0 { - return fmt.Errorf("Duplicate endpoints found in config: %v", keys(duplicates)) + return fmt.Errorf("duplicate endpoints found in config: %v", strings.Join(sortedKeys(duplicates), ", ")) } return nil } - -func keys(m map[string]struct{}) []string { - keys := make([]string, 0, len(m)) - for k := range m { - keys = append(keys, k) - } - return keys -} diff --git a/generator/main.go b/generator/main.go index a8449c1..ef5c388 100644 --- a/generator/main.go +++ b/generator/main.go @@ -102,6 +102,15 @@ func exec() error { return err } + // To validate all operation ids in the config exist in the OpenAPI spec + // OperationID => Package name + configOperationIDs := make(map[string]string) + for pkg, idList := range config { + for _, id := range idList { + configOperationIDs[id] = pkg + } + } + pkgs := make(map[string][]*Path) for path := range doc.Paths { v := doc.Paths[path] @@ -114,23 +123,15 @@ func exec() error { p.Method = strings.ToUpper(meth) p.ID = p.OperationID - var pkg string - outer: - for k, idList := range config { - for _, id := range idList { - if p.ID == id { - pkg = k - - break outer - } - } - } - - if pkg == "" { - log.Error().Msgf("%q id not found in config!", p.ID) + pkg, ok := configOperationIDs[p.ID] + if !ok { + log.Warn().Msgf("%q id not found in config!", p.ID) continue } + // Removes the operation id from the map to see which are not used + delete(configOperationIDs, p.ID) + pkgs[pkg] = append(pkgs[pkg], p) params := make([]*Parameter, 0) @@ -155,6 +156,10 @@ func exec() error { } } + if len(configOperationIDs) > 0 { + return fmt.Errorf("config has unused operation ids: %s", strings.Join(sortedKeys(configOperationIDs), ", ")) + } + ctx := jen.Id("ctx").Qual("context", "Context") doer := jen.Comment(doerName + " http client").Line().Type().Id(doerName).Interface( jen.Id("Do").Params( diff --git a/handler/account/account.go b/handler/account/account.go index abbd413..7efb22b 100644 --- a/handler/account/account.go +++ b/handler/account/account.go @@ -351,7 +351,7 @@ type AccountBillingGroupOut struct { EstimatedBalanceUsd string `json:"estimated_balance_usd"` // Estimated balance in USD, before tax PaymentMethod PaymentMethodType `json:"payment_method"` // Payment method ShippingAddressId *string `json:"shipping_address_id,omitempty"` // Address ID - State string `json:"state"` // Address state + State string `json:"state"` // Address state or province VatId string `json:"vat_id"` // EU VAT Identification Number ZipCode string `json:"zip_code"` // Address zip code } @@ -645,7 +645,7 @@ type ProjectOut struct { OrganizationId string `json:"organization_id"` // Organization ID PaymentMethod string `json:"payment_method"` // Payment method ProjectName string `json:"project_name"` // Project name - State *string `json:"state,omitempty"` // Address state + State *string `json:"state,omitempty"` // Address state or province Tags map[string]string `json:"tags,omitempty"` // Set of resource tags TechEmails []TechEmailOut `json:"tech_emails,omitempty"` // List of project tech email addresses TenantId *string `json:"tenant_id,omitempty"` // Tenant ID diff --git a/handler/billinggroup/billinggroup.go b/handler/billinggroup/billinggroup.go index 85f1ef8..18aafdc 100644 --- a/handler/billinggroup/billinggroup.go +++ b/handler/billinggroup/billinggroup.go @@ -279,7 +279,7 @@ type BillingGroupCreateIn struct { CopyFromBillingGroup *string `json:"copy_from_billing_group,omitempty"` // Billing group ID CountryCode *string `json:"country_code,omitempty"` // Two letter country code for billing country ShippingAddressId *string `json:"shipping_address_id,omitempty"` // Address ID - State *string `json:"state,omitempty"` // Address state + State *string `json:"state,omitempty"` // Address state or province VatId *string `json:"vat_id,omitempty"` // EU VAT Identification Number ZipCode *string `json:"zip_code,omitempty"` // Address zip code } @@ -307,7 +307,7 @@ type BillingGroupCreateOut struct { EstimatedBalanceUsd string `json:"estimated_balance_usd"` // Estimated balance in USD, before tax PaymentMethod PaymentMethodType `json:"payment_method"` // Payment method ShippingAddressId *string `json:"shipping_address_id,omitempty"` // Address ID - State string `json:"state"` // Address state + State string `json:"state"` // Address state or province VatId string `json:"vat_id"` // EU VAT Identification Number ZipCode string `json:"zip_code"` // Address zip code } @@ -350,7 +350,7 @@ type BillingGroupGetOut struct { EstimatedBalanceUsd string `json:"estimated_balance_usd"` // Estimated balance in USD, before tax PaymentMethod PaymentMethodType `json:"payment_method"` // Payment method ShippingAddressId *string `json:"shipping_address_id,omitempty"` // Address ID - State string `json:"state"` // Address state + State string `json:"state"` // Address state or province VatId string `json:"vat_id"` // EU VAT Identification Number ZipCode string `json:"zip_code"` // Address zip code } @@ -376,7 +376,7 @@ type BillingGroupOut struct { EstimatedBalanceUsd string `json:"estimated_balance_usd"` // Estimated balance in USD, before tax PaymentMethod PaymentMethodType `json:"payment_method"` // Payment method ShippingAddressId *string `json:"shipping_address_id,omitempty"` // Address ID - State string `json:"state"` // Address state + State string `json:"state"` // Address state or province VatId string `json:"vat_id"` // EU VAT Identification Number ZipCode string `json:"zip_code"` // Address zip code } @@ -410,7 +410,7 @@ type BillingGroupUpdateIn struct { Company *string `json:"company,omitempty"` // Name of a company CountryCode *string `json:"country_code,omitempty"` // Two letter country code for billing country ShippingAddressId *string `json:"shipping_address_id,omitempty"` // Address ID - State *string `json:"state,omitempty"` // Address state + State *string `json:"state,omitempty"` // Address state or province VatId *string `json:"vat_id,omitempty"` // EU VAT Identification Number ZipCode *string `json:"zip_code,omitempty"` // Address zip code } @@ -438,7 +438,7 @@ type BillingGroupUpdateOut struct { EstimatedBalanceUsd string `json:"estimated_balance_usd"` // Estimated balance in USD, before tax PaymentMethod PaymentMethodType `json:"payment_method"` // Payment method ShippingAddressId *string `json:"shipping_address_id,omitempty"` // Address ID - State string `json:"state"` // Address state + State string `json:"state"` // Address state or province VatId string `json:"vat_id"` // EU VAT Identification Number ZipCode string `json:"zip_code"` // Address zip code } @@ -614,6 +614,7 @@ type ServiceType string const ( ServiceTypeAlertmanager ServiceType = "alertmanager" ServiceTypeAlloydbomni ServiceType = "alloydbomni" + ServiceTypeApplication ServiceType = "application" ServiceTypeCassandra ServiceType = "cassandra" ServiceTypeClickhouse ServiceType = "clickhouse" ServiceTypeDragonfly ServiceType = "dragonfly" @@ -646,7 +647,7 @@ const ( ) func ServiceTypeChoices() []string { - return []string{"alertmanager", "alloydbomni", "cassandra", "clickhouse", "dragonfly", "elasticsearch", "flink", "grafana", "influxdb", "kafka", "kafka_connect", "kafka_mirrormaker", "m3aggregator", "m3db", "mysql", "opensearch", "parca", "pg", "redis", "stresstester", "sw", "thanos", "thanoscompactor", "thanosquery", "thanosreceiver", "thanosruler", "thanosstore", "valkey", "vector", "vmalert", "warpstream"} + return []string{"alertmanager", "alloydbomni", "application", "cassandra", "clickhouse", "dragonfly", "elasticsearch", "flink", "grafana", "influxdb", "kafka", "kafka_connect", "kafka_mirrormaker", "m3aggregator", "m3db", "mysql", "opensearch", "parca", "pg", "redis", "stresstester", "sw", "thanos", "thanoscompactor", "thanosquery", "thanosreceiver", "thanosruler", "thanosstore", "valkey", "vector", "vmalert", "warpstream"} } // billingGroupCreateOut BillingGroupCreateResponse diff --git a/handler/kafka/kafka.go b/handler/kafka/kafka.go index 7254fca..1c9c663 100644 --- a/handler/kafka/kafka.go +++ b/handler/kafka/kafka.go @@ -338,7 +338,6 @@ type QuotaOut struct { RequestPercentage float64 `json:"request_percentage"` // cpu percentage throttle User string `json:"user"` // user } - type ResourceType string const ( diff --git a/handler/project/project.go b/handler/project/project.go index ee21b51..f8e470b 100644 --- a/handler/project/project.go +++ b/handler/project/project.go @@ -771,7 +771,7 @@ type ProjectCreateOut struct { OrganizationId string `json:"organization_id"` // Organization ID PaymentMethod string `json:"payment_method"` // Payment method ProjectName string `json:"project_name"` // Project name - State *string `json:"state,omitempty"` // Address state + State *string `json:"state,omitempty"` // Address state or province Tags map[string]string `json:"tags,omitempty"` // Set of resource tags TechEmails []TechEmailOut `json:"tech_emails,omitempty"` // List of project tech email addresses TenantId *string `json:"tenant_id,omitempty"` // Tenant ID @@ -805,7 +805,7 @@ type ProjectGetOut struct { OrganizationId string `json:"organization_id"` // Organization ID PaymentMethod string `json:"payment_method"` // Payment method ProjectName string `json:"project_name"` // Project name - State *string `json:"state,omitempty"` // Address state + State *string `json:"state,omitempty"` // Address state or province Tags map[string]string `json:"tags,omitempty"` // Set of resource tags TechEmails []TechEmailOut `json:"tech_emails,omitempty"` // List of project tech email addresses TenantId *string `json:"tenant_id,omitempty"` // Tenant ID @@ -865,7 +865,7 @@ type ProjectOut struct { OrganizationId string `json:"organization_id"` // Organization ID PaymentMethod string `json:"payment_method"` // Payment method ProjectName string `json:"project_name"` // Project name - State *string `json:"state,omitempty"` // Address state + State *string `json:"state,omitempty"` // Address state or province Tags map[string]string `json:"tags,omitempty"` // Set of resource tags TechEmails []TechEmailOut `json:"tech_emails,omitempty"` // List of project tech email addresses TenantId *string `json:"tenant_id,omitempty"` // Tenant ID @@ -994,7 +994,7 @@ type ProjectUpdateOut struct { OrganizationId string `json:"organization_id"` // Organization ID PaymentMethod string `json:"payment_method"` // Payment method ProjectName string `json:"project_name"` // Project name - State *string `json:"state,omitempty"` // Address state + State *string `json:"state,omitempty"` // Address state or province Tags map[string]string `json:"tags,omitempty"` // Set of resource tags TechEmails []TechEmailOut `json:"tech_emails,omitempty"` // List of project tech email addresses TenantId *string `json:"tenant_id,omitempty"` // Tenant ID diff --git a/handler/user/user.go b/handler/user/user.go index c84dcb2..6d70a8d 100644 --- a/handler/user/user.go +++ b/handler/user/user.go @@ -719,7 +719,7 @@ type UserCreateIn struct { Origin *string `json:"origin,omitempty"` // Origin of the user Password *string `json:"password,omitempty"` // User password RealName string `json:"real_name"` // User real name - State *string `json:"state,omitempty"` // Address state + State *string `json:"state,omitempty"` // Address state or province Token *string `json:"token,omitempty"` // Signup token for single sign-on linking }