redpine-sdk 0.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. redpine_sdk-0.1.5/PKG-INFO +47 -0
  2. redpine_sdk-0.1.5/README.md +18 -0
  3. redpine_sdk-0.1.5/openapi-python-client.yaml +2 -0
  4. redpine_sdk-0.1.5/pyproject.toml +58 -0
  5. redpine_sdk-0.1.5/src/redpine/__init__.py +33 -0
  6. redpine_sdk-0.1.5/src/redpine/_generated/__init__.py +8 -0
  7. redpine_sdk-0.1.5/src/redpine/_generated/api/__init__.py +1 -0
  8. redpine_sdk-0.1.5/src/redpine/_generated/api/search/__init__.py +1 -0
  9. redpine_sdk-0.1.5/src/redpine/_generated/api/search/get_cached_result.py +199 -0
  10. redpine_sdk-0.1.5/src/redpine/_generated/api/search/get_quota.py +142 -0
  11. redpine_sdk-0.1.5/src/redpine/_generated/api/search/list_collections.py +152 -0
  12. redpine_sdk-0.1.5/src/redpine/_generated/api/search/search_assisted.py +222 -0
  13. redpine_sdk-0.1.5/src/redpine/_generated/api/search/search_collection.py +231 -0
  14. redpine_sdk-0.1.5/src/redpine/_generated/api/search/search_preview.py +235 -0
  15. redpine_sdk-0.1.5/src/redpine/_generated/api/search/search_query.py +215 -0
  16. redpine_sdk-0.1.5/src/redpine/_generated/api/search/search_unlock.py +212 -0
  17. redpine_sdk-0.1.5/src/redpine/_generated/client.py +272 -0
  18. redpine_sdk-0.1.5/src/redpine/_generated/errors.py +16 -0
  19. redpine_sdk-0.1.5/src/redpine/_generated/models/__init__.py +69 -0
  20. redpine_sdk-0.1.5/src/redpine/_generated/models/assisted_billing_info.py +71 -0
  21. redpine_sdk-0.1.5/src/redpine/_generated/models/assisted_search_request.py +226 -0
  22. redpine_sdk-0.1.5/src/redpine/_generated/models/assisted_search_request_filters_type_0.py +48 -0
  23. redpine_sdk-0.1.5/src/redpine/_generated/models/assisted_search_response.py +265 -0
  24. redpine_sdk-0.1.5/src/redpine/_generated/models/assisted_search_response_status.py +10 -0
  25. redpine_sdk-0.1.5/src/redpine/_generated/models/assisted_search_result.py +187 -0
  26. redpine_sdk-0.1.5/src/redpine/_generated/models/assisted_search_result_metadata_type_0.py +48 -0
  27. redpine_sdk-0.1.5/src/redpine/_generated/models/clarification_info.py +73 -0
  28. redpine_sdk-0.1.5/src/redpine/_generated/models/collections_response.py +86 -0
  29. redpine_sdk-0.1.5/src/redpine/_generated/models/collections_response_collections_item.py +70 -0
  30. redpine_sdk-0.1.5/src/redpine/_generated/models/error.py +68 -0
  31. redpine_sdk-0.1.5/src/redpine/_generated/models/error_error.py +81 -0
  32. redpine_sdk-0.1.5/src/redpine/_generated/models/filter_warning.py +78 -0
  33. redpine_sdk-0.1.5/src/redpine/_generated/models/journal_metric_expansion.py +99 -0
  34. redpine_sdk-0.1.5/src/redpine/_generated/models/preview_result.py +182 -0
  35. redpine_sdk-0.1.5/src/redpine/_generated/models/preview_result_metadata_type_0.py +51 -0
  36. redpine_sdk-0.1.5/src/redpine/_generated/models/preview_unlock_response.py +213 -0
  37. redpine_sdk-0.1.5/src/redpine/_generated/models/query_understanding.py +111 -0
  38. redpine_sdk-0.1.5/src/redpine/_generated/models/query_understanding_filters.py +52 -0
  39. redpine_sdk-0.1.5/src/redpine/_generated/models/quota_info.py +102 -0
  40. redpine_sdk-0.1.5/src/redpine/_generated/models/relevance_info.py +85 -0
  41. redpine_sdk-0.1.5/src/redpine/_generated/models/search_collection_body.py +165 -0
  42. redpine_sdk-0.1.5/src/redpine/_generated/models/search_collection_body_filters_type_0.py +74 -0
  43. redpine_sdk-0.1.5/src/redpine/_generated/models/search_preview_request.py +192 -0
  44. redpine_sdk-0.1.5/src/redpine/_generated/models/search_preview_request_filters_type_0.py +74 -0
  45. redpine_sdk-0.1.5/src/redpine/_generated/models/search_request.py +236 -0
  46. redpine_sdk-0.1.5/src/redpine/_generated/models/search_request_filters_type_0.py +74 -0
  47. redpine_sdk-0.1.5/src/redpine/_generated/models/search_response.py +190 -0
  48. redpine_sdk-0.1.5/src/redpine/_generated/models/search_result.py +132 -0
  49. redpine_sdk-0.1.5/src/redpine/_generated/models/search_result_metadata_type_0.py +48 -0
  50. redpine_sdk-0.1.5/src/redpine/_generated/models/search_results_preview_response.py +189 -0
  51. redpine_sdk-0.1.5/src/redpine/_generated/models/unlock_request.py +96 -0
  52. redpine_sdk-0.1.5/src/redpine/_generated/types.py +54 -0
  53. redpine_sdk-0.1.5/src/redpine/_retry.py +28 -0
  54. redpine_sdk-0.1.5/src/redpine/client.py +423 -0
  55. redpine_sdk-0.1.5/src/redpine/errors.py +131 -0
  56. redpine_sdk-0.1.5/src/redpine/filters.py +101 -0
  57. redpine_sdk-0.1.5/src/redpine/py.typed +0 -0
  58. redpine_sdk-0.1.5/tests/smoke/test_smoke.py +20 -0
  59. redpine_sdk-0.1.5/tests/test_client.py +274 -0
  60. redpine_sdk-0.1.5/tests/test_client_async.py +45 -0
  61. redpine_sdk-0.1.5/tests/test_contract.py +65 -0
  62. redpine_sdk-0.1.5/tests/test_errors.py +73 -0
  63. redpine_sdk-0.1.5/tests/test_filters.py +84 -0
  64. redpine_sdk-0.1.5/tests/test_retry.py +36 -0
  65. redpine_sdk-0.1.5/uv.lock +747 -0
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.5
2
+ Name: redpine-sdk
3
+ Version: 0.1.5
4
+ Summary: Python client for the Redpine search API
5
+ Project-URL: Homepage, https://redpine.ai
6
+ Project-URL: Documentation, https://docs.redpine.ai/docs/sdks
7
+ Project-URL: Repository, https://github.com/redpine-ai/redpine-sdk-python
8
+ License: MIT
9
+ Keywords: rag,redpine,retrieval,scientific-literature,search
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: attrs>=23.1
25
+ Requires-Dist: httpx>=0.27
26
+ Requires-Dist: python-dateutil>=2.8
27
+ Requires-Dist: typing-extensions>=4.12
28
+ Description-Content-Type: text/markdown
29
+
30
+ # redpine-sdk
31
+
32
+ Python client for the Redpine search API. Python 3.10+, sync and async.
33
+
34
+ ```bash
35
+ pip install redpine-sdk
36
+ ```
37
+
38
+ ```python
39
+ from redpine import Redpine, F
40
+
41
+ client = Redpine() # reads REDPINE_API_KEY
42
+ r = client.search("crispr delivery", collections=["corpus"], filters=F("issn").eq("1664-302X"))
43
+ for hit in r.results:
44
+ print(hit.id, hit.text[:80])
45
+ ```
46
+
47
+ Docs: https://docs.redpine.ai/docs/sdks
@@ -0,0 +1,18 @@
1
+ # redpine-sdk
2
+
3
+ Python client for the Redpine search API. Python 3.10+, sync and async.
4
+
5
+ ```bash
6
+ pip install redpine-sdk
7
+ ```
8
+
9
+ ```python
10
+ from redpine import Redpine, F
11
+
12
+ client = Redpine() # reads REDPINE_API_KEY
13
+ r = client.search("crispr delivery", collections=["corpus"], filters=F("issn").eq("1664-302X"))
14
+ for hit in r.results:
15
+ print(hit.id, hit.text[:80])
16
+ ```
17
+
18
+ Docs: https://docs.redpine.ai/docs/sdks
@@ -0,0 +1,2 @@
1
+ package_name_override: _generated
2
+ project_name_override: redpine-generated
@@ -0,0 +1,58 @@
1
+ [project]
2
+ name = "redpine-sdk"
3
+ version = "0.1.5"
4
+ description = "Python client for the Redpine search API"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = {text = "MIT"}
8
+ keywords = ["redpine", "search", "retrieval", "scientific-literature", "rag"]
9
+ classifiers = [
10
+ "Development Status :: 4 - Beta",
11
+ "Intended Audience :: Developers",
12
+ "Intended Audience :: Science/Research",
13
+ "License :: OSI Approved :: MIT License",
14
+ "Operating System :: OS Independent",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Topic :: Scientific/Engineering",
21
+ "Topic :: Software Development :: Libraries :: Python Modules",
22
+ "Typing :: Typed",
23
+ ]
24
+ dependencies = [
25
+ "httpx>=0.27",
26
+ "attrs>=23.1",
27
+ "python-dateutil>=2.8",
28
+ "typing-extensions>=4.12",
29
+ ]
30
+
31
+ [project.urls]
32
+ Homepage = "https://redpine.ai"
33
+ Documentation = "https://docs.redpine.ai/docs/sdks"
34
+ Repository = "https://github.com/redpine-ai/redpine-sdk-python"
35
+
36
+ [dependency-groups]
37
+ dev = [
38
+ "pytest>=8",
39
+ "pytest-asyncio>=0.23",
40
+ "respx>=0.21",
41
+ "openapi-python-client>=0.21",
42
+ "ruff>=0.5",
43
+ ]
44
+
45
+ [build-system]
46
+ requires = ["hatchling"]
47
+ build-backend = "hatchling.build"
48
+
49
+ [tool.hatch.build.targets.wheel]
50
+ packages = ["src/redpine"]
51
+
52
+ [tool.pytest.ini_options]
53
+ asyncio_mode = "auto"
54
+ testpaths = ["tests"]
55
+
56
+ [tool.ruff]
57
+ line-length = 100
58
+ extend-exclude = ["src/redpine/_generated"]
@@ -0,0 +1,33 @@
1
+ """Redpine SDK — Python client for the Redpine search API."""
2
+
3
+ from .client import AsyncRedpine, Redpine
4
+ from .errors import (
5
+ AccessDenied,
6
+ AssistedUnavailable,
7
+ AuthError,
8
+ Expired,
9
+ InsufficientCredits,
10
+ NotFound,
11
+ QuotaExceeded,
12
+ RedpineError,
13
+ ValidationError,
14
+ )
15
+ from .filters import F, Field, Filter
16
+
17
+ __version__ = "0.1.5"
18
+ __all__ = [
19
+ "AccessDenied",
20
+ "AssistedUnavailable",
21
+ "AsyncRedpine",
22
+ "AuthError",
23
+ "Expired",
24
+ "F",
25
+ "Field",
26
+ "Filter",
27
+ "InsufficientCredits",
28
+ "NotFound",
29
+ "QuotaExceeded",
30
+ "Redpine",
31
+ "RedpineError",
32
+ "ValidationError",
33
+ ]
@@ -0,0 +1,8 @@
1
+ """A client library for accessing Redpine Connect Search API"""
2
+
3
+ from .client import AuthenticatedClient, Client
4
+
5
+ __all__ = (
6
+ "AuthenticatedClient",
7
+ "Client",
8
+ )
@@ -0,0 +1 @@
1
+ """Contains methods for accessing the API"""
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,199 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.error import Error
10
+ from ...models.search_results_preview_response import SearchResultsPreviewResponse
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ query_id: str,
16
+ ) -> dict[str, Any]:
17
+
18
+ _kwargs: dict[str, Any] = {
19
+ "method": "get",
20
+ "url": "/api/v1/search/results/{query_id}".format(
21
+ query_id=quote(str(query_id), safe=""),
22
+ ),
23
+ }
24
+
25
+ return _kwargs
26
+
27
+
28
+ def _parse_response(
29
+ *, client: AuthenticatedClient | Client, response: httpx.Response
30
+ ) -> Error | SearchResultsPreviewResponse | None:
31
+ if response.status_code == 200:
32
+ response_200 = SearchResultsPreviewResponse.from_dict(response.json())
33
+
34
+ return response_200
35
+
36
+ if response.status_code == 401:
37
+ response_401 = Error.from_dict(response.json())
38
+
39
+ return response_401
40
+
41
+ if response.status_code == 404:
42
+ response_404 = Error.from_dict(response.json())
43
+
44
+ return response_404
45
+
46
+ if response.status_code == 410:
47
+ response_410 = Error.from_dict(response.json())
48
+
49
+ return response_410
50
+
51
+ if client.raise_on_unexpected_status:
52
+ raise errors.UnexpectedStatus(response.status_code, response.content)
53
+ else:
54
+ return None
55
+
56
+
57
+ def _build_response(
58
+ *, client: AuthenticatedClient | Client, response: httpx.Response
59
+ ) -> Response[Error | SearchResultsPreviewResponse]:
60
+ return Response(
61
+ status_code=HTTPStatus(response.status_code),
62
+ content=response.content,
63
+ headers=response.headers,
64
+ parsed=_parse_response(client=client, response=response),
65
+ )
66
+
67
+
68
+ def sync_detailed(
69
+ query_id: str,
70
+ *,
71
+ client: AuthenticatedClient | Client,
72
+ ) -> Response[Error | SearchResultsPreviewResponse]:
73
+ """Re-fetch cached results
74
+
75
+ Retrieve previously returned search results using the queryId from a prior search response. Returns
76
+ the same results without billing. The request must use the same API key that performed the original
77
+ search. Results are available for 7 days.
78
+
79
+ Each result carries `locked`/`tokens`/`cost`: a result not yet paid for through POST
80
+ /api/v1/search/unlock comes back as a teaser (`locked: true`), never the full text.
81
+
82
+ Args:
83
+ query_id (str):
84
+
85
+ Raises:
86
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
87
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
88
+
89
+ Returns:
90
+ Response[Error | SearchResultsPreviewResponse]
91
+ """
92
+
93
+ kwargs = _get_kwargs(
94
+ query_id=query_id,
95
+ )
96
+
97
+ response = client.get_httpx_client().request(
98
+ **kwargs,
99
+ )
100
+
101
+ return _build_response(client=client, response=response)
102
+
103
+
104
+ def sync(
105
+ query_id: str,
106
+ *,
107
+ client: AuthenticatedClient | Client,
108
+ ) -> Error | SearchResultsPreviewResponse | None:
109
+ """Re-fetch cached results
110
+
111
+ Retrieve previously returned search results using the queryId from a prior search response. Returns
112
+ the same results without billing. The request must use the same API key that performed the original
113
+ search. Results are available for 7 days.
114
+
115
+ Each result carries `locked`/`tokens`/`cost`: a result not yet paid for through POST
116
+ /api/v1/search/unlock comes back as a teaser (`locked: true`), never the full text.
117
+
118
+ Args:
119
+ query_id (str):
120
+
121
+ Raises:
122
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
123
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
124
+
125
+ Returns:
126
+ Error | SearchResultsPreviewResponse
127
+ """
128
+
129
+ return sync_detailed(
130
+ query_id=query_id,
131
+ client=client,
132
+ ).parsed
133
+
134
+
135
+ async def asyncio_detailed(
136
+ query_id: str,
137
+ *,
138
+ client: AuthenticatedClient | Client,
139
+ ) -> Response[Error | SearchResultsPreviewResponse]:
140
+ """Re-fetch cached results
141
+
142
+ Retrieve previously returned search results using the queryId from a prior search response. Returns
143
+ the same results without billing. The request must use the same API key that performed the original
144
+ search. Results are available for 7 days.
145
+
146
+ Each result carries `locked`/`tokens`/`cost`: a result not yet paid for through POST
147
+ /api/v1/search/unlock comes back as a teaser (`locked: true`), never the full text.
148
+
149
+ Args:
150
+ query_id (str):
151
+
152
+ Raises:
153
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
154
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
155
+
156
+ Returns:
157
+ Response[Error | SearchResultsPreviewResponse]
158
+ """
159
+
160
+ kwargs = _get_kwargs(
161
+ query_id=query_id,
162
+ )
163
+
164
+ response = await client.get_async_httpx_client().request(**kwargs)
165
+
166
+ return _build_response(client=client, response=response)
167
+
168
+
169
+ async def asyncio(
170
+ query_id: str,
171
+ *,
172
+ client: AuthenticatedClient | Client,
173
+ ) -> Error | SearchResultsPreviewResponse | None:
174
+ """Re-fetch cached results
175
+
176
+ Retrieve previously returned search results using the queryId from a prior search response. Returns
177
+ the same results without billing. The request must use the same API key that performed the original
178
+ search. Results are available for 7 days.
179
+
180
+ Each result carries `locked`/`tokens`/`cost`: a result not yet paid for through POST
181
+ /api/v1/search/unlock comes back as a teaser (`locked: true`), never the full text.
182
+
183
+ Args:
184
+ query_id (str):
185
+
186
+ Raises:
187
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
188
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
189
+
190
+ Returns:
191
+ Error | SearchResultsPreviewResponse
192
+ """
193
+
194
+ return (
195
+ await asyncio_detailed(
196
+ query_id=query_id,
197
+ client=client,
198
+ )
199
+ ).parsed
@@ -0,0 +1,142 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.error import Error
9
+ from ...models.quota_info import QuotaInfo
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs() -> dict[str, Any]:
14
+
15
+ _kwargs: dict[str, Any] = {
16
+ "method": "get",
17
+ "url": "/api/v1/search/quota",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(
24
+ *, client: AuthenticatedClient | Client, response: httpx.Response
25
+ ) -> Error | QuotaInfo | None:
26
+ if response.status_code == 200:
27
+ response_200 = QuotaInfo.from_dict(response.json())
28
+
29
+ return response_200
30
+
31
+ if response.status_code == 401:
32
+ response_401 = Error.from_dict(response.json())
33
+
34
+ return response_401
35
+
36
+ if client.raise_on_unexpected_status:
37
+ raise errors.UnexpectedStatus(response.status_code, response.content)
38
+ else:
39
+ return None
40
+
41
+
42
+ def _build_response(
43
+ *, client: AuthenticatedClient | Client, response: httpx.Response
44
+ ) -> Response[Error | QuotaInfo]:
45
+ return Response(
46
+ status_code=HTTPStatus(response.status_code),
47
+ content=response.content,
48
+ headers=response.headers,
49
+ parsed=_parse_response(client=client, response=response),
50
+ )
51
+
52
+
53
+ def sync_detailed(
54
+ *,
55
+ client: AuthenticatedClient | Client,
56
+ ) -> Response[Error | QuotaInfo]:
57
+ """Current quota usage and limits
58
+
59
+ Daily and monthly query usage and limits for the authenticated organization.
60
+
61
+ Raises:
62
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
63
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
64
+
65
+ Returns:
66
+ Response[Error | QuotaInfo]
67
+ """
68
+
69
+ kwargs = _get_kwargs()
70
+
71
+ response = client.get_httpx_client().request(
72
+ **kwargs,
73
+ )
74
+
75
+ return _build_response(client=client, response=response)
76
+
77
+
78
+ def sync(
79
+ *,
80
+ client: AuthenticatedClient | Client,
81
+ ) -> Error | QuotaInfo | None:
82
+ """Current quota usage and limits
83
+
84
+ Daily and monthly query usage and limits for the authenticated organization.
85
+
86
+ Raises:
87
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
88
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
89
+
90
+ Returns:
91
+ Error | QuotaInfo
92
+ """
93
+
94
+ return sync_detailed(
95
+ client=client,
96
+ ).parsed
97
+
98
+
99
+ async def asyncio_detailed(
100
+ *,
101
+ client: AuthenticatedClient | Client,
102
+ ) -> Response[Error | QuotaInfo]:
103
+ """Current quota usage and limits
104
+
105
+ Daily and monthly query usage and limits for the authenticated organization.
106
+
107
+ Raises:
108
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
109
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
110
+
111
+ Returns:
112
+ Response[Error | QuotaInfo]
113
+ """
114
+
115
+ kwargs = _get_kwargs()
116
+
117
+ response = await client.get_async_httpx_client().request(**kwargs)
118
+
119
+ return _build_response(client=client, response=response)
120
+
121
+
122
+ async def asyncio(
123
+ *,
124
+ client: AuthenticatedClient | Client,
125
+ ) -> Error | QuotaInfo | None:
126
+ """Current quota usage and limits
127
+
128
+ Daily and monthly query usage and limits for the authenticated organization.
129
+
130
+ Raises:
131
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
132
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
133
+
134
+ Returns:
135
+ Error | QuotaInfo
136
+ """
137
+
138
+ return (
139
+ await asyncio_detailed(
140
+ client=client,
141
+ )
142
+ ).parsed
@@ -0,0 +1,152 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.collections_response import CollectionsResponse
9
+ from ...models.error import Error
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs() -> dict[str, Any]:
14
+
15
+ _kwargs: dict[str, Any] = {
16
+ "method": "get",
17
+ "url": "/api/v1/search/collections",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(
24
+ *, client: AuthenticatedClient | Client, response: httpx.Response
25
+ ) -> CollectionsResponse | Error | None:
26
+ if response.status_code == 200:
27
+ response_200 = CollectionsResponse.from_dict(response.json())
28
+
29
+ return response_200
30
+
31
+ if response.status_code == 401:
32
+ response_401 = Error.from_dict(response.json())
33
+
34
+ return response_401
35
+
36
+ if response.status_code == 403:
37
+ response_403 = Error.from_dict(response.json())
38
+
39
+ return response_403
40
+
41
+ if response.status_code == 429:
42
+ response_429 = Error.from_dict(response.json())
43
+
44
+ return response_429
45
+
46
+ if client.raise_on_unexpected_status:
47
+ raise errors.UnexpectedStatus(response.status_code, response.content)
48
+ else:
49
+ return None
50
+
51
+
52
+ def _build_response(
53
+ *, client: AuthenticatedClient | Client, response: httpx.Response
54
+ ) -> Response[CollectionsResponse | Error]:
55
+ return Response(
56
+ status_code=HTTPStatus(response.status_code),
57
+ content=response.content,
58
+ headers=response.headers,
59
+ parsed=_parse_response(client=client, response=response),
60
+ )
61
+
62
+
63
+ def sync_detailed(
64
+ *,
65
+ client: AuthenticatedClient | Client,
66
+ ) -> Response[CollectionsResponse | Error]:
67
+ """List collections
68
+
69
+ List all document collections accessible to the authenticated API key.
70
+
71
+ Raises:
72
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
73
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
74
+
75
+ Returns:
76
+ Response[CollectionsResponse | Error]
77
+ """
78
+
79
+ kwargs = _get_kwargs()
80
+
81
+ response = client.get_httpx_client().request(
82
+ **kwargs,
83
+ )
84
+
85
+ return _build_response(client=client, response=response)
86
+
87
+
88
+ def sync(
89
+ *,
90
+ client: AuthenticatedClient | Client,
91
+ ) -> CollectionsResponse | Error | None:
92
+ """List collections
93
+
94
+ List all document collections accessible to the authenticated API key.
95
+
96
+ Raises:
97
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
98
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
99
+
100
+ Returns:
101
+ CollectionsResponse | Error
102
+ """
103
+
104
+ return sync_detailed(
105
+ client=client,
106
+ ).parsed
107
+
108
+
109
+ async def asyncio_detailed(
110
+ *,
111
+ client: AuthenticatedClient | Client,
112
+ ) -> Response[CollectionsResponse | Error]:
113
+ """List collections
114
+
115
+ List all document collections accessible to the authenticated API key.
116
+
117
+ Raises:
118
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
119
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
120
+
121
+ Returns:
122
+ Response[CollectionsResponse | Error]
123
+ """
124
+
125
+ kwargs = _get_kwargs()
126
+
127
+ response = await client.get_async_httpx_client().request(**kwargs)
128
+
129
+ return _build_response(client=client, response=response)
130
+
131
+
132
+ async def asyncio(
133
+ *,
134
+ client: AuthenticatedClient | Client,
135
+ ) -> CollectionsResponse | Error | None:
136
+ """List collections
137
+
138
+ List all document collections accessible to the authenticated API key.
139
+
140
+ Raises:
141
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
142
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
143
+
144
+ Returns:
145
+ CollectionsResponse | Error
146
+ """
147
+
148
+ return (
149
+ await asyncio_detailed(
150
+ client=client,
151
+ )
152
+ ).parsed