codeset 0.4.4__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 (63) hide show
  1. codeset/__init__.py +92 -0
  2. codeset/_base_client.py +2001 -0
  3. codeset/_client.py +572 -0
  4. codeset/_compat.py +219 -0
  5. codeset/_constants.py +14 -0
  6. codeset/_exceptions.py +108 -0
  7. codeset/_files.py +123 -0
  8. codeset/_models.py +857 -0
  9. codeset/_qs.py +150 -0
  10. codeset/_resource.py +43 -0
  11. codeset/_response.py +830 -0
  12. codeset/_streaming.py +333 -0
  13. codeset/_types.py +261 -0
  14. codeset/_utils/__init__.py +66 -0
  15. codeset/_utils/_compat.py +45 -0
  16. codeset/_utils/_datetime_parse.py +136 -0
  17. codeset/_utils/_logs.py +25 -0
  18. codeset/_utils/_proxy.py +65 -0
  19. codeset/_utils/_reflection.py +42 -0
  20. codeset/_utils/_resources_proxy.py +24 -0
  21. codeset/_utils/_streams.py +12 -0
  22. codeset/_utils/_sync.py +58 -0
  23. codeset/_utils/_transform.py +457 -0
  24. codeset/_utils/_typing.py +156 -0
  25. codeset/_utils/_utils.py +474 -0
  26. codeset/_version.py +4 -0
  27. codeset/lib/.keep +4 -0
  28. codeset/py.typed +0 -0
  29. codeset/resources/__init__.py +61 -0
  30. codeset/resources/datasets.py +135 -0
  31. codeset/resources/health.py +135 -0
  32. codeset/resources/samples.py +303 -0
  33. codeset/resources/sessions/__init__.py +33 -0
  34. codeset/resources/sessions/sessions.py +891 -0
  35. codeset/resources/sessions/verify.py +335 -0
  36. codeset/types/__init__.py +22 -0
  37. codeset/types/container_info.py +32 -0
  38. codeset/types/dataset_list_response.py +28 -0
  39. codeset/types/error_info.py +15 -0
  40. codeset/types/health_check_response.py +21 -0
  41. codeset/types/interaction.py +37 -0
  42. codeset/types/interaction_status.py +7 -0
  43. codeset/types/sample_download_params.py +14 -0
  44. codeset/types/sample_list_params.py +22 -0
  45. codeset/types/sample_list_response.py +95 -0
  46. codeset/types/session.py +48 -0
  47. codeset/types/session_close_response.py +15 -0
  48. codeset/types/session_create_params.py +18 -0
  49. codeset/types/session_create_response.py +21 -0
  50. codeset/types/session_execute_command_params.py +15 -0
  51. codeset/types/session_execute_command_response.py +15 -0
  52. codeset/types/session_list_response.py +20 -0
  53. codeset/types/session_status.py +7 -0
  54. codeset/types/session_str_replace_params.py +18 -0
  55. codeset/types/session_str_replace_response.py +15 -0
  56. codeset/types/sessions/__init__.py +7 -0
  57. codeset/types/sessions/job_status.py +7 -0
  58. codeset/types/sessions/verify_start_response.py +21 -0
  59. codeset/types/sessions/verify_status_response.py +79 -0
  60. codeset-0.4.4.dist-info/METADATA +399 -0
  61. codeset-0.4.4.dist-info/RECORD +63 -0
  62. codeset-0.4.4.dist-info/WHEEL +4 -0
  63. codeset-0.4.4.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,474 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import re
5
+ import time
6
+ import inspect
7
+ import functools
8
+ from typing import (
9
+ Any,
10
+ Tuple,
11
+ Mapping,
12
+ TypeVar,
13
+ Callable,
14
+ Iterable,
15
+ Sequence,
16
+ cast,
17
+ overload,
18
+ )
19
+ from pathlib import Path
20
+ from datetime import date, datetime
21
+ from typing_extensions import TypeGuard
22
+
23
+ import httpx
24
+ import sniffio
25
+
26
+ from .._types import Omit, NotGiven, FileTypes, HeadersLike
27
+
28
+ _T = TypeVar("_T")
29
+ _TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
30
+ _MappingT = TypeVar("_MappingT", bound=Mapping[str, object])
31
+ _SequenceT = TypeVar("_SequenceT", bound=Sequence[object])
32
+ CallableT = TypeVar("CallableT", bound=Callable[..., Any])
33
+
34
+
35
+ def flatten(t: Iterable[Iterable[_T]]) -> list[_T]:
36
+ return [item for sublist in t for item in sublist]
37
+
38
+
39
+ def extract_files(
40
+ # TODO: this needs to take Dict but variance issues.....
41
+ # create protocol type ?
42
+ query: Mapping[str, object],
43
+ *,
44
+ paths: Sequence[Sequence[str]],
45
+ ) -> list[tuple[str, FileTypes]]:
46
+ """Recursively extract files from the given dictionary based on specified paths.
47
+
48
+ A path may look like this ['foo', 'files', '<array>', 'data'].
49
+
50
+ Note: this mutates the given dictionary.
51
+ """
52
+ files: list[tuple[str, FileTypes]] = []
53
+ for path in paths:
54
+ files.extend(_extract_items(query, path, index=0, flattened_key=None))
55
+ return files
56
+
57
+
58
+ def _extract_items(
59
+ obj: object,
60
+ path: Sequence[str],
61
+ *,
62
+ index: int,
63
+ flattened_key: str | None,
64
+ ) -> list[tuple[str, FileTypes]]:
65
+ try:
66
+ key = path[index]
67
+ except IndexError:
68
+ if not is_given(obj):
69
+ # no value was provided - we can safely ignore
70
+ return []
71
+
72
+ # cyclical import
73
+ from .._files import assert_is_file_content
74
+
75
+ # We have exhausted the path, return the entry we found.
76
+ assert flattened_key is not None
77
+
78
+ if is_list(obj):
79
+ files: list[tuple[str, FileTypes]] = []
80
+ for entry in obj:
81
+ assert_is_file_content(entry, key=flattened_key + "[]" if flattened_key else "")
82
+ files.append((flattened_key + "[]", cast(FileTypes, entry)))
83
+ return files
84
+
85
+ assert_is_file_content(obj, key=flattened_key)
86
+ return [(flattened_key, cast(FileTypes, obj))]
87
+
88
+ index += 1
89
+ if is_dict(obj):
90
+ try:
91
+ # We are at the last entry in the path so we must remove the field
92
+ if (len(path)) == index:
93
+ item = obj.pop(key)
94
+ else:
95
+ item = obj[key]
96
+ except KeyError:
97
+ # Key was not present in the dictionary, this is not indicative of an error
98
+ # as the given path may not point to a required field. We also do not want
99
+ # to enforce required fields as the API may differ from the spec in some cases.
100
+ return []
101
+ if flattened_key is None:
102
+ flattened_key = key
103
+ else:
104
+ flattened_key += f"[{key}]"
105
+ return _extract_items(
106
+ item,
107
+ path,
108
+ index=index,
109
+ flattened_key=flattened_key,
110
+ )
111
+ elif is_list(obj):
112
+ if key != "<array>":
113
+ return []
114
+
115
+ return flatten(
116
+ [
117
+ _extract_items(
118
+ item,
119
+ path,
120
+ index=index,
121
+ flattened_key=flattened_key + "[]" if flattened_key is not None else "[]",
122
+ )
123
+ for item in obj
124
+ ]
125
+ )
126
+
127
+ # Something unexpected was passed, just ignore it.
128
+ return []
129
+
130
+
131
+ def is_given(obj: _T | NotGiven | Omit) -> TypeGuard[_T]:
132
+ return not isinstance(obj, NotGiven) and not isinstance(obj, Omit)
133
+
134
+
135
+ # Type safe methods for narrowing types with TypeVars.
136
+ # The default narrowing for isinstance(obj, dict) is dict[unknown, unknown],
137
+ # however this cause Pyright to rightfully report errors. As we know we don't
138
+ # care about the contained types we can safely use `object` in its place.
139
+ #
140
+ # There are two separate functions defined, `is_*` and `is_*_t` for different use cases.
141
+ # `is_*` is for when you're dealing with an unknown input
142
+ # `is_*_t` is for when you're narrowing a known union type to a specific subset
143
+
144
+
145
+ def is_tuple(obj: object) -> TypeGuard[tuple[object, ...]]:
146
+ return isinstance(obj, tuple)
147
+
148
+
149
+ def is_tuple_t(obj: _TupleT | object) -> TypeGuard[_TupleT]:
150
+ return isinstance(obj, tuple)
151
+
152
+
153
+ def is_sequence(obj: object) -> TypeGuard[Sequence[object]]:
154
+ return isinstance(obj, Sequence)
155
+
156
+
157
+ def is_sequence_t(obj: _SequenceT | object) -> TypeGuard[_SequenceT]:
158
+ return isinstance(obj, Sequence)
159
+
160
+
161
+ def is_mapping(obj: object) -> TypeGuard[Mapping[str, object]]:
162
+ return isinstance(obj, Mapping)
163
+
164
+
165
+ def is_mapping_t(obj: _MappingT | object) -> TypeGuard[_MappingT]:
166
+ return isinstance(obj, Mapping)
167
+
168
+
169
+ def is_dict(obj: object) -> TypeGuard[dict[object, object]]:
170
+ return isinstance(obj, dict)
171
+
172
+
173
+ def is_list(obj: object) -> TypeGuard[list[object]]:
174
+ return isinstance(obj, list)
175
+
176
+
177
+ def is_iterable(obj: object) -> TypeGuard[Iterable[object]]:
178
+ return isinstance(obj, Iterable)
179
+
180
+
181
+ def deepcopy_minimal(item: _T) -> _T:
182
+ """Minimal reimplementation of copy.deepcopy() that will only copy certain object types:
183
+
184
+ - mappings, e.g. `dict`
185
+ - list
186
+
187
+ This is done for performance reasons.
188
+ """
189
+ if is_mapping(item):
190
+ return cast(_T, {k: deepcopy_minimal(v) for k, v in item.items()})
191
+ if is_list(item):
192
+ return cast(_T, [deepcopy_minimal(entry) for entry in item])
193
+ return item
194
+
195
+
196
+ # copied from https://github.com/Rapptz/RoboDanny
197
+ def human_join(seq: Sequence[str], *, delim: str = ", ", final: str = "or") -> str:
198
+ size = len(seq)
199
+ if size == 0:
200
+ return ""
201
+
202
+ if size == 1:
203
+ return seq[0]
204
+
205
+ if size == 2:
206
+ return f"{seq[0]} {final} {seq[1]}"
207
+
208
+ return delim.join(seq[:-1]) + f" {final} {seq[-1]}"
209
+
210
+
211
+ def quote(string: str) -> str:
212
+ """Add single quotation marks around the given string. Does *not* do any escaping."""
213
+ return f"'{string}'"
214
+
215
+
216
+ def required_args(*variants: Sequence[str]) -> Callable[[CallableT], CallableT]:
217
+ """Decorator to enforce a given set of arguments or variants of arguments are passed to the decorated function.
218
+
219
+ Useful for enforcing runtime validation of overloaded functions.
220
+
221
+ Example usage:
222
+ ```py
223
+ @overload
224
+ def foo(*, a: str) -> str: ...
225
+
226
+
227
+ @overload
228
+ def foo(*, b: bool) -> str: ...
229
+
230
+
231
+ # This enforces the same constraints that a static type checker would
232
+ # i.e. that either a or b must be passed to the function
233
+ @required_args(["a"], ["b"])
234
+ def foo(*, a: str | None = None, b: bool | None = None) -> str: ...
235
+ ```
236
+ """
237
+
238
+ def inner(func: CallableT) -> CallableT:
239
+ params = inspect.signature(func).parameters
240
+ positional = [
241
+ name
242
+ for name, param in params.items()
243
+ if param.kind
244
+ in {
245
+ param.POSITIONAL_ONLY,
246
+ param.POSITIONAL_OR_KEYWORD,
247
+ }
248
+ ]
249
+
250
+ @functools.wraps(func)
251
+ def wrapper(*args: object, **kwargs: object) -> object:
252
+ given_params: set[str] = set()
253
+ for i, _ in enumerate(args):
254
+ try:
255
+ given_params.add(positional[i])
256
+ except IndexError:
257
+ raise TypeError(
258
+ f"{func.__name__}() takes {len(positional)} argument(s) but {len(args)} were given"
259
+ ) from None
260
+
261
+ for key in kwargs.keys():
262
+ given_params.add(key)
263
+
264
+ for variant in variants:
265
+ matches = all((param in given_params for param in variant))
266
+ if matches:
267
+ break
268
+ else: # no break
269
+ if len(variants) > 1:
270
+ variations = human_join(
271
+ ["(" + human_join([quote(arg) for arg in variant], final="and") + ")" for variant in variants]
272
+ )
273
+ msg = f"Missing required arguments; Expected either {variations} arguments to be given"
274
+ else:
275
+ assert len(variants) > 0
276
+
277
+ # TODO: this error message is not deterministic
278
+ missing = list(set(variants[0]) - given_params)
279
+ if len(missing) > 1:
280
+ msg = f"Missing required arguments: {human_join([quote(arg) for arg in missing])}"
281
+ else:
282
+ msg = f"Missing required argument: {quote(missing[0])}"
283
+ raise TypeError(msg)
284
+ return func(*args, **kwargs)
285
+
286
+ return wrapper # type: ignore
287
+
288
+ return inner
289
+
290
+
291
+ _K = TypeVar("_K")
292
+ _V = TypeVar("_V")
293
+
294
+
295
+ @overload
296
+ def strip_not_given(obj: None) -> None: ...
297
+
298
+
299
+ @overload
300
+ def strip_not_given(obj: Mapping[_K, _V | NotGiven]) -> dict[_K, _V]: ...
301
+
302
+
303
+ @overload
304
+ def strip_not_given(obj: object) -> object: ...
305
+
306
+
307
+ def strip_not_given(obj: object | None) -> object:
308
+ """Remove all top-level keys where their values are instances of `NotGiven`"""
309
+ if obj is None:
310
+ return None
311
+
312
+ if not is_mapping(obj):
313
+ return obj
314
+
315
+ return {key: value for key, value in obj.items() if not isinstance(value, NotGiven)}
316
+
317
+
318
+ def coerce_integer(val: str) -> int:
319
+ return int(val, base=10)
320
+
321
+
322
+ def coerce_float(val: str) -> float:
323
+ return float(val)
324
+
325
+
326
+ def coerce_boolean(val: str) -> bool:
327
+ return val == "true" or val == "1" or val == "on"
328
+
329
+
330
+ def maybe_coerce_integer(val: str | None) -> int | None:
331
+ if val is None:
332
+ return None
333
+ return coerce_integer(val)
334
+
335
+
336
+ def maybe_coerce_float(val: str | None) -> float | None:
337
+ if val is None:
338
+ return None
339
+ return coerce_float(val)
340
+
341
+
342
+ def maybe_coerce_boolean(val: str | None) -> bool | None:
343
+ if val is None:
344
+ return None
345
+ return coerce_boolean(val)
346
+
347
+
348
+ def removeprefix(string: str, prefix: str) -> str:
349
+ """Remove a prefix from a string.
350
+
351
+ Backport of `str.removeprefix` for Python < 3.9
352
+ """
353
+ if string.startswith(prefix):
354
+ return string[len(prefix) :]
355
+ return string
356
+
357
+
358
+ def removesuffix(string: str, suffix: str) -> str:
359
+ """Remove a suffix from a string.
360
+
361
+ Backport of `str.removesuffix` for Python < 3.9
362
+ """
363
+ if string.endswith(suffix):
364
+ return string[: -len(suffix)]
365
+ return string
366
+
367
+
368
+ def file_from_path(path: str) -> FileTypes:
369
+ contents = Path(path).read_bytes()
370
+ file_name = os.path.basename(path)
371
+ return (file_name, contents)
372
+
373
+
374
+ def get_required_header(headers: HeadersLike, header: str) -> str:
375
+ lower_header = header.lower()
376
+ if is_mapping_t(headers):
377
+ # mypy doesn't understand the type narrowing here
378
+ for k, v in headers.items(): # type: ignore
379
+ if k.lower() == lower_header and isinstance(v, str):
380
+ return v
381
+
382
+ # to deal with the case where the header looks like Stainless-Event-Id
383
+ intercaps_header = re.sub(r"([^\w])(\w)", lambda pat: pat.group(1) + pat.group(2).upper(), header.capitalize())
384
+
385
+ for normalized_header in [header, lower_header, header.upper(), intercaps_header]:
386
+ value = headers.get(normalized_header)
387
+ if value:
388
+ return value
389
+
390
+ raise ValueError(f"Could not find {header} header")
391
+
392
+
393
+ def get_async_library() -> str:
394
+ try:
395
+ return sniffio.current_async_library()
396
+ except Exception:
397
+ return "false"
398
+
399
+
400
+ def lru_cache(*, maxsize: int | None = 128) -> Callable[[CallableT], CallableT]:
401
+ """A version of functools.lru_cache that retains the type signature
402
+ for the wrapped function arguments.
403
+ """
404
+ wrapper = functools.lru_cache( # noqa: TID251
405
+ maxsize=maxsize,
406
+ )
407
+ return cast(Any, wrapper) # type: ignore[no-any-return]
408
+
409
+
410
+ def json_safe(data: object) -> object:
411
+ """Translates a mapping / sequence recursively in the same fashion
412
+ as `pydantic` v2's `model_dump(mode="json")`.
413
+ """
414
+ if is_mapping(data):
415
+ return {json_safe(key): json_safe(value) for key, value in data.items()}
416
+
417
+ if is_iterable(data) and not isinstance(data, (str, bytes, bytearray)):
418
+ return [json_safe(item) for item in data]
419
+
420
+ if isinstance(data, (datetime, date)):
421
+ return data.isoformat()
422
+
423
+ return data
424
+
425
+
426
+ def get_remaining_timeout(
427
+ timeout: float | httpx.Timeout | None | NotGiven,
428
+ start_time: float,
429
+ ) -> float | httpx.Timeout | None | NotGiven:
430
+ """Calculate the remaining timeout based on elapsed time.
431
+
432
+ Args:
433
+ timeout: The original timeout value (float, httpx.Timeout, None, or NotGiven)
434
+ start_time: The start time of the operation (from time.time())
435
+
436
+ Returns:
437
+ The remaining timeout value in the same format as the input timeout
438
+ """
439
+ if isinstance(timeout, NotGiven) or timeout is None:
440
+ return timeout
441
+ elapsed = time.time() - start_time
442
+ if isinstance(timeout, (int, float)):
443
+ timeout_seconds = float(timeout)
444
+ remaining = max(0.1, timeout_seconds - elapsed)
445
+ return remaining if remaining > 0 else 0.1
446
+ else:
447
+ timeout_seconds = getattr(timeout, "timeout", 300.0)
448
+ remaining = max(0.1, timeout_seconds - elapsed)
449
+ if remaining <= 0:
450
+ raise TimeoutError(f"Operation timed out after {elapsed:.2f} seconds")
451
+ return httpx.Timeout(timeout=remaining, connect=getattr(timeout, "connect", 5.0))
452
+
453
+
454
+ def check_timeout(
455
+ timeout: float | httpx.Timeout | None | NotGiven,
456
+ start_time: float,
457
+ ) -> None:
458
+ """Check if the operation has exceeded the timeout and raise TimeoutError if so.
459
+
460
+ Args:
461
+ timeout: The original timeout value (float, httpx.Timeout, None, or NotGiven)
462
+ start_time: The start time of the operation (from time.time())
463
+
464
+ Raises:
465
+ TimeoutError: If the elapsed time exceeds the timeout
466
+ """
467
+ if not isinstance(timeout, NotGiven) and timeout is not None:
468
+ elapsed = time.time() - start_time
469
+ if isinstance(timeout, (int, float)):
470
+ timeout_seconds = float(timeout)
471
+ else:
472
+ timeout_seconds = getattr(timeout, "timeout", 300.0)
473
+ if elapsed >= timeout_seconds:
474
+ raise TimeoutError(f"Operation timed out after {elapsed:.2f} seconds")
codeset/_version.py ADDED
@@ -0,0 +1,4 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ __title__ = "codeset"
4
+ __version__ = "0.4.4" # x-release-please-version
codeset/lib/.keep ADDED
@@ -0,0 +1,4 @@
1
+ File generated from our OpenAPI spec by Stainless.
2
+
3
+ This directory can be used to store custom files to expand the SDK.
4
+ It is ignored by Stainless code generation and its content (other than this keep file) won't be touched.
codeset/py.typed ADDED
File without changes
@@ -0,0 +1,61 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from .health import (
4
+ HealthResource,
5
+ AsyncHealthResource,
6
+ HealthResourceWithRawResponse,
7
+ AsyncHealthResourceWithRawResponse,
8
+ HealthResourceWithStreamingResponse,
9
+ AsyncHealthResourceWithStreamingResponse,
10
+ )
11
+ from .samples import (
12
+ SamplesResource,
13
+ AsyncSamplesResource,
14
+ SamplesResourceWithRawResponse,
15
+ AsyncSamplesResourceWithRawResponse,
16
+ SamplesResourceWithStreamingResponse,
17
+ AsyncSamplesResourceWithStreamingResponse,
18
+ )
19
+ from .datasets import (
20
+ DatasetsResource,
21
+ AsyncDatasetsResource,
22
+ DatasetsResourceWithRawResponse,
23
+ AsyncDatasetsResourceWithRawResponse,
24
+ DatasetsResourceWithStreamingResponse,
25
+ AsyncDatasetsResourceWithStreamingResponse,
26
+ )
27
+ from .sessions import (
28
+ SessionsResource,
29
+ AsyncSessionsResource,
30
+ SessionsResourceWithRawResponse,
31
+ AsyncSessionsResourceWithRawResponse,
32
+ SessionsResourceWithStreamingResponse,
33
+ AsyncSessionsResourceWithStreamingResponse,
34
+ )
35
+
36
+ __all__ = [
37
+ "HealthResource",
38
+ "AsyncHealthResource",
39
+ "HealthResourceWithRawResponse",
40
+ "AsyncHealthResourceWithRawResponse",
41
+ "HealthResourceWithStreamingResponse",
42
+ "AsyncHealthResourceWithStreamingResponse",
43
+ "SamplesResource",
44
+ "AsyncSamplesResource",
45
+ "SamplesResourceWithRawResponse",
46
+ "AsyncSamplesResourceWithRawResponse",
47
+ "SamplesResourceWithStreamingResponse",
48
+ "AsyncSamplesResourceWithStreamingResponse",
49
+ "DatasetsResource",
50
+ "AsyncDatasetsResource",
51
+ "DatasetsResourceWithRawResponse",
52
+ "AsyncDatasetsResourceWithRawResponse",
53
+ "DatasetsResourceWithStreamingResponse",
54
+ "AsyncDatasetsResourceWithStreamingResponse",
55
+ "SessionsResource",
56
+ "AsyncSessionsResource",
57
+ "SessionsResourceWithRawResponse",
58
+ "AsyncSessionsResourceWithRawResponse",
59
+ "SessionsResourceWithStreamingResponse",
60
+ "AsyncSessionsResourceWithStreamingResponse",
61
+ ]
@@ -0,0 +1,135 @@
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 Body, Query, Headers, NotGiven, not_given
8
+ from .._compat import cached_property
9
+ from .._resource import SyncAPIResource, AsyncAPIResource
10
+ from .._response import (
11
+ to_raw_response_wrapper,
12
+ to_streamed_response_wrapper,
13
+ async_to_raw_response_wrapper,
14
+ async_to_streamed_response_wrapper,
15
+ )
16
+ from .._base_client import make_request_options
17
+ from ..types.dataset_list_response import DatasetListResponse
18
+
19
+ __all__ = ["DatasetsResource", "AsyncDatasetsResource"]
20
+
21
+
22
+ class DatasetsResource(SyncAPIResource):
23
+ @cached_property
24
+ def with_raw_response(self) -> DatasetsResourceWithRawResponse:
25
+ """
26
+ This property can be used as a prefix for any HTTP method call to return
27
+ the raw response object instead of the parsed content.
28
+
29
+ For more information, see https://www.github.com/codeset-ai/codeset-sdk#accessing-raw-response-data-eg-headers
30
+ """
31
+ return DatasetsResourceWithRawResponse(self)
32
+
33
+ @cached_property
34
+ def with_streaming_response(self) -> DatasetsResourceWithStreamingResponse:
35
+ """
36
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
37
+
38
+ For more information, see https://www.github.com/codeset-ai/codeset-sdk#with_streaming_response
39
+ """
40
+ return DatasetsResourceWithStreamingResponse(self)
41
+
42
+ def list(
43
+ self,
44
+ *,
45
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
46
+ # The extra values given here take precedence over values defined on the client or passed to this method.
47
+ extra_headers: Headers | None = None,
48
+ extra_query: Query | None = None,
49
+ extra_body: Body | None = None,
50
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
51
+ ) -> DatasetListResponse:
52
+ """List available datasets"""
53
+ return self._get(
54
+ "/datasets",
55
+ options=make_request_options(
56
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
57
+ ),
58
+ cast_to=DatasetListResponse,
59
+ )
60
+
61
+
62
+ class AsyncDatasetsResource(AsyncAPIResource):
63
+ @cached_property
64
+ def with_raw_response(self) -> AsyncDatasetsResourceWithRawResponse:
65
+ """
66
+ This property can be used as a prefix for any HTTP method call to return
67
+ the raw response object instead of the parsed content.
68
+
69
+ For more information, see https://www.github.com/codeset-ai/codeset-sdk#accessing-raw-response-data-eg-headers
70
+ """
71
+ return AsyncDatasetsResourceWithRawResponse(self)
72
+
73
+ @cached_property
74
+ def with_streaming_response(self) -> AsyncDatasetsResourceWithStreamingResponse:
75
+ """
76
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
77
+
78
+ For more information, see https://www.github.com/codeset-ai/codeset-sdk#with_streaming_response
79
+ """
80
+ return AsyncDatasetsResourceWithStreamingResponse(self)
81
+
82
+ async def list(
83
+ self,
84
+ *,
85
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
86
+ # The extra values given here take precedence over values defined on the client or passed to this method.
87
+ extra_headers: Headers | None = None,
88
+ extra_query: Query | None = None,
89
+ extra_body: Body | None = None,
90
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
91
+ ) -> DatasetListResponse:
92
+ """List available datasets"""
93
+ return await self._get(
94
+ "/datasets",
95
+ options=make_request_options(
96
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
97
+ ),
98
+ cast_to=DatasetListResponse,
99
+ )
100
+
101
+
102
+ class DatasetsResourceWithRawResponse:
103
+ def __init__(self, datasets: DatasetsResource) -> None:
104
+ self._datasets = datasets
105
+
106
+ self.list = to_raw_response_wrapper(
107
+ datasets.list,
108
+ )
109
+
110
+
111
+ class AsyncDatasetsResourceWithRawResponse:
112
+ def __init__(self, datasets: AsyncDatasetsResource) -> None:
113
+ self._datasets = datasets
114
+
115
+ self.list = async_to_raw_response_wrapper(
116
+ datasets.list,
117
+ )
118
+
119
+
120
+ class DatasetsResourceWithStreamingResponse:
121
+ def __init__(self, datasets: DatasetsResource) -> None:
122
+ self._datasets = datasets
123
+
124
+ self.list = to_streamed_response_wrapper(
125
+ datasets.list,
126
+ )
127
+
128
+
129
+ class AsyncDatasetsResourceWithStreamingResponse:
130
+ def __init__(self, datasets: AsyncDatasetsResource) -> None:
131
+ self._datasets = datasets
132
+
133
+ self.list = async_to_streamed_response_wrapper(
134
+ datasets.list,
135
+ )