construct

package
v0.3.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugLogGraphObject

func DebugLogGraphObject(ctx context.Context, message string, object serialization.Parsable) error

Helper function to serialize and debug log Microsoft Graph objects that implement serialization.Parsable. This function takes a Microsoft Graph object (like a policy, device configuration, etc.) and converts it into a human-readable JSON format before it gets sent to Microsoft's API. It's like taking a snapshot of what we're about to send.

Parameters:

  • ctx: The context for logging
  • message: A descriptive message that will prefix the JSON in the logs
  • object: Any Microsoft Graph object that implements serialization.Parsable

Returns:

  • error: Any error encountered during serialization or logging

Usage example:

if err := debugLogGraphObject(ctx, "Final JSON to be sent to Graph API", profile); err != nil {
    tflog.Error(ctx, "Failed to debug log object", map[string]interface{}{
        "error": err.Error(),
    })
}

func ParseEnum

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

ParseEnum parses an enum value and sets it if the value is not null or unknown. It accepts a basetypes.StringValue (Terraform SDK type) and uses a parser function to translate the string into an enum type. If the value is valid, it casts the parsed value to the expected type T and passes it to the setter function.

func SetArrayProperty

func SetArrayProperty(values []types.String, setter func([]string))

Add this new helper function to your construct package

func SetBoolProperty

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

SetBoolProperty sets the value of a bool property if the value is not null or unknown. It accepts a basetypes.BoolValue (Terraform SDK type) and translates it into a pointer to a bool for use in the setter function.

func SetInt32Property

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

SetInt32Property sets the value of an int32 property if the value is not null or unknown. It accepts a basetypes.Int32Value (Terraform SDK type) and passes it to the setter function.

func SetInt64Property

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

SetInt64Property sets the value of an int64 property if the value is not null or unknown. It accepts a basetypes.Int64Value (Terraform SDK type) and passes it to the setter function.

func SetStringProperty

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

SetStringProperty sets the value of a string property if the value is not null or unknown. It accepts a basetypes.StringValue (Terraform SDK type) and translates it into a pointer to a string for use in the setter function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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