{"id":47784516,"url":"https://github.com/itential/igsdk","last_synced_at":"2026-04-03T14:15:39.914Z","repository":{"id":342615962,"uuid":"1173550707","full_name":"itential/igsdk","owner":"itential","description":"Go SDK for Itential Platform and Itential Automation Gateway v4 APIs, providing HTTP clients with authentication, structured logging, sensitive data redaction and error handling.","archived":false,"fork":false,"pushed_at":"2026-03-06T15:44:28.000Z","size":58,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-06T19:21:59.162Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itential.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":"CLA.md"}},"created_at":"2026-03-05T13:48:07.000Z","updated_at":"2026-03-06T15:44:32.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/itential/igsdk","commit_stats":null,"previous_names":["itential/igsdk"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/itential/igsdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itential%2Figsdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itential%2Figsdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itential%2Figsdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itential%2Figsdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itential","download_url":"https://codeload.github.com/itential/igsdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itential%2Figsdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31356882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T08:03:20.796Z","status":"ssl_error","status_checked_at":"2026-04-03T08:00:37.834Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-03T14:15:39.044Z","updated_at":"2026-04-03T14:15:39.892Z","avatar_url":"https://github.com/itential.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# igsdk\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/itential/igsdk.svg)](https://pkg.go.dev/github.com/itential/igsdk)\n[![Build Status](https://github.com/itential/igsdk/actions/workflows/ci.yml/badge.svg)](https://github.com/itential/igsdk/actions/workflows/ci.yml)\n[![License](https://img.shields.io/badge/License-GPL--3.0-blue.svg)](LICENSE)\n[![GitHub release](https://img.shields.io/github/v/release/itential/igsdk)](https://github.com/itential/igsdk/releases)\n\nA Go SDK for the Itential Automation Platform and Itential Automation Gateway. It provides\nidiomatic HTTP clients with automatic authentication, TTL-based re-authentication, structured\nlogging with sensitive-data redaction, and context-aware request tracing.\n\n## Features\n\n- **Dual-client support** - Separate `PlatformClient` and `GatewayClient` for the Itential Automation Platform and Gateway\n- **Automatic authentication** - Basic Auth and OAuth 2.0 (Client Credentials) handled transparently on every request\n- **TTL-based re-authentication** - Configurable token lifetimes with automatic re-auth before expiry\n- **Structured logging** - Text and JSON loggers built on `log/slog` with optional sensitive-data redaction\n- **Context-aware tracing** - Attach trace IDs and correlation fields to a `context.Context`; they appear in all SDK log entries for that request\n- **Concurrency-safe** - Both clients are safe for use by multiple goroutines\n\n## Requirements\n\n- Go 1.24+\n\n## Installation\n\n```bash\ngo get github.com/itential/igsdk\n```\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n\n    \"github.com/itential/igsdk\"\n)\n\nfunc main() {\n    client, err := igsdk.NewPlatformClient(\"platform.example.com\",\n        igsdk.WithBasicAuth(\"admin\", \"password\"),\n    )\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    resp, err := client.Get(context.Background(), \"/health/server\", nil)\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    fmt.Println(resp.StatusCode())\n}\n```\n\n## Usage\n\n### Platform Client\n\n```go\nclient, err := igsdk.NewPlatformClient(\"platform.example.com\",\n    igsdk.WithBasicAuth(\"admin\", \"password\"),\n    igsdk.WithTLS(true),\n    igsdk.WithVerify(true),\n    igsdk.WithTimeout(30 * time.Second),\n    igsdk.WithTTL(15 * time.Minute),\n)\n```\n\n### Gateway Client\n\n```go\nclient, err := igsdk.NewGatewayClient(\"gateway.example.com\",\n    igsdk.WithBasicAuth(\"admin@itential\", \"password\"),\n)\n// Requests are automatically prefixed with /api/v2.0\nresp, err := client.Get(ctx, \"/devices\", nil)\n```\n\n### OAuth Authentication (Platform only)\n\n```go\nclient, err := igsdk.NewPlatformClient(\"platform.example.com\",\n    igsdk.WithOAuth(\"my-client-id\", \"my-client-secret\"),\n)\n```\n\n### Making Requests\n\nAll HTTP methods accept a `context.Context`, a path, optional query parameters, and optional\nper-request options:\n\n```go\n// GET with query parameters\nparams := url.Values{\"limit\": []string{\"10\"}, \"skip\": []string{\"0\"}}\nresp, err := client.Get(ctx, \"/adapters\", params)\n\n// POST with a JSON payload\npayload := map[string]any{\"name\": \"MyAdapter\", \"type\": \"HTTP\"}\nresp, err := client.Post(ctx, \"/adapters\", nil, payload)\n\n// PUT / PATCH / DELETE\nresp, err := client.Put(ctx, \"/adapters/123\", nil, updates)\nresp, err := client.Patch(ctx, \"/adapters/123\", nil, changes)\nresp, err := client.Delete(ctx, \"/adapters/123\", nil)\n```\n\n### Handling Responses\n\n```go\nresp, err := client.Get(ctx, \"/users/me\", nil)\nif err != nil {\n    return err\n}\n\n// Parse JSON\nvar user map[string]any\nif err := resp.JSON(\u0026user); err != nil {\n    return err\n}\n\n// Raw text\nbody := resp.Text()\n\n// Status inspection\nfmt.Println(resp.StatusCode())\nfmt.Println(resp.IsSuccess())\nfmt.Println(resp.IsError())\n```\n\n### Error Handling\n\nHTTP 4xx/5xx responses are returned as `*igsdk.HTTPStatusError`:\n\n```go\nresp, err := client.Get(ctx, \"/resource/missing\", nil)\nif err != nil {\n    var httpErr *igsdk.HTTPStatusError\n    if errors.As(err, \u0026httpErr) {\n        switch httpErr.StatusCode {\n        case 404:\n            fmt.Println(\"resource not found\")\n        case 401:\n            fmt.Println(\"authentication failed\")\n        default:\n            fmt.Printf(\"HTTP error: %s\\n\", httpErr.Status)\n        }\n    }\n    return err\n}\n```\n\n### Logging\n\n```go\n// Text logger (stderr, Info level by default)\nlogger := igsdk.NewLogger(\n    igsdk.WithLogLevel(slog.LevelDebug),\n    igsdk.WithLogOutput(os.Stdout),\n)\n\n// JSON logger\nlogger := igsdk.NewJSONLogger(igsdk.WithLogLevel(slog.LevelDebug))\n\nclient, err := igsdk.NewPlatformClient(\"platform.example.com\",\n    igsdk.WithLogger(logger),\n)\n```\n\n### Sensitive Data Redaction\n\n```go\nscanner := igsdk.NewScanner()\n\nlogger := igsdk.NewLogger(igsdk.WithSensitiveDataRedaction(scanner))\n\nclient, err := igsdk.NewPlatformClient(\"platform.example.com\",\n    igsdk.WithLogger(logger),\n    igsdk.WithScanner(scanner),\n)\n```\n\n### Request Tracing\n\nAttach correlation fields to a context; the SDK includes them in every log entry\nfor requests made with that context:\n\n```go\nctx = igsdk.LogContext(ctx, \"request_id\", reqID, \"tenant\", tenantID)\nresp, err := client.Get(ctx, \"/resources\", nil)\n```\n\n### Custom Request Headers\n\n```go\nresp, err := client.Get(ctx, \"/report\", nil,\n    igsdk.WithHeader(\"Accept\", \"application/xml\"),\n)\n```\n\n## Documentation\n\n- [API Reference](https://pkg.go.dev/github.com/itential/igsdk) - Full GoDoc reference\n- [Contributing Guide](CONTRIBUTING.md) - How to contribute to this project\n- [Changelog](CHANGELOG.md) - Version history and release notes\n\n## Contributing\n\nContributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) to get started.\n\nBefore contributing, you'll need to sign our [Contributor License Agreement](CLA.md).\n\n## Support\n\n- **Bug Reports**: [Open an issue](https://github.com/itential/igsdk/issues/new)\n- **Questions**: [Start a discussion](https://github.com/itential/igsdk/discussions)\n- **Maintainer**: [@privateip](https://github.com/privateip)\n\n## License\n\nThis project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.\n\n---\n\n\u003cp align=\"center\"\u003e\n  Made with ❤️  by the \u003ca href=\"https://github.com/itential\"\u003eItential\u003c/a\u003e community\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitential%2Figsdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitential%2Figsdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitential%2Figsdk/lists"}