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

Version 2 #243

Merged
merged 136 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
454b015
more fix
thejoeker12 May 21, 2024
555af17
Merge pull request #194 from thejoeker12/main
thejoeker12 May 21, 2024
50720f3
fix
thejoeker12 May 21, 2024
08b4f8a
Merge pull request #195 from thejoeker12/main
thejoeker12 May 21, 2024
c8732d4
fix
thejoeker12 May 21, 2024
4cb17eb
Merge pull request #196 from thejoeker12/main
thejoeker12 May 21, 2024
d1c7ec7
fix fix
thejoeker12 May 21, 2024
7dac6f1
Merge pull request #197 from thejoeker12/main
thejoeker12 May 21, 2024
45ceb58
cookie jar no worky
thejoeker12 May 22, 2024
0542344
Merge branch 'dev-jl-cookiesOverhaul' into fix-cookiejar
thejoeker12 May 28, 2024
c51c091
Merge pull request #203 from deploymenttheory/fix-cookiejar
thejoeker12 May 28, 2024
d05dc17
Put cookie jar back into client. Why was it it's own package?
thejoeker12 May 28, 2024
c19004f
Refactoring things which do not need to be packages.
thejoeker12 May 28, 2024
c6bf072
Refactor continued
thejoeker12 May 28, 2024
07fbd2b
Refactor cont.
thejoeker12 May 28, 2024
30392e0
master struct flattening
thejoeker12 May 29, 2024
e8397c9
var renaming
thejoeker12 May 29, 2024
7861529
GetAuthMethod refactored slightly but I think I'm going to change the…
thejoeker12 May 29, 2024
a2ad528
ripping out repeated code and non-uniform logic for validation/defaul…
thejoeker12 May 29, 2024
afb677a
Validation func in prog
thejoeker12 May 29, 2024
a5b6bf6
Config value validation function complete. Removed retyping of time.D…
thejoeker12 May 29, 2024
a9fe9e0
client_configuration refactored
thejoeker12 May 29, 2024
ee2a998
Solving renaming issues before continuing to refactor to improve read…
thejoeker12 May 29, 2024
fd3f084
flattening structure
thejoeker12 May 29, 2024
83aa93f
continued
thejoeker12 May 29, 2024
26e2242
Skipping logging, I hate it.
thejoeker12 May 29, 2024
fd40970
Slowing detaching API handlers to act as plugins
thejoeker12 May 29, 2024
df409f9
More removing of handlers.
thejoeker12 May 29, 2024
5b49034
Doing away with lots of structs which just pass vars around
thejoeker12 May 29, 2024
fbbd303
Simplification refactor mostly complete. Other req types need to be d…
thejoeker12 May 29, 2024
572a5b1
Satisfying some modules
thejoeker12 May 29, 2024
8646c77
fixes for testing
thejoeker12 May 30, 2024
6fda7e6
bugfix
thejoeker12 May 30, 2024
a56955a
bugfix
thejoeker12 May 30, 2024
4f721de
bugfix
thejoeker12 May 30, 2024
4fd7a64
bugfix
thejoeker12 May 30, 2024
8add15e
Modulising auth into an interface 1
thejoeker12 May 31, 2024
904b839
Interfacing client data for modulisation
thejoeker12 Jun 3, 2024
866510a
Default value setter complete, integrated into validator func
thejoeker12 Jun 3, 2024
2872d76
Restructuring of api integrations
thejoeker12 Jun 3, 2024
d3dd1f9
Refactored request.go to fit new interface logic
thejoeker12 Jun 3, 2024
e9f58dd
refactor continued
thejoeker12 Jun 3, 2024
d6dd1f4
Removed pointers because they broke everything
thejoeker12 Jun 3, 2024
ae7d515
more removal
thejoeker12 Jun 3, 2024
1413af1
Jamf integration to it's own repo
thejoeker12 Jun 3, 2024
c3352dc
shut up go
thejoeker12 Jun 3, 2024
2108676
debug
thejoeker12 Jun 3, 2024
177d7db
debug
thejoeker12 Jun 4, 2024
428e2e9
debug
thejoeker12 Jun 4, 2024
03b8e57
debugging current changes
thejoeker12 Jun 4, 2024
50e2f4e
debugging
thejoeker12 Jun 4, 2024
2ca36f1
reimplemented anonymous func
thejoeker12 Jun 4, 2024
2995119
debugging
thejoeker12 Jun 4, 2024
52fc361
debugging
thejoeker12 Jun 4, 2024
b922f37
debugging
thejoeker12 Jun 4, 2024
2ee5402
debugging
thejoeker12 Jun 4, 2024
c84c2a5
debugging
thejoeker12 Jun 4, 2024
d127ebe
debug
thejoeker12 Jun 4, 2024
2d1701c
debugging
thejoeker12 Jun 4, 2024
bd9f982
stop making files please
thejoeker12 Jun 4, 2024
4c67a7e
update
thejoeker12 Jun 4, 2024
80f3b9c
fixing url
thejoeker12 Jun 4, 2024
b579e2c
req debugging - headers required
thejoeker12 Jun 4, 2024
966b6ed
header debug
thejoeker12 Jun 4, 2024
ecd067b
debug
thejoeker12 Jun 4, 2024
d5332e6
debug
thejoeker12 Jun 4, 2024
0d5ef8f
adding headers
thejoeker12 Jun 4, 2024
be6a1d8
debug
thejoeker12 Jun 4, 2024
b2fc7aa
renaming funcs
thejoeker12 Jun 4, 2024
2aa6325
header func removed from interface
thejoeker12 Jun 4, 2024
e6c7ca3
print req as pretty json
thejoeker12 Jun 4, 2024
0c7fa62
pff
thejoeker12 Jun 4, 2024
b0f18e0
Reimplementing auth logic
thejoeker12 Jun 4, 2024
4747da8
debug
thejoeker12 Jun 4, 2024
0f92e3b
debug
thejoeker12 Jun 4, 2024
64073c3
boom
thejoeker12 Jun 4, 2024
ea9677f
Code reviewing - comments adjusted.
thejoeker12 Jun 5, 2024
02a497f
lots of TODOs
thejoeker12 Jun 5, 2024
0b2e992
add
thejoeker12 Jun 5, 2024
e41d833
More tidying up
thejoeker12 Jun 5, 2024
a4a40ec
reimplemented multipart req logic from v1
thejoeker12 Jun 5, 2024
8f6424f
mod sum
thejoeker12 Jun 5, 2024
01a4bbe
Reimplemented default value setting
thejoeker12 Jun 5, 2024
190ed7f
I hate logging
thejoeker12 Jun 5, 2024
8f808b3
fix
thejoeker12 Jun 5, 2024
27588e3
removed log
thejoeker12 Jun 5, 2024
1cd3f67
migrated to integration
thejoeker12 Jun 7, 2024
cbf580f
comment todo
thejoeker12 Jun 10, 2024
b713726
interface changes
thejoeker12 Jun 10, 2024
51c89be
shut up
thejoeker12 Jun 10, 2024
1dcd3ec
integration support updates
thejoeker12 Jun 10, 2024
df65ad3
debugging
thejoeker12 Jun 10, 2024
b0b2da6
Solving some redundant conflicts
thejoeker12 Jun 10, 2024
7c1bf7c
more solving
thejoeker12 Jun 10, 2024
16f23a4
and more
thejoeker12 Jun 10, 2024
22fdff2
multipart updated for client v2
thejoeker12 Jun 10, 2024
191fa0e
resolving conflicts
thejoeker12 Jun 10, 2024
77cf263
resolving
thejoeker12 Jun 10, 2024
2af9c3f
Merge pull request #236 from deploymenttheory/dev-jl-version2
thejoeker12 Jun 10, 2024
5535776
boop
thejoeker12 Jun 10, 2024
53d7b9e
tidying up
thejoeker12 Jun 10, 2024
e141e65
Merge pull request #237 from deploymenttheory/dev-jl-version2
thejoeker12 Jun 10, 2024
3a4284f
cookie func added
thejoeker12 Jun 10, 2024
bb237a8
update
thejoeker12 Jun 10, 2024
faa6da9
fix
thejoeker12 Jun 10, 2024
195a2f9
debug
thejoeker12 Jun 10, 2024
ab09568
debug
thejoeker12 Jun 10, 2024
c5e5a89
debug
thejoeker12 Jun 10, 2024
82b8333
rename
thejoeker12 Jun 10, 2024
030eb85
update
thejoeker12 Jun 10, 2024
0c10fff
jar made
thejoeker12 Jun 10, 2024
96652c9
debug
thejoeker12 Jun 10, 2024
3f4370f
Merge pull request #238 from deploymenttheory/dev-jl-version2
thejoeker12 Jun 10, 2024
4324072
mod
thejoeker12 Jun 10, 2024
38f2fbd
logger to arg
thejoeker12 Jun 10, 2024
419f1ae
Merge pull request #239 from deploymenttheory/dev-jl-version2
thejoeker12 Jun 10, 2024
7a57529
mod sum
thejoeker12 Jun 11, 2024
505576d
modsum
thejoeker12 Jun 12, 2024
8ad7563
debug
thejoeker12 Jun 14, 2024
1faf217
removed log level validation
thejoeker12 Jun 14, 2024
b454c35
ew
thejoeker12 Jun 14, 2024
89970b5
littleif
thejoeker12 Jun 14, 2024
67cda8b
update
thejoeker12 Jun 17, 2024
2335731
Merge branch 'staging-version2' into dev-jl-version2
thejoeker12 Jun 17, 2024
a0db942
Merge pull request #240 from deploymenttheory/dev-jl-version2
thejoeker12 Jun 17, 2024
2c6ef92
bugfix
thejoeker12 Jun 17, 2024
ce1bf28
concurrency flag added
thejoeker12 Jun 17, 2024
256e134
bodge
thejoeker12 Jun 17, 2024
b34e699
Removed concurrency management
thejoeker12 Jun 18, 2024
b2ea5b4
Merge pull request #241 from deploymenttheory/dev-jl-version2
thejoeker12 Jun 18, 2024
1d27d52
appeasing the static check monster
thejoeker12 Jun 18, 2024
676a0da
general tidiness improvements, removal of some comments.
thejoeker12 Jun 19, 2024
a45474d
removed a comment
thejoeker12 Jun 19, 2024
2e10e1a
Merge pull request #242 from deploymenttheory/dev-jl-version2
thejoeker12 Jun 19, 2024
c3df238
doc change
thejoeker12 Jun 19, 2024
d4bdf67
Merge pull request #244 from deploymenttheory/dev-jl-version2
thejoeker12 Jun 19, 2024
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
112 changes: 1 addition & 111 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,117 +20,7 @@ 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.

- **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.

## API Handler

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.

### Implementations

Currently, the HTTP client supports the following API handlers:

- **Jamf Pro**: Tailored for interacting with Jamf Pro's API, providing specialized methods for device management and configuration.
- **Microsoft Graph**: Designed for Microsoft Graph API, enabling access to various Microsoft 365 services.

## 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:

```bash
go get github.com/yourusername/go-api-http-client
```

### Usage

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

```go
package main

import (
"encoding/xml"
"fmt"
"log"

"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
)

func main() {
// Define the path to the JSON configuration file
configFilePath := "/path/to/your/clientconfig.json"

// Initialize the Jamf Pro client with the HTTP client configuration
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
if err != nil {
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
}
}

```

Example configuration file (clientconfig.json):

```json
{
"Auth": {
"ClientID": "client-id", // set this for oauth2 based authentication
"ClientSecret": "client-secret", // set this for oauth2 based authentication
"Username": "username", // set this for basic auth
"Password": "password" // set this for basic auth
},
"Environment": {
"APIType": "", // define the api integration e.g "jamfpro" / "msgraph"
"InstanceName": "yourinstance", // used for "jamfpro"
"OverrideBaseDomain": "", // used for "jamfpro"
"TenantID": "tenant-id", // used for "msgraph"h
"TenantName ": "resource", // used for "msgraph"
},
"ClientOptions": {
"Logging": {
"LogLevel": "LogLevelDebug", // "LogLevelDebug" / "LogLevelInfo" / "LogLevelWarn" / "LogLevelError" / "LogLevelFatal" / "LogLevelPanic"
"LogOutputFormat": "console", // "console" / "json"
"LogConsoleSeparator": " ", // " " / "\t" / "," / etc.
"LogExportPath": "/your/log/path/folder",
"HideSensitiveData": true // redacts sensitive data from logs
},
"Cookies": {
"EnableCookieJar": true, // enable cookie jar support
"CustomCookies": { // set custom cookies as an alternative to cookie jar
"sessionId": "abc123",
"authToken": "xyz789"
}
},
"Retry": {
"MaxRetryAttempts": 5, // set number of retry attempts
"EnableDynamicRateLimiting": true // enable dynamic rate limiting
},
"Concurrency": {
"MaxConcurrentRequests": 3 // set number of concurrent requests
},
"Redirect": {
"FollowRedirects": true, // follow redirects
"MaxRedirects": 5 // set number of redirects to follow
}
}
}
```


TBC


## Reporting Issues and Feedback
Expand Down
55 changes: 0 additions & 55 deletions apiintegrations/apihandler/apihandler.go

This file was deleted.

66 changes: 0 additions & 66 deletions apiintegrations/apihandler/apihandler_test.go.TODO

This file was deleted.

38 changes: 0 additions & 38 deletions apiintegrations/jamfpro/README.MD

This file was deleted.

45 changes: 0 additions & 45 deletions apiintegrations/jamfpro/jamfpro_api_exceptions.go

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions apiintegrations/jamfpro/jamfpro_api_handler.go

This file was deleted.

Loading
Loading