mirascope 2.0.0a6__py3-none-any.whl → 2.0.1__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 (226) hide show
  1. mirascope/api/_generated/__init__.py +186 -5
  2. mirascope/api/_generated/annotations/client.py +38 -6
  3. mirascope/api/_generated/annotations/raw_client.py +366 -47
  4. mirascope/api/_generated/annotations/types/annotations_create_response.py +19 -6
  5. mirascope/api/_generated/annotations/types/annotations_get_response.py +19 -6
  6. mirascope/api/_generated/annotations/types/annotations_list_response_annotations_item.py +22 -7
  7. mirascope/api/_generated/annotations/types/annotations_update_response.py +19 -6
  8. mirascope/api/_generated/api_keys/__init__.py +12 -2
  9. mirascope/api/_generated/api_keys/client.py +107 -6
  10. mirascope/api/_generated/api_keys/raw_client.py +486 -38
  11. mirascope/api/_generated/api_keys/types/__init__.py +7 -1
  12. mirascope/api/_generated/api_keys/types/api_keys_list_all_for_org_response_item.py +40 -0
  13. mirascope/api/_generated/client.py +36 -0
  14. mirascope/api/_generated/docs/raw_client.py +71 -9
  15. mirascope/api/_generated/environment.py +3 -3
  16. mirascope/api/_generated/environments/__init__.py +6 -0
  17. mirascope/api/_generated/environments/client.py +158 -9
  18. mirascope/api/_generated/environments/raw_client.py +620 -52
  19. mirascope/api/_generated/environments/types/__init__.py +10 -0
  20. mirascope/api/_generated/environments/types/environments_get_analytics_response.py +60 -0
  21. mirascope/api/_generated/environments/types/environments_get_analytics_response_top_functions_item.py +24 -0
  22. mirascope/api/_generated/{organizations/types/organizations_credits_response.py → environments/types/environments_get_analytics_response_top_models_item.py} +6 -3
  23. mirascope/api/_generated/errors/__init__.py +6 -0
  24. mirascope/api/_generated/errors/bad_request_error.py +5 -2
  25. mirascope/api/_generated/errors/conflict_error.py +5 -2
  26. mirascope/api/_generated/errors/payment_required_error.py +15 -0
  27. mirascope/api/_generated/errors/service_unavailable_error.py +14 -0
  28. mirascope/api/_generated/errors/too_many_requests_error.py +15 -0
  29. mirascope/api/_generated/functions/__init__.py +10 -0
  30. mirascope/api/_generated/functions/client.py +222 -8
  31. mirascope/api/_generated/functions/raw_client.py +975 -134
  32. mirascope/api/_generated/functions/types/__init__.py +28 -4
  33. mirascope/api/_generated/functions/types/functions_get_by_env_response.py +53 -0
  34. mirascope/api/_generated/functions/types/functions_get_by_env_response_dependencies_value.py +22 -0
  35. mirascope/api/_generated/functions/types/functions_list_by_env_response.py +25 -0
  36. mirascope/api/_generated/functions/types/functions_list_by_env_response_functions_item.py +56 -0
  37. mirascope/api/_generated/functions/types/functions_list_by_env_response_functions_item_dependencies_value.py +22 -0
  38. mirascope/api/_generated/health/raw_client.py +74 -10
  39. mirascope/api/_generated/organization_invitations/__init__.py +33 -0
  40. mirascope/api/_generated/organization_invitations/client.py +546 -0
  41. mirascope/api/_generated/organization_invitations/raw_client.py +1519 -0
  42. mirascope/api/_generated/organization_invitations/types/__init__.py +53 -0
  43. mirascope/api/_generated/organization_invitations/types/organization_invitations_accept_response.py +34 -0
  44. mirascope/api/_generated/organization_invitations/types/organization_invitations_accept_response_role.py +7 -0
  45. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_request_role.py +7 -0
  46. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response.py +48 -0
  47. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response_role.py +7 -0
  48. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response_status.py +7 -0
  49. mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response.py +48 -0
  50. mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response_role.py +7 -0
  51. mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response_status.py +7 -0
  52. mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item.py +48 -0
  53. mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item_role.py +7 -0
  54. mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item_status.py +7 -0
  55. mirascope/api/_generated/organization_memberships/__init__.py +19 -0
  56. mirascope/api/_generated/organization_memberships/client.py +302 -0
  57. mirascope/api/_generated/organization_memberships/raw_client.py +736 -0
  58. mirascope/api/_generated/organization_memberships/types/__init__.py +27 -0
  59. mirascope/api/_generated/organization_memberships/types/organization_memberships_list_response_item.py +33 -0
  60. mirascope/api/_generated/organization_memberships/types/organization_memberships_list_response_item_role.py +7 -0
  61. mirascope/api/_generated/organization_memberships/types/organization_memberships_update_request_role.py +7 -0
  62. mirascope/api/_generated/organization_memberships/types/organization_memberships_update_response.py +31 -0
  63. mirascope/api/_generated/organization_memberships/types/organization_memberships_update_response_role.py +7 -0
  64. mirascope/api/_generated/organizations/__init__.py +26 -2
  65. mirascope/api/_generated/organizations/client.py +442 -20
  66. mirascope/api/_generated/organizations/raw_client.py +1763 -164
  67. mirascope/api/_generated/organizations/types/__init__.py +48 -2
  68. mirascope/api/_generated/organizations/types/organizations_create_payment_intent_response.py +24 -0
  69. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_request_target_plan.py +7 -0
  70. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response.py +47 -0
  71. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response_validation_errors_item.py +33 -0
  72. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response_validation_errors_item_resource.py +7 -0
  73. mirascope/api/_generated/organizations/types/organizations_router_balance_response.py +24 -0
  74. mirascope/api/_generated/organizations/types/organizations_subscription_response.py +53 -0
  75. mirascope/api/_generated/organizations/types/organizations_subscription_response_current_plan.py +7 -0
  76. mirascope/api/_generated/organizations/types/organizations_subscription_response_payment_method.py +26 -0
  77. mirascope/api/_generated/organizations/types/organizations_subscription_response_scheduled_change.py +34 -0
  78. mirascope/api/_generated/organizations/types/organizations_subscription_response_scheduled_change_target_plan.py +7 -0
  79. mirascope/api/_generated/organizations/types/organizations_update_subscription_request_target_plan.py +7 -0
  80. mirascope/api/_generated/organizations/types/organizations_update_subscription_response.py +35 -0
  81. mirascope/api/_generated/project_memberships/__init__.py +25 -0
  82. mirascope/api/_generated/project_memberships/client.py +437 -0
  83. mirascope/api/_generated/project_memberships/raw_client.py +1039 -0
  84. mirascope/api/_generated/project_memberships/types/__init__.py +29 -0
  85. mirascope/api/_generated/project_memberships/types/project_memberships_create_request_role.py +7 -0
  86. mirascope/api/_generated/project_memberships/types/project_memberships_create_response.py +35 -0
  87. mirascope/api/_generated/project_memberships/types/project_memberships_create_response_role.py +7 -0
  88. mirascope/api/_generated/project_memberships/types/project_memberships_list_response_item.py +33 -0
  89. mirascope/api/_generated/project_memberships/types/project_memberships_list_response_item_role.py +7 -0
  90. mirascope/api/_generated/project_memberships/types/project_memberships_update_request_role.py +7 -0
  91. mirascope/api/_generated/project_memberships/types/project_memberships_update_response.py +35 -0
  92. mirascope/api/_generated/project_memberships/types/project_memberships_update_response_role.py +7 -0
  93. mirascope/api/_generated/projects/raw_client.py +415 -58
  94. mirascope/api/_generated/reference.md +2767 -397
  95. mirascope/api/_generated/tags/__init__.py +19 -0
  96. mirascope/api/_generated/tags/client.py +504 -0
  97. mirascope/api/_generated/tags/raw_client.py +1288 -0
  98. mirascope/api/_generated/tags/types/__init__.py +17 -0
  99. mirascope/api/_generated/tags/types/tags_create_response.py +41 -0
  100. mirascope/api/_generated/tags/types/tags_get_response.py +41 -0
  101. mirascope/api/_generated/tags/types/tags_list_response.py +23 -0
  102. mirascope/api/_generated/tags/types/tags_list_response_tags_item.py +41 -0
  103. mirascope/api/_generated/tags/types/tags_update_response.py +41 -0
  104. mirascope/api/_generated/token_cost/__init__.py +7 -0
  105. mirascope/api/_generated/token_cost/client.py +160 -0
  106. mirascope/api/_generated/token_cost/raw_client.py +264 -0
  107. mirascope/api/_generated/token_cost/types/__init__.py +8 -0
  108. mirascope/api/_generated/token_cost/types/token_cost_calculate_request_usage.py +54 -0
  109. mirascope/api/_generated/token_cost/types/token_cost_calculate_response.py +52 -0
  110. mirascope/api/_generated/traces/__init__.py +20 -0
  111. mirascope/api/_generated/traces/client.py +543 -0
  112. mirascope/api/_generated/traces/raw_client.py +1366 -96
  113. mirascope/api/_generated/traces/types/__init__.py +28 -0
  114. mirascope/api/_generated/traces/types/traces_get_analytics_summary_response.py +6 -0
  115. mirascope/api/_generated/traces/types/traces_get_trace_detail_by_env_response.py +33 -0
  116. mirascope/api/_generated/traces/types/traces_get_trace_detail_by_env_response_spans_item.py +88 -0
  117. mirascope/api/_generated/traces/types/traces_get_trace_detail_response_spans_item.py +0 -2
  118. mirascope/api/_generated/traces/types/traces_list_by_function_hash_response.py +25 -0
  119. mirascope/api/_generated/traces/types/traces_list_by_function_hash_response_traces_item.py +44 -0
  120. mirascope/api/_generated/traces/types/traces_search_by_env_request_attribute_filters_item.py +26 -0
  121. mirascope/api/_generated/traces/types/traces_search_by_env_request_attribute_filters_item_operator.py +7 -0
  122. mirascope/api/_generated/traces/types/traces_search_by_env_request_sort_by.py +7 -0
  123. mirascope/api/_generated/traces/types/traces_search_by_env_request_sort_order.py +7 -0
  124. mirascope/api/_generated/traces/types/traces_search_by_env_response.py +26 -0
  125. mirascope/api/_generated/traces/types/traces_search_by_env_response_spans_item.py +50 -0
  126. mirascope/api/_generated/traces/types/traces_search_response_spans_item.py +10 -1
  127. mirascope/api/_generated/types/__init__.py +32 -2
  128. mirascope/api/_generated/types/bad_request_error_body.py +50 -0
  129. mirascope/api/_generated/types/date.py +3 -0
  130. mirascope/api/_generated/types/immutable_resource_error.py +22 -0
  131. mirascope/api/_generated/types/internal_server_error_body.py +3 -3
  132. mirascope/api/_generated/types/plan_limit_exceeded_error.py +32 -0
  133. mirascope/api/_generated/types/plan_limit_exceeded_error_tag.py +7 -0
  134. mirascope/api/_generated/types/pricing_unavailable_error.py +23 -0
  135. mirascope/api/_generated/types/rate_limit_error.py +31 -0
  136. mirascope/api/_generated/types/rate_limit_error_tag.py +5 -0
  137. mirascope/api/_generated/types/service_unavailable_error_body.py +24 -0
  138. mirascope/api/_generated/types/service_unavailable_error_tag.py +7 -0
  139. mirascope/api/_generated/types/subscription_past_due_error.py +31 -0
  140. mirascope/api/_generated/types/subscription_past_due_error_tag.py +7 -0
  141. mirascope/api/settings.py +19 -1
  142. mirascope/llm/__init__.py +53 -10
  143. mirascope/llm/calls/__init__.py +2 -1
  144. mirascope/llm/calls/calls.py +3 -1
  145. mirascope/llm/calls/decorator.py +21 -7
  146. mirascope/llm/content/tool_output.py +22 -5
  147. mirascope/llm/exceptions.py +284 -71
  148. mirascope/llm/formatting/__init__.py +17 -0
  149. mirascope/llm/formatting/format.py +112 -35
  150. mirascope/llm/formatting/output_parser.py +178 -0
  151. mirascope/llm/formatting/partial.py +80 -7
  152. mirascope/llm/formatting/primitives.py +192 -0
  153. mirascope/llm/formatting/types.py +20 -8
  154. mirascope/llm/messages/__init__.py +3 -0
  155. mirascope/llm/messages/_utils.py +34 -0
  156. mirascope/llm/models/__init__.py +5 -0
  157. mirascope/llm/models/models.py +137 -69
  158. mirascope/llm/{providers/base → models}/params.py +7 -57
  159. mirascope/llm/models/thinking_config.py +61 -0
  160. mirascope/llm/prompts/_utils.py +0 -32
  161. mirascope/llm/prompts/decorator.py +16 -5
  162. mirascope/llm/prompts/prompts.py +131 -68
  163. mirascope/llm/providers/__init__.py +1 -4
  164. mirascope/llm/providers/anthropic/_utils/__init__.py +2 -0
  165. mirascope/llm/providers/anthropic/_utils/beta_decode.py +18 -9
  166. mirascope/llm/providers/anthropic/_utils/beta_encode.py +62 -13
  167. mirascope/llm/providers/anthropic/_utils/decode.py +18 -9
  168. mirascope/llm/providers/anthropic/_utils/encode.py +26 -7
  169. mirascope/llm/providers/anthropic/_utils/errors.py +2 -2
  170. mirascope/llm/providers/anthropic/beta_provider.py +64 -18
  171. mirascope/llm/providers/anthropic/provider.py +91 -33
  172. mirascope/llm/providers/base/__init__.py +0 -4
  173. mirascope/llm/providers/base/_utils.py +55 -6
  174. mirascope/llm/providers/base/base_provider.py +116 -37
  175. mirascope/llm/providers/google/_utils/__init__.py +2 -0
  176. mirascope/llm/providers/google/_utils/decode.py +20 -7
  177. mirascope/llm/providers/google/_utils/encode.py +26 -7
  178. mirascope/llm/providers/google/_utils/errors.py +3 -2
  179. mirascope/llm/providers/google/provider.py +64 -18
  180. mirascope/llm/providers/mirascope/_utils.py +13 -17
  181. mirascope/llm/providers/mirascope/provider.py +49 -18
  182. mirascope/llm/providers/mlx/_utils.py +7 -2
  183. mirascope/llm/providers/mlx/encoding/base.py +5 -2
  184. mirascope/llm/providers/mlx/encoding/transformers.py +5 -2
  185. mirascope/llm/providers/mlx/mlx.py +23 -6
  186. mirascope/llm/providers/mlx/provider.py +42 -13
  187. mirascope/llm/providers/openai/_utils/errors.py +2 -2
  188. mirascope/llm/providers/openai/completions/_utils/encode.py +20 -16
  189. mirascope/llm/providers/openai/completions/base_provider.py +40 -11
  190. mirascope/llm/providers/openai/provider.py +40 -10
  191. mirascope/llm/providers/openai/responses/_utils/__init__.py +2 -0
  192. mirascope/llm/providers/openai/responses/_utils/decode.py +19 -6
  193. mirascope/llm/providers/openai/responses/_utils/encode.py +22 -10
  194. mirascope/llm/providers/openai/responses/provider.py +56 -18
  195. mirascope/llm/providers/provider_registry.py +93 -19
  196. mirascope/llm/responses/__init__.py +6 -1
  197. mirascope/llm/responses/_utils.py +102 -12
  198. mirascope/llm/responses/base_response.py +5 -2
  199. mirascope/llm/responses/base_stream_response.py +115 -25
  200. mirascope/llm/responses/response.py +2 -1
  201. mirascope/llm/responses/root_response.py +89 -17
  202. mirascope/llm/responses/stream_response.py +6 -9
  203. mirascope/llm/tools/decorator.py +9 -4
  204. mirascope/llm/tools/tool_schema.py +12 -6
  205. mirascope/llm/tools/toolkit.py +35 -27
  206. mirascope/llm/tools/tools.py +45 -20
  207. mirascope/ops/__init__.py +4 -0
  208. mirascope/ops/_internal/configuration.py +82 -31
  209. mirascope/ops/_internal/exporters/exporters.py +64 -11
  210. mirascope/ops/_internal/instrumentation/llm/common.py +530 -0
  211. mirascope/ops/_internal/instrumentation/llm/cost.py +190 -0
  212. mirascope/ops/_internal/instrumentation/llm/encode.py +1 -1
  213. mirascope/ops/_internal/instrumentation/llm/llm.py +116 -1242
  214. mirascope/ops/_internal/instrumentation/llm/model.py +1798 -0
  215. mirascope/ops/_internal/instrumentation/llm/response.py +521 -0
  216. mirascope/ops/_internal/instrumentation/llm/serialize.py +300 -0
  217. mirascope/ops/_internal/protocols.py +83 -1
  218. mirascope/ops/_internal/traced_calls.py +4 -0
  219. mirascope/ops/_internal/traced_functions.py +118 -8
  220. mirascope/ops/_internal/tracing.py +78 -1
  221. mirascope/ops/_internal/utils.py +52 -4
  222. {mirascope-2.0.0a6.dist-info → mirascope-2.0.1.dist-info}/METADATA +12 -11
  223. mirascope-2.0.1.dist-info/RECORD +423 -0
  224. {mirascope-2.0.0a6.dist-info → mirascope-2.0.1.dist-info}/licenses/LICENSE +1 -1
  225. mirascope-2.0.0a6.dist-info/RECORD +0 -316
  226. {mirascope-2.0.0a6.dist-info → mirascope-2.0.1.dist-info}/WHEEL +0 -0
@@ -14,15 +14,36 @@ from ..errors.conflict_error import ConflictError
14
14
  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
- from ..types.already_exists_error import AlreadyExistsError
18
- from ..types.http_api_decode_error import HttpApiDecodeError
17
+ from ..errors.payment_required_error import PaymentRequiredError
18
+ from ..errors.service_unavailable_error import ServiceUnavailableError
19
+ from ..errors.too_many_requests_error import TooManyRequestsError
19
20
  from ..types.not_found_error_body import NotFoundErrorBody
20
21
  from ..types.permission_denied_error import PermissionDeniedError
22
+ from ..types.plan_limit_exceeded_error import PlanLimitExceededError
23
+ from ..types.rate_limit_error import RateLimitError
24
+ from .types.organizations_create_payment_intent_response import (
25
+ OrganizationsCreatePaymentIntentResponse,
26
+ )
21
27
  from .types.organizations_create_response import OrganizationsCreateResponse
22
- from .types.organizations_credits_response import OrganizationsCreditsResponse
23
28
  from .types.organizations_get_response import OrganizationsGetResponse
24
29
  from .types.organizations_list_response_item import OrganizationsListResponseItem
30
+ from .types.organizations_preview_subscription_change_request_target_plan import (
31
+ OrganizationsPreviewSubscriptionChangeRequestTargetPlan,
32
+ )
33
+ from .types.organizations_preview_subscription_change_response import (
34
+ OrganizationsPreviewSubscriptionChangeResponse,
35
+ )
36
+ from .types.organizations_router_balance_response import (
37
+ OrganizationsRouterBalanceResponse,
38
+ )
39
+ from .types.organizations_subscription_response import OrganizationsSubscriptionResponse
25
40
  from .types.organizations_update_response import OrganizationsUpdateResponse
41
+ from .types.organizations_update_subscription_request_target_plan import (
42
+ OrganizationsUpdateSubscriptionRequestTargetPlan,
43
+ )
44
+ from .types.organizations_update_subscription_response import (
45
+ OrganizationsUpdateSubscriptionResponse,
46
+ )
26
47
 
27
48
  # this is used as the default value for optional parameters
28
49
  OMIT = typing.cast(typing.Any, ...)
@@ -65,9 +86,20 @@ class RawOrganizationsClient:
65
86
  raise BadRequestError(
66
87
  headers=dict(_response.headers),
67
88
  body=typing.cast(
68
- HttpApiDecodeError,
89
+ typing.Optional[typing.Any],
90
+ parse_obj_as(
91
+ type_=typing.Optional[typing.Any], # type: ignore
92
+ object_=_response.json(),
93
+ ),
94
+ ),
95
+ )
96
+ if _response.status_code == 429:
97
+ raise TooManyRequestsError(
98
+ headers=dict(_response.headers),
99
+ body=typing.cast(
100
+ RateLimitError,
69
101
  parse_obj_as(
70
- type_=HttpApiDecodeError, # type: ignore
102
+ type_=RateLimitError, # type: ignore
71
103
  object_=_response.json(),
72
104
  ),
73
105
  ),
@@ -83,13 +115,36 @@ class RawOrganizationsClient:
83
115
  ),
84
116
  ),
85
117
  )
118
+ if _response.status_code == 503:
119
+ raise ServiceUnavailableError(
120
+ headers=dict(_response.headers),
121
+ body=typing.cast(
122
+ typing.Optional[typing.Any],
123
+ parse_obj_as(
124
+ type_=typing.Optional[typing.Any], # type: ignore
125
+ object_=_response.json(),
126
+ ),
127
+ ),
128
+ )
86
129
  _response_json = _response.json()
87
130
  except JSONDecodeError:
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)
131
+ raise ApiError(
132
+ status_code=_response.status_code,
133
+ headers=dict(_response.headers),
134
+ body=_response.text,
135
+ )
136
+ raise ApiError(
137
+ status_code=_response.status_code,
138
+ headers=dict(_response.headers),
139
+ body=_response_json,
140
+ )
90
141
 
91
142
  def create(
92
- self, *, name: str, slug: str, request_options: typing.Optional[RequestOptions] = None
143
+ self,
144
+ *,
145
+ name: str,
146
+ slug: str,
147
+ request_options: typing.Optional[RequestOptions] = None,
93
148
  ) -> HttpResponse[OrganizationsCreateResponse]:
94
149
  """
95
150
  Parameters
@@ -135,9 +190,9 @@ class RawOrganizationsClient:
135
190
  raise BadRequestError(
136
191
  headers=dict(_response.headers),
137
192
  body=typing.cast(
138
- HttpApiDecodeError,
193
+ typing.Optional[typing.Any],
139
194
  parse_obj_as(
140
- type_=HttpApiDecodeError, # type: ignore
195
+ type_=typing.Optional[typing.Any], # type: ignore
141
196
  object_=_response.json(),
142
197
  ),
143
198
  ),
@@ -157,9 +212,20 @@ class RawOrganizationsClient:
157
212
  raise ConflictError(
158
213
  headers=dict(_response.headers),
159
214
  body=typing.cast(
160
- AlreadyExistsError,
215
+ typing.Optional[typing.Any],
216
+ parse_obj_as(
217
+ type_=typing.Optional[typing.Any], # type: ignore
218
+ object_=_response.json(),
219
+ ),
220
+ ),
221
+ )
222
+ if _response.status_code == 429:
223
+ raise TooManyRequestsError(
224
+ headers=dict(_response.headers),
225
+ body=typing.cast(
226
+ RateLimitError,
161
227
  parse_obj_as(
162
- type_=AlreadyExistsError, # type: ignore
228
+ type_=RateLimitError, # type: ignore
163
229
  object_=_response.json(),
164
230
  ),
165
231
  ),
@@ -175,10 +241,29 @@ class RawOrganizationsClient:
175
241
  ),
176
242
  ),
177
243
  )
244
+ if _response.status_code == 503:
245
+ raise ServiceUnavailableError(
246
+ headers=dict(_response.headers),
247
+ body=typing.cast(
248
+ typing.Optional[typing.Any],
249
+ parse_obj_as(
250
+ type_=typing.Optional[typing.Any], # type: ignore
251
+ object_=_response.json(),
252
+ ),
253
+ ),
254
+ )
178
255
  _response_json = _response.json()
179
256
  except JSONDecodeError:
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)
257
+ raise ApiError(
258
+ status_code=_response.status_code,
259
+ headers=dict(_response.headers),
260
+ body=_response.text,
261
+ )
262
+ raise ApiError(
263
+ status_code=_response.status_code,
264
+ headers=dict(_response.headers),
265
+ body=_response_json,
266
+ )
182
267
 
183
268
  def get(
184
269
  self, id: str, *, request_options: typing.Optional[RequestOptions] = None
@@ -215,9 +300,9 @@ class RawOrganizationsClient:
215
300
  raise BadRequestError(
216
301
  headers=dict(_response.headers),
217
302
  body=typing.cast(
218
- HttpApiDecodeError,
303
+ typing.Optional[typing.Any],
219
304
  parse_obj_as(
220
- type_=HttpApiDecodeError, # type: ignore
305
+ type_=typing.Optional[typing.Any], # type: ignore
221
306
  object_=_response.json(),
222
307
  ),
223
308
  ),
@@ -244,6 +329,17 @@ class RawOrganizationsClient:
244
329
  ),
245
330
  ),
246
331
  )
332
+ if _response.status_code == 429:
333
+ raise TooManyRequestsError(
334
+ headers=dict(_response.headers),
335
+ body=typing.cast(
336
+ RateLimitError,
337
+ parse_obj_as(
338
+ type_=RateLimitError, # type: ignore
339
+ object_=_response.json(),
340
+ ),
341
+ ),
342
+ )
247
343
  if _response.status_code == 500:
248
344
  raise InternalServerError(
249
345
  headers=dict(_response.headers),
@@ -255,10 +351,29 @@ class RawOrganizationsClient:
255
351
  ),
256
352
  ),
257
353
  )
354
+ if _response.status_code == 503:
355
+ raise ServiceUnavailableError(
356
+ headers=dict(_response.headers),
357
+ body=typing.cast(
358
+ typing.Optional[typing.Any],
359
+ parse_obj_as(
360
+ type_=typing.Optional[typing.Any], # type: ignore
361
+ object_=_response.json(),
362
+ ),
363
+ ),
364
+ )
258
365
  _response_json = _response.json()
259
366
  except JSONDecodeError:
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)
367
+ raise ApiError(
368
+ status_code=_response.status_code,
369
+ headers=dict(_response.headers),
370
+ body=_response.text,
371
+ )
372
+ raise ApiError(
373
+ status_code=_response.status_code,
374
+ headers=dict(_response.headers),
375
+ body=_response_json,
376
+ )
262
377
 
263
378
  def update(
264
379
  self,
@@ -314,9 +429,9 @@ class RawOrganizationsClient:
314
429
  raise BadRequestError(
315
430
  headers=dict(_response.headers),
316
431
  body=typing.cast(
317
- HttpApiDecodeError,
432
+ typing.Optional[typing.Any],
318
433
  parse_obj_as(
319
- type_=HttpApiDecodeError, # type: ignore
434
+ type_=typing.Optional[typing.Any], # type: ignore
320
435
  object_=_response.json(),
321
436
  ),
322
437
  ),
@@ -343,6 +458,17 @@ class RawOrganizationsClient:
343
458
  ),
344
459
  ),
345
460
  )
461
+ if _response.status_code == 429:
462
+ raise TooManyRequestsError(
463
+ headers=dict(_response.headers),
464
+ body=typing.cast(
465
+ RateLimitError,
466
+ parse_obj_as(
467
+ type_=RateLimitError, # type: ignore
468
+ object_=_response.json(),
469
+ ),
470
+ ),
471
+ )
346
472
  if _response.status_code == 500:
347
473
  raise InternalServerError(
348
474
  headers=dict(_response.headers),
@@ -354,12 +480,33 @@ class RawOrganizationsClient:
354
480
  ),
355
481
  ),
356
482
  )
483
+ if _response.status_code == 503:
484
+ raise ServiceUnavailableError(
485
+ headers=dict(_response.headers),
486
+ body=typing.cast(
487
+ typing.Optional[typing.Any],
488
+ parse_obj_as(
489
+ type_=typing.Optional[typing.Any], # type: ignore
490
+ object_=_response.json(),
491
+ ),
492
+ ),
493
+ )
357
494
  _response_json = _response.json()
358
495
  except JSONDecodeError:
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)
496
+ raise ApiError(
497
+ status_code=_response.status_code,
498
+ headers=dict(_response.headers),
499
+ body=_response.text,
500
+ )
501
+ raise ApiError(
502
+ status_code=_response.status_code,
503
+ headers=dict(_response.headers),
504
+ body=_response_json,
505
+ )
361
506
 
362
- def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
507
+ def delete(
508
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
509
+ ) -> HttpResponse[None]:
363
510
  """
364
511
  Parameters
365
512
  ----------
@@ -384,9 +531,9 @@ class RawOrganizationsClient:
384
531
  raise BadRequestError(
385
532
  headers=dict(_response.headers),
386
533
  body=typing.cast(
387
- HttpApiDecodeError,
534
+ typing.Optional[typing.Any],
388
535
  parse_obj_as(
389
- type_=HttpApiDecodeError, # type: ignore
536
+ type_=typing.Optional[typing.Any], # type: ignore
390
537
  object_=_response.json(),
391
538
  ),
392
539
  ),
@@ -413,6 +560,28 @@ class RawOrganizationsClient:
413
560
  ),
414
561
  ),
415
562
  )
563
+ if _response.status_code == 409:
564
+ raise ConflictError(
565
+ headers=dict(_response.headers),
566
+ body=typing.cast(
567
+ typing.Optional[typing.Any],
568
+ parse_obj_as(
569
+ type_=typing.Optional[typing.Any], # type: ignore
570
+ object_=_response.json(),
571
+ ),
572
+ ),
573
+ )
574
+ if _response.status_code == 429:
575
+ raise TooManyRequestsError(
576
+ headers=dict(_response.headers),
577
+ body=typing.cast(
578
+ RateLimitError,
579
+ parse_obj_as(
580
+ type_=RateLimitError, # type: ignore
581
+ object_=_response.json(),
582
+ ),
583
+ ),
584
+ )
416
585
  if _response.status_code == 500:
417
586
  raise InternalServerError(
418
587
  headers=dict(_response.headers),
@@ -424,14 +593,33 @@ class RawOrganizationsClient:
424
593
  ),
425
594
  ),
426
595
  )
596
+ if _response.status_code == 503:
597
+ raise ServiceUnavailableError(
598
+ headers=dict(_response.headers),
599
+ body=typing.cast(
600
+ typing.Optional[typing.Any],
601
+ parse_obj_as(
602
+ type_=typing.Optional[typing.Any], # type: ignore
603
+ object_=_response.json(),
604
+ ),
605
+ ),
606
+ )
427
607
  _response_json = _response.json()
428
608
  except JSONDecodeError:
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)
609
+ raise ApiError(
610
+ status_code=_response.status_code,
611
+ headers=dict(_response.headers),
612
+ body=_response.text,
613
+ )
614
+ raise ApiError(
615
+ status_code=_response.status_code,
616
+ headers=dict(_response.headers),
617
+ body=_response_json,
618
+ )
431
619
 
432
- def credits(
620
+ def routerbalance(
433
621
  self, id: str, *, request_options: typing.Optional[RequestOptions] = None
434
- ) -> HttpResponse[OrganizationsCreditsResponse]:
622
+ ) -> HttpResponse[OrganizationsRouterBalanceResponse]:
435
623
  """
436
624
  Parameters
437
625
  ----------
@@ -442,20 +630,20 @@ class RawOrganizationsClient:
442
630
 
443
631
  Returns
444
632
  -------
445
- HttpResponse[OrganizationsCreditsResponse]
633
+ HttpResponse[OrganizationsRouterBalanceResponse]
446
634
  Success
447
635
  """
448
636
  _response = self._client_wrapper.httpx_client.request(
449
- f"organizations/{jsonable_encoder(id)}/credits",
637
+ f"organizations/{jsonable_encoder(id)}/router-balance",
450
638
  method="GET",
451
639
  request_options=request_options,
452
640
  )
453
641
  try:
454
642
  if 200 <= _response.status_code < 300:
455
643
  _data = typing.cast(
456
- OrganizationsCreditsResponse,
644
+ OrganizationsRouterBalanceResponse,
457
645
  parse_obj_as(
458
- type_=OrganizationsCreditsResponse, # type: ignore
646
+ type_=OrganizationsRouterBalanceResponse, # type: ignore
459
647
  object_=_response.json(),
460
648
  ),
461
649
  )
@@ -464,9 +652,9 @@ class RawOrganizationsClient:
464
652
  raise BadRequestError(
465
653
  headers=dict(_response.headers),
466
654
  body=typing.cast(
467
- HttpApiDecodeError,
655
+ typing.Optional[typing.Any],
468
656
  parse_obj_as(
469
- type_=HttpApiDecodeError, # type: ignore
657
+ type_=typing.Optional[typing.Any], # type: ignore
470
658
  object_=_response.json(),
471
659
  ),
472
660
  ),
@@ -493,69 +681,30 @@ class RawOrganizationsClient:
493
681
  ),
494
682
  ),
495
683
  )
496
- if _response.status_code == 500:
497
- raise InternalServerError(
684
+ if _response.status_code == 429:
685
+ raise TooManyRequestsError(
498
686
  headers=dict(_response.headers),
499
687
  body=typing.cast(
500
- typing.Optional[typing.Any],
688
+ RateLimitError,
501
689
  parse_obj_as(
502
- type_=typing.Optional[typing.Any], # type: ignore
690
+ type_=RateLimitError, # type: ignore
503
691
  object_=_response.json(),
504
692
  ),
505
693
  ),
506
694
  )
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)
511
-
512
-
513
- class AsyncRawOrganizationsClient:
514
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
515
- self._client_wrapper = client_wrapper
516
-
517
- async def list(
518
- self, *, request_options: typing.Optional[RequestOptions] = None
519
- ) -> AsyncHttpResponse[typing.List[OrganizationsListResponseItem]]:
520
- """
521
- Parameters
522
- ----------
523
- request_options : typing.Optional[RequestOptions]
524
- Request-specific configuration.
525
-
526
- Returns
527
- -------
528
- AsyncHttpResponse[typing.List[OrganizationsListResponseItem]]
529
- Success
530
- """
531
- _response = await self._client_wrapper.httpx_client.request(
532
- "organizations",
533
- method="GET",
534
- request_options=request_options,
535
- )
536
- try:
537
- if 200 <= _response.status_code < 300:
538
- _data = typing.cast(
539
- typing.List[OrganizationsListResponseItem],
540
- parse_obj_as(
541
- type_=typing.List[OrganizationsListResponseItem], # type: ignore
542
- object_=_response.json(),
543
- ),
544
- )
545
- return AsyncHttpResponse(response=_response, data=_data)
546
- if _response.status_code == 400:
547
- raise BadRequestError(
695
+ if _response.status_code == 500:
696
+ raise InternalServerError(
548
697
  headers=dict(_response.headers),
549
698
  body=typing.cast(
550
- HttpApiDecodeError,
699
+ typing.Optional[typing.Any],
551
700
  parse_obj_as(
552
- type_=HttpApiDecodeError, # type: ignore
701
+ type_=typing.Optional[typing.Any], # type: ignore
553
702
  object_=_response.json(),
554
703
  ),
555
704
  ),
556
705
  )
557
- if _response.status_code == 500:
558
- raise InternalServerError(
706
+ if _response.status_code == 503:
707
+ raise ServiceUnavailableError(
559
708
  headers=dict(_response.headers),
560
709
  body=typing.cast(
561
710
  typing.Optional[typing.Any],
@@ -567,35 +716,45 @@ class AsyncRawOrganizationsClient:
567
716
  )
568
717
  _response_json = _response.json()
569
718
  except JSONDecodeError:
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)
719
+ raise ApiError(
720
+ status_code=_response.status_code,
721
+ headers=dict(_response.headers),
722
+ body=_response.text,
723
+ )
724
+ raise ApiError(
725
+ status_code=_response.status_code,
726
+ headers=dict(_response.headers),
727
+ body=_response_json,
728
+ )
572
729
 
573
- async def create(
574
- self, *, name: str, slug: str, request_options: typing.Optional[RequestOptions] = None
575
- ) -> AsyncHttpResponse[OrganizationsCreateResponse]:
730
+ def createpaymentintent(
731
+ self,
732
+ id: str,
733
+ *,
734
+ amount: float,
735
+ request_options: typing.Optional[RequestOptions] = None,
736
+ ) -> HttpResponse[OrganizationsCreatePaymentIntentResponse]:
576
737
  """
577
738
  Parameters
578
739
  ----------
579
- name : str
580
- a string at most 100 character(s) long
740
+ id : str
581
741
 
582
- slug : str
583
- a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
742
+ amount : float
743
+ a positive number
584
744
 
585
745
  request_options : typing.Optional[RequestOptions]
586
746
  Request-specific configuration.
587
747
 
588
748
  Returns
589
749
  -------
590
- AsyncHttpResponse[OrganizationsCreateResponse]
750
+ HttpResponse[OrganizationsCreatePaymentIntentResponse]
591
751
  Success
592
752
  """
593
- _response = await self._client_wrapper.httpx_client.request(
594
- "organizations",
753
+ _response = self._client_wrapper.httpx_client.request(
754
+ f"organizations/{jsonable_encoder(id)}/credits/payment-intent",
595
755
  method="POST",
596
756
  json={
597
- "name": name,
598
- "slug": slug,
757
+ "amount": amount,
599
758
  },
600
759
  headers={
601
760
  "content-type": "application/json",
@@ -606,20 +765,31 @@ class AsyncRawOrganizationsClient:
606
765
  try:
607
766
  if 200 <= _response.status_code < 300:
608
767
  _data = typing.cast(
609
- OrganizationsCreateResponse,
768
+ OrganizationsCreatePaymentIntentResponse,
610
769
  parse_obj_as(
611
- type_=OrganizationsCreateResponse, # type: ignore
770
+ type_=OrganizationsCreatePaymentIntentResponse, # type: ignore
612
771
  object_=_response.json(),
613
772
  ),
614
773
  )
615
- return AsyncHttpResponse(response=_response, data=_data)
774
+ return HttpResponse(response=_response, data=_data)
616
775
  if _response.status_code == 400:
617
776
  raise BadRequestError(
618
777
  headers=dict(_response.headers),
619
778
  body=typing.cast(
620
- HttpApiDecodeError,
779
+ typing.Optional[typing.Any],
780
+ parse_obj_as(
781
+ type_=typing.Optional[typing.Any], # type: ignore
782
+ object_=_response.json(),
783
+ ),
784
+ ),
785
+ )
786
+ if _response.status_code == 403:
787
+ raise ForbiddenError(
788
+ headers=dict(_response.headers),
789
+ body=typing.cast(
790
+ PermissionDeniedError,
621
791
  parse_obj_as(
622
- type_=HttpApiDecodeError, # type: ignore
792
+ type_=PermissionDeniedError, # type: ignore
623
793
  object_=_response.json(),
624
794
  ),
625
795
  ),
@@ -635,13 +805,13 @@ class AsyncRawOrganizationsClient:
635
805
  ),
636
806
  ),
637
807
  )
638
- if _response.status_code == 409:
639
- raise ConflictError(
808
+ if _response.status_code == 429:
809
+ raise TooManyRequestsError(
640
810
  headers=dict(_response.headers),
641
811
  body=typing.cast(
642
- AlreadyExistsError,
812
+ RateLimitError,
643
813
  parse_obj_as(
644
- type_=AlreadyExistsError, # type: ignore
814
+ type_=RateLimitError, # type: ignore
645
815
  object_=_response.json(),
646
816
  ),
647
817
  ),
@@ -657,14 +827,33 @@ class AsyncRawOrganizationsClient:
657
827
  ),
658
828
  ),
659
829
  )
830
+ if _response.status_code == 503:
831
+ raise ServiceUnavailableError(
832
+ headers=dict(_response.headers),
833
+ body=typing.cast(
834
+ typing.Optional[typing.Any],
835
+ parse_obj_as(
836
+ type_=typing.Optional[typing.Any], # type: ignore
837
+ object_=_response.json(),
838
+ ),
839
+ ),
840
+ )
660
841
  _response_json = _response.json()
661
842
  except JSONDecodeError:
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)
843
+ raise ApiError(
844
+ status_code=_response.status_code,
845
+ headers=dict(_response.headers),
846
+ body=_response.text,
847
+ )
848
+ raise ApiError(
849
+ status_code=_response.status_code,
850
+ headers=dict(_response.headers),
851
+ body=_response_json,
852
+ )
664
853
 
665
- async def get(
854
+ def subscription(
666
855
  self, id: str, *, request_options: typing.Optional[RequestOptions] = None
667
- ) -> AsyncHttpResponse[OrganizationsGetResponse]:
856
+ ) -> HttpResponse[OrganizationsSubscriptionResponse]:
668
857
  """
669
858
  Parameters
670
859
  ----------
@@ -675,31 +864,31 @@ class AsyncRawOrganizationsClient:
675
864
 
676
865
  Returns
677
866
  -------
678
- AsyncHttpResponse[OrganizationsGetResponse]
867
+ HttpResponse[OrganizationsSubscriptionResponse]
679
868
  Success
680
869
  """
681
- _response = await self._client_wrapper.httpx_client.request(
682
- f"organizations/{jsonable_encoder(id)}",
870
+ _response = self._client_wrapper.httpx_client.request(
871
+ f"organizations/{jsonable_encoder(id)}/subscription",
683
872
  method="GET",
684
873
  request_options=request_options,
685
874
  )
686
875
  try:
687
876
  if 200 <= _response.status_code < 300:
688
877
  _data = typing.cast(
689
- OrganizationsGetResponse,
878
+ OrganizationsSubscriptionResponse,
690
879
  parse_obj_as(
691
- type_=OrganizationsGetResponse, # type: ignore
880
+ type_=OrganizationsSubscriptionResponse, # type: ignore
692
881
  object_=_response.json(),
693
882
  ),
694
883
  )
695
- return AsyncHttpResponse(response=_response, data=_data)
884
+ return HttpResponse(response=_response, data=_data)
696
885
  if _response.status_code == 400:
697
886
  raise BadRequestError(
698
887
  headers=dict(_response.headers),
699
888
  body=typing.cast(
700
- HttpApiDecodeError,
889
+ typing.Optional[typing.Any],
701
890
  parse_obj_as(
702
- type_=HttpApiDecodeError, # type: ignore
891
+ type_=typing.Optional[typing.Any], # type: ignore
703
892
  object_=_response.json(),
704
893
  ),
705
894
  ),
@@ -726,6 +915,17 @@ class AsyncRawOrganizationsClient:
726
915
  ),
727
916
  ),
728
917
  )
918
+ if _response.status_code == 429:
919
+ raise TooManyRequestsError(
920
+ headers=dict(_response.headers),
921
+ body=typing.cast(
922
+ RateLimitError,
923
+ parse_obj_as(
924
+ type_=RateLimitError, # type: ignore
925
+ object_=_response.json(),
926
+ ),
927
+ ),
928
+ )
729
929
  if _response.status_code == 500:
730
930
  raise InternalServerError(
731
931
  headers=dict(_response.headers),
@@ -737,44 +937,749 @@ class AsyncRawOrganizationsClient:
737
937
  ),
738
938
  ),
739
939
  )
940
+ if _response.status_code == 503:
941
+ raise ServiceUnavailableError(
942
+ headers=dict(_response.headers),
943
+ body=typing.cast(
944
+ typing.Optional[typing.Any],
945
+ parse_obj_as(
946
+ type_=typing.Optional[typing.Any], # type: ignore
947
+ object_=_response.json(),
948
+ ),
949
+ ),
950
+ )
740
951
  _response_json = _response.json()
741
952
  except JSONDecodeError:
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)
953
+ raise ApiError(
954
+ status_code=_response.status_code,
955
+ headers=dict(_response.headers),
956
+ body=_response.text,
957
+ )
958
+ raise ApiError(
959
+ status_code=_response.status_code,
960
+ headers=dict(_response.headers),
961
+ body=_response_json,
962
+ )
744
963
 
745
- async def update(
964
+ def previewsubscriptionchange(
746
965
  self,
747
966
  id: str,
748
967
  *,
749
- name: typing.Optional[str] = OMIT,
750
- slug: typing.Optional[str] = OMIT,
968
+ target_plan: OrganizationsPreviewSubscriptionChangeRequestTargetPlan,
751
969
  request_options: typing.Optional[RequestOptions] = None,
752
- ) -> AsyncHttpResponse[OrganizationsUpdateResponse]:
970
+ ) -> HttpResponse[OrganizationsPreviewSubscriptionChangeResponse]:
753
971
  """
754
972
  Parameters
755
973
  ----------
756
974
  id : str
757
975
 
758
- name : typing.Optional[str]
759
- a string at most 100 character(s) long
760
-
761
- slug : typing.Optional[str]
762
- a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
976
+ target_plan : OrganizationsPreviewSubscriptionChangeRequestTargetPlan
763
977
 
764
978
  request_options : typing.Optional[RequestOptions]
765
979
  Request-specific configuration.
766
980
 
767
981
  Returns
768
982
  -------
769
- AsyncHttpResponse[OrganizationsUpdateResponse]
983
+ HttpResponse[OrganizationsPreviewSubscriptionChangeResponse]
770
984
  Success
771
985
  """
772
- _response = await self._client_wrapper.httpx_client.request(
773
- f"organizations/{jsonable_encoder(id)}",
774
- method="PUT",
986
+ _response = self._client_wrapper.httpx_client.request(
987
+ f"organizations/{jsonable_encoder(id)}/subscription/preview",
988
+ method="POST",
775
989
  json={
776
- "name": name,
777
- "slug": slug,
990
+ "targetPlan": target_plan,
991
+ },
992
+ headers={
993
+ "content-type": "application/json",
994
+ },
995
+ request_options=request_options,
996
+ omit=OMIT,
997
+ )
998
+ try:
999
+ if 200 <= _response.status_code < 300:
1000
+ _data = typing.cast(
1001
+ OrganizationsPreviewSubscriptionChangeResponse,
1002
+ parse_obj_as(
1003
+ type_=OrganizationsPreviewSubscriptionChangeResponse, # type: ignore
1004
+ object_=_response.json(),
1005
+ ),
1006
+ )
1007
+ return HttpResponse(response=_response, data=_data)
1008
+ if _response.status_code == 400:
1009
+ raise BadRequestError(
1010
+ headers=dict(_response.headers),
1011
+ body=typing.cast(
1012
+ typing.Optional[typing.Any],
1013
+ parse_obj_as(
1014
+ type_=typing.Optional[typing.Any], # type: ignore
1015
+ object_=_response.json(),
1016
+ ),
1017
+ ),
1018
+ )
1019
+ if _response.status_code == 403:
1020
+ raise ForbiddenError(
1021
+ headers=dict(_response.headers),
1022
+ body=typing.cast(
1023
+ PermissionDeniedError,
1024
+ parse_obj_as(
1025
+ type_=PermissionDeniedError, # type: ignore
1026
+ object_=_response.json(),
1027
+ ),
1028
+ ),
1029
+ )
1030
+ if _response.status_code == 404:
1031
+ raise NotFoundError(
1032
+ headers=dict(_response.headers),
1033
+ body=typing.cast(
1034
+ NotFoundErrorBody,
1035
+ parse_obj_as(
1036
+ type_=NotFoundErrorBody, # type: ignore
1037
+ object_=_response.json(),
1038
+ ),
1039
+ ),
1040
+ )
1041
+ if _response.status_code == 429:
1042
+ raise TooManyRequestsError(
1043
+ headers=dict(_response.headers),
1044
+ body=typing.cast(
1045
+ RateLimitError,
1046
+ parse_obj_as(
1047
+ type_=RateLimitError, # type: ignore
1048
+ object_=_response.json(),
1049
+ ),
1050
+ ),
1051
+ )
1052
+ if _response.status_code == 500:
1053
+ raise InternalServerError(
1054
+ headers=dict(_response.headers),
1055
+ body=typing.cast(
1056
+ typing.Optional[typing.Any],
1057
+ parse_obj_as(
1058
+ type_=typing.Optional[typing.Any], # type: ignore
1059
+ object_=_response.json(),
1060
+ ),
1061
+ ),
1062
+ )
1063
+ if _response.status_code == 503:
1064
+ raise ServiceUnavailableError(
1065
+ headers=dict(_response.headers),
1066
+ body=typing.cast(
1067
+ typing.Optional[typing.Any],
1068
+ parse_obj_as(
1069
+ type_=typing.Optional[typing.Any], # type: ignore
1070
+ object_=_response.json(),
1071
+ ),
1072
+ ),
1073
+ )
1074
+ _response_json = _response.json()
1075
+ except JSONDecodeError:
1076
+ raise ApiError(
1077
+ status_code=_response.status_code,
1078
+ headers=dict(_response.headers),
1079
+ body=_response.text,
1080
+ )
1081
+ raise ApiError(
1082
+ status_code=_response.status_code,
1083
+ headers=dict(_response.headers),
1084
+ body=_response_json,
1085
+ )
1086
+
1087
+ def updatesubscription(
1088
+ self,
1089
+ id: str,
1090
+ *,
1091
+ target_plan: OrganizationsUpdateSubscriptionRequestTargetPlan,
1092
+ request_options: typing.Optional[RequestOptions] = None,
1093
+ ) -> HttpResponse[OrganizationsUpdateSubscriptionResponse]:
1094
+ """
1095
+ Parameters
1096
+ ----------
1097
+ id : str
1098
+
1099
+ target_plan : OrganizationsUpdateSubscriptionRequestTargetPlan
1100
+
1101
+ request_options : typing.Optional[RequestOptions]
1102
+ Request-specific configuration.
1103
+
1104
+ Returns
1105
+ -------
1106
+ HttpResponse[OrganizationsUpdateSubscriptionResponse]
1107
+ Success
1108
+ """
1109
+ _response = self._client_wrapper.httpx_client.request(
1110
+ f"organizations/{jsonable_encoder(id)}/subscription/update",
1111
+ method="POST",
1112
+ json={
1113
+ "targetPlan": target_plan,
1114
+ },
1115
+ headers={
1116
+ "content-type": "application/json",
1117
+ },
1118
+ request_options=request_options,
1119
+ omit=OMIT,
1120
+ )
1121
+ try:
1122
+ if 200 <= _response.status_code < 300:
1123
+ _data = typing.cast(
1124
+ OrganizationsUpdateSubscriptionResponse,
1125
+ parse_obj_as(
1126
+ type_=OrganizationsUpdateSubscriptionResponse, # type: ignore
1127
+ object_=_response.json(),
1128
+ ),
1129
+ )
1130
+ return HttpResponse(response=_response, data=_data)
1131
+ if _response.status_code == 400:
1132
+ raise BadRequestError(
1133
+ headers=dict(_response.headers),
1134
+ body=typing.cast(
1135
+ typing.Optional[typing.Any],
1136
+ parse_obj_as(
1137
+ type_=typing.Optional[typing.Any], # type: ignore
1138
+ object_=_response.json(),
1139
+ ),
1140
+ ),
1141
+ )
1142
+ if _response.status_code == 402:
1143
+ raise PaymentRequiredError(
1144
+ headers=dict(_response.headers),
1145
+ body=typing.cast(
1146
+ PlanLimitExceededError,
1147
+ parse_obj_as(
1148
+ type_=PlanLimitExceededError, # type: ignore
1149
+ object_=_response.json(),
1150
+ ),
1151
+ ),
1152
+ )
1153
+ if _response.status_code == 403:
1154
+ raise ForbiddenError(
1155
+ headers=dict(_response.headers),
1156
+ body=typing.cast(
1157
+ PermissionDeniedError,
1158
+ parse_obj_as(
1159
+ type_=PermissionDeniedError, # type: ignore
1160
+ object_=_response.json(),
1161
+ ),
1162
+ ),
1163
+ )
1164
+ if _response.status_code == 404:
1165
+ raise NotFoundError(
1166
+ headers=dict(_response.headers),
1167
+ body=typing.cast(
1168
+ NotFoundErrorBody,
1169
+ parse_obj_as(
1170
+ type_=NotFoundErrorBody, # type: ignore
1171
+ object_=_response.json(),
1172
+ ),
1173
+ ),
1174
+ )
1175
+ if _response.status_code == 429:
1176
+ raise TooManyRequestsError(
1177
+ headers=dict(_response.headers),
1178
+ body=typing.cast(
1179
+ RateLimitError,
1180
+ parse_obj_as(
1181
+ type_=RateLimitError, # type: ignore
1182
+ object_=_response.json(),
1183
+ ),
1184
+ ),
1185
+ )
1186
+ if _response.status_code == 500:
1187
+ raise InternalServerError(
1188
+ headers=dict(_response.headers),
1189
+ body=typing.cast(
1190
+ typing.Optional[typing.Any],
1191
+ parse_obj_as(
1192
+ type_=typing.Optional[typing.Any], # type: ignore
1193
+ object_=_response.json(),
1194
+ ),
1195
+ ),
1196
+ )
1197
+ if _response.status_code == 503:
1198
+ raise ServiceUnavailableError(
1199
+ headers=dict(_response.headers),
1200
+ body=typing.cast(
1201
+ typing.Optional[typing.Any],
1202
+ parse_obj_as(
1203
+ type_=typing.Optional[typing.Any], # type: ignore
1204
+ object_=_response.json(),
1205
+ ),
1206
+ ),
1207
+ )
1208
+ _response_json = _response.json()
1209
+ except JSONDecodeError:
1210
+ raise ApiError(
1211
+ status_code=_response.status_code,
1212
+ headers=dict(_response.headers),
1213
+ body=_response.text,
1214
+ )
1215
+ raise ApiError(
1216
+ status_code=_response.status_code,
1217
+ headers=dict(_response.headers),
1218
+ body=_response_json,
1219
+ )
1220
+
1221
+ def cancelscheduleddowngrade(
1222
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1223
+ ) -> HttpResponse[None]:
1224
+ """
1225
+ Parameters
1226
+ ----------
1227
+ id : str
1228
+
1229
+ request_options : typing.Optional[RequestOptions]
1230
+ Request-specific configuration.
1231
+
1232
+ Returns
1233
+ -------
1234
+ HttpResponse[None]
1235
+ """
1236
+ _response = self._client_wrapper.httpx_client.request(
1237
+ f"organizations/{jsonable_encoder(id)}/subscription/cancel-downgrade",
1238
+ method="POST",
1239
+ request_options=request_options,
1240
+ )
1241
+ try:
1242
+ if 200 <= _response.status_code < 300:
1243
+ return HttpResponse(response=_response, data=None)
1244
+ if _response.status_code == 400:
1245
+ raise BadRequestError(
1246
+ headers=dict(_response.headers),
1247
+ body=typing.cast(
1248
+ typing.Optional[typing.Any],
1249
+ parse_obj_as(
1250
+ type_=typing.Optional[typing.Any], # type: ignore
1251
+ object_=_response.json(),
1252
+ ),
1253
+ ),
1254
+ )
1255
+ if _response.status_code == 403:
1256
+ raise ForbiddenError(
1257
+ headers=dict(_response.headers),
1258
+ body=typing.cast(
1259
+ PermissionDeniedError,
1260
+ parse_obj_as(
1261
+ type_=PermissionDeniedError, # type: ignore
1262
+ object_=_response.json(),
1263
+ ),
1264
+ ),
1265
+ )
1266
+ if _response.status_code == 404:
1267
+ raise NotFoundError(
1268
+ headers=dict(_response.headers),
1269
+ body=typing.cast(
1270
+ NotFoundErrorBody,
1271
+ parse_obj_as(
1272
+ type_=NotFoundErrorBody, # type: ignore
1273
+ object_=_response.json(),
1274
+ ),
1275
+ ),
1276
+ )
1277
+ if _response.status_code == 429:
1278
+ raise TooManyRequestsError(
1279
+ headers=dict(_response.headers),
1280
+ body=typing.cast(
1281
+ RateLimitError,
1282
+ parse_obj_as(
1283
+ type_=RateLimitError, # type: ignore
1284
+ object_=_response.json(),
1285
+ ),
1286
+ ),
1287
+ )
1288
+ if _response.status_code == 500:
1289
+ raise InternalServerError(
1290
+ headers=dict(_response.headers),
1291
+ body=typing.cast(
1292
+ typing.Optional[typing.Any],
1293
+ parse_obj_as(
1294
+ type_=typing.Optional[typing.Any], # type: ignore
1295
+ object_=_response.json(),
1296
+ ),
1297
+ ),
1298
+ )
1299
+ if _response.status_code == 503:
1300
+ raise ServiceUnavailableError(
1301
+ headers=dict(_response.headers),
1302
+ body=typing.cast(
1303
+ typing.Optional[typing.Any],
1304
+ parse_obj_as(
1305
+ type_=typing.Optional[typing.Any], # type: ignore
1306
+ object_=_response.json(),
1307
+ ),
1308
+ ),
1309
+ )
1310
+ _response_json = _response.json()
1311
+ except JSONDecodeError:
1312
+ raise ApiError(
1313
+ status_code=_response.status_code,
1314
+ headers=dict(_response.headers),
1315
+ body=_response.text,
1316
+ )
1317
+ raise ApiError(
1318
+ status_code=_response.status_code,
1319
+ headers=dict(_response.headers),
1320
+ body=_response_json,
1321
+ )
1322
+
1323
+
1324
+ class AsyncRawOrganizationsClient:
1325
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
1326
+ self._client_wrapper = client_wrapper
1327
+
1328
+ async def list(
1329
+ self, *, request_options: typing.Optional[RequestOptions] = None
1330
+ ) -> AsyncHttpResponse[typing.List[OrganizationsListResponseItem]]:
1331
+ """
1332
+ Parameters
1333
+ ----------
1334
+ request_options : typing.Optional[RequestOptions]
1335
+ Request-specific configuration.
1336
+
1337
+ Returns
1338
+ -------
1339
+ AsyncHttpResponse[typing.List[OrganizationsListResponseItem]]
1340
+ Success
1341
+ """
1342
+ _response = await self._client_wrapper.httpx_client.request(
1343
+ "organizations",
1344
+ method="GET",
1345
+ request_options=request_options,
1346
+ )
1347
+ try:
1348
+ if 200 <= _response.status_code < 300:
1349
+ _data = typing.cast(
1350
+ typing.List[OrganizationsListResponseItem],
1351
+ parse_obj_as(
1352
+ type_=typing.List[OrganizationsListResponseItem], # type: ignore
1353
+ object_=_response.json(),
1354
+ ),
1355
+ )
1356
+ return AsyncHttpResponse(response=_response, data=_data)
1357
+ if _response.status_code == 400:
1358
+ raise BadRequestError(
1359
+ headers=dict(_response.headers),
1360
+ body=typing.cast(
1361
+ typing.Optional[typing.Any],
1362
+ parse_obj_as(
1363
+ type_=typing.Optional[typing.Any], # type: ignore
1364
+ object_=_response.json(),
1365
+ ),
1366
+ ),
1367
+ )
1368
+ if _response.status_code == 429:
1369
+ raise TooManyRequestsError(
1370
+ headers=dict(_response.headers),
1371
+ body=typing.cast(
1372
+ RateLimitError,
1373
+ parse_obj_as(
1374
+ type_=RateLimitError, # type: ignore
1375
+ object_=_response.json(),
1376
+ ),
1377
+ ),
1378
+ )
1379
+ if _response.status_code == 500:
1380
+ raise InternalServerError(
1381
+ headers=dict(_response.headers),
1382
+ body=typing.cast(
1383
+ typing.Optional[typing.Any],
1384
+ parse_obj_as(
1385
+ type_=typing.Optional[typing.Any], # type: ignore
1386
+ object_=_response.json(),
1387
+ ),
1388
+ ),
1389
+ )
1390
+ if _response.status_code == 503:
1391
+ raise ServiceUnavailableError(
1392
+ headers=dict(_response.headers),
1393
+ body=typing.cast(
1394
+ typing.Optional[typing.Any],
1395
+ parse_obj_as(
1396
+ type_=typing.Optional[typing.Any], # type: ignore
1397
+ object_=_response.json(),
1398
+ ),
1399
+ ),
1400
+ )
1401
+ _response_json = _response.json()
1402
+ except JSONDecodeError:
1403
+ raise ApiError(
1404
+ status_code=_response.status_code,
1405
+ headers=dict(_response.headers),
1406
+ body=_response.text,
1407
+ )
1408
+ raise ApiError(
1409
+ status_code=_response.status_code,
1410
+ headers=dict(_response.headers),
1411
+ body=_response_json,
1412
+ )
1413
+
1414
+ async def create(
1415
+ self,
1416
+ *,
1417
+ name: str,
1418
+ slug: str,
1419
+ request_options: typing.Optional[RequestOptions] = None,
1420
+ ) -> AsyncHttpResponse[OrganizationsCreateResponse]:
1421
+ """
1422
+ Parameters
1423
+ ----------
1424
+ name : str
1425
+ a string at most 100 character(s) long
1426
+
1427
+ slug : str
1428
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
1429
+
1430
+ request_options : typing.Optional[RequestOptions]
1431
+ Request-specific configuration.
1432
+
1433
+ Returns
1434
+ -------
1435
+ AsyncHttpResponse[OrganizationsCreateResponse]
1436
+ Success
1437
+ """
1438
+ _response = await self._client_wrapper.httpx_client.request(
1439
+ "organizations",
1440
+ method="POST",
1441
+ json={
1442
+ "name": name,
1443
+ "slug": slug,
1444
+ },
1445
+ headers={
1446
+ "content-type": "application/json",
1447
+ },
1448
+ request_options=request_options,
1449
+ omit=OMIT,
1450
+ )
1451
+ try:
1452
+ if 200 <= _response.status_code < 300:
1453
+ _data = typing.cast(
1454
+ OrganizationsCreateResponse,
1455
+ parse_obj_as(
1456
+ type_=OrganizationsCreateResponse, # type: ignore
1457
+ object_=_response.json(),
1458
+ ),
1459
+ )
1460
+ return AsyncHttpResponse(response=_response, data=_data)
1461
+ if _response.status_code == 400:
1462
+ raise BadRequestError(
1463
+ headers=dict(_response.headers),
1464
+ body=typing.cast(
1465
+ typing.Optional[typing.Any],
1466
+ parse_obj_as(
1467
+ type_=typing.Optional[typing.Any], # type: ignore
1468
+ object_=_response.json(),
1469
+ ),
1470
+ ),
1471
+ )
1472
+ if _response.status_code == 404:
1473
+ raise NotFoundError(
1474
+ headers=dict(_response.headers),
1475
+ body=typing.cast(
1476
+ NotFoundErrorBody,
1477
+ parse_obj_as(
1478
+ type_=NotFoundErrorBody, # type: ignore
1479
+ object_=_response.json(),
1480
+ ),
1481
+ ),
1482
+ )
1483
+ if _response.status_code == 409:
1484
+ raise ConflictError(
1485
+ headers=dict(_response.headers),
1486
+ body=typing.cast(
1487
+ typing.Optional[typing.Any],
1488
+ parse_obj_as(
1489
+ type_=typing.Optional[typing.Any], # type: ignore
1490
+ object_=_response.json(),
1491
+ ),
1492
+ ),
1493
+ )
1494
+ if _response.status_code == 429:
1495
+ raise TooManyRequestsError(
1496
+ headers=dict(_response.headers),
1497
+ body=typing.cast(
1498
+ RateLimitError,
1499
+ parse_obj_as(
1500
+ type_=RateLimitError, # type: ignore
1501
+ object_=_response.json(),
1502
+ ),
1503
+ ),
1504
+ )
1505
+ if _response.status_code == 500:
1506
+ raise InternalServerError(
1507
+ headers=dict(_response.headers),
1508
+ body=typing.cast(
1509
+ typing.Optional[typing.Any],
1510
+ parse_obj_as(
1511
+ type_=typing.Optional[typing.Any], # type: ignore
1512
+ object_=_response.json(),
1513
+ ),
1514
+ ),
1515
+ )
1516
+ if _response.status_code == 503:
1517
+ raise ServiceUnavailableError(
1518
+ headers=dict(_response.headers),
1519
+ body=typing.cast(
1520
+ typing.Optional[typing.Any],
1521
+ parse_obj_as(
1522
+ type_=typing.Optional[typing.Any], # type: ignore
1523
+ object_=_response.json(),
1524
+ ),
1525
+ ),
1526
+ )
1527
+ _response_json = _response.json()
1528
+ except JSONDecodeError:
1529
+ raise ApiError(
1530
+ status_code=_response.status_code,
1531
+ headers=dict(_response.headers),
1532
+ body=_response.text,
1533
+ )
1534
+ raise ApiError(
1535
+ status_code=_response.status_code,
1536
+ headers=dict(_response.headers),
1537
+ body=_response_json,
1538
+ )
1539
+
1540
+ async def get(
1541
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1542
+ ) -> AsyncHttpResponse[OrganizationsGetResponse]:
1543
+ """
1544
+ Parameters
1545
+ ----------
1546
+ id : str
1547
+
1548
+ request_options : typing.Optional[RequestOptions]
1549
+ Request-specific configuration.
1550
+
1551
+ Returns
1552
+ -------
1553
+ AsyncHttpResponse[OrganizationsGetResponse]
1554
+ Success
1555
+ """
1556
+ _response = await self._client_wrapper.httpx_client.request(
1557
+ f"organizations/{jsonable_encoder(id)}",
1558
+ method="GET",
1559
+ request_options=request_options,
1560
+ )
1561
+ try:
1562
+ if 200 <= _response.status_code < 300:
1563
+ _data = typing.cast(
1564
+ OrganizationsGetResponse,
1565
+ parse_obj_as(
1566
+ type_=OrganizationsGetResponse, # type: ignore
1567
+ object_=_response.json(),
1568
+ ),
1569
+ )
1570
+ return AsyncHttpResponse(response=_response, data=_data)
1571
+ if _response.status_code == 400:
1572
+ raise BadRequestError(
1573
+ headers=dict(_response.headers),
1574
+ body=typing.cast(
1575
+ typing.Optional[typing.Any],
1576
+ parse_obj_as(
1577
+ type_=typing.Optional[typing.Any], # type: ignore
1578
+ object_=_response.json(),
1579
+ ),
1580
+ ),
1581
+ )
1582
+ if _response.status_code == 403:
1583
+ raise ForbiddenError(
1584
+ headers=dict(_response.headers),
1585
+ body=typing.cast(
1586
+ PermissionDeniedError,
1587
+ parse_obj_as(
1588
+ type_=PermissionDeniedError, # type: ignore
1589
+ object_=_response.json(),
1590
+ ),
1591
+ ),
1592
+ )
1593
+ if _response.status_code == 404:
1594
+ raise NotFoundError(
1595
+ headers=dict(_response.headers),
1596
+ body=typing.cast(
1597
+ NotFoundErrorBody,
1598
+ parse_obj_as(
1599
+ type_=NotFoundErrorBody, # type: ignore
1600
+ object_=_response.json(),
1601
+ ),
1602
+ ),
1603
+ )
1604
+ if _response.status_code == 429:
1605
+ raise TooManyRequestsError(
1606
+ headers=dict(_response.headers),
1607
+ body=typing.cast(
1608
+ RateLimitError,
1609
+ parse_obj_as(
1610
+ type_=RateLimitError, # type: ignore
1611
+ object_=_response.json(),
1612
+ ),
1613
+ ),
1614
+ )
1615
+ if _response.status_code == 500:
1616
+ raise InternalServerError(
1617
+ headers=dict(_response.headers),
1618
+ body=typing.cast(
1619
+ typing.Optional[typing.Any],
1620
+ parse_obj_as(
1621
+ type_=typing.Optional[typing.Any], # type: ignore
1622
+ object_=_response.json(),
1623
+ ),
1624
+ ),
1625
+ )
1626
+ if _response.status_code == 503:
1627
+ raise ServiceUnavailableError(
1628
+ headers=dict(_response.headers),
1629
+ body=typing.cast(
1630
+ typing.Optional[typing.Any],
1631
+ parse_obj_as(
1632
+ type_=typing.Optional[typing.Any], # type: ignore
1633
+ object_=_response.json(),
1634
+ ),
1635
+ ),
1636
+ )
1637
+ _response_json = _response.json()
1638
+ except JSONDecodeError:
1639
+ raise ApiError(
1640
+ status_code=_response.status_code,
1641
+ headers=dict(_response.headers),
1642
+ body=_response.text,
1643
+ )
1644
+ raise ApiError(
1645
+ status_code=_response.status_code,
1646
+ headers=dict(_response.headers),
1647
+ body=_response_json,
1648
+ )
1649
+
1650
+ async def update(
1651
+ self,
1652
+ id: str,
1653
+ *,
1654
+ name: typing.Optional[str] = OMIT,
1655
+ slug: typing.Optional[str] = OMIT,
1656
+ request_options: typing.Optional[RequestOptions] = None,
1657
+ ) -> AsyncHttpResponse[OrganizationsUpdateResponse]:
1658
+ """
1659
+ Parameters
1660
+ ----------
1661
+ id : str
1662
+
1663
+ name : typing.Optional[str]
1664
+ a string at most 100 character(s) long
1665
+
1666
+ slug : typing.Optional[str]
1667
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
1668
+
1669
+ request_options : typing.Optional[RequestOptions]
1670
+ Request-specific configuration.
1671
+
1672
+ Returns
1673
+ -------
1674
+ AsyncHttpResponse[OrganizationsUpdateResponse]
1675
+ Success
1676
+ """
1677
+ _response = await self._client_wrapper.httpx_client.request(
1678
+ f"organizations/{jsonable_encoder(id)}",
1679
+ method="PUT",
1680
+ json={
1681
+ "name": name,
1682
+ "slug": slug,
778
1683
  },
779
1684
  headers={
780
1685
  "content-type": "application/json",
@@ -787,7 +1692,464 @@ class AsyncRawOrganizationsClient:
787
1692
  _data = typing.cast(
788
1693
  OrganizationsUpdateResponse,
789
1694
  parse_obj_as(
790
- type_=OrganizationsUpdateResponse, # type: ignore
1695
+ type_=OrganizationsUpdateResponse, # type: ignore
1696
+ object_=_response.json(),
1697
+ ),
1698
+ )
1699
+ return AsyncHttpResponse(response=_response, data=_data)
1700
+ if _response.status_code == 400:
1701
+ raise BadRequestError(
1702
+ headers=dict(_response.headers),
1703
+ body=typing.cast(
1704
+ typing.Optional[typing.Any],
1705
+ parse_obj_as(
1706
+ type_=typing.Optional[typing.Any], # type: ignore
1707
+ object_=_response.json(),
1708
+ ),
1709
+ ),
1710
+ )
1711
+ if _response.status_code == 403:
1712
+ raise ForbiddenError(
1713
+ headers=dict(_response.headers),
1714
+ body=typing.cast(
1715
+ PermissionDeniedError,
1716
+ parse_obj_as(
1717
+ type_=PermissionDeniedError, # type: ignore
1718
+ object_=_response.json(),
1719
+ ),
1720
+ ),
1721
+ )
1722
+ if _response.status_code == 404:
1723
+ raise NotFoundError(
1724
+ headers=dict(_response.headers),
1725
+ body=typing.cast(
1726
+ NotFoundErrorBody,
1727
+ parse_obj_as(
1728
+ type_=NotFoundErrorBody, # type: ignore
1729
+ object_=_response.json(),
1730
+ ),
1731
+ ),
1732
+ )
1733
+ if _response.status_code == 429:
1734
+ raise TooManyRequestsError(
1735
+ headers=dict(_response.headers),
1736
+ body=typing.cast(
1737
+ RateLimitError,
1738
+ parse_obj_as(
1739
+ type_=RateLimitError, # type: ignore
1740
+ object_=_response.json(),
1741
+ ),
1742
+ ),
1743
+ )
1744
+ if _response.status_code == 500:
1745
+ raise InternalServerError(
1746
+ headers=dict(_response.headers),
1747
+ body=typing.cast(
1748
+ typing.Optional[typing.Any],
1749
+ parse_obj_as(
1750
+ type_=typing.Optional[typing.Any], # type: ignore
1751
+ object_=_response.json(),
1752
+ ),
1753
+ ),
1754
+ )
1755
+ if _response.status_code == 503:
1756
+ raise ServiceUnavailableError(
1757
+ headers=dict(_response.headers),
1758
+ body=typing.cast(
1759
+ typing.Optional[typing.Any],
1760
+ parse_obj_as(
1761
+ type_=typing.Optional[typing.Any], # type: ignore
1762
+ object_=_response.json(),
1763
+ ),
1764
+ ),
1765
+ )
1766
+ _response_json = _response.json()
1767
+ except JSONDecodeError:
1768
+ raise ApiError(
1769
+ status_code=_response.status_code,
1770
+ headers=dict(_response.headers),
1771
+ body=_response.text,
1772
+ )
1773
+ raise ApiError(
1774
+ status_code=_response.status_code,
1775
+ headers=dict(_response.headers),
1776
+ body=_response_json,
1777
+ )
1778
+
1779
+ async def delete(
1780
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1781
+ ) -> AsyncHttpResponse[None]:
1782
+ """
1783
+ Parameters
1784
+ ----------
1785
+ id : str
1786
+
1787
+ request_options : typing.Optional[RequestOptions]
1788
+ Request-specific configuration.
1789
+
1790
+ Returns
1791
+ -------
1792
+ AsyncHttpResponse[None]
1793
+ """
1794
+ _response = await self._client_wrapper.httpx_client.request(
1795
+ f"organizations/{jsonable_encoder(id)}",
1796
+ method="DELETE",
1797
+ request_options=request_options,
1798
+ )
1799
+ try:
1800
+ if 200 <= _response.status_code < 300:
1801
+ return AsyncHttpResponse(response=_response, data=None)
1802
+ if _response.status_code == 400:
1803
+ raise BadRequestError(
1804
+ headers=dict(_response.headers),
1805
+ body=typing.cast(
1806
+ typing.Optional[typing.Any],
1807
+ parse_obj_as(
1808
+ type_=typing.Optional[typing.Any], # type: ignore
1809
+ object_=_response.json(),
1810
+ ),
1811
+ ),
1812
+ )
1813
+ if _response.status_code == 403:
1814
+ raise ForbiddenError(
1815
+ headers=dict(_response.headers),
1816
+ body=typing.cast(
1817
+ PermissionDeniedError,
1818
+ parse_obj_as(
1819
+ type_=PermissionDeniedError, # type: ignore
1820
+ object_=_response.json(),
1821
+ ),
1822
+ ),
1823
+ )
1824
+ if _response.status_code == 404:
1825
+ raise NotFoundError(
1826
+ headers=dict(_response.headers),
1827
+ body=typing.cast(
1828
+ NotFoundErrorBody,
1829
+ parse_obj_as(
1830
+ type_=NotFoundErrorBody, # type: ignore
1831
+ object_=_response.json(),
1832
+ ),
1833
+ ),
1834
+ )
1835
+ if _response.status_code == 409:
1836
+ raise ConflictError(
1837
+ headers=dict(_response.headers),
1838
+ body=typing.cast(
1839
+ typing.Optional[typing.Any],
1840
+ parse_obj_as(
1841
+ type_=typing.Optional[typing.Any], # type: ignore
1842
+ object_=_response.json(),
1843
+ ),
1844
+ ),
1845
+ )
1846
+ if _response.status_code == 429:
1847
+ raise TooManyRequestsError(
1848
+ headers=dict(_response.headers),
1849
+ body=typing.cast(
1850
+ RateLimitError,
1851
+ parse_obj_as(
1852
+ type_=RateLimitError, # type: ignore
1853
+ object_=_response.json(),
1854
+ ),
1855
+ ),
1856
+ )
1857
+ if _response.status_code == 500:
1858
+ raise InternalServerError(
1859
+ headers=dict(_response.headers),
1860
+ body=typing.cast(
1861
+ typing.Optional[typing.Any],
1862
+ parse_obj_as(
1863
+ type_=typing.Optional[typing.Any], # type: ignore
1864
+ object_=_response.json(),
1865
+ ),
1866
+ ),
1867
+ )
1868
+ if _response.status_code == 503:
1869
+ raise ServiceUnavailableError(
1870
+ headers=dict(_response.headers),
1871
+ body=typing.cast(
1872
+ typing.Optional[typing.Any],
1873
+ parse_obj_as(
1874
+ type_=typing.Optional[typing.Any], # type: ignore
1875
+ object_=_response.json(),
1876
+ ),
1877
+ ),
1878
+ )
1879
+ _response_json = _response.json()
1880
+ except JSONDecodeError:
1881
+ raise ApiError(
1882
+ status_code=_response.status_code,
1883
+ headers=dict(_response.headers),
1884
+ body=_response.text,
1885
+ )
1886
+ raise ApiError(
1887
+ status_code=_response.status_code,
1888
+ headers=dict(_response.headers),
1889
+ body=_response_json,
1890
+ )
1891
+
1892
+ async def routerbalance(
1893
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1894
+ ) -> AsyncHttpResponse[OrganizationsRouterBalanceResponse]:
1895
+ """
1896
+ Parameters
1897
+ ----------
1898
+ id : str
1899
+
1900
+ request_options : typing.Optional[RequestOptions]
1901
+ Request-specific configuration.
1902
+
1903
+ Returns
1904
+ -------
1905
+ AsyncHttpResponse[OrganizationsRouterBalanceResponse]
1906
+ Success
1907
+ """
1908
+ _response = await self._client_wrapper.httpx_client.request(
1909
+ f"organizations/{jsonable_encoder(id)}/router-balance",
1910
+ method="GET",
1911
+ request_options=request_options,
1912
+ )
1913
+ try:
1914
+ if 200 <= _response.status_code < 300:
1915
+ _data = typing.cast(
1916
+ OrganizationsRouterBalanceResponse,
1917
+ parse_obj_as(
1918
+ type_=OrganizationsRouterBalanceResponse, # type: ignore
1919
+ object_=_response.json(),
1920
+ ),
1921
+ )
1922
+ return AsyncHttpResponse(response=_response, data=_data)
1923
+ if _response.status_code == 400:
1924
+ raise BadRequestError(
1925
+ headers=dict(_response.headers),
1926
+ body=typing.cast(
1927
+ typing.Optional[typing.Any],
1928
+ parse_obj_as(
1929
+ type_=typing.Optional[typing.Any], # type: ignore
1930
+ object_=_response.json(),
1931
+ ),
1932
+ ),
1933
+ )
1934
+ if _response.status_code == 403:
1935
+ raise ForbiddenError(
1936
+ headers=dict(_response.headers),
1937
+ body=typing.cast(
1938
+ PermissionDeniedError,
1939
+ parse_obj_as(
1940
+ type_=PermissionDeniedError, # type: ignore
1941
+ object_=_response.json(),
1942
+ ),
1943
+ ),
1944
+ )
1945
+ if _response.status_code == 404:
1946
+ raise NotFoundError(
1947
+ headers=dict(_response.headers),
1948
+ body=typing.cast(
1949
+ NotFoundErrorBody,
1950
+ parse_obj_as(
1951
+ type_=NotFoundErrorBody, # type: ignore
1952
+ object_=_response.json(),
1953
+ ),
1954
+ ),
1955
+ )
1956
+ if _response.status_code == 429:
1957
+ raise TooManyRequestsError(
1958
+ headers=dict(_response.headers),
1959
+ body=typing.cast(
1960
+ RateLimitError,
1961
+ parse_obj_as(
1962
+ type_=RateLimitError, # type: ignore
1963
+ object_=_response.json(),
1964
+ ),
1965
+ ),
1966
+ )
1967
+ if _response.status_code == 500:
1968
+ raise InternalServerError(
1969
+ headers=dict(_response.headers),
1970
+ body=typing.cast(
1971
+ typing.Optional[typing.Any],
1972
+ parse_obj_as(
1973
+ type_=typing.Optional[typing.Any], # type: ignore
1974
+ object_=_response.json(),
1975
+ ),
1976
+ ),
1977
+ )
1978
+ if _response.status_code == 503:
1979
+ raise ServiceUnavailableError(
1980
+ headers=dict(_response.headers),
1981
+ body=typing.cast(
1982
+ typing.Optional[typing.Any],
1983
+ parse_obj_as(
1984
+ type_=typing.Optional[typing.Any], # type: ignore
1985
+ object_=_response.json(),
1986
+ ),
1987
+ ),
1988
+ )
1989
+ _response_json = _response.json()
1990
+ except JSONDecodeError:
1991
+ raise ApiError(
1992
+ status_code=_response.status_code,
1993
+ headers=dict(_response.headers),
1994
+ body=_response.text,
1995
+ )
1996
+ raise ApiError(
1997
+ status_code=_response.status_code,
1998
+ headers=dict(_response.headers),
1999
+ body=_response_json,
2000
+ )
2001
+
2002
+ async def createpaymentintent(
2003
+ self,
2004
+ id: str,
2005
+ *,
2006
+ amount: float,
2007
+ request_options: typing.Optional[RequestOptions] = None,
2008
+ ) -> AsyncHttpResponse[OrganizationsCreatePaymentIntentResponse]:
2009
+ """
2010
+ Parameters
2011
+ ----------
2012
+ id : str
2013
+
2014
+ amount : float
2015
+ a positive number
2016
+
2017
+ request_options : typing.Optional[RequestOptions]
2018
+ Request-specific configuration.
2019
+
2020
+ Returns
2021
+ -------
2022
+ AsyncHttpResponse[OrganizationsCreatePaymentIntentResponse]
2023
+ Success
2024
+ """
2025
+ _response = await self._client_wrapper.httpx_client.request(
2026
+ f"organizations/{jsonable_encoder(id)}/credits/payment-intent",
2027
+ method="POST",
2028
+ json={
2029
+ "amount": amount,
2030
+ },
2031
+ headers={
2032
+ "content-type": "application/json",
2033
+ },
2034
+ request_options=request_options,
2035
+ omit=OMIT,
2036
+ )
2037
+ try:
2038
+ if 200 <= _response.status_code < 300:
2039
+ _data = typing.cast(
2040
+ OrganizationsCreatePaymentIntentResponse,
2041
+ parse_obj_as(
2042
+ type_=OrganizationsCreatePaymentIntentResponse, # type: ignore
2043
+ object_=_response.json(),
2044
+ ),
2045
+ )
2046
+ return AsyncHttpResponse(response=_response, data=_data)
2047
+ if _response.status_code == 400:
2048
+ raise BadRequestError(
2049
+ headers=dict(_response.headers),
2050
+ body=typing.cast(
2051
+ typing.Optional[typing.Any],
2052
+ parse_obj_as(
2053
+ type_=typing.Optional[typing.Any], # type: ignore
2054
+ object_=_response.json(),
2055
+ ),
2056
+ ),
2057
+ )
2058
+ if _response.status_code == 403:
2059
+ raise ForbiddenError(
2060
+ headers=dict(_response.headers),
2061
+ body=typing.cast(
2062
+ PermissionDeniedError,
2063
+ parse_obj_as(
2064
+ type_=PermissionDeniedError, # type: ignore
2065
+ object_=_response.json(),
2066
+ ),
2067
+ ),
2068
+ )
2069
+ if _response.status_code == 404:
2070
+ raise NotFoundError(
2071
+ headers=dict(_response.headers),
2072
+ body=typing.cast(
2073
+ NotFoundErrorBody,
2074
+ parse_obj_as(
2075
+ type_=NotFoundErrorBody, # type: ignore
2076
+ object_=_response.json(),
2077
+ ),
2078
+ ),
2079
+ )
2080
+ if _response.status_code == 429:
2081
+ raise TooManyRequestsError(
2082
+ headers=dict(_response.headers),
2083
+ body=typing.cast(
2084
+ RateLimitError,
2085
+ parse_obj_as(
2086
+ type_=RateLimitError, # type: ignore
2087
+ object_=_response.json(),
2088
+ ),
2089
+ ),
2090
+ )
2091
+ if _response.status_code == 500:
2092
+ raise InternalServerError(
2093
+ headers=dict(_response.headers),
2094
+ body=typing.cast(
2095
+ typing.Optional[typing.Any],
2096
+ parse_obj_as(
2097
+ type_=typing.Optional[typing.Any], # type: ignore
2098
+ object_=_response.json(),
2099
+ ),
2100
+ ),
2101
+ )
2102
+ if _response.status_code == 503:
2103
+ raise ServiceUnavailableError(
2104
+ headers=dict(_response.headers),
2105
+ body=typing.cast(
2106
+ typing.Optional[typing.Any],
2107
+ parse_obj_as(
2108
+ type_=typing.Optional[typing.Any], # type: ignore
2109
+ object_=_response.json(),
2110
+ ),
2111
+ ),
2112
+ )
2113
+ _response_json = _response.json()
2114
+ except JSONDecodeError:
2115
+ raise ApiError(
2116
+ status_code=_response.status_code,
2117
+ headers=dict(_response.headers),
2118
+ body=_response.text,
2119
+ )
2120
+ raise ApiError(
2121
+ status_code=_response.status_code,
2122
+ headers=dict(_response.headers),
2123
+ body=_response_json,
2124
+ )
2125
+
2126
+ async def subscription(
2127
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
2128
+ ) -> AsyncHttpResponse[OrganizationsSubscriptionResponse]:
2129
+ """
2130
+ Parameters
2131
+ ----------
2132
+ id : str
2133
+
2134
+ request_options : typing.Optional[RequestOptions]
2135
+ Request-specific configuration.
2136
+
2137
+ Returns
2138
+ -------
2139
+ AsyncHttpResponse[OrganizationsSubscriptionResponse]
2140
+ Success
2141
+ """
2142
+ _response = await self._client_wrapper.httpx_client.request(
2143
+ f"organizations/{jsonable_encoder(id)}/subscription",
2144
+ method="GET",
2145
+ request_options=request_options,
2146
+ )
2147
+ try:
2148
+ if 200 <= _response.status_code < 300:
2149
+ _data = typing.cast(
2150
+ OrganizationsSubscriptionResponse,
2151
+ parse_obj_as(
2152
+ type_=OrganizationsSubscriptionResponse, # type: ignore
791
2153
  object_=_response.json(),
792
2154
  ),
793
2155
  )
@@ -796,9 +2158,9 @@ class AsyncRawOrganizationsClient:
796
2158
  raise BadRequestError(
797
2159
  headers=dict(_response.headers),
798
2160
  body=typing.cast(
799
- HttpApiDecodeError,
2161
+ typing.Optional[typing.Any],
800
2162
  parse_obj_as(
801
- type_=HttpApiDecodeError, # type: ignore
2163
+ type_=typing.Optional[typing.Any], # type: ignore
802
2164
  object_=_response.json(),
803
2165
  ),
804
2166
  ),
@@ -825,6 +2187,17 @@ class AsyncRawOrganizationsClient:
825
2187
  ),
826
2188
  ),
827
2189
  )
2190
+ if _response.status_code == 429:
2191
+ raise TooManyRequestsError(
2192
+ headers=dict(_response.headers),
2193
+ body=typing.cast(
2194
+ RateLimitError,
2195
+ parse_obj_as(
2196
+ type_=RateLimitError, # type: ignore
2197
+ object_=_response.json(),
2198
+ ),
2199
+ ),
2200
+ )
828
2201
  if _response.status_code == 500:
829
2202
  raise InternalServerError(
830
2203
  headers=dict(_response.headers),
@@ -836,41 +2209,81 @@ class AsyncRawOrganizationsClient:
836
2209
  ),
837
2210
  ),
838
2211
  )
2212
+ if _response.status_code == 503:
2213
+ raise ServiceUnavailableError(
2214
+ headers=dict(_response.headers),
2215
+ body=typing.cast(
2216
+ typing.Optional[typing.Any],
2217
+ parse_obj_as(
2218
+ type_=typing.Optional[typing.Any], # type: ignore
2219
+ object_=_response.json(),
2220
+ ),
2221
+ ),
2222
+ )
839
2223
  _response_json = _response.json()
840
2224
  except JSONDecodeError:
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)
2225
+ raise ApiError(
2226
+ status_code=_response.status_code,
2227
+ headers=dict(_response.headers),
2228
+ body=_response.text,
2229
+ )
2230
+ raise ApiError(
2231
+ status_code=_response.status_code,
2232
+ headers=dict(_response.headers),
2233
+ body=_response_json,
2234
+ )
843
2235
 
844
- async def delete(
845
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
846
- ) -> AsyncHttpResponse[None]:
2236
+ async def previewsubscriptionchange(
2237
+ self,
2238
+ id: str,
2239
+ *,
2240
+ target_plan: OrganizationsPreviewSubscriptionChangeRequestTargetPlan,
2241
+ request_options: typing.Optional[RequestOptions] = None,
2242
+ ) -> AsyncHttpResponse[OrganizationsPreviewSubscriptionChangeResponse]:
847
2243
  """
848
2244
  Parameters
849
2245
  ----------
850
2246
  id : str
851
2247
 
2248
+ target_plan : OrganizationsPreviewSubscriptionChangeRequestTargetPlan
2249
+
852
2250
  request_options : typing.Optional[RequestOptions]
853
2251
  Request-specific configuration.
854
2252
 
855
2253
  Returns
856
2254
  -------
857
- AsyncHttpResponse[None]
2255
+ AsyncHttpResponse[OrganizationsPreviewSubscriptionChangeResponse]
2256
+ Success
858
2257
  """
859
2258
  _response = await self._client_wrapper.httpx_client.request(
860
- f"organizations/{jsonable_encoder(id)}",
861
- method="DELETE",
2259
+ f"organizations/{jsonable_encoder(id)}/subscription/preview",
2260
+ method="POST",
2261
+ json={
2262
+ "targetPlan": target_plan,
2263
+ },
2264
+ headers={
2265
+ "content-type": "application/json",
2266
+ },
862
2267
  request_options=request_options,
2268
+ omit=OMIT,
863
2269
  )
864
2270
  try:
865
2271
  if 200 <= _response.status_code < 300:
866
- return AsyncHttpResponse(response=_response, data=None)
2272
+ _data = typing.cast(
2273
+ OrganizationsPreviewSubscriptionChangeResponse,
2274
+ parse_obj_as(
2275
+ type_=OrganizationsPreviewSubscriptionChangeResponse, # type: ignore
2276
+ object_=_response.json(),
2277
+ ),
2278
+ )
2279
+ return AsyncHttpResponse(response=_response, data=_data)
867
2280
  if _response.status_code == 400:
868
2281
  raise BadRequestError(
869
2282
  headers=dict(_response.headers),
870
2283
  body=typing.cast(
871
- HttpApiDecodeError,
2284
+ typing.Optional[typing.Any],
872
2285
  parse_obj_as(
873
- type_=HttpApiDecodeError, # type: ignore
2286
+ type_=typing.Optional[typing.Any], # type: ignore
874
2287
  object_=_response.json(),
875
2288
  ),
876
2289
  ),
@@ -897,6 +2310,17 @@ class AsyncRawOrganizationsClient:
897
2310
  ),
898
2311
  ),
899
2312
  )
2313
+ if _response.status_code == 429:
2314
+ raise TooManyRequestsError(
2315
+ headers=dict(_response.headers),
2316
+ body=typing.cast(
2317
+ RateLimitError,
2318
+ parse_obj_as(
2319
+ type_=RateLimitError, # type: ignore
2320
+ object_=_response.json(),
2321
+ ),
2322
+ ),
2323
+ )
900
2324
  if _response.status_code == 500:
901
2325
  raise InternalServerError(
902
2326
  headers=dict(_response.headers),
@@ -908,38 +2332,70 @@ class AsyncRawOrganizationsClient:
908
2332
  ),
909
2333
  ),
910
2334
  )
2335
+ if _response.status_code == 503:
2336
+ raise ServiceUnavailableError(
2337
+ headers=dict(_response.headers),
2338
+ body=typing.cast(
2339
+ typing.Optional[typing.Any],
2340
+ parse_obj_as(
2341
+ type_=typing.Optional[typing.Any], # type: ignore
2342
+ object_=_response.json(),
2343
+ ),
2344
+ ),
2345
+ )
911
2346
  _response_json = _response.json()
912
2347
  except JSONDecodeError:
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)
2348
+ raise ApiError(
2349
+ status_code=_response.status_code,
2350
+ headers=dict(_response.headers),
2351
+ body=_response.text,
2352
+ )
2353
+ raise ApiError(
2354
+ status_code=_response.status_code,
2355
+ headers=dict(_response.headers),
2356
+ body=_response_json,
2357
+ )
915
2358
 
916
- async def credits(
917
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
918
- ) -> AsyncHttpResponse[OrganizationsCreditsResponse]:
2359
+ async def updatesubscription(
2360
+ self,
2361
+ id: str,
2362
+ *,
2363
+ target_plan: OrganizationsUpdateSubscriptionRequestTargetPlan,
2364
+ request_options: typing.Optional[RequestOptions] = None,
2365
+ ) -> AsyncHttpResponse[OrganizationsUpdateSubscriptionResponse]:
919
2366
  """
920
2367
  Parameters
921
2368
  ----------
922
2369
  id : str
923
2370
 
2371
+ target_plan : OrganizationsUpdateSubscriptionRequestTargetPlan
2372
+
924
2373
  request_options : typing.Optional[RequestOptions]
925
2374
  Request-specific configuration.
926
2375
 
927
2376
  Returns
928
2377
  -------
929
- AsyncHttpResponse[OrganizationsCreditsResponse]
2378
+ AsyncHttpResponse[OrganizationsUpdateSubscriptionResponse]
930
2379
  Success
931
2380
  """
932
2381
  _response = await self._client_wrapper.httpx_client.request(
933
- f"organizations/{jsonable_encoder(id)}/credits",
934
- method="GET",
2382
+ f"organizations/{jsonable_encoder(id)}/subscription/update",
2383
+ method="POST",
2384
+ json={
2385
+ "targetPlan": target_plan,
2386
+ },
2387
+ headers={
2388
+ "content-type": "application/json",
2389
+ },
935
2390
  request_options=request_options,
2391
+ omit=OMIT,
936
2392
  )
937
2393
  try:
938
2394
  if 200 <= _response.status_code < 300:
939
2395
  _data = typing.cast(
940
- OrganizationsCreditsResponse,
2396
+ OrganizationsUpdateSubscriptionResponse,
941
2397
  parse_obj_as(
942
- type_=OrganizationsCreditsResponse, # type: ignore
2398
+ type_=OrganizationsUpdateSubscriptionResponse, # type: ignore
943
2399
  object_=_response.json(),
944
2400
  ),
945
2401
  )
@@ -948,9 +2404,122 @@ class AsyncRawOrganizationsClient:
948
2404
  raise BadRequestError(
949
2405
  headers=dict(_response.headers),
950
2406
  body=typing.cast(
951
- HttpApiDecodeError,
2407
+ typing.Optional[typing.Any],
2408
+ parse_obj_as(
2409
+ type_=typing.Optional[typing.Any], # type: ignore
2410
+ object_=_response.json(),
2411
+ ),
2412
+ ),
2413
+ )
2414
+ if _response.status_code == 402:
2415
+ raise PaymentRequiredError(
2416
+ headers=dict(_response.headers),
2417
+ body=typing.cast(
2418
+ PlanLimitExceededError,
2419
+ parse_obj_as(
2420
+ type_=PlanLimitExceededError, # type: ignore
2421
+ object_=_response.json(),
2422
+ ),
2423
+ ),
2424
+ )
2425
+ if _response.status_code == 403:
2426
+ raise ForbiddenError(
2427
+ headers=dict(_response.headers),
2428
+ body=typing.cast(
2429
+ PermissionDeniedError,
2430
+ parse_obj_as(
2431
+ type_=PermissionDeniedError, # type: ignore
2432
+ object_=_response.json(),
2433
+ ),
2434
+ ),
2435
+ )
2436
+ if _response.status_code == 404:
2437
+ raise NotFoundError(
2438
+ headers=dict(_response.headers),
2439
+ body=typing.cast(
2440
+ NotFoundErrorBody,
2441
+ parse_obj_as(
2442
+ type_=NotFoundErrorBody, # type: ignore
2443
+ object_=_response.json(),
2444
+ ),
2445
+ ),
2446
+ )
2447
+ if _response.status_code == 429:
2448
+ raise TooManyRequestsError(
2449
+ headers=dict(_response.headers),
2450
+ body=typing.cast(
2451
+ RateLimitError,
2452
+ parse_obj_as(
2453
+ type_=RateLimitError, # type: ignore
2454
+ object_=_response.json(),
2455
+ ),
2456
+ ),
2457
+ )
2458
+ if _response.status_code == 500:
2459
+ raise InternalServerError(
2460
+ headers=dict(_response.headers),
2461
+ body=typing.cast(
2462
+ typing.Optional[typing.Any],
2463
+ parse_obj_as(
2464
+ type_=typing.Optional[typing.Any], # type: ignore
2465
+ object_=_response.json(),
2466
+ ),
2467
+ ),
2468
+ )
2469
+ if _response.status_code == 503:
2470
+ raise ServiceUnavailableError(
2471
+ headers=dict(_response.headers),
2472
+ body=typing.cast(
2473
+ typing.Optional[typing.Any],
2474
+ parse_obj_as(
2475
+ type_=typing.Optional[typing.Any], # type: ignore
2476
+ object_=_response.json(),
2477
+ ),
2478
+ ),
2479
+ )
2480
+ _response_json = _response.json()
2481
+ except JSONDecodeError:
2482
+ raise ApiError(
2483
+ status_code=_response.status_code,
2484
+ headers=dict(_response.headers),
2485
+ body=_response.text,
2486
+ )
2487
+ raise ApiError(
2488
+ status_code=_response.status_code,
2489
+ headers=dict(_response.headers),
2490
+ body=_response_json,
2491
+ )
2492
+
2493
+ async def cancelscheduleddowngrade(
2494
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
2495
+ ) -> AsyncHttpResponse[None]:
2496
+ """
2497
+ Parameters
2498
+ ----------
2499
+ id : str
2500
+
2501
+ request_options : typing.Optional[RequestOptions]
2502
+ Request-specific configuration.
2503
+
2504
+ Returns
2505
+ -------
2506
+ AsyncHttpResponse[None]
2507
+ """
2508
+ _response = await self._client_wrapper.httpx_client.request(
2509
+ f"organizations/{jsonable_encoder(id)}/subscription/cancel-downgrade",
2510
+ method="POST",
2511
+ request_options=request_options,
2512
+ )
2513
+ try:
2514
+ if 200 <= _response.status_code < 300:
2515
+ return AsyncHttpResponse(response=_response, data=None)
2516
+ if _response.status_code == 400:
2517
+ raise BadRequestError(
2518
+ headers=dict(_response.headers),
2519
+ body=typing.cast(
2520
+ typing.Optional[typing.Any],
952
2521
  parse_obj_as(
953
- type_=HttpApiDecodeError, # type: ignore
2522
+ type_=typing.Optional[typing.Any], # type: ignore
954
2523
  object_=_response.json(),
955
2524
  ),
956
2525
  ),
@@ -977,6 +2546,17 @@ class AsyncRawOrganizationsClient:
977
2546
  ),
978
2547
  ),
979
2548
  )
2549
+ if _response.status_code == 429:
2550
+ raise TooManyRequestsError(
2551
+ headers=dict(_response.headers),
2552
+ body=typing.cast(
2553
+ RateLimitError,
2554
+ parse_obj_as(
2555
+ type_=RateLimitError, # type: ignore
2556
+ object_=_response.json(),
2557
+ ),
2558
+ ),
2559
+ )
980
2560
  if _response.status_code == 500:
981
2561
  raise InternalServerError(
982
2562
  headers=dict(_response.headers),
@@ -988,7 +2568,26 @@ class AsyncRawOrganizationsClient:
988
2568
  ),
989
2569
  ),
990
2570
  )
2571
+ if _response.status_code == 503:
2572
+ raise ServiceUnavailableError(
2573
+ headers=dict(_response.headers),
2574
+ body=typing.cast(
2575
+ typing.Optional[typing.Any],
2576
+ parse_obj_as(
2577
+ type_=typing.Optional[typing.Any], # type: ignore
2578
+ object_=_response.json(),
2579
+ ),
2580
+ ),
2581
+ )
991
2582
  _response_json = _response.json()
992
2583
  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)
2584
+ raise ApiError(
2585
+ status_code=_response.status_code,
2586
+ headers=dict(_response.headers),
2587
+ body=_response.text,
2588
+ )
2589
+ raise ApiError(
2590
+ status_code=_response.status_code,
2591
+ headers=dict(_response.headers),
2592
+ body=_response_json,
2593
+ )