Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 74 additions & 3 deletions go/models/database_compute_settings_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions go/models/database_compute_settings_request_validate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package models

import "fmt"

// ValidateCrossFieldConstraints checks cross-field invariants that cannot be
// expressed in the OpenAPI 2.0 schema and are therefore not covered by the
// generated Validate method. Callers should invoke this after Validate.
//
// Rules enforced:
// - When both min_cu and max_cu are provided, max_cu >= min_cu.
// - When both min_cu and max_cu are provided, max_cu - min_cu <= 8.0.
func (m *DatabaseComputeSettingsRequest) ValidateCrossFieldConstraints() error {
if m.MinCu == nil || m.MaxCu == nil {
return nil
}

if *m.MaxCu < *m.MinCu {
return fmt.Errorf("max_cu (%g) must be greater than or equal to min_cu (%g)", *m.MaxCu, *m.MinCu)
}

if *m.MaxCu-*m.MinCu > 8.0 {
return fmt.Errorf("max_cu - min_cu must not exceed 8.0 (got %g)", *m.MaxCu-*m.MinCu)
}

return nil
}
8 changes: 8 additions & 0 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3908,19 +3908,27 @@ definitions:
min_cu:
type: number
format: double
minimum: 0.25
maximum: 16
x-nullable: true
description: >-
Minimum compute units (0.25 to 16.0).
Must be less than or equal to max_cu.
max_cu:
type: number
format: double
minimum: 0.25
maximum: 16
x-nullable: true
description: >-
Maximum compute units (0.25 to 16.0).
Must be greater than or equal to min_cu.
max_cu - min_cu must not exceed 8.0.
sleep_timeout_seconds:
type: integer
format: int64
minimum: -1
x-nullable: true
description: >-
Seconds of inactivity before the compute endpoint is suspended.
Use -1 for always on, or a non-negative value.
Expand Down
Loading