Skip to content

Commit 10f5770

Browse files
authored
Merge pull request #69 from deploymenttheory/dev
Dev
2 parents e135047 + e2432a7 commit 10f5770

File tree

27 files changed

+4344
-200
lines changed

27 files changed

+4344
-200
lines changed

README.md

Lines changed: 333 additions & 163 deletions
Large diffs are not rendered by default.
File renamed without changes.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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
24+
25+
// Configuration for the jamfpro client
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+
// Define the parameters for the file upload
41+
resource := "ebooks" // Example resource, adjust as needed
42+
idType := "id" // Can be id or name, Name is supported for all but the peripherals resource
43+
id := "3" // Example ID of the resource to attach the file upload to. can be a numeral or a resource name as needed
44+
45+
// Define the files to be uploaded
46+
files := map[string]string{
47+
"fileFieldName": "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/examples/support_files/ebooks_pdf/Apple-Developer-Program-License-Agreement-20230828-English.pdf", // Replace with your actual file and field name
48+
}
49+
50+
// Call the CreateFileAttachments method
51+
resp, err := client.CreateFileAttachments(resource, idType, id, files)
52+
if err != nil {
53+
fmt.Printf("Error uploading file attachments: %v\n", err)
54+
return
55+
}
56+
57+
// Process the response as needed
58+
fmt.Println("File attachments uploaded successfully:", resp.Status)
59+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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
24+
25+
// Configuration for the jamfpro client
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+
// Define the parameters for the file upload
41+
resource := "policies" // Example resource, adjust as needed
42+
idType := "id" // Can be id or name, Name is supported for all but the peripherals resource
43+
id := "7" // Example ID of the resource to attach the file upload to. can be a numeral or a resource name as needed
44+
45+
// Define the files to be uploaded
46+
files := map[string]string{
47+
"fileFieldName": "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/examples/support_files/printer_ppd/cnadv400x1g.ppd", // Replace with your actual file and field name
48+
}
49+
50+
// Call the CreateFileAttachments method
51+
resp, err := client.CreateFileAttachments(resource, idType, id, files)
52+
if err != nil {
53+
fmt.Printf("Error uploading file attachments: %v\n", err)
54+
return
55+
}
56+
57+
// Process the response as needed
58+
fmt.Println("File attachments uploaded successfully:", resp.Status)
59+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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
24+
25+
// Configuration for the jamfpro client
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+
// Define the parameters for the file upload
41+
resource := "printers" // Example resource, adjust as needed
42+
idType := "id" // Can be id or name, Name is supported for all but the peripherals resource
43+
id := "104" // Example ID of the resource to attach the file upload to. can be a numeral or a resource name as needed
44+
45+
// Define the files to be uploaded
46+
files := map[string]string{
47+
"fileFieldName": "/Users/dafyddwatkins/GitHub/deploymenttheory/go-api-sdk-jamfpro/examples/support_files/printer_ppd/cnadv400x1g.ppd", // Replace with your actual file and field name
48+
}
49+
50+
// Call the CreateFileAttachments method
51+
resp, err := client.CreateFileAttachments(resource, idType, id, files)
52+
if err != nil {
53+
fmt.Printf("Error uploading file attachments: %v\n", err)
54+
return
55+
}
56+
57+
// Process the response as needed
58+
fmt.Println("File attachments uploaded successfully:", resp.Status)
59+
}
Binary file not shown.

0 commit comments

Comments
 (0)