@@ -18,14 +18,21 @@ import (
1818// with the workspace ID to all requests made by workspace clients
1919func workspaceOrgIdVisitor (cfg * Config ) func (r * http.Request ) error {
2020 return func (r * http.Request ) error {
21- if cfg .GetClientType () == WorkspaceClient && cfg . WorkspaceId != "" {
21+ if cfg .WorkspaceId != "" {
2222 r .Header .Set ("X-Databricks-Org-Id" , cfg .WorkspaceId )
2323 }
2424 return nil
2525 }
2626}
2727
28- func HTTPClientConfigFromConfig (cfg * Config ) (httpclient.ClientConfig , error ) {
28+ // noopVisitor creates a visitor that does nothing
29+ func noopVisitor () func (r * http.Request ) error {
30+ return func (r * http.Request ) error {
31+ return nil
32+ }
33+ }
34+
35+ func HTTPClientConfigFromConfig (cfg * Config , isWorkspaceClient bool ) (httpclient.ClientConfig , error ) {
2936 if skippable , ok := cfg .HTTPTransport .(interface {
3037 SkipRetryOnIO () bool
3138 }); ok && skippable .SkipRetryOnIO () {
@@ -85,7 +92,12 @@ func HTTPClientConfigFromConfig(cfg *Config) (httpclient.ClientConfig, error) {
8592 * r = * r .WithContext (ctx ) // replace request
8693 return nil
8794 },
88- workspaceOrgIdVisitor (cfg ),
95+ func () httpclient.RequestVisitor {
96+ if isWorkspaceClient {
97+ return workspaceOrgIdVisitor (cfg )
98+ }
99+ return noopVisitor ()
100+ }(),
89101 },
90102 TransientErrors : []string {
91103 // This is temporary workaround for SCIM API returning 500.
@@ -119,8 +131,8 @@ func (noopAuth) Configure(context.Context, *Config) (credentials.CredentialsProv
119131}
120132
121133// Deprecated: use [HTTPClientConfigFromConfig] with [httpclient.NewApiClient].
122- func (c * Config ) NewApiClient () (* httpclient.ApiClient , error ) {
123- cfg , err := HTTPClientConfigFromConfig (c )
134+ func (c * Config ) NewApiClient (isWorkspaceClient bool ) (* httpclient.ApiClient , error ) {
135+ cfg , err := HTTPClientConfigFromConfig (c , isWorkspaceClient )
124136 if err != nil {
125137 return nil , err
126138 }
0 commit comments