-
Notifications
You must be signed in to change notification settings - Fork 6
/
UpdateComputerPrestageByNameByID.go
126 lines (118 loc) · 3.56 KB
/
UpdateComputerPrestageByNameByID.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
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
)
func main() {
// Define the path to the JSON configuration file
configFilePath := "/Users/dafyddwatkins/localtesting/jamfpro/clientconfig.json"
// Initialize the Jamf Pro client with the HTTP client configuration
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
if err != nil {
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
}
// The ID of the computer prestage you want to update
prestageName := "YOUR_PRESTAGE_ID_HERE"
// Define the updated information for the computer prestage
// Here we are just creating a new instance for demonstration purposes.
// You would typically populate this struct with your updated data.
var update jamfpro.ResourceComputerPrestage
updateData := `{
"mandatory": true,
"mdmRemovable": true,
"defaultPrestage": true,
"keepExistingSiteMembership": true,
"keepExistingLocationInformation": true,
"requireAuthentication": true,
"preventActivationLock": true,
"enableDeviceBasedActivationLock": true,
"skipSetupItems": {
"newKey": true
},
"locationInformation": {
"email": "test@jamf.com",
"room": "room",
"position": "postion",
"departmentId": "1",
"id": "-1",
"versionLock": 1,
"buildingId": "1",
"username": "name",
"realname": "realName",
"phone": "123-456-7890"
},
"purchasingInformation": {
"leased": true,
"purchased": true,
"id": "-1",
"appleCareId": "abcd",
"poNumber": "53-1",
"vendor": "Example Vendor",
"purchasePrice": "$500",
"lifeExpectancy": 5,
"purchasingAccount": "admin",
"purchasingContact": "true",
"leaseDate": "2019-01-01",
"poDate": "2019-01-01",
"warrantyDate": "2019-01-01",
"versionLock": 1
},
"autoAdvanceSetup": true,
"installProfilesDuringSetup": true,
"accountSettings": {
"payloadConfigured": false,
"localAdminAccountEnabled": false,
"hiddenAdminAccount": false,
"localUserManaged": false,
"userAccountType": "STANDARD",
"versionLock": 0,
"prefillPrimaryAccountInfoFeatureEnabled": false,
"prefillType": "CUSTOM",
"preventPrefillInfoFromModification": false,
"id": "1",
"adminUsername": "admin",
"adminPassword": "password"
},
"displayName": "test",
"supportPhoneNumber": "5555555555",
"supportEmailAddress": "someemail@domain.com",
"department": "Oxbow",
"enrollmentSiteId": "-1",
"authenticationPrompt": "LDAP authentication prompt",
"deviceEnrollmentProgramInstanceId": "5",
"anchorCertificates": [
"xNE5HRgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="
],
"enrollmentCustomizationId": "2",
"language": "en",
"region": "US",
"prestageInstalledProfileIds": [
"-1"
],
"customPackageDistributionPointId": "1",
"enableRecoveryLock": true,
"recoveryLockPasswordType": "MANUAL",
"rotateRecoveryLockPassword": true,
"recoveryLockPassword": "password123",
"customPackageIds": [
"-1"
]
}`
err = json.Unmarshal([]byte(updateData), &update)
if err != nil {
log.Fatalf("Error unmarshaling update data: %v", err)
}
// Call UpdateComputerPrestageByName to update the prestage
updatedPrestage, err := client.UpdateComputerPrestageByName(prestageName, &update)
if err != nil {
log.Fatalf("Error updating computer prestage: %v", err)
}
// Pretty print the computer prestage in JSON
prestageJSON, err := json.MarshalIndent(updatedPrestage, "", " ") // Indent with 4 spaces
if err != nil {
log.Fatalf("Error marshaling computer prestage data: %v", err)
}
fmt.Println("Fetched computer prestage:\n", string(prestageJSON))
}