33 lines
1.4 KiB
Go
33 lines
1.4 KiB
Go
package store
|
|
|
|
// EffectiveBillingConfigInput describes the billing layers used by runtime and
|
|
// catalog responses. LegacyPlatformModelConfig is retained only as a fallback
|
|
// for models that do not have an effective pricing rule set.
|
|
type EffectiveBillingConfigInput struct {
|
|
BaseConfig map[string]any
|
|
LegacyPlatformModelConfig map[string]any
|
|
InheritedRuleSetConfig map[string]any
|
|
ModelRuleSetConfig map[string]any
|
|
Override map[string]any
|
|
}
|
|
|
|
// ResolveEffectiveBillingConfig keeps inherited pricing rules authoritative over
|
|
// the legacy materialized snapshot. Explicit model rules and overrides retain
|
|
// their higher-priority exception semantics.
|
|
func ResolveEffectiveBillingConfig(input EffectiveBillingConfigInput) map[string]any {
|
|
config := mergeObjects(input.BaseConfig, nil)
|
|
if len(input.InheritedRuleSetConfig) > 0 {
|
|
// Rule sets are allowed to cover only a subset of resource types. Keep
|
|
// base-model prices for resources that the inherited rule set does not
|
|
// define, while letting the rule set remain authoritative for matching
|
|
// top-level keys.
|
|
config = mergeObjects(config, input.InheritedRuleSetConfig)
|
|
} else if len(input.LegacyPlatformModelConfig) > 0 {
|
|
config = mergeObjects(config, input.LegacyPlatformModelConfig)
|
|
}
|
|
if len(input.ModelRuleSetConfig) > 0 {
|
|
config = mergeObjects(config, input.ModelRuleSetConfig)
|
|
}
|
|
return mergeObjects(config, input.Override)
|
|
}
|