mirascope 2.0.0a4__py3-none-any.whl → 2.0.0a6__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 (215) hide show
  1. mirascope/__init__.py +10 -1
  2. mirascope/_stubs.py +363 -0
  3. mirascope/api/__init__.py +8 -0
  4. mirascope/api/_generated/__init__.py +119 -1
  5. mirascope/api/_generated/annotations/__init__.py +33 -0
  6. mirascope/api/_generated/annotations/client.py +474 -0
  7. mirascope/api/_generated/annotations/raw_client.py +1095 -0
  8. mirascope/api/_generated/annotations/types/__init__.py +31 -0
  9. mirascope/api/_generated/annotations/types/annotations_create_request_label.py +5 -0
  10. mirascope/api/_generated/annotations/types/annotations_create_response.py +35 -0
  11. mirascope/api/_generated/annotations/types/annotations_create_response_label.py +5 -0
  12. mirascope/api/_generated/annotations/types/annotations_get_response.py +35 -0
  13. mirascope/api/_generated/annotations/types/annotations_get_response_label.py +5 -0
  14. mirascope/api/_generated/annotations/types/annotations_list_request_label.py +5 -0
  15. mirascope/api/_generated/annotations/types/annotations_list_response.py +21 -0
  16. mirascope/api/_generated/annotations/types/annotations_list_response_annotations_item.py +35 -0
  17. mirascope/api/_generated/annotations/types/annotations_list_response_annotations_item_label.py +5 -0
  18. mirascope/api/_generated/annotations/types/annotations_update_request_label.py +5 -0
  19. mirascope/api/_generated/annotations/types/annotations_update_response.py +35 -0
  20. mirascope/api/_generated/annotations/types/annotations_update_response_label.py +5 -0
  21. mirascope/api/_generated/api_keys/__init__.py +7 -0
  22. mirascope/api/_generated/api_keys/client.py +429 -0
  23. mirascope/api/_generated/api_keys/raw_client.py +788 -0
  24. mirascope/api/_generated/api_keys/types/__init__.py +9 -0
  25. mirascope/api/_generated/api_keys/types/api_keys_create_response.py +28 -0
  26. mirascope/api/_generated/api_keys/types/api_keys_get_response.py +27 -0
  27. mirascope/api/_generated/api_keys/types/api_keys_list_response_item.py +27 -0
  28. mirascope/api/_generated/client.py +12 -0
  29. mirascope/api/_generated/core/client_wrapper.py +2 -14
  30. mirascope/api/_generated/core/datetime_utils.py +1 -3
  31. mirascope/api/_generated/core/file.py +2 -5
  32. mirascope/api/_generated/core/http_client.py +36 -112
  33. mirascope/api/_generated/core/jsonable_encoder.py +1 -3
  34. mirascope/api/_generated/core/pydantic_utilities.py +19 -74
  35. mirascope/api/_generated/core/query_encoder.py +1 -3
  36. mirascope/api/_generated/core/serialization.py +4 -10
  37. mirascope/api/_generated/docs/client.py +2 -6
  38. mirascope/api/_generated/docs/raw_client.py +4 -20
  39. mirascope/api/_generated/environments/__init__.py +17 -0
  40. mirascope/api/_generated/environments/client.py +500 -0
  41. mirascope/api/_generated/environments/raw_client.py +999 -0
  42. mirascope/api/_generated/environments/types/__init__.py +15 -0
  43. mirascope/api/_generated/environments/types/environments_create_response.py +24 -0
  44. mirascope/api/_generated/environments/types/environments_get_response.py +24 -0
  45. mirascope/api/_generated/environments/types/environments_list_response_item.py +24 -0
  46. mirascope/api/_generated/environments/types/environments_update_response.py +24 -0
  47. mirascope/api/_generated/errors/__init__.py +2 -0
  48. mirascope/api/_generated/errors/bad_request_error.py +1 -5
  49. mirascope/api/_generated/errors/conflict_error.py +1 -5
  50. mirascope/api/_generated/errors/forbidden_error.py +1 -5
  51. mirascope/api/_generated/errors/internal_server_error.py +1 -6
  52. mirascope/api/_generated/errors/not_found_error.py +1 -5
  53. mirascope/api/_generated/errors/unauthorized_error.py +11 -0
  54. mirascope/api/_generated/functions/__init__.py +29 -0
  55. mirascope/api/_generated/functions/client.py +433 -0
  56. mirascope/api/_generated/functions/raw_client.py +1049 -0
  57. mirascope/api/_generated/functions/types/__init__.py +29 -0
  58. mirascope/api/_generated/functions/types/functions_create_request_dependencies_value.py +20 -0
  59. mirascope/api/_generated/functions/types/functions_create_response.py +37 -0
  60. mirascope/api/_generated/functions/types/functions_create_response_dependencies_value.py +20 -0
  61. mirascope/api/_generated/functions/types/functions_find_by_hash_response.py +39 -0
  62. mirascope/api/_generated/functions/types/functions_find_by_hash_response_dependencies_value.py +20 -0
  63. mirascope/api/_generated/functions/types/functions_get_response.py +37 -0
  64. mirascope/api/_generated/functions/types/functions_get_response_dependencies_value.py +20 -0
  65. mirascope/api/_generated/functions/types/functions_list_response.py +21 -0
  66. mirascope/api/_generated/functions/types/functions_list_response_functions_item.py +41 -0
  67. mirascope/api/_generated/functions/types/functions_list_response_functions_item_dependencies_value.py +20 -0
  68. mirascope/api/_generated/health/client.py +2 -6
  69. mirascope/api/_generated/health/raw_client.py +5 -23
  70. mirascope/api/_generated/health/types/health_check_response.py +1 -3
  71. mirascope/api/_generated/organizations/__init__.py +2 -0
  72. mirascope/api/_generated/organizations/client.py +94 -27
  73. mirascope/api/_generated/organizations/raw_client.py +246 -128
  74. mirascope/api/_generated/organizations/types/__init__.py +2 -0
  75. mirascope/api/_generated/organizations/types/organizations_create_response.py +5 -3
  76. mirascope/api/_generated/organizations/types/organizations_create_response_role.py +1 -3
  77. mirascope/api/_generated/organizations/types/organizations_credits_response.py +19 -0
  78. mirascope/api/_generated/organizations/types/organizations_get_response.py +5 -3
  79. mirascope/api/_generated/organizations/types/organizations_get_response_role.py +1 -3
  80. mirascope/api/_generated/organizations/types/organizations_list_response_item.py +5 -3
  81. mirascope/api/_generated/organizations/types/organizations_list_response_item_role.py +1 -3
  82. mirascope/api/_generated/organizations/types/organizations_update_response.py +5 -3
  83. mirascope/api/_generated/organizations/types/organizations_update_response_role.py +1 -3
  84. mirascope/api/_generated/projects/__init__.py +2 -12
  85. mirascope/api/_generated/projects/client.py +38 -68
  86. mirascope/api/_generated/projects/raw_client.py +92 -163
  87. mirascope/api/_generated/projects/types/__init__.py +1 -6
  88. mirascope/api/_generated/projects/types/projects_create_response.py +4 -9
  89. mirascope/api/_generated/projects/types/projects_get_response.py +4 -9
  90. mirascope/api/_generated/projects/types/projects_list_response_item.py +4 -9
  91. mirascope/api/_generated/projects/types/projects_update_response.py +4 -9
  92. mirascope/api/_generated/reference.md +1862 -70
  93. mirascope/api/_generated/traces/__init__.py +22 -0
  94. mirascope/api/_generated/traces/client.py +398 -0
  95. mirascope/api/_generated/traces/raw_client.py +902 -18
  96. mirascope/api/_generated/traces/types/__init__.py +32 -0
  97. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item.py +4 -11
  98. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource.py +2 -6
  99. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item.py +1 -3
  100. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value.py +8 -24
  101. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_array_value.py +2 -6
  102. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value.py +3 -9
  103. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value_values_item.py +2 -6
  104. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item.py +3 -9
  105. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope.py +4 -8
  106. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item.py +2 -6
  107. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value.py +8 -24
  108. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_array_value.py +2 -6
  109. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value.py +3 -9
  110. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value_values_item.py +1 -3
  111. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item.py +6 -18
  112. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item.py +3 -9
  113. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value.py +8 -24
  114. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_array_value.py +2 -6
  115. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value.py +2 -6
  116. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value_values_item.py +1 -3
  117. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_status.py +2 -6
  118. mirascope/api/_generated/traces/types/traces_create_response.py +2 -5
  119. mirascope/api/_generated/traces/types/traces_create_response_partial_success.py +3 -9
  120. mirascope/api/_generated/traces/types/traces_get_analytics_summary_response.py +54 -0
  121. mirascope/api/_generated/traces/types/traces_get_analytics_summary_response_top_functions_item.py +24 -0
  122. mirascope/api/_generated/traces/types/traces_get_analytics_summary_response_top_models_item.py +22 -0
  123. mirascope/api/_generated/traces/types/traces_get_trace_detail_response.py +33 -0
  124. mirascope/api/_generated/traces/types/traces_get_trace_detail_response_spans_item.py +90 -0
  125. mirascope/api/_generated/traces/types/traces_search_request_attribute_filters_item.py +26 -0
  126. mirascope/api/_generated/traces/types/traces_search_request_attribute_filters_item_operator.py +7 -0
  127. mirascope/api/_generated/traces/types/traces_search_request_sort_by.py +7 -0
  128. mirascope/api/_generated/traces/types/traces_search_request_sort_order.py +5 -0
  129. mirascope/api/_generated/traces/types/traces_search_response.py +26 -0
  130. mirascope/api/_generated/traces/types/traces_search_response_spans_item.py +41 -0
  131. mirascope/api/_generated/types/__init__.py +18 -0
  132. mirascope/api/_generated/types/already_exists_error.py +1 -3
  133. mirascope/api/_generated/types/click_house_error.py +22 -0
  134. mirascope/api/_generated/types/database_error.py +1 -3
  135. mirascope/api/_generated/types/http_api_decode_error.py +1 -3
  136. mirascope/api/_generated/types/internal_server_error_body.py +49 -0
  137. mirascope/api/_generated/types/issue.py +1 -3
  138. mirascope/api/_generated/types/issue_tag.py +1 -8
  139. mirascope/api/_generated/types/not_found_error_body.py +1 -3
  140. mirascope/api/_generated/types/number_from_string.py +3 -0
  141. mirascope/api/_generated/types/permission_denied_error.py +1 -3
  142. mirascope/api/_generated/types/permission_denied_error_tag.py +1 -3
  143. mirascope/api/_generated/types/property_key_key.py +1 -3
  144. mirascope/api/_generated/types/stripe_error.py +20 -0
  145. mirascope/api/_generated/types/unauthorized_error_body.py +21 -0
  146. mirascope/api/_generated/types/unauthorized_error_tag.py +5 -0
  147. mirascope/llm/__init__.py +6 -2
  148. mirascope/llm/content/tool_call.py +6 -0
  149. mirascope/llm/exceptions.py +28 -0
  150. mirascope/llm/formatting/__init__.py +2 -2
  151. mirascope/llm/formatting/format.py +120 -8
  152. mirascope/llm/formatting/types.py +1 -56
  153. mirascope/llm/mcp/__init__.py +2 -2
  154. mirascope/llm/mcp/mcp_client.py +130 -0
  155. mirascope/llm/providers/__init__.py +26 -5
  156. mirascope/llm/providers/anthropic/__init__.py +3 -21
  157. mirascope/llm/providers/anthropic/_utils/__init__.py +2 -0
  158. mirascope/llm/providers/anthropic/_utils/beta_decode.py +4 -2
  159. mirascope/llm/providers/anthropic/_utils/beta_encode.py +13 -12
  160. mirascope/llm/providers/anthropic/_utils/decode.py +4 -2
  161. mirascope/llm/providers/anthropic/_utils/encode.py +57 -14
  162. mirascope/llm/providers/anthropic/_utils/errors.py +46 -0
  163. mirascope/llm/providers/anthropic/beta_provider.py +6 -0
  164. mirascope/llm/providers/anthropic/provider.py +5 -0
  165. mirascope/llm/providers/base/__init__.py +5 -2
  166. mirascope/llm/providers/base/_utils.py +2 -7
  167. mirascope/llm/providers/base/base_provider.py +173 -58
  168. mirascope/llm/providers/base/params.py +63 -34
  169. mirascope/llm/providers/google/__init__.py +2 -17
  170. mirascope/llm/providers/google/_utils/__init__.py +2 -0
  171. mirascope/llm/providers/google/_utils/decode.py +17 -8
  172. mirascope/llm/providers/google/_utils/encode.py +105 -16
  173. mirascope/llm/providers/google/_utils/errors.py +49 -0
  174. mirascope/llm/providers/google/model_info.py +1 -0
  175. mirascope/llm/providers/google/provider.py +9 -5
  176. mirascope/llm/providers/mirascope/__init__.py +5 -0
  177. mirascope/llm/providers/mirascope/_utils.py +77 -0
  178. mirascope/llm/providers/mirascope/provider.py +318 -0
  179. mirascope/llm/providers/mlx/__init__.py +2 -17
  180. mirascope/llm/providers/mlx/_utils.py +9 -2
  181. mirascope/llm/providers/mlx/provider.py +8 -0
  182. mirascope/llm/providers/ollama/__init__.py +1 -13
  183. mirascope/llm/providers/openai/__init__.py +10 -1
  184. mirascope/llm/providers/openai/_utils/__init__.py +5 -0
  185. mirascope/llm/providers/openai/_utils/errors.py +46 -0
  186. mirascope/llm/providers/openai/completions/__init__.py +2 -20
  187. mirascope/llm/providers/openai/completions/_utils/decode.py +14 -3
  188. mirascope/llm/providers/openai/completions/_utils/encode.py +15 -12
  189. mirascope/llm/providers/openai/completions/base_provider.py +6 -6
  190. mirascope/llm/providers/openai/provider.py +14 -1
  191. mirascope/llm/providers/openai/responses/__init__.py +1 -17
  192. mirascope/llm/providers/openai/responses/_utils/decode.py +2 -2
  193. mirascope/llm/providers/openai/responses/_utils/encode.py +43 -15
  194. mirascope/llm/providers/openai/responses/provider.py +13 -7
  195. mirascope/llm/providers/provider_id.py +1 -0
  196. mirascope/llm/providers/provider_registry.py +59 -3
  197. mirascope/llm/providers/together/__init__.py +1 -13
  198. mirascope/llm/responses/base_stream_response.py +24 -20
  199. mirascope/llm/tools/decorator.py +8 -4
  200. mirascope/llm/tools/tool_schema.py +33 -6
  201. mirascope/llm/tools/tools.py +84 -16
  202. mirascope/ops/__init__.py +60 -109
  203. mirascope/ops/_internal/closure.py +62 -11
  204. mirascope/ops/_internal/instrumentation/llm/llm.py +1 -2
  205. mirascope/ops/_internal/traced_functions.py +23 -4
  206. mirascope/ops/_internal/versioned_functions.py +54 -43
  207. {mirascope-2.0.0a4.dist-info → mirascope-2.0.0a6.dist-info}/METADATA +7 -7
  208. mirascope-2.0.0a6.dist-info/RECORD +316 -0
  209. mirascope/llm/formatting/_utils.py +0 -78
  210. mirascope/llm/mcp/client.py +0 -118
  211. mirascope/llm/providers/_missing_import_stubs.py +0 -49
  212. mirascope/llm/providers/load_provider.py +0 -54
  213. mirascope-2.0.0a4.dist-info/RECORD +0 -247
  214. {mirascope-2.0.0a4.dist-info → mirascope-2.0.0a6.dist-info}/WHEEL +0 -0
  215. {mirascope-2.0.0a4.dist-info → mirascope-2.0.0a6.dist-info}/licenses/LICENSE +0 -0
@@ -15,11 +15,11 @@ from ..errors.forbidden_error import ForbiddenError
15
15
  from ..errors.internal_server_error import InternalServerError
16
16
  from ..errors.not_found_error import NotFoundError
17
17
  from ..types.already_exists_error import AlreadyExistsError
18
- from ..types.database_error import DatabaseError
19
18
  from ..types.http_api_decode_error import HttpApiDecodeError
20
19
  from ..types.not_found_error_body import NotFoundErrorBody
21
20
  from ..types.permission_denied_error import PermissionDeniedError
22
21
  from .types.organizations_create_response import OrganizationsCreateResponse
22
+ from .types.organizations_credits_response import OrganizationsCreditsResponse
23
23
  from .types.organizations_get_response import OrganizationsGetResponse
24
24
  from .types.organizations_list_response_item import OrganizationsListResponseItem
25
25
  from .types.organizations_update_response import OrganizationsUpdateResponse
@@ -76,28 +76,20 @@ class RawOrganizationsClient:
76
76
  raise InternalServerError(
77
77
  headers=dict(_response.headers),
78
78
  body=typing.cast(
79
- DatabaseError,
79
+ typing.Optional[typing.Any],
80
80
  parse_obj_as(
81
- type_=DatabaseError, # type: ignore
81
+ type_=typing.Optional[typing.Any], # type: ignore
82
82
  object_=_response.json(),
83
83
  ),
84
84
  ),
85
85
  )
86
86
  _response_json = _response.json()
87
87
  except JSONDecodeError:
88
- raise ApiError(
89
- status_code=_response.status_code,
90
- headers=dict(_response.headers),
91
- body=_response.text,
92
- )
93
- raise ApiError(
94
- status_code=_response.status_code,
95
- headers=dict(_response.headers),
96
- body=_response_json,
97
- )
88
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
89
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
98
90
 
99
91
  def create(
100
- self, *, name: str, request_options: typing.Optional[RequestOptions] = None
92
+ self, *, name: str, slug: str, request_options: typing.Optional[RequestOptions] = None
101
93
  ) -> HttpResponse[OrganizationsCreateResponse]:
102
94
  """
103
95
  Parameters
@@ -105,6 +97,9 @@ class RawOrganizationsClient:
105
97
  name : str
106
98
  a string at most 100 character(s) long
107
99
 
100
+ slug : str
101
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
102
+
108
103
  request_options : typing.Optional[RequestOptions]
109
104
  Request-specific configuration.
110
105
 
@@ -118,6 +113,7 @@ class RawOrganizationsClient:
118
113
  method="POST",
119
114
  json={
120
115
  "name": name,
116
+ "slug": slug,
121
117
  },
122
118
  headers={
123
119
  "content-type": "application/json",
@@ -146,6 +142,17 @@ class RawOrganizationsClient:
146
142
  ),
147
143
  ),
148
144
  )
145
+ if _response.status_code == 404:
146
+ raise NotFoundError(
147
+ headers=dict(_response.headers),
148
+ body=typing.cast(
149
+ NotFoundErrorBody,
150
+ parse_obj_as(
151
+ type_=NotFoundErrorBody, # type: ignore
152
+ object_=_response.json(),
153
+ ),
154
+ ),
155
+ )
149
156
  if _response.status_code == 409:
150
157
  raise ConflictError(
151
158
  headers=dict(_response.headers),
@@ -161,25 +168,17 @@ class RawOrganizationsClient:
161
168
  raise InternalServerError(
162
169
  headers=dict(_response.headers),
163
170
  body=typing.cast(
164
- DatabaseError,
171
+ typing.Optional[typing.Any],
165
172
  parse_obj_as(
166
- type_=DatabaseError, # type: ignore
173
+ type_=typing.Optional[typing.Any], # type: ignore
167
174
  object_=_response.json(),
168
175
  ),
169
176
  ),
170
177
  )
171
178
  _response_json = _response.json()
172
179
  except JSONDecodeError:
173
- raise ApiError(
174
- status_code=_response.status_code,
175
- headers=dict(_response.headers),
176
- body=_response.text,
177
- )
178
- raise ApiError(
179
- status_code=_response.status_code,
180
- headers=dict(_response.headers),
181
- body=_response_json,
182
- )
180
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
181
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
183
182
 
184
183
  def get(
185
184
  self, id: str, *, request_options: typing.Optional[RequestOptions] = None
@@ -249,31 +248,24 @@ class RawOrganizationsClient:
249
248
  raise InternalServerError(
250
249
  headers=dict(_response.headers),
251
250
  body=typing.cast(
252
- DatabaseError,
251
+ typing.Optional[typing.Any],
253
252
  parse_obj_as(
254
- type_=DatabaseError, # type: ignore
253
+ type_=typing.Optional[typing.Any], # type: ignore
255
254
  object_=_response.json(),
256
255
  ),
257
256
  ),
258
257
  )
259
258
  _response_json = _response.json()
260
259
  except JSONDecodeError:
261
- raise ApiError(
262
- status_code=_response.status_code,
263
- headers=dict(_response.headers),
264
- body=_response.text,
265
- )
266
- raise ApiError(
267
- status_code=_response.status_code,
268
- headers=dict(_response.headers),
269
- body=_response_json,
270
- )
260
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
261
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
271
262
 
272
263
  def update(
273
264
  self,
274
265
  id: str,
275
266
  *,
276
- name: str,
267
+ name: typing.Optional[str] = OMIT,
268
+ slug: typing.Optional[str] = OMIT,
277
269
  request_options: typing.Optional[RequestOptions] = None,
278
270
  ) -> HttpResponse[OrganizationsUpdateResponse]:
279
271
  """
@@ -281,9 +273,12 @@ class RawOrganizationsClient:
281
273
  ----------
282
274
  id : str
283
275
 
284
- name : str
276
+ name : typing.Optional[str]
285
277
  a string at most 100 character(s) long
286
278
 
279
+ slug : typing.Optional[str]
280
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
281
+
287
282
  request_options : typing.Optional[RequestOptions]
288
283
  Request-specific configuration.
289
284
 
@@ -297,6 +292,7 @@ class RawOrganizationsClient:
297
292
  method="PUT",
298
293
  json={
299
294
  "name": name,
295
+ "slug": slug,
300
296
  },
301
297
  headers={
302
298
  "content-type": "application/json",
@@ -351,29 +347,19 @@ class RawOrganizationsClient:
351
347
  raise InternalServerError(
352
348
  headers=dict(_response.headers),
353
349
  body=typing.cast(
354
- DatabaseError,
350
+ typing.Optional[typing.Any],
355
351
  parse_obj_as(
356
- type_=DatabaseError, # type: ignore
352
+ type_=typing.Optional[typing.Any], # type: ignore
357
353
  object_=_response.json(),
358
354
  ),
359
355
  ),
360
356
  )
361
357
  _response_json = _response.json()
362
358
  except JSONDecodeError:
363
- raise ApiError(
364
- status_code=_response.status_code,
365
- headers=dict(_response.headers),
366
- body=_response.text,
367
- )
368
- raise ApiError(
369
- status_code=_response.status_code,
370
- headers=dict(_response.headers),
371
- body=_response_json,
372
- )
359
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
360
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
373
361
 
374
- def delete(
375
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
376
- ) -> HttpResponse[None]:
362
+ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
377
363
  """
378
364
  Parameters
379
365
  ----------
@@ -431,25 +417,97 @@ class RawOrganizationsClient:
431
417
  raise InternalServerError(
432
418
  headers=dict(_response.headers),
433
419
  body=typing.cast(
434
- DatabaseError,
420
+ typing.Optional[typing.Any],
435
421
  parse_obj_as(
436
- type_=DatabaseError, # type: ignore
422
+ type_=typing.Optional[typing.Any], # type: ignore
437
423
  object_=_response.json(),
438
424
  ),
439
425
  ),
440
426
  )
441
427
  _response_json = _response.json()
442
428
  except JSONDecodeError:
443
- raise ApiError(
444
- status_code=_response.status_code,
445
- headers=dict(_response.headers),
446
- body=_response.text,
447
- )
448
- raise ApiError(
449
- status_code=_response.status_code,
450
- headers=dict(_response.headers),
451
- body=_response_json,
429
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
430
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
431
+
432
+ def credits(
433
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
434
+ ) -> HttpResponse[OrganizationsCreditsResponse]:
435
+ """
436
+ Parameters
437
+ ----------
438
+ id : str
439
+
440
+ request_options : typing.Optional[RequestOptions]
441
+ Request-specific configuration.
442
+
443
+ Returns
444
+ -------
445
+ HttpResponse[OrganizationsCreditsResponse]
446
+ Success
447
+ """
448
+ _response = self._client_wrapper.httpx_client.request(
449
+ f"organizations/{jsonable_encoder(id)}/credits",
450
+ method="GET",
451
+ request_options=request_options,
452
452
  )
453
+ try:
454
+ if 200 <= _response.status_code < 300:
455
+ _data = typing.cast(
456
+ OrganizationsCreditsResponse,
457
+ parse_obj_as(
458
+ type_=OrganizationsCreditsResponse, # type: ignore
459
+ object_=_response.json(),
460
+ ),
461
+ )
462
+ return HttpResponse(response=_response, data=_data)
463
+ if _response.status_code == 400:
464
+ raise BadRequestError(
465
+ headers=dict(_response.headers),
466
+ body=typing.cast(
467
+ HttpApiDecodeError,
468
+ parse_obj_as(
469
+ type_=HttpApiDecodeError, # type: ignore
470
+ object_=_response.json(),
471
+ ),
472
+ ),
473
+ )
474
+ if _response.status_code == 403:
475
+ raise ForbiddenError(
476
+ headers=dict(_response.headers),
477
+ body=typing.cast(
478
+ PermissionDeniedError,
479
+ parse_obj_as(
480
+ type_=PermissionDeniedError, # type: ignore
481
+ object_=_response.json(),
482
+ ),
483
+ ),
484
+ )
485
+ if _response.status_code == 404:
486
+ raise NotFoundError(
487
+ headers=dict(_response.headers),
488
+ body=typing.cast(
489
+ NotFoundErrorBody,
490
+ parse_obj_as(
491
+ type_=NotFoundErrorBody, # type: ignore
492
+ object_=_response.json(),
493
+ ),
494
+ ),
495
+ )
496
+ if _response.status_code == 500:
497
+ raise InternalServerError(
498
+ headers=dict(_response.headers),
499
+ body=typing.cast(
500
+ typing.Optional[typing.Any],
501
+ parse_obj_as(
502
+ type_=typing.Optional[typing.Any], # type: ignore
503
+ object_=_response.json(),
504
+ ),
505
+ ),
506
+ )
507
+ _response_json = _response.json()
508
+ except JSONDecodeError:
509
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
510
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
453
511
 
454
512
 
455
513
  class AsyncRawOrganizationsClient:
@@ -500,28 +558,20 @@ class AsyncRawOrganizationsClient:
500
558
  raise InternalServerError(
501
559
  headers=dict(_response.headers),
502
560
  body=typing.cast(
503
- DatabaseError,
561
+ typing.Optional[typing.Any],
504
562
  parse_obj_as(
505
- type_=DatabaseError, # type: ignore
563
+ type_=typing.Optional[typing.Any], # type: ignore
506
564
  object_=_response.json(),
507
565
  ),
508
566
  ),
509
567
  )
510
568
  _response_json = _response.json()
511
569
  except JSONDecodeError:
512
- raise ApiError(
513
- status_code=_response.status_code,
514
- headers=dict(_response.headers),
515
- body=_response.text,
516
- )
517
- raise ApiError(
518
- status_code=_response.status_code,
519
- headers=dict(_response.headers),
520
- body=_response_json,
521
- )
570
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
571
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
522
572
 
523
573
  async def create(
524
- self, *, name: str, request_options: typing.Optional[RequestOptions] = None
574
+ self, *, name: str, slug: str, request_options: typing.Optional[RequestOptions] = None
525
575
  ) -> AsyncHttpResponse[OrganizationsCreateResponse]:
526
576
  """
527
577
  Parameters
@@ -529,6 +579,9 @@ class AsyncRawOrganizationsClient:
529
579
  name : str
530
580
  a string at most 100 character(s) long
531
581
 
582
+ slug : str
583
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
584
+
532
585
  request_options : typing.Optional[RequestOptions]
533
586
  Request-specific configuration.
534
587
 
@@ -542,6 +595,7 @@ class AsyncRawOrganizationsClient:
542
595
  method="POST",
543
596
  json={
544
597
  "name": name,
598
+ "slug": slug,
545
599
  },
546
600
  headers={
547
601
  "content-type": "application/json",
@@ -570,6 +624,17 @@ class AsyncRawOrganizationsClient:
570
624
  ),
571
625
  ),
572
626
  )
627
+ if _response.status_code == 404:
628
+ raise NotFoundError(
629
+ headers=dict(_response.headers),
630
+ body=typing.cast(
631
+ NotFoundErrorBody,
632
+ parse_obj_as(
633
+ type_=NotFoundErrorBody, # type: ignore
634
+ object_=_response.json(),
635
+ ),
636
+ ),
637
+ )
573
638
  if _response.status_code == 409:
574
639
  raise ConflictError(
575
640
  headers=dict(_response.headers),
@@ -585,25 +650,17 @@ class AsyncRawOrganizationsClient:
585
650
  raise InternalServerError(
586
651
  headers=dict(_response.headers),
587
652
  body=typing.cast(
588
- DatabaseError,
653
+ typing.Optional[typing.Any],
589
654
  parse_obj_as(
590
- type_=DatabaseError, # type: ignore
655
+ type_=typing.Optional[typing.Any], # type: ignore
591
656
  object_=_response.json(),
592
657
  ),
593
658
  ),
594
659
  )
595
660
  _response_json = _response.json()
596
661
  except JSONDecodeError:
597
- raise ApiError(
598
- status_code=_response.status_code,
599
- headers=dict(_response.headers),
600
- body=_response.text,
601
- )
602
- raise ApiError(
603
- status_code=_response.status_code,
604
- headers=dict(_response.headers),
605
- body=_response_json,
606
- )
662
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
663
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
607
664
 
608
665
  async def get(
609
666
  self, id: str, *, request_options: typing.Optional[RequestOptions] = None
@@ -673,31 +730,24 @@ class AsyncRawOrganizationsClient:
673
730
  raise InternalServerError(
674
731
  headers=dict(_response.headers),
675
732
  body=typing.cast(
676
- DatabaseError,
733
+ typing.Optional[typing.Any],
677
734
  parse_obj_as(
678
- type_=DatabaseError, # type: ignore
735
+ type_=typing.Optional[typing.Any], # type: ignore
679
736
  object_=_response.json(),
680
737
  ),
681
738
  ),
682
739
  )
683
740
  _response_json = _response.json()
684
741
  except JSONDecodeError:
685
- raise ApiError(
686
- status_code=_response.status_code,
687
- headers=dict(_response.headers),
688
- body=_response.text,
689
- )
690
- raise ApiError(
691
- status_code=_response.status_code,
692
- headers=dict(_response.headers),
693
- body=_response_json,
694
- )
742
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
743
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
695
744
 
696
745
  async def update(
697
746
  self,
698
747
  id: str,
699
748
  *,
700
- name: str,
749
+ name: typing.Optional[str] = OMIT,
750
+ slug: typing.Optional[str] = OMIT,
701
751
  request_options: typing.Optional[RequestOptions] = None,
702
752
  ) -> AsyncHttpResponse[OrganizationsUpdateResponse]:
703
753
  """
@@ -705,9 +755,12 @@ class AsyncRawOrganizationsClient:
705
755
  ----------
706
756
  id : str
707
757
 
708
- name : str
758
+ name : typing.Optional[str]
709
759
  a string at most 100 character(s) long
710
760
 
761
+ slug : typing.Optional[str]
762
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
763
+
711
764
  request_options : typing.Optional[RequestOptions]
712
765
  Request-specific configuration.
713
766
 
@@ -721,6 +774,7 @@ class AsyncRawOrganizationsClient:
721
774
  method="PUT",
722
775
  json={
723
776
  "name": name,
777
+ "slug": slug,
724
778
  },
725
779
  headers={
726
780
  "content-type": "application/json",
@@ -775,25 +829,17 @@ class AsyncRawOrganizationsClient:
775
829
  raise InternalServerError(
776
830
  headers=dict(_response.headers),
777
831
  body=typing.cast(
778
- DatabaseError,
832
+ typing.Optional[typing.Any],
779
833
  parse_obj_as(
780
- type_=DatabaseError, # type: ignore
834
+ type_=typing.Optional[typing.Any], # type: ignore
781
835
  object_=_response.json(),
782
836
  ),
783
837
  ),
784
838
  )
785
839
  _response_json = _response.json()
786
840
  except JSONDecodeError:
787
- raise ApiError(
788
- status_code=_response.status_code,
789
- headers=dict(_response.headers),
790
- body=_response.text,
791
- )
792
- raise ApiError(
793
- status_code=_response.status_code,
794
- headers=dict(_response.headers),
795
- body=_response_json,
796
- )
841
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
842
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
797
843
 
798
844
  async def delete(
799
845
  self, id: str, *, request_options: typing.Optional[RequestOptions] = None
@@ -855,22 +901,94 @@ class AsyncRawOrganizationsClient:
855
901
  raise InternalServerError(
856
902
  headers=dict(_response.headers),
857
903
  body=typing.cast(
858
- DatabaseError,
904
+ typing.Optional[typing.Any],
859
905
  parse_obj_as(
860
- type_=DatabaseError, # type: ignore
906
+ type_=typing.Optional[typing.Any], # type: ignore
861
907
  object_=_response.json(),
862
908
  ),
863
909
  ),
864
910
  )
865
911
  _response_json = _response.json()
866
912
  except JSONDecodeError:
867
- raise ApiError(
868
- status_code=_response.status_code,
869
- headers=dict(_response.headers),
870
- body=_response.text,
871
- )
872
- raise ApiError(
873
- status_code=_response.status_code,
874
- headers=dict(_response.headers),
875
- body=_response_json,
913
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
914
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
915
+
916
+ async def credits(
917
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
918
+ ) -> AsyncHttpResponse[OrganizationsCreditsResponse]:
919
+ """
920
+ Parameters
921
+ ----------
922
+ id : str
923
+
924
+ request_options : typing.Optional[RequestOptions]
925
+ Request-specific configuration.
926
+
927
+ Returns
928
+ -------
929
+ AsyncHttpResponse[OrganizationsCreditsResponse]
930
+ Success
931
+ """
932
+ _response = await self._client_wrapper.httpx_client.request(
933
+ f"organizations/{jsonable_encoder(id)}/credits",
934
+ method="GET",
935
+ request_options=request_options,
876
936
  )
937
+ try:
938
+ if 200 <= _response.status_code < 300:
939
+ _data = typing.cast(
940
+ OrganizationsCreditsResponse,
941
+ parse_obj_as(
942
+ type_=OrganizationsCreditsResponse, # type: ignore
943
+ object_=_response.json(),
944
+ ),
945
+ )
946
+ return AsyncHttpResponse(response=_response, data=_data)
947
+ if _response.status_code == 400:
948
+ raise BadRequestError(
949
+ headers=dict(_response.headers),
950
+ body=typing.cast(
951
+ HttpApiDecodeError,
952
+ parse_obj_as(
953
+ type_=HttpApiDecodeError, # type: ignore
954
+ object_=_response.json(),
955
+ ),
956
+ ),
957
+ )
958
+ if _response.status_code == 403:
959
+ raise ForbiddenError(
960
+ headers=dict(_response.headers),
961
+ body=typing.cast(
962
+ PermissionDeniedError,
963
+ parse_obj_as(
964
+ type_=PermissionDeniedError, # type: ignore
965
+ object_=_response.json(),
966
+ ),
967
+ ),
968
+ )
969
+ if _response.status_code == 404:
970
+ raise NotFoundError(
971
+ headers=dict(_response.headers),
972
+ body=typing.cast(
973
+ NotFoundErrorBody,
974
+ parse_obj_as(
975
+ type_=NotFoundErrorBody, # type: ignore
976
+ object_=_response.json(),
977
+ ),
978
+ ),
979
+ )
980
+ if _response.status_code == 500:
981
+ raise InternalServerError(
982
+ headers=dict(_response.headers),
983
+ body=typing.cast(
984
+ typing.Optional[typing.Any],
985
+ parse_obj_as(
986
+ type_=typing.Optional[typing.Any], # type: ignore
987
+ object_=_response.json(),
988
+ ),
989
+ ),
990
+ )
991
+ _response_json = _response.json()
992
+ except JSONDecodeError:
993
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
994
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -4,6 +4,7 @@
4
4
 
5
5
  from .organizations_create_response import OrganizationsCreateResponse
6
6
  from .organizations_create_response_role import OrganizationsCreateResponseRole
7
+ from .organizations_credits_response import OrganizationsCreditsResponse
7
8
  from .organizations_get_response import OrganizationsGetResponse
8
9
  from .organizations_get_response_role import OrganizationsGetResponseRole
9
10
  from .organizations_list_response_item import OrganizationsListResponseItem
@@ -14,6 +15,7 @@ from .organizations_update_response_role import OrganizationsUpdateResponseRole
14
15
  __all__ = [
15
16
  "OrganizationsCreateResponse",
16
17
  "OrganizationsCreateResponseRole",
18
+ "OrganizationsCreditsResponse",
17
19
  "OrganizationsGetResponse",
18
20
  "OrganizationsGetResponseRole",
19
21
  "OrganizationsListResponseItem",
@@ -3,19 +3,21 @@
3
3
  import typing
4
4
 
5
5
  import pydantic
6
+ import typing_extensions
6
7
  from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
8
+ from ...core.serialization import FieldMetadata
7
9
  from .organizations_create_response_role import OrganizationsCreateResponseRole
8
10
 
9
11
 
10
12
  class OrganizationsCreateResponse(UniversalBaseModel):
11
13
  id: str
12
14
  name: str
15
+ slug: str
16
+ stripe_customer_id: typing_extensions.Annotated[str, FieldMetadata(alias="stripeCustomerId")]
13
17
  role: OrganizationsCreateResponseRole
14
18
 
15
19
  if IS_PYDANTIC_V2:
16
- model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
17
- extra="allow", frozen=True
18
- ) # type: ignore # Pydantic v2
20
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
19
21
  else:
20
22
 
21
23
  class Config:
@@ -2,6 +2,4 @@
2
2
 
3
3
  import typing
4
4
 
5
- OrganizationsCreateResponseRole = typing.Union[
6
- typing.Literal["OWNER", "ADMIN", "MEMBER"], typing.Any
7
- ]
5
+ OrganizationsCreateResponseRole = typing.Union[typing.Literal["OWNER", "ADMIN", "MEMBER"], typing.Any]
@@ -0,0 +1,19 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class OrganizationsCreditsResponse(UniversalBaseModel):
10
+ balance: float
11
+
12
+ if IS_PYDANTIC_V2:
13
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
14
+ else:
15
+
16
+ class Config:
17
+ frozen = True
18
+ smart_union = True
19
+ extra = pydantic.Extra.allow