Skip to content

Commit 177ed34

Browse files
authored
Merge pull request #951 from neilmartin83/nm-smart-computer-groups-2025-10-21
feat: add full support for api/v2/computer-groups
2 parents b63d359 + cd8d563 commit 177ed34

File tree

16 files changed

+514
-137
lines changed

16 files changed

+514
-137
lines changed

examples/smart_computer_groups/CreateSmartComputerGroup/CreateSmartComputerGroup.go renamed to examples/smart_computer_groups/CreateSmartComputerGroupV2/CreateSmartComputerGroupV2.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

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

1515
// Initialize the Jamf Pro client with the HTTP client configuration
1616
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
@@ -20,8 +20,9 @@ func main() {
2020

2121
// Create new smart computer group
2222
siteID := "-1"
23-
newGroup := jamfpro.ResourceSmartComputerGroup{
24-
Name: "Operating System Version like 15",
23+
newGroup := jamfpro.ResourceSmartComputerGroupV2{
24+
Name: "Operating System Version like 15",
25+
Description: "This is a description",
2526
Criteria: []jamfpro.SharedSubsetCriteriaJamfProAPI{
2627
{
2728
Name: "Operating System Version",
@@ -46,7 +47,7 @@ func main() {
4647
}
4748

4849
// Call function
49-
created, err := client.CreateSmartComputerGroup(newGroup)
50+
created, err := client.CreateSmartComputerGroupV2(newGroup)
5051
if err != nil {
5152
log.Fatalf("Error creating smart computer group: %v", err)
5253
}

examples/smart_computer_groups/DeleteComputerGroupByID/DeleteComputerGroupByID.go renamed to examples/smart_computer_groups/DeleteComputerGroupByIDV2/DeleteComputerGroupByIDV2.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

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

1414
// Initialize the Jamf Pro client with the HTTP client configuration
1515
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
@@ -18,10 +18,10 @@ func main() {
1818
}
1919

2020
// Define group ID to delete
21-
groupID := "1"
21+
groupID := "1196"
2222

2323
// Call function
24-
err = client.DeleteSmartComputerGroupByID(groupID)
24+
err = client.DeleteSmartComputerGroupByIDV2(groupID)
2525
if err != nil {
2626
log.Fatalf("Error deleting smart computer group: %v", err)
2727
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"log"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
9+
)
10+
11+
func main() {
12+
// Define the path to the JSON configuration file
13+
configFilePath := "/Users/Shared/GitHub/go-api-sdk-jamfpro/localtesting/clientconfig.json"
14+
15+
// Initialize the Jamf Pro client with the HTTP client configuration
16+
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
17+
if err != nil {
18+
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
19+
}
20+
21+
// Define a Smart Computer Group ID for testing
22+
groupID := "1197" // Replace with actual group ID
23+
24+
// Call GetSmartComputerGroupByID function
25+
group, err := client.GetSmartComputerGroupByIDV2(groupID)
26+
if err != nil {
27+
log.Fatalf("Error fetching Smart Computer Group by ID: %v", err)
28+
}
29+
30+
// Pretty print the group in JSON
31+
groupJSON, err := json.MarshalIndent(group, "", " ") // Indent with 4 spaces
32+
if err != nil {
33+
log.Fatalf("Error marshaling Smart Computer Group data: %v", err)
34+
}
35+
fmt.Println("Fetched Smart Computer Group:\n", string(groupJSON))
36+
}

examples/smart_computer_groups/GetSmartComputerGroupByName/GetSmartComputerGroupByName.go renamed to examples/smart_computer_groups/GetSmartComputerGroupByNameV2/GetSmartComputerGroupByNameV2.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

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

1515
// Initialize the Jamf Pro client with the HTTP client configuration
1616
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
@@ -22,7 +22,7 @@ func main() {
2222
groupName := "Operating System Version like 15" // Replace with actual group name
2323

2424
// Call GetSmartComputerGroupByName function
25-
group, err := client.GetSmartComputerGroupByName(groupName)
25+
group, err := client.GetSmartComputerGroupByNameV2(groupName)
2626
if err != nil {
2727
log.Fatalf("Error fetching Smart Computer Group by name: %v", err)
2828
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

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

1515
// Initialize the Jamf Pro client with the HTTP client configuration
1616
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
@@ -19,10 +19,10 @@ func main() {
1919
}
2020

2121
// Define the group ID
22-
groupID := "5"
22+
groupID := "1197"
2323

2424
// Call function
25-
membership, err := client.GetSmartComputerGroupMembershipByID(groupID)
25+
membership, err := client.GetSmartComputerGroupMembershipByIDV2(groupID)
2626
if err != nil {
2727
log.Fatalf("Error fetching smart computer group membership: %v", err)
2828
}

examples/smart_computer_groups/GetSmartComputerGroups/GetSmartComputerGroups.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

examples/smart_computer_groups/GetSmartComputerGroupsV2/GetSmartComputerGroupsV2.go

Lines changed: 1 addition & 1 deletion
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)

examples/smart_computer_groups/UpdateSmartComputerGroupByID/UpdateSmartComputerGroupByID.go renamed to examples/smart_computer_groups/UpdateSmartComputerGroupByIDV2/UpdateSmartComputerGroupByIDV2.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

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

1515
// Initialize the Jamf Pro client with the HTTP client configuration
1616
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
@@ -19,15 +19,15 @@ func main() {
1919
}
2020

2121
// Define group ID to update
22-
groupID := "1"
22+
groupID := "1197"
2323
siteID := "-1"
2424

2525
// Create update data
26-
updateGroup := jamfpro.ResourceSmartComputerGroup{
26+
updateGroup := jamfpro.ResourceSmartComputerGroupV2{
2727
Name: "Updated Smart Group",
2828
Criteria: []jamfpro.SharedSubsetCriteriaJamfProAPI{
2929
{
30-
Name: "Account",
30+
Name: "Username",
3131
Priority: 0,
3232
AndOr: "and",
3333
SearchType: "is",
@@ -40,7 +40,7 @@ func main() {
4040
}
4141

4242
// Call function
43-
updated, err := client.UpdateSmartComputerGroupByID(groupID, updateGroup)
43+
updated, err := client.UpdateSmartComputerGroupByIDV2(groupID, updateGroup)
4444
if err != nil {
4545
log.Fatalf("Error updating smart computer group: %v", err)
4646
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"log"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
9+
)
10+
11+
func main() {
12+
// Define the path to the JSON configuration file
13+
configFilePath := "/Users/Shared/GitHub/go-api-sdk-jamfpro/localtesting/clientconfig.json"
14+
15+
// Initialize the Jamf Pro client with the HTTP client configuration
16+
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
17+
if err != nil {
18+
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
19+
}
20+
21+
// Create new static computer group
22+
newGroup := jamfpro.ResourceStaticComputerGroupV2{
23+
Name: "Static Test Group",
24+
Description: "Some kind of description",
25+
}
26+
27+
// Call function
28+
created, err := client.CreateStaticComputerGroupV2(newGroup)
29+
if err != nil {
30+
log.Fatalf("Error creating static computer group: %v", err)
31+
}
32+
33+
// Pretty print the JSON
34+
response, err := json.MarshalIndent(created, "", " ")
35+
if err != nil {
36+
log.Fatalf("Error marshaling created group data: %v", err)
37+
}
38+
fmt.Println("Created Static Computer Group:\n", string(response))
39+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
7+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
8+
)
9+
10+
func main() {
11+
// Define the path to the JSON configuration file
12+
configFilePath := "/Users/Shared/GitHub/go-api-sdk-jamfpro/localtesting/clientconfig.json"
13+
14+
// Initialize the Jamf Pro client with the HTTP client configuration
15+
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
16+
if err != nil {
17+
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
18+
}
19+
20+
// Define group ID to delete
21+
groupID := "1199"
22+
23+
// Call function
24+
err = client.DeleteStaticComputerGroupByIDV2(groupID)
25+
if err != nil {
26+
log.Fatalf("Error deleting static computer group: %v", err)
27+
}
28+
29+
fmt.Printf("Successfully deleted static computer group with ID %s\n", groupID)
30+
}

0 commit comments

Comments
 (0)