Skip to content

Commit ee71746

Browse files
committed
Add example usage and configuration file***
The commit message should be: ***Add example usage and configuration file
1 parent f5eb8f8 commit ee71746

File tree

1 file changed

+68
-2
lines changed

1 file changed

+68
-2
lines changed

README.md

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,73 @@ go get github.com/yourusername/go-api-http-client
2626
```
2727

2828
### Usage
29-
Import the package and configure the client according to your API's needs:
29+
Example usage with a configuration file:
30+
31+
```go
32+
package main
33+
34+
import (
35+
"fmt"
36+
"log"
37+
38+
"github.com/deploymenttheory/go-api-http-client/httpclient"
39+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
40+
)
41+
42+
func main() {
43+
configFilePath := "/path/to/clientconfig.json"
44+
loadedConfig, err := jamfpro.LoadClientConfig(configFilePath)
45+
if err != nil {
46+
log.Fatalf("Failed to load client OAuth configuration: %v", err)
47+
}
48+
49+
config := httpclient.ClientConfig{
50+
Auth: httpclient.AuthConfig{
51+
ClientID: loadedConfig.Auth.ClientID,
52+
ClientSecret: loadedConfig.Auth.ClientSecret,
53+
},
54+
Environment: httpclient.EnvironmentConfig{
55+
APIType: loadedConfig.Environment.APIType,
56+
InstanceName: loadedConfig.Environment.InstanceName,
57+
},
58+
ClientOptions: httpclient.ClientOptions{
59+
LogLevel: loadedConfig.ClientOptions.LogLevel,
60+
HideSensitiveData: loadedConfig.ClientOptions.HideSensitiveData,
61+
LogOutputFormat: loadedConfig.ClientOptions.LogOutputFormat,
62+
},
63+
}
64+
65+
client, err := jamfpro.BuildClient(config)
66+
if err != nil {
67+
log.Fatalf("Failed to create client: %v", err)
68+
}
69+
}
70+
71+
```
72+
73+
Example configuration file (clientconfig.json):
74+
75+
```json
76+
{
77+
"Auth": {
78+
"ClientID": "client-id",
79+
"ClientSecret": "client-secret",
80+
"Username": "username",
81+
"Password": "password"
82+
},
83+
"Environment": {
84+
"InstanceName": "yourinstance",
85+
"OverrideBaseDomain": "",
86+
"APIType": "" // "jamfpro" / "graph"
87+
},
88+
"ClientOptions": {
89+
"LogLevel": "LogLevelDebug", // "LogLevelDebug" / "LogLevelInfo" / "LogLevelWarn" / "LogLevelError" / "LogLevelFatal" / "LogLevelPanic"
90+
"LogOutputFormat": "console", // "console" / "json"
91+
"LogConsoleSeparator": " ", // " " / "\t" / "," / etc.
92+
"HideSensitiveData": true, // true / false
93+
}
94+
}
95+
```
3096

3197
## Status
3298

@@ -45,7 +111,7 @@ If you are taking the time to mention a problem, even a seemingly minor one, it
45111

46112
## Feedback
47113

48-
If there is a feature you would like to see in here, please file an issue or feature request in the [GitHub Issues][GitHubIssues] page to provide direct feedback.
114+
Contributions are welcome to make this HTTP client even better! Feel free to fork the repository, make your improvements, and submit a pull request. For major changes or new features, please file an issue or feature request in the [GitHub Issues][GitHubIssues] page to discuss what you would like to change.
49115

50116
## Contribution
51117

0 commit comments

Comments
 (0)