Skip to content

Commit 8ea5be2

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): OpenAPI spec update via Stainless API (#1192)
1 parent 9c895b4 commit 8ea5be2

File tree

6 files changed

+72
-4
lines changed

6 files changed

+72
-4
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1256
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-dc191ddbe3d3013cd1f90d1747ebd7022d0f938d1e547eb284ae675d34c87e78.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2a553d49ea7dea09efa86fd5af7cdaba8c2a757071c4114a4d8de234cbcdc740.yml

src/cloudflare/resources/d1/database.py

+35-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
from typing import Any, List, Type, cast
6+
from typing_extensions import Literal
67

78
import httpx
89

@@ -47,6 +48,7 @@ def create(
4748
*,
4849
account_id: str,
4950
name: str,
51+
primary_location_hint: Literal["wnam", "enam", "weur", "eeur", "apac", "oc"] | NotGiven = NOT_GIVEN,
5052
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5153
# The extra values given here take precedence over values defined on the client or passed to this method.
5254
extra_headers: Headers | None = None,
@@ -60,6 +62,9 @@ def create(
6062
Args:
6163
account_id: Account identifier tag.
6264
65+
primary_location_hint: Specify the region to create the D1 primary, if available. If this option is
66+
omitted, the D1 will be created as close as possible to the current user.
67+
6368
extra_headers: Send extra headers
6469
6570
extra_query: Add additional query parameters to the request
@@ -72,7 +77,13 @@ def create(
7277
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
7378
return self._post(
7479
f"/accounts/{account_id}/d1/database",
75-
body=maybe_transform({"name": name}, database_create_params.DatabaseCreateParams),
80+
body=maybe_transform(
81+
{
82+
"name": name,
83+
"primary_location_hint": primary_location_hint,
84+
},
85+
database_create_params.DatabaseCreateParams,
86+
),
7687
options=make_request_options(
7788
extra_headers=extra_headers,
7889
extra_query=extra_query,
@@ -248,6 +259,9 @@ def query(
248259
Args:
249260
account_id: Account identifier tag.
250261
262+
sql: Your SQL query. Supports multiple statements, joined by semicolons, which will
263+
be executed as a batch.
264+
251265
extra_headers: Send extra headers
252266
253267
extra_query: Add additional query parameters to the request
@@ -301,6 +315,9 @@ def raw(
301315
Args:
302316
account_id: Account identifier tag.
303317
318+
sql: Your SQL query. Supports multiple statements, joined by semicolons, which will
319+
be executed as a batch.
320+
304321
extra_headers: Send extra headers
305322
306323
extra_query: Add additional query parameters to the request
@@ -347,6 +364,7 @@ async def create(
347364
*,
348365
account_id: str,
349366
name: str,
367+
primary_location_hint: Literal["wnam", "enam", "weur", "eeur", "apac", "oc"] | NotGiven = NOT_GIVEN,
350368
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
351369
# The extra values given here take precedence over values defined on the client or passed to this method.
352370
extra_headers: Headers | None = None,
@@ -360,6 +378,9 @@ async def create(
360378
Args:
361379
account_id: Account identifier tag.
362380
381+
primary_location_hint: Specify the region to create the D1 primary, if available. If this option is
382+
omitted, the D1 will be created as close as possible to the current user.
383+
363384
extra_headers: Send extra headers
364385
365386
extra_query: Add additional query parameters to the request
@@ -372,7 +393,13 @@ async def create(
372393
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
373394
return await self._post(
374395
f"/accounts/{account_id}/d1/database",
375-
body=await async_maybe_transform({"name": name}, database_create_params.DatabaseCreateParams),
396+
body=await async_maybe_transform(
397+
{
398+
"name": name,
399+
"primary_location_hint": primary_location_hint,
400+
},
401+
database_create_params.DatabaseCreateParams,
402+
),
376403
options=make_request_options(
377404
extra_headers=extra_headers,
378405
extra_query=extra_query,
@@ -548,6 +575,9 @@ async def query(
548575
Args:
549576
account_id: Account identifier tag.
550577
578+
sql: Your SQL query. Supports multiple statements, joined by semicolons, which will
579+
be executed as a batch.
580+
551581
extra_headers: Send extra headers
552582
553583
extra_query: Add additional query parameters to the request
@@ -601,6 +631,9 @@ async def raw(
601631
Args:
602632
account_id: Account identifier tag.
603633
634+
sql: Your SQL query. Supports multiple statements, joined by semicolons, which will
635+
be executed as a batch.
636+
604637
extra_headers: Send extra headers
605638
606639
extra_query: Add additional query parameters to the request

src/cloudflare/types/d1/database_create_params.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Required, TypedDict
5+
from typing_extensions import Literal, Required, TypedDict
66

77
__all__ = ["DatabaseCreateParams"]
88

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

1414
name: Required[str]
15+
16+
primary_location_hint: Literal["wnam", "enam", "weur", "eeur", "apac", "oc"]
17+
"""Specify the region to create the D1 primary, if available.
18+
19+
If this option is omitted, the D1 will be created as close as possible to the
20+
current user.
21+
"""

src/cloudflare/types/d1/database_query_params.py

+5
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@ class DatabaseQueryParams(TypedDict, total=False):
1313
"""Account identifier tag."""
1414

1515
sql: Required[str]
16+
"""Your SQL query.
17+
18+
Supports multiple statements, joined by semicolons, which will be executed as a
19+
batch.
20+
"""
1621

1722
params: List[str]

src/cloudflare/types/d1/database_raw_params.py

+5
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@ class DatabaseRawParams(TypedDict, total=False):
1313
"""Account identifier tag."""
1414

1515
sql: Required[str]
16+
"""Your SQL query.
17+
18+
Supports multiple statements, joined by semicolons, which will be executed as a
19+
batch.
20+
"""
1621

1722
params: List[str]

tests/api_resources/d1/test_database.py

+18
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ def test_method_create(self, client: Cloudflare) -> None:
3333
)
3434
assert_matches_type(DatabaseCreateResponse, database, path=["response"])
3535

36+
@parametrize
37+
def test_method_create_with_all_params(self, client: Cloudflare) -> None:
38+
database = client.d1.database.create(
39+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
40+
name="my-database",
41+
primary_location_hint="wnam",
42+
)
43+
assert_matches_type(DatabaseCreateResponse, database, path=["response"])
44+
3645
@parametrize
3746
def test_raw_response_create(self, client: Cloudflare) -> None:
3847
response = client.d1.database.with_raw_response.create(
@@ -349,6 +358,15 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None:
349358
)
350359
assert_matches_type(DatabaseCreateResponse, database, path=["response"])
351360

361+
@parametrize
362+
async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
363+
database = await async_client.d1.database.create(
364+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
365+
name="my-database",
366+
primary_location_hint="wnam",
367+
)
368+
assert_matches_type(DatabaseCreateResponse, database, path=["response"])
369+
352370
@parametrize
353371
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
354372
response = await async_client.d1.database.with_raw_response.create(

0 commit comments

Comments
 (0)