Skip to content

Commit 04c8b17

Browse files
authored
initial implementation of igsdk Go SDK (#1)
Add a Go SDK for the Itential Automation Platform and Automation Gateway HTTP APIs, providing idiomatic Go clients with the following features: - PlatformClient and GatewayClient with full CRUD HTTP methods (Get, Post, Put, Patch, Delete) - Automatic authentication: Basic Auth and OAuth 2.0 client credentials (Platform only) - TTL-based token re-authentication with mutex-protected auth state - Functional options pattern for client and per-request configuration - Structured logging via log/slog with Debug-level request/response tracing - Sensitive data redaction via Scanner (passwords, tokens, secrets, URLs) - Context-aware APIs for cancellation and timeout propagation - Thread-safe clients safe for use across multiple goroutines - HTTPStatusError type for programmatic HTTP error handling - Package-level version and build metadata via GetInfo() - Table-driven test suite covering auth flows, HTTP methods, and error paths
1 parent 4b196e9 commit 04c8b17

20 files changed

Lines changed: 3780 additions & 228 deletions

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
ci:
8+
name: CI
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Set up Go
14+
uses: actions/setup-go@v5
15+
with:
16+
go-version-file: go.mod
17+
18+
- name: Install tools
19+
run: make tools
20+
21+
- name: Run CI
22+
run: make ci

.gitignore

Lines changed: 149 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,173 @@
1-
# =============================================================================
2-
# OS Generated Files
3-
# =============================================================================
4-
.DS_Store
5-
.DS_Store?
6-
._*
7-
.Spotlight-V100
8-
.Trashes
9-
ehthumbs.db
10-
Thumbs.db
11-
desktop.ini
1+
# ---> Go
2+
# Binaries for programs and plugins
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
9+
# Test binary, built with `go test -c`
10+
*.test
11+
12+
# Output of the go coverage tool
13+
*.out
14+
cover.*
15+
cover/
16+
coverage.out
17+
coverage.html
18+
*.cov
19+
*.coverprofile
20+
21+
# Go workspace file
22+
go.work
23+
go.work.sum
24+
25+
# Build output
26+
bin/
27+
dist/
28+
build/
29+
!build/*.go
30+
31+
# Dependency directories
32+
# vendor/
1233

13-
# =============================================================================
14-
# Editor and IDE
15-
# =============================================================================
16-
# JetBrains (IntelliJ, PyCharm, GoLand, etc.)
34+
# ---> IDE and Editor Files
35+
# IntelliJ IDEA / GoLand
1736
.idea/
37+
.idea
38+
*.iml
39+
*.iws
40+
*.ipr
1841

19-
# VS Code (uncomment to ignore all settings, or keep to share workspace config)
20-
# .vscode/
42+
# Visual Studio Code
43+
.vscode/
44+
*.code-workspace
45+
46+
# Sublime Text
47+
*.sublime-project
48+
*.sublime-workspace
2149

2250
# Vim
2351
*.swp
2452
*.swo
2553
*~
54+
.*.swp
55+
.*.swo
2656

2757
# Emacs
58+
*~
2859
\#*\#
29-
.#*
60+
.\#*
61+
.projectile
3062

31-
# =============================================================================
32-
# Security - NEVER commit these
33-
# =============================================================================
34-
.env
35-
.env.*
36-
!.env.example
63+
# Eclipse
64+
.classpath
65+
.project
66+
.settings/
67+
68+
# ---> OS-specific Files
69+
# macOS
70+
.DS_Store
71+
.AppleDouble
72+
.LSOverride
73+
Icon
74+
._*
75+
.DocumentRevisions-V100
76+
.fseventsd
77+
.Spotlight-V100
78+
.TemporaryItems
79+
.Trashes
80+
.VolumeIcon.icns
81+
.com.apple.timemachine.donotpresent
82+
.AppleDB
83+
.AppleDesktop
84+
Network Trash Folder
85+
Temporary Items
86+
.apdisk
87+
88+
# Windows
89+
Thumbs.db
90+
Thumbs.db:encryptable
91+
ehthumbs.db
92+
ehthumbs_vista.db
93+
*.stackdump
94+
[Dd]esktop.ini
95+
$RECYCLE.BIN/
96+
*.cab
97+
*.msi
98+
*.msix
99+
*.msm
100+
*.msp
101+
*.lnk
102+
103+
# Linux
104+
.directory
105+
.Trash-*
106+
.nfs*
107+
108+
# ---> Security and Secrets
37109
*.pem
110+
*.crt
38111
*.key
39112
*.p12
40113
*.pfx
41-
credentials.json
114+
*.cer
115+
*.der
116+
*_key
117+
*_cert
118+
*.env
119+
.env
120+
.env.*
121+
!.env.example
122+
secrets/
42123
secrets.yaml
43124
secrets.yml
125+
secrets.json
44126

45-
# =============================================================================
46-
# Logs and Databases
47-
# =============================================================================
127+
# ---> Logs and Temporary Files
48128
*.log
49129
logs/
50-
*.sqlite
51-
*.sqlite3
52-
*.db
53-
54-
# =============================================================================
55-
# Build Artifacts and Caches
56-
# =============================================================================
57-
dist/
58-
build/
59-
out/
60-
.cache/
61130
*.tmp
62131
*.temp
132+
tmp/
133+
temp/
134+
*.bak
135+
*.backup
136+
*.pid
137+
*.seed
138+
*.pid.lock
139+
140+
# ---> Project-specific
141+
# Docker config file
142+
build/torero.conf
143+
144+
# Python virtualenv for docs
145+
venv/
146+
.venv/
147+
env/
148+
ENV/
149+
150+
# Temporary files
151+
./delete
152+
delete
153+
*.diff
154+
155+
# Debug and profiling
156+
debug
157+
*.prof
158+
*.trace
159+
pprof.*
160+
cpu.out
161+
mem.out
162+
block.out
163+
mutex.out
164+
165+
# Air live reload
166+
tmp/
167+
.air.toml
63168

64-
# =============================================================================
65-
# Test Coverage
66-
# =============================================================================
67-
coverage/
68-
htmlcov/
69-
.coverage
70-
*.cover
71-
72-
# =============================================================================
73-
# MAINTAINER: Add language-specific patterns below
74-
# =============================================================================
75-
# Examples:
76-
#
77-
# Python:
78-
# __pycache__/
79-
# *.py[cod]
80-
# .venv/
81-
# venv/
82-
# .pytest_cache/
83-
#
84-
# Node.js:
85-
# node_modules/
86-
# npm-debug.log
87-
# .npm/
88-
#
89-
# Go:
90-
# vendor/
91-
# *.exe
92-
#
93-
# Rust:
94-
# target/
95-
# Cargo.lock (for libraries only)
169+
# Local configuration overrides
170+
*.local
171+
*_local.go
172+
local.conf
173+
config.local.*

AGENTS.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
This repository is a Go module: `github.com/itential/igsdk`.
5+
6+
- Root package files contain SDK functionality:
7+
- `client.go`: core HTTP client, auth flow, TTL re-auth, request methods
8+
- `platform.go`, `gateway.go`: client constructors
9+
- `errors.go`, `http_types.go`, `jsonutils.go`: shared types/utilities
10+
- `logging.go`, `heuristics.go`: logging and sensitive-data redaction
11+
- `metadata.go`, `init.go`: package metadata and initialization
12+
- Tests live in `client_test.go` (table-driven and behavior-focused tests).
13+
- Module metadata is in `go.mod`.
14+
15+
Keep new code in the root package unless a clear subpackage boundary emerges.
16+
17+
## Build, Test, and Development Commands
18+
Use standard Go tooling:
19+
20+
- `go test ./...` runs all tests.
21+
- `go test ./... -cover` reports package coverage.
22+
- `go test ./... -coverprofile=cover.out && go tool cover -func=cover.out` shows per-function coverage.
23+
- `gofmt -w *.go` formats all Go files in this repository.
24+
25+
Run formatting and tests before opening a PR.
26+
27+
## Coding Style & Naming Conventions
28+
- Follow idiomatic Go and `gofmt` output (tabs, standard formatting).
29+
- Exported APIs use `PascalCase` (`NewPlatformClient`); internal helpers use `camelCase` (`makeBaseURL`).
30+
- Keep constructors `New...`-prefixed.
31+
- Prefer explicit error wrapping/types over string-only errors.
32+
- Keep functions focused and small; use comments only where behavior is non-obvious.
33+
34+
## Testing Guidelines
35+
- Use Go’s built-in `testing` package.
36+
- Name tests as `TestXxxBehavior` (e.g., `TestNewGatewayClientDefaults`).
37+
- Cover success paths, edge cases, and failure branches (auth errors, HTTP errors, serialization failures).
38+
- Coverage target: strive for very high coverage; avoid untested exported behavior.
39+
40+
## Commit & Pull Request Guidelines
41+
- Write commit messages in imperative mood: `rename factory constructors`, `add gateway auth tests`.
42+
- Keep commits focused (one logical change per commit).
43+
- PRs should include:
44+
- What changed and why
45+
- Any API changes or breaking behavior
46+
- Test evidence (`go test ./...` output summary)
47+
- Linked issue/ticket when applicable
48+
49+
## Security & Configuration Notes
50+
- Never commit credentials, tokens, or real endpoint secrets.
51+
- Preserve sensitive-data redaction behavior in logging paths.
52+
- Prefer `context.Context`-aware APIs for cancellation and timeout control.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

0 commit comments

Comments
 (0)