Skip to content

Commit

Permalink
feat(api): OpenAPI spec update (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 4, 2024
1 parent 9f0f0cc commit bd173d3
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 41
configured_endpoints: 42
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ from dataherald.types import (
AdminConsoleGoldenSqlResponse,
GoldenSqlListResponse,
GoldenSqlDeleteResponse,
GoldenSqlUploadResponse,
)
```

Expand All @@ -66,6 +67,7 @@ Methods:
- <code title="get /api/golden-sqls/{id}">client.golden_sqls.<a href="./src/dataherald/resources/golden_sqls.py">retrieve</a>(id) -> <a href="./src/dataherald/types/shared/golden_sql_response.py">GoldenSqlResponse</a></code>
- <code title="get /api/golden-sqls">client.golden_sqls.<a href="./src/dataherald/resources/golden_sqls.py">list</a>(\*\*<a href="src/dataherald/types/golden_sql_list_params.py">params</a>) -> <a href="./src/dataherald/types/golden_sql_list_response.py">GoldenSqlListResponse</a></code>
- <code title="delete /api/golden-sqls/{id}">client.golden_sqls.<a href="./src/dataherald/resources/golden_sqls.py">delete</a>(id) -> <a href="./src/dataherald/types/golden_sql_delete_response.py">object</a></code>
- <code title="post /api/golden-sqls">client.golden_sqls.<a href="./src/dataherald/resources/golden_sqls.py">upload</a>(\*\*<a href="src/dataherald/types/golden_sql_upload_params.py">params</a>) -> <a href="./src/dataherald/types/golden_sql_upload_response.py">GoldenSqlUploadResponse</a></code>

# Instructions

Expand Down
79 changes: 77 additions & 2 deletions src/dataherald/resources/golden_sqls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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,
)
2 changes: 2 additions & 0 deletions src/dataherald/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions src/dataherald/types/golden_sql_upload_params.py
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions src/dataherald/types/golden_sql_upload_response.py
Original file line number Diff line number Diff line change
@@ -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]
101 changes: 100 additions & 1 deletion tests/api_resources/test_golden_sqls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"])

0 comments on commit bd173d3

Please sign in to comment.