Skip to content

Commit d4bdf67

Browse files
authored
Merge pull request #244 from deploymenttheory/dev-jl-version2
doc change
2 parents 2e10e1a + c3df238 commit d4bdf67

File tree

1 file changed

+1
-111
lines changed

1 file changed

+1
-111
lines changed

README.md

Lines changed: 1 addition & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -20,117 +20,7 @@ This HTTP client is intended to be used with targetted SDK's and terraform provi
2020
- **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.
2121
- **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.
2222

23-
- **Cookie Jar Support**: Incorporates an optional cookie jar to manage cookies effortlessly across requests, enhancing session management and statefulness with APIs that require cookie-based authentication or tracking. This feature allows for automatic storage and sending of cookies with subsequent requests, mirroring browser-like interaction with web services. It can be enabled or disabled based on configuration, providing flexibility in how stateful interactions are handled with the target API.
24-
25-
## API Handler
26-
27-
The `APIHandler` interface abstracts the functionality needed to interact with various APIs, making the HTTP client adaptable to different API implementations. It includes methods for constructing resource and authentication endpoints, marshaling requests, handling responses, and managing API-specific headers.
28-
29-
### Implementations
30-
31-
Currently, the HTTP client supports the following API handlers:
32-
33-
- **Jamf Pro**: Tailored for interacting with Jamf Pro's API, providing specialized methods for device management and configuration.
34-
- **Microsoft Graph**: Designed for Microsoft Graph API, enabling access to various Microsoft 365 services.
35-
36-
## Getting Started
37-
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-
50-
### Installation
51-
52-
To use this HTTP client in your project, add the package to your Go module dependencies:
53-
54-
```bash
55-
go get github.com/yourusername/go-api-http-client
56-
```
57-
58-
### Usage
59-
60-
Example usage with a configuration file using the jamfpro SDK client builder function:
61-
62-
```go
63-
package main
64-
65-
import (
66-
"encoding/xml"
67-
"fmt"
68-
"log"
69-
70-
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
71-
)
72-
73-
func main() {
74-
// Define the path to the JSON configuration file
75-
configFilePath := "/path/to/your/clientconfig.json"
76-
77-
// Initialize the Jamf Pro client with the HTTP client configuration
78-
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
79-
if err != nil {
80-
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
81-
}
82-
}
83-
84-
```
85-
86-
Example configuration file (clientconfig.json):
87-
88-
```json
89-
{
90-
"Auth": {
91-
"ClientID": "client-id", // set this for oauth2 based authentication
92-
"ClientSecret": "client-secret", // set this for oauth2 based authentication
93-
"Username": "username", // set this for basic auth
94-
"Password": "password" // set this for basic auth
95-
},
96-
"Environment": {
97-
"APIType": "", // define the api integration e.g "jamfpro" / "msgraph"
98-
"InstanceName": "yourinstance", // used for "jamfpro"
99-
"OverrideBaseDomain": "", // used for "jamfpro"
100-
"TenantID": "tenant-id", // used for "msgraph"h
101-
"TenantName ": "resource", // used for "msgraph"
102-
},
103-
"ClientOptions": {
104-
"Logging": {
105-
"LogLevel": "LogLevelDebug", // "LogLevelDebug" / "LogLevelInfo" / "LogLevelWarn" / "LogLevelError" / "LogLevelFatal" / "LogLevelPanic"
106-
"LogOutputFormat": "console", // "console" / "json"
107-
"LogConsoleSeparator": " ", // " " / "\t" / "," / etc.
108-
"LogExportPath": "/your/log/path/folder",
109-
"HideSensitiveData": true // redacts sensitive data from logs
110-
},
111-
"Cookies": {
112-
"EnableCookieJar": true, // enable cookie jar support
113-
"CustomCookies": { // set custom cookies as an alternative to cookie jar
114-
"sessionId": "abc123",
115-
"authToken": "xyz789"
116-
}
117-
},
118-
"Retry": {
119-
"MaxRetryAttempts": 5, // set number of retry attempts
120-
"EnableDynamicRateLimiting": true // enable dynamic rate limiting
121-
},
122-
"Concurrency": {
123-
"MaxConcurrentRequests": 3 // set number of concurrent requests
124-
},
125-
"Redirect": {
126-
"FollowRedirects": true, // follow redirects
127-
"MaxRedirects": 5 // set number of redirects to follow
128-
}
129-
}
130-
}
131-
```
132-
133-
23+
TBC
13424

13525

13626
## Reporting Issues and Feedback

0 commit comments

Comments
 (0)