From c197ab53dd21f565077faa6efc9a612423ebe1c2 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Tue, 9 Jan 2024 18:53:02 +0000
Subject: [PATCH] feat(api): OpenAPI spec update (#20)
---
.stats.yml | 2 +-
api.md | 3 +-
.../sql_generations/sql_generations.py | 86 ++++++++++++++++++-
src/dataherald/types/__init__.py | 2 +
.../types/sql_generation_execute_params.py | 11 +++
.../types/sql_generation_execute_response.py | 7 ++
tests/api_resources/test_sql_generations.py | 53 +++++++++++-
7 files changed, 160 insertions(+), 4 deletions(-)
create mode 100644 src/dataherald/types/sql_generation_execute_params.py
create mode 100644 src/dataherald/types/sql_generation_execute_response.py
diff --git a/.stats.yml b/.stats.yml
index 48f88c4..de0574c 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1 +1 @@
-configured_endpoints: 43
+configured_endpoints: 44
diff --git a/api.md b/api.md
index e63b951..2b720f3 100644
--- a/api.md
+++ b/api.md
@@ -141,7 +141,7 @@ Methods:
Types:
```python
-from dataherald.types import SqlGenerationListResponse
+from dataherald.types import SqlGenerationListResponse, SqlGenerationExecuteResponse
```
Methods:
@@ -149,6 +149,7 @@ Methods:
- client.sql_generations.create(\*\*params) -> SqlGenerationResponse
- client.sql_generations.retrieve(id) -> SqlGenerationResponse
- client.sql_generations.list(\*\*params) -> SqlGenerationListResponse
+- client.sql_generations.execute(id, \*\*params) -> SqlGenerationExecuteResponse
## NlGenerations
diff --git a/src/dataherald/resources/sql_generations/sql_generations.py b/src/dataherald/resources/sql_generations/sql_generations.py
index d588b9a..ba2d8b9 100644
--- a/src/dataherald/resources/sql_generations/sql_generations.py
+++ b/src/dataherald/resources/sql_generations/sql_generations.py
@@ -4,7 +4,13 @@
import httpx
-from ...types import SqlGenerationListResponse, sql_generation_list_params, sql_generation_create_params
+from ...types import (
+ SqlGenerationListResponse,
+ SqlGenerationExecuteResponse,
+ sql_generation_list_params,
+ sql_generation_create_params,
+ sql_generation_execute_params,
+)
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import maybe_transform
from ..._compat import cached_property
@@ -155,6 +161,42 @@ def list(
cast_to=SqlGenerationListResponse,
)
+ def execute(
+ self,
+ id: str,
+ *,
+ max_rows: int | 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.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> SqlGenerationExecuteResponse:
+ """
+ Execute Sql Generation
+
+ Args:
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return self._get(
+ f"/api/sql-generations/{id}/execute",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform({"max_rows": max_rows}, sql_generation_execute_params.SqlGenerationExecuteParams),
+ ),
+ cast_to=SqlGenerationExecuteResponse,
+ )
+
class AsyncSqlGenerations(AsyncAPIResource):
@cached_property
@@ -287,6 +329,42 @@ async def list(
cast_to=SqlGenerationListResponse,
)
+ async def execute(
+ self,
+ id: str,
+ *,
+ max_rows: int | 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.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> SqlGenerationExecuteResponse:
+ """
+ Execute Sql Generation
+
+ Args:
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return await self._get(
+ f"/api/sql-generations/{id}/execute",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform({"max_rows": max_rows}, sql_generation_execute_params.SqlGenerationExecuteParams),
+ ),
+ cast_to=SqlGenerationExecuteResponse,
+ )
+
class SqlGenerationsWithRawResponse:
def __init__(self, sql_generations: SqlGenerations) -> None:
@@ -301,6 +379,9 @@ def __init__(self, sql_generations: SqlGenerations) -> None:
self.list = to_raw_response_wrapper(
sql_generations.list,
)
+ self.execute = to_raw_response_wrapper(
+ sql_generations.execute,
+ )
class AsyncSqlGenerationsWithRawResponse:
@@ -316,3 +397,6 @@ def __init__(self, sql_generations: AsyncSqlGenerations) -> None:
self.list = async_to_raw_response_wrapper(
sql_generations.list,
)
+ self.execute = async_to_raw_response_wrapper(
+ sql_generations.execute,
+ )
diff --git a/src/dataherald/types/__init__.py b/src/dataherald/types/__init__.py
index 8e346b2..9b59f05 100644
--- a/src/dataherald/types/__init__.py
+++ b/src/dataherald/types/__init__.py
@@ -37,7 +37,9 @@
from .nl_generation_list_response import NlGenerationListResponse as NlGenerationListResponse
from .sql_generation_create_params import SqlGenerationCreateParams as SqlGenerationCreateParams
from .sql_generation_list_response import SqlGenerationListResponse as SqlGenerationListResponse
+from .sql_generation_execute_params import SqlGenerationExecuteParams as SqlGenerationExecuteParams
from .table_description_list_params import TableDescriptionListParams as TableDescriptionListParams
+from .sql_generation_execute_response import SqlGenerationExecuteResponse as SqlGenerationExecuteResponse
from .table_description_list_response import TableDescriptionListResponse as TableDescriptionListResponse
from .table_description_update_params import TableDescriptionUpdateParams as TableDescriptionUpdateParams
from .generation_sql_generation_params import GenerationSqlGenerationParams as GenerationSqlGenerationParams
diff --git a/src/dataherald/types/sql_generation_execute_params.py b/src/dataherald/types/sql_generation_execute_params.py
new file mode 100644
index 0000000..bbf78f7
--- /dev/null
+++ b/src/dataherald/types/sql_generation_execute_params.py
@@ -0,0 +1,11 @@
+# File generated from our OpenAPI spec by Stainless.
+
+from __future__ import annotations
+
+from typing_extensions import TypedDict
+
+__all__ = ["SqlGenerationExecuteParams"]
+
+
+class SqlGenerationExecuteParams(TypedDict, total=False):
+ max_rows: int
diff --git a/src/dataherald/types/sql_generation_execute_response.py b/src/dataherald/types/sql_generation_execute_response.py
new file mode 100644
index 0000000..f324f79
--- /dev/null
+++ b/src/dataherald/types/sql_generation_execute_response.py
@@ -0,0 +1,7 @@
+# File generated from our OpenAPI spec by Stainless.
+
+from typing import List
+
+__all__ = ["SqlGenerationExecuteResponse"]
+
+SqlGenerationExecuteResponse = List[object]
diff --git a/tests/api_resources/test_sql_generations.py b/tests/api_resources/test_sql_generations.py
index 9e18025..036f74b 100644
--- a/tests/api_resources/test_sql_generations.py
+++ b/tests/api_resources/test_sql_generations.py
@@ -8,7 +8,10 @@
from dataherald import Dataherald, AsyncDataherald
from tests.utils import assert_matches_type
-from dataherald.types import SqlGenerationListResponse
+from dataherald.types import (
+ SqlGenerationListResponse,
+ SqlGenerationExecuteResponse,
+)
from dataherald._client import Dataherald, AsyncDataherald
from dataherald.types.shared import SqlGenerationResponse
@@ -96,6 +99,30 @@ def test_raw_response_list(self, client: Dataherald) -> None:
sql_generation = response.parse()
assert_matches_type(SqlGenerationListResponse, sql_generation, path=["response"])
+ @parametrize
+ def test_method_execute(self, client: Dataherald) -> None:
+ sql_generation = client.sql_generations.execute(
+ "string",
+ )
+ assert_matches_type(SqlGenerationExecuteResponse, sql_generation, path=["response"])
+
+ @parametrize
+ def test_method_execute_with_all_params(self, client: Dataherald) -> None:
+ sql_generation = client.sql_generations.execute(
+ "string",
+ max_rows=0,
+ )
+ assert_matches_type(SqlGenerationExecuteResponse, sql_generation, path=["response"])
+
+ @parametrize
+ def test_raw_response_execute(self, client: Dataherald) -> None:
+ response = client.sql_generations.with_raw_response.execute(
+ "string",
+ )
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ sql_generation = response.parse()
+ assert_matches_type(SqlGenerationExecuteResponse, sql_generation, path=["response"])
+
class TestAsyncSqlGenerations:
strict_client = AsyncDataherald(base_url=base_url, api_key=api_key, _strict_response_validation=True)
@@ -176,3 +203,27 @@ async def test_raw_response_list(self, client: AsyncDataherald) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
sql_generation = response.parse()
assert_matches_type(SqlGenerationListResponse, sql_generation, path=["response"])
+
+ @parametrize
+ async def test_method_execute(self, client: AsyncDataherald) -> None:
+ sql_generation = await client.sql_generations.execute(
+ "string",
+ )
+ assert_matches_type(SqlGenerationExecuteResponse, sql_generation, path=["response"])
+
+ @parametrize
+ async def test_method_execute_with_all_params(self, client: AsyncDataherald) -> None:
+ sql_generation = await client.sql_generations.execute(
+ "string",
+ max_rows=0,
+ )
+ assert_matches_type(SqlGenerationExecuteResponse, sql_generation, path=["response"])
+
+ @parametrize
+ async def test_raw_response_execute(self, client: AsyncDataherald) -> None:
+ response = await client.sql_generations.with_raw_response.execute(
+ "string",
+ )
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ sql_generation = response.parse()
+ assert_matches_type(SqlGenerationExecuteResponse, sql_generation, path=["response"])