Skip to content

Commit ef8b8ba

Browse files
authored
Merge pull request #974 from neilmartin83/nm-computer-prestages-2025-11-09
refactor: jamfpro_computer_prestages.go - clean up ptr usage and add omitempty for optional fields per API spec
2 parents 384c946 + 690959c commit ef8b8ba

File tree

6 files changed

+245
-272
lines changed

6 files changed

+245
-272
lines changed

examples/computer_prestages/CreateComputerPrestageFullConfig/CreateComputerPrestageFullConfig.go

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,44 @@ func main() {
2121
// Define the payload for creating a new computer prestage
2222
prestage := jamfpro.ResourceComputerPrestage{
2323
DisplayName: "jamfpro-sdk-example-computerPrestageFull-config",
24-
Mandatory: jamfpro.TruePtr(),
25-
MDMRemovable: jamfpro.TruePtr(),
24+
Mandatory: true,
25+
MDMRemovable: true,
2626
SupportPhoneNumber: "111-222-3333",
2727
SupportEmailAddress: "email@company.com",
2828
Department: "department name",
29-
DefaultPrestage: jamfpro.FalsePtr(),
29+
DefaultPrestage: false,
3030
EnrollmentSiteId: "-1",
31-
KeepExistingSiteMembership: jamfpro.FalsePtr(),
32-
KeepExistingLocationInformation: jamfpro.FalsePtr(),
33-
RequireAuthentication: jamfpro.FalsePtr(),
31+
KeepExistingSiteMembership: false,
32+
KeepExistingLocationInformation: false,
33+
RequireAuthentication: false,
3434
AuthenticationPrompt: "hello welcome to your enterprise managed macOS device",
35-
PreventActivationLock: jamfpro.FalsePtr(),
36-
EnableDeviceBasedActivationLock: jamfpro.FalsePtr(),
35+
PreventActivationLock: false,
36+
EnableDeviceBasedActivationLock: false,
3737
DeviceEnrollmentProgramInstanceId: "1",
3838
SkipSetupItems: jamfpro.ComputerPrestageSubsetSkipSetupItems{
3939
// Selected items are not displayed in the Setup Assistant during enrollment
40-
Biometric: jamfpro.TruePtr(),
41-
TermsOfAddress: jamfpro.TruePtr(),
42-
FileVault: jamfpro.TruePtr(),
43-
ICloudDiagnostics: jamfpro.TruePtr(),
44-
Diagnostics: jamfpro.TruePtr(),
45-
Accessibility: jamfpro.TruePtr(),
46-
AppleID: jamfpro.TruePtr(),
47-
ScreenTime: jamfpro.TruePtr(),
48-
Siri: jamfpro.TruePtr(),
49-
DisplayTone: jamfpro.FalsePtr(), // Deprecated
50-
Restore: jamfpro.TruePtr(),
51-
Appearance: jamfpro.TruePtr(),
52-
Privacy: jamfpro.TruePtr(),
53-
Payment: jamfpro.TruePtr(),
54-
Registration: jamfpro.TruePtr(),
55-
TOS: jamfpro.TruePtr(),
56-
ICloudStorage: jamfpro.TruePtr(),
57-
Location: jamfpro.FalsePtr(),
58-
Intelligence: jamfpro.TruePtr(),
59-
EnableLockdownMode: jamfpro.TruePtr(),
60-
Welcome: jamfpro.TruePtr(),
61-
Wallpaper: jamfpro.TruePtr(),
40+
Biometric: true,
41+
TermsOfAddress: true,
42+
FileVault: true,
43+
ICloudDiagnostics: true,
44+
Diagnostics: true,
45+
Accessibility: true,
46+
AppleID: true,
47+
ScreenTime: true,
48+
Siri: true,
49+
DisplayTone: false, // Deprecated
50+
Restore: true,
51+
Appearance: true,
52+
Privacy: true,
53+
Payment: true,
54+
Registration: true,
55+
TOS: true,
56+
ICloudStorage: true,
57+
Location: false,
58+
Intelligence: true,
59+
EnableLockdownMode: true,
60+
Welcome: true,
61+
Wallpaper: true,
6262
},
6363
LocationInformation: jamfpro.ComputerPrestageSubsetLocationInformation{
6464
ID: "-1", // Required
@@ -74,8 +74,8 @@ func main() {
7474
},
7575
PurchasingInformation: jamfpro.ComputerPrestageSubsetPurchasingInformation{
7676
ID: "-1", // Required
77-
Leased: jamfpro.FalsePtr(),
78-
Purchased: jamfpro.TruePtr(),
77+
Leased: false,
78+
Purchased: true,
7979
AppleCareId: "",
8080
PONumber: "",
8181
Vendor: "",
@@ -89,33 +89,33 @@ func main() {
8989
VersionLock: 0,
9090
},
9191
EnrollmentCustomizationId: "0",
92-
AutoAdvanceSetup: jamfpro.FalsePtr(),
93-
InstallProfilesDuringSetup: jamfpro.TruePtr(),
92+
AutoAdvanceSetup: false,
93+
InstallProfilesDuringSetup: true,
9494
PrestageInstalledProfileIds: []string{},
9595
CustomPackageIds: []string{"1", "2"},
9696
CustomPackageDistributionPointId: "-1", // -2 for all cloud distribution points , -1 for not used, then id for all distribution points
97-
EnableRecoveryLock: jamfpro.FalsePtr(),
97+
EnableRecoveryLock: false,
9898
RecoveryLockPasswordType: "MANUAL",
99-
RotateRecoveryLockPassword: jamfpro.FalsePtr(),
99+
RotateRecoveryLockPassword: false,
100100
PrestageMinimumOsTargetVersionType: "MINIMUM_OS_SPECIFIC_VERSION", // NO_ENFORCEMENT / MINIMUM_OS_LATEST_VERSION / MINIMUM_OS_LATEST_MAJOR_VERSION / MINIMUM_OS_LATEST_MINOR_VERSION / MINIMUM_OS_SPECIFIC_VERSION
101101
MinimumOsSpecificVersion: "14.6", // Required if PrestageMinimumOsTargetVersionType is MINIMUM_OS_SPECIFIC_VERSION
102102
//ProfileUuid: "0386E7C8D455A040106850A8A2033968", // Automated Device Enrollment instance to associate with the PreStage enrollment. Devices associated with the selected Automated Device Enrollment instance can be assigned the PreStage enrollment
103103
SiteId: "-1",
104104
VersionLock: 0,
105105
AccountSettings: jamfpro.ComputerPrestageSubsetAccountSettings{
106-
PayloadConfigured: jamfpro.TruePtr(),
107-
LocalAdminAccountEnabled: jamfpro.TruePtr(),
106+
PayloadConfigured: true,
107+
LocalAdminAccountEnabled: true,
108108
AdminUsername: "testadmin",
109109
AdminPassword: "testpassword",
110-
HiddenAdminAccount: jamfpro.TruePtr(),
111-
LocalUserManaged: jamfpro.FalsePtr(),
110+
HiddenAdminAccount: true,
111+
LocalUserManaged: false,
112112
UserAccountType: "ADMINISTRATOR",
113113
VersionLock: 0,
114-
PrefillPrimaryAccountInfoFeatureEnabled: jamfpro.TruePtr(),
114+
PrefillPrimaryAccountInfoFeatureEnabled: true,
115115
PrefillType: "UNKNOWN", // UNKNOWN / DEVICE_OWNER / CUSTOM
116116
PrefillAccountFullName: "", // Required if PrefillType is CUSTOM
117117
PrefillAccountUserName: "", // Required if PrefillType is CUSTOM
118-
PreventPrefillInfoFromModification: jamfpro.FalsePtr(),
118+
PreventPrefillInfoFromModification: false,
119119
},
120120
}
121121

examples/computer_prestages/CreateComputerPrestageMinimumConfig/CreateComputerPrestageMinimumConfig.go

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,43 @@ func main() {
2121
// Define the payload for creating a new computer prestage
2222
prestage := jamfpro.ResourceComputerPrestage{
2323
DisplayName: "jamfpro-sdk-example-computerPrestageMinimum-config",
24-
Mandatory: jamfpro.TruePtr(),
25-
MDMRemovable: jamfpro.TruePtr(),
24+
Mandatory: true,
25+
MDMRemovable: true,
2626
SupportPhoneNumber: "111-222-3333",
2727
SupportEmailAddress: "email@company.com",
2828
Department: "department name",
29-
DefaultPrestage: jamfpro.FalsePtr(),
29+
DefaultPrestage: false,
3030
EnrollmentSiteId: "-1",
31-
KeepExistingSiteMembership: jamfpro.FalsePtr(),
32-
KeepExistingLocationInformation: jamfpro.FalsePtr(),
33-
RequireAuthentication: jamfpro.FalsePtr(),
31+
KeepExistingSiteMembership: false,
32+
KeepExistingLocationInformation: false,
33+
RequireAuthentication: false,
3434
AuthenticationPrompt: "hello welcome to your enterprise managed macOS device",
35-
PreventActivationLock: jamfpro.FalsePtr(),
36-
EnableDeviceBasedActivationLock: jamfpro.FalsePtr(),
35+
PreventActivationLock: false,
36+
EnableDeviceBasedActivationLock: false,
3737
DeviceEnrollmentProgramInstanceId: "1",
3838
SkipSetupItems: jamfpro.ComputerPrestageSubsetSkipSetupItems{
39-
Biometric: jamfpro.FalsePtr(),
40-
TermsOfAddress: jamfpro.FalsePtr(),
41-
FileVault: jamfpro.FalsePtr(),
42-
ICloudDiagnostics: jamfpro.FalsePtr(),
43-
Diagnostics: jamfpro.FalsePtr(),
44-
Accessibility: jamfpro.FalsePtr(),
45-
AppleID: jamfpro.FalsePtr(),
46-
ScreenTime: jamfpro.FalsePtr(),
47-
Siri: jamfpro.FalsePtr(),
48-
DisplayTone: jamfpro.FalsePtr(),
49-
Restore: jamfpro.FalsePtr(),
50-
Appearance: jamfpro.FalsePtr(),
51-
Privacy: jamfpro.FalsePtr(),
52-
Payment: jamfpro.FalsePtr(),
53-
Registration: jamfpro.FalsePtr(),
54-
TOS: jamfpro.FalsePtr(),
55-
ICloudStorage: jamfpro.FalsePtr(),
56-
Location: jamfpro.FalsePtr(),
57-
Intelligence: jamfpro.FalsePtr(),
58-
EnableLockdownMode: jamfpro.FalsePtr(),
59-
Welcome: jamfpro.FalsePtr(),
60-
Wallpaper: jamfpro.FalsePtr(),
39+
Biometric: false,
40+
TermsOfAddress: false,
41+
FileVault: false,
42+
ICloudDiagnostics: false,
43+
Diagnostics: false,
44+
Accessibility: false,
45+
AppleID: false,
46+
ScreenTime: false,
47+
Siri: false,
48+
DisplayTone: false,
49+
Restore: false,
50+
Appearance: false,
51+
Privacy: false,
52+
Payment: false,
53+
Registration: false,
54+
TOS: false,
55+
ICloudStorage: false,
56+
Location: false,
57+
Intelligence: false,
58+
EnableLockdownMode: false,
59+
Welcome: false,
60+
Wallpaper: false,
6161
},
6262
LocationInformation: jamfpro.ComputerPrestageSubsetLocationInformation{
6363
ID: "-1", // Required
@@ -73,8 +73,8 @@ func main() {
7373
},
7474
PurchasingInformation: jamfpro.ComputerPrestageSubsetPurchasingInformation{
7575
ID: "-1", // Required
76-
Leased: jamfpro.FalsePtr(),
77-
Purchased: jamfpro.TruePtr(),
76+
Leased: false,
77+
Purchased: true,
7878
AppleCareId: "",
7979
PONumber: "",
8080
Vendor: "",
@@ -88,33 +88,33 @@ func main() {
8888
VersionLock: 0, // Not required for creates
8989
},
9090
EnrollmentCustomizationId: "0",
91-
AutoAdvanceSetup: jamfpro.FalsePtr(),
92-
InstallProfilesDuringSetup: jamfpro.TruePtr(),
91+
AutoAdvanceSetup: false,
92+
InstallProfilesDuringSetup: true,
9393
PrestageInstalledProfileIds: []string{},
9494
CustomPackageIds: []string{},
9595
CustomPackageDistributionPointId: "-1", // -2 for all cloud distribution points , -1 for not used, then id for all distribution points
96-
EnableRecoveryLock: jamfpro.FalsePtr(),
96+
EnableRecoveryLock: false,
9797
RecoveryLockPasswordType: "",
9898
RecoveryLockPassword: "",
99-
RotateRecoveryLockPassword: jamfpro.FalsePtr(),
99+
RotateRecoveryLockPassword: false,
100100
PrestageMinimumOsTargetVersionType: "NO_ENFORCEMENT", // NO_ENFORCEMENT / MINIMUM_OS_LATEST_VERSION / MINIMUM_OS_LATEST_MAJOR_VERSION / MINIMUM_OS_LATEST_MINOR_VERSION / MINIMUM_OS_SPECIFIC_VERSION
101101
MinimumOsSpecificVersion: "",
102102
SiteId: "-1",
103103
VersionLock: 0, // Not required for creates
104104
AccountSettings: jamfpro.ComputerPrestageSubsetAccountSettings{
105-
PayloadConfigured: jamfpro.TruePtr(),
106-
LocalAdminAccountEnabled: jamfpro.FalsePtr(),
105+
PayloadConfigured: true,
106+
LocalAdminAccountEnabled: false,
107107
AdminUsername: "",
108108
AdminPassword: "",
109-
HiddenAdminAccount: jamfpro.FalsePtr(),
110-
LocalUserManaged: jamfpro.FalsePtr(),
109+
HiddenAdminAccount: false,
110+
LocalUserManaged: false,
111111
UserAccountType: "ADMINISTRATOR",
112112
VersionLock: 0, // Not required for creates
113-
PrefillPrimaryAccountInfoFeatureEnabled: jamfpro.FalsePtr(),
113+
PrefillPrimaryAccountInfoFeatureEnabled: false,
114114
PrefillType: "UNKNOWN",
115115
PrefillAccountFullName: "",
116116
PrefillAccountUserName: "",
117-
PreventPrefillInfoFromModification: jamfpro.FalsePtr(),
117+
PreventPrefillInfoFromModification: false,
118118
},
119119
}
120120

examples/computer_prestages/GetComputerPrestages/GetComputerPrestages.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
func main() {
1313
// Define the path to the JSON configuration file
14-
configFilePath := "/Users/dafyddwatkins/localtesting/jamfpro/clientconfig.json"
14+
configFilePath := "/Users/Shared/GitHub/go-api-sdk-jamfpro/localtesting/clientconfig.json"
1515

1616
// Initialize the Jamf Pro client with the HTTP client configuration
1717
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
@@ -22,7 +22,6 @@ func main() {
2222
// Define sorting parameters
2323
// For more information on how to add parameters to this request, see docs/url_queries.md
2424
params := url.Values{}
25-
params.Add("sort", "name")
2625

2726
// Fetch computer prestages using the V3 API
2827
prestages, err := client.GetComputerPrestages(params)

0 commit comments

Comments
 (0)