Skip to content

Commit f5c0d88

Browse files
feat: feat(api): RAG-586: enable terraform for AI Search instances and tokens
* feat(api): RAG-586: fix ai search tokens endpoints * feat(api): RAG-586: enable terraform for AI Search instances and tokens
1 parent 466b5b9 commit f5c0d88

6 files changed

Lines changed: 83 additions & 13 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 2013
1+
configured_endpoints: 2015
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-83f49bc3fa9273ef989d3e8bcd27f6fdaa7d04ae2519a91f4878f46acc501bb9.yml
33
openapi_spec_hash: 3f4be3af6f51eea4787dc8345f9ca9c1
4-
config_hash: f2fe616450f46430ad4918e245c09a69
4+
config_hash: ef33fdb9b0af38377b29a35407bc7617

api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10724,10 +10724,10 @@ from cloudflare.types.aisearch import (
1072410724
Methods:
1072510725

1072610726
- <code title="post /accounts/{account_id}/ai-search/tokens">client.aisearch.tokens.<a href="./src/cloudflare/resources/aisearch/tokens.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/aisearch/token_create_params.py">params</a>) -> <a href="./src/cloudflare/types/aisearch/token_create_response.py">TokenCreateResponse</a></code>
10727-
- <code title="delete /accounts/{account_id}/ai-search/tokens/{id}">client.aisearch.tokens.<a href="./src/cloudflare/resources/aisearch/tokens.py">update</a>(id, \*, account_id) -> <a href="./src/cloudflare/types/aisearch/token_update_response.py">TokenUpdateResponse</a></code>
10727+
- <code title="put /accounts/{account_id}/ai-search/tokens/{id}">client.aisearch.tokens.<a href="./src/cloudflare/resources/aisearch/tokens.py">update</a>(id, \*, account_id, \*\*<a href="src/cloudflare/types/aisearch/token_update_params.py">params</a>) -> <a href="./src/cloudflare/types/aisearch/token_update_response.py">TokenUpdateResponse</a></code>
1072810728
- <code title="get /accounts/{account_id}/ai-search/tokens">client.aisearch.tokens.<a href="./src/cloudflare/resources/aisearch/tokens.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/aisearch/token_list_params.py">params</a>) -> <a href="./src/cloudflare/types/aisearch/token_list_response.py">SyncV4PagePaginationArray[TokenListResponse]</a></code>
1072910729
- <code title="delete /accounts/{account_id}/ai-search/tokens/{id}">client.aisearch.tokens.<a href="./src/cloudflare/resources/aisearch/tokens.py">delete</a>(id, \*, account_id) -> <a href="./src/cloudflare/types/aisearch/token_delete_response.py">TokenDeleteResponse</a></code>
10730-
- <code title="delete /accounts/{account_id}/ai-search/tokens/{id}">client.aisearch.tokens.<a href="./src/cloudflare/resources/aisearch/tokens.py">read</a>(id, \*, account_id) -> <a href="./src/cloudflare/types/aisearch/token_read_response.py">TokenReadResponse</a></code>
10730+
- <code title="get /accounts/{account_id}/ai-search/tokens/{id}">client.aisearch.tokens.<a href="./src/cloudflare/resources/aisearch/tokens.py">read</a>(id, \*, account_id) -> <a href="./src/cloudflare/types/aisearch/token_read_response.py">TokenReadResponse</a></code>
1073110731

1073210732
# SecurityCenter
1073310733

src/cloudflare/resources/aisearch/tokens.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from ..._wrappers import ResultWrapper
2020
from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
2121
from ..._base_client import AsyncPaginator, make_request_options
22-
from ...types.aisearch import token_list_params, token_create_params
22+
from ...types.aisearch import token_list_params, token_create_params, token_update_params
2323
from ...types.aisearch.token_list_response import TokenListResponse
2424
from ...types.aisearch.token_read_response import TokenReadResponse
2525
from ...types.aisearch.token_create_response import TokenCreateResponse
@@ -102,6 +102,9 @@ def update(
102102
id: str,
103103
*,
104104
account_id: str,
105+
cf_api_id: str,
106+
cf_api_key: str,
107+
name: str,
105108
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
106109
# The extra values given here take precedence over values defined on the client or passed to this method.
107110
extra_headers: Headers | None = None,
@@ -110,7 +113,7 @@ def update(
110113
timeout: float | httpx.Timeout | None | NotGiven = not_given,
111114
) -> TokenUpdateResponse:
112115
"""
113-
Delete tokens.
116+
Update tokens.
114117
115118
Args:
116119
extra_headers: Send extra headers
@@ -125,8 +128,16 @@ def update(
125128
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
126129
if not id:
127130
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
128-
return self._delete(
131+
return self._put(
129132
f"/accounts/{account_id}/ai-search/tokens/{id}",
133+
body=maybe_transform(
134+
{
135+
"cf_api_id": cf_api_id,
136+
"cf_api_key": cf_api_key,
137+
"name": name,
138+
},
139+
token_update_params.TokenUpdateParams,
140+
),
130141
options=make_request_options(
131142
extra_headers=extra_headers,
132143
extra_query=extra_query,
@@ -236,7 +247,7 @@ def read(
236247
timeout: float | httpx.Timeout | None | NotGiven = not_given,
237248
) -> TokenReadResponse:
238249
"""
239-
Delete tokens.
250+
Read tokens.
240251
241252
Args:
242253
extra_headers: Send extra headers
@@ -251,7 +262,7 @@ def read(
251262
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
252263
if not id:
253264
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
254-
return self._delete(
265+
return self._get(
255266
f"/accounts/{account_id}/ai-search/tokens/{id}",
256267
options=make_request_options(
257268
extra_headers=extra_headers,
@@ -337,6 +348,9 @@ async def update(
337348
id: str,
338349
*,
339350
account_id: str,
351+
cf_api_id: str,
352+
cf_api_key: str,
353+
name: str,
340354
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
341355
# The extra values given here take precedence over values defined on the client or passed to this method.
342356
extra_headers: Headers | None = None,
@@ -345,7 +359,7 @@ async def update(
345359
timeout: float | httpx.Timeout | None | NotGiven = not_given,
346360
) -> TokenUpdateResponse:
347361
"""
348-
Delete tokens.
362+
Update tokens.
349363
350364
Args:
351365
extra_headers: Send extra headers
@@ -360,8 +374,16 @@ async def update(
360374
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
361375
if not id:
362376
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
363-
return await self._delete(
377+
return await self._put(
364378
f"/accounts/{account_id}/ai-search/tokens/{id}",
379+
body=await async_maybe_transform(
380+
{
381+
"cf_api_id": cf_api_id,
382+
"cf_api_key": cf_api_key,
383+
"name": name,
384+
},
385+
token_update_params.TokenUpdateParams,
386+
),
365387
options=make_request_options(
366388
extra_headers=extra_headers,
367389
extra_query=extra_query,
@@ -471,7 +493,7 @@ async def read(
471493
timeout: float | httpx.Timeout | None | NotGiven = not_given,
472494
) -> TokenReadResponse:
473495
"""
474-
Delete tokens.
496+
Read tokens.
475497
476498
Args:
477499
extra_headers: Send extra headers
@@ -486,7 +508,7 @@ async def read(
486508
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
487509
if not id:
488510
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
489-
return await self._delete(
511+
return await self._get(
490512
f"/accounts/{account_id}/ai-search/tokens/{id}",
491513
options=make_request_options(
492514
extra_headers=extra_headers,

src/cloudflare/types/aisearch/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .token_create_params import TokenCreateParams as TokenCreateParams
77
from .token_list_response import TokenListResponse as TokenListResponse
88
from .token_read_response import TokenReadResponse as TokenReadResponse
9+
from .token_update_params import TokenUpdateParams as TokenUpdateParams
910
from .instance_list_params import InstanceListParams as InstanceListParams
1011
from .token_create_response import TokenCreateResponse as TokenCreateResponse
1112
from .token_delete_response import TokenDeleteResponse as TokenDeleteResponse
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import Required, TypedDict
6+
7+
__all__ = ["TokenUpdateParams"]
8+
9+
10+
class TokenUpdateParams(TypedDict, total=False):
11+
account_id: Required[str]
12+
13+
cf_api_id: Required[str]
14+
15+
cf_api_key: Required[str]
16+
17+
name: Required[str]

tests/api_resources/aisearch/test_tokens.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ def test_method_update(self, client: Cloudflare) -> None:
7979
token = client.aisearch.tokens.update(
8080
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
8181
account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22",
82+
cf_api_id="cf_api_id",
83+
cf_api_key="cf_api_key",
84+
name="name",
8285
)
8386
assert_matches_type(TokenUpdateResponse, token, path=["response"])
8487

@@ -87,6 +90,9 @@ def test_raw_response_update(self, client: Cloudflare) -> None:
8790
response = client.aisearch.tokens.with_raw_response.update(
8891
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
8992
account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22",
93+
cf_api_id="cf_api_id",
94+
cf_api_key="cf_api_key",
95+
name="name",
9096
)
9197

9298
assert response.is_closed is True
@@ -99,6 +105,9 @@ def test_streaming_response_update(self, client: Cloudflare) -> None:
99105
with client.aisearch.tokens.with_streaming_response.update(
100106
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
101107
account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22",
108+
cf_api_id="cf_api_id",
109+
cf_api_key="cf_api_key",
110+
name="name",
102111
) as response:
103112
assert not response.is_closed
104113
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -114,12 +123,18 @@ def test_path_params_update(self, client: Cloudflare) -> None:
114123
client.aisearch.tokens.with_raw_response.update(
115124
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
116125
account_id="",
126+
cf_api_id="cf_api_id",
127+
cf_api_key="cf_api_key",
128+
name="name",
117129
)
118130

119131
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
120132
client.aisearch.tokens.with_raw_response.update(
121133
id="",
122134
account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22",
135+
cf_api_id="cf_api_id",
136+
cf_api_key="cf_api_key",
137+
name="name",
123138
)
124139

125140
@parametrize
@@ -326,6 +341,9 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None:
326341
token = await async_client.aisearch.tokens.update(
327342
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
328343
account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22",
344+
cf_api_id="cf_api_id",
345+
cf_api_key="cf_api_key",
346+
name="name",
329347
)
330348
assert_matches_type(TokenUpdateResponse, token, path=["response"])
331349

@@ -334,6 +352,9 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
334352
response = await async_client.aisearch.tokens.with_raw_response.update(
335353
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
336354
account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22",
355+
cf_api_id="cf_api_id",
356+
cf_api_key="cf_api_key",
357+
name="name",
337358
)
338359

339360
assert response.is_closed is True
@@ -346,6 +367,9 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) ->
346367
async with async_client.aisearch.tokens.with_streaming_response.update(
347368
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
348369
account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22",
370+
cf_api_id="cf_api_id",
371+
cf_api_key="cf_api_key",
372+
name="name",
349373
) as response:
350374
assert not response.is_closed
351375
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -361,12 +385,18 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
361385
await async_client.aisearch.tokens.with_raw_response.update(
362386
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
363387
account_id="",
388+
cf_api_id="cf_api_id",
389+
cf_api_key="cf_api_key",
390+
name="name",
364391
)
365392

366393
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
367394
await async_client.aisearch.tokens.with_raw_response.update(
368395
id="",
369396
account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22",
397+
cf_api_id="cf_api_id",
398+
cf_api_key="cf_api_key",
399+
name="name",
370400
)
371401

372402
@parametrize

0 commit comments

Comments
 (0)