Documentation ¶
Index ¶
- Constants
- func BuildArrayField(field string) string
- func BuildDefaultModelPath(paths ...string) string
- func BuildModelPath(modelPathSeparator string, paths ...string) string
- type APIModel
- type ArrIndexer
- type BlockSliceToStructSlice
- type BlockSliceToStructSliceField
- type BlockToStruct
- type BlockToStructSlice
- type BlockToStructSliceField
- type EvaluatedField
- type EvaluationFunc
- type EvaluationMode
- type ListToStruct
- type Map
- type TFSchemaModelConverter
- func (converter *TFSchemaModelConverter[T]) ConvertTFSchemaToAPIModel(data *schema.ResourceData, buildOnlyKeys []string) (modelPtr T, err error)
- func (converter *TFSchemaModelConverter[T]) FillTFSchema(modelPtr T, data *schema.ResourceData) error
- func (converter *TFSchemaModelConverter[T]) UnpackSchema(prefix string) *BlockToStruct
Constants ¶
const ( DefaultModelPathSeparator = "|" ArrayFieldMarker = "[]" AllMapKeysFieldMarker = "*" )
Variables ¶
This section is empty.
Functions ¶
func BuildArrayField ¶ added in v1.3.1
func BuildDefaultModelPath ¶ added in v1.3.1
func BuildModelPath ¶ added in v1.3.1
Types ¶
type ArrIndexer ¶
type ArrIndexer struct {
IndicesInts []int
}
func (*ArrIndexer) AppendIndex ¶
func (arrIndex *ArrIndexer) AppendIndex(index int)
func (*ArrIndexer) GetAllIndexes ¶
func (arrIndex *ArrIndexer) GetAllIndexes() []int
func (*ArrIndexer) IncrementLastIndex ¶
func (arrIndex *ArrIndexer) IncrementLastIndex()
func (*ArrIndexer) IsActive ¶
func (arrIndex *ArrIndexer) IsActive() bool
func (*ArrIndexer) New ¶
func (arrIndex *ArrIndexer) New()
func (*ArrIndexer) RemoveLastIndex ¶
func (arrIndex *ArrIndexer) RemoveLastIndex()
type BlockSliceToStructSlice ¶
type BlockSliceToStructSlice []*BlockToStruct
type BlockSliceToStructSliceField ¶ added in v1.4.0
type BlockSliceToStructSliceField struct { Field string Mapping BlockToStructSlice }
BlockSliceToStructSliceField Converts a Terraform Block to a Slice of Swagger Structs (N:N).
type BlockToStruct ¶
type BlockToStruct map[string]interface{}
BlockToStruct Converts a Terraform Block to a Swagger Struct (1:1).
func (*BlockToStruct) Copy ¶ added in v1.4.2
func (currBlock *BlockToStruct) Copy(excludedKeys []string) *BlockToStruct
Copy Creates a copy of a BlockToStruct object. excludeKeys argument can be used to exclude certain keys to be copied.
func (*BlockToStruct) UnpackSchema ¶
func (currBlock *BlockToStruct) UnpackSchema(modelPathSeparator string, mapValue interface{}, prefix string) interface{}
UnpackSchema Unpacks a schema to a higher level schema, useful for data sources which list an individual Swagger API Model.
type BlockToStructSlice ¶
type BlockToStructSlice []*BlockToStruct
type BlockToStructSliceField ¶ added in v1.4.0
type BlockToStructSliceField struct { Field string Mapping BlockToStructSlice }
BlockToStructSliceField Converts a Terraform Block to a Slice of Swagger Structs (1:N).
type EvaluatedField ¶
type EvaluatedField struct { Field string EvalFunc EvaluationFunc }
EvaluatedField If needed to intervene in specific fields, this helps you connect a function to the converter.
type EvaluationFunc ¶
type EvaluationFunc func(EvaluationMode, interface{}) interface{}
type EvaluationMode ¶
type EvaluationMode string
const ( ConstructModel EvaluationMode = "CONSTRUCT_MODEL" ConstructTFSchema EvaluationMode = "CONSTRUCT_TF_SCHEMA" )
type ListToStruct ¶
type ListToStruct []string
ListToStruct Converts a Terraform primitive Slice field to a Slice of Swagger Structs (1:N).
type Map ¶
type Map map[string]interface{}
Map Converts a Terraform Block/Map to Swagger Struct/Map.
type TFSchemaModelConverter ¶
type TFSchemaModelConverter[T APIModel] struct { TFModelMap *BlockToStruct ModelPathSeparator string }
func (*TFSchemaModelConverter[T]) ConvertTFSchemaToAPIModel ¶
func (converter *TFSchemaModelConverter[T]) ConvertTFSchemaToAPIModel(data *schema.ResourceData, buildOnlyKeys []string) (modelPtr T, err error)
ConvertTFSchemaToAPIModel This function converts a given TF Schema data (aka schema.ResourceData) to Swagger API Model. Arguments for the function are: data - a schema.ResourceData object. buildOnlyKeys - a []string for specifying specific keys to be built in the model. keys should be supplied relatively to the Terraform schema structure, for nested keys it should be supplied with a separator. If no keys supplied in the slice, the function will build the entire model.
func (*TFSchemaModelConverter[T]) FillTFSchema ¶
func (converter *TFSchemaModelConverter[T]) FillTFSchema(modelPtr T, data *schema.ResourceData) error
FillTFSchema This function converts a given Swagger API Model to TF Schema data (aka schema.ResourceData) structure and fills the schema. Arguments for the function are: modelPtr - a Swagger API Model object. data - a schema.ResourceData object.
func (*TFSchemaModelConverter[T]) UnpackSchema ¶
func (converter *TFSchemaModelConverter[T]) UnpackSchema(prefix string) *BlockToStruct
UnpackSchema This function helps you create a higher level Schema. It utilizes the implementation of schema unpacking implemented for BlockToStruct types. As an example, if you have converter or converter mapping of an object like Target Location and you need to create another schema for a slice of Target Locations, then you can use the converter or the mapping to unpack the schema for the higher level struct containing the list of Target Locations.