Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated docs for refactor changes #247

Merged
merged 3 commits into from
Jun 21, 2024
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
55 changes: 14 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

This Go module offers a sophisticated HTTP client designed for seamless API interactions, with a strong emphasis on concurrency management, robust error handling, extensive logging, and adaptive rate limiting. It's particularly suitable for applications requiring high-throughput API interactions with complex authentication and operational resilience.

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 client is designed to be used with targetted SDK's and terraform providers only. As such the http client cannot be used without a supporting SDK and associated api integration plugin [go-api-http-client-integrations](https://github.com/deploymenttheory/go-api-http-client-integrations).

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.
The plugin is required to provide the necessary API-specific handlers and configuration to the HTTP client. The plugin approach is designed to provide a consistent interface for interacting with various APIs, including Microsoft Graph, Jamf Pro, and others. It is easily extensible to support additional APIs and 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. Conseqently the client provides core common HTTP client functionality, such as rate limiting, logging, concurrency and responses while the plugin provides the API-specific logic, such as encoding and decoding requests, managing authentication endpoints, and handling API-specific logic.

## Features
## HTTP Client Features

- **Comprehensive Authentication Support**: Robust support for various authentication schemes, including OAuth and Bearer Token, with built-in token management and validation.
- **Advanced Concurrency Management**: An intelligent Concurrency Manager dynamically adjusts concurrent request limits to optimize throughput and adhere to API rate limits.
Expand All @@ -20,42 +20,19 @@ This HTTP client is intended to be used with targetted SDK's and terraform provi
- **API Handler Interface**: Provides a flexible and extensible way to interact with different APIs, including encoding and decoding requests and responses, managing authentication endpoints, and handling API-specific logic.
- **Configuration via JSON or Environment Variables**: The Go API HTTP Client supports configuration via JSON files or environment variables, providing flexibility in defining authentication credentials, API endpoints, logging settings, and other parameters.

TBC

## Getting Started
'
{
"Integration": {
"FQDN": "https://api.example.com",
"AuthMethodDescriptor": "Bearer"
// other necessary fields for integration
},
"HideSensitiveData": true,
"CustomCookies": [
{
"Name": "sessionid",
"Value": "abc123",
"Path": "/",
"Domain": "example.com",
"Expires": "2025-01-02T15:04:05Z",
"MaxAge": 86400,
"Secure": true,
"HttpOnly": true,
"SameSite": 1
}
],
"MaxRetryAttempts": 5,
"MaxConcurrentRequests": 10,
"EnableDynamicRateLimiting": true,
"CustomTimeout": "10s",
"TokenRefreshBufferPeriod": "2m",
"TotalRetryDuration": "10m",
"FollowRedirects": true,
"MaxRedirects": 3,
"ConcurrencyManagementEnabled": true
}
'

This SDK requires an existing Go environment to build and run. If you do not have Go installed, you can download and install it from the [official Go website](https://golang.org/doc/install).



## SDK Support

This http client is used in conjuction with the following SDKs:

- [go-api-sdk-m365](https://github.com/deploymenttheory/go-api-sdk-m365)

- [go-api-sdk-jamfpro](https://github.com/deploymenttheory/go-api-sdk-jamfpro)

## Reporting Issues and Feedback

Expand All @@ -75,10 +52,6 @@ If you would like to become an active contributor to this repository or project,

## Learn More

* [GitHub Documentation][GitHubDocs]
* [Azure DevOps Documentation][AzureDevOpsDocs]
* [Microsoft Azure Documentation][MicrosoftAzureDocs]

<!-- References -->

<!-- Local -->
Expand Down
16 changes: 8 additions & 8 deletions httpclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ type Client struct {
// Options/Variables for Client
type ClientConfig struct {
Integration APIIntegration
HideSensitiveData bool
HideSensitiveData bool `json:"hide_sensitive_data"`
CustomCookies []*http.Cookie
MaxRetryAttempts int
MaxConcurrentRequests int
EnableDynamicRateLimiting bool
MaxRetryAttempts int `json:"max_retry_attempts"`
MaxConcurrentRequests int `json:"max_concurrent_requests"`
EnableDynamicRateLimiting bool `json:"enable_dynamic_rate_limiting"`
CustomTimeout time.Duration
TokenRefreshBufferPeriod time.Duration
TotalRetryDuration time.Duration // TODO do we need this now it's in the integration?
FollowRedirects bool
MaxRedirects int
EnableConcurrencyManagement bool
TotalRetryDuration time.Duration
FollowRedirects bool `json:"follow_redirects"`
MaxRedirects int `json:"max_redirects"`
EnableConcurrencyManagement bool `json:"enable_concurrency_management"`
}

// BuildClient creates a new HTTP client with the provided configuration.
Expand Down
Loading