datalist

package
v1.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2020 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResource

func NewResource(config *ResourceConfig) *schema.Resource

Returns a new "data list" resource given the specified configuration. This is a resource with `filter` and `sort` attributes that can select a subset of records from a list of records for a particular type of resource.

Types

type ResourceConfig

type ResourceConfig struct {
	// The schema for a single instance of the resource.
	RecordSchema map[string]*schema.Schema

	// A string slice with the attribute keys on which the filter attribute can operate.
	// The filter attribute operates on all field types except for schema.TypeMap.
	FilterKeys []string

	// A string slice with the attribute keys on which the sort attribute can operate.
	// The sort attribute only operates on the schema.TypeString, schema.TypeBool,
	// schema.TypeInt, and schema.TypeFloat field types.
	SortKeys []string

	// The name of the attribute in the resource through which to expose results.
	ResultAttributeName string

	// Given a record returned from the GetRecords function, flatten the record to a
	// map acceptable to the Set method on schema.ResourceData.
	FlattenRecord func(record, meta interface{}) (map[string]interface{}, error)

	// Return all of the records on which the data list resource should operate.
	// The `meta` argument is the same meta argument passed into the resource's Read
	// function.
	GetRecords func(meta interface{}) ([]interface{}, error)
}

This is the configuration for a "data list" resource. It represents the schema and operations needed to create the data list resource.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL