Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,47 @@ This documentation provides details on the API endpoints available for managing
- [x] ✅ **DELETE** `/JSSResource/ebooks/name/{name}`
`DeleteEbookByName` deletes an ebook by its name.

### Jamf Pro Classic API - VPP Mac Applications

This documentation outlines the API endpoints available for managing VPP Mac applications within Jamf Pro using the Classic API, which supports XML data structures.

## Endpoints

- [x] ✅ **GET** `/JSSResource/macapplications`
`GetMacApplications` retrieves a serialized list of all VPP Mac applications.

- [x] ✅ **GET** `/JSSResource/macapplications/id/{id}`
`GetMacApplicationByID` fetches a single Mac application by its ID.

- [x] ✅ **GET** `/JSSResource/macapplications/name/{name}`
`GetMacApplicationByName` retrieves a Mac application by its name.

- [x] ✅ **GET** `/JSSResource/macapplications/name/{name}/subset/{subset}`
`GetMacApplicationByNameAndDataSubset` retrieves a specific subset (General, Scope, SelfService, VPPCodes, and VPP) of a Mac application by its name.

- [x] ✅ **GET** `/JSSResource/macapplications/id/{id}/subset/{subset}`
`GetMacApplicationByIDAndDataSubset` retrieves a specific subset (General, Scope, SelfService, VPPCodes, and VPP) of a Mac application by its ID.

- [x] ✅ **POST** `/JSSResource/macapplications/id/0`
`CreateMacApplication` creates a new Mac application with the provided details. The ID `0` in the endpoint indicates creation.

- [x] ✅ **PUT** `/JSSResource/macapplications/id/{id}`
`UpdateMacApplicationByID` updates an existing Mac application by its ID.

- [x] ✅ **PUT** `/JSSResource/macapplications/name/{name}`
`UpdateMacApplicationByName` updates an existing Mac application by its name.

- [x] ✅ **DELETE** `/JSSResource/macapplications/id/{id}`
`DeleteMacApplicationByID` deletes a Mac application by its ID.

- [x] ✅ **DELETE** `/JSSResource/macapplications/name/{name}`
`DeleteMacApplicationByName` deletes a Mac application by its name.


## Progress Summary

- Total Endpoints: 244
- Covered: 225
- Total Endpoints: 254
- Covered: 235
- Not Covered: 19
- Partially Covered: 0

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package main

import (
"encoding/xml"
"fmt"
"log"

"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
)

func main() {
// Define the path to the JSON configuration file
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"

// Load the client OAuth credentials from the configuration file
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
if err != nil {
log.Fatalf("Failed to load client OAuth configuration: %v", err)
}

// Instantiate the default logger and set the desired log level
logger := http_client.NewDefaultLogger()
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug

// Configuration for the jamfpro
config := jamfpro.Config{
InstanceName: authConfig.InstanceName,
LogLevel: logLevel,
Logger: logger,
ClientID: authConfig.ClientID,
ClientSecret: authConfig.ClientSecret,
}

// Create a new jamfpro client instance
client, err := jamfpro.NewClient(config)
if err != nil {
log.Fatalf("Failed to create Jamf Pro client: %v", err)
}

// Define a new Mac Application
newMacApp := jamfpro.ResponseMacApplications{
General: jamfpro.MacAppDataSubsetGeneral{
Name: "TextWrangler.app",
Version: "5.5.2",
IsFree: true,
BundleID: "com.barebones.textwrangler",
URL: "https://itunes.apple.com/us/app/textwrangler/id404010395?mt=12&uo=4",
Category: jamfpro.MacAppCategory{ID: -1, Name: "Unknown"},
Site: jamfpro.MacAppSite{ID: -1, Name: "None"},
},
Scope: jamfpro.MacAppDataSubsetScope{
AllComputers: false,
AllJSSUsers: false,
},
SelfService: jamfpro.MacAppDataSubsetSelfService{
InstallButtonText: "Install",
SelfServiceDescription: "Installs the TextWrangler application",
ForceUsersToViewDescription: true,
SelfServiceIcon: jamfpro.MacAppSelfServiceIcon{},
FeatureOnMainPage: true,
SelfServiceCategories: []jamfpro.MacAppSelfServiceCategory{},
Notification: "string",
NotificationSubject: "TextWrangler is Available to Install",
NotificationMessage: "You can install TextWrangler by clicking this link or going to Self Service",
VPP: jamfpro.MacAppVPP{
AssignVPPDeviceBasedLicenses: false,
VPPAdminAccountID: -1,
},
},
}

// Call CreateMacApplication
createdMacApp, err := client.CreateMacApplication(newMacApp)
if err != nil {
log.Fatalf("Error creating Mac Application: %v", err)
}

// Pretty print the created Mac Application in XML
macAppXML, err := xml.MarshalIndent(createdMacApp, "", " ") // Indent with 4 spaces
if err != nil {
log.Fatalf("Error marshaling Mac Application data: %v", err)
}
fmt.Println("Created Mac Application:\n", string(macAppXML))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package main

import (
"fmt"
"log"

"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
)

func main() {
// Define the path to the JSON configuration file
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"

// Load the client OAuth credentials from the configuration file
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
if err != nil {
log.Fatalf("Failed to load client OAuth configuration: %v", err)
}

// Instantiate the default logger and set the desired log level
logger := http_client.NewDefaultLogger()
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug

// Configuration for the jamfpro
config := jamfpro.Config{
InstanceName: authConfig.InstanceName,
LogLevel: logLevel,
Logger: logger,
ClientID: authConfig.ClientID,
ClientSecret: authConfig.ClientSecret,
}

// Create a new jamfpro client instance
client, err := jamfpro.NewClient(config)
if err != nil {
log.Fatalf("Failed to create Jamf Pro client: %v", err)
}

// Define the ID of the VPP mac application you want to delete
profileID := 1

// Call the DeleteMacOSConfigurationProfileByID function
err = client.DeleteMacApplicationByID(profileID)
if err != nil {
log.Fatalf("Failed to delete VPP mac application with ID %d: %v", profileID, err)
}

fmt.Printf("VPP mac application with ID %d deleted successfully\n", profileID)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package main

import (
"fmt"
"log"

"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
)

func main() {
// Define the path to the JSON configuration file
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"

// Load the client OAuth credentials from the configuration file
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
if err != nil {
log.Fatalf("Failed to load client OAuth configuration: %v", err)
}

// Instantiate the default logger and set the desired log level
logger := http_client.NewDefaultLogger()
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug

// Configuration for the jamfpro
config := jamfpro.Config{
InstanceName: authConfig.InstanceName,
LogLevel: logLevel,
Logger: logger,
ClientID: authConfig.ClientID,
ClientSecret: authConfig.ClientSecret,
}

// Create a new jamfpro client instance
client, err := jamfpro.NewClient(config)
if err != nil {
log.Fatalf("Failed to create Jamf Pro client: %v", err)
}

// Define the name of the macOS Configuration Profile you want to delete
VPPMacApplicationName := "TextWrangler.app"

// Call the DeleteMacApplicationByName function
err = client.DeleteMacApplicationByName(VPPMacApplicationName)
if err != nil {
log.Fatalf("Failed to delete VPP Mac Application with name '%s': %v", VPPMacApplicationName, err)
}

fmt.Printf("VPP Mac Application with name '%s' deleted successfully\n", VPPMacApplicationName)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package main

import (
"encoding/xml"
"fmt"
"log"

"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
)

func main() {
// Define the path to the JSON configuration file
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"

// Load the client OAuth credentials from the configuration file
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
if err != nil {
log.Fatalf("Failed to load client OAuth configuration: %v", err)
}

// Instantiate the default logger and set the desired log level
logger := http_client.NewDefaultLogger()
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug

// Configuration for the jamfpro
config := jamfpro.Config{
InstanceName: authConfig.InstanceName,
LogLevel: logLevel,
Logger: logger,
ClientID: authConfig.ClientID,
ClientSecret: authConfig.ClientSecret,
}

// Create a new jamfpro client instance
client, err := jamfpro.NewClient(config)
if err != nil {
log.Fatalf("Failed to create Jamf Pro client: %v", err)
}

id := 1 // Replace with your Mac application ID
macApp, err := client.GetMacApplicationByID(id)
if err != nil {
log.Fatalf("Error fetching Mac Application by ID: %v", err)
}

// Pretty print the profile in XML
profileXML, err := xml.MarshalIndent(macApp, "", " ") // Indent with 4 spaces
if err != nil {
log.Fatalf("Error marshaling VPP mac Application data: %v", err)
}
fmt.Println("Fetched VPP mac Application:\n", string(profileXML))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package main

import (
"encoding/xml"
"fmt"
"log"

"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/http_client" // Import http_client for logging
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
)

func main() {
// Define the path to the JSON configuration file
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"

// Load the client OAuth credentials from the configuration file
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
if err != nil {
log.Fatalf("Failed to load client OAuth configuration: %v", err)
}

// Instantiate the default logger and set the desired log level
logger := http_client.NewDefaultLogger()
logLevel := http_client.LogLevelDebug // LogLevelNone // LogLevelWarning // LogLevelInfo // LogLevelDebug

// Configuration for the jamfpro
config := jamfpro.Config{
InstanceName: authConfig.InstanceName,
LogLevel: logLevel,
Logger: logger,
ClientID: authConfig.ClientID,
ClientSecret: authConfig.ClientSecret,
}

// Create a new jamfpro client instance
client, err := jamfpro.NewClient(config)
if err != nil {
log.Fatalf("Failed to create Jamf Pro client: %v", err)
}

// Define the application name and the subset you want to retrieve
appID := 1 // Replace with the actual application name
subset := "General" // Subset values can be General, Scope, SelfService, VPPCodes and VPP.

// Call GetMacApplicationByNameAndDataSubset
macApp, err := client.GetMacApplicationByIDAndDataSubset(appID, subset)
if err != nil {
log.Fatalf("Error fetching Mac Application by Name and Subset: %v", err)
}

// Pretty print the response in XML
macAppXML, err := xml.MarshalIndent(macApp, "", " ") // Indent with 4 spaces
if err != nil {
log.Fatalf("Error marshaling Mac Application data: %v", err)
}
fmt.Println("Fetched Mac Application Data:\n", string(macAppXML))
}
Loading