Skip to content

Commit bccb2cc

Browse files
feat(api): api update
1 parent 5e2a523 commit bccb2cc

20 files changed

+106
-890
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 14
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-41cc2c9708dd44636519f09907b8945c8d7a8c0d2f9586f4ff6b54dc87529afd.yml
3-
openapi_spec_hash: 13e20d1a1759b5a513d2441732a0851e
1+
configured_endpoints: 10
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-3798b2043988c1dba908d62df73c76dc771f2cda8a401ca34960c3303cfceaa2.yml
3+
openapi_spec_hash: 1b2e464ea074f544ccd927283c992cef
44
config_hash: a39dfe90372d06d735dfb3d27b30409f

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ first_page = await client.documents.list(
143143

144144
print(f"next page cursor: {first_page.next_cursor}") # => "next page cursor: ..."
145145
for document in first_page.items:
146-
print(document.id)
146+
print(document.resource_id)
147147

148148
# Remove `await` for non-async usage.
149149
```
@@ -165,7 +165,7 @@ response = client.query.search(
165165
"after": datetime.fromisoformat("2019-12-27T18:11:19.117"),
166166
"before": datetime.fromisoformat("2019-12-27T18:11:19.117"),
167167
"box": {},
168-
"collections": {"collections": ["string"]},
168+
"collections": {},
169169
"google_calendar": {"calendar_id": "calendar_id"},
170170
"google_drive": {},
171171
"notion": {"notion_page_ids": ["string"]},
@@ -195,7 +195,6 @@ from hyperspell import Hyperspell
195195
client = Hyperspell()
196196

197197
client.documents.upload(
198-
collection="collection",
199198
file=Path("/path/to/file"),
200199
)
201200
```

api.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,26 @@ Methods:
3939
Types:
4040

4141
```python
42-
from hyperspell.types import Document, DocumentStatus, DocumentListResponse, DocumentGetResponse
42+
from hyperspell.types import DocumentStatus, DocumentListResponse
4343
```
4444

4545
Methods:
4646

4747
- <code title="get /documents/list">client.documents.<a href="./src/hyperspell/resources/documents.py">list</a>(\*\*<a href="src/hyperspell/types/document_list_params.py">params</a>) -> <a href="./src/hyperspell/types/document_list_response.py">SyncCursorPage[DocumentListResponse]</a></code>
4848
- <code title="post /documents/add">client.documents.<a href="./src/hyperspell/resources/documents.py">add</a>(\*\*<a href="src/hyperspell/types/document_add_params.py">params</a>) -> <a href="./src/hyperspell/types/document_status.py">DocumentStatus</a></code>
49-
- <code title="post /documents/scrape">client.documents.<a href="./src/hyperspell/resources/documents.py">add_url</a>(\*\*<a href="src/hyperspell/types/document_add_url_params.py">params</a>) -> <a href="./src/hyperspell/types/document_status.py">DocumentStatus</a></code>
50-
- <code title="get /documents/get/{document_id}">client.documents.<a href="./src/hyperspell/resources/documents.py">get</a>(document_id) -> <a href="./src/hyperspell/types/document_get_response.py">object</a></code>
5149
- <code title="post /documents/upload">client.documents.<a href="./src/hyperspell/resources/documents.py">upload</a>(\*\*<a href="src/hyperspell/types/document_upload_params.py">params</a>) -> <a href="./src/hyperspell/types/document_status.py">DocumentStatus</a></code>
5250

5351
# Collections
5452

5553
Types:
5654

5755
```python
58-
from hyperspell.types import Collection, CollectionListResponse
56+
from hyperspell.types import CollectionListResponse
5957
```
6058

6159
Methods:
6260

63-
- <code title="post /collections/add">client.collections.<a href="./src/hyperspell/resources/collections.py">create</a>(\*\*<a href="src/hyperspell/types/collection_create_params.py">params</a>) -> <a href="./src/hyperspell/types/collection.py">Collection</a></code>
6461
- <code title="get /collections/list">client.collections.<a href="./src/hyperspell/resources/collections.py">list</a>(\*\*<a href="src/hyperspell/types/collection_list_params.py">params</a>) -> <a href="./src/hyperspell/types/collection_list_response.py">SyncCursorPage[CollectionListResponse]</a></code>
65-
- <code title="get /collections/get/{name}">client.collections.<a href="./src/hyperspell/resources/collections.py">get</a>(name) -> <a href="./src/hyperspell/types/collection.py">Collection</a></code>
6662

6763
# Query
6864

src/hyperspell/resources/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def user_token(
7272
extra_body: Body | None = None,
7373
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
7474
) -> Token:
75-
"""Use this endpoing to create a user token for a specific user.
75+
"""Use this endpoint to create a user token for a specific user.
7676
7777
This token can be
7878
safely passed to your user-facing front-end.
@@ -146,7 +146,7 @@ async def user_token(
146146
extra_body: Body | None = None,
147147
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
148148
) -> Token:
149-
"""Use this endpoing to create a user token for a specific user.
149+
"""Use this endpoint to create a user token for a specific user.
150150
151151
This token can be
152152
safely passed to your user-facing front-end.

src/hyperspell/resources/collections.py

Lines changed: 10 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
import httpx
88

9-
from ..types import collection_list_params, collection_create_params
9+
from ..types import collection_list_params
1010
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11-
from .._utils import maybe_transform, async_maybe_transform
11+
from .._utils import maybe_transform
1212
from .._compat import cached_property
1313
from .._resource import SyncAPIResource, AsyncAPIResource
1414
from .._response import (
@@ -19,7 +19,6 @@
1919
)
2020
from ..pagination import SyncCursorPage, AsyncCursorPage
2121
from .._base_client import AsyncPaginator, make_request_options
22-
from ..types.collection import Collection
2322
from ..types.collection_list_response import CollectionListResponse
2423

2524
__all__ = ["CollectionsResource", "AsyncCollectionsResource"]
@@ -45,52 +44,6 @@ def with_streaming_response(self) -> CollectionsResourceWithStreamingResponse:
4544
"""
4645
return CollectionsResourceWithStreamingResponse(self)
4746

48-
def create(
49-
self,
50-
*,
51-
name: str,
52-
owner: Optional[str] | NotGiven = NOT_GIVEN,
53-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
54-
# The extra values given here take precedence over values defined on the client or passed to this method.
55-
extra_headers: Headers | None = None,
56-
extra_query: Query | None = None,
57-
extra_body: Body | None = None,
58-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
59-
) -> Collection:
60-
"""This endpoint allows you to paginate through all documents in the index.
61-
62-
You can
63-
filter the documents by title, date, metadata, etc.
64-
65-
Args:
66-
name: The name of the collection.
67-
68-
owner: The owner of the collection. If the request is made using a user token, this
69-
will be set to the user ID.
70-
71-
extra_headers: Send extra headers
72-
73-
extra_query: Add additional query parameters to the request
74-
75-
extra_body: Add additional JSON properties to the request
76-
77-
timeout: Override the client-level default timeout for this request, in seconds
78-
"""
79-
return self._post(
80-
"/collections/add",
81-
body=maybe_transform(
82-
{
83-
"name": name,
84-
"owner": owner,
85-
},
86-
collection_create_params.CollectionCreateParams,
87-
),
88-
options=make_request_options(
89-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
90-
),
91-
cast_to=Collection,
92-
)
93-
9447
def list(
9548
self,
9649
*,
@@ -103,8 +56,10 @@ def list(
10356
extra_body: Body | None = None,
10457
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
10558
) -> SyncCursorPage[CollectionListResponse]:
106-
"""
107-
Lists all collections the user has access to.
59+
"""This endpoint allows you to paginate through all documents in the index.
60+
61+
You can
62+
filter the documents by title, date, metadata, etc.
10863
10964
Args:
11065
extra_headers: Send extra headers
@@ -134,39 +89,6 @@ def list(
13489
model=CollectionListResponse,
13590
)
13691

137-
def get(
138-
self,
139-
name: str,
140-
*,
141-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
142-
# The extra values given here take precedence over values defined on the client or passed to this method.
143-
extra_headers: Headers | None = None,
144-
extra_query: Query | None = None,
145-
extra_body: Body | None = None,
146-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
147-
) -> Collection:
148-
"""
149-
Retrieves a collection by name.
150-
151-
Args:
152-
extra_headers: Send extra headers
153-
154-
extra_query: Add additional query parameters to the request
155-
156-
extra_body: Add additional JSON properties to the request
157-
158-
timeout: Override the client-level default timeout for this request, in seconds
159-
"""
160-
if not name:
161-
raise ValueError(f"Expected a non-empty value for `name` but received {name!r}")
162-
return self._get(
163-
f"/collections/get/{name}",
164-
options=make_request_options(
165-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
166-
),
167-
cast_to=Collection,
168-
)
169-
17092

17193
class AsyncCollectionsResource(AsyncAPIResource):
17294
@cached_property
@@ -188,52 +110,6 @@ def with_streaming_response(self) -> AsyncCollectionsResourceWithStreamingRespon
188110
"""
189111
return AsyncCollectionsResourceWithStreamingResponse(self)
190112

191-
async def create(
192-
self,
193-
*,
194-
name: str,
195-
owner: Optional[str] | NotGiven = NOT_GIVEN,
196-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
197-
# The extra values given here take precedence over values defined on the client or passed to this method.
198-
extra_headers: Headers | None = None,
199-
extra_query: Query | None = None,
200-
extra_body: Body | None = None,
201-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
202-
) -> Collection:
203-
"""This endpoint allows you to paginate through all documents in the index.
204-
205-
You can
206-
filter the documents by title, date, metadata, etc.
207-
208-
Args:
209-
name: The name of the collection.
210-
211-
owner: The owner of the collection. If the request is made using a user token, this
212-
will be set to the user ID.
213-
214-
extra_headers: Send extra headers
215-
216-
extra_query: Add additional query parameters to the request
217-
218-
extra_body: Add additional JSON properties to the request
219-
220-
timeout: Override the client-level default timeout for this request, in seconds
221-
"""
222-
return await self._post(
223-
"/collections/add",
224-
body=await async_maybe_transform(
225-
{
226-
"name": name,
227-
"owner": owner,
228-
},
229-
collection_create_params.CollectionCreateParams,
230-
),
231-
options=make_request_options(
232-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
233-
),
234-
cast_to=Collection,
235-
)
236-
237113
def list(
238114
self,
239115
*,
@@ -246,8 +122,10 @@ def list(
246122
extra_body: Body | None = None,
247123
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
248124
) -> AsyncPaginator[CollectionListResponse, AsyncCursorPage[CollectionListResponse]]:
249-
"""
250-
Lists all collections the user has access to.
125+
"""This endpoint allows you to paginate through all documents in the index.
126+
127+
You can
128+
filter the documents by title, date, metadata, etc.
251129
252130
Args:
253131
extra_headers: Send extra headers
@@ -277,95 +155,38 @@ def list(
277155
model=CollectionListResponse,
278156
)
279157

280-
async def get(
281-
self,
282-
name: str,
283-
*,
284-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
285-
# The extra values given here take precedence over values defined on the client or passed to this method.
286-
extra_headers: Headers | None = None,
287-
extra_query: Query | None = None,
288-
extra_body: Body | None = None,
289-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
290-
) -> Collection:
291-
"""
292-
Retrieves a collection by name.
293-
294-
Args:
295-
extra_headers: Send extra headers
296-
297-
extra_query: Add additional query parameters to the request
298-
299-
extra_body: Add additional JSON properties to the request
300-
301-
timeout: Override the client-level default timeout for this request, in seconds
302-
"""
303-
if not name:
304-
raise ValueError(f"Expected a non-empty value for `name` but received {name!r}")
305-
return await self._get(
306-
f"/collections/get/{name}",
307-
options=make_request_options(
308-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
309-
),
310-
cast_to=Collection,
311-
)
312-
313158

314159
class CollectionsResourceWithRawResponse:
315160
def __init__(self, collections: CollectionsResource) -> None:
316161
self._collections = collections
317162

318-
self.create = to_raw_response_wrapper(
319-
collections.create,
320-
)
321163
self.list = to_raw_response_wrapper(
322164
collections.list,
323165
)
324-
self.get = to_raw_response_wrapper(
325-
collections.get,
326-
)
327166

328167

329168
class AsyncCollectionsResourceWithRawResponse:
330169
def __init__(self, collections: AsyncCollectionsResource) -> None:
331170
self._collections = collections
332171

333-
self.create = async_to_raw_response_wrapper(
334-
collections.create,
335-
)
336172
self.list = async_to_raw_response_wrapper(
337173
collections.list,
338174
)
339-
self.get = async_to_raw_response_wrapper(
340-
collections.get,
341-
)
342175

343176

344177
class CollectionsResourceWithStreamingResponse:
345178
def __init__(self, collections: CollectionsResource) -> None:
346179
self._collections = collections
347180

348-
self.create = to_streamed_response_wrapper(
349-
collections.create,
350-
)
351181
self.list = to_streamed_response_wrapper(
352182
collections.list,
353183
)
354-
self.get = to_streamed_response_wrapper(
355-
collections.get,
356-
)
357184

358185

359186
class AsyncCollectionsResourceWithStreamingResponse:
360187
def __init__(self, collections: AsyncCollectionsResource) -> None:
361188
self._collections = collections
362189

363-
self.create = async_to_streamed_response_wrapper(
364-
collections.create,
365-
)
366190
self.list = async_to_streamed_response_wrapper(
367191
collections.list,
368192
)
369-
self.get = async_to_streamed_response_wrapper(
370-
collections.get,
371-
)

0 commit comments

Comments
 (0)