refactor: jamfpro_computer_prestages.go - clean up ptr usage and add omitempty for optional fields per API spec #974
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change
Reviewed the endpoint and refactored fields to remove excessive pointer usage. Should make it more robust and efficient. Have also ensured optional fields as specified in the API schema are omitted. https://developer.jamf.com/jamf-pro/reference/post_v3-computer-prestages
Added a new skipSetupItems field for OSShowcase.
No changes to methods - only updated types and example scripts as needed.
This will require the provider resource to be refactored to remove pointer handling for fields that no longer require it. Will submit a PR for this shortly.
The main advantage here is future proofing for new fields that appear in skipSetupItems - found that in testing, the API handles any field name supplied here safely. If you try to set one in a request body that doesn't exist in that version of JPro, it's ignored for POST/PUT. This would cause issues previously when using bool pointers.
The API is also tolerant when sending top-level fields introduced in new versions of Jamf Pro well - like PlatformSsoAppBundleId and PssoEnabled introduced in 11.21, the request succeeds and the field is ignored.
Also removed many non-existent fields from ResourceComputerPrestage and the OnboardingItem type which is also not in the API spec.
I have tested against Jamf Pro 11.20, 11.21 and 11.22 with no issues.
Type of Change
Please DELETE options that are not relevant.
Checklist