Skip to content

Commit 67b1c1f

Browse files
authored
Merge pull request #42 from deploymenttheory/dev
+ sdk vpp mac applications with examples
2 parents fdad4da + 60b86e1 commit 67b1c1f

File tree

14 files changed

+1041
-288
lines changed

14 files changed

+1041
-288
lines changed

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,11 +710,47 @@ This documentation provides details on the API endpoints available for managing
710710
- [x] ✅ **DELETE** `/JSSResource/ebooks/name/{name}`
711711
`DeleteEbookByName` deletes an ebook by its name.
712712
713+
### Jamf Pro Classic API - VPP Mac Applications
714+
715+
This documentation outlines the API endpoints available for managing VPP Mac applications within Jamf Pro using the Classic API, which supports XML data structures.
716+
717+
## Endpoints
718+
719+
- [x] ✅ **GET** `/JSSResource/macapplications`
720+
`GetMacApplications` retrieves a serialized list of all VPP Mac applications.
721+
722+
- [x] ✅ **GET** `/JSSResource/macapplications/id/{id}`
723+
`GetMacApplicationByID` fetches a single Mac application by its ID.
724+
725+
- [x] ✅ **GET** `/JSSResource/macapplications/name/{name}`
726+
`GetMacApplicationByName` retrieves a Mac application by its name.
727+
728+
- [x] ✅ **GET** `/JSSResource/macapplications/name/{name}/subset/{subset}`
729+
`GetMacApplicationByNameAndDataSubset` retrieves a specific subset (General, Scope, SelfService, VPPCodes, and VPP) of a Mac application by its name.
730+
731+
- [x] ✅ **GET** `/JSSResource/macapplications/id/{id}/subset/{subset}`
732+
`GetMacApplicationByIDAndDataSubset` retrieves a specific subset (General, Scope, SelfService, VPPCodes, and VPP) of a Mac application by its ID.
733+
734+
- [x] ✅ **POST** `/JSSResource/macapplications/id/0`
735+
`CreateMacApplication` creates a new Mac application with the provided details. The ID `0` in the endpoint indicates creation.
736+
737+
- [x] ✅ **PUT** `/JSSResource/macapplications/id/{id}`
738+
`UpdateMacApplicationByID` updates an existing Mac application by its ID.
739+
740+
- [x] ✅ **PUT** `/JSSResource/macapplications/name/{name}`
741+
`UpdateMacApplicationByName` updates an existing Mac application by its name.
742+
743+
- [x] ✅ **DELETE** `/JSSResource/macapplications/id/{id}`
744+
`DeleteMacApplicationByID` deletes a Mac application by its ID.
745+
746+
- [x] ✅ **DELETE** `/JSSResource/macapplications/name/{name}`
747+
`DeleteMacApplicationByName` deletes a Mac application by its name.
748+
713749
714750
## Progress Summary
715751
716-
- Total Endpoints: 244
717-
- Covered: 225
752+
- Total Endpoints: 254
753+
- Covered: 235
718754
- Not Covered: 19
719755
- Partially Covered: 0
720756
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package main
2+
3+
import (
4+
"encoding/xml"
5+
"fmt"
6+
"log"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
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/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
15+
16+
// Load the client OAuth credentials from the configuration file
17+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
18+
if err != nil {
19+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
20+
}
21+
22+
// Instantiate the default logger and set the desired log level
23+
logger := http_client.NewDefaultLogger()
24+
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug
25+
26+
// Configuration for the jamfpro
27+
config := jamfpro.Config{
28+
InstanceName: authConfig.InstanceName,
29+
LogLevel: logLevel,
30+
Logger: logger,
31+
ClientID: authConfig.ClientID,
32+
ClientSecret: authConfig.ClientSecret,
33+
}
34+
35+
// Create a new jamfpro client instance
36+
client, err := jamfpro.NewClient(config)
37+
if err != nil {
38+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
39+
}
40+
41+
// Define a new Mac Application
42+
newMacApp := jamfpro.ResponseMacApplications{
43+
General: jamfpro.MacAppDataSubsetGeneral{
44+
Name: "TextWrangler.app",
45+
Version: "5.5.2",
46+
IsFree: true,
47+
BundleID: "com.barebones.textwrangler",
48+
URL: "https://itunes.apple.com/us/app/textwrangler/id404010395?mt=12&uo=4",
49+
Category: jamfpro.MacAppCategory{ID: -1, Name: "Unknown"},
50+
Site: jamfpro.MacAppSite{ID: -1, Name: "None"},
51+
},
52+
Scope: jamfpro.MacAppDataSubsetScope{
53+
AllComputers: false,
54+
AllJSSUsers: false,
55+
},
56+
SelfService: jamfpro.MacAppDataSubsetSelfService{
57+
InstallButtonText: "Install",
58+
SelfServiceDescription: "Installs the TextWrangler application",
59+
ForceUsersToViewDescription: true,
60+
SelfServiceIcon: jamfpro.MacAppSelfServiceIcon{},
61+
FeatureOnMainPage: true,
62+
SelfServiceCategories: []jamfpro.MacAppSelfServiceCategory{},
63+
Notification: "string",
64+
NotificationSubject: "TextWrangler is Available to Install",
65+
NotificationMessage: "You can install TextWrangler by clicking this link or going to Self Service",
66+
VPP: jamfpro.MacAppVPP{
67+
AssignVPPDeviceBasedLicenses: false,
68+
VPPAdminAccountID: -1,
69+
},
70+
},
71+
}
72+
73+
// Call CreateMacApplication
74+
createdMacApp, err := client.CreateMacApplication(newMacApp)
75+
if err != nil {
76+
log.Fatalf("Error creating Mac Application: %v", err)
77+
}
78+
79+
// Pretty print the created Mac Application in XML
80+
macAppXML, err := xml.MarshalIndent(createdMacApp, "", " ") // Indent with 4 spaces
81+
if err != nil {
82+
log.Fatalf("Error marshaling Mac Application data: %v", err)
83+
}
84+
fmt.Println("Created Mac Application:\n", string(macAppXML))
85+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
7+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
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/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
14+
15+
// Load the client OAuth credentials from the configuration file
16+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
17+
if err != nil {
18+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
19+
}
20+
21+
// Instantiate the default logger and set the desired log level
22+
logger := http_client.NewDefaultLogger()
23+
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug
24+
25+
// Configuration for the jamfpro
26+
config := jamfpro.Config{
27+
InstanceName: authConfig.InstanceName,
28+
LogLevel: logLevel,
29+
Logger: logger,
30+
ClientID: authConfig.ClientID,
31+
ClientSecret: authConfig.ClientSecret,
32+
}
33+
34+
// Create a new jamfpro client instance
35+
client, err := jamfpro.NewClient(config)
36+
if err != nil {
37+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
38+
}
39+
40+
// Define the ID of the VPP mac application you want to delete
41+
profileID := 1
42+
43+
// Call the DeleteMacOSConfigurationProfileByID function
44+
err = client.DeleteMacApplicationByID(profileID)
45+
if err != nil {
46+
log.Fatalf("Failed to delete VPP mac application with ID %d: %v", profileID, err)
47+
}
48+
49+
fmt.Printf("VPP mac application with ID %d deleted successfully\n", profileID)
50+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
7+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
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/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
14+
15+
// Load the client OAuth credentials from the configuration file
16+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
17+
if err != nil {
18+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
19+
}
20+
21+
// Instantiate the default logger and set the desired log level
22+
logger := http_client.NewDefaultLogger()
23+
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug
24+
25+
// Configuration for the jamfpro
26+
config := jamfpro.Config{
27+
InstanceName: authConfig.InstanceName,
28+
LogLevel: logLevel,
29+
Logger: logger,
30+
ClientID: authConfig.ClientID,
31+
ClientSecret: authConfig.ClientSecret,
32+
}
33+
34+
// Create a new jamfpro client instance
35+
client, err := jamfpro.NewClient(config)
36+
if err != nil {
37+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
38+
}
39+
40+
// Define the name of the macOS Configuration Profile you want to delete
41+
VPPMacApplicationName := "TextWrangler.app"
42+
43+
// Call the DeleteMacApplicationByName function
44+
err = client.DeleteMacApplicationByName(VPPMacApplicationName)
45+
if err != nil {
46+
log.Fatalf("Failed to delete VPP Mac Application with name '%s': %v", VPPMacApplicationName, err)
47+
}
48+
49+
fmt.Printf("VPP Mac Application with name '%s' deleted successfully\n", VPPMacApplicationName)
50+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package main
2+
3+
import (
4+
"encoding/xml"
5+
"fmt"
6+
"log"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
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/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
15+
16+
// Load the client OAuth credentials from the configuration file
17+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
18+
if err != nil {
19+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
20+
}
21+
22+
// Instantiate the default logger and set the desired log level
23+
logger := http_client.NewDefaultLogger()
24+
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug
25+
26+
// Configuration for the jamfpro
27+
config := jamfpro.Config{
28+
InstanceName: authConfig.InstanceName,
29+
LogLevel: logLevel,
30+
Logger: logger,
31+
ClientID: authConfig.ClientID,
32+
ClientSecret: authConfig.ClientSecret,
33+
}
34+
35+
// Create a new jamfpro client instance
36+
client, err := jamfpro.NewClient(config)
37+
if err != nil {
38+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
39+
}
40+
41+
id := 1 // Replace with your Mac application ID
42+
macApp, err := client.GetMacApplicationByID(id)
43+
if err != nil {
44+
log.Fatalf("Error fetching Mac Application by ID: %v", err)
45+
}
46+
47+
// Pretty print the profile in XML
48+
profileXML, err := xml.MarshalIndent(macApp, "", " ") // Indent with 4 spaces
49+
if err != nil {
50+
log.Fatalf("Error marshaling VPP mac Application data: %v", err)
51+
}
52+
fmt.Println("Fetched VPP mac Application:\n", string(profileXML))
53+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package main
2+
3+
import (
4+
"encoding/xml"
5+
"fmt"
6+
"log"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
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/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
15+
16+
// Load the client OAuth credentials from the configuration file
17+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
18+
if err != nil {
19+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
20+
}
21+
22+
// Instantiate the default logger and set the desired log level
23+
logger := http_client.NewDefaultLogger()
24+
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug
25+
26+
// Configuration for the jamfpro
27+
config := jamfpro.Config{
28+
InstanceName: authConfig.InstanceName,
29+
LogLevel: logLevel,
30+
Logger: logger,
31+
ClientID: authConfig.ClientID,
32+
ClientSecret: authConfig.ClientSecret,
33+
}
34+
35+
// Create a new jamfpro client instance
36+
client, err := jamfpro.NewClient(config)
37+
if err != nil {
38+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
39+
}
40+
41+
// Define the application name and the subset you want to retrieve
42+
appID := 1 // Replace with the actual application name
43+
subset := "General" // Subset values can be General, Scope, SelfService, VPPCodes and VPP.
44+
45+
// Call GetMacApplicationByNameAndDataSubset
46+
macApp, err := client.GetMacApplicationByIDAndDataSubset(appID, subset)
47+
if err != nil {
48+
log.Fatalf("Error fetching Mac Application by Name and Subset: %v", err)
49+
}
50+
51+
// Pretty print the response in XML
52+
macAppXML, err := xml.MarshalIndent(macApp, "", " ") // Indent with 4 spaces
53+
if err != nil {
54+
log.Fatalf("Error marshaling Mac Application data: %v", err)
55+
}
56+
fmt.Println("Fetched Mac Application Data:\n", string(macAppXML))
57+
}

0 commit comments

Comments
 (0)