Skip to content

Commit

Permalink
Merge pull request #28 from deploymenttheory/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ShocOne authored Nov 5, 2023
2 parents d5e069b + fdd0ae4 commit 19c1681
Show file tree
Hide file tree
Showing 28 changed files with 1,342 additions and 1,369 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ This document tracks the progress of API endpoint coverage tests. As endpoints a
- [ ] ✅ DELETE `/JSSResource/allowedfileextensions/id/{id}` - DeleteAllowedFileExtensionByID deletes an existing allowed file extension by ID
- [ ] ✅ DELETE `/JSSResource/allowedfileextensions/extension/{extensionName}` - DeleteAllowedFileExtensionByNameByID deletes an existing allowed file extension by resolving its name to an ID

### BYO Profiles - `/JSSResource/byoprofiles`

- [x] ✅ GET `/JSSResource/byoprofiles` - `GetBYOProfiles` retrieves all BYO profiles.
- [x] ✅ GET `/JSSResource/byoprofiles/id/{id}` - `GetBYOProfileByID` retrieves a BYO profile by its ID.
- [x] ✅ GET `/JSSResource/byoprofiles/name/{name}` - `GetBYOProfileByName` retrieves a BYO profile by its name.
- [x] ✅ POST `/JSSResource/byoprofiles/id/0` - `CreateBYOProfile` creates a new BYO profile.
- [x] ✅ PUT `/JSSResource/byoprofiles/id/{id}` - `UpdateBYOProfileByID` updates an existing BYO profile by its ID.
- [x] ✅ PUT `/JSSResource/byoprofiles/name/{oldName}` - `UpdateBYOProfileByName` updates an existing BYO profile by its name.
- [x] ✅ DELETE `/JSSResource/byoprofiles/id/{id}` - `DeleteBYOProfileByID` deletes an existing BYO profile by its ID.
- [x] ✅ DELETE `/JSSResource/byoprofiles/name/{name}` - `DeleteBYOProfileByName` deletes an existing BYO profile by its name.


### Jamf Pro API - Categories

- [ ] ✅ GET `/api/v1/categories` - `GetCategories` retrieves categories based on query parameters.
Expand Down
58 changes: 58 additions & 0 deletions examples/byoprofiles/CreateBYOProfile/CreateBYOProfile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package main

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

"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)
}

// Configuration for the jamfpro
config := jamfpro.Config{
InstanceName: authConfig.InstanceName,
DebugMode: true,
Logger: jamfpro.NewDefaultLogger(),
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)
}
// Create a BYOProfile structure to send
newProfile := jamfpro.ResponseBYOProfile{
General: jamfpro.BYOProfileGeneralInfo{
Name: "Personal Device Profile",
Site: jamfpro.BYOProfileSiteInfo{ID: -1, Name: "None"},
Enabled: true,
Description: "Used for Android or iOS BYO device enrollments",
},
}

// Convert the profile to XML to see the output (optional, for debug purposes)
xmlData, err := xml.MarshalIndent(newProfile, "", " ")
if err != nil {
log.Fatalf("Error marshaling XML: %v", err)
}
fmt.Printf("XML Request: %s\n", xmlData)

// Now call the create function
createdProfile, err := client.CreateBYOProfile(&newProfile)
if err != nil {
log.Fatalf("Error creating BYO Profile: %v", err)
}
fmt.Printf("Created BYO Profile: %+v\n", createdProfile)
}
43 changes: 43 additions & 0 deletions examples/byoprofiles/DeleteBYOProfileByID/DeleteBYOProfileByID.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import (
"fmt"
"log"

"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)
}

// Configuration for the jamfpro
config := jamfpro.Config{
InstanceName: authConfig.InstanceName,
DebugMode: true,
Logger: jamfpro.NewDefaultLogger(),
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)
}

profileID := 1 // Use the actual ID of the profile to be deleted

err = client.DeleteBYOProfileByID(profileID)
if err != nil {
log.Fatalf("Error deleting BYO Profile by ID: %v", err)
} else {
fmt.Println("BYO Profile deleted successfully by ID")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import (
"fmt"
"log"

"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)
}

// Configuration for the jamfpro
config := jamfpro.Config{
InstanceName: authConfig.InstanceName,
DebugMode: true,
Logger: jamfpro.NewDefaultLogger(),
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)
}

profileName := "Personal Device Profile" // Use the actual name of the profile to be deleted

err = client.DeleteBYOProfileByName(profileName)
if err != nil {
log.Fatalf("Error deleting BYO Profile by name: %v", err)
} else {
fmt.Println("BYO Profile deleted successfully by name")
}
}
42 changes: 42 additions & 0 deletions examples/byoprofiles/GetBYOProfileByID/GetBYOProfileByID.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"fmt"
"log"

"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)
}

// Configuration for the jamfpro
config := jamfpro.Config{
InstanceName: authConfig.InstanceName,
DebugMode: true,
Logger: jamfpro.NewDefaultLogger(),
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)
}

// Replace with the actual ID you want to retrieve
profileID := 1
profile, err := client.GetBYOProfileByID(profileID)
if err != nil {
log.Fatalf("Error fetching BYO Profile by ID: %v", err)
}
fmt.Printf("Fetched BYO Profile: %+v\n", profile)
}
42 changes: 42 additions & 0 deletions examples/byoprofiles/GetBYOProfileByName/GetBYOProfileByName.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"fmt"
"log"

"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)
}

// Configuration for the jamfpro
config := jamfpro.Config{
InstanceName: authConfig.InstanceName,
DebugMode: true,
Logger: jamfpro.NewDefaultLogger(),
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)
}

// Replace with the actual name you want to retrieve
profileName := "Personal Device Profile"
profile, err := client.GetBYOProfileByName(profileName)
if err != nil {
log.Fatalf("Error fetching BYO Profile by name: %v", err)
}
fmt.Printf("Fetched BYO Profile: %+v\n", profile)
}
46 changes: 46 additions & 0 deletions examples/byoprofiles/GetBYOProfiles/GetBYOProfiles.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

import (
"fmt"
"log"

"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)
}

// Configuration for the jamfpro
config := jamfpro.Config{
InstanceName: authConfig.InstanceName,
DebugMode: true,
Logger: jamfpro.NewDefaultLogger(),
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)
}

// Call GetBYOProfiles function
profiles, err := client.GetBYOProfiles()
if err != nil {
log.Fatalf("Failed to get BYO Profiles: %v", err)
}

// Print out the profiles
fmt.Printf("Total BYO Profiles: %d\n", profiles.Size)
for _, profile := range profiles.BYOProfiles {
fmt.Printf("ID: %d, Name: %s\n", profile.ID, profile.Name)
}
}
61 changes: 61 additions & 0 deletions examples/byoprofiles/UpdateBYOProfileByID/UpdateBYOProfileByID.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package main

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

"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)
}

// Configuration for the jamfpro
config := jamfpro.Config{
InstanceName: authConfig.InstanceName,
DebugMode: true,
Logger: jamfpro.NewDefaultLogger(),
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)
}

// Create a BYOProfile structure to send
updatedProfile := jamfpro.ResponseBYOProfile{
General: jamfpro.BYOProfileGeneralInfo{
Name: "Personal Device Profile Updated",
Site: jamfpro.BYOProfileSiteInfo{ID: -1, Name: "None"},
Enabled: true,
Description: "Updated description for BYO device enrollments",
},
}

profileID := 1 // Use the actual ID of the profile to be updated

// Convert the profile to XML to see the output (optional, for debug purposes)
xmlData, err := xml.MarshalIndent(updatedProfile, "", " ")
if err != nil {
log.Fatalf("Error marshaling XML: %v", err)
}
fmt.Printf("XML Request: %s\n", xmlData)

// Now call the update function
updatedProfileResp, err := client.UpdateBYOProfileByID(profileID, &updatedProfile)
if err != nil {
log.Fatalf("Error updating BYO Profile by ID: %v", err)
}
fmt.Printf("Updated BYO Profile: %+v\n", updatedProfileResp)
}
Loading

0 comments on commit 19c1681

Please sign in to comment.