Documentation
¶
Index ¶
- func GetDateOrDefaultDate(d *schema.ResourceData, key string) string
- func GetHCLStringOrDefaultInteger(d *schema.ResourceData, key string) string
- func GetListFromSet(data map[string]interface{}, key string) []interface{}
- func HandleVersionLock(currentVersionLock interface{}, isUpdate bool) int
- func MapSetToStructs[NestedObjectType any, ListItemPrimitiveType comparable](path string, fieldName string, d *schema.ResourceData, ...) error
- func ParseResourceID(val interface{}, fieldName string, index int) (int, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDateOrDefaultDate ¶ added in v0.20.0
func GetDateOrDefaultDate(d *schema.ResourceData, key string) string
GetDateOrDefaultDate returns the date string if it exists and is not empty, otherwise it returns the default date "1970-01-01".
func GetHCLStringOrDefaultInteger ¶ added in v0.20.0
func GetHCLStringOrDefaultInteger(d *schema.ResourceData, key string) string
GetHCLStringOrDefaultInteger returns the string value from the ResourceData if it exists, otherwise it returns the default value "-1".
func GetListFromSet ¶
GetListFromSet is a helper function to safely extract a list of interfaces from a *schema.Set stored within a map[string]interface{}. It returns an empty slice if the key is not found or the value is not a *schema.Set.
func HandleVersionLock ¶ added in v0.20.0
HandleVersionLock manages the VersionLock field for Jamf Pro Prestage resources during update operations.
https://developer.jamf.com/jamf-pro/docs/optimistic-locking
Parameters:
- currentVersionLock: The current version lock value as an interface{}.
- isUpdate: A boolean flag indicating whether this is an update operation.
Returns:
- An integer representing the version lock to be used in the API request. For create operations (isUpdate == false), this will be 0. For update operations (isUpdate == true), this will be the incremented version lock.
Behavior:
- Create operations (isUpdate == false):
- Returns 0, as version lock is not needed for create operations.
- Update operations (isUpdate == true):
- Attempts to convert the currentVersionLock to an integer and increment it by 1.
- If conversion fails, logs a warning and returns 0.
Error Handling:
- If the currentVersionLock cannot be converted to an integer during an update operation, the function logs a warning and returns 0.
Usage:
- This function should be called for each structure within a resource that requires version lock handling.
func MapSetToStructs ¶
func MapSetToStructs[NestedObjectType any, ListItemPrimitiveType comparable](path string, fieldName string, d *schema.ResourceData, outputSlice *[]NestedObjectType) error
MapSetToStructs transforms a schema.Set of primitive values (typically IDs) into a slice of structs by mapping each value to a specified field in a new struct instance.
Type parameters: - NestedObjectType: The target struct type (e.g., PolicySubsetNetworkSegment) - ListItemPrimitiveType: The primitive value type in the set (e.g., int, string)
The function relies on Terraform's schema validation to ensure values are of the correct type. This is typically used to transform schema.Set elements like IDs to API struct objects.
func ParseResourceID ¶
ParseResourceID ensures a value can be safely used as an ID in Jamf Pro resources. Handles int, float64, and string inputs with appropriate logging for conversion issues. Returns the validated integer ID and a success boolean.
Types ¶
This section is empty.