Skip to content

Add support for custom headers in WorkspaceClient and AccountClient.#1245

Merged
renaudhartert-db merged 5 commits intomainfrom
renaud-hartert_data/feature/custom-headers-support
Feb 6, 2026
Merged

Add support for custom headers in WorkspaceClient and AccountClient.#1245
renaudhartert-db merged 5 commits intomainfrom
renaud-hartert_data/feature/custom-headers-support

Conversation

@renaudhartert-db
Copy link
Contributor

@renaudhartert-db renaudhartert-db commented Feb 5, 2026

Summary

This PR adds support for custom HTTP headers in WorkspaceClient and AccountClient, 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

  • 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

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()

Testing

Added unit tests.

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>
renaudhartert-db and others added 2 commits February 5, 2026 19:34
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>
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-py

Inputs:

  • PR number: 1245
  • Commit SHA: d5d4956b1497382d2cb15f0c3ee55e5694013a26

Checks will be approved automatically on success.

@renaudhartert-db renaudhartert-db added this pull request to the merge queue Feb 6, 2026
Merged via the queue into main with commit 4a80b43 Feb 6, 2026
17 checks passed
@renaudhartert-db renaudhartert-db deleted the renaud-hartert_data/feature/custom-headers-support branch February 6, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants