Skip to content

Commit 11de98a

Browse files
authored
Merge pull request #50 from deploymenttheory/dev
+ sdk coverage fo mobile device enrollment profile
2 parents 72e371b + 04a25c5 commit 11de98a

File tree

16 files changed

+1199
-3
lines changed

16 files changed

+1199
-3
lines changed

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,11 +975,56 @@ This documentation outlines the API endpoints available for managing Mobile Exte
975975
- [x] ✅ **DELETE** `/JSSResource/mobiledeviceextensionattributes/name/{name}`
976976
`DeleteMobileExtensionAttributeByName` deletes a Mobile Extension Attribute by its name.
977977
978+
### Jamf Pro Classic API - Mobile Device Enrollment Profiles
979+
980+
This documentation outlines the API endpoints available for managing Mobile Device Enrollment Profiles within Jamf Pro using the Classic API, which supports XML data structures.
981+
982+
## Endpoints
983+
984+
- [x] ✅ **GET** `/JSSResource/mobiledeviceenrollmentprofiles`
985+
`GetMobileDeviceEnrollmentProfiles` retrieves a serialized list of all Mobile Device Enrollment Profiles.
986+
987+
- [x] ✅ **GET** `/JSSResource/mobiledeviceenrollmentprofiles/id/{id}`
988+
`GetMobileDeviceEnrollmentProfileByID` fetches details of a single Mobile Device Enrollment Profile by its ID.
989+
990+
- [x] ✅ **GET** `/JSSResource/mobiledeviceenrollmentprofiles/name/{name}`
991+
`GetMobileDeviceEnrollmentProfileByName` retrieves details of a Mobile Device Enrollment Profile by its name.
992+
993+
- [x] ✅ **GET** `/JSSResource/mobiledeviceenrollmentprofiles/invitation/{invitation}`
994+
`GetProfileByInvitation` fetches a Mobile Device Enrollment Profile by its invitation.
995+
996+
- [x] ✅ **GET** `/JSSResource/mobiledeviceenrollmentprofiles/id/{id}/subset/{subset}`
997+
`GetMobileDeviceEnrollmentProfileByIDBySubset` fetches a specific Mobile Device Enrollment Profile by its ID and a specified subset.
998+
999+
- [x] ✅ **GET** `/JSSResource/mobiledeviceenrollmentprofiles/name/{name}/subset/{subset}`
1000+
`GetMobileDeviceEnrollmentProfileByNameBySubset` fetches a specific Mobile Device Enrollment Profile by its name and a specified subset.
1001+
1002+
- [x] ✅ **POST** `/JSSResource/mobiledeviceenrollmentprofiles/id/0`
1003+
`CreateMobileDeviceEnrollmentProfile` creates a new Mobile Device Enrollment Profile. The ID `0` in the endpoint indicates creation.
1004+
1005+
- [x] ✅ **PUT** `/JSSResource/mobiledeviceenrollmentprofiles/id/{id}`
1006+
`UpdateMobileDeviceEnrollmentProfileByID` updates an existing Mobile Device Enrollment Profile by its ID.
1007+
1008+
- [x] ✅ **PUT** `/JSSResource/mobiledeviceenrollmentprofiles/name/{name}`
1009+
`UpdateMobileDeviceEnrollmentProfileByName` updates an existing Mobile Device Enrollment Profile by its name.
1010+
1011+
- [x] ✅ **PUT** `/JSSResource/mobiledeviceenrollmentprofiles/invitation/{invitation}`
1012+
`UpdateMobileDeviceEnrollmentProfileByInvitation` updates an existing Mobile Device Enrollment Profile by its invitation.
1013+
1014+
- [x] ✅ **DELETE** `/JSSResource/mobiledeviceenrollmentprofiles/id/{id}`
1015+
`DeleteMobileDeviceEnrollmentProfileByID` deletes a Mobile Device Enrollment Profile by its ID.
1016+
1017+
- [x] ✅ **DELETE** `/JSSResource/mobiledeviceenrollmentprofiles/name/{name}`
1018+
`DeleteMobileDeviceEnrollmentProfileByName` deletes a Mobile Device Enrollment Profile by its name.
1019+
1020+
- [x] ✅ **DELETE** `/JSSResource/mobiledeviceenrollmentprofiles/invitation/{invitation}`
1021+
`DeleteMobileDeviceEnrollmentProfileByInvitation` deletes a Mobile Device Enrollment Profile by its invitation.
1022+
9781023
9791024
## Progress Summary
9801025
981-
- Total Endpoints: 318
982-
- Covered: 299
1026+
- Total Endpoints: 331
1027+
- Covered: 312
9831028
- Not Covered: 19
9841029
- Partially Covered: 0
9851030
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
newProfile := jamfpro.ResponseMobileDeviceEnrollmentProfile{
41+
General: jamfpro.MobileDeviceEnrollmentProfileGeneral{
42+
Name: "Configurator Enrollment Profile",
43+
Description: "string",
44+
},
45+
Location: jamfpro.MobileDeviceEnrollmentProfileLocation{
46+
// Initialize with empty or specific values if required
47+
Username: "",
48+
Realname: "",
49+
RealName: "",
50+
EmailAddress: "",
51+
Position: "",
52+
Phone: "",
53+
PhoneNumber: "",
54+
Department: "",
55+
Building: "",
56+
Room: 0, // or specific room number
57+
},
58+
Purchasing: jamfpro.MobileDeviceEnrollmentProfilePurchasing{
59+
IsPurchased: true,
60+
IsLeased: false,
61+
PONumber: "",
62+
Vendor: "",
63+
ApplecareID: "",
64+
PurchasePrice: "",
65+
PurchasingAccount: "",
66+
PODate: "",
67+
PODateEpoch: 0,
68+
PODateUTC: "",
69+
WarrantyExpires: "",
70+
WarrantyExpiresEpoch: 0,
71+
WarrantyExpiresUTC: "",
72+
LeaseExpires: "",
73+
LeaseExpiresEpoch: 0,
74+
LeaseExpiresUTC: "",
75+
LifeExpectancy: 0,
76+
PurchasingContact: "",
77+
},
78+
}
79+
80+
profile, err := client.CreateMobileDeviceEnrollmentProfile(&newProfile)
81+
if err != nil {
82+
fmt.Println("Error creating enrollment profile:", err)
83+
return
84+
}
85+
86+
fmt.Printf("Created Profile: %+v\n", profile)
87+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
profileID := 1 // Replace with actual ID
41+
42+
err = client.DeleteMobileDeviceEnrollmentProfileByID(profileID)
43+
if err != nil {
44+
log.Fatalf("Error deleting profile by name: %v", err)
45+
}
46+
47+
fmt.Println("Profile deleted successfully.")
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
invitation := "YourInvitationCode" // Replace with actual invitation name
41+
42+
err = client.DeleteMobileDeviceEnrollmentProfileByInvitation(invitation)
43+
if err != nil {
44+
log.Fatalf("Error deleting profile by name: %v", err)
45+
}
46+
47+
fmt.Println("Profile deleted successfully.")
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
profileName := "Configurator Enrollment Profile" // Replace with actual name
41+
42+
err = client.DeleteMobileDeviceEnrollmentProfileByName(profileName)
43+
if err != nil {
44+
log.Fatalf("Error deleting profile by name: %v", err)
45+
}
46+
47+
fmt.Println("Profile deleted successfully.")
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
profileID := 1 // Replace with the actual ID
42+
43+
profile, err := client.GetMobileDeviceEnrollmentProfileByID(profileID)
44+
if err != nil {
45+
fmt.Println("Error fetching profile by name:", err)
46+
return
47+
}
48+
// Pretty print the extension attribute details in XML
49+
applicationsXML, err := xml.MarshalIndent(profile, "", " ") // Indent with 4 spaces and use '='
50+
if err != nil {
51+
log.Fatalf("Error marshaling policy details data: %v", err)
52+
}
53+
fmt.Println("Created Policy Details:\n", string(applicationsXML))
54+
}
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+
profileID := 1 // Replace with the actual profile ID
41+
subset := "general" // Replace with the actual subset (e.g., "general")
42+
43+
profile, err := client.GetMobileDeviceEnrollmentProfileByIDBySubset(profileID, subset)
44+
if err != nil {
45+
fmt.Println("Error fetching profile by name and subset:", err)
46+
return
47+
}
48+
49+
fmt.Printf("Profile: %+v\n", profile)
50+
}

0 commit comments

Comments
 (0)