Skip to content
Merged
Show file tree
Hide file tree
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
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ client = Dataherald(
environment="staging",
)

db_connection_response = client.database_connections.create()
db_connection_response = client.database_connections.create(
alias="string",
connection_uri="string",
)
print(db_connection_response.id)
```

Expand All @@ -58,7 +61,10 @@ client = AsyncDataherald(


async def main() -> None:
db_connection_response = await client.database_connections.create()
db_connection_response = await client.database_connections.create(
alias="string",
connection_uri="string",
)
print(db_connection_response.id)


Expand Down Expand Up @@ -92,7 +98,10 @@ from dataherald import Dataherald
client = Dataherald()

try:
client.database_connections.create()
client.database_connections.create(
alias="string",
connection_uri="string",
)
except dataherald.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
Expand Down Expand Up @@ -135,7 +144,10 @@ client = Dataherald(
)

# Or, configure per-request:
client.with_options(max_retries=5).database_connections.create()
client.with_options(max_retries=5).database_connections.create(
alias="string",
connection_uri="string",
)
```

### Timeouts
Expand All @@ -158,7 +170,10 @@ client = Dataherald(
)

# Override per-request:
client.with_options(timeout=5 * 1000).database_connections.create()
client.with_options(timeout=5 * 1000).database_connections.create(
alias="string",
connection_uri="string",
)
```

On timeout, an `APITimeoutError` is thrown.
Expand Down Expand Up @@ -197,7 +212,10 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
from dataherald import Dataherald

client = Dataherald()
response = client.database_connections.with_raw_response.create()
response = client.database_connections.with_raw_response.create(
alias="string",
connection_uri="string",
)
print(response.headers.get('X-My-Header'))

database_connection = response.parse() # get the object that `database_connections.create()` would have returned
Expand All @@ -215,7 +233,10 @@ The above interface eagerly reads the full response body when you make the reque
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.

```python
with client.database_connections.with_streaming_response.create() as response:
with client.database_connections.with_streaming_response.create(
alias="string",
connection_uri="string",
) as response:
print(response.headers.get("X-My-Header"))

for line in response.iter_lines():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def with_streaming_response(self) -> DatabaseConnectionsWithStreamingResponse:
def create(
self,
*,
alias: str | NotGiven = NOT_GIVEN,
connection_uri: str | NotGiven = NOT_GIVEN,
credential_file_content: Union[object, str] | NotGiven = NOT_GIVEN,
alias: str,
connection_uri: str,
bigquery_credential_file_content: Union[object, str] | NotGiven = NOT_GIVEN,
llm_api_key: str | NotGiven = NOT_GIVEN,
metadata: object | NotGiven = NOT_GIVEN,
ssh_settings: database_connection_create_params.SSHSettings | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -85,7 +85,7 @@ def create(
{
"alias": alias,
"connection_uri": connection_uri,
"credential_file_content": credential_file_content,
"bigquery_credential_file_content": bigquery_credential_file_content,
"llm_api_key": llm_api_key,
"metadata": metadata,
"ssh_settings": ssh_settings,
Expand Down Expand Up @@ -136,9 +136,9 @@ def update(
self,
id: str,
*,
alias: str | NotGiven = NOT_GIVEN,
connection_uri: str | NotGiven = NOT_GIVEN,
credential_file_content: Union[object, str] | NotGiven = NOT_GIVEN,
alias: str,
connection_uri: str,
bigquery_credential_file_content: Union[object, str] | NotGiven = NOT_GIVEN,
llm_api_key: str | NotGiven = NOT_GIVEN,
metadata: object | NotGiven = NOT_GIVEN,
ssh_settings: database_connection_update_params.SSHSettings | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -170,7 +170,7 @@ def update(
{
"alias": alias,
"connection_uri": connection_uri,
"credential_file_content": credential_file_content,
"bigquery_credential_file_content": bigquery_credential_file_content,
"llm_api_key": llm_api_key,
"metadata": metadata,
"ssh_settings": ssh_settings,
Expand Down Expand Up @@ -220,9 +220,9 @@ def with_streaming_response(self) -> AsyncDatabaseConnectionsWithStreamingRespon
async def create(
self,
*,
alias: str | NotGiven = NOT_GIVEN,
connection_uri: str | NotGiven = NOT_GIVEN,
credential_file_content: Union[object, str] | NotGiven = NOT_GIVEN,
alias: str,
connection_uri: str,
bigquery_credential_file_content: Union[object, str] | NotGiven = NOT_GIVEN,
llm_api_key: str | NotGiven = NOT_GIVEN,
metadata: object | NotGiven = NOT_GIVEN,
ssh_settings: database_connection_create_params.SSHSettings | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -252,7 +252,7 @@ async def create(
{
"alias": alias,
"connection_uri": connection_uri,
"credential_file_content": credential_file_content,
"bigquery_credential_file_content": bigquery_credential_file_content,
"llm_api_key": llm_api_key,
"metadata": metadata,
"ssh_settings": ssh_settings,
Expand Down Expand Up @@ -303,9 +303,9 @@ async def update(
self,
id: str,
*,
alias: str | NotGiven = NOT_GIVEN,
connection_uri: str | NotGiven = NOT_GIVEN,
credential_file_content: Union[object, str] | NotGiven = NOT_GIVEN,
alias: str,
connection_uri: str,
bigquery_credential_file_content: Union[object, str] | NotGiven = NOT_GIVEN,
llm_api_key: str | NotGiven = NOT_GIVEN,
metadata: object | NotGiven = NOT_GIVEN,
ssh_settings: database_connection_update_params.SSHSettings | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -337,7 +337,7 @@ async def update(
{
"alias": alias,
"connection_uri": connection_uri,
"credential_file_content": credential_file_content,
"bigquery_credential_file_content": bigquery_credential_file_content,
"llm_api_key": llm_api_key,
"metadata": metadata,
"ssh_settings": ssh_settings,
Expand Down
20 changes: 4 additions & 16 deletions src/dataherald/types/database_connection_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
from __future__ import annotations

from typing import Union
from typing_extensions import TypedDict
from typing_extensions import Required, TypedDict

__all__ = ["DatabaseConnectionCreateParams", "SSHSettings"]


class DatabaseConnectionCreateParams(TypedDict, total=False):
alias: str
alias: Required[str]

connection_uri: str
connection_uri: Required[str]

credential_file_content: Union[object, str]
bigquery_credential_file_content: Union[object, str]

llm_api_key: str

Expand All @@ -25,20 +25,8 @@ class DatabaseConnectionCreateParams(TypedDict, total=False):


class SSHSettings(TypedDict, total=False):
db_driver: str

db_name: str

host: str

password: str

private_key_password: str

remote_db_name: str

remote_db_password: str

remote_host: str

username: str
20 changes: 4 additions & 16 deletions src/dataherald/types/database_connection_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
from __future__ import annotations

from typing import Union
from typing_extensions import TypedDict
from typing_extensions import Required, TypedDict

__all__ = ["DatabaseConnectionUpdateParams", "SSHSettings"]


class DatabaseConnectionUpdateParams(TypedDict, total=False):
alias: str
alias: Required[str]

connection_uri: str
connection_uri: Required[str]

credential_file_content: Union[object, str]
bigquery_credential_file_content: Union[object, str]

llm_api_key: str

Expand All @@ -25,20 +25,8 @@ class DatabaseConnectionUpdateParams(TypedDict, total=False):


class SSHSettings(TypedDict, total=False):
db_driver: str

db_name: str

host: str

password: str

private_key_password: str

remote_db_name: str

remote_db_password: str

remote_host: str

username: str
18 changes: 4 additions & 14 deletions src/dataherald/types/db_connection_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,21 @@ class Metadata(BaseModel):


class SSHSettings(BaseModel):
db_driver: Optional[str] = None

db_name: Optional[str] = None

host: Optional[str] = None

password: Optional[str] = None

private_key_password: Optional[str] = None

remote_db_name: Optional[str] = None

remote_db_password: Optional[str] = None

remote_host: Optional[str] = None

username: Optional[str] = None


class DBConnectionResponse(BaseModel):
id: str
alias: str

connection_uri: str

alias: Optional[str] = None
id: Optional[str] = None

created_at: Optional[datetime] = None

Expand All @@ -51,6 +43,4 @@ class DBConnectionResponse(BaseModel):

ssh_settings: Optional[SSHSettings] = None

uri: Optional[str] = None

use_ssh: Optional[bool] = None
Loading