Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This Go module offers a sophisticated HTTP client designed for seamless API inte

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.

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.

## Features

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

## Getting Started

## HTTP Client Build Flow

The HTTP client build flow can be initiated using a number of methods. The primary methods include:

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.

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.

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.

![HTTP Client Build Flow](docs/media/BuildClient.png)

### Installation

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

### Usage
Example usage with a configuration file:

Example usage with a configuration file using the jamfpro SDK client builder function:

```go
package main
Expand Down Expand Up @@ -84,23 +99,21 @@ Example configuration file (clientconfig.json):
"APIType": "" // "jamfpro" / "graph"
},
"ClientOptions": {
"LogLevel": "LogLevelDebug", // "LogLevelDebug" / "LogLevelInfo" / "LogLevelWarn" / "LogLevelError" / "LogLevelFatal" / "LogLevelPanic"
"LogLevel": "LogLevelDebug", // "LogLevelDebug" / "LogLevelInfo" / "LogLevelWarn" / "LogLevelError" / "LogLevelFatal" / "LogLevelPanic"
"LogOutputFormat": "console", // "console" / "json"
"LogConsoleSeparator": " ", // " " / "\t" / "," / etc.
"HideSensitiveData": true, // true / false
"EnableDynamicRateLimiting": true, // true / false
"MaxRetryAttempts": 5,
"MaxConcurrentRequests": 3,
"EnableCookieJar": true // true / false
"LogConsoleSeparator": " ", // " " / "\t" / "," / etc.
"LogExportPath": "/path/to/export/your/logs",
"HideSensitiveData": true, // redacts sensitive data from logs
"MaxRetryAttempts": 5, // set number of retry attempts
"MaxConcurrentRequests": 3, // set number of concurrent requests
"EnableCookieJar": false, // enable cookie jar support
"FollowRedirects": true, // follow redirects
"MaxRedirects": 5 // set number of redirects to follow
}
}
```

## Status

[![Super Linter](<https://github.com/segraef/Template/actions/workflows/linter.yml/badge.svg>)](<https://github.com/segraef/Template/actions/workflows/linter.yml>)

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


## Reporting Issues and Feedback
Expand Down
103 changes: 0 additions & 103 deletions docs/markdown-syntax-guide.md

This file was deleted.

Binary file added docs/media/BuildClient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/media/MicrosoftAzure-32px.png
Binary file not shown.
Binary file removed docs/media/MicrosoftPowerShellCore-32px.png
Binary file not shown.
3 changes: 3 additions & 0 deletions httpclient/client_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ func LoadConfigFromEnv(config *ClientConfig) (*ClientConfig, error) {
config.ClientOptions.LogConsoleSeparator = getEnvOrDefault("LOG_CONSOLE_SEPARATOR", config.ClientOptions.LogConsoleSeparator)
log.Printf("LogConsoleSeparator env value found and set to: %s", config.ClientOptions.LogConsoleSeparator)

config.ClientOptions.LogExportPath = getEnvOrDefault("LOG_EXPORT_PATH", config.ClientOptions.LogExportPath)
log.Printf("LogExportPath env value found and set to: %s", config.ClientOptions.LogExportPath)

config.ClientOptions.HideSensitiveData = parseBool(getEnvOrDefault("HIDE_SENSITIVE_DATA", strconv.FormatBool(config.ClientOptions.HideSensitiveData)))
log.Printf("HideSensitiveData env value found and set to: %t", config.ClientOptions.HideSensitiveData)

Expand Down