convert

package
v0.23.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FrameworkToGraphBitmaskEnum

func FrameworkToGraphBitmaskEnum[T any](value basetypes.StringValue, parser func(string) (any, error), setter func(*T)) error

FrameworkToGraphBitmaskEnum parses a Terraform Framework string as a bitmask-style enum and sets a Graph SDK enum property. Expects the parser to return a pointer to the enum type. Returns an error if parsing or type assertion fails. No-op if the value is null or unknown.

func FrameworkToGraphBitmaskEnumFromSet

func FrameworkToGraphBitmaskEnumFromSet[T any](
	ctx context.Context,
	set types.Set,
	parser func(string) (any, error),
	setter func(*T)) error

FrameworkToGraphBitmaskEnumFromSet converts a Terraform Framework set of strings to a bitmask enum. This is useful for APIs that use bitmask enums with String() methods that return comma-separated values. The function joins the set elements with commas, parses the result using the provided parser function, and sets the resulting enum using the provided setter function. Returns an error if parsing fails. No-op if the set is null or unknown.

func FrameworkToGraphBool

func FrameworkToGraphBool(value basetypes.BoolValue, setter func(*bool))

FrameworkToGraphBool sets a Graph SDK bool property from a Terraform Framework bool. Only sets the value if it's not null or unknown.

func FrameworkToGraphBytes

func FrameworkToGraphBytes(value basetypes.StringValue, setter func([]byte))

FrameworkToGraphBytes converts a Terraform Framework string to bytes and sets a Graph SDK byte slice property. Only sets the value if it's not null or unknown.

func FrameworkToGraphDateOnly

func FrameworkToGraphDateOnly(value basetypes.StringValue, setter func(*serialization.DateOnly)) error

FrameworkToGraphDateOnly parses a Terraform Framework string as a date and sets a Graph SDK DateOnly property. Returns an error if parsing fails. No-op if the value is null, unknown, or empty.

func FrameworkToGraphEnum

func FrameworkToGraphEnum[T any](value basetypes.StringValue, parser func(string) (any, error), setter func(T)) error

FrameworkToGraphEnum parses a Terraform Framework string as an enum and sets a Graph SDK enum property. Uses a parser function to convert the string to the enum type. Returns an error if parsing or type assertion fails. No-op if the value is null or unknown.

func FrameworkToGraphISODuration

func FrameworkToGraphISODuration(value basetypes.StringValue, setter func(*serialization.ISODuration)) error

FrameworkToGraphISODuration parses a Terraform Framework string as ISO 8601 duration and sets a Graph SDK ISODuration property. Returns an error if parsing fails. No-op if the value is null, unknown, or empty.

func FrameworkToGraphInt32

func FrameworkToGraphInt32(value basetypes.Int32Value, setter func(*int32))

FrameworkToGraphInt32 sets a Graph SDK int32 property from a Terraform Framework int32. Only sets the value if it's not null or unknown.

func FrameworkToGraphInt64

func FrameworkToGraphInt64(value basetypes.Int64Value, setter func(*int64))

FrameworkToGraphInt64 sets a Graph SDK int64 property from a Terraform Framework int64. Only sets the value if it's not null or unknown.

func FrameworkToGraphObjectsFromStringSet

func FrameworkToGraphObjectsFromStringSet[T any](
	ctx context.Context,
	set types.Set,
	converter func(context.Context, []string) []T,
	setter func([]T)) error

FrameworkToGraphObjectsFromStringSet is a generic function that converts a Terraform Framework string set to objects. Extracts string values from the set, passes them to a converter function to transform them into the desired object type, and then sets them using the provided setter function.

func FrameworkToGraphString

func FrameworkToGraphString(value basetypes.StringValue, setter func(*string))

FrameworkToGraphString sets a Graph SDK string property from a Terraform Framework string. Only sets the value if it's not null or unknown.

func FrameworkToGraphStringList

func FrameworkToGraphStringList(ctx context.Context, list types.List, setter func([]string)) error

FrameworkToGraphStringList converts a Terraform Framework list to a string slice and sets a Graph SDK string slice property. Returns an error if list elements are not strings. Sets nil if the list is null or unknown.

func FrameworkToGraphStringSet

func FrameworkToGraphStringSet(ctx context.Context, set types.Set, setter func([]string)) error

FrameworkToGraphStringSet converts a Terraform Framework set to a string slice and sets a Graph SDK string slice property. Returns an error if set elements are not strings. Sets nil if the set is null or unknown.

func FrameworkToGraphTime

func FrameworkToGraphTime(value basetypes.StringValue, setter func(*time.Time)) error

FrameworkToGraphTime parses a Terraform Framework string as RFC3339 time and sets a Graph SDK time property. Returns an error if parsing fails. No-op if the value is null, unknown, empty, or zero-value time.

func FrameworkToGraphTimeOnly

func FrameworkToGraphTimeOnly(value types.String, setter func(*serialization.TimeOnly)) error

Supports various time formats with different nanosecond precision levels (HH:MM:SS, HH:MM:SS.fff, etc.). Returns an error if parsing fails. No-op if the value is null, unknown, or empty.

func FrameworkToGraphTimeOnlyWithPrecision

func FrameworkToGraphTimeOnlyWithPrecision(value types.String, precision int, setter func(*serialization.TimeOnly)) error

FrameworkToGraphTimeOnlyWithPrecision parses a Terraform Framework string as time with explicit precision control. Supports various time formats and allows specifying the desired output precision. precision: 0-9, where 0 = HH:MM:SS, 1 = HH:MM:SS.f, 2 = HH:MM:SS.ff, etc.

func FrameworkToGraphUUID

func FrameworkToGraphUUID(value basetypes.StringValue, setter func(*uuid.UUID)) error

FrameworkToGraphUUID parses a Terraform Framework string as UUID and sets a Graph SDK UUID property. Returns an error if parsing fails. No-op if the value is null, unknown, or empty.

func GraphToFrameworkBitmaskEnumAsSet

func GraphToFrameworkBitmaskEnumAsSet[T fmt.Stringer](ctx context.Context, value *T) types.Set

GraphToFrameworkBitmaskEnumAsSet converts a bitmask enum to a Terraform Framework set of strings. This is useful for APIs that use bitmask enums with String() methods that return comma-separated values. The function calls the String() method on the enum, splits the result by commas, and creates a set. Returns types.SetNull() if the input is nil.

func GraphToFrameworkBool

func GraphToFrameworkBool(value *bool) types.Bool

GraphToFrameworkBool converts a Graph SDK bool pointer to a Terraform Framework bool. Returns types.BoolNull() if the input is nil.

func GraphToFrameworkBoolWithDefault

func GraphToFrameworkBoolWithDefault(value *bool, defaultValue bool) types.Bool

GraphToFrameworkBoolWithDefault converts a Graph SDK bool pointer to a Terraform Framework bool. Returns the default value if the pointer is nil.

func GraphToFrameworkBytes

func GraphToFrameworkBytes(value []byte) types.String

GraphToFrameworkBytes converts a Graph SDK byte slice to a Terraform Framework string. Returns types.StringNull() if the input is nil. This is useful for script content which is stored as []byte but needs to be represented as a string.

func GraphToFrameworkDateOnly

func GraphToFrameworkDateOnly(value *serialization.DateOnly) types.String

GraphToFrameworkDateOnly converts a Graph SDK DateOnly pointer to a Terraform Framework string. Returns types.StringNull() if the input is nil.

func GraphToFrameworkEnum

func GraphToFrameworkEnum[T fmt.Stringer](value *T) types.String

GraphToFrameworkEnum converts a Graph SDK enum pointer to a Terraform Framework string. Uses the String() method of the enum type to convert the value to a string. Returns types.StringNull() if the input is nil.

func GraphToFrameworkEnumPtrSlice

func GraphToFrameworkEnumPtrSlice[T fmt.Stringer](value []*T) []types.String

GraphToFrameworkEnumPtrSlice converts a Graph SDK enum pointer slice to a slice of Terraform Framework strings. Uses the String() method of the enum type to convert each value to a string. Returns types.StringNull() for nil pointers in the slice.

func GraphToFrameworkEnumSlice

func GraphToFrameworkEnumSlice[T fmt.Stringer](value []T) []types.String

GraphToFrameworkEnumSlice converts a Graph SDK enum slice to a slice of Terraform Framework strings. Uses the String() method of the enum type to convert each value to a string. Returns nil if the input is nil.

func GraphToFrameworkFloat64

func GraphToFrameworkFloat64(value *float64) types.Float64

GraphToFrameworkFloat64 converts a Graph SDK float64 pointer to a Terraform Framework float64. Returns types.Float64Null() if the input is nil.

func GraphToFrameworkISODuration

func GraphToFrameworkISODuration(value *serialization.ISODuration) types.String

GraphToFrameworkISODuration converts a Graph SDK ISODuration pointer to a Terraform Framework string. Returns types.StringNull() if the input is nil. This function preserves the original ISO 8601 duration format as much as possible to avoid normalization issues (e.g., P7D becoming P1W) that can cause Terraform state inconsistencies.

func GraphToFrameworkInt32

func GraphToFrameworkInt32(value *int32) types.Int32

GraphToFrameworkInt32 converts a Graph SDK int32 pointer to a Terraform Framework int32. Returns types.Int32Null() if the input is nil.

func GraphToFrameworkInt32AsInt64

func GraphToFrameworkInt32AsInt64(value *int32) types.Int64

GraphToFrameworkInt32AsInt64 converts a Graph SDK int32 pointer to a Terraform Framework int64. This is useful when the Graph API uses int32 but Terraform schema expects int64. Returns types.Int64Null() if the input is nil.

func GraphToFrameworkInt64

func GraphToFrameworkInt64(value *int64) types.Int64

GraphToFrameworkInt64 converts a Graph SDK int64 pointer to a Terraform Framework int64. Returns types.Int64Null() if the input is nil.

func GraphToFrameworkString

func GraphToFrameworkString(value *string) types.String

GraphToFrameworkString converts a Graph SDK string pointer to a Terraform Framework string. Returns types.StringNull() if the input is nil.

func GraphToFrameworkStringList

func GraphToFrameworkStringList(value []string) types.List

GraphToFrameworkStringList converts a Graph SDK string slice to a Terraform Framework list. Returns an empty list if the input is nil or empty.

func GraphToFrameworkStringSet

func GraphToFrameworkStringSet(ctx context.Context, value []string) types.Set

GraphToFrameworkStringSet converts a Graph SDK string slice to a Terraform Framework set. Returns types.SetNull() if the input is empty.

func GraphToFrameworkStringSetPreserveEmpty

func GraphToFrameworkStringSetPreserveEmpty(ctx context.Context, value []string) types.Set

GraphToFrameworkStringSetPreserveEmpty converts a string slice to a Terraform Framework set, preserving empty arrays as empty sets instead of null. This is specifically needed for resources using HTTP clients (not Graph SDK) where we need to distinguish between: - Fields that were configured in Terraform as empty arrays [] → should become empty sets - Fields that were not configured in Terraform at all → should remain null

Use this helper when you need to maintain state consistency for optional set attributes that can be explicitly set to empty in Terraform configuration.

func GraphToFrameworkStringSlice

func GraphToFrameworkStringSlice(value []string) []types.String

GraphToFrameworkStringSlice converts a Graph SDK string slice to a slice of Terraform Framework strings. Returns an empty slice if the input is nil or empty.

func GraphToFrameworkStringWithDefault

func GraphToFrameworkStringWithDefault(value *string, defaultValue string) types.String

GraphToFrameworkStringWithDefault converts a Graph SDK string pointer to a Terraform Framework string. Returns the default value if the pointer is nil or points to an empty string.

func GraphToFrameworkTime

func GraphToFrameworkTime(value *time.Time) types.String

GraphToFrameworkTime converts a Graph SDK time pointer to a Terraform Framework string. Returns types.StringNull() if the input is nil. Time is formatted using RFC3339 format.

func GraphToFrameworkTimeOnly

func GraphToFrameworkTimeOnly(value *serialization.TimeOnly) types.String

GraphToFrameworkTimeOnly converts a Graph SDK TimeOnly pointer to a Terraform Framework string. Returns types.StringNull() if the input is nil. Uses default formatting with seconds precision (HH:MM:SS).

func GraphToFrameworkTimeOnlyWithPrecision

func GraphToFrameworkTimeOnlyWithPrecision(value *serialization.TimeOnly, precision int) types.String

GraphToFrameworkTimeOnlyWithPrecision converts a Graph SDK TimeOnly pointer to a Terraform Framework string with the specified precision. Returns types.StringNull() if the input is nil. precision: 0-9, where 0 = HH:MM:SS, 1 = HH:MM:SS.f, 2 = HH:MM:SS.ff, etc.

func GraphToFrameworkUUID

func GraphToFrameworkUUID(value *uuid.UUID) types.String

GraphToFrameworkUUID converts a Graph SDK UUID pointer to a Terraform Framework string. Returns types.StringNull() if the input is nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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