OpenMetadata/openmetadata-clients
Ross Andreucetti 5d368fdba5
feat: Add extraHeaders support to Java client (#24236)
* feat: Add extraHeaders support to Java client

The Java client was missing extraHeaders functionality that exists
in the Python SDK. This prevented users from adding custom headers
like X-Caller-Service to identify upstream services in logs.

This implementation:
- Adds extraHeaders processing in OpenMetadata.java initClient()
- Implements template substitution for header values using %(HeaderName)s syntax
- Ensures auth interceptor runs before extra headers interceptor for proper header reference
- Matches Python SDK behavior from client.py lines 199-202

Users can now set extraHeaders in OpenMetadataConnection:
  connection.setExtraHeaders(
    new ExtraHeaders().withAdditionalProperty("X-Caller-Service", "my-service")
  )

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: Restore apiClient.addAuthorization call

The previous commit incorrectly removed the addAuthorization call
which is needed for the ApiClient to properly register the auth
interceptor. Now both addAuthorization and the extra headers
interceptor work together.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: Simplify extraHeaders to static values only

Remove template substitution feature (regex pattern matching) that
was copied from Python SDK but not actually used anywhere. The
simpler implementation:

- Removed Pattern/Matcher imports and regex logic (~40 lines)
- Removed extractCurrentHeaders and resolveTemplateValue helpers
- Now just sets static header values directly
- Matches actual usage patterns (no template substitution needed)

This keeps the implementation focused on the real use case:
  extraHeaders.put("X-Caller-Service", "my-service")

Template substitution can be added later if actually needed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update OpenMetadata.java

---------

Co-authored-by: randreucetti <randreucetti@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-12-24 10:15:44 -08:00
..
2025-12-17 18:36:03 +05:30