Skip to content

Commit 23bd4df

Browse files
committed
feat: add support for api/v1/mobile-device-groups/static-groups
1 parent 2c9e735 commit 23bd4df

File tree

7 files changed

+396
-0
lines changed

7 files changed

+396
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 mobile device group
22+
siteId := "-1"
23+
newGroup := jamfpro.ResourceStaticMobileDeviceGroupV1{
24+
GroupName: "Static Test Group",
25+
SiteId: siteId,
26+
GroupDescription: "Description goes here",
27+
}
28+
29+
// Call function
30+
created, err := client.CreateStaticMobileDeviceGroupV1(newGroup)
31+
if err != nil {
32+
log.Fatalf("Error creating static mobile device group: %v", err)
33+
}
34+
35+
// Pretty print the JSON
36+
response, err := json.MarshalIndent(created, "", " ")
37+
if err != nil {
38+
log.Fatalf("Error marshaling created group data: %v", err)
39+
}
40+
fmt.Println("Created Static Mobile Device Group:\n", string(response))
41+
}
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 := "103"
22+
23+
// Call function
24+
err = client.DeleteStaticMobileDeviceGroupByIDV1(groupID)
25+
if err != nil {
26+
log.Fatalf("Error deleting static mobile device group: %v", err)
27+
}
28+
29+
fmt.Printf("Successfully deleted static mobile device group with ID %s\n", groupID)
30+
}
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 Static Mobile Device Group ID for testing
22+
groupID := "102" // Replace with actual group ID
23+
24+
// Call GetStaticMobileDeviceGroupByID function
25+
group, err := client.GetStaticMobileDeviceGroupByIDV1(groupID)
26+
if err != nil {
27+
log.Fatalf("Error fetching Static Mobile Device 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 Static Mobile Device Group data: %v", err)
34+
}
35+
fmt.Println("Fetched Static Mobile Device Group:\n", string(groupJSON))
36+
}
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 Static Mobile Device Group name for testing
22+
groupName := "Excluded Devices" // Replace with actual group name
23+
24+
// Call GetStaticMobileDeviceGroupByName function
25+
group, err := client.GetStaticMobileDeviceGroupByNameV1(groupName)
26+
if err != nil {
27+
log.Fatalf("Error fetching Static Mobile Device Group by name: %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 Static Mobile Device Group data: %v", err)
34+
}
35+
fmt.Println("Fetched Static Mobile Device Group:\n", string(groupJSON))
36+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"log"
7+
"net/url"
8+
9+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
10+
)
11+
12+
func main() {
13+
// Define the path to the JSON configuration file
14+
configFilePath := "/Users/Shared/GitHub/go-api-sdk-jamfpro/localtesting/clientconfig.json"
15+
16+
// Initialize the Jamf Pro client with the HTTP client configuration
17+
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
18+
if err != nil {
19+
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
20+
}
21+
22+
// Set sorting filter (optional)
23+
// For more information on how to add parameters to this request, see docs/url_queries.md
24+
25+
params := url.Values{}
26+
params.Add("sort", "groupName:asc")
27+
28+
// Call function
29+
groups, err := client.GetStaticMobileDeviceGroupsV1(params)
30+
if err != nil {
31+
log.Fatalf("Error fetching static mobile device groups v1: %v", err)
32+
}
33+
34+
// Pretty print the JSON
35+
response, err := json.MarshalIndent(groups, "", " ")
36+
if err != nil {
37+
log.Fatalf("Error marshaling groups data: %v", err)
38+
}
39+
fmt.Println("Fetched Static Mobile Device Groups v1:\n", string(response))
40+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 group ID to update
22+
groupID := "106"
23+
siteID := "-1"
24+
25+
// Create update data
26+
updateGroup := jamfpro.ResourceStaticMobileDeviceGroupV1{
27+
GroupName: "Updated Static Test Group",
28+
SiteId: siteID,
29+
GroupDescription: "Description goes here",
30+
}
31+
// Call function
32+
updated, err := client.UpdateStaticMobileDeviceGroupByIDV1(groupID, updateGroup)
33+
if err != nil {
34+
log.Fatalf("Error updating static mobile device group: %v", err)
35+
}
36+
37+
// Pretty print the JSON
38+
response, err := json.MarshalIndent(updated, "", " ")
39+
if err != nil {
40+
log.Fatalf("Error marshaling updated group data: %v", err)
41+
}
42+
fmt.Println("Updated Static Mobile Device Group:\n", string(response))
43+
}

0 commit comments

Comments
 (0)