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
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadDescription</key>
<string/>
<key>PayloadDisplayName</key>
<string>Dock</string>
<key>PayloadEnabled</key>
<true/>
<key>PayloadIdentifier</key>
<string>6756212F-E97A-4EEF-91C1-F8C5CD3A11F9</string>
<key>PayloadOrganization</key>
<string>Lloyds Bank</string>
<key>PayloadType</key>
<string>com.apple.dock</string>
<key>PayloadUUID</key>
<string>6756212F-E97A-4EEF-91C1-F8C5CD3A11F9</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>autohide</key>
<false/>
<key>contents-immutable</key>
<false/>
<key>largesize</key>
<integer>16</integer>
<key>launchanim</key>
<true/>
<key>launchanim-immutable</key>
<true/>
<key>magnification</key>
<false/>
<key>magnify-immutable</key>
<true/>
<key>magsize-immutable</key>
<true/>
<key>mineffect</key>
<string>genie</string>
<key>mineffect-immutable</key>
<true/>
<key>minimize-to-application</key>
<false/>
<key>minimize-to-application-immutable</key>
<false/>
<key>orientation</key>
<string>right</string>
<key>position-immutable</key>
<true/>
<key>show-process-indicators</key>
<false/>
<key>show-process-indicators-immutable</key>
<true/>
<key>size-immutable</key>
<true/>
<key>static-apps</key>
<array>
</array>
<key>static-only</key>
<false/>
<key>static-others</key>
<array>
</array>
<key>tilesize</key>
<integer>16</integer>
</dict>
</array>
<key>PayloadDescription</key>
<string/>
<key>PayloadDisplayName</key>
<string>DOCK</string>
<key>PayloadEnabled</key>
<true/>
<key>PayloadIdentifier</key>
<string>2359960C-3E2F-4159-B3D2-90D7804AEFF2</string>
<key>PayloadOrganization</key>
<string>Lloyds Bank</string>
<key>PayloadRemovalDisallowed</key>
<true/>
<key>PayloadScope</key>
<string>System</string>
<key>PayloadType</key>
<string>Configuration</string>
<key>PayloadUUID</key>
<string>2359960C-3E2F-4159-B3D2-90D7804AEFF2</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func main() {
}

// Load payload from file
payloads, err := readPayloadFromFile("/Users/dafyddwatkins/localtesting/terraform/support_files/macosconfigurationprofiles/imazing/post-jamfpro-upload/restrictions-jamfpro-export-with-gui-updates.mobileconfig")
payloads, err := readPayloadFromFile("/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/examples/macos_configuration_profiles/UpdateMacOSConfigurationProfileByIDWithFileUpload/DOCK.mobileconfig")
if err != nil {
log.Fatalf("Failed to read payload: %v", err)
}
Expand All @@ -28,7 +28,7 @@ func main() {
// Define the macOS Configuration Profile as per the given XML structure
profile := jamfpro.ResourceMacOSConfigurationProfile{
General: jamfpro.MacOSConfigurationProfileSubsetGeneral{
Name: "restrictions-jamfpro-export-with-api-updates-and-new-uuid-at-root", // this must match the name of the existing profile in Jamf Pro that you want to update by ID
Name: "DOCK", // this must match the name of the existing profile in Jamf Pro that you want to update by ID
Description: "",
Site: &jamfpro.SharedResourceSite{ID: -1, Name: "None"}, // Optional, the Create fuction will set default values if no site is set
Category: &jamfpro.SharedResourceCategory{ID: -1, Name: "No category assigned"}, // Optional, the Create fuction will set default values if no category is set
Expand All @@ -41,6 +41,13 @@ func main() {
Scope: jamfpro.MacOSConfigurationProfileSubsetScope{
AllComputers: false,
AllJSSUsers: false,
Computers: []jamfpro.MacOSConfigurationProfileSubsetComputer{
{
MacOSConfigurationProfileSubsetScopeEntity: jamfpro.MacOSConfigurationProfileSubsetScopeEntity{
ID: 23,
},
},
},
},
SelfService: jamfpro.MacOSConfigurationProfileSubsetSelfService{
InstallButtonText: "Install",
Expand All @@ -51,7 +58,7 @@ func main() {
}

// Set the config profile ID you want to update
id := "5498" // Replace with the actual ID of the profile you want to update
id := "5502" // Replace with the actual ID of the profile you want to update

// Call the UpdateMacOSConfigurationProfileByID function
updatedProfileID, err := client.UpdateMacOSConfigurationProfileByID(id, &profile)
Expand Down
32 changes: 32 additions & 0 deletions examples/packages/GetPackageByName/GetPackageByName.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"encoding/json"
"fmt"
"log"

"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
)

func main() {
configFilePath := "/Users/dafyddwatkins/localtesting/jamfpro/clientconfig.json"

client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
if err != nil {
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
}

packageName := "Firefox 133.0.3.pkg"

response, err := client.GetPackageByName(packageName)
if err != nil {
fmt.Println("Error fetching package by name:", err)
return
}

packageJSON, err := json.MarshalIndent(response, "", " ")
if err != nil {
log.Fatalf("Error marshaling package data: %v", err)
}
fmt.Println("Obtained package Details:\n", string(packageJSON))
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
// Global configuration variables
var (
configFilePath = "/Users/dafyddwatkins/localtesting/jamfpro/clientconfig.json"
exportDir = "/Users/dafyddwatkins/localtesting/terraform/support_files/macosconfigurationprofiles/imazing/post-jamfpro-upload"
profileID = "5498" // Set your desired profile ID here
exportDir = "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/examples/macos_configuration_profiles/UpdateMacOSConfigurationProfileByIDWithFileUpload"
profileID = "5502" // Set your desired profile ID here
)

func main() {
Expand Down
16 changes: 16 additions & 0 deletions sdk/jamfpro/jamfproapi_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ func (c *Client) GetPackageByID(id string) (*ResourcePackage, error) {
return &response, nil
}

// GetPackageByName retrieves a package by name, returns ResourcePackage
func (c *Client) GetPackageByName(name string) (*ResourcePackage, error) {
packages, err := c.GetPackages("", "")
if err != nil {
return nil, fmt.Errorf(errMsgFailedPaginatedGet, "packages", err)
}

for _, value := range packages.Results {
if value.PackageName == name {
return &value, nil
}
}

return nil, fmt.Errorf(errMsgFailedGetByName, "package", name, errMsgNoName)
}

// GetPackageHistoryByPackageID retrieves the history of a specific package by its ID with pagination, sorting, and filtering.
func (c *Client) GetPackageHistoryByPackageID(id string, sort, filter string) (*ResponsePackageHistoryList, error) {
const maxPageSize = 200
Expand Down
Loading