Skip to content

Commit 3ec143d

Browse files
committed
Merge branch 'zack-client-creds' of github.com:posit-dev/posit-sdk-py into zack-client-creds
2 parents b229b4b + d58a743 commit 3ec143d

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

docs/_quarto.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,7 @@ quartodoc:
107107
contents:
108108
- connect.metrics
109109
- connect.metrics.usage
110+
- title: External Integrations
111+
contents:
112+
- connect.external.databricks
113+
- connect.external.snowflake

src/posit/connect/content.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,8 @@ def find_by(
755755
-------
756756
Optional[ContentItem]
757757
758-
Example
759-
-------
758+
Examples
759+
--------
760760
>>> find_by(name="example-content-name")
761761
"""
762762
attr_items = attrs.items()

src/posit/connect/external/databricks.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515
# The Databricks SDK CredentialsProvider == Databricks SQL HeaderFactory
1616
CredentialsProvider = Callable[[], Dict[str, str]]
1717

18+
1819
class CredentialsStrategy(abc.ABC):
1920
"""Maintain compatibility with the Databricks SQL/SDK client libraries.
2021
21-
https://github.com/databricks/databricks-sql-python/blob/v3.3.0/src/databricks/sql/auth/authenticators.py#L19-L33
22-
https://github.com/databricks/databricks-sdk-py/blob/v0.29.0/databricks/sdk/credentials_provider.py#L44-L54
22+
See Also
23+
--------
24+
* https://github.com/databricks/databricks-sql-python/blob/v3.3.0/src/databricks/sql/auth/authenticators.py#L19-L33
25+
* https://github.com/databricks/databricks-sdk-py/blob/v0.29.0/databricks/sdk/credentials_provider.py#L44-L54
2326
"""
2427

2528
@abc.abstractmethod
@@ -47,7 +50,8 @@ def _new_bearer_authorization_header(credentials: Credentials) -> Dict[str, str]
4750
raise ValueError("Missing value for field 'access_token' in credentials.")
4851
return {"Authorization": f"Bearer {access_token}"}
4952

50-
def _get_auth_type(local_auth_type: str) -> str:
53+
54+
def _get_auth_type(local_auth_type: str) -> str:
5155
"""Returns the auth type currently in use.
5256
5357
The databricks-sdk client uses the configured auth_type to create
@@ -62,16 +66,15 @@ def _get_auth_type(local_auth_type: str) -> str:
6266
See Also
6367
--------
6468
* https://github.com/databricks/databricks-sdk-py/blob/v0.29.0/databricks/sdk/config.py#L261-L269
65-
69+
6670
Returns
6771
-------
6872
str
6973
"""
7074
if is_local():
7175
return local_auth_type
7276

73-
return POSIT_OAUTH_INTEGRATION_AUTH_TYPE
74-
77+
return POSIT_OAUTH_INTEGRATION_AUTH_TYPE
7578

7679

7780
class PositContentCredentialsProvider:
@@ -117,7 +120,7 @@ def __call__(self) -> Dict[str, str]:
117120
class PositContentCredentialsStrategy(CredentialsStrategy):
118121
"""`CredentialsStrategy` implementation which supports interacting with Service Account OAuth integrations on Connect.
119122
120-
This strategy callable class returns a `PositContentCredentialsProvider` when hosted on Connect, and
123+
This strategy callable class returns a `PositContentCredentialsProvider` when hosted on Connect, and
121124
its `local_strategy` strategy otherwise.
122125
123126
Examples
@@ -130,7 +133,6 @@ class PositContentCredentialsStrategy(CredentialsStrategy):
130133
from posit.connect.external.databricks import PositContentCredentialsStrategy
131134
132135
import pandas as pd
133-
134136
from databricks import sql
135137
from databricks.sdk.core import ApiClient, Config, databricks_cli
136138
from databricks.sdk.service.iam import CurrentUserAPI
@@ -197,7 +199,7 @@ def __call__(self, *args, **kwargs) -> CredentialsProvider:
197199
class PositCredentialsStrategy(CredentialsStrategy):
198200
"""`CredentialsStrategy` implementation which supports interacting with Viewer OAuth integrations on Connect.
199201
200-
This strategy callable class returns a `PositCredentialsProvider` when hosted on Connect, and
202+
This strategy callable class returns a `PositCredentialsProvider` when hosted on Connect, and
201203
its `local_strategy` strategy otherwise.
202204
203205
Examples
@@ -222,6 +224,7 @@ class PositCredentialsStrategy(CredentialsStrategy):
222224
223225
app_ui = ui.page_fluid(ui.output_text("text"), ui.output_data_frame("result"))
224226
227+
225228
def server(i: Inputs, o: Outputs, session: Session):
226229
227230
# HTTP session headers are available in this context.
@@ -250,7 +253,8 @@ def result():
250253
def text():
251254
databricks_user_info = CurrentUserAPI(ApiClient(cfg)).me()
252255
return f"Hello, {databricks_user_info.display_name}!"
253-
256+
257+
254258
app = App(app_ui, server)
255259
```
256260
"""

0 commit comments

Comments
 (0)