Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#1192)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Jul 16, 2024
1 parent 86ce9df commit 7ae9572
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1256
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-dc191ddbe3d3013cd1f90d1747ebd7022d0f938d1e547eb284ae675d34c87e78.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2a553d49ea7dea09efa86fd5af7cdaba8c2a757071c4114a4d8de234cbcdc740.yml
37 changes: 35 additions & 2 deletions src/cloudflare/resources/d1/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from typing import Any, List, Type, cast
from typing_extensions import Literal

import httpx

Expand Down Expand Up @@ -47,6 +48,7 @@ def create(
*,
account_id: str,
name: str,
primary_location_hint: Literal["wnam", "enam", "weur", "eeur", "apac", "oc"] | 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,
Expand All @@ -60,6 +62,9 @@ def create(
Args:
account_id: Account identifier tag.
primary_location_hint: Specify the region to create the D1 primary, if available. If this option is
omitted, the D1 will be created as close as possible to the current user.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand All @@ -72,7 +77,13 @@ def create(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._post(
f"/accounts/{account_id}/d1/database",
body=maybe_transform({"name": name}, database_create_params.DatabaseCreateParams),
body=maybe_transform(
{
"name": name,
"primary_location_hint": primary_location_hint,
},
database_create_params.DatabaseCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down Expand Up @@ -248,6 +259,9 @@ def query(
Args:
account_id: Account identifier tag.
sql: Your SQL query. Supports multiple statements, joined by semicolons, which will
be executed as a batch.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -301,6 +315,9 @@ def raw(
Args:
account_id: Account identifier tag.
sql: Your SQL query. Supports multiple statements, joined by semicolons, which will
be executed as a batch.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -347,6 +364,7 @@ async def create(
*,
account_id: str,
name: str,
primary_location_hint: Literal["wnam", "enam", "weur", "eeur", "apac", "oc"] | 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,
Expand All @@ -360,6 +378,9 @@ async def create(
Args:
account_id: Account identifier tag.
primary_location_hint: Specify the region to create the D1 primary, if available. If this option is
omitted, the D1 will be created as close as possible to the current user.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand All @@ -372,7 +393,13 @@ async def create(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return await self._post(
f"/accounts/{account_id}/d1/database",
body=await async_maybe_transform({"name": name}, database_create_params.DatabaseCreateParams),
body=await async_maybe_transform(
{
"name": name,
"primary_location_hint": primary_location_hint,
},
database_create_params.DatabaseCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down Expand Up @@ -548,6 +575,9 @@ async def query(
Args:
account_id: Account identifier tag.
sql: Your SQL query. Supports multiple statements, joined by semicolons, which will
be executed as a batch.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -601,6 +631,9 @@ async def raw(
Args:
account_id: Account identifier tag.
sql: Your SQL query. Supports multiple statements, joined by semicolons, which will
be executed as a batch.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand Down
9 changes: 8 additions & 1 deletion src/cloudflare/types/d1/database_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing_extensions import Required, TypedDict
from typing_extensions import Literal, Required, TypedDict

__all__ = ["DatabaseCreateParams"]

Expand All @@ -12,3 +12,10 @@ class DatabaseCreateParams(TypedDict, total=False):
"""Account identifier tag."""

name: Required[str]

primary_location_hint: Literal["wnam", "enam", "weur", "eeur", "apac", "oc"]
"""Specify the region to create the D1 primary, if available.
If this option is omitted, the D1 will be created as close as possible to the
current user.
"""
5 changes: 5 additions & 0 deletions src/cloudflare/types/d1/database_query_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ class DatabaseQueryParams(TypedDict, total=False):
"""Account identifier tag."""

sql: Required[str]
"""Your SQL query.
Supports multiple statements, joined by semicolons, which will be executed as a
batch.
"""

params: List[str]
5 changes: 5 additions & 0 deletions src/cloudflare/types/d1/database_raw_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ class DatabaseRawParams(TypedDict, total=False):
"""Account identifier tag."""

sql: Required[str]
"""Your SQL query.
Supports multiple statements, joined by semicolons, which will be executed as a
batch.
"""

params: List[str]
18 changes: 18 additions & 0 deletions tests/api_resources/d1/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ def test_method_create(self, client: Cloudflare) -> None:
)
assert_matches_type(DatabaseCreateResponse, database, path=["response"])

@parametrize
def test_method_create_with_all_params(self, client: Cloudflare) -> None:
database = client.d1.database.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
name="my-database",
primary_location_hint="wnam",
)
assert_matches_type(DatabaseCreateResponse, database, path=["response"])

@parametrize
def test_raw_response_create(self, client: Cloudflare) -> None:
response = client.d1.database.with_raw_response.create(
Expand Down Expand Up @@ -349,6 +358,15 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None:
)
assert_matches_type(DatabaseCreateResponse, database, path=["response"])

@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
database = await async_client.d1.database.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
name="my-database",
primary_location_hint="wnam",
)
assert_matches_type(DatabaseCreateResponse, database, path=["response"])

@parametrize
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
response = await async_client.d1.database.with_raw_response.create(
Expand Down

0 comments on commit 7ae9572

Please sign in to comment.