-
Notifications
You must be signed in to change notification settings - Fork 5
/
CreateManagedSoftwareUpdatePlanByDeviceID.go
48 lines (41 loc) · 1.84 KB
/
CreateManagedSoftwareUpdatePlanByDeviceID.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
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)
}
// Define a sample plan for testing
sampleUpdatePlan := &jamfpro.ResourceManagedSoftwareUpdatePlan{
Devices: []jamfpro.ManagedSoftwareUpdatePlanObject{{
ObjectType: "COMPUTER", // COMPUTER / MOBILE_DEVICE / APPLE_TV
DeviceId: "18",
}},
Config: jamfpro.ManagedSoftwareUpdatePlanConfig{
UpdateAction: "DOWNLOAD_INSTALL_ALLOW_DEFERRAL", // DOWNLOAD_ONLY / DOWNLOAD_INSTALL / DOWNLOAD_INSTALL_ALLOW_DEFERRAL / DOWNLOAD_INSTALL_RESTART / DOWNLOAD_INSTALL_SCHEDULE / UNKNOWN
VersionType: "LATEST_MAJOR", // LATEST_MAJOR / LATEST_MINOR / LATEST_ANY / SPECIFIC_VERSION / UNKNOWN
SpecificVersion: "NO_SPECIFIC_VERSION", // NO_SPECIFIC_VERSION / 14.4.1 etc
MaxDeferrals: 5,
//ForceInstallLocalDateTime: "2023-12-25T21:09:31",
},
}
// Call CreateManagedSoftwareUpdatePlanByDeviceID function
createdPlan, err := client.CreateManagedSoftwareUpdatePlanByDeviceID(sampleUpdatePlan)
if err != nil {
log.Fatalf("Error creating managed software update plan: %v", err)
}
// Pretty print the created managed software update plan details in JSON
createdPlanJSON, err := json.MarshalIndent(createdPlan, "", " ") // Indent with 4 spaces
if err != nil {
log.Fatalf("Error marshaling created managed software update plan data: %v", err)
}
fmt.Println("Created managed software update plan Details:\n", string(createdPlanJSON))
}