From 8ea5be246f8471bc252df1dd431c45bc428d08b5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2024 12:40:42 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API (#1192) --- .stats.yml | 2 +- src/cloudflare/resources/d1/database.py | 37 ++++++++++++++++++- .../types/d1/database_create_params.py | 9 ++++- .../types/d1/database_query_params.py | 5 +++ .../types/d1/database_raw_params.py | 5 +++ tests/api_resources/d1/test_database.py | 18 +++++++++ 6 files changed, 72 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index de350b884f5..d61ced56609 100644 --- a/.stats.yml +++ b/.stats.yml @@ -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 diff --git a/src/cloudflare/resources/d1/database.py b/src/cloudflare/resources/d1/database.py index 7223084588d..14a2dfce413 100644 --- a/src/cloudflare/resources/d1/database.py +++ b/src/cloudflare/resources/d1/database.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Any, List, Type, cast +from typing_extensions import Literal import httpx @@ -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, @@ -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 @@ -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, @@ -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 @@ -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 @@ -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, @@ -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 @@ -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, @@ -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 @@ -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 diff --git a/src/cloudflare/types/d1/database_create_params.py b/src/cloudflare/types/d1/database_create_params.py index e71180e85dd..3db8ef15021 100644 --- a/src/cloudflare/types/d1/database_create_params.py +++ b/src/cloudflare/types/d1/database_create_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["DatabaseCreateParams"] @@ -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. + """ diff --git a/src/cloudflare/types/d1/database_query_params.py b/src/cloudflare/types/d1/database_query_params.py index 5c33fb076cb..f7c06437625 100644 --- a/src/cloudflare/types/d1/database_query_params.py +++ b/src/cloudflare/types/d1/database_query_params.py @@ -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] diff --git a/src/cloudflare/types/d1/database_raw_params.py b/src/cloudflare/types/d1/database_raw_params.py index 9c056647b21..5a7fd0ae2e3 100644 --- a/src/cloudflare/types/d1/database_raw_params.py +++ b/src/cloudflare/types/d1/database_raw_params.py @@ -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] diff --git a/tests/api_resources/d1/test_database.py b/tests/api_resources/d1/test_database.py index 58ce4be1a90..d0ade522942 100644 --- a/tests/api_resources/d1/test_database.py +++ b/tests/api_resources/d1/test_database.py @@ -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( @@ -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(