-
Notifications
You must be signed in to change notification settings - Fork 5
/
example_client_setup_with_manual_conf.go
54 lines (48 loc) · 1.53 KB
/
example_client_setup_with_manual_conf.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"fmt"
"log"
"time"
"github.com/deploymenttheory/go-api-http-client/httpclient"
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
)
func main() {
// Manually define the client configuration
config := httpclient.ClientConfig{
Environment: httpclient.EnvironmentConfig{
InstanceName: "your-instance-name",
OverrideBaseDomain: "", // Only required if you are not on jamfcloud.com
APIType: "jamfpro", // Required to specify the API type
},
Auth: httpclient.AuthConfig{
ClientID: "your-client-id",
ClientSecret: "your-client-secret",
},
ClientOptions: httpclient.ClientOptions{
LogLevel: "LogLevelDebug",
LogOutputFormat: "console",
HideSensitiveData: true,
MaxRetryAttempts: 5,
EnableDynamicRateLimiting: true,
MaxConcurrentRequests: 10,
TokenRefreshBufferPeriod: 5 * time.Minute,
TotalRetryDuration: 60 * time.Second,
CustomTimeout: 30 * time.Second,
},
}
// Initialize the Jamf Pro client with the given configuration
client, err := jamfpro.BuildClient(config)
if err != nil {
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
}
// Call the GetComputers method
computers, err := client.GetComputers()
if err != nil {
log.Fatalf("Error fetching computers: %v", err)
}
// Print out the fetched computers
fmt.Println("Fetched Computers:")
for _, computer := range computers.Results {
fmt.Printf("ID: %d, Name: %s\n", computer.ID, computer.Name)
}
}