-
Notifications
You must be signed in to change notification settings - Fork 5
/
UpdateComputerInventoryByID.go
51 lines (41 loc) · 1.29 KB
/
UpdateComputerInventoryByID.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
package main
import (
"embed"
"encoding/json"
"fmt"
"log"
"os"
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
)
//go:embed payload.json
var fsys embed.FS
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 the computer ID you want to update
computerID := "8" // Replace with the actual computer ID
// Read the content of the embedded file
data, err := fsys.ReadFile("payload.json")
if err != nil {
fmt.Println("Error reading embedded file:", err)
return
}
var payload jamfpro.ResourceComputerInventory
if err := json.Unmarshal(data, &payload); err != nil {
fmt.Fprintf(os.Stderr, "Error decoding payload: %v\n", err)
return
}
// Call the UpdateComputerInventoryByID function
updatedInventory, err := client.UpdateComputerInventoryByID(computerID, &payload)
if err != nil {
fmt.Fprintf(os.Stderr, "Error updating computer inventory: %v\n", err)
return
}
// Print the updated inventory
fmt.Printf("Updated Inventory: %+v\n", updatedInventory)
}