cribl-control-plane 0.0.13__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.

Potentially problematic release.


This version of cribl-control-plane might be problematic. Click here for more details.

Files changed (197) hide show
  1. cribl_control_plane/__init__.py +17 -0
  2. cribl_control_plane/_hooks/__init__.py +5 -0
  3. cribl_control_plane/_hooks/clientcredentials.py +211 -0
  4. cribl_control_plane/_hooks/registration.py +13 -0
  5. cribl_control_plane/_hooks/sdkhooks.py +81 -0
  6. cribl_control_plane/_hooks/types.py +112 -0
  7. cribl_control_plane/_version.py +15 -0
  8. cribl_control_plane/auth_sdk.py +184 -0
  9. cribl_control_plane/basesdk.py +358 -0
  10. cribl_control_plane/errors/__init__.py +60 -0
  11. cribl_control_plane/errors/apierror.py +38 -0
  12. cribl_control_plane/errors/criblcontrolplaneerror.py +26 -0
  13. cribl_control_plane/errors/error.py +24 -0
  14. cribl_control_plane/errors/healthstatus_error.py +38 -0
  15. cribl_control_plane/errors/no_response_error.py +13 -0
  16. cribl_control_plane/errors/responsevalidationerror.py +25 -0
  17. cribl_control_plane/health.py +166 -0
  18. cribl_control_plane/httpclient.py +126 -0
  19. cribl_control_plane/models/__init__.py +7305 -0
  20. cribl_control_plane/models/addhectokenrequest.py +34 -0
  21. cribl_control_plane/models/authtoken.py +13 -0
  22. cribl_control_plane/models/createinputhectokenbyidop.py +45 -0
  23. cribl_control_plane/models/createinputop.py +24 -0
  24. cribl_control_plane/models/createoutputop.py +24 -0
  25. cribl_control_plane/models/createoutputtestbyidop.py +46 -0
  26. cribl_control_plane/models/criblevent.py +14 -0
  27. cribl_control_plane/models/deleteinputbyidop.py +37 -0
  28. cribl_control_plane/models/deleteoutputbyidop.py +37 -0
  29. cribl_control_plane/models/deleteoutputpqbyidop.py +36 -0
  30. cribl_control_plane/models/getinputbyidop.py +37 -0
  31. cribl_control_plane/models/getoutputbyidop.py +37 -0
  32. cribl_control_plane/models/getoutputpqbyidop.py +36 -0
  33. cribl_control_plane/models/getoutputsamplesbyidop.py +37 -0
  34. cribl_control_plane/models/healthstatus.py +36 -0
  35. cribl_control_plane/models/input.py +199 -0
  36. cribl_control_plane/models/inputappscope.py +448 -0
  37. cribl_control_plane/models/inputazureblob.py +308 -0
  38. cribl_control_plane/models/inputcollection.py +208 -0
  39. cribl_control_plane/models/inputconfluentcloud.py +585 -0
  40. cribl_control_plane/models/inputcribl.py +165 -0
  41. cribl_control_plane/models/inputcriblhttp.py +341 -0
  42. cribl_control_plane/models/inputcribllakehttp.py +342 -0
  43. cribl_control_plane/models/inputcriblmetrics.py +175 -0
  44. cribl_control_plane/models/inputcribltcp.py +299 -0
  45. cribl_control_plane/models/inputcrowdstrike.py +410 -0
  46. cribl_control_plane/models/inputdatadogagent.py +364 -0
  47. cribl_control_plane/models/inputdatagen.py +180 -0
  48. cribl_control_plane/models/inputedgeprometheus.py +551 -0
  49. cribl_control_plane/models/inputelastic.py +494 -0
  50. cribl_control_plane/models/inputeventhub.py +360 -0
  51. cribl_control_plane/models/inputexec.py +213 -0
  52. cribl_control_plane/models/inputfile.py +259 -0
  53. cribl_control_plane/models/inputfirehose.py +341 -0
  54. cribl_control_plane/models/inputgooglepubsub.py +247 -0
  55. cribl_control_plane/models/inputgrafana_union.py +1247 -0
  56. cribl_control_plane/models/inputhttp.py +403 -0
  57. cribl_control_plane/models/inputhttpraw.py +407 -0
  58. cribl_control_plane/models/inputjournalfiles.py +208 -0
  59. cribl_control_plane/models/inputkafka.py +581 -0
  60. cribl_control_plane/models/inputkinesis.py +363 -0
  61. cribl_control_plane/models/inputkubeevents.py +182 -0
  62. cribl_control_plane/models/inputkubelogs.py +256 -0
  63. cribl_control_plane/models/inputkubemetrics.py +233 -0
  64. cribl_control_plane/models/inputloki.py +468 -0
  65. cribl_control_plane/models/inputmetrics.py +290 -0
  66. cribl_control_plane/models/inputmodeldriventelemetry.py +274 -0
  67. cribl_control_plane/models/inputmsk.py +654 -0
  68. cribl_control_plane/models/inputnetflow.py +224 -0
  69. cribl_control_plane/models/inputoffice365mgmt.py +384 -0
  70. cribl_control_plane/models/inputoffice365msgtrace.py +449 -0
  71. cribl_control_plane/models/inputoffice365service.py +377 -0
  72. cribl_control_plane/models/inputopentelemetry.py +516 -0
  73. cribl_control_plane/models/inputprometheus.py +464 -0
  74. cribl_control_plane/models/inputprometheusrw.py +470 -0
  75. cribl_control_plane/models/inputrawudp.py +207 -0
  76. cribl_control_plane/models/inputs3.py +416 -0
  77. cribl_control_plane/models/inputs3inventory.py +440 -0
  78. cribl_control_plane/models/inputsecuritylake.py +425 -0
  79. cribl_control_plane/models/inputsnmp.py +274 -0
  80. cribl_control_plane/models/inputsplunk.py +387 -0
  81. cribl_control_plane/models/inputsplunkhec.py +478 -0
  82. cribl_control_plane/models/inputsplunksearch.py +537 -0
  83. cribl_control_plane/models/inputsqs.py +320 -0
  84. cribl_control_plane/models/inputsyslog_union.py +759 -0
  85. cribl_control_plane/models/inputsystemmetrics.py +533 -0
  86. cribl_control_plane/models/inputsystemstate.py +417 -0
  87. cribl_control_plane/models/inputtcp.py +359 -0
  88. cribl_control_plane/models/inputtcpjson.py +334 -0
  89. cribl_control_plane/models/inputwef.py +498 -0
  90. cribl_control_plane/models/inputwindowsmetrics.py +457 -0
  91. cribl_control_plane/models/inputwineventlogs.py +222 -0
  92. cribl_control_plane/models/inputwiz.py +334 -0
  93. cribl_control_plane/models/inputzscalerhec.py +439 -0
  94. cribl_control_plane/models/listinputop.py +24 -0
  95. cribl_control_plane/models/listoutputop.py +24 -0
  96. cribl_control_plane/models/logininfo.py +16 -0
  97. cribl_control_plane/models/output.py +229 -0
  98. cribl_control_plane/models/outputazureblob.py +471 -0
  99. cribl_control_plane/models/outputazuredataexplorer.py +660 -0
  100. cribl_control_plane/models/outputazureeventhub.py +321 -0
  101. cribl_control_plane/models/outputazurelogs.py +386 -0
  102. cribl_control_plane/models/outputclickhouse.py +650 -0
  103. cribl_control_plane/models/outputcloudwatch.py +273 -0
  104. cribl_control_plane/models/outputconfluentcloud.py +591 -0
  105. cribl_control_plane/models/outputcriblhttp.py +494 -0
  106. cribl_control_plane/models/outputcribllake.py +396 -0
  107. cribl_control_plane/models/outputcribltcp.py +387 -0
  108. cribl_control_plane/models/outputcrowdstrikenextgensiem.py +410 -0
  109. cribl_control_plane/models/outputdatadog.py +472 -0
  110. cribl_control_plane/models/outputdataset.py +437 -0
  111. cribl_control_plane/models/outputdefault.py +55 -0
  112. cribl_control_plane/models/outputdevnull.py +50 -0
  113. cribl_control_plane/models/outputdiskspool.py +89 -0
  114. cribl_control_plane/models/outputdls3.py +560 -0
  115. cribl_control_plane/models/outputdynatracehttp.py +454 -0
  116. cribl_control_plane/models/outputdynatraceotlp.py +486 -0
  117. cribl_control_plane/models/outputelastic.py +494 -0
  118. cribl_control_plane/models/outputelasticcloud.py +407 -0
  119. cribl_control_plane/models/outputexabeam.py +297 -0
  120. cribl_control_plane/models/outputfilesystem.py +357 -0
  121. cribl_control_plane/models/outputgooglechronicle.py +486 -0
  122. cribl_control_plane/models/outputgooglecloudlogging.py +557 -0
  123. cribl_control_plane/models/outputgooglecloudstorage.py +499 -0
  124. cribl_control_plane/models/outputgooglepubsub.py +274 -0
  125. cribl_control_plane/models/outputgrafanacloud_union.py +1024 -0
  126. cribl_control_plane/models/outputgraphite.py +225 -0
  127. cribl_control_plane/models/outputhoneycomb.py +369 -0
  128. cribl_control_plane/models/outputhumiohec.py +389 -0
  129. cribl_control_plane/models/outputinfluxdb.py +523 -0
  130. cribl_control_plane/models/outputkafka.py +581 -0
  131. cribl_control_plane/models/outputkinesis.py +312 -0
  132. cribl_control_plane/models/outputloki.py +425 -0
  133. cribl_control_plane/models/outputminio.py +512 -0
  134. cribl_control_plane/models/outputmsk.py +654 -0
  135. cribl_control_plane/models/outputnetflow.py +80 -0
  136. cribl_control_plane/models/outputnewrelic.py +424 -0
  137. cribl_control_plane/models/outputnewrelicevents.py +401 -0
  138. cribl_control_plane/models/outputopentelemetry.py +669 -0
  139. cribl_control_plane/models/outputprometheus.py +485 -0
  140. cribl_control_plane/models/outputring.py +121 -0
  141. cribl_control_plane/models/outputrouter.py +83 -0
  142. cribl_control_plane/models/outputs3.py +556 -0
  143. cribl_control_plane/models/outputsamplesresponse.py +14 -0
  144. cribl_control_plane/models/outputsecuritylake.py +505 -0
  145. cribl_control_plane/models/outputsentinel.py +488 -0
  146. cribl_control_plane/models/outputsentineloneaisiem.py +505 -0
  147. cribl_control_plane/models/outputservicenow.py +543 -0
  148. cribl_control_plane/models/outputsignalfx.py +369 -0
  149. cribl_control_plane/models/outputsnmp.py +80 -0
  150. cribl_control_plane/models/outputsns.py +274 -0
  151. cribl_control_plane/models/outputsplunk.py +383 -0
  152. cribl_control_plane/models/outputsplunkhec.py +434 -0
  153. cribl_control_plane/models/outputsplunklb.py +558 -0
  154. cribl_control_plane/models/outputsqs.py +328 -0
  155. cribl_control_plane/models/outputstatsd.py +224 -0
  156. cribl_control_plane/models/outputstatsdext.py +225 -0
  157. cribl_control_plane/models/outputsumologic.py +378 -0
  158. cribl_control_plane/models/outputsyslog.py +415 -0
  159. cribl_control_plane/models/outputtcpjson.py +413 -0
  160. cribl_control_plane/models/outputtestrequest.py +15 -0
  161. cribl_control_plane/models/outputtestresponse.py +29 -0
  162. cribl_control_plane/models/outputwavefront.py +369 -0
  163. cribl_control_plane/models/outputwebhook.py +689 -0
  164. cribl_control_plane/models/outputxsiam.py +415 -0
  165. cribl_control_plane/models/schemeclientoauth.py +24 -0
  166. cribl_control_plane/models/security.py +36 -0
  167. cribl_control_plane/models/updatehectokenrequest.py +31 -0
  168. cribl_control_plane/models/updateinputbyidop.py +44 -0
  169. cribl_control_plane/models/updateinputhectokenbyidandtokenop.py +52 -0
  170. cribl_control_plane/models/updateoutputbyidop.py +44 -0
  171. cribl_control_plane/outputs.py +1615 -0
  172. cribl_control_plane/py.typed +1 -0
  173. cribl_control_plane/sdk.py +164 -0
  174. cribl_control_plane/sdkconfiguration.py +36 -0
  175. cribl_control_plane/sources.py +1355 -0
  176. cribl_control_plane/types/__init__.py +21 -0
  177. cribl_control_plane/types/basemodel.py +39 -0
  178. cribl_control_plane/utils/__init__.py +187 -0
  179. cribl_control_plane/utils/annotations.py +55 -0
  180. cribl_control_plane/utils/datetimes.py +23 -0
  181. cribl_control_plane/utils/enums.py +74 -0
  182. cribl_control_plane/utils/eventstreaming.py +238 -0
  183. cribl_control_plane/utils/forms.py +223 -0
  184. cribl_control_plane/utils/headers.py +136 -0
  185. cribl_control_plane/utils/logger.py +27 -0
  186. cribl_control_plane/utils/metadata.py +118 -0
  187. cribl_control_plane/utils/queryparams.py +205 -0
  188. cribl_control_plane/utils/requestbodies.py +66 -0
  189. cribl_control_plane/utils/retries.py +217 -0
  190. cribl_control_plane/utils/security.py +207 -0
  191. cribl_control_plane/utils/serializers.py +249 -0
  192. cribl_control_plane/utils/unmarshal_json_response.py +24 -0
  193. cribl_control_plane/utils/url.py +155 -0
  194. cribl_control_plane/utils/values.py +137 -0
  195. cribl_control_plane-0.0.13.dist-info/METADATA +489 -0
  196. cribl_control_plane-0.0.13.dist-info/RECORD +197 -0
  197. cribl_control_plane-0.0.13.dist-info/WHEEL +4 -0
@@ -0,0 +1,21 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basemodel import (
4
+ BaseModel,
5
+ Nullable,
6
+ OptionalNullable,
7
+ UnrecognizedInt,
8
+ UnrecognizedStr,
9
+ UNSET,
10
+ UNSET_SENTINEL,
11
+ )
12
+
13
+ __all__ = [
14
+ "BaseModel",
15
+ "Nullable",
16
+ "OptionalNullable",
17
+ "UnrecognizedInt",
18
+ "UnrecognizedStr",
19
+ "UNSET",
20
+ "UNSET_SENTINEL",
21
+ ]
@@ -0,0 +1,39 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from pydantic import ConfigDict, model_serializer
4
+ from pydantic import BaseModel as PydanticBaseModel
5
+ from typing import TYPE_CHECKING, Literal, Optional, TypeVar, Union
6
+ from typing_extensions import TypeAliasType, TypeAlias
7
+
8
+
9
+ class BaseModel(PydanticBaseModel):
10
+ model_config = ConfigDict(
11
+ populate_by_name=True, arbitrary_types_allowed=True, protected_namespaces=()
12
+ )
13
+
14
+
15
+ class Unset(BaseModel):
16
+ @model_serializer(mode="plain")
17
+ def serialize_model(self):
18
+ return UNSET_SENTINEL
19
+
20
+ def __bool__(self) -> Literal[False]:
21
+ return False
22
+
23
+
24
+ UNSET = Unset()
25
+ UNSET_SENTINEL = "~?~unset~?~sentinel~?~"
26
+
27
+
28
+ T = TypeVar("T")
29
+ if TYPE_CHECKING:
30
+ Nullable: TypeAlias = Union[T, None]
31
+ OptionalNullable: TypeAlias = Union[Optional[Nullable[T]], Unset]
32
+ else:
33
+ Nullable = TypeAliasType("Nullable", Union[T, None], type_params=(T,))
34
+ OptionalNullable = TypeAliasType(
35
+ "OptionalNullable", Union[Optional[Nullable[T]], Unset], type_params=(T,)
36
+ )
37
+
38
+ UnrecognizedInt: TypeAlias = int
39
+ UnrecognizedStr: TypeAlias = str
@@ -0,0 +1,187 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from typing import TYPE_CHECKING
4
+ from importlib import import_module
5
+
6
+ if TYPE_CHECKING:
7
+ from .annotations import get_discriminator
8
+ from .datetimes import parse_datetime
9
+ from .enums import OpenEnumMeta
10
+ from .headers import get_headers, get_response_headers
11
+ from .metadata import (
12
+ FieldMetadata,
13
+ find_metadata,
14
+ FormMetadata,
15
+ HeaderMetadata,
16
+ MultipartFormMetadata,
17
+ PathParamMetadata,
18
+ QueryParamMetadata,
19
+ RequestMetadata,
20
+ SecurityMetadata,
21
+ )
22
+ from .queryparams import get_query_params
23
+ from .retries import BackoffStrategy, Retries, retry, retry_async, RetryConfig
24
+ from .requestbodies import serialize_request_body, SerializedRequestBody
25
+ from .security import get_security, get_security_from_env
26
+
27
+ from .serializers import (
28
+ get_pydantic_model,
29
+ marshal_json,
30
+ unmarshal,
31
+ unmarshal_json,
32
+ serialize_decimal,
33
+ serialize_float,
34
+ serialize_int,
35
+ stream_to_text,
36
+ stream_to_text_async,
37
+ stream_to_bytes,
38
+ stream_to_bytes_async,
39
+ validate_const,
40
+ validate_decimal,
41
+ validate_float,
42
+ validate_int,
43
+ validate_open_enum,
44
+ )
45
+ from .url import generate_url, template_url, remove_suffix
46
+ from .values import (
47
+ get_global_from_env,
48
+ match_content_type,
49
+ match_status_codes,
50
+ match_response,
51
+ cast_partial,
52
+ )
53
+ from .logger import Logger, get_body_content, get_default_logger
54
+
55
+ __all__ = [
56
+ "BackoffStrategy",
57
+ "FieldMetadata",
58
+ "find_metadata",
59
+ "FormMetadata",
60
+ "generate_url",
61
+ "get_body_content",
62
+ "get_default_logger",
63
+ "get_discriminator",
64
+ "parse_datetime",
65
+ "get_global_from_env",
66
+ "get_headers",
67
+ "get_pydantic_model",
68
+ "get_query_params",
69
+ "get_response_headers",
70
+ "get_security",
71
+ "get_security_from_env",
72
+ "HeaderMetadata",
73
+ "Logger",
74
+ "marshal_json",
75
+ "match_content_type",
76
+ "match_status_codes",
77
+ "match_response",
78
+ "MultipartFormMetadata",
79
+ "OpenEnumMeta",
80
+ "PathParamMetadata",
81
+ "QueryParamMetadata",
82
+ "remove_suffix",
83
+ "Retries",
84
+ "retry",
85
+ "retry_async",
86
+ "RetryConfig",
87
+ "RequestMetadata",
88
+ "SecurityMetadata",
89
+ "serialize_decimal",
90
+ "serialize_float",
91
+ "serialize_int",
92
+ "serialize_request_body",
93
+ "SerializedRequestBody",
94
+ "stream_to_text",
95
+ "stream_to_text_async",
96
+ "stream_to_bytes",
97
+ "stream_to_bytes_async",
98
+ "template_url",
99
+ "unmarshal",
100
+ "unmarshal_json",
101
+ "validate_decimal",
102
+ "validate_const",
103
+ "validate_float",
104
+ "validate_int",
105
+ "validate_open_enum",
106
+ "cast_partial",
107
+ ]
108
+
109
+ _dynamic_imports: dict[str, str] = {
110
+ "BackoffStrategy": ".retries",
111
+ "FieldMetadata": ".metadata",
112
+ "find_metadata": ".metadata",
113
+ "FormMetadata": ".metadata",
114
+ "generate_url": ".url",
115
+ "get_body_content": ".logger",
116
+ "get_default_logger": ".logger",
117
+ "get_discriminator": ".annotations",
118
+ "parse_datetime": ".datetimes",
119
+ "get_global_from_env": ".values",
120
+ "get_headers": ".headers",
121
+ "get_pydantic_model": ".serializers",
122
+ "get_query_params": ".queryparams",
123
+ "get_response_headers": ".headers",
124
+ "get_security": ".security",
125
+ "get_security_from_env": ".security",
126
+ "HeaderMetadata": ".metadata",
127
+ "Logger": ".logger",
128
+ "marshal_json": ".serializers",
129
+ "match_content_type": ".values",
130
+ "match_status_codes": ".values",
131
+ "match_response": ".values",
132
+ "MultipartFormMetadata": ".metadata",
133
+ "OpenEnumMeta": ".enums",
134
+ "PathParamMetadata": ".metadata",
135
+ "QueryParamMetadata": ".metadata",
136
+ "remove_suffix": ".url",
137
+ "Retries": ".retries",
138
+ "retry": ".retries",
139
+ "retry_async": ".retries",
140
+ "RetryConfig": ".retries",
141
+ "RequestMetadata": ".metadata",
142
+ "SecurityMetadata": ".metadata",
143
+ "serialize_decimal": ".serializers",
144
+ "serialize_float": ".serializers",
145
+ "serialize_int": ".serializers",
146
+ "serialize_request_body": ".requestbodies",
147
+ "SerializedRequestBody": ".requestbodies",
148
+ "stream_to_text": ".serializers",
149
+ "stream_to_text_async": ".serializers",
150
+ "stream_to_bytes": ".serializers",
151
+ "stream_to_bytes_async": ".serializers",
152
+ "template_url": ".url",
153
+ "unmarshal": ".serializers",
154
+ "unmarshal_json": ".serializers",
155
+ "validate_decimal": ".serializers",
156
+ "validate_const": ".serializers",
157
+ "validate_float": ".serializers",
158
+ "validate_int": ".serializers",
159
+ "validate_open_enum": ".serializers",
160
+ "cast_partial": ".values",
161
+ }
162
+
163
+
164
+ def __getattr__(attr_name: str) -> object:
165
+ module_name = _dynamic_imports.get(attr_name)
166
+ if module_name is None:
167
+ raise AttributeError(
168
+ f"no {attr_name} found in _dynamic_imports, module name -> {__name__} "
169
+ )
170
+
171
+ try:
172
+ module = import_module(module_name, __package__)
173
+ result = getattr(module, attr_name)
174
+ return result
175
+ except ImportError as e:
176
+ raise ImportError(
177
+ f"Failed to import {attr_name} from {module_name}: {e}"
178
+ ) from e
179
+ except AttributeError as e:
180
+ raise AttributeError(
181
+ f"Failed to get {attr_name} from {module_name}: {e}"
182
+ ) from e
183
+
184
+
185
+ def __dir__():
186
+ lazy_attrs = list(_dynamic_imports.keys())
187
+ return sorted(lazy_attrs)
@@ -0,0 +1,55 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from enum import Enum
4
+ from typing import Any, Optional
5
+
6
+ def get_discriminator(model: Any, fieldname: str, key: str) -> str:
7
+ """
8
+ Recursively search for the discriminator attribute in a model.
9
+
10
+ Args:
11
+ model (Any): The model to search within.
12
+ fieldname (str): The name of the field to search for.
13
+ key (str): The key to search for in dictionaries.
14
+
15
+ Returns:
16
+ str: The name of the discriminator attribute.
17
+
18
+ Raises:
19
+ ValueError: If the discriminator attribute is not found.
20
+ """
21
+ upper_fieldname = fieldname.upper()
22
+
23
+ def get_field_discriminator(field: Any) -> Optional[str]:
24
+ """Search for the discriminator attribute in a given field."""
25
+
26
+ if isinstance(field, dict):
27
+ if key in field:
28
+ return f'{field[key]}'
29
+
30
+ if hasattr(field, fieldname):
31
+ attr = getattr(field, fieldname)
32
+ if isinstance(attr, Enum):
33
+ return f'{attr.value}'
34
+ return f'{attr}'
35
+
36
+ if hasattr(field, upper_fieldname):
37
+ attr = getattr(field, upper_fieldname)
38
+ if isinstance(attr, Enum):
39
+ return f'{attr.value}'
40
+ return f'{attr}'
41
+
42
+ return None
43
+
44
+
45
+ if isinstance(model, list):
46
+ for field in model:
47
+ discriminator = get_field_discriminator(field)
48
+ if discriminator is not None:
49
+ return discriminator
50
+
51
+ discriminator = get_field_discriminator(model)
52
+ if discriminator is not None:
53
+ return discriminator
54
+
55
+ raise ValueError(f'Could not find discriminator field {fieldname} in {model}')
@@ -0,0 +1,23 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from datetime import datetime
4
+ import sys
5
+
6
+
7
+ def parse_datetime(datetime_string: str) -> datetime:
8
+ """
9
+ Convert a RFC 3339 / ISO 8601 formatted string into a datetime object.
10
+ Python versions 3.11 and later support parsing RFC 3339 directly with
11
+ datetime.fromisoformat(), but for earlier versions, this function
12
+ encapsulates the necessary extra logic.
13
+ """
14
+ # Python 3.11 and later can parse RFC 3339 directly
15
+ if sys.version_info >= (3, 11):
16
+ return datetime.fromisoformat(datetime_string)
17
+
18
+ # For Python 3.10 and earlier, a common ValueError is trailing 'Z' suffix,
19
+ # so fix that upfront.
20
+ if datetime_string.endswith("Z"):
21
+ datetime_string = datetime_string[:-1] + "+00:00"
22
+
23
+ return datetime.fromisoformat(datetime_string)
@@ -0,0 +1,74 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ import enum
4
+ import sys
5
+
6
+ class OpenEnumMeta(enum.EnumMeta):
7
+ # The __call__ method `boundary` kwarg was added in 3.11 and must be present
8
+ # for pyright. Refer also: https://github.com/pylint-dev/pylint/issues/9622
9
+ # pylint: disable=unexpected-keyword-arg
10
+ # The __call__ method `values` varg must be named for pyright.
11
+ # pylint: disable=keyword-arg-before-vararg
12
+
13
+ if sys.version_info >= (3, 11):
14
+ def __call__(
15
+ cls, value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None
16
+ ):
17
+ # The `type` kwarg also happens to be a built-in that pylint flags as
18
+ # redeclared. Safe to ignore this lint rule with this scope.
19
+ # pylint: disable=redefined-builtin
20
+
21
+ if names is not None:
22
+ return super().__call__(
23
+ value,
24
+ names=names,
25
+ *values,
26
+ module=module,
27
+ qualname=qualname,
28
+ type=type,
29
+ start=start,
30
+ boundary=boundary,
31
+ )
32
+
33
+ try:
34
+ return super().__call__(
35
+ value,
36
+ names=names, # pyright: ignore[reportArgumentType]
37
+ *values,
38
+ module=module,
39
+ qualname=qualname,
40
+ type=type,
41
+ start=start,
42
+ boundary=boundary,
43
+ )
44
+ except ValueError:
45
+ return value
46
+ else:
47
+ def __call__(
48
+ cls, value, names=None, *, module=None, qualname=None, type=None, start=1
49
+ ):
50
+ # The `type` kwarg also happens to be a built-in that pylint flags as
51
+ # redeclared. Safe to ignore this lint rule with this scope.
52
+ # pylint: disable=redefined-builtin
53
+
54
+ if names is not None:
55
+ return super().__call__(
56
+ value,
57
+ names=names,
58
+ module=module,
59
+ qualname=qualname,
60
+ type=type,
61
+ start=start,
62
+ )
63
+
64
+ try:
65
+ return super().__call__(
66
+ value,
67
+ names=names, # pyright: ignore[reportArgumentType]
68
+ module=module,
69
+ qualname=qualname,
70
+ type=type,
71
+ start=start,
72
+ )
73
+ except ValueError:
74
+ return value
@@ -0,0 +1,238 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ import re
4
+ import json
5
+ from typing import (
6
+ Callable,
7
+ Generic,
8
+ TypeVar,
9
+ Optional,
10
+ Generator,
11
+ AsyncGenerator,
12
+ Tuple,
13
+ )
14
+ import httpx
15
+
16
+ T = TypeVar("T")
17
+
18
+
19
+ class EventStream(Generic[T]):
20
+ response: httpx.Response
21
+ generator: Generator[T, None, None]
22
+
23
+ def __init__(
24
+ self,
25
+ response: httpx.Response,
26
+ decoder: Callable[[str], T],
27
+ sentinel: Optional[str] = None,
28
+ ):
29
+ self.response = response
30
+ self.generator = stream_events(response, decoder, sentinel)
31
+
32
+ def __iter__(self):
33
+ return self
34
+
35
+ def __next__(self):
36
+ return next(self.generator)
37
+
38
+ def __enter__(self):
39
+ return self
40
+
41
+ def __exit__(self, exc_type, exc_val, exc_tb):
42
+ self.response.close()
43
+
44
+
45
+ class EventStreamAsync(Generic[T]):
46
+ response: httpx.Response
47
+ generator: AsyncGenerator[T, None]
48
+
49
+ def __init__(
50
+ self,
51
+ response: httpx.Response,
52
+ decoder: Callable[[str], T],
53
+ sentinel: Optional[str] = None,
54
+ ):
55
+ self.response = response
56
+ self.generator = stream_events_async(response, decoder, sentinel)
57
+
58
+ def __aiter__(self):
59
+ return self
60
+
61
+ async def __anext__(self):
62
+ return await self.generator.__anext__()
63
+
64
+ async def __aenter__(self):
65
+ return self
66
+
67
+ async def __aexit__(self, exc_type, exc_val, exc_tb):
68
+ await self.response.aclose()
69
+
70
+
71
+ class ServerEvent:
72
+ id: Optional[str] = None
73
+ event: Optional[str] = None
74
+ data: Optional[str] = None
75
+ retry: Optional[int] = None
76
+
77
+
78
+ MESSAGE_BOUNDARIES = [
79
+ b"\r\n\r\n",
80
+ b"\n\n",
81
+ b"\r\r",
82
+ ]
83
+
84
+
85
+ async def stream_events_async(
86
+ response: httpx.Response,
87
+ decoder: Callable[[str], T],
88
+ sentinel: Optional[str] = None,
89
+ ) -> AsyncGenerator[T, None]:
90
+ buffer = bytearray()
91
+ position = 0
92
+ discard = False
93
+ async for chunk in response.aiter_bytes():
94
+ # We've encountered the sentinel value and should no longer process
95
+ # incoming data. Instead we throw new data away until the server closes
96
+ # the connection.
97
+ if discard:
98
+ continue
99
+
100
+ buffer += chunk
101
+ for i in range(position, len(buffer)):
102
+ char = buffer[i : i + 1]
103
+ seq: Optional[bytes] = None
104
+ if char in [b"\r", b"\n"]:
105
+ for boundary in MESSAGE_BOUNDARIES:
106
+ seq = _peek_sequence(i, buffer, boundary)
107
+ if seq is not None:
108
+ break
109
+ if seq is None:
110
+ continue
111
+
112
+ block = buffer[position:i]
113
+ position = i + len(seq)
114
+ event, discard = _parse_event(block, decoder, sentinel)
115
+ if event is not None:
116
+ yield event
117
+
118
+ if position > 0:
119
+ buffer = buffer[position:]
120
+ position = 0
121
+
122
+ event, discard = _parse_event(buffer, decoder, sentinel)
123
+ if event is not None:
124
+ yield event
125
+
126
+
127
+ def stream_events(
128
+ response: httpx.Response,
129
+ decoder: Callable[[str], T],
130
+ sentinel: Optional[str] = None,
131
+ ) -> Generator[T, None, None]:
132
+ buffer = bytearray()
133
+ position = 0
134
+ discard = False
135
+ for chunk in response.iter_bytes():
136
+ # We've encountered the sentinel value and should no longer process
137
+ # incoming data. Instead we throw new data away until the server closes
138
+ # the connection.
139
+ if discard:
140
+ continue
141
+
142
+ buffer += chunk
143
+ for i in range(position, len(buffer)):
144
+ char = buffer[i : i + 1]
145
+ seq: Optional[bytes] = None
146
+ if char in [b"\r", b"\n"]:
147
+ for boundary in MESSAGE_BOUNDARIES:
148
+ seq = _peek_sequence(i, buffer, boundary)
149
+ if seq is not None:
150
+ break
151
+ if seq is None:
152
+ continue
153
+
154
+ block = buffer[position:i]
155
+ position = i + len(seq)
156
+ event, discard = _parse_event(block, decoder, sentinel)
157
+ if event is not None:
158
+ yield event
159
+
160
+ if position > 0:
161
+ buffer = buffer[position:]
162
+ position = 0
163
+
164
+ event, discard = _parse_event(buffer, decoder, sentinel)
165
+ if event is not None:
166
+ yield event
167
+
168
+
169
+ def _parse_event(
170
+ raw: bytearray, decoder: Callable[[str], T], sentinel: Optional[str] = None
171
+ ) -> Tuple[Optional[T], bool]:
172
+ block = raw.decode()
173
+ lines = re.split(r"\r?\n|\r", block)
174
+ publish = False
175
+ event = ServerEvent()
176
+ data = ""
177
+ for line in lines:
178
+ if not line:
179
+ continue
180
+
181
+ delim = line.find(":")
182
+ if delim <= 0:
183
+ continue
184
+
185
+ field = line[0:delim]
186
+ value = line[delim + 1 :] if delim < len(line) - 1 else ""
187
+ if len(value) and value[0] == " ":
188
+ value = value[1:]
189
+
190
+ if field == "event":
191
+ event.event = value
192
+ publish = True
193
+ elif field == "data":
194
+ data += value + "\n"
195
+ publish = True
196
+ elif field == "id":
197
+ event.id = value
198
+ publish = True
199
+ elif field == "retry":
200
+ event.retry = int(value) if value.isdigit() else None
201
+ publish = True
202
+
203
+ if sentinel and data == f"{sentinel}\n":
204
+ return None, True
205
+
206
+ if data:
207
+ data = data[:-1]
208
+ event.data = data
209
+
210
+ data_is_primitive = (
211
+ data.isnumeric() or data == "true" or data == "false" or data == "null"
212
+ )
213
+ data_is_json = (
214
+ data.startswith("{") or data.startswith("[") or data.startswith('"')
215
+ )
216
+
217
+ if data_is_primitive or data_is_json:
218
+ try:
219
+ event.data = json.loads(data)
220
+ except Exception:
221
+ pass
222
+
223
+ out = None
224
+ if publish:
225
+ out = decoder(json.dumps(event.__dict__))
226
+
227
+ return out, False
228
+
229
+
230
+ def _peek_sequence(position: int, buffer: bytearray, sequence: bytes):
231
+ if len(sequence) > (len(buffer) - position):
232
+ return None
233
+
234
+ for i, seq in enumerate(sequence):
235
+ if buffer[position + i] != seq:
236
+ return None
237
+
238
+ return sequence