lucirpcglue

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Overview

This package contains "glue" code for working with the lucirpc package from Terraform.

Index

Constants

View Source
const (
	DataSourceTerraformType = "data_source"

	ResourceTerraformType = "resource"
)

Variables

This section is empty.

Functions

func AnyBool added in v0.0.8

func AnyBool(validators ...validator.Bool) validator.Bool

AnyBool returns a validator which ensures that any configured attribute value passes at least one of the given validators.

func CreateSection

func CreateSection(
	ctx context.Context,
	client lucirpc.Client,
	config string,
	sectionType string,
	section string,
	options lucirpc.Options,
) diag.Diagnostics

CreateSection attempts to create a new section. Any diagnostic information found in the process (including errors) is returned.

func DeleteSection

func DeleteSection(
	ctx context.Context,
	client lucirpc.Client,
	config string,
	section string,
) diag.Diagnostics

DeleteSection attempts to delete an existing section. Any diagnostic information found in the process (including errors) is returned.

func GenerateUpsertBody added in v0.0.5

func GenerateUpsertBody[Model any](
	ctx context.Context,
	fullTypeName string,
	model Model,
	attributes map[string]SchemaAttribute[Model, lucirpc.Options, lucirpc.Options],
) (context.Context, lucirpc.Options, diag.Diagnostics)

func GetMetadataString

func GetMetadataString(
	ctx context.Context,
	fullTypeName string,
	terraformType string,
	section lucirpc.Options,
	key string,
) (context.Context, types.String, diag.Diagnostics)

GetMetadataString attempts to parse the given metadata key from the section as a string. Any diagnostic information found in the process (including errors) is returned.

func GetOptionBool

func GetOptionBool(
	ctx context.Context,
	fullTypeName string,
	terraformType string,
	section lucirpc.Options,
	attribute path.Path,
	option string,
) (context.Context, types.Bool, diag.Diagnostics)

GetOptionBool attempts to parse the given option from the section as a bool. Any diagnostic information found in the process (including errors) is returned.

func GetOptionInt64

func GetOptionInt64(
	ctx context.Context,
	fullTypeName string,
	terraformType string,
	section lucirpc.Options,
	attribute path.Path,
	option string,
) (context.Context, types.Int64, diag.Diagnostics)

GetOptionInt64 attempts to parse the given option from the section as an int64. Any diagnostic information found in the process (including errors) is returned.

func GetOptionListString added in v0.0.7

func GetOptionListString(
	ctx context.Context,
	fullTypeName string,
	terraformType string,
	section lucirpc.Options,
	attribute path.Path,
	option string,
) (context.Context, types.List, diag.Diagnostics)

GetOptionListString attempts to parse the given option from the section as a []string. Any diagnostic information found in the process (including errors) is returned.

func GetOptionSetString added in v0.0.4

func GetOptionSetString(
	ctx context.Context,
	fullTypeName string,
	terraformType string,
	section lucirpc.Options,
	attribute path.Path,
	option string,
) (context.Context, types.Set, diag.Diagnostics)

GetOptionSetString attempts to parse the given option from the section as a []string. Any diagnostic information found in the process (including errors) is returned.

func GetOptionString

func GetOptionString(
	ctx context.Context,
	fullTypeName string,
	terraformType string,
	section lucirpc.Options,
	attribute path.Path,
	option string,
) (context.Context, types.String, diag.Diagnostics)

GetOptionString attempts to parse the given option from the section as a string. Any diagnostic information found in the process (including errors) is returned.

func GetSection

func GetSection(
	ctx context.Context,
	client lucirpc.Client,
	config string,
	section string,
) (lucirpc.Options, diag.Diagnostics)

GetMetadataString attempts to parse the given metadata key from the section. Any diagnostic information found in the process (including errors) is returned.

func NewDataSource added in v0.0.5

func NewDataSource[Model any](
	getId func(Model) types.String,
	schemaAttributes map[string]SchemaAttribute[Model, lucirpc.Options, lucirpc.Options],
	schemaDescription string,
	uciConfig string,
	uciType string,
) datasource.DataSource

func NewResource added in v0.0.5

func NewResource[Model any](
	getId func(Model) types.String,
	schemaAttributes map[string]SchemaAttribute[Model, lucirpc.Options, lucirpc.Options],
	schemaDescription string,
	uciConfig string,
	uciType string,
) frameworkresource.Resource

func ReadModel added in v0.0.5

func ReadModel[Model any](
	ctx context.Context,
	fullTypeName string,
	terraformType string,
	client lucirpc.Client,
	attributes map[string]SchemaAttribute[Model, lucirpc.Options, lucirpc.Options],
	uciConfig string,
	uciSection string,
) (context.Context, Model, diag.Diagnostics)

func ReadResponseOptionBool added in v0.0.3

func ReadResponseOptionBool[Model any](
	set func(*Model, types.Bool),
	attribute string,
	option string,
) func(context.Context, string, string, lucirpc.Options, Model) (context.Context, Model, diag.Diagnostics)

func ReadResponseOptionInt64 added in v0.0.3

func ReadResponseOptionInt64[Model any](
	set func(*Model, types.Int64),
	attribute string,
	option string,
) func(context.Context, string, string, lucirpc.Options, Model) (context.Context, Model, diag.Diagnostics)

func ReadResponseOptionListString added in v0.0.7

func ReadResponseOptionListString[Model any](
	set func(*Model, types.List),
	attribute string,
	option string,
) func(context.Context, string, string, lucirpc.Options, Model) (context.Context, Model, diag.Diagnostics)

func ReadResponseOptionSetString added in v0.0.4

func ReadResponseOptionSetString[Model any](
	set func(*Model, types.Set),
	attribute string,
	option string,
) func(context.Context, string, string, lucirpc.Options, Model) (context.Context, Model, diag.Diagnostics)

func ReadResponseOptionString added in v0.0.3

func ReadResponseOptionString[Model any](
	set func(*Model, types.String),
	attribute string,
	option string,
) func(context.Context, string, string, lucirpc.Options, Model) (context.Context, Model, diag.Diagnostics)

func RequiredIfAttributeNotEqualBool added in v0.0.18

func RequiredIfAttributeNotEqualBool(
	expression path.Expression,
	expected bool,
) requiredIfAttributeNot[bool]

func RequiresAttributeEqualBool added in v0.0.4

func RequiresAttributeEqualBool(
	expression path.Expression,
	expected bool,
) requiresAttribute[bool]

func RequiresAttributeEqualString added in v0.0.4

func RequiresAttributeEqualString(
	expression path.Expression,
	expected string,
) requiresAttribute[string]

func UpdateSection

func UpdateSection(
	ctx context.Context,
	client lucirpc.Client,
	config string,
	section string,
	options lucirpc.Options,
) diag.Diagnostics

UpdateSection attempts to update an existing section. Any diagnostic information found in the process (including errors) is returned.

func UpsertRequestOptionBool added in v0.0.3

func UpsertRequestOptionBool[Model any](
	get func(Model) types.Bool,
	attribute string,
	option string,
) func(context.Context, string, lucirpc.Options, Model) (context.Context, lucirpc.Options, diag.Diagnostics)

func UpsertRequestOptionInt64 added in v0.0.3

func UpsertRequestOptionInt64[Model any](
	get func(Model) types.Int64,
	attribute string,
	option string,
) func(context.Context, string, lucirpc.Options, Model) (context.Context, lucirpc.Options, diag.Diagnostics)

func UpsertRequestOptionListString added in v0.0.7

func UpsertRequestOptionListString[Model any](
	get func(Model) types.List,
	attribute string,
	option string,
) func(context.Context, string, lucirpc.Options, Model) (context.Context, lucirpc.Options, diag.Diagnostics)

func UpsertRequestOptionSetString added in v0.0.4

func UpsertRequestOptionSetString[Model any](
	get func(Model) types.Set,
	attribute string,
	option string,
) func(context.Context, string, lucirpc.Options, Model) (context.Context, lucirpc.Options, diag.Diagnostics)

func UpsertRequestOptionString added in v0.0.3

func UpsertRequestOptionString[Model any](
	get func(Model) types.String,
	attribute string,
	option string,
) func(context.Context, string, lucirpc.Options, Model) (context.Context, lucirpc.Options, diag.Diagnostics)

Types

type AttributeExistence added in v0.0.3

type AttributeExistence int
const (
	ReadOnly AttributeExistence = iota
	NoValidation
	Optional
	Required

	IdAttribute = "id"
)

func (AttributeExistence) ToComputed added in v0.0.3

func (e AttributeExistence) ToComputed() bool

func (AttributeExistence) ToOptional added in v0.0.3

func (e AttributeExistence) ToOptional() bool

func (AttributeExistence) ToRequired added in v0.0.3

func (e AttributeExistence) ToRequired() bool

type BoolSchemaAttribute added in v0.0.3

type BoolSchemaAttribute[Model any, Request any, Response any] struct {
	DataSourceExistence AttributeExistence
	DeprecationMessage  string
	Description         string
	MarkdownDescription string
	ReadResponse        func(context.Context, string, string, Response, Model) (context.Context, Model, diag.Diagnostics)
	ResourceExistence   AttributeExistence
	Sensitive           bool
	UpsertRequest       func(context.Context, string, Request, Model) (context.Context, Request, diag.Diagnostics)
	Validators          []validator.Bool
}

func (BoolSchemaAttribute[Model, Request, Response]) Read added in v0.0.3

func (a BoolSchemaAttribute[Model, Request, Response]) Read(
	ctx context.Context,
	fullTypeName string,
	terraformType string,
	response Response,
	model Model,
) (context.Context, Model, diag.Diagnostics)

func (BoolSchemaAttribute[Model, Request, Response]) ToDataSource added in v0.0.3

func (a BoolSchemaAttribute[Model, Request, Response]) ToDataSource() datasourceschema.Attribute

func (BoolSchemaAttribute[Model, Request, Response]) ToResource added in v0.0.3

func (a BoolSchemaAttribute[Model, Request, Response]) ToResource() resourceschema.Attribute

func (BoolSchemaAttribute[Model, Request, Response]) Upsert added in v0.0.3

func (a BoolSchemaAttribute[Model, Request, Response]) Upsert(
	ctx context.Context,
	fullTypeName string,
	request Request,
	model Model,
) (context.Context, Request, diag.Diagnostics)

type ConfigureRequest

type ConfigureRequest struct {
	ProviderData any
}

type Int64SchemaAttribute added in v0.0.3

type Int64SchemaAttribute[Model any, Request any, Response any] struct {
	DataSourceExistence AttributeExistence
	DeprecationMessage  string
	Description         string
	MarkdownDescription string
	ReadResponse        func(context.Context, string, string, Response, Model) (context.Context, Model, diag.Diagnostics)
	ResourceExistence   AttributeExistence
	Sensitive           bool
	UpsertRequest       func(context.Context, string, Request, Model) (context.Context, Request, diag.Diagnostics)
	Validators          []validator.Int64
}

func (Int64SchemaAttribute[Model, Request, Response]) Read added in v0.0.3

func (a Int64SchemaAttribute[Model, Request, Response]) Read(
	ctx context.Context,
	fullTypeName string,
	terraformType string,
	response Response,
	model Model,
) (context.Context, Model, diag.Diagnostics)

func (Int64SchemaAttribute[Model, Request, Response]) ToDataSource added in v0.0.3

func (a Int64SchemaAttribute[Model, Request, Response]) ToDataSource() datasourceschema.Attribute

func (Int64SchemaAttribute[Model, Request, Response]) ToResource added in v0.0.3

func (a Int64SchemaAttribute[Model, Request, Response]) ToResource() resourceschema.Attribute

func (Int64SchemaAttribute[Model, Request, Response]) Upsert added in v0.0.3

func (a Int64SchemaAttribute[Model, Request, Response]) Upsert(
	ctx context.Context,
	fullTypeName string,
	request Request,
	model Model,
) (context.Context, Request, diag.Diagnostics)

type ListStringSchemaAttribute added in v0.0.7

type ListStringSchemaAttribute[Model any, Request any, Response any] struct {
	DataSourceExistence AttributeExistence
	DeprecationMessage  string
	Description         string
	MarkdownDescription string
	ReadResponse        func(context.Context, string, string, Response, Model) (context.Context, Model, diag.Diagnostics)
	ResourceExistence   AttributeExistence
	Sensitive           bool
	UpsertRequest       func(context.Context, string, Request, Model) (context.Context, Request, diag.Diagnostics)
	Validators          []validator.List
}

func (ListStringSchemaAttribute[Model, Request, Response]) Read added in v0.0.7

func (a ListStringSchemaAttribute[Model, Request, Response]) Read(
	ctx context.Context,
	fullTypeName string,
	terraformType string,
	response Response,
	model Model,
) (context.Context, Model, diag.Diagnostics)

func (ListStringSchemaAttribute[Model, Request, Response]) ToDataSource added in v0.0.7

func (a ListStringSchemaAttribute[Model, Request, Response]) ToDataSource() datasourceschema.Attribute

func (ListStringSchemaAttribute[Model, Request, Response]) ToResource added in v0.0.7

func (a ListStringSchemaAttribute[Model, Request, Response]) ToResource() resourceschema.Attribute

func (ListStringSchemaAttribute[Model, Request, Response]) Upsert added in v0.0.7

func (a ListStringSchemaAttribute[Model, Request, Response]) Upsert(
	ctx context.Context,
	fullTypeName string,
	request Request,
	model Model,
) (context.Context, Request, diag.Diagnostics)

type ProviderData added in v0.0.5

type ProviderData struct {
	Client   lucirpc.Client
	TypeName string
}

func NewProviderData added in v0.0.5

func NewProviderData(
	client lucirpc.Client,
	typeName string,
) ProviderData

func ParseProviderData added in v0.0.5

func ParseProviderData(
	req ConfigureRequest,
) (ProviderData, diag.Diagnostics)

ParseProviderData attempts to extract a ProviderData from the given ConfigureRequest. Any diagnostic information found in the process (including errors) is returned.

type SchemaAttribute added in v0.0.3

type SchemaAttribute[Model any, Request any, Response any] interface {
	Read(context.Context, string, string, Response, Model) (context.Context, Model, diag.Diagnostics)
	ToDataSource() datasourceschema.Attribute
	ToResource() resourceschema.Attribute
	Upsert(context.Context, string, Request, Model) (context.Context, Request, diag.Diagnostics)
}

func IdSchemaAttribute added in v0.0.5

func IdSchemaAttribute[Model any](
	get func(Model) types.String,
	set func(*Model, types.String),
) SchemaAttribute[Model, lucirpc.Options, lucirpc.Options]

type SetStringSchemaAttribute added in v0.0.4

type SetStringSchemaAttribute[Model any, Request any, Response any] struct {
	DataSourceExistence AttributeExistence
	DeprecationMessage  string
	Description         string
	MarkdownDescription string
	ReadResponse        func(context.Context, string, string, Response, Model) (context.Context, Model, diag.Diagnostics)
	ResourceExistence   AttributeExistence
	Sensitive           bool
	UpsertRequest       func(context.Context, string, Request, Model) (context.Context, Request, diag.Diagnostics)
	Validators          []validator.Set
}

func (SetStringSchemaAttribute[Model, Request, Response]) Read added in v0.0.4

func (a SetStringSchemaAttribute[Model, Request, Response]) Read(
	ctx context.Context,
	fullTypeName string,
	terraformType string,
	response Response,
	model Model,
) (context.Context, Model, diag.Diagnostics)

func (SetStringSchemaAttribute[Model, Request, Response]) ToDataSource added in v0.0.4

func (a SetStringSchemaAttribute[Model, Request, Response]) ToDataSource() datasourceschema.Attribute

func (SetStringSchemaAttribute[Model, Request, Response]) ToResource added in v0.0.4

func (a SetStringSchemaAttribute[Model, Request, Response]) ToResource() resourceschema.Attribute

func (SetStringSchemaAttribute[Model, Request, Response]) Upsert added in v0.0.4

func (a SetStringSchemaAttribute[Model, Request, Response]) Upsert(
	ctx context.Context,
	fullTypeName string,
	request Request,
	model Model,
) (context.Context, Request, diag.Diagnostics)

type StringSchemaAttribute added in v0.0.3

type StringSchemaAttribute[Model any, Request any, Response any] struct {
	DataSourceExistence AttributeExistence
	DeprecationMessage  string
	Description         string
	MarkdownDescription string
	ReadResponse        func(context.Context, string, string, Response, Model) (context.Context, Model, diag.Diagnostics)
	ResourceExistence   AttributeExistence
	Sensitive           bool
	UpsertRequest       func(context.Context, string, Request, Model) (context.Context, Request, diag.Diagnostics)
	Validators          []validator.String
}

func (StringSchemaAttribute[Model, Request, Response]) Read added in v0.0.3

func (a StringSchemaAttribute[Model, Request, Response]) Read(
	ctx context.Context,
	fullTypeName string,
	terraformType string,
	response Response,
	model Model,
) (context.Context, Model, diag.Diagnostics)

func (StringSchemaAttribute[Model, Request, Response]) ToDataSource added in v0.0.3

func (a StringSchemaAttribute[Model, Request, Response]) ToDataSource() datasourceschema.Attribute

func (StringSchemaAttribute[Model, Request, Response]) ToResource added in v0.0.3

func (a StringSchemaAttribute[Model, Request, Response]) ToResource() resourceschema.Attribute

func (StringSchemaAttribute[Model, Request, Response]) Upsert added in v0.0.3

func (a StringSchemaAttribute[Model, Request, Response]) Upsert(
	ctx context.Context,
	fullTypeName string,
	request Request,
	model Model,
) (context.Context, Request, diag.Diagnostics)

Jump to

Keyboard shortcuts

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