Documentation ¶
Index ¶
- Constants
- func FilterTypeBool(value string) (any, error)
- func FilterTypeInt(value string) (any, error)
- func FilterTypeString(value string) (any, error)
- type Config
- func (f Config) GenerateID(filters []FilterModel) (types.String, diag.Diagnostic)
- func (f Config) GetAndFilter(ctx context.Context, client *linodego.Client, filters []FilterModel, ...) ([]any, diag.Diagnostic)
- func (f Config) GetLatestCreated(elems []any, structField string) ([]any, diag.Diagnostic)
- func (f Config) GetLatestVersion(elems []any, structField string) (any, diag.Diagnostic)
- func (f Config) OrderBySchema() schema.StringAttribute
- func (f Config) OrderSchema() schema.StringAttribute
- func (f Config) Schema() schema.SetNestedBlock
- type FilterAttribute
- type FilterModel
- type FilterTypeFunc
- type FiltersModelType
- type ListFunc
Constants ¶
const ( EXACT = "exact" SUBSTRING = "substring" REGEX = "regex" )
Variables ¶
This section is empty.
Functions ¶
func FilterTypeBool ¶
func FilterTypeInt ¶
func FilterTypeString ¶
Types ¶
type Config ¶
type Config map[string]FilterAttribute
Config is the root configuration type for filter data sources.
func (Config) GenerateID ¶
func (f Config) GenerateID(filters []FilterModel) (types.String, diag.Diagnostic)
GenerateID will generate a unique ID from the given filters.
func (Config) GetAndFilter ¶
func (f Config) GetAndFilter( ctx context.Context, client *linodego.Client, filters []FilterModel, listFunc ListFunc, order types.String, orderBy types.String, ) ([]any, diag.Diagnostic)
GetAndFilter will run all filter operations given the parameters and return a list of API response objects.
func (Config) GetLatestCreated ¶
GetLatestCreated is a helper function that returns the latest create entry in the input slice.
func (Config) GetLatestVersion ¶
GetLatestVersion gets the latest version of the given struct
func (Config) OrderBySchema ¶
func (f Config) OrderBySchema() schema.StringAttribute
OrderBySchema returns the schema for the top-level `order_by` field.
func (Config) OrderSchema ¶
func (f Config) OrderSchema() schema.StringAttribute
OrderSchema returns the schema for the top-level `order` field.
func (Config) Schema ¶
func (f Config) Schema() schema.SetNestedBlock
Schema returns the schema that should be used for the `filter` attribute in list data sources.
type FilterAttribute ¶
type FilterAttribute struct { // Whether this field can be filtered on at an API level. // If false, this filter will be handled on the client. APIFilterable bool // Converts the filter string to the correct type. TypeFunc FilterTypeFunc // (Optional) Allows this attribute during validation // for the order and order_by fields. // This is useful for edge cases where we want order // through the API but filter on the client. AllowOrderOverride bool }
FilterAttribute is used to configure filtering for an individual response field.
type FilterModel ¶
type FilterModel struct { Name types.String `tfsdk:"name" json:"name"` Values []types.String `tfsdk:"values" json:"values"` MatchBy types.String `tfsdk:"match_by" json:"match_by"` }
FilterModel describes the Terraform resource data model to match the resource schema.
type FilterTypeFunc ¶
FilterTypeFunc is a function that takes in a filter name and value, and returns the value converted to the correct filter type.
type FiltersModelType ¶
type FiltersModelType []FilterModel
FiltersModelType should be used for the `filter` attribute in list data sources.