Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Added support for custom api_endpoint #1027

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions dbt/adapters/bigquery/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import google.auth.exceptions
import google.cloud.bigquery as bigquery
import google.cloud.exceptions
from google.api_core import retry, client_info
from google.api_core import retry, client_info, client_options
from google.auth import impersonated_credentials
from google.auth.credentials import AnonymousCredentials
from google.oauth2 import (
credentials as GoogleCredentials,
service_account as GoogleServiceAccountCredentials,
Expand Down Expand Up @@ -98,6 +99,7 @@ class BigQueryConnectionMethod(StrEnum):
SERVICE_ACCOUNT = "service-account"
SERVICE_ACCOUNT_JSON = "service-account-json"
OAUTH_SECRETS = "oauth-secrets"
ANONYMOUS = "anonymous"


@dataclass
Expand Down Expand Up @@ -355,6 +357,8 @@ def get_google_credentials(cls, profile_credentials) -> GoogleCredentials:
token_uri=profile_credentials.token_uri,
scopes=profile_credentials.scopes,
)
elif method == BigQueryConnectionMethod.ANONYMOUS:
return AnonymousCredentials()

error = 'Invalid `method` in profile: "{}"'.format(method)
raise FailedToConnectError(error)
Expand Down Expand Up @@ -383,11 +387,11 @@ def get_bigquery_client(cls, profile_credentials):
location = getattr(profile_credentials, "location", None)

info = client_info.ClientInfo(user_agent=f"dbt-{dbt_version}")

api_endpoint = getattr(profile_credentials, "api_endpoint", None)
options = client_options.ClientOptions(api_endpoint=api_endpoint)
return google.cloud.bigquery.Client(
execution_project,
creds,
location=location,
client_info=info,
execution_project, creds, location=location, client_info=info, client_options=options
)

@classmethod
Expand Down