Skip to content

Commit 20f2512

Browse files
feat(api): update via SDK Studio
1 parent 6896be4 commit 20f2512

File tree

7 files changed

+240
-2
lines changed

7 files changed

+240
-2
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 174
1+
configured_endpoints: 175
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/digitalocean%2Fgradient-40c154e2fdc4fef9ca1cf8329c29b7102bf324acfc9589571d6f3452d1ca579c.yml
33
openapi_spec_hash: 83a3d092965fde776b29b61f785459f9
4-
config_hash: 3752c9f438752ab61938a8921bb3befd
4+
config_hash: dd3a0f16fb9e072bb63c570b14beccd2

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ from gradient.types.knowledge_bases import (
852852
DataSourceCreateResponse,
853853
DataSourceListResponse,
854854
DataSourceDeleteResponse,
855+
DataSourceCreatePresignedURLsResponse,
855856
)
856857
```
857858

@@ -860,6 +861,7 @@ Methods:
860861
- <code title="post /v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources">client.knowledge_bases.data_sources.<a href="./src/gradient/resources/knowledge_bases/data_sources.py">create</a>(path_knowledge_base_uuid, \*\*<a href="src/gradient/types/knowledge_bases/data_source_create_params.py">params</a>) -> <a href="./src/gradient/types/knowledge_bases/data_source_create_response.py">DataSourceCreateResponse</a></code>
861862
- <code title="get /v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources">client.knowledge_bases.data_sources.<a href="./src/gradient/resources/knowledge_bases/data_sources.py">list</a>(knowledge_base_uuid, \*\*<a href="src/gradient/types/knowledge_bases/data_source_list_params.py">params</a>) -> <a href="./src/gradient/types/knowledge_bases/data_source_list_response.py">DataSourceListResponse</a></code>
862863
- <code title="delete /v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources/{data_source_uuid}">client.knowledge_bases.data_sources.<a href="./src/gradient/resources/knowledge_bases/data_sources.py">delete</a>(data_source_uuid, \*, knowledge_base_uuid) -> <a href="./src/gradient/types/knowledge_bases/data_source_delete_response.py">DataSourceDeleteResponse</a></code>
864+
- <code title="post /v2/gen-ai/knowledge_bases/data_sources/file_upload_presigned_urls">client.knowledge_bases.data_sources.<a href="./src/gradient/resources/knowledge_bases/data_sources.py">create_presigned_urls</a>(\*\*<a href="src/gradient/types/knowledge_bases/data_source_create_presigned_urls_params.py">params</a>) -> <a href="./src/gradient/types/knowledge_bases/data_source_create_presigned_urls_response.py">DataSourceCreatePresignedURLsResponse</a></code>
863865

864866
## IndexingJobs
865867

src/gradient/resources/knowledge_bases/data_sources.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from __future__ import annotations
44

5+
from typing import Iterable
6+
57
import httpx
68

79
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
@@ -18,13 +20,15 @@
1820
from ...types.knowledge_bases import (
1921
data_source_list_params,
2022
data_source_create_params,
23+
data_source_create_presigned_urls_params,
2124
)
2225
from ...types.knowledge_bases.aws_data_source_param import AwsDataSourceParam
2326
from ...types.knowledge_bases.data_source_list_response import DataSourceListResponse
2427
from ...types.knowledge_bases.data_source_create_response import DataSourceCreateResponse
2528
from ...types.knowledge_bases.data_source_delete_response import DataSourceDeleteResponse
2629
from ...types.knowledge_bases.api_spaces_data_source_param import APISpacesDataSourceParam
2730
from ...types.knowledge_bases.api_web_crawler_data_source_param import APIWebCrawlerDataSourceParam
31+
from ...types.knowledge_bases.data_source_create_presigned_urls_response import DataSourceCreatePresignedURLsResponse
2832

2933
__all__ = ["DataSourcesResource", "AsyncDataSourcesResource"]
3034

@@ -203,6 +207,45 @@ def delete(
203207
cast_to=DataSourceDeleteResponse,
204208
)
205209

210+
def create_presigned_urls(
211+
self,
212+
*,
213+
files: Iterable[data_source_create_presigned_urls_params.File] | Omit = omit,
214+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
215+
# The extra values given here take precedence over values defined on the client or passed to this method.
216+
extra_headers: Headers | None = None,
217+
extra_query: Query | None = None,
218+
extra_body: Body | None = None,
219+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
220+
) -> DataSourceCreatePresignedURLsResponse:
221+
"""
222+
To create presigned URLs for knowledge base data source file upload, send a POST
223+
request to `/v2/gen-ai/knowledge_bases/data_sources/file_upload_presigned_urls`.
224+
225+
Args:
226+
files: A list of files to generate presigned URLs for.
227+
228+
extra_headers: Send extra headers
229+
230+
extra_query: Add additional query parameters to the request
231+
232+
extra_body: Add additional JSON properties to the request
233+
234+
timeout: Override the client-level default timeout for this request, in seconds
235+
"""
236+
return self._post(
237+
"/v2/gen-ai/knowledge_bases/data_sources/file_upload_presigned_urls"
238+
if self._client._base_url_overridden
239+
else "https://api.digitalocean.com/v2/gen-ai/knowledge_bases/data_sources/file_upload_presigned_urls",
240+
body=maybe_transform(
241+
{"files": files}, data_source_create_presigned_urls_params.DataSourceCreatePresignedURLsParams
242+
),
243+
options=make_request_options(
244+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
245+
),
246+
cast_to=DataSourceCreatePresignedURLsResponse,
247+
)
248+
206249

207250
class AsyncDataSourcesResource(AsyncAPIResource):
208251
@cached_property
@@ -378,6 +421,45 @@ async def delete(
378421
cast_to=DataSourceDeleteResponse,
379422
)
380423

424+
async def create_presigned_urls(
425+
self,
426+
*,
427+
files: Iterable[data_source_create_presigned_urls_params.File] | Omit = omit,
428+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
429+
# The extra values given here take precedence over values defined on the client or passed to this method.
430+
extra_headers: Headers | None = None,
431+
extra_query: Query | None = None,
432+
extra_body: Body | None = None,
433+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
434+
) -> DataSourceCreatePresignedURLsResponse:
435+
"""
436+
To create presigned URLs for knowledge base data source file upload, send a POST
437+
request to `/v2/gen-ai/knowledge_bases/data_sources/file_upload_presigned_urls`.
438+
439+
Args:
440+
files: A list of files to generate presigned URLs for.
441+
442+
extra_headers: Send extra headers
443+
444+
extra_query: Add additional query parameters to the request
445+
446+
extra_body: Add additional JSON properties to the request
447+
448+
timeout: Override the client-level default timeout for this request, in seconds
449+
"""
450+
return await self._post(
451+
"/v2/gen-ai/knowledge_bases/data_sources/file_upload_presigned_urls"
452+
if self._client._base_url_overridden
453+
else "https://api.digitalocean.com/v2/gen-ai/knowledge_bases/data_sources/file_upload_presigned_urls",
454+
body=await async_maybe_transform(
455+
{"files": files}, data_source_create_presigned_urls_params.DataSourceCreatePresignedURLsParams
456+
),
457+
options=make_request_options(
458+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
459+
),
460+
cast_to=DataSourceCreatePresignedURLsResponse,
461+
)
462+
381463

382464
class DataSourcesResourceWithRawResponse:
383465
def __init__(self, data_sources: DataSourcesResource) -> None:
@@ -392,6 +474,9 @@ def __init__(self, data_sources: DataSourcesResource) -> None:
392474
self.delete = to_raw_response_wrapper(
393475
data_sources.delete,
394476
)
477+
self.create_presigned_urls = to_raw_response_wrapper(
478+
data_sources.create_presigned_urls,
479+
)
395480

396481

397482
class AsyncDataSourcesResourceWithRawResponse:
@@ -407,6 +492,9 @@ def __init__(self, data_sources: AsyncDataSourcesResource) -> None:
407492
self.delete = async_to_raw_response_wrapper(
408493
data_sources.delete,
409494
)
495+
self.create_presigned_urls = async_to_raw_response_wrapper(
496+
data_sources.create_presigned_urls,
497+
)
410498

411499

412500
class DataSourcesResourceWithStreamingResponse:
@@ -422,6 +510,9 @@ def __init__(self, data_sources: DataSourcesResource) -> None:
422510
self.delete = to_streamed_response_wrapper(
423511
data_sources.delete,
424512
)
513+
self.create_presigned_urls = to_streamed_response_wrapper(
514+
data_sources.create_presigned_urls,
515+
)
425516

426517

427518
class AsyncDataSourcesResourceWithStreamingResponse:
@@ -437,3 +528,6 @@ def __init__(self, data_sources: AsyncDataSourcesResource) -> None:
437528
self.delete = async_to_streamed_response_wrapper(
438529
data_sources.delete,
439530
)
531+
self.create_presigned_urls = async_to_streamed_response_wrapper(
532+
data_sources.create_presigned_urls,
533+
)

src/gradient/types/knowledge_bases/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
from .api_web_crawler_data_source_param import APIWebCrawlerDataSourceParam as APIWebCrawlerDataSourceParam
2525
from .indexing_job_update_cancel_params import IndexingJobUpdateCancelParams as IndexingJobUpdateCancelParams
2626
from .indexing_job_update_cancel_response import IndexingJobUpdateCancelResponse as IndexingJobUpdateCancelResponse
27+
from .data_source_create_presigned_urls_params import (
28+
DataSourceCreatePresignedURLsParams as DataSourceCreatePresignedURLsParams,
29+
)
30+
from .data_source_create_presigned_urls_response import (
31+
DataSourceCreatePresignedURLsResponse as DataSourceCreatePresignedURLsResponse,
32+
)
2733
from .indexing_job_retrieve_data_sources_response import (
2834
IndexingJobRetrieveDataSourcesResponse as IndexingJobRetrieveDataSourcesResponse,
2935
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Iterable
6+
from typing_extensions import TypedDict
7+
8+
__all__ = ["DataSourceCreatePresignedURLsParams", "File"]
9+
10+
11+
class DataSourceCreatePresignedURLsParams(TypedDict, total=False):
12+
files: Iterable[File]
13+
"""A list of files to generate presigned URLs for."""
14+
15+
16+
class File(TypedDict, total=False):
17+
file_name: str
18+
"""Local filename"""
19+
20+
file_size: str
21+
"""The size of the file in bytes."""
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Optional
4+
from datetime import datetime
5+
6+
from ..._models import BaseModel
7+
8+
__all__ = ["DataSourceCreatePresignedURLsResponse", "Upload"]
9+
10+
11+
class Upload(BaseModel):
12+
expires_at: Optional[datetime] = None
13+
"""The time the url expires at."""
14+
15+
object_key: Optional[str] = None
16+
"""The unique object key to store the file as."""
17+
18+
original_file_name: Optional[str] = None
19+
"""The original file name."""
20+
21+
presigned_url: Optional[str] = None
22+
"""The actual presigned URL the client can use to upload the file directly."""
23+
24+
25+
class DataSourceCreatePresignedURLsResponse(BaseModel):
26+
request_id: Optional[str] = None
27+
"""The ID generated for the request for Presigned URLs."""
28+
29+
uploads: Optional[List[Upload]] = None
30+
"""A list of generated presigned URLs and object keys, one per file."""

tests/api_resources/knowledge_bases/test_data_sources.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
DataSourceListResponse,
1414
DataSourceCreateResponse,
1515
DataSourceDeleteResponse,
16+
DataSourceCreatePresignedURLsResponse,
1617
)
1718

1819
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -195,6 +196,47 @@ def test_path_params_delete(self, client: Gradient) -> None:
195196
knowledge_base_uuid='"123e4567-e89b-12d3-a456-426614174000"',
196197
)
197198

199+
@pytest.mark.skip(reason="Prism tests are disabled")
200+
@parametrize
201+
def test_method_create_presigned_urls(self, client: Gradient) -> None:
202+
data_source = client.knowledge_bases.data_sources.create_presigned_urls()
203+
assert_matches_type(DataSourceCreatePresignedURLsResponse, data_source, path=["response"])
204+
205+
@pytest.mark.skip(reason="Prism tests are disabled")
206+
@parametrize
207+
def test_method_create_presigned_urls_with_all_params(self, client: Gradient) -> None:
208+
data_source = client.knowledge_bases.data_sources.create_presigned_urls(
209+
files=[
210+
{
211+
"file_name": "example name",
212+
"file_size": "file_size",
213+
}
214+
],
215+
)
216+
assert_matches_type(DataSourceCreatePresignedURLsResponse, data_source, path=["response"])
217+
218+
@pytest.mark.skip(reason="Prism tests are disabled")
219+
@parametrize
220+
def test_raw_response_create_presigned_urls(self, client: Gradient) -> None:
221+
response = client.knowledge_bases.data_sources.with_raw_response.create_presigned_urls()
222+
223+
assert response.is_closed is True
224+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
225+
data_source = response.parse()
226+
assert_matches_type(DataSourceCreatePresignedURLsResponse, data_source, path=["response"])
227+
228+
@pytest.mark.skip(reason="Prism tests are disabled")
229+
@parametrize
230+
def test_streaming_response_create_presigned_urls(self, client: Gradient) -> None:
231+
with client.knowledge_bases.data_sources.with_streaming_response.create_presigned_urls() as response:
232+
assert not response.is_closed
233+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
234+
235+
data_source = response.parse()
236+
assert_matches_type(DataSourceCreatePresignedURLsResponse, data_source, path=["response"])
237+
238+
assert cast(Any, response.is_closed) is True
239+
198240

199241
class TestAsyncDataSources:
200242
parametrize = pytest.mark.parametrize(
@@ -374,3 +416,46 @@ async def test_path_params_delete(self, async_client: AsyncGradient) -> None:
374416
data_source_uuid="",
375417
knowledge_base_uuid='"123e4567-e89b-12d3-a456-426614174000"',
376418
)
419+
420+
@pytest.mark.skip(reason="Prism tests are disabled")
421+
@parametrize
422+
async def test_method_create_presigned_urls(self, async_client: AsyncGradient) -> None:
423+
data_source = await async_client.knowledge_bases.data_sources.create_presigned_urls()
424+
assert_matches_type(DataSourceCreatePresignedURLsResponse, data_source, path=["response"])
425+
426+
@pytest.mark.skip(reason="Prism tests are disabled")
427+
@parametrize
428+
async def test_method_create_presigned_urls_with_all_params(self, async_client: AsyncGradient) -> None:
429+
data_source = await async_client.knowledge_bases.data_sources.create_presigned_urls(
430+
files=[
431+
{
432+
"file_name": "example name",
433+
"file_size": "file_size",
434+
}
435+
],
436+
)
437+
assert_matches_type(DataSourceCreatePresignedURLsResponse, data_source, path=["response"])
438+
439+
@pytest.mark.skip(reason="Prism tests are disabled")
440+
@parametrize
441+
async def test_raw_response_create_presigned_urls(self, async_client: AsyncGradient) -> None:
442+
response = await async_client.knowledge_bases.data_sources.with_raw_response.create_presigned_urls()
443+
444+
assert response.is_closed is True
445+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
446+
data_source = await response.parse()
447+
assert_matches_type(DataSourceCreatePresignedURLsResponse, data_source, path=["response"])
448+
449+
@pytest.mark.skip(reason="Prism tests are disabled")
450+
@parametrize
451+
async def test_streaming_response_create_presigned_urls(self, async_client: AsyncGradient) -> None:
452+
async with (
453+
async_client.knowledge_bases.data_sources.with_streaming_response.create_presigned_urls()
454+
) as response:
455+
assert not response.is_closed
456+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
457+
458+
data_source = await response.parse()
459+
assert_matches_type(DataSourceCreatePresignedURLsResponse, data_source, path=["response"])
460+
461+
assert cast(Any, response.is_closed) is True

0 commit comments

Comments
 (0)