Skip to content

Commit

Permalink
feat(api): OpenAPI spec update (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 9, 2024
1 parent 92d1f7d commit c197ab5
Show file tree
Hide file tree
Showing 7 changed files with 160 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: 43
configured_endpoints: 44
3 changes: 2 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,15 @@ Methods:
Types:

```python
from dataherald.types import SqlGenerationListResponse
from dataherald.types import SqlGenerationListResponse, SqlGenerationExecuteResponse
```

Methods:

- <code title="post /api/prompts/sql-generations">client.sql_generations.<a href="./src/dataherald/resources/sql_generations/sql_generations.py">create</a>(\*\*<a href="src/dataherald/types/sql_generation_create_params.py">params</a>) -> <a href="./src/dataherald/types/shared/sql_generation_response.py">SqlGenerationResponse</a></code>
- <code title="get /api/sql-generations/{id}">client.sql_generations.<a href="./src/dataherald/resources/sql_generations/sql_generations.py">retrieve</a>(id) -> <a href="./src/dataherald/types/shared/sql_generation_response.py">SqlGenerationResponse</a></code>
- <code title="get /api/sql-generations">client.sql_generations.<a href="./src/dataherald/resources/sql_generations/sql_generations.py">list</a>(\*\*<a href="src/dataherald/types/sql_generation_list_params.py">params</a>) -> <a href="./src/dataherald/types/sql_generation_list_response.py">SqlGenerationListResponse</a></code>
- <code title="get /api/sql-generations/{id}/execute">client.sql_generations.<a href="./src/dataherald/resources/sql_generations/sql_generations.py">execute</a>(id, \*\*<a href="src/dataherald/types/sql_generation_execute_params.py">params</a>) -> <a href="./src/dataherald/types/sql_generation_execute_response.py">SqlGenerationExecuteResponse</a></code>

## NlGenerations

Expand Down
86 changes: 85 additions & 1 deletion src/dataherald/resources/sql_generations/sql_generations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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,
)
2 changes: 2 additions & 0 deletions src/dataherald/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/dataherald/types/sql_generation_execute_params.py
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions src/dataherald/types/sql_generation_execute_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# File generated from our OpenAPI spec by Stainless.

from typing import List

__all__ = ["SqlGenerationExecuteResponse"]

SqlGenerationExecuteResponse = List[object]
53 changes: 52 additions & 1 deletion tests/api_resources/test_sql_generations.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 SqlGenerationListResponse
from dataherald.types import (
SqlGenerationListResponse,
SqlGenerationExecuteResponse,
)
from dataherald._client import Dataherald, AsyncDataherald
from dataherald.types.shared import SqlGenerationResponse

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

0 comments on commit c197ab5

Please sign in to comment.