From cb3f97bf978ec30fa71a9dc594f60d433c662ee8 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Thu, 4 Jan 2024 23:10:26 +0000 Subject: [PATCH] feat(api): OpenAPI spec update --- pyproject.toml | 1 + src/dataherald/_compat.py | 10 +++++ .../database_connections.py | 30 +++++++------- .../resources/database_connections/drivers.py | 22 ++++------ src/dataherald/resources/engine.py | 22 ++++------ src/dataherald/resources/finetunings.py | 22 ++++------ src/dataherald/resources/generations.py | 21 ++++------ src/dataherald/resources/golden_sqls.py | 22 ++++------ src/dataherald/resources/heartbeat.py | 22 ++++------ .../resources/instructions/first.py | 22 ++++------ .../resources/instructions/instructions.py | 30 ++++++-------- src/dataherald/resources/nl_generations.py | 22 ++++------ src/dataherald/resources/prompts/prompts.py | 37 +++++++---------- .../resources/prompts/sql_generations.py | 22 ++++------ .../sql_generations/nl_generations.py | 22 ++++------ .../sql_generations/sql_generations.py | 30 ++++++-------- .../resources/table_descriptions.py | 40 ++++++++++--------- .../types/table_description_list_params.py | 4 +- .../api_resources/test_table_descriptions.py | 18 +++++++-- 19 files changed, 176 insertions(+), 243 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 29b7532..da00aab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ dependencies = [ "anyio>=3.5.0, <5", "distro>=1.7.0, <2", "sniffio", + "cached-property; python_version < '3.8'", ] requires-python = ">= 3.7" diff --git a/src/dataherald/_compat.py b/src/dataherald/_compat.py index d95db8e..3cda399 100644 --- a/src/dataherald/_compat.py +++ b/src/dataherald/_compat.py @@ -173,3 +173,13 @@ class GenericModel(pydantic.BaseModel): class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): ... + + +# cached properties +if TYPE_CHECKING: + cached_property = property +else: + try: + from functools import cached_property as cached_property + except ImportError: + from cached_property import cached_property as cached_property diff --git a/src/dataherald/resources/database_connections/database_connections.py b/src/dataherald/resources/database_connections/database_connections.py index db2499a..28dc501 100644 --- a/src/dataherald/resources/database_connections/database_connections.py +++ b/src/dataherald/resources/database_connections/database_connections.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import Union import httpx @@ -21,26 +21,24 @@ NotGiven, ) from ..._utils import maybe_transform +from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..._base_client import ( make_request_options, ) -if TYPE_CHECKING: - from ..._client import Dataherald, AsyncDataherald - __all__ = ["DatabaseConnections", "AsyncDatabaseConnections"] class DatabaseConnections(SyncAPIResource): - drivers: Drivers - with_raw_response: DatabaseConnectionsWithRawResponse + @cached_property + def drivers(self) -> Drivers: + return Drivers(self._client) - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.drivers = Drivers(client) - self.with_raw_response = DatabaseConnectionsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> DatabaseConnectionsWithRawResponse: + return DatabaseConnectionsWithRawResponse(self) def create( self, @@ -193,13 +191,13 @@ def list( class AsyncDatabaseConnections(AsyncAPIResource): - drivers: AsyncDrivers - with_raw_response: AsyncDatabaseConnectionsWithRawResponse + @cached_property + def drivers(self) -> AsyncDrivers: + return AsyncDrivers(self._client) - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.drivers = AsyncDrivers(client) - self.with_raw_response = AsyncDatabaseConnectionsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncDatabaseConnectionsWithRawResponse: + return AsyncDatabaseConnectionsWithRawResponse(self) async def create( self, diff --git a/src/dataherald/resources/database_connections/drivers.py b/src/dataherald/resources/database_connections/drivers.py index 53db8e9..9efa1ce 100644 --- a/src/dataherald/resources/database_connections/drivers.py +++ b/src/dataherald/resources/database_connections/drivers.py @@ -2,8 +2,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING - import httpx from ..._types import ( @@ -13,6 +11,7 @@ Headers, NotGiven, ) +from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..._base_client import ( @@ -20,18 +19,13 @@ ) from ...types.database_connections import DriverListResponse -if TYPE_CHECKING: - from ..._client import Dataherald, AsyncDataherald - __all__ = ["Drivers", "AsyncDrivers"] class Drivers(SyncAPIResource): - with_raw_response: DriversWithRawResponse - - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.with_raw_response = DriversWithRawResponse(self) + @cached_property + def with_raw_response(self) -> DriversWithRawResponse: + return DriversWithRawResponse(self) def list( self, @@ -54,11 +48,9 @@ def list( class AsyncDrivers(AsyncAPIResource): - with_raw_response: AsyncDriversWithRawResponse - - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.with_raw_response = AsyncDriversWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncDriversWithRawResponse: + return AsyncDriversWithRawResponse(self) async def list( self, diff --git a/src/dataherald/resources/engine.py b/src/dataherald/resources/engine.py index 5c95ee3..77d4217 100644 --- a/src/dataherald/resources/engine.py +++ b/src/dataherald/resources/engine.py @@ -2,8 +2,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING - import httpx from .._types import ( @@ -14,24 +12,20 @@ NotGiven, UnknownResponse, ) +from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from .._base_client import ( make_request_options, ) -if TYPE_CHECKING: - from .._client import Dataherald, AsyncDataherald - __all__ = ["Engine", "AsyncEngine"] class Engine(SyncAPIResource): - with_raw_response: EngineWithRawResponse - - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.with_raw_response = EngineWithRawResponse(self) + @cached_property + def with_raw_response(self) -> EngineWithRawResponse: + return EngineWithRawResponse(self) def heartbeat( self, @@ -54,11 +48,9 @@ def heartbeat( class AsyncEngine(AsyncAPIResource): - with_raw_response: AsyncEngineWithRawResponse - - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.with_raw_response = AsyncEngineWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncEngineWithRawResponse: + return AsyncEngineWithRawResponse(self) async def heartbeat( self, diff --git a/src/dataherald/resources/finetunings.py b/src/dataherald/resources/finetunings.py index 29739ea..0a82a0f 100644 --- a/src/dataherald/resources/finetunings.py +++ b/src/dataherald/resources/finetunings.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List +from typing import List import httpx @@ -20,24 +20,20 @@ NotGiven, ) from .._utils import maybe_transform +from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from .._base_client import ( make_request_options, ) -if TYPE_CHECKING: - from .._client import Dataherald, AsyncDataherald - __all__ = ["Finetunings", "AsyncFinetunings"] class Finetunings(SyncAPIResource): - with_raw_response: FinetuningsWithRawResponse - - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.with_raw_response = FinetuningsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> FinetuningsWithRawResponse: + return FinetuningsWithRawResponse(self) def create( self, @@ -152,11 +148,9 @@ def list( class AsyncFinetunings(AsyncAPIResource): - with_raw_response: AsyncFinetuningsWithRawResponse - - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.with_raw_response = AsyncFinetuningsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncFinetuningsWithRawResponse: + return AsyncFinetuningsWithRawResponse(self) async def create( self, diff --git a/src/dataherald/resources/generations.py b/src/dataherald/resources/generations.py index c677362..067a4e9 100644 --- a/src/dataherald/resources/generations.py +++ b/src/dataherald/resources/generations.py @@ -2,7 +2,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING from typing_extensions import Literal import httpx @@ -22,6 +21,7 @@ NotGiven, ) from .._utils import maybe_transform +from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from .._base_client import ( @@ -29,18 +29,13 @@ ) from ..types.shared import NlGenerationResponse -if TYPE_CHECKING: - from .._client import Dataherald, AsyncDataherald - __all__ = ["Generations", "AsyncGenerations"] class Generations(SyncAPIResource): - with_raw_response: GenerationsWithRawResponse - - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.with_raw_response = GenerationsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> GenerationsWithRawResponse: + return GenerationsWithRawResponse(self) def create( self, @@ -259,11 +254,9 @@ def sql_generation( class AsyncGenerations(AsyncAPIResource): - with_raw_response: AsyncGenerationsWithRawResponse - - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.with_raw_response = AsyncGenerationsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncGenerationsWithRawResponse: + return AsyncGenerationsWithRawResponse(self) async def create( self, diff --git a/src/dataherald/resources/golden_sqls.py b/src/dataherald/resources/golden_sqls.py index 6acd4bf..21d385c 100644 --- a/src/dataherald/resources/golden_sqls.py +++ b/src/dataherald/resources/golden_sqls.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List +from typing import List import httpx @@ -21,6 +21,7 @@ UnknownResponse, ) from .._utils import maybe_transform +from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from .._base_client import ( @@ -28,18 +29,13 @@ ) from ..types.shared import GoldenSqlResponse -if TYPE_CHECKING: - from .._client import Dataherald, AsyncDataherald - __all__ = ["GoldenSqls", "AsyncGoldenSqls"] class GoldenSqls(SyncAPIResource): - with_raw_response: GoldenSqlsWithRawResponse - - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.with_raw_response = GoldenSqlsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> GoldenSqlsWithRawResponse: + return GoldenSqlsWithRawResponse(self) def retrieve( self, @@ -183,11 +179,9 @@ def upload( class AsyncGoldenSqls(AsyncAPIResource): - with_raw_response: AsyncGoldenSqlsWithRawResponse - - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.with_raw_response = AsyncGoldenSqlsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncGoldenSqlsWithRawResponse: + return AsyncGoldenSqlsWithRawResponse(self) async def retrieve( self, diff --git a/src/dataherald/resources/heartbeat.py b/src/dataherald/resources/heartbeat.py index b60f1f6..44d159a 100644 --- a/src/dataherald/resources/heartbeat.py +++ b/src/dataherald/resources/heartbeat.py @@ -2,8 +2,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING - import httpx from .._types import ( @@ -14,24 +12,20 @@ NotGiven, UnknownResponse, ) +from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from .._base_client import ( make_request_options, ) -if TYPE_CHECKING: - from .._client import Dataherald, AsyncDataherald - __all__ = ["Heartbeat", "AsyncHeartbeat"] class Heartbeat(SyncAPIResource): - with_raw_response: HeartbeatWithRawResponse - - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.with_raw_response = HeartbeatWithRawResponse(self) + @cached_property + def with_raw_response(self) -> HeartbeatWithRawResponse: + return HeartbeatWithRawResponse(self) def retrieve( self, @@ -54,11 +48,9 @@ def retrieve( class AsyncHeartbeat(AsyncAPIResource): - with_raw_response: AsyncHeartbeatWithRawResponse - - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.with_raw_response = AsyncHeartbeatWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncHeartbeatWithRawResponse: + return AsyncHeartbeatWithRawResponse(self) async def retrieve( self, diff --git a/src/dataherald/resources/instructions/first.py b/src/dataherald/resources/instructions/first.py index 51d97f9..7438704 100644 --- a/src/dataherald/resources/instructions/first.py +++ b/src/dataherald/resources/instructions/first.py @@ -2,8 +2,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING - import httpx from ..._types import ( @@ -13,6 +11,7 @@ Headers, NotGiven, ) +from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..._base_client import ( @@ -20,18 +19,13 @@ ) from ...types.shared import InstructionResponse -if TYPE_CHECKING: - from ..._client import Dataherald, AsyncDataherald - __all__ = ["First", "AsyncFirst"] class First(SyncAPIResource): - with_raw_response: FirstWithRawResponse - - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.with_raw_response = FirstWithRawResponse(self) + @cached_property + def with_raw_response(self) -> FirstWithRawResponse: + return FirstWithRawResponse(self) def retrieve( self, @@ -54,11 +48,9 @@ def retrieve( class AsyncFirst(AsyncAPIResource): - with_raw_response: AsyncFirstWithRawResponse - - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.with_raw_response = AsyncFirstWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncFirstWithRawResponse: + return AsyncFirstWithRawResponse(self) async def retrieve( self, diff --git a/src/dataherald/resources/instructions/instructions.py b/src/dataherald/resources/instructions/instructions.py index e53d001..a5d88d3 100644 --- a/src/dataherald/resources/instructions/instructions.py +++ b/src/dataherald/resources/instructions/instructions.py @@ -2,8 +2,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING - import httpx from .first import First, AsyncFirst, FirstWithRawResponse, AsyncFirstWithRawResponse @@ -22,6 +20,7 @@ UnknownResponse, ) from ..._utils import maybe_transform +from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..._base_client import ( @@ -29,20 +28,17 @@ ) from ...types.shared import InstructionResponse -if TYPE_CHECKING: - from ..._client import Dataherald, AsyncDataherald - __all__ = ["Instructions", "AsyncInstructions"] class Instructions(SyncAPIResource): - first: First - with_raw_response: InstructionsWithRawResponse + @cached_property + def first(self) -> First: + return First(self._client) - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.first = First(client) - self.with_raw_response = InstructionsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> InstructionsWithRawResponse: + return InstructionsWithRawResponse(self) def create( self, @@ -197,13 +193,13 @@ def delete( class AsyncInstructions(AsyncAPIResource): - first: AsyncFirst - with_raw_response: AsyncInstructionsWithRawResponse + @cached_property + def first(self) -> AsyncFirst: + return AsyncFirst(self._client) - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.first = AsyncFirst(client) - self.with_raw_response = AsyncInstructionsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncInstructionsWithRawResponse: + return AsyncInstructionsWithRawResponse(self) async def create( self, diff --git a/src/dataherald/resources/nl_generations.py b/src/dataherald/resources/nl_generations.py index 5383212..be38bee 100644 --- a/src/dataherald/resources/nl_generations.py +++ b/src/dataherald/resources/nl_generations.py @@ -2,8 +2,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING - import httpx from ..types import NlGenerationListResponse, nl_generation_list_params @@ -15,6 +13,7 @@ NotGiven, ) from .._utils import maybe_transform +from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from .._base_client import ( @@ -22,18 +21,13 @@ ) from ..types.shared import NlGenerationResponse -if TYPE_CHECKING: - from .._client import Dataherald, AsyncDataherald - __all__ = ["NlGenerations", "AsyncNlGenerations"] class NlGenerations(SyncAPIResource): - with_raw_response: NlGenerationsWithRawResponse - - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.with_raw_response = NlGenerationsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> NlGenerationsWithRawResponse: + return NlGenerationsWithRawResponse(self) def retrieve( self, @@ -114,11 +108,9 @@ def list( class AsyncNlGenerations(AsyncAPIResource): - with_raw_response: AsyncNlGenerationsWithRawResponse - - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.with_raw_response = AsyncNlGenerationsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncNlGenerationsWithRawResponse: + return AsyncNlGenerationsWithRawResponse(self) async def retrieve( self, diff --git a/src/dataherald/resources/prompts/prompts.py b/src/dataherald/resources/prompts/prompts.py index 8d38458..4313ac9 100644 --- a/src/dataherald/resources/prompts/prompts.py +++ b/src/dataherald/resources/prompts/prompts.py @@ -2,16 +2,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING - import httpx -from ...types import ( - PromptResponse, - PromptListResponse, - prompt_list_params, - prompt_create_params, -) +from ...types import PromptResponse, PromptListResponse, prompt_list_params, prompt_create_params from ..._types import ( NOT_GIVEN, Body, @@ -20,6 +13,7 @@ NotGiven, ) from ..._utils import maybe_transform +from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..._base_client import ( @@ -32,20 +26,17 @@ AsyncSqlGenerationsWithRawResponse, ) -if TYPE_CHECKING: - from ..._client import Dataherald, AsyncDataherald - __all__ = ["Prompts", "AsyncPrompts"] class Prompts(SyncAPIResource): - sql_generations: SqlGenerations - with_raw_response: PromptsWithRawResponse + @cached_property + def sql_generations(self) -> SqlGenerations: + return SqlGenerations(self._client) - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.sql_generations = SqlGenerations(client) - self.with_raw_response = PromptsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> PromptsWithRawResponse: + return PromptsWithRawResponse(self) def create( self, @@ -167,13 +158,13 @@ def list( class AsyncPrompts(AsyncAPIResource): - sql_generations: AsyncSqlGenerations - with_raw_response: AsyncPromptsWithRawResponse + @cached_property + def sql_generations(self) -> AsyncSqlGenerations: + return AsyncSqlGenerations(self._client) - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.sql_generations = AsyncSqlGenerations(client) - self.with_raw_response = AsyncPromptsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncPromptsWithRawResponse: + return AsyncPromptsWithRawResponse(self) async def create( self, diff --git a/src/dataherald/resources/prompts/sql_generations.py b/src/dataherald/resources/prompts/sql_generations.py index 0b840da..5b67629 100644 --- a/src/dataherald/resources/prompts/sql_generations.py +++ b/src/dataherald/resources/prompts/sql_generations.py @@ -2,8 +2,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING - import httpx from ..._types import ( @@ -15,6 +13,7 @@ UnknownResponse, ) from ..._utils import maybe_transform +from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..._base_client import ( @@ -27,18 +26,13 @@ sql_generation_nl_generations_params, ) -if TYPE_CHECKING: - from ..._client import Dataherald, AsyncDataherald - __all__ = ["SqlGenerations", "AsyncSqlGenerations"] class SqlGenerations(SyncAPIResource): - with_raw_response: SqlGenerationsWithRawResponse - - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.with_raw_response = SqlGenerationsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> SqlGenerationsWithRawResponse: + return SqlGenerationsWithRawResponse(self) def create( self, @@ -175,11 +169,9 @@ def nl_generations( class AsyncSqlGenerations(AsyncAPIResource): - with_raw_response: AsyncSqlGenerationsWithRawResponse - - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.with_raw_response = AsyncSqlGenerationsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncSqlGenerationsWithRawResponse: + return AsyncSqlGenerationsWithRawResponse(self) async def create( self, diff --git a/src/dataherald/resources/sql_generations/nl_generations.py b/src/dataherald/resources/sql_generations/nl_generations.py index 776cf3e..618d322 100644 --- a/src/dataherald/resources/sql_generations/nl_generations.py +++ b/src/dataherald/resources/sql_generations/nl_generations.py @@ -2,8 +2,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING - import httpx from ..._types import ( @@ -15,6 +13,7 @@ UnknownResponse, ) from ..._utils import maybe_transform +from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..._base_client import ( @@ -23,18 +22,13 @@ from ...types.shared import NlGenerationResponse from ...types.sql_generations import nl_generation_create_params, nl_generation_retrieve_params -if TYPE_CHECKING: - from ..._client import Dataherald, AsyncDataherald - __all__ = ["NlGenerations", "AsyncNlGenerations"] class NlGenerations(SyncAPIResource): - with_raw_response: NlGenerationsWithRawResponse - - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.with_raw_response = NlGenerationsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> NlGenerationsWithRawResponse: + return NlGenerationsWithRawResponse(self) def create( self, @@ -125,11 +119,9 @@ def retrieve( class AsyncNlGenerations(AsyncAPIResource): - with_raw_response: AsyncNlGenerationsWithRawResponse - - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.with_raw_response = AsyncNlGenerationsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncNlGenerationsWithRawResponse: + return AsyncNlGenerationsWithRawResponse(self) async def create( self, diff --git a/src/dataherald/resources/sql_generations/sql_generations.py b/src/dataherald/resources/sql_generations/sql_generations.py index bd74334..df054e1 100644 --- a/src/dataherald/resources/sql_generations/sql_generations.py +++ b/src/dataherald/resources/sql_generations/sql_generations.py @@ -2,8 +2,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING - import httpx from ...types import ( @@ -21,6 +19,7 @@ NotGiven, ) from ..._utils import maybe_transform +from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import to_raw_response_wrapper, async_to_raw_response_wrapper from ..._base_client import ( @@ -34,20 +33,17 @@ AsyncNlGenerationsWithRawResponse, ) -if TYPE_CHECKING: - from ..._client import Dataherald, AsyncDataherald - __all__ = ["SqlGenerations", "AsyncSqlGenerations"] class SqlGenerations(SyncAPIResource): - nl_generations: NlGenerations - with_raw_response: SqlGenerationsWithRawResponse + @cached_property + def nl_generations(self) -> NlGenerations: + return NlGenerations(self._client) - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.nl_generations = NlGenerations(client) - self.with_raw_response = SqlGenerationsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> SqlGenerationsWithRawResponse: + return SqlGenerationsWithRawResponse(self) def create( self, @@ -206,13 +202,13 @@ def execute( class AsyncSqlGenerations(AsyncAPIResource): - nl_generations: AsyncNlGenerations - with_raw_response: AsyncSqlGenerationsWithRawResponse + @cached_property + def nl_generations(self) -> AsyncNlGenerations: + return AsyncNlGenerations(self._client) - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.nl_generations = AsyncNlGenerations(client) - self.with_raw_response = AsyncSqlGenerationsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncSqlGenerationsWithRawResponse: + return AsyncSqlGenerationsWithRawResponse(self) async def create( self, diff --git a/src/dataherald/resources/table_descriptions.py b/src/dataherald/resources/table_descriptions.py index 08da66e..d4566a9 100644 --- a/src/dataherald/resources/table_descriptions.py +++ b/src/dataherald/resources/table_descriptions.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List +from typing import List import httpx @@ -22,24 +22,20 @@ UnknownResponse, ) from .._utils import maybe_transform +from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import to_raw_response_wrapper, async_to_raw_response_wrapper from .._base_client import ( make_request_options, ) -if TYPE_CHECKING: - from .._client import Dataherald, AsyncDataherald - __all__ = ["TableDescriptions", "AsyncTableDescriptions"] class TableDescriptions(SyncAPIResource): - with_raw_response: TableDescriptionsWithRawResponse - - def __init__(self, client: Dataherald) -> None: - super().__init__(client) - self.with_raw_response = TableDescriptionsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> TableDescriptionsWithRawResponse: + return TableDescriptionsWithRawResponse(self) def retrieve( self, @@ -119,6 +115,7 @@ def update( def list( self, *, + db_connection_id: str, table_name: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -128,7 +125,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> TableDescriptionListResponse: """ - Api Get Table Descriptions + Get Table Descriptions Args: extra_headers: Send extra headers @@ -147,7 +144,11 @@ def list( extra_body=extra_body, timeout=timeout, query=maybe_transform( - {"table_name": table_name}, table_description_list_params.TableDescriptionListParams + { + "db_connection_id": db_connection_id, + "table_name": table_name, + }, + table_description_list_params.TableDescriptionListParams, ), ), cast_to=TableDescriptionListResponse, @@ -194,11 +195,9 @@ def sync_schemas( class AsyncTableDescriptions(AsyncAPIResource): - with_raw_response: AsyncTableDescriptionsWithRawResponse - - def __init__(self, client: AsyncDataherald) -> None: - super().__init__(client) - self.with_raw_response = AsyncTableDescriptionsWithRawResponse(self) + @cached_property + def with_raw_response(self) -> AsyncTableDescriptionsWithRawResponse: + return AsyncTableDescriptionsWithRawResponse(self) async def retrieve( self, @@ -278,6 +277,7 @@ async def update( async def list( self, *, + db_connection_id: str, table_name: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -287,7 +287,7 @@ async def list( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> TableDescriptionListResponse: """ - Api Get Table Descriptions + Get Table Descriptions Args: extra_headers: Send extra headers @@ -306,7 +306,11 @@ async def list( extra_body=extra_body, timeout=timeout, query=maybe_transform( - {"table_name": table_name}, table_description_list_params.TableDescriptionListParams + { + "db_connection_id": db_connection_id, + "table_name": table_name, + }, + table_description_list_params.TableDescriptionListParams, ), ), cast_to=TableDescriptionListResponse, diff --git a/src/dataherald/types/table_description_list_params.py b/src/dataherald/types/table_description_list_params.py index f7e514b..7af6b09 100644 --- a/src/dataherald/types/table_description_list_params.py +++ b/src/dataherald/types/table_description_list_params.py @@ -2,10 +2,12 @@ from __future__ import annotations -from typing_extensions import TypedDict +from typing_extensions import Required, TypedDict __all__ = ["TableDescriptionListParams"] class TableDescriptionListParams(TypedDict, total=False): + db_connection_id: Required[str] + table_name: str diff --git a/tests/api_resources/test_table_descriptions.py b/tests/api_resources/test_table_descriptions.py index e12fdc5..440beb2 100644 --- a/tests/api_resources/test_table_descriptions.py +++ b/tests/api_resources/test_table_descriptions.py @@ -96,19 +96,24 @@ def test_raw_response_update(self, client: Dataherald) -> None: @parametrize def test_method_list(self, client: Dataherald) -> None: - table_description = client.table_descriptions.list() + table_description = client.table_descriptions.list( + db_connection_id="string", + ) assert_matches_type(TableDescriptionListResponse, table_description, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Dataherald) -> None: table_description = client.table_descriptions.list( + db_connection_id="string", table_name="string", ) assert_matches_type(TableDescriptionListResponse, table_description, path=["response"]) @parametrize def test_raw_response_list(self, client: Dataherald) -> None: - response = client.table_descriptions.with_raw_response.list() + response = client.table_descriptions.with_raw_response.list( + db_connection_id="string", + ) assert response.http_request.headers.get("X-Stainless-Lang") == "python" table_description = response.parse() assert_matches_type(TableDescriptionListResponse, table_description, path=["response"]) @@ -216,19 +221,24 @@ async def test_raw_response_update(self, client: AsyncDataherald) -> None: @parametrize async def test_method_list(self, client: AsyncDataherald) -> None: - table_description = await client.table_descriptions.list() + table_description = await client.table_descriptions.list( + db_connection_id="string", + ) assert_matches_type(TableDescriptionListResponse, table_description, path=["response"]) @parametrize async def test_method_list_with_all_params(self, client: AsyncDataherald) -> None: table_description = await client.table_descriptions.list( + db_connection_id="string", table_name="string", ) assert_matches_type(TableDescriptionListResponse, table_description, path=["response"]) @parametrize async def test_raw_response_list(self, client: AsyncDataherald) -> None: - response = await client.table_descriptions.with_raw_response.list() + response = await client.table_descriptions.with_raw_response.list( + db_connection_id="string", + ) assert response.http_request.headers.get("X-Stainless-Lang") == "python" table_description = response.parse() assert_matches_type(TableDescriptionListResponse, table_description, path=["response"])