Skip to content

Commit

Permalink
Merge pull request #12 from deploymenttheory/dev
Browse files Browse the repository at this point in the history
Added classicapi_computer_extension_attributes_test.go
  • Loading branch information
ShocOne authored Oct 29, 2023
2 parents 9a5726a + 8c35515 commit 2707d33
Show file tree
Hide file tree
Showing 6 changed files with 707 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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 inside the main function
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)
}

// Define the ID of the Computer Prestage you want to fetch as a string
prestageID := "2" // Replace with the actual prestage ID as a string

// Call GetComputerPrestageByID function
prestage, err := client.GetComputerPrestageByID(prestageID)
if err != nil {
log.Fatalf("Error fetching Computer Prestage by ID: %v", err)
}

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

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

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

const (
prestageName = "pse-ade_lbgstaging_Jamf_Connect_New_Config-1.1-0000" // Replace with the actual prestage name you want to fetch
)

func main() {
// Define the path to the JSON configuration file inside the main function
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 GetComputerPrestageByNameByID function
prestage, err := client.GetComputerPrestageByNameByID(prestageName)
if err != nil {
log.Fatalf("Error fetching Jamf computer prestage by name: %v", err)
}

// Pretty print the prestage in JSON
prestageJSON, err := json.MarshalIndent(prestage, "", " ") // Indent with 4 spaces
if err != nil {
log.Fatalf("Error marshaling Jamf computer prestage data: %v", err)
}
fmt.Println("Fetched Jamf computer prestage:\n", string(prestageJSON))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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 inside the main function
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 GetComputerPrestages function
prestages, err := client.GetComputerPrestages()
if err != nil {
log.Fatalf("Error fetching Computer Prestages: %v", err)
}

// Pretty print the prestages in XML
prestagesXML, err := xml.MarshalIndent(prestages, "", " ") // Indent with 4 spaces
if err != nil {
log.Fatalf("Error marshaling Computer Prestages data: %v", err)
}
fmt.Println("Fetched Computer Prestages:\n", string(prestagesXML))
}
Loading

0 comments on commit 2707d33

Please sign in to comment.