Documentation ¶
Overview ¶
Package ruleformats contains logic required for akamai_property_rules_builder data source.
Index ¶
- Variables
- func NameMappings(ruleFormat string) map[string]string
- func Schemas() map[string]*schema.Schema
- func ShouldFlattenFunc(ruleFormat string) func(string) bool
- func TypeMappings(ruleFormat string) map[string]any
- type NotFoundError
- type RuleFormat
- type RuleItem
- type RuleItems
- type RuleVersion
- type RulesBuilder
- type RulesSchemaReader
- func (r *RulesSchemaReader) GetBehaviorsList() ([]RuleItem, error)
- func (r *RulesSchemaReader) GetChildrenList() ([]string, error)
- func (r *RulesSchemaReader) GetCriteriaList() ([]RuleItem, error)
- func (r *RulesSchemaReader) GetRuleFormat() string
- func (r *RulesSchemaReader) GetVariablesList() ([]map[string]any, error)
- type RulesUpdate
- type TooManyElementsError
- type TypeAssertionError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is used when value not found in schema.ResourceData. ErrNotFound = errors.New("not found") // ErrTypeAssertion is used when type assertion failed. ErrTypeAssertion = errors.New("type assertion") // ErrTooManyElements is used when too many elements were found in a list. ErrTooManyElements = errors.New("too many elements") // ErrOnlyForDefault is used when some fields are used outside "default" rules in data source ErrOnlyForDefault = errors.New("cannot be used outside 'default' rule") // ErrNotForDefault is used when some fields cannot be used in "default" rules in data source ErrNotForDefault = errors.New("cannot be used in 'default' rule") )
Functions ¶
func NameMappings ¶
NameMappings returns a map of option name mappings for a given rule format
For example, field "detect_smart_dns_proxy" converted to camelCase would end up as "detectSmartDnsProxy" and it would be incorrect. Correct value that is expected by API should be "detectSmartDNSProxy" and the returned map would contain following mapping: {"detectSmartDnsProxy":"detectSmartDNSProxy"}
func Schemas ¶
Schemas returns map of terraform schemas for all rule formats that are in the registry.
func ShouldFlattenFunc ¶
ShouldFlattenFunc returns a function for given rule format that can be called with given "{behavior_name}.{option_name}" as input, and it returns if it should get flatten it is useful for flattening lists that are expected to be objects in json.
func TypeMappings ¶
TypeMappings returns a map of mappings for a given rule format that is: mappings of values to its expected form in json the keys are "{behavior}.{option_name}.{value}".
For example if a certain enum expects some of the fields to be of a different type than the others, type mapping will take care of the conversion from the common terraform type of that attribute.
Types ¶
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
NotFoundError defines an error that is used when value is not found in the schema.ResourceData.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
Error returns NotFoundError as a string.
func (*NotFoundError) Unwrap ¶
func (e *NotFoundError) Unwrap() error
Unwrap unwraps NotFoundError into ErrNotFound.
type RuleFormat ¶
type RuleFormat struct {
// contains filtered or unexported fields
}
RuleFormat contains information about a specific ruleformat schema.
type RuleVersion ¶
type RuleVersion string
RuleVersion contains rule format version and allows for version format conversion.
func GetUsedRuleFormat ¶
func GetUsedRuleFormat(d *schema.ResourceData) RuleVersion
GetUsedRuleFormat finds RuleVersion that is used in schema.ResourceData.
func RulesFormats ¶
func RulesFormats() []RuleVersion
RulesFormats returns a list of all rule formats that are in registry.
func (RuleVersion) SchemaKey ¶
func (v RuleVersion) SchemaKey() string
SchemaKey returns schema key under which given rule version can be found.
func (RuleVersion) Version ¶
func (v RuleVersion) Version() string
Version returns schema version in normalized format.
type RulesBuilder ¶
type RulesBuilder struct {
// contains filtered or unexported fields
}
RulesBuilder orchestrates the construction of papi.Rules from the terraform schema.
func NewBuilder ¶
func NewBuilder(d *schema.ResourceData) *RulesBuilder
NewBuilder returns a new RulesBuilder that uses the provided schema.ResourceData to construct papi.Rules.
type RulesSchemaReader ¶
type RulesSchemaReader struct {
// contains filtered or unexported fields
}
RulesSchemaReader knows how to retrieve data from schema.ResourceData.
func NewRulesSchemaReader ¶
func NewRulesSchemaReader(d *schema.ResourceData) *RulesSchemaReader
NewRulesSchemaReader creates a new RulesSchemaReader for the given schema.ResourceData.
func (*RulesSchemaReader) GetBehaviorsList ¶
func (r *RulesSchemaReader) GetBehaviorsList() ([]RuleItem, error)
GetBehaviorsList reads and returns a slice of RuleItem, which are behaviors.
func (*RulesSchemaReader) GetChildrenList ¶
func (r *RulesSchemaReader) GetChildrenList() ([]string, error)
GetChildrenList reads and returns slice of children.
func (*RulesSchemaReader) GetCriteriaList ¶
func (r *RulesSchemaReader) GetCriteriaList() ([]RuleItem, error)
GetCriteriaList reads and returns a slice of RuleItem, which are rule criteria.
func (*RulesSchemaReader) GetRuleFormat ¶
func (r *RulesSchemaReader) GetRuleFormat() string
GetRuleFormat returns rule format as a string.
func (*RulesSchemaReader) GetVariablesList ¶
func (r *RulesSchemaReader) GetVariablesList() ([]map[string]any, error)
GetVariablesList reads and returns rule variables as slice of map[string]any.
type RulesUpdate ¶ added in v5.1.0
type RulesUpdate struct { RuleFormat string `json:"_ruleFormat_"` papi.RulesUpdate }
RulesUpdate is a helper structure for easier injecting rule format AND preserving the order of fields
type TooManyElementsError ¶
type TooManyElementsError struct {
// contains filtered or unexported fields
}
TooManyElementsError defines an error that is used when too many elements were found in the list.
func (*TooManyElementsError) Error ¶
func (e *TooManyElementsError) Error() string
Error returns TooManyElementsError as a string.
func (*TooManyElementsError) Unwrap ¶
func (e *TooManyElementsError) Unwrap() error
Unwrap unwraps TooManyElementsError into ErrTooManyElements.
type TypeAssertionError ¶
type TypeAssertionError struct {
// contains filtered or unexported fields
}
TypeAssertionError defines an error that is used when type assertion failed.
func (*TypeAssertionError) Error ¶
func (e *TypeAssertionError) Error() string
Error returns TypeAssertionError as a string.
func (*TypeAssertionError) Unwrap ¶
func (e *TypeAssertionError) Unwrap() error
Unwrap unwraps TypeAssertionError into ErrTypeAssertion.