Add support for custom headers in WorkspaceClient and AccountClient.#1245
Merged
renaudhartert-db merged 5 commits intomainfrom Feb 6, 2026
Merged
Conversation
This change allows users to pass custom HTTP headers that will be
automatically included in all API requests made by the client.
Changes:
- Added `custom_headers` parameter to WorkspaceClient and AccountClient
constructors
- Added `custom_headers` parameter to Config class to store the headers
- Modified ApiClient.do() to merge custom headers with request-specific
headers (request headers take precedence)
- Added comprehensive tests to verify the functionality
Usage example:
```python
from databricks.sdk import WorkspaceClient
w = WorkspaceClient(
host="https://your-workspace.databricks.com",
token="your-token",
custom_headers={
"X-Custom-Header": "custom-value",
"X-Request-ID": "request-123"
}
)
# All requests now include the custom headers
w.clusters.list()
```
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This change allows users to pass custom HTTP headers that will be
automatically included in all API requests made by the client.
Changes:
- Added `custom_headers` parameter to WorkspaceClient and AccountClient
constructors
- Added `custom_headers` parameter to Config class to store the headers
- Modified ApiClient.do() to merge custom headers with request-specific
headers (request headers take precedence)
- Added comprehensive tests to verify the functionality
Usage example:
```python
from databricks.sdk import WorkspaceClient
w = WorkspaceClient(
host="https://your-workspace.databricks.com",
token="your-token",
custom_headers={
"X-Custom-Header": "custom-value",
"X-Request-ID": "request-123"
}
)
# All requests now include the custom headers
w.clusters.list()
```
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…github.com-ghec:databricks/databricks-sdk-py into feature/custom-headers-support
Added comprehensive docstrings to explain the custom_headers parameter and its behavior across WorkspaceClient, AccountClient, and Config classes. Documentation clarifies: - Purpose: Add custom HTTP headers to all API requests - Behavior: Headers are merged with standard headers - Precedence: Request-specific headers can override custom headers - Example usage with dictionary format Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Run make fmt to fix formatting issues in test_custom_headers.py Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
hectorcast-db
approved these changes
Feb 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for custom HTTP headers in
WorkspaceClientandAccountClient, allowing users to pass headers that will be automatically included in all API requests.Request-specific headers can still override custom headers when needed. The parameter is optional, so existing code continues to work without changes
Changes
custom_headersparameter toWorkspaceClientandAccountClientconstructorscustom_headersparameter toConfigclass to store the headersApiClient.do()to merge custom headers with request-specific headers (request headers take precedence)Usage Example
Testing
Added unit tests.