hubmap-search-sdk 1.0.0a1__py3-none-any.whl

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 (54) hide show
  1. hubmap_search_sdk/__init__.py +94 -0
  2. hubmap_search_sdk/_base_client.py +1969 -0
  3. hubmap_search_sdk/_client.py +464 -0
  4. hubmap_search_sdk/_compat.py +219 -0
  5. hubmap_search_sdk/_constants.py +14 -0
  6. hubmap_search_sdk/_exceptions.py +108 -0
  7. hubmap_search_sdk/_files.py +123 -0
  8. hubmap_search_sdk/_models.py +804 -0
  9. hubmap_search_sdk/_qs.py +150 -0
  10. hubmap_search_sdk/_resource.py +43 -0
  11. hubmap_search_sdk/_response.py +832 -0
  12. hubmap_search_sdk/_streaming.py +333 -0
  13. hubmap_search_sdk/_types.py +217 -0
  14. hubmap_search_sdk/_utils/__init__.py +57 -0
  15. hubmap_search_sdk/_utils/_logs.py +25 -0
  16. hubmap_search_sdk/_utils/_proxy.py +62 -0
  17. hubmap_search_sdk/_utils/_reflection.py +42 -0
  18. hubmap_search_sdk/_utils/_streams.py +12 -0
  19. hubmap_search_sdk/_utils/_sync.py +86 -0
  20. hubmap_search_sdk/_utils/_transform.py +402 -0
  21. hubmap_search_sdk/_utils/_typing.py +149 -0
  22. hubmap_search_sdk/_utils/_utils.py +414 -0
  23. hubmap_search_sdk/_version.py +4 -0
  24. hubmap_search_sdk/lib/.keep +4 -0
  25. hubmap_search_sdk/py.typed +0 -0
  26. hubmap_search_sdk/resources/__init__.py +145 -0
  27. hubmap_search_sdk/resources/add.py +367 -0
  28. hubmap_search_sdk/resources/clear_docs.py +342 -0
  29. hubmap_search_sdk/resources/indices.py +145 -0
  30. hubmap_search_sdk/resources/mapping.py +212 -0
  31. hubmap_search_sdk/resources/mget.py +265 -0
  32. hubmap_search_sdk/resources/param_search.py +197 -0
  33. hubmap_search_sdk/resources/reindex.py +164 -0
  34. hubmap_search_sdk/resources/scroll_search.py +181 -0
  35. hubmap_search_sdk/resources/search.py +313 -0
  36. hubmap_search_sdk/resources/update.py +367 -0
  37. hubmap_search_sdk/types/__init__.py +23 -0
  38. hubmap_search_sdk/types/add_create_document_params.py +11 -0
  39. hubmap_search_sdk/types/add_create_document_with_index_params.py +13 -0
  40. hubmap_search_sdk/types/add_update_document_with_scope_params.py +15 -0
  41. hubmap_search_sdk/types/index_list_response.py +11 -0
  42. hubmap_search_sdk/types/mget_retrieve_multiple_by_index_params.py +11 -0
  43. hubmap_search_sdk/types/mget_retrieve_multiple_params.py +11 -0
  44. hubmap_search_sdk/types/param_search_execute_params.py +18 -0
  45. hubmap_search_sdk/types/scroll_search_create_params.py +11 -0
  46. hubmap_search_sdk/types/search_execute_index_query_params.py +20 -0
  47. hubmap_search_sdk/types/search_execute_query_params.py +20 -0
  48. hubmap_search_sdk/types/update_update_document_at_index_params.py +13 -0
  49. hubmap_search_sdk/types/update_update_document_params.py +11 -0
  50. hubmap_search_sdk/types/update_update_document_with_scope_params.py +15 -0
  51. hubmap_search_sdk-1.0.0a1.dist-info/METADATA +355 -0
  52. hubmap_search_sdk-1.0.0a1.dist-info/RECORD +54 -0
  53. hubmap_search_sdk-1.0.0a1.dist-info/WHEEL +4 -0
  54. hubmap_search_sdk-1.0.0a1.dist-info/licenses/LICENSE +7 -0
@@ -0,0 +1,181 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import httpx
6
+
7
+ from ..types import scroll_search_create_params
8
+ from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
9
+ from .._utils import (
10
+ maybe_transform,
11
+ async_maybe_transform,
12
+ )
13
+ from .._compat import cached_property
14
+ from .._resource import SyncAPIResource, AsyncAPIResource
15
+ from .._response import (
16
+ to_raw_response_wrapper,
17
+ to_streamed_response_wrapper,
18
+ async_to_raw_response_wrapper,
19
+ async_to_streamed_response_wrapper,
20
+ )
21
+ from .._base_client import make_request_options
22
+
23
+ __all__ = ["ScrollSearchResource", "AsyncScrollSearchResource"]
24
+
25
+
26
+ class ScrollSearchResource(SyncAPIResource):
27
+ @cached_property
28
+ def with_raw_response(self) -> ScrollSearchResourceWithRawResponse:
29
+ """
30
+ This property can be used as a prefix for any HTTP method call to return
31
+ the raw response object instead of the parsed content.
32
+
33
+ For more information, see https://www.github.com/hubmapconsortium/search-python-sdk#accessing-raw-response-data-eg-headers
34
+ """
35
+ return ScrollSearchResourceWithRawResponse(self)
36
+
37
+ @cached_property
38
+ def with_streaming_response(self) -> ScrollSearchResourceWithStreamingResponse:
39
+ """
40
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
41
+
42
+ For more information, see https://www.github.com/hubmapconsortium/search-python-sdk#with_streaming_response
43
+ """
44
+ return ScrollSearchResourceWithStreamingResponse(self)
45
+
46
+ def create(
47
+ self,
48
+ index: str,
49
+ *,
50
+ body: object,
51
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
52
+ # The extra values given here take precedence over values defined on the client or passed to this method.
53
+ extra_headers: Headers | None = None,
54
+ extra_query: Query | None = None,
55
+ extra_body: Body | None = None,
56
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
57
+ ) -> None:
58
+ """
59
+ Use the OpenSearch scroll API
60
+ (https://opensearch.org/docs/latest/api-reference/scroll/) to open a scroll
61
+ which will be navigated in the specified time when scroll_id is not provided,
62
+ retrieve more results when a scroll_id is provided, and close a scroll when zero
63
+ is the specified time.
64
+
65
+ Args:
66
+ extra_headers: Send extra headers
67
+
68
+ extra_query: Add additional query parameters to the request
69
+
70
+ extra_body: Add additional JSON properties to the request
71
+
72
+ timeout: Override the client-level default timeout for this request, in seconds
73
+ """
74
+ if not index:
75
+ raise ValueError(f"Expected a non-empty value for `index` but received {index!r}")
76
+ extra_headers = {"Accept": "*/*", **(extra_headers or {})}
77
+ return self._post(
78
+ f"/{index}/scroll-search",
79
+ body=maybe_transform(body, scroll_search_create_params.ScrollSearchCreateParams),
80
+ options=make_request_options(
81
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
82
+ ),
83
+ cast_to=NoneType,
84
+ )
85
+
86
+
87
+ class AsyncScrollSearchResource(AsyncAPIResource):
88
+ @cached_property
89
+ def with_raw_response(self) -> AsyncScrollSearchResourceWithRawResponse:
90
+ """
91
+ This property can be used as a prefix for any HTTP method call to return
92
+ the raw response object instead of the parsed content.
93
+
94
+ For more information, see https://www.github.com/hubmapconsortium/search-python-sdk#accessing-raw-response-data-eg-headers
95
+ """
96
+ return AsyncScrollSearchResourceWithRawResponse(self)
97
+
98
+ @cached_property
99
+ def with_streaming_response(self) -> AsyncScrollSearchResourceWithStreamingResponse:
100
+ """
101
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
102
+
103
+ For more information, see https://www.github.com/hubmapconsortium/search-python-sdk#with_streaming_response
104
+ """
105
+ return AsyncScrollSearchResourceWithStreamingResponse(self)
106
+
107
+ async def create(
108
+ self,
109
+ index: str,
110
+ *,
111
+ body: object,
112
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
113
+ # The extra values given here take precedence over values defined on the client or passed to this method.
114
+ extra_headers: Headers | None = None,
115
+ extra_query: Query | None = None,
116
+ extra_body: Body | None = None,
117
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
118
+ ) -> None:
119
+ """
120
+ Use the OpenSearch scroll API
121
+ (https://opensearch.org/docs/latest/api-reference/scroll/) to open a scroll
122
+ which will be navigated in the specified time when scroll_id is not provided,
123
+ retrieve more results when a scroll_id is provided, and close a scroll when zero
124
+ is the specified time.
125
+
126
+ Args:
127
+ extra_headers: Send extra headers
128
+
129
+ extra_query: Add additional query parameters to the request
130
+
131
+ extra_body: Add additional JSON properties to the request
132
+
133
+ timeout: Override the client-level default timeout for this request, in seconds
134
+ """
135
+ if not index:
136
+ raise ValueError(f"Expected a non-empty value for `index` but received {index!r}")
137
+ extra_headers = {"Accept": "*/*", **(extra_headers or {})}
138
+ return await self._post(
139
+ f"/{index}/scroll-search",
140
+ body=await async_maybe_transform(body, scroll_search_create_params.ScrollSearchCreateParams),
141
+ options=make_request_options(
142
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
143
+ ),
144
+ cast_to=NoneType,
145
+ )
146
+
147
+
148
+ class ScrollSearchResourceWithRawResponse:
149
+ def __init__(self, scroll_search: ScrollSearchResource) -> None:
150
+ self._scroll_search = scroll_search
151
+
152
+ self.create = to_raw_response_wrapper(
153
+ scroll_search.create,
154
+ )
155
+
156
+
157
+ class AsyncScrollSearchResourceWithRawResponse:
158
+ def __init__(self, scroll_search: AsyncScrollSearchResource) -> None:
159
+ self._scroll_search = scroll_search
160
+
161
+ self.create = async_to_raw_response_wrapper(
162
+ scroll_search.create,
163
+ )
164
+
165
+
166
+ class ScrollSearchResourceWithStreamingResponse:
167
+ def __init__(self, scroll_search: ScrollSearchResource) -> None:
168
+ self._scroll_search = scroll_search
169
+
170
+ self.create = to_streamed_response_wrapper(
171
+ scroll_search.create,
172
+ )
173
+
174
+
175
+ class AsyncScrollSearchResourceWithStreamingResponse:
176
+ def __init__(self, scroll_search: AsyncScrollSearchResource) -> None:
177
+ self._scroll_search = scroll_search
178
+
179
+ self.create = async_to_streamed_response_wrapper(
180
+ scroll_search.create,
181
+ )
@@ -0,0 +1,313 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import httpx
6
+
7
+ from ..types import search_execute_query_params, search_execute_index_query_params
8
+ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
9
+ from .._utils import (
10
+ maybe_transform,
11
+ async_maybe_transform,
12
+ )
13
+ from .._compat import cached_property
14
+ from .._resource import SyncAPIResource, AsyncAPIResource
15
+ from .._response import (
16
+ to_raw_response_wrapper,
17
+ to_streamed_response_wrapper,
18
+ async_to_raw_response_wrapper,
19
+ async_to_streamed_response_wrapper,
20
+ )
21
+ from .._base_client import make_request_options
22
+
23
+ __all__ = ["SearchResource", "AsyncSearchResource"]
24
+
25
+
26
+ class SearchResource(SyncAPIResource):
27
+ @cached_property
28
+ def with_raw_response(self) -> SearchResourceWithRawResponse:
29
+ """
30
+ This property can be used as a prefix for any HTTP method call to return
31
+ the raw response object instead of the parsed content.
32
+
33
+ For more information, see https://www.github.com/hubmapconsortium/search-python-sdk#accessing-raw-response-data-eg-headers
34
+ """
35
+ return SearchResourceWithRawResponse(self)
36
+
37
+ @cached_property
38
+ def with_streaming_response(self) -> SearchResourceWithStreamingResponse:
39
+ """
40
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
41
+
42
+ For more information, see https://www.github.com/hubmapconsortium/search-python-sdk#with_streaming_response
43
+ """
44
+ return SearchResourceWithStreamingResponse(self)
45
+
46
+ def execute_index_query(
47
+ self,
48
+ index_name: str,
49
+ *,
50
+ body: object,
51
+ produce_clt_manifest: str | NotGiven = NOT_GIVEN,
52
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
53
+ # The extra values given here take precedence over values defined on the client or passed to this method.
54
+ extra_headers: Headers | None = None,
55
+ extra_query: Query | None = None,
56
+ extra_body: Body | None = None,
57
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
58
+ ) -> object:
59
+ """
60
+ To execute a query, the POST method must provide 1) a request body that
61
+ specifies an
62
+ [Elasticsearch Query DSL statement](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html) 2)
63
+ a bearer token in the Authorization header supplied by HuBMAP. Results are
64
+ limited to those authorized by the bearer token. Uses the
65
+ <strong>entities</strong> index by default.
66
+
67
+ Args:
68
+ produce_clt_manifest: An optional parameter that, when set to "true", will make the endpoint return a
69
+ text representation of a manifest file that corresponds with the datasets
70
+ queried rather than the original response
71
+
72
+ extra_headers: Send extra headers
73
+
74
+ extra_query: Add additional query parameters to the request
75
+
76
+ extra_body: Add additional JSON properties to the request
77
+
78
+ timeout: Override the client-level default timeout for this request, in seconds
79
+ """
80
+ if not index_name:
81
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
82
+ return self._post(
83
+ f"/{index_name}/search",
84
+ body=maybe_transform(body, search_execute_index_query_params.SearchExecuteIndexQueryParams),
85
+ options=make_request_options(
86
+ extra_headers=extra_headers,
87
+ extra_query=extra_query,
88
+ extra_body=extra_body,
89
+ timeout=timeout,
90
+ query=maybe_transform(
91
+ {"produce_clt_manifest": produce_clt_manifest},
92
+ search_execute_index_query_params.SearchExecuteIndexQueryParams,
93
+ ),
94
+ ),
95
+ cast_to=object,
96
+ )
97
+
98
+ def execute_query(
99
+ self,
100
+ *,
101
+ body: object,
102
+ produce_clt_manifest: str | NotGiven = NOT_GIVEN,
103
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
104
+ # The extra values given here take precedence over values defined on the client or passed to this method.
105
+ extra_headers: Headers | None = None,
106
+ extra_query: Query | None = None,
107
+ extra_body: Body | None = None,
108
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
109
+ ) -> object:
110
+ """
111
+ To execute a query, the POST method must provide 1) a request body that
112
+ specifies an
113
+ [Elasticsearch Query DSL statement](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html) 2)
114
+ a bearer token in the Authorization header supplied by HuBMAP. Results are
115
+ limited to those authorized by the bearer token. Uses the
116
+ <strong>entities</strong> index by default.
117
+
118
+ Args:
119
+ produce_clt_manifest: An optional parameter that, when set to "true", will make the endpoint return a
120
+ text representation of a manifest file that corresponds with the datasets
121
+ queried rather than the original response
122
+
123
+ extra_headers: Send extra headers
124
+
125
+ extra_query: Add additional query parameters to the request
126
+
127
+ extra_body: Add additional JSON properties to the request
128
+
129
+ timeout: Override the client-level default timeout for this request, in seconds
130
+ """
131
+ return self._post(
132
+ "/search",
133
+ body=maybe_transform(body, search_execute_query_params.SearchExecuteQueryParams),
134
+ options=make_request_options(
135
+ extra_headers=extra_headers,
136
+ extra_query=extra_query,
137
+ extra_body=extra_body,
138
+ timeout=timeout,
139
+ query=maybe_transform(
140
+ {"produce_clt_manifest": produce_clt_manifest}, search_execute_query_params.SearchExecuteQueryParams
141
+ ),
142
+ ),
143
+ cast_to=object,
144
+ )
145
+
146
+
147
+ class AsyncSearchResource(AsyncAPIResource):
148
+ @cached_property
149
+ def with_raw_response(self) -> AsyncSearchResourceWithRawResponse:
150
+ """
151
+ This property can be used as a prefix for any HTTP method call to return
152
+ the raw response object instead of the parsed content.
153
+
154
+ For more information, see https://www.github.com/hubmapconsortium/search-python-sdk#accessing-raw-response-data-eg-headers
155
+ """
156
+ return AsyncSearchResourceWithRawResponse(self)
157
+
158
+ @cached_property
159
+ def with_streaming_response(self) -> AsyncSearchResourceWithStreamingResponse:
160
+ """
161
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
162
+
163
+ For more information, see https://www.github.com/hubmapconsortium/search-python-sdk#with_streaming_response
164
+ """
165
+ return AsyncSearchResourceWithStreamingResponse(self)
166
+
167
+ async def execute_index_query(
168
+ self,
169
+ index_name: str,
170
+ *,
171
+ body: object,
172
+ produce_clt_manifest: str | NotGiven = NOT_GIVEN,
173
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
174
+ # The extra values given here take precedence over values defined on the client or passed to this method.
175
+ extra_headers: Headers | None = None,
176
+ extra_query: Query | None = None,
177
+ extra_body: Body | None = None,
178
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
179
+ ) -> object:
180
+ """
181
+ To execute a query, the POST method must provide 1) a request body that
182
+ specifies an
183
+ [Elasticsearch Query DSL statement](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html) 2)
184
+ a bearer token in the Authorization header supplied by HuBMAP. Results are
185
+ limited to those authorized by the bearer token. Uses the
186
+ <strong>entities</strong> index by default.
187
+
188
+ Args:
189
+ produce_clt_manifest: An optional parameter that, when set to "true", will make the endpoint return a
190
+ text representation of a manifest file that corresponds with the datasets
191
+ queried rather than the original response
192
+
193
+ extra_headers: Send extra headers
194
+
195
+ extra_query: Add additional query parameters to the request
196
+
197
+ extra_body: Add additional JSON properties to the request
198
+
199
+ timeout: Override the client-level default timeout for this request, in seconds
200
+ """
201
+ if not index_name:
202
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
203
+ return await self._post(
204
+ f"/{index_name}/search",
205
+ body=await async_maybe_transform(body, search_execute_index_query_params.SearchExecuteIndexQueryParams),
206
+ options=make_request_options(
207
+ extra_headers=extra_headers,
208
+ extra_query=extra_query,
209
+ extra_body=extra_body,
210
+ timeout=timeout,
211
+ query=await async_maybe_transform(
212
+ {"produce_clt_manifest": produce_clt_manifest},
213
+ search_execute_index_query_params.SearchExecuteIndexQueryParams,
214
+ ),
215
+ ),
216
+ cast_to=object,
217
+ )
218
+
219
+ async def execute_query(
220
+ self,
221
+ *,
222
+ body: object,
223
+ produce_clt_manifest: str | NotGiven = NOT_GIVEN,
224
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
225
+ # The extra values given here take precedence over values defined on the client or passed to this method.
226
+ extra_headers: Headers | None = None,
227
+ extra_query: Query | None = None,
228
+ extra_body: Body | None = None,
229
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
230
+ ) -> object:
231
+ """
232
+ To execute a query, the POST method must provide 1) a request body that
233
+ specifies an
234
+ [Elasticsearch Query DSL statement](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html) 2)
235
+ a bearer token in the Authorization header supplied by HuBMAP. Results are
236
+ limited to those authorized by the bearer token. Uses the
237
+ <strong>entities</strong> index by default.
238
+
239
+ Args:
240
+ produce_clt_manifest: An optional parameter that, when set to "true", will make the endpoint return a
241
+ text representation of a manifest file that corresponds with the datasets
242
+ queried rather than the original response
243
+
244
+ extra_headers: Send extra headers
245
+
246
+ extra_query: Add additional query parameters to the request
247
+
248
+ extra_body: Add additional JSON properties to the request
249
+
250
+ timeout: Override the client-level default timeout for this request, in seconds
251
+ """
252
+ return await self._post(
253
+ "/search",
254
+ body=await async_maybe_transform(body, search_execute_query_params.SearchExecuteQueryParams),
255
+ options=make_request_options(
256
+ extra_headers=extra_headers,
257
+ extra_query=extra_query,
258
+ extra_body=extra_body,
259
+ timeout=timeout,
260
+ query=await async_maybe_transform(
261
+ {"produce_clt_manifest": produce_clt_manifest}, search_execute_query_params.SearchExecuteQueryParams
262
+ ),
263
+ ),
264
+ cast_to=object,
265
+ )
266
+
267
+
268
+ class SearchResourceWithRawResponse:
269
+ def __init__(self, search: SearchResource) -> None:
270
+ self._search = search
271
+
272
+ self.execute_index_query = to_raw_response_wrapper(
273
+ search.execute_index_query,
274
+ )
275
+ self.execute_query = to_raw_response_wrapper(
276
+ search.execute_query,
277
+ )
278
+
279
+
280
+ class AsyncSearchResourceWithRawResponse:
281
+ def __init__(self, search: AsyncSearchResource) -> None:
282
+ self._search = search
283
+
284
+ self.execute_index_query = async_to_raw_response_wrapper(
285
+ search.execute_index_query,
286
+ )
287
+ self.execute_query = async_to_raw_response_wrapper(
288
+ search.execute_query,
289
+ )
290
+
291
+
292
+ class SearchResourceWithStreamingResponse:
293
+ def __init__(self, search: SearchResource) -> None:
294
+ self._search = search
295
+
296
+ self.execute_index_query = to_streamed_response_wrapper(
297
+ search.execute_index_query,
298
+ )
299
+ self.execute_query = to_streamed_response_wrapper(
300
+ search.execute_query,
301
+ )
302
+
303
+
304
+ class AsyncSearchResourceWithStreamingResponse:
305
+ def __init__(self, search: AsyncSearchResource) -> None:
306
+ self._search = search
307
+
308
+ self.execute_index_query = async_to_streamed_response_wrapper(
309
+ search.execute_index_query,
310
+ )
311
+ self.execute_query = async_to_streamed_response_wrapper(
312
+ search.execute_query,
313
+ )