From bd173d34e3e4287611ad1ecd0f9c7745cac7b8d8 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Thu, 4 Jan 2024 16:31:23 +0000
Subject: [PATCH] feat(api): OpenAPI spec update (#8)
---
.stats.yml | 2 +-
api.md | 2 +
src/dataherald/resources/golden_sqls.py | 79 +++++++++++++-
src/dataherald/types/__init__.py | 2 +
.../types/golden_sql_upload_params.py | 22 ++++
.../types/golden_sql_upload_response.py | 9 ++
tests/api_resources/test_golden_sqls.py | 101 +++++++++++++++++-
7 files changed, 213 insertions(+), 4 deletions(-)
create mode 100644 src/dataherald/types/golden_sql_upload_params.py
create mode 100644 src/dataherald/types/golden_sql_upload_response.py
diff --git a/.stats.yml b/.stats.yml
index 1fd2991..37da431 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1 +1 @@
-configured_endpoints: 41
+configured_endpoints: 42
diff --git a/api.md b/api.md
index 7769312..6e31cf3 100644
--- a/api.md
+++ b/api.md
@@ -58,6 +58,7 @@ from dataherald.types import (
AdminConsoleGoldenSqlResponse,
GoldenSqlListResponse,
GoldenSqlDeleteResponse,
+ GoldenSqlUploadResponse,
)
```
@@ -66,6 +67,7 @@ Methods:
- client.golden_sqls.retrieve(id) -> GoldenSqlResponse
- client.golden_sqls.list(\*\*params) -> GoldenSqlListResponse
- client.golden_sqls.delete(id) -> object
+- client.golden_sqls.upload(\*\*params) -> GoldenSqlUploadResponse
# Instructions
diff --git a/src/dataherald/resources/golden_sqls.py b/src/dataherald/resources/golden_sqls.py
index e89379a..6acd4bf 100644
--- a/src/dataherald/resources/golden_sqls.py
+++ b/src/dataherald/resources/golden_sqls.py
@@ -2,11 +2,16 @@
from __future__ import annotations
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, List
import httpx
-from ..types import GoldenSqlListResponse, golden_sql_list_params
+from ..types import (
+ GoldenSqlListResponse,
+ GoldenSqlUploadResponse,
+ golden_sql_list_params,
+ golden_sql_upload_params,
+)
from .._types import (
NOT_GIVEN,
Body,
@@ -144,6 +149,38 @@ def delete(
cast_to=UnknownResponse,
)
+ def upload(
+ self,
+ *,
+ body: List[golden_sql_upload_params.Body],
+ # 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,
+ ) -> GoldenSqlUploadResponse:
+ """
+ Api Add User Upload Golden Sql
+
+ 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._post(
+ "/api/golden-sqls",
+ body=maybe_transform(body, golden_sql_upload_params.GoldenSqlUploadParams),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=GoldenSqlUploadResponse,
+ )
+
class AsyncGoldenSqls(AsyncAPIResource):
with_raw_response: AsyncGoldenSqlsWithRawResponse
@@ -260,6 +297,38 @@ async def delete(
cast_to=UnknownResponse,
)
+ async def upload(
+ self,
+ *,
+ body: List[golden_sql_upload_params.Body],
+ # 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,
+ ) -> GoldenSqlUploadResponse:
+ """
+ Api Add User Upload Golden Sql
+
+ 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._post(
+ "/api/golden-sqls",
+ body=maybe_transform(body, golden_sql_upload_params.GoldenSqlUploadParams),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=GoldenSqlUploadResponse,
+ )
+
class GoldenSqlsWithRawResponse:
def __init__(self, golden_sqls: GoldenSqls) -> None:
@@ -272,6 +341,9 @@ def __init__(self, golden_sqls: GoldenSqls) -> None:
self.delete = to_raw_response_wrapper(
golden_sqls.delete,
)
+ self.upload = to_raw_response_wrapper(
+ golden_sqls.upload,
+ )
class AsyncGoldenSqlsWithRawResponse:
@@ -285,3 +357,6 @@ def __init__(self, golden_sqls: AsyncGoldenSqls) -> None:
self.delete = async_to_raw_response_wrapper(
golden_sqls.delete,
)
+ self.upload = async_to_raw_response_wrapper(
+ golden_sqls.upload,
+ )
diff --git a/src/dataherald/types/__init__.py b/src/dataherald/types/__init__.py
index 0308b86..4f91c11 100644
--- a/src/dataherald/types/__init__.py
+++ b/src/dataherald/types/__init__.py
@@ -23,10 +23,12 @@
from .generation_list_response import GenerationListResponse as GenerationListResponse
from .generation_update_params import GenerationUpdateParams as GenerationUpdateParams
from .golden_sql_list_response import GoldenSqlListResponse as GoldenSqlListResponse
+from .golden_sql_upload_params import GoldenSqlUploadParams as GoldenSqlUploadParams
from .instruction_create_params import InstructionCreateParams as InstructionCreateParams
from .instruction_list_response import InstructionListResponse as InstructionListResponse
from .instruction_update_params import InstructionUpdateParams as InstructionUpdateParams
from .nl_generation_list_params import NlGenerationListParams as NlGenerationListParams
+from .golden_sql_upload_response import GoldenSqlUploadResponse as GoldenSqlUploadResponse
from .sql_generation_list_params import SqlGenerationListParams as SqlGenerationListParams
from .table_description_response import TableDescriptionResponse as TableDescriptionResponse
from .nl_generation_list_response import NlGenerationListResponse as NlGenerationListResponse
diff --git a/src/dataherald/types/golden_sql_upload_params.py b/src/dataherald/types/golden_sql_upload_params.py
new file mode 100644
index 0000000..0280003
--- /dev/null
+++ b/src/dataherald/types/golden_sql_upload_params.py
@@ -0,0 +1,22 @@
+# File generated from our OpenAPI spec by Stainless.
+
+from __future__ import annotations
+
+from typing import List
+from typing_extensions import Required, TypedDict
+
+__all__ = ["GoldenSqlUploadParams", "Body"]
+
+
+class GoldenSqlUploadParams(TypedDict, total=False):
+ body: Required[List[Body]]
+
+
+class Body(TypedDict, total=False):
+ db_connection_id: Required[str]
+
+ prompt_text: Required[str]
+
+ sql: Required[str]
+
+ metadata: object
diff --git a/src/dataherald/types/golden_sql_upload_response.py b/src/dataherald/types/golden_sql_upload_response.py
new file mode 100644
index 0000000..f4490a6
--- /dev/null
+++ b/src/dataherald/types/golden_sql_upload_response.py
@@ -0,0 +1,9 @@
+# File generated from our OpenAPI spec by Stainless.
+
+from typing import List
+
+from .shared import GoldenSqlResponse
+
+__all__ = ["GoldenSqlUploadResponse"]
+
+GoldenSqlUploadResponse = List[GoldenSqlResponse]
diff --git a/tests/api_resources/test_golden_sqls.py b/tests/api_resources/test_golden_sqls.py
index 35dce7a..ccf0660 100644
--- a/tests/api_resources/test_golden_sqls.py
+++ b/tests/api_resources/test_golden_sqls.py
@@ -8,7 +8,10 @@
from dataherald import Dataherald, AsyncDataherald
from tests.utils import assert_matches_type
-from dataherald.types import GoldenSqlListResponse
+from dataherald.types import (
+ GoldenSqlListResponse,
+ GoldenSqlUploadResponse,
+)
from dataherald._client import Dataherald, AsyncDataherald
from dataherald.types.shared import GoldenSqlResponse
@@ -75,6 +78,54 @@ def test_raw_response_delete(self, client: Dataherald) -> None:
golden_sql = response.parse()
assert_matches_type(object, golden_sql, path=["response"])
+ @parametrize
+ def test_method_upload(self, client: Dataherald) -> None:
+ golden_sql = client.golden_sqls.upload(
+ body=[
+ {
+ "db_connection_id": "string",
+ "prompt_text": "string",
+ "sql": "string",
+ },
+ {
+ "db_connection_id": "string",
+ "prompt_text": "string",
+ "sql": "string",
+ },
+ {
+ "db_connection_id": "string",
+ "prompt_text": "string",
+ "sql": "string",
+ },
+ ],
+ )
+ assert_matches_type(GoldenSqlUploadResponse, golden_sql, path=["response"])
+
+ @parametrize
+ def test_raw_response_upload(self, client: Dataherald) -> None:
+ response = client.golden_sqls.with_raw_response.upload(
+ body=[
+ {
+ "db_connection_id": "string",
+ "prompt_text": "string",
+ "sql": "string",
+ },
+ {
+ "db_connection_id": "string",
+ "prompt_text": "string",
+ "sql": "string",
+ },
+ {
+ "db_connection_id": "string",
+ "prompt_text": "string",
+ "sql": "string",
+ },
+ ],
+ )
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ golden_sql = response.parse()
+ assert_matches_type(GoldenSqlUploadResponse, golden_sql, path=["response"])
+
class TestAsyncGoldenSqls:
strict_client = AsyncDataherald(base_url=base_url, api_key=api_key, _strict_response_validation=True)
@@ -134,3 +185,51 @@ async def test_raw_response_delete(self, client: AsyncDataherald) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
golden_sql = response.parse()
assert_matches_type(object, golden_sql, path=["response"])
+
+ @parametrize
+ async def test_method_upload(self, client: AsyncDataherald) -> None:
+ golden_sql = await client.golden_sqls.upload(
+ body=[
+ {
+ "db_connection_id": "string",
+ "prompt_text": "string",
+ "sql": "string",
+ },
+ {
+ "db_connection_id": "string",
+ "prompt_text": "string",
+ "sql": "string",
+ },
+ {
+ "db_connection_id": "string",
+ "prompt_text": "string",
+ "sql": "string",
+ },
+ ],
+ )
+ assert_matches_type(GoldenSqlUploadResponse, golden_sql, path=["response"])
+
+ @parametrize
+ async def test_raw_response_upload(self, client: AsyncDataherald) -> None:
+ response = await client.golden_sqls.with_raw_response.upload(
+ body=[
+ {
+ "db_connection_id": "string",
+ "prompt_text": "string",
+ "sql": "string",
+ },
+ {
+ "db_connection_id": "string",
+ "prompt_text": "string",
+ "sql": "string",
+ },
+ {
+ "db_connection_id": "string",
+ "prompt_text": "string",
+ "sql": "string",
+ },
+ ],
+ )
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ golden_sql = response.parse()
+ assert_matches_type(GoldenSqlUploadResponse, golden_sql, path=["response"])