Skip to content

Commit 8fd0f59

Browse files
authored
Merge pull request #148 from deploymenttheory/dev
Updated documention for BuildClient
2 parents 80a6644 + 0d14a74 commit 8fd0f59

File tree

6 files changed

+28
-115
lines changed

6 files changed

+28
-115
lines changed

README.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This Go module offers a sophisticated HTTP client designed for seamless API inte
44

55
This client leverages API-specific SDKs to provide a comprehensive and consistent interface for interacting with various APIs, including Microsoft Graph, Jamf Pro, and others. It is designed to be easily extensible to support additional APIs and to be highly configurable to meet specific API requirements. It achieves this through using a modular design, with a core HTTP client and API-specific handlers that encapsulate the unique requirements of each API supported.
66

7+
This HTTP client is intended to be used with targetted SDK's and terraform providers only. As such the http client cannot be used without a supporting SDK.
8+
79
## Features
810

911
- **Comprehensive Authentication Support**: Robust support for various authentication schemes, including OAuth and Bearer Token, with built-in token management and validation.
@@ -33,6 +35,18 @@ Currently, the HTTP client supports the following API handlers:
3335

3436
## Getting Started
3537

38+
## HTTP Client Build Flow
39+
40+
The HTTP client build flow can be initiated using a number of methods. The primary methods include:
41+
42+
Using the SDK `BuildClientWithConfigFile` function, which reads the configuration from a JSON file and constructs the client accordingly. The configuration file specifies the authentication details, API environment settings, and client options, such as logging level, retry attempts, and concurrency limits.
43+
44+
Or using the SDK `BuildClientWithEnvironmentVariables` function, which reads the configuration from environment variables and constructs the client accordingly. This method allows for more flexible configuration management, particularly in containerized environments or when using orchestration tools.
45+
46+
There is also the option to the build the client manually by creating a new `Client` struct and setting the required fields directly. This method provides the most granular control over the client configuration and can be useful for advanced use cases or when integrating with existing configuration management systems. This is the approached used in related terraform providers.
47+
48+
![HTTP Client Build Flow](docs/media/BuildClient.png)
49+
3650
### Installation
3751

3852
To use this HTTP client in your project, add the package to your Go module dependencies:
@@ -42,7 +56,8 @@ go get github.com/yourusername/go-api-http-client
4256
```
4357

4458
### Usage
45-
Example usage with a configuration file:
59+
60+
Example usage with a configuration file using the jamfpro SDK client builder function:
4661

4762
```go
4863
package main
@@ -84,23 +99,21 @@ Example configuration file (clientconfig.json):
8499
"APIType": "" // "jamfpro" / "graph"
85100
},
86101
"ClientOptions": {
87-
"LogLevel": "LogLevelDebug", // "LogLevelDebug" / "LogLevelInfo" / "LogLevelWarn" / "LogLevelError" / "LogLevelFatal" / "LogLevelPanic"
102+
"LogLevel": "LogLevelDebug", // "LogLevelDebug" / "LogLevelInfo" / "LogLevelWarn" / "LogLevelError" / "LogLevelFatal" / "LogLevelPanic"
88103
"LogOutputFormat": "console", // "console" / "json"
89-
"LogConsoleSeparator": " ", // " " / "\t" / "," / etc.
90-
"HideSensitiveData": true, // true / false
91-
"EnableDynamicRateLimiting": true, // true / false
92-
"MaxRetryAttempts": 5,
93-
"MaxConcurrentRequests": 3,
94-
"EnableCookieJar": true // true / false
104+
"LogConsoleSeparator": " ", // " " / "\t" / "," / etc.
105+
"LogExportPath": "/path/to/export/your/logs",
106+
"HideSensitiveData": true, // redacts sensitive data from logs
107+
"MaxRetryAttempts": 5, // set number of retry attempts
108+
"MaxConcurrentRequests": 3, // set number of concurrent requests
109+
"EnableCookieJar": false, // enable cookie jar support
110+
"FollowRedirects": true, // follow redirects
111+
"MaxRedirects": 5 // set number of redirects to follow
95112
}
96113
}
97114
```
98115

99-
## Status
100-
101-
[![Super Linter](<https://github.com/segraef/Template/actions/workflows/linter.yml/badge.svg>)](<https://github.com/segraef/Template/actions/workflows/linter.yml>)
102116

103-
[![Sample Workflow](<https://github.com/segraef/Template/actions/workflows/workflow.yml/badge.svg>)](<https://github.com/segraef/Template/actions/workflows/workflow.yml>)
104117

105118

106119
## Reporting Issues and Feedback

docs/markdown-syntax-guide.md

Lines changed: 0 additions & 103 deletions
This file was deleted.

docs/media/BuildClient.png

157 KB
Loading

docs/media/MicrosoftAzure-32px.png

-1020 Bytes
Binary file not shown.
-1.56 KB
Binary file not shown.

httpclient/client_configuration.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ func LoadConfigFromEnv(config *ClientConfig) (*ClientConfig, error) {
104104
config.ClientOptions.LogConsoleSeparator = getEnvOrDefault("LOG_CONSOLE_SEPARATOR", config.ClientOptions.LogConsoleSeparator)
105105
log.Printf("LogConsoleSeparator env value found and set to: %s", config.ClientOptions.LogConsoleSeparator)
106106

107+
config.ClientOptions.LogExportPath = getEnvOrDefault("LOG_EXPORT_PATH", config.ClientOptions.LogExportPath)
108+
log.Printf("LogExportPath env value found and set to: %s", config.ClientOptions.LogExportPath)
109+
107110
config.ClientOptions.HideSensitiveData = parseBool(getEnvOrDefault("HIDE_SENSITIVE_DATA", strconv.FormatBool(config.ClientOptions.HideSensitiveData)))
108111
log.Printf("HideSensitiveData env value found and set to: %t", config.ClientOptions.HideSensitiveData)
109112

0 commit comments

Comments
 (0)