diff --git a/README.md b/README.md index 386b04f..c640664 100644 --- a/README.md +++ b/README.md @@ -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) ``` @@ -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) @@ -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. @@ -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 @@ -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. @@ -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 @@ -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(): diff --git a/src/dataherald/resources/database_connections/database_connections.py b/src/dataherald/resources/database_connections/database_connections.py index 8925990..3a9fb39 100644 --- a/src/dataherald/resources/database_connections/database_connections.py +++ b/src/dataherald/resources/database_connections/database_connections.py @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/src/dataherald/types/database_connection_create_params.py b/src/dataherald/types/database_connection_create_params.py index dba52af..1fa71aa 100644 --- a/src/dataherald/types/database_connection_create_params.py +++ b/src/dataherald/types/database_connection_create_params.py @@ -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 @@ -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 diff --git a/src/dataherald/types/database_connection_update_params.py b/src/dataherald/types/database_connection_update_params.py index 53eb8ec..2f51d0f 100644 --- a/src/dataherald/types/database_connection_update_params.py +++ b/src/dataherald/types/database_connection_update_params.py @@ -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 @@ -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 diff --git a/src/dataherald/types/db_connection_response.py b/src/dataherald/types/db_connection_response.py index 872930e..c18f52b 100644 --- a/src/dataherald/types/db_connection_response.py +++ b/src/dataherald/types/db_connection_response.py @@ -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 @@ -51,6 +43,4 @@ class DBConnectionResponse(BaseModel): ssh_settings: Optional[SSHSettings] = None - uri: Optional[str] = None - use_ssh: Optional[bool] = None diff --git a/tests/api_resources/test_database_connections.py b/tests/api_resources/test_database_connections.py index 7586f39..a11a6fb 100644 --- a/tests/api_resources/test_database_connections.py +++ b/tests/api_resources/test_database_connections.py @@ -22,7 +22,10 @@ class TestDatabaseConnections: @parametrize def test_method_create(self, client: Dataherald) -> None: - database_connection = client.database_connections.create() + database_connection = client.database_connections.create( + alias="string", + connection_uri="string", + ) assert_matches_type(DBConnectionResponse, database_connection, path=["response"]) @parametrize @@ -30,19 +33,13 @@ def test_method_create_with_all_params(self, client: Dataherald) -> None: database_connection = client.database_connections.create( alias="string", connection_uri="string", - credential_file_content={}, + bigquery_credential_file_content={}, llm_api_key="string", metadata={}, ssh_settings={ - "db_name": "string", "host": "string", "username": "string", "password": "string", - "remote_host": "string", - "remote_db_name": "string", - "remote_db_password": "string", - "private_key_password": "string", - "db_driver": "string", }, use_ssh=True, ) @@ -50,7 +47,10 @@ def test_method_create_with_all_params(self, client: Dataherald) -> None: @parametrize def test_raw_response_create(self, client: Dataherald) -> None: - response = client.database_connections.with_raw_response.create() + response = client.database_connections.with_raw_response.create( + alias="string", + connection_uri="string", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -59,7 +59,10 @@ def test_raw_response_create(self, client: Dataherald) -> None: @parametrize def test_streaming_response_create(self, client: Dataherald) -> None: - 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: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -110,6 +113,8 @@ def test_path_params_retrieve(self, client: Dataherald) -> None: def test_method_update(self, client: Dataherald) -> None: database_connection = client.database_connections.update( "string", + alias="string", + connection_uri="string", ) assert_matches_type(DBConnectionResponse, database_connection, path=["response"]) @@ -119,19 +124,13 @@ def test_method_update_with_all_params(self, client: Dataherald) -> None: "string", alias="string", connection_uri="string", - credential_file_content={}, + bigquery_credential_file_content={}, llm_api_key="string", metadata={}, ssh_settings={ - "db_name": "string", "host": "string", "username": "string", "password": "string", - "remote_host": "string", - "remote_db_name": "string", - "remote_db_password": "string", - "private_key_password": "string", - "db_driver": "string", }, use_ssh=True, ) @@ -141,6 +140,8 @@ def test_method_update_with_all_params(self, client: Dataherald) -> None: def test_raw_response_update(self, client: Dataherald) -> None: response = client.database_connections.with_raw_response.update( "string", + alias="string", + connection_uri="string", ) assert response.is_closed is True @@ -152,6 +153,8 @@ def test_raw_response_update(self, client: Dataherald) -> None: def test_streaming_response_update(self, client: Dataherald) -> None: with client.database_connections.with_streaming_response.update( "string", + alias="string", + connection_uri="string", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -166,6 +169,8 @@ def test_path_params_update(self, client: Dataherald) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): client.database_connections.with_raw_response.update( "", + alias="string", + connection_uri="string", ) @parametrize @@ -199,7 +204,10 @@ class TestAsyncDatabaseConnections: @parametrize async def test_method_create(self, async_client: AsyncDataherald) -> None: - database_connection = await async_client.database_connections.create() + database_connection = await async_client.database_connections.create( + alias="string", + connection_uri="string", + ) assert_matches_type(DBConnectionResponse, database_connection, path=["response"]) @parametrize @@ -207,19 +215,13 @@ async def test_method_create_with_all_params(self, async_client: AsyncDataherald database_connection = await async_client.database_connections.create( alias="string", connection_uri="string", - credential_file_content={}, + bigquery_credential_file_content={}, llm_api_key="string", metadata={}, ssh_settings={ - "db_name": "string", "host": "string", "username": "string", "password": "string", - "remote_host": "string", - "remote_db_name": "string", - "remote_db_password": "string", - "private_key_password": "string", - "db_driver": "string", }, use_ssh=True, ) @@ -227,7 +229,10 @@ async def test_method_create_with_all_params(self, async_client: AsyncDataherald @parametrize async def test_raw_response_create(self, async_client: AsyncDataherald) -> None: - response = await async_client.database_connections.with_raw_response.create() + response = await async_client.database_connections.with_raw_response.create( + alias="string", + connection_uri="string", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -236,7 +241,10 @@ async def test_raw_response_create(self, async_client: AsyncDataherald) -> None: @parametrize async def test_streaming_response_create(self, async_client: AsyncDataherald) -> None: - async with async_client.database_connections.with_streaming_response.create() as response: + async with async_client.database_connections.with_streaming_response.create( + alias="string", + connection_uri="string", + ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -287,6 +295,8 @@ async def test_path_params_retrieve(self, async_client: AsyncDataherald) -> None async def test_method_update(self, async_client: AsyncDataherald) -> None: database_connection = await async_client.database_connections.update( "string", + alias="string", + connection_uri="string", ) assert_matches_type(DBConnectionResponse, database_connection, path=["response"]) @@ -296,19 +306,13 @@ async def test_method_update_with_all_params(self, async_client: AsyncDataherald "string", alias="string", connection_uri="string", - credential_file_content={}, + bigquery_credential_file_content={}, llm_api_key="string", metadata={}, ssh_settings={ - "db_name": "string", "host": "string", "username": "string", "password": "string", - "remote_host": "string", - "remote_db_name": "string", - "remote_db_password": "string", - "private_key_password": "string", - "db_driver": "string", }, use_ssh=True, ) @@ -318,6 +322,8 @@ async def test_method_update_with_all_params(self, async_client: AsyncDataherald async def test_raw_response_update(self, async_client: AsyncDataherald) -> None: response = await async_client.database_connections.with_raw_response.update( "string", + alias="string", + connection_uri="string", ) assert response.is_closed is True @@ -329,6 +335,8 @@ async def test_raw_response_update(self, async_client: AsyncDataherald) -> None: async def test_streaming_response_update(self, async_client: AsyncDataherald) -> None: async with async_client.database_connections.with_streaming_response.update( "string", + alias="string", + connection_uri="string", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -343,6 +351,8 @@ async def test_path_params_update(self, async_client: AsyncDataherald) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): await async_client.database_connections.with_raw_response.update( "", + alias="string", + connection_uri="string", ) @parametrize diff --git a/tests/test_client.py b/tests/test_client.py index cf47f5e..9038b17 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -674,7 +674,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> No with pytest.raises(APITimeoutError): self.client.post( "/api/database-connections", - body=dict(), + body=dict(alias="string", connection_uri="string"), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, ) @@ -689,7 +689,7 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> Non with pytest.raises(APIStatusError): self.client.post( "/api/database-connections", - body=dict(), + body=dict(alias="string", connection_uri="string"), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, ) @@ -1327,7 +1327,7 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) with pytest.raises(APITimeoutError): await self.client.post( "/api/database-connections", - body=dict(), + body=dict(alias="string", connection_uri="string"), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, ) @@ -1342,7 +1342,7 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) with pytest.raises(APIStatusError): await self.client.post( "/api/database-connections", - body=dict(), + body=dict(alias="string", connection_uri="string"), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, )