Skip to content

Commit d5e069b

Browse files
authored
Merge pull request #27 from deploymenttheory/dev
Added SDK coverage for Self Service Branding macOS
2 parents eb5dfd2 + 4663bb9 commit d5e069b

File tree

17 files changed

+1172
-1
lines changed

17 files changed

+1172
-1
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@ This document tracks the progress of API endpoint coverage tests. As endpoints a
317317
- [ ] ✅ DELETE `/JSSResource/policies/id/{id}` - DeletePolicyByID deletes a policy by its ID
318318
- [ ] ✅ DELETE `/JSSResource/policies/name/{name}` - DeletePolicyByName deletes a policy by its name
319319

320+
### Jamf Pro API - Self Service Branding macOS
321+
322+
- [x] ✅ GET `/api/v1/self-service/branding/macos` - `GetSelfServiceBrandingMacOS` fetches all self-service branding configurations for macOS.
323+
- [x] ✅ GET `/api/v1/self-service/branding/macos/{id}` - `GetSelfServiceBrandingMacOSByID` fetches a self-service branding configuration for macOS by its ID.
324+
- [x] ✅ GET `/api/v1/self-service/branding/macos/name/{name}` - `GetSelfServiceBrandingMacOSByNameByID` fetches a self-service branding configuration for macOS by its name.
325+
- [x] ✅ POST `/api/v1/self-service/branding/macos` - `CreateSelfServiceBrandingMacOS` creates a new self-service branding configuration for macOS.
326+
- [x] ✅ PUT `/api/v1/self-service/branding/macos/{id}` - `UpdateSelfServiceBrandingMacOSByID` updates an existing self-service branding configuration for macOS by its ID.
327+
- [x] ✅ PUT - `UpdateSelfServiceBrandingMacOSByName` updates a self-service branding configuration for macOS by its name.
328+
- [x] ✅ DELETE `/api/v1/self-service/branding/macos/{id}` - `DeleteSelfServiceBrandingMacOSByID` deletes a self-service branding configuration for macOS by its ID.
329+
- [x] ✅ DELETE - `DeleteSelfServiceBrandingMacOSByName` deletes a self-service branding configuration for macOS by its name.
330+
331+
320332
### Scripts - /JSSResource/scripts
321333

322334
- [ ] ✅ GET `/JSSResource/scripts` - GetScripts retrieves all scripts.
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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 inside the main function
12+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
13+
14+
// Load the client OAuth credentials from the configuration file
15+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
16+
if err != nil {
17+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
18+
}
19+
20+
// Configuration for the jamfpro
21+
config := jamfpro.Config{
22+
InstanceName: authConfig.InstanceName,
23+
DebugMode: true,
24+
Logger: jamfpro.NewDefaultLogger(),
25+
ClientID: authConfig.ClientID,
26+
ClientSecret: authConfig.ClientSecret,
27+
}
28+
29+
// Create a new jamfpro client instance
30+
client, err := jamfpro.NewClient(config)
31+
if err != nil {
32+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
33+
}
34+
35+
// Define the new prestage with the provided example
36+
newPrestage := jamfpro.ComputerPrestagesItem{
37+
DisplayName: "computer-prestage-name",
38+
Mandatory: true,
39+
MDMRemovable: false,
40+
DefaultPrestage: false,
41+
KeepExistingSiteMembership: true,
42+
KeepExistingLocationInformation: true,
43+
RequireAuthentication: true,
44+
PreventActivationLock: true,
45+
EnableDeviceBasedActivationLock: true,
46+
SkipSetupItems: map[string]bool{
47+
"newKey": false,
48+
},
49+
LocationInformation: jamfpro.ComputerPrestagesLocationInformation{
50+
Phone: "123-456-7890",
51+
Realname: "realName",
52+
Room: "room",
53+
Position: "position",
54+
DepartmentId: "-1",
55+
BuildingId: "-1",
56+
ID: "-1",
57+
VersionLock: 1,
58+
Username: "name",
59+
60+
},
61+
PurchasingInformation: jamfpro.ComputerPrestagesPurchasingInformation{
62+
Leased: true,
63+
Purchased: true,
64+
ID: "-1",
65+
AppleCareId: "abcd",
66+
PONumber: "53-1",
67+
Vendor: "Example Vendor",
68+
PurchasePrice: "$500",
69+
LifeExpectancy: 5,
70+
PurchasingAccount: "admin",
71+
PurchasingContact: "true",
72+
LeaseDate: "2019-01-01",
73+
PODate: "2019-01-01",
74+
WarrantyDate: "2019-01-01",
75+
VersionLock: 1,
76+
},
77+
AutoAdvanceSetup: true,
78+
InstallProfilesDuringSetup: true,
79+
SupportPhoneNumber: "5555555555",
80+
SupportEmailAddress: "[email protected]",
81+
Department: "Oxbow",
82+
EnrollmentSiteId: "-1",
83+
AuthenticationPrompt: "LDAP authentication prompt",
84+
DeviceEnrollmentProgramInstanceId: "5",
85+
AnchorCertificates: []string{
86+
"xNE5HRgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==",
87+
},
88+
EnrollmentCustomizationId: "2",
89+
Language: "en",
90+
Region: "US",
91+
PrestageInstalledProfileIds: []string{"1"},
92+
CustomPackageIds: []string{"1"},
93+
CustomPackageDistributionPointId: "1",
94+
RecoveryLockPasswordType: "RANDOM",
95+
EnableRecoveryLock: true,
96+
RotateRecoveryLockPassword: true,
97+
RecoveryLockPassword: "password123",
98+
AccountSettings: jamfpro.ComputerPrestagesAccountSettings{
99+
PayloadConfigured: false,
100+
LocalAdminAccountEnabled: false,
101+
HiddenAdminAccount: false,
102+
LocalUserManaged: false,
103+
UserAccountType: "STANDARD",
104+
VersionLock: 0,
105+
PrefillPrimaryAccountInfoFeatureEnabled: false,
106+
PrefillType: "CUSTOM",
107+
PreventPrefillInfoFromModification: false,
108+
ID: "1",
109+
AdminUsername: "admin",
110+
AdminPassword: "password", // Assuming this field exists in your struct
111+
PrefillAccountFullName: "TestUser FullName",
112+
PrefillAccountUserName: "username",
113+
},
114+
}
115+
116+
// Use the address-of operator (&) to pass a pointer to CreateComputerPrestage
117+
createdPrestage, err := client.CreateComputerPrestage(&newPrestage)
118+
if err != nil {
119+
log.Fatalf("Error creating computer prestage: %v", err)
120+
}
121+
122+
fmt.Printf("Created computer prestage: %+v\n", createdPrestage)
123+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 inside the main function
12+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
13+
14+
// Load the client OAuth credentials from the configuration file
15+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
16+
if err != nil {
17+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
18+
}
19+
20+
// Configuration for the jamfpro
21+
config := jamfpro.Config{
22+
InstanceName: authConfig.InstanceName,
23+
DebugMode: true,
24+
Logger: jamfpro.NewDefaultLogger(),
25+
ClientID: authConfig.ClientID,
26+
ClientSecret: authConfig.ClientSecret,
27+
}
28+
29+
// Create a new jamfpro client instance
30+
client, err := jamfpro.NewClient(config)
31+
if err != nil {
32+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
33+
}
34+
35+
// ID of the computer prestage you want to retrieve
36+
prestageID := "2" // Replace with the actual ID
37+
38+
// Call the GetComputerPrestageByID function
39+
prestage, err := client.GetComputerPrestageByID(prestageID)
40+
if err != nil {
41+
log.Fatalf("Error fetching computer prestage by ID: %v", err)
42+
}
43+
44+
// Output the retrieved prestage
45+
fmt.Printf("Computer Prestage: %+v\n", prestage)
46+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 inside the main function
12+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
13+
14+
// Load the client OAuth credentials from the configuration file
15+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
16+
if err != nil {
17+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
18+
}
19+
20+
// Configuration for the jamfpro
21+
config := jamfpro.Config{
22+
InstanceName: authConfig.InstanceName,
23+
DebugMode: true,
24+
Logger: jamfpro.NewDefaultLogger(),
25+
ClientID: authConfig.ClientID,
26+
ClientSecret: authConfig.ClientSecret,
27+
}
28+
29+
// Create a new jamfpro client instance
30+
client, err := jamfpro.NewClient(config)
31+
if err != nil {
32+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
33+
}
34+
35+
// Define pagination and sorting parameters
36+
page := 0 // starting page
37+
pageSize := 10 // number of items per page
38+
sort := []string{""} // sort by name, for example
39+
40+
// Fetch computer prestages using the V3 API
41+
prestages, err := client.GetComputerPrestagesV3(page, pageSize, sort)
42+
if err != nil {
43+
log.Fatalf("Error fetching computer prestages: %v", err)
44+
}
45+
46+
// Print out the fetched computer prestages
47+
for _, prestage := range prestages.Results {
48+
fmt.Printf("Prestage Name: %s\n", prestage.DisplayName)
49+
// Add more details to print as needed
50+
}
51+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 inside the main function
12+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json"
13+
14+
// Load the client OAuth credentials from the configuration file
15+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
16+
if err != nil {
17+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
18+
}
19+
20+
// Configuration for the jamfpro
21+
config := jamfpro.Config{
22+
InstanceName: authConfig.InstanceName,
23+
DebugMode: true,
24+
Logger: jamfpro.NewDefaultLogger(),
25+
ClientID: authConfig.ClientID,
26+
ClientSecret: authConfig.ClientSecret,
27+
}
28+
29+
// Create a new jamfpro client instance
30+
client, err := jamfpro.NewClient(config)
31+
if err != nil {
32+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
33+
}
34+
35+
// The ID of the computer prestage to retrieve the device scope for
36+
prestageID := "123" // Replace with the actual ID
37+
38+
// Fetch the device scope for the specified computer prestage
39+
deviceScope, err := client.GetDeviceScopeForComputerPrestage(prestageID)
40+
if err != nil {
41+
log.Fatalf("Error fetching device scope for computer prestage: %v", err)
42+
}
43+
44+
// Print out the fetched device scope
45+
fmt.Printf("Device Scope for Prestage ID: %s\n", prestageID)
46+
for _, assignment := range deviceScope.Assignments {
47+
fmt.Printf("Serial Number: %s, Assigned Date: %s, User Assigned: %s\n",
48+
assignment.SerialNumber,
49+
assignment.AssignmentDate,
50+
assignment.UserAssigned,
51+
)
52+
// Add more details to print as needed
53+
}
54+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"os"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
9+
)
10+
11+
func main() {
12+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json" // Update the path to your configuration file
13+
14+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
15+
if err != nil {
16+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
17+
}
18+
19+
config := jamfpro.Config{
20+
InstanceName: authConfig.InstanceName,
21+
DebugMode: true,
22+
Logger: jamfpro.NewDefaultLogger(),
23+
ClientID: authConfig.ClientID,
24+
ClientSecret: authConfig.ClientSecret,
25+
}
26+
27+
client, err := jamfpro.NewClient(config)
28+
if err != nil {
29+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
30+
}
31+
32+
newBranding := jamfpro.SelfServiceBrandingDetail{
33+
ApplicationName: "Self Service",
34+
BrandingName: "Self Service",
35+
BrandingNameSecondary: "Self Service",
36+
//IconId: 1, // IconId should match the icon image ID uploaded seperately
37+
//BrandingHeaderImageId: 1, // BrandingHeaderImageId should match the icon image ID uploaded seperately
38+
}
39+
40+
createdBranding, err := client.CreateSelfServiceBrandingMacOS(&newBranding)
41+
if err != nil {
42+
fmt.Fprintf(os.Stderr, "Error creating self-service branding for macOS: %v\n", err)
43+
os.Exit(1)
44+
}
45+
46+
fmt.Printf("Created Branding ID: %s\n", createdBranding.ID)
47+
fmt.Printf("Application Name: %s\n", createdBranding.ApplicationName)
48+
fmt.Printf("Branding Name: %s\n", createdBranding.BrandingName)
49+
fmt.Printf("Branding Name Secondary: %s\n", createdBranding.BrandingNameSecondary)
50+
fmt.Printf("Icon ID: %d\n", createdBranding.IconId)
51+
fmt.Printf("Branding Header Image ID: %d\n", createdBranding.BrandingHeaderImageId)
52+
}
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+
"fmt"
5+
"log"
6+
"os"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
9+
)
10+
11+
func main() {
12+
configFilePath := "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/clientauth.json" // Update the path to your configuration file
13+
14+
authConfig, err := jamfpro.LoadClientAuthConfig(configFilePath)
15+
if err != nil {
16+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
17+
}
18+
19+
config := jamfpro.Config{
20+
InstanceName: authConfig.InstanceName,
21+
DebugMode: true,
22+
Logger: jamfpro.NewDefaultLogger(),
23+
ClientID: authConfig.ClientID,
24+
ClientSecret: authConfig.ClientSecret,
25+
}
26+
27+
client, err := jamfpro.NewClient(config)
28+
if err != nil {
29+
log.Fatalf("Failed to create Jamf Pro client: %v", err)
30+
}
31+
32+
// Assume we have an ID for the branding we want to delete
33+
brandingID := "2" // Replace with your actual branding ID
34+
35+
// Call the delete function with the ID
36+
err = client.DeleteSelfServiceBrandingMacOSByID(brandingID)
37+
if err != nil {
38+
fmt.Fprintf(os.Stderr, "Error deleting self-service branding: %v\n", err)
39+
os.Exit(1)
40+
}
41+
42+
fmt.Println("Self Service Branding deleted successfully")
43+
}

0 commit comments

Comments
 (0)