-
Notifications
You must be signed in to change notification settings - Fork 5
/
CreateComputerPrestageMinimumConfig.go
152 lines (142 loc) · 5.19 KB
/
CreateComputerPrestageMinimumConfig.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client"
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
)
func main() {
// Define the path to the JSON configuration file
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
// Load the client OAuth credentials from the configuration file
authConfig, err := jamfpro.LoadAuthConfig(configFilePath)
if err != nil {
log.Fatalf("Failed to load client OAuth configuration: %v", err)
}
// Instantiate the default logger and set the desired log level
logLevel := http_client.LogLevelWarning // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug
// Configuration for the jamfpro
config := http_client.Config{
InstanceName: authConfig.InstanceName,
Auth: http_client.AuthConfig{
ClientID: authConfig.ClientID,
ClientSecret: authConfig.ClientSecret,
},
LogLevel: logLevel,
}
// Create a new jamfpro client instance
client, err := jamfpro.NewClient(config)
if err != nil {
log.Fatalf("Failed to create Jamf Pro client: %v", err)
}
// Define the payload for creating a new computer prestage
// Manually create a ResourceComputerPrestage struct with mapped values
prestage := jamfpro.ResourceComputerPrestage{
DisplayName: "jamfpro-sdk-example-computerPrestage-config",
Mandatory: true,
MDMRemovable: false,
SupportPhoneNumber: "",
SupportEmailAddress: "",
Department: "",
DefaultPrestage: false,
EnrollmentSiteId: "-1",
KeepExistingSiteMembership: false,
KeepExistingLocationInformation: false,
RequireAuthentication: false,
AuthenticationPrompt: "",
PreventActivationLock: true,
EnableDeviceBasedActivationLock: false,
DeviceEnrollmentProgramInstanceId: "1",
SkipSetupItems: jamfpro.ComputerPrestageSubsetSkipSetupItems{
Accessibility: true,
Appearance: true,
AppleID: true,
Biometric: true,
Diagnostics: true,
DisplayTone: true,
FileVault: true,
Location: true,
Payment: true,
Privacy: true,
Registration: true,
Restore: true,
ScreenTime: true,
Siri: true,
TOS: true,
TermsOfAddress: true,
ICloudDiagnostics: true,
ICloudStorage: true,
},
LocationInformation: jamfpro.ComputerPrestageSubsetLocationInformation{
Username: "",
Realname: "",
Phone: "",
Email: "",
Room: "",
Position: "",
DepartmentId: "-1",
BuildingId: "-1",
ID: "1",
VersionLock: 0,
},
PurchasingInformation: jamfpro.ComputerPrestageSubsetPurchasingInformation{
ID: "1",
Leased: false,
Purchased: true,
AppleCareId: "",
PONumber: "",
Vendor: "",
PurchasePrice: "",
LifeExpectancy: 0,
PurchasingAccount: "",
PurchasingContact: "",
LeaseDate: "1970-01-01",
PODate: "1970-01-01",
WarrantyDate: "1970-01-01",
VersionLock: 0,
},
AnchorCertificates: []string{},
EnrollmentCustomizationId: "0",
Language: "en",
Region: "GB",
AutoAdvanceSetup: true,
InstallProfilesDuringSetup: true,
PrestageInstalledProfileIds: []string{},
CustomPackageIds: []string{},
CustomPackageDistributionPointId: "-1",
EnableRecoveryLock: false,
RecoveryLockPasswordType: "MANUAL",
RotateRecoveryLockPassword: false,
ID: "1",
ProfileUuid: "C101330EE870D6082D5D08FA013ADE51",
SiteId: "-1",
VersionLock: 3,
AccountSettings: jamfpro.ComputerPrestageSubsetAccountSettings{
ID: "1",
PayloadConfigured: true,
LocalAdminAccountEnabled: true,
AdminUsername: "localAdmin",
HiddenAdminAccount: true,
LocalUserManaged: false,
UserAccountType: "ADMINISTRATOR",
VersionLock: 1,
PrefillPrimaryAccountInfoFeatureEnabled: false,
PrefillType: "CUSTOM",
PrefillAccountFullName: "",
PrefillAccountUserName: "",
PreventPrefillInfoFromModification: false,
},
}
// Call the CreateComputerPrestage function
createdPrestage, err := client.CreateComputerPrestage(&prestage)
if err != nil {
log.Fatalf("Error creating computer prestage: %v", err)
}
// Pretty print the computer prestage in JSON
prestageJSON, err := json.MarshalIndent(createdPrestage, "", " ") // Indent with 4 spaces
if err != nil {
log.Fatalf("Error marshaling computer prestage data: %v", err)
}
fmt.Println("Created computer prestage:\n", string(prestageJSON))
}