mirascope 2.0.0a6__py3-none-any.whl → 2.0.2__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 (230) hide show
  1. mirascope/_utils.py +34 -0
  2. mirascope/api/_generated/__init__.py +186 -5
  3. mirascope/api/_generated/annotations/client.py +38 -6
  4. mirascope/api/_generated/annotations/raw_client.py +366 -47
  5. mirascope/api/_generated/annotations/types/annotations_create_response.py +19 -6
  6. mirascope/api/_generated/annotations/types/annotations_get_response.py +19 -6
  7. mirascope/api/_generated/annotations/types/annotations_list_response_annotations_item.py +22 -7
  8. mirascope/api/_generated/annotations/types/annotations_update_response.py +19 -6
  9. mirascope/api/_generated/api_keys/__init__.py +12 -2
  10. mirascope/api/_generated/api_keys/client.py +107 -6
  11. mirascope/api/_generated/api_keys/raw_client.py +486 -38
  12. mirascope/api/_generated/api_keys/types/__init__.py +7 -1
  13. mirascope/api/_generated/api_keys/types/api_keys_list_all_for_org_response_item.py +40 -0
  14. mirascope/api/_generated/client.py +36 -0
  15. mirascope/api/_generated/docs/raw_client.py +71 -9
  16. mirascope/api/_generated/environment.py +3 -3
  17. mirascope/api/_generated/environments/__init__.py +6 -0
  18. mirascope/api/_generated/environments/client.py +158 -9
  19. mirascope/api/_generated/environments/raw_client.py +620 -52
  20. mirascope/api/_generated/environments/types/__init__.py +10 -0
  21. mirascope/api/_generated/environments/types/environments_get_analytics_response.py +60 -0
  22. mirascope/api/_generated/environments/types/environments_get_analytics_response_top_functions_item.py +24 -0
  23. mirascope/api/_generated/{organizations/types/organizations_credits_response.py → environments/types/environments_get_analytics_response_top_models_item.py} +6 -3
  24. mirascope/api/_generated/errors/__init__.py +6 -0
  25. mirascope/api/_generated/errors/bad_request_error.py +5 -2
  26. mirascope/api/_generated/errors/conflict_error.py +5 -2
  27. mirascope/api/_generated/errors/payment_required_error.py +15 -0
  28. mirascope/api/_generated/errors/service_unavailable_error.py +14 -0
  29. mirascope/api/_generated/errors/too_many_requests_error.py +15 -0
  30. mirascope/api/_generated/functions/__init__.py +10 -0
  31. mirascope/api/_generated/functions/client.py +222 -8
  32. mirascope/api/_generated/functions/raw_client.py +975 -134
  33. mirascope/api/_generated/functions/types/__init__.py +28 -4
  34. mirascope/api/_generated/functions/types/functions_get_by_env_response.py +53 -0
  35. mirascope/api/_generated/functions/types/functions_get_by_env_response_dependencies_value.py +22 -0
  36. mirascope/api/_generated/functions/types/functions_list_by_env_response.py +25 -0
  37. mirascope/api/_generated/functions/types/functions_list_by_env_response_functions_item.py +56 -0
  38. mirascope/api/_generated/functions/types/functions_list_by_env_response_functions_item_dependencies_value.py +22 -0
  39. mirascope/api/_generated/health/raw_client.py +74 -10
  40. mirascope/api/_generated/organization_invitations/__init__.py +33 -0
  41. mirascope/api/_generated/organization_invitations/client.py +546 -0
  42. mirascope/api/_generated/organization_invitations/raw_client.py +1519 -0
  43. mirascope/api/_generated/organization_invitations/types/__init__.py +53 -0
  44. mirascope/api/_generated/organization_invitations/types/organization_invitations_accept_response.py +34 -0
  45. mirascope/api/_generated/organization_invitations/types/organization_invitations_accept_response_role.py +7 -0
  46. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_request_role.py +7 -0
  47. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response.py +48 -0
  48. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response_role.py +7 -0
  49. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response_status.py +7 -0
  50. mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response.py +48 -0
  51. mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response_role.py +7 -0
  52. mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response_status.py +7 -0
  53. mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item.py +48 -0
  54. mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item_role.py +7 -0
  55. mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item_status.py +7 -0
  56. mirascope/api/_generated/organization_memberships/__init__.py +19 -0
  57. mirascope/api/_generated/organization_memberships/client.py +302 -0
  58. mirascope/api/_generated/organization_memberships/raw_client.py +736 -0
  59. mirascope/api/_generated/organization_memberships/types/__init__.py +27 -0
  60. mirascope/api/_generated/organization_memberships/types/organization_memberships_list_response_item.py +33 -0
  61. mirascope/api/_generated/organization_memberships/types/organization_memberships_list_response_item_role.py +7 -0
  62. mirascope/api/_generated/organization_memberships/types/organization_memberships_update_request_role.py +7 -0
  63. mirascope/api/_generated/organization_memberships/types/organization_memberships_update_response.py +31 -0
  64. mirascope/api/_generated/organization_memberships/types/organization_memberships_update_response_role.py +7 -0
  65. mirascope/api/_generated/organizations/__init__.py +26 -2
  66. mirascope/api/_generated/organizations/client.py +442 -20
  67. mirascope/api/_generated/organizations/raw_client.py +1763 -164
  68. mirascope/api/_generated/organizations/types/__init__.py +48 -2
  69. mirascope/api/_generated/organizations/types/organizations_create_payment_intent_response.py +24 -0
  70. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_request_target_plan.py +7 -0
  71. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response.py +47 -0
  72. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response_validation_errors_item.py +33 -0
  73. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response_validation_errors_item_resource.py +7 -0
  74. mirascope/api/_generated/organizations/types/organizations_router_balance_response.py +24 -0
  75. mirascope/api/_generated/organizations/types/organizations_subscription_response.py +53 -0
  76. mirascope/api/_generated/organizations/types/organizations_subscription_response_current_plan.py +7 -0
  77. mirascope/api/_generated/organizations/types/organizations_subscription_response_payment_method.py +26 -0
  78. mirascope/api/_generated/organizations/types/organizations_subscription_response_scheduled_change.py +34 -0
  79. mirascope/api/_generated/organizations/types/organizations_subscription_response_scheduled_change_target_plan.py +7 -0
  80. mirascope/api/_generated/organizations/types/organizations_update_subscription_request_target_plan.py +7 -0
  81. mirascope/api/_generated/organizations/types/organizations_update_subscription_response.py +35 -0
  82. mirascope/api/_generated/project_memberships/__init__.py +25 -0
  83. mirascope/api/_generated/project_memberships/client.py +437 -0
  84. mirascope/api/_generated/project_memberships/raw_client.py +1039 -0
  85. mirascope/api/_generated/project_memberships/types/__init__.py +29 -0
  86. mirascope/api/_generated/project_memberships/types/project_memberships_create_request_role.py +7 -0
  87. mirascope/api/_generated/project_memberships/types/project_memberships_create_response.py +35 -0
  88. mirascope/api/_generated/project_memberships/types/project_memberships_create_response_role.py +7 -0
  89. mirascope/api/_generated/project_memberships/types/project_memberships_list_response_item.py +33 -0
  90. mirascope/api/_generated/project_memberships/types/project_memberships_list_response_item_role.py +7 -0
  91. mirascope/api/_generated/project_memberships/types/project_memberships_update_request_role.py +7 -0
  92. mirascope/api/_generated/project_memberships/types/project_memberships_update_response.py +35 -0
  93. mirascope/api/_generated/project_memberships/types/project_memberships_update_response_role.py +7 -0
  94. mirascope/api/_generated/projects/raw_client.py +415 -58
  95. mirascope/api/_generated/reference.md +2767 -397
  96. mirascope/api/_generated/tags/__init__.py +19 -0
  97. mirascope/api/_generated/tags/client.py +504 -0
  98. mirascope/api/_generated/tags/raw_client.py +1288 -0
  99. mirascope/api/_generated/tags/types/__init__.py +17 -0
  100. mirascope/api/_generated/tags/types/tags_create_response.py +41 -0
  101. mirascope/api/_generated/tags/types/tags_get_response.py +41 -0
  102. mirascope/api/_generated/tags/types/tags_list_response.py +23 -0
  103. mirascope/api/_generated/tags/types/tags_list_response_tags_item.py +41 -0
  104. mirascope/api/_generated/tags/types/tags_update_response.py +41 -0
  105. mirascope/api/_generated/token_cost/__init__.py +7 -0
  106. mirascope/api/_generated/token_cost/client.py +160 -0
  107. mirascope/api/_generated/token_cost/raw_client.py +264 -0
  108. mirascope/api/_generated/token_cost/types/__init__.py +8 -0
  109. mirascope/api/_generated/token_cost/types/token_cost_calculate_request_usage.py +54 -0
  110. mirascope/api/_generated/token_cost/types/token_cost_calculate_response.py +52 -0
  111. mirascope/api/_generated/traces/__init__.py +20 -0
  112. mirascope/api/_generated/traces/client.py +543 -0
  113. mirascope/api/_generated/traces/raw_client.py +1366 -96
  114. mirascope/api/_generated/traces/types/__init__.py +28 -0
  115. mirascope/api/_generated/traces/types/traces_get_analytics_summary_response.py +6 -0
  116. mirascope/api/_generated/traces/types/traces_get_trace_detail_by_env_response.py +33 -0
  117. mirascope/api/_generated/traces/types/traces_get_trace_detail_by_env_response_spans_item.py +88 -0
  118. mirascope/api/_generated/traces/types/traces_get_trace_detail_response_spans_item.py +0 -2
  119. mirascope/api/_generated/traces/types/traces_list_by_function_hash_response.py +25 -0
  120. mirascope/api/_generated/traces/types/traces_list_by_function_hash_response_traces_item.py +44 -0
  121. mirascope/api/_generated/traces/types/traces_search_by_env_request_attribute_filters_item.py +26 -0
  122. mirascope/api/_generated/traces/types/traces_search_by_env_request_attribute_filters_item_operator.py +7 -0
  123. mirascope/api/_generated/traces/types/traces_search_by_env_request_sort_by.py +7 -0
  124. mirascope/api/_generated/traces/types/traces_search_by_env_request_sort_order.py +7 -0
  125. mirascope/api/_generated/traces/types/traces_search_by_env_response.py +26 -0
  126. mirascope/api/_generated/traces/types/traces_search_by_env_response_spans_item.py +50 -0
  127. mirascope/api/_generated/traces/types/traces_search_response_spans_item.py +10 -1
  128. mirascope/api/_generated/types/__init__.py +32 -2
  129. mirascope/api/_generated/types/bad_request_error_body.py +50 -0
  130. mirascope/api/_generated/types/date.py +3 -0
  131. mirascope/api/_generated/types/immutable_resource_error.py +22 -0
  132. mirascope/api/_generated/types/internal_server_error_body.py +3 -3
  133. mirascope/api/_generated/types/plan_limit_exceeded_error.py +32 -0
  134. mirascope/api/_generated/types/plan_limit_exceeded_error_tag.py +7 -0
  135. mirascope/api/_generated/types/pricing_unavailable_error.py +23 -0
  136. mirascope/api/_generated/types/rate_limit_error.py +31 -0
  137. mirascope/api/_generated/types/rate_limit_error_tag.py +5 -0
  138. mirascope/api/_generated/types/service_unavailable_error_body.py +24 -0
  139. mirascope/api/_generated/types/service_unavailable_error_tag.py +7 -0
  140. mirascope/api/_generated/types/subscription_past_due_error.py +31 -0
  141. mirascope/api/_generated/types/subscription_past_due_error_tag.py +7 -0
  142. mirascope/api/settings.py +19 -1
  143. mirascope/llm/__init__.py +53 -10
  144. mirascope/llm/calls/__init__.py +2 -1
  145. mirascope/llm/calls/calls.py +29 -20
  146. mirascope/llm/calls/decorator.py +21 -7
  147. mirascope/llm/content/tool_output.py +22 -5
  148. mirascope/llm/exceptions.py +284 -71
  149. mirascope/llm/formatting/__init__.py +17 -0
  150. mirascope/llm/formatting/format.py +112 -35
  151. mirascope/llm/formatting/output_parser.py +178 -0
  152. mirascope/llm/formatting/partial.py +80 -7
  153. mirascope/llm/formatting/primitives.py +192 -0
  154. mirascope/llm/formatting/types.py +20 -8
  155. mirascope/llm/messages/__init__.py +3 -0
  156. mirascope/llm/messages/_utils.py +34 -0
  157. mirascope/llm/models/__init__.py +5 -0
  158. mirascope/llm/models/models.py +137 -69
  159. mirascope/llm/{providers/base → models}/params.py +7 -57
  160. mirascope/llm/models/thinking_config.py +61 -0
  161. mirascope/llm/prompts/_utils.py +0 -32
  162. mirascope/llm/prompts/decorator.py +16 -5
  163. mirascope/llm/prompts/prompts.py +160 -92
  164. mirascope/llm/providers/__init__.py +1 -4
  165. mirascope/llm/providers/anthropic/_utils/__init__.py +2 -0
  166. mirascope/llm/providers/anthropic/_utils/beta_decode.py +18 -9
  167. mirascope/llm/providers/anthropic/_utils/beta_encode.py +62 -13
  168. mirascope/llm/providers/anthropic/_utils/decode.py +18 -9
  169. mirascope/llm/providers/anthropic/_utils/encode.py +26 -7
  170. mirascope/llm/providers/anthropic/_utils/errors.py +2 -2
  171. mirascope/llm/providers/anthropic/beta_provider.py +64 -18
  172. mirascope/llm/providers/anthropic/provider.py +91 -33
  173. mirascope/llm/providers/base/__init__.py +0 -4
  174. mirascope/llm/providers/base/_utils.py +55 -6
  175. mirascope/llm/providers/base/base_provider.py +116 -37
  176. mirascope/llm/providers/google/_utils/__init__.py +2 -0
  177. mirascope/llm/providers/google/_utils/decode.py +20 -7
  178. mirascope/llm/providers/google/_utils/encode.py +26 -7
  179. mirascope/llm/providers/google/_utils/errors.py +3 -2
  180. mirascope/llm/providers/google/provider.py +64 -18
  181. mirascope/llm/providers/mirascope/_utils.py +13 -17
  182. mirascope/llm/providers/mirascope/provider.py +49 -18
  183. mirascope/llm/providers/mlx/_utils.py +7 -2
  184. mirascope/llm/providers/mlx/encoding/base.py +5 -2
  185. mirascope/llm/providers/mlx/encoding/transformers.py +5 -2
  186. mirascope/llm/providers/mlx/mlx.py +23 -6
  187. mirascope/llm/providers/mlx/provider.py +42 -13
  188. mirascope/llm/providers/openai/_utils/errors.py +2 -2
  189. mirascope/llm/providers/openai/completions/_utils/encode.py +20 -16
  190. mirascope/llm/providers/openai/completions/base_provider.py +40 -11
  191. mirascope/llm/providers/openai/provider.py +40 -10
  192. mirascope/llm/providers/openai/responses/_utils/__init__.py +2 -0
  193. mirascope/llm/providers/openai/responses/_utils/decode.py +19 -6
  194. mirascope/llm/providers/openai/responses/_utils/encode.py +22 -10
  195. mirascope/llm/providers/openai/responses/provider.py +56 -18
  196. mirascope/llm/providers/provider_registry.py +93 -19
  197. mirascope/llm/responses/__init__.py +6 -1
  198. mirascope/llm/responses/_utils.py +102 -12
  199. mirascope/llm/responses/base_response.py +5 -2
  200. mirascope/llm/responses/base_stream_response.py +115 -25
  201. mirascope/llm/responses/response.py +2 -1
  202. mirascope/llm/responses/root_response.py +89 -17
  203. mirascope/llm/responses/stream_response.py +6 -9
  204. mirascope/llm/tools/decorator.py +9 -4
  205. mirascope/llm/tools/tool_schema.py +17 -6
  206. mirascope/llm/tools/toolkit.py +35 -27
  207. mirascope/llm/tools/tools.py +45 -20
  208. mirascope/ops/__init__.py +4 -0
  209. mirascope/ops/_internal/closure.py +4 -1
  210. mirascope/ops/_internal/configuration.py +82 -31
  211. mirascope/ops/_internal/exporters/exporters.py +55 -35
  212. mirascope/ops/_internal/exporters/utils.py +37 -0
  213. mirascope/ops/_internal/instrumentation/llm/common.py +530 -0
  214. mirascope/ops/_internal/instrumentation/llm/cost.py +190 -0
  215. mirascope/ops/_internal/instrumentation/llm/encode.py +1 -1
  216. mirascope/ops/_internal/instrumentation/llm/llm.py +116 -1242
  217. mirascope/ops/_internal/instrumentation/llm/model.py +1798 -0
  218. mirascope/ops/_internal/instrumentation/llm/response.py +521 -0
  219. mirascope/ops/_internal/instrumentation/llm/serialize.py +300 -0
  220. mirascope/ops/_internal/protocols.py +83 -1
  221. mirascope/ops/_internal/traced_calls.py +18 -0
  222. mirascope/ops/_internal/traced_functions.py +125 -10
  223. mirascope/ops/_internal/tracing.py +78 -1
  224. mirascope/ops/_internal/utils.py +60 -4
  225. mirascope/ops/_internal/versioned_functions.py +1 -1
  226. {mirascope-2.0.0a6.dist-info → mirascope-2.0.2.dist-info}/METADATA +12 -11
  227. mirascope-2.0.2.dist-info/RECORD +424 -0
  228. {mirascope-2.0.0a6.dist-info → mirascope-2.0.2.dist-info}/licenses/LICENSE +1 -1
  229. mirascope-2.0.0a6.dist-info/RECORD +0 -316
  230. {mirascope-2.0.0a6.dist-info → mirascope-2.0.2.dist-info}/WHEEL +0 -0
@@ -0,0 +1,1519 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from json.decoder import JSONDecodeError
5
+
6
+ from ..core.api_error import ApiError
7
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
9
+ from ..core.jsonable_encoder import jsonable_encoder
10
+ from ..core.pydantic_utilities import parse_obj_as
11
+ from ..core.request_options import RequestOptions
12
+ from ..errors.bad_request_error import BadRequestError
13
+ from ..errors.conflict_error import ConflictError
14
+ from ..errors.forbidden_error import ForbiddenError
15
+ from ..errors.internal_server_error import InternalServerError
16
+ from ..errors.not_found_error import NotFoundError
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
20
+ from ..types.not_found_error_body import NotFoundErrorBody
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.organization_invitations_accept_response import (
25
+ OrganizationInvitationsAcceptResponse,
26
+ )
27
+ from .types.organization_invitations_create_request_role import (
28
+ OrganizationInvitationsCreateRequestRole,
29
+ )
30
+ from .types.organization_invitations_create_response import (
31
+ OrganizationInvitationsCreateResponse,
32
+ )
33
+ from .types.organization_invitations_get_response import (
34
+ OrganizationInvitationsGetResponse,
35
+ )
36
+ from .types.organization_invitations_list_response_item import (
37
+ OrganizationInvitationsListResponseItem,
38
+ )
39
+
40
+ # this is used as the default value for optional parameters
41
+ OMIT = typing.cast(typing.Any, ...)
42
+
43
+
44
+ class RawOrganizationInvitationsClient:
45
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
46
+ self._client_wrapper = client_wrapper
47
+
48
+ def list(
49
+ self,
50
+ organization_id: str,
51
+ *,
52
+ request_options: typing.Optional[RequestOptions] = None,
53
+ ) -> HttpResponse[typing.List[OrganizationInvitationsListResponseItem]]:
54
+ """
55
+ Parameters
56
+ ----------
57
+ organization_id : str
58
+
59
+ request_options : typing.Optional[RequestOptions]
60
+ Request-specific configuration.
61
+
62
+ Returns
63
+ -------
64
+ HttpResponse[typing.List[OrganizationInvitationsListResponseItem]]
65
+ Success
66
+ """
67
+ _response = self._client_wrapper.httpx_client.request(
68
+ f"organizations/{jsonable_encoder(organization_id)}/invitations",
69
+ method="GET",
70
+ request_options=request_options,
71
+ )
72
+ try:
73
+ if 200 <= _response.status_code < 300:
74
+ _data = typing.cast(
75
+ typing.List[OrganizationInvitationsListResponseItem],
76
+ parse_obj_as(
77
+ type_=typing.List[OrganizationInvitationsListResponseItem], # type: ignore
78
+ object_=_response.json(),
79
+ ),
80
+ )
81
+ return HttpResponse(response=_response, data=_data)
82
+ if _response.status_code == 400:
83
+ raise BadRequestError(
84
+ headers=dict(_response.headers),
85
+ body=typing.cast(
86
+ typing.Optional[typing.Any],
87
+ parse_obj_as(
88
+ type_=typing.Optional[typing.Any], # type: ignore
89
+ object_=_response.json(),
90
+ ),
91
+ ),
92
+ )
93
+ if _response.status_code == 403:
94
+ raise ForbiddenError(
95
+ headers=dict(_response.headers),
96
+ body=typing.cast(
97
+ PermissionDeniedError,
98
+ parse_obj_as(
99
+ type_=PermissionDeniedError, # type: ignore
100
+ object_=_response.json(),
101
+ ),
102
+ ),
103
+ )
104
+ if _response.status_code == 404:
105
+ raise NotFoundError(
106
+ headers=dict(_response.headers),
107
+ body=typing.cast(
108
+ NotFoundErrorBody,
109
+ parse_obj_as(
110
+ type_=NotFoundErrorBody, # type: ignore
111
+ object_=_response.json(),
112
+ ),
113
+ ),
114
+ )
115
+ if _response.status_code == 429:
116
+ raise TooManyRequestsError(
117
+ headers=dict(_response.headers),
118
+ body=typing.cast(
119
+ RateLimitError,
120
+ parse_obj_as(
121
+ type_=RateLimitError, # type: ignore
122
+ object_=_response.json(),
123
+ ),
124
+ ),
125
+ )
126
+ if _response.status_code == 500:
127
+ raise InternalServerError(
128
+ headers=dict(_response.headers),
129
+ body=typing.cast(
130
+ typing.Optional[typing.Any],
131
+ parse_obj_as(
132
+ type_=typing.Optional[typing.Any], # type: ignore
133
+ object_=_response.json(),
134
+ ),
135
+ ),
136
+ )
137
+ if _response.status_code == 503:
138
+ raise ServiceUnavailableError(
139
+ headers=dict(_response.headers),
140
+ body=typing.cast(
141
+ typing.Optional[typing.Any],
142
+ parse_obj_as(
143
+ type_=typing.Optional[typing.Any], # type: ignore
144
+ object_=_response.json(),
145
+ ),
146
+ ),
147
+ )
148
+ _response_json = _response.json()
149
+ except JSONDecodeError:
150
+ raise ApiError(
151
+ status_code=_response.status_code,
152
+ headers=dict(_response.headers),
153
+ body=_response.text,
154
+ )
155
+ raise ApiError(
156
+ status_code=_response.status_code,
157
+ headers=dict(_response.headers),
158
+ body=_response_json,
159
+ )
160
+
161
+ def create(
162
+ self,
163
+ organization_id: str,
164
+ *,
165
+ recipient_email: str,
166
+ role: OrganizationInvitationsCreateRequestRole,
167
+ request_options: typing.Optional[RequestOptions] = None,
168
+ ) -> HttpResponse[OrganizationInvitationsCreateResponse]:
169
+ """
170
+ Parameters
171
+ ----------
172
+ organization_id : str
173
+
174
+ recipient_email : str
175
+ a string matching the pattern ^[^ \t\n\r\f\v@]+@[^ \t\n\r\f\v@]+[.][^ \t\n\r\f\v@]+$
176
+
177
+ role : OrganizationInvitationsCreateRequestRole
178
+
179
+ request_options : typing.Optional[RequestOptions]
180
+ Request-specific configuration.
181
+
182
+ Returns
183
+ -------
184
+ HttpResponse[OrganizationInvitationsCreateResponse]
185
+ Success
186
+ """
187
+ _response = self._client_wrapper.httpx_client.request(
188
+ f"organizations/{jsonable_encoder(organization_id)}/invitations",
189
+ method="POST",
190
+ json={
191
+ "recipientEmail": recipient_email,
192
+ "role": role,
193
+ },
194
+ headers={
195
+ "content-type": "application/json",
196
+ },
197
+ request_options=request_options,
198
+ omit=OMIT,
199
+ )
200
+ try:
201
+ if 200 <= _response.status_code < 300:
202
+ _data = typing.cast(
203
+ OrganizationInvitationsCreateResponse,
204
+ parse_obj_as(
205
+ type_=OrganizationInvitationsCreateResponse, # type: ignore
206
+ object_=_response.json(),
207
+ ),
208
+ )
209
+ return HttpResponse(response=_response, data=_data)
210
+ if _response.status_code == 400:
211
+ raise BadRequestError(
212
+ headers=dict(_response.headers),
213
+ body=typing.cast(
214
+ typing.Optional[typing.Any],
215
+ parse_obj_as(
216
+ type_=typing.Optional[typing.Any], # type: ignore
217
+ object_=_response.json(),
218
+ ),
219
+ ),
220
+ )
221
+ if _response.status_code == 402:
222
+ raise PaymentRequiredError(
223
+ headers=dict(_response.headers),
224
+ body=typing.cast(
225
+ PlanLimitExceededError,
226
+ parse_obj_as(
227
+ type_=PlanLimitExceededError, # type: ignore
228
+ object_=_response.json(),
229
+ ),
230
+ ),
231
+ )
232
+ if _response.status_code == 403:
233
+ raise ForbiddenError(
234
+ headers=dict(_response.headers),
235
+ body=typing.cast(
236
+ PermissionDeniedError,
237
+ parse_obj_as(
238
+ type_=PermissionDeniedError, # type: ignore
239
+ object_=_response.json(),
240
+ ),
241
+ ),
242
+ )
243
+ if _response.status_code == 404:
244
+ raise NotFoundError(
245
+ headers=dict(_response.headers),
246
+ body=typing.cast(
247
+ NotFoundErrorBody,
248
+ parse_obj_as(
249
+ type_=NotFoundErrorBody, # type: ignore
250
+ object_=_response.json(),
251
+ ),
252
+ ),
253
+ )
254
+ if _response.status_code == 409:
255
+ raise ConflictError(
256
+ headers=dict(_response.headers),
257
+ body=typing.cast(
258
+ typing.Optional[typing.Any],
259
+ parse_obj_as(
260
+ type_=typing.Optional[typing.Any], # type: ignore
261
+ object_=_response.json(),
262
+ ),
263
+ ),
264
+ )
265
+ if _response.status_code == 429:
266
+ raise TooManyRequestsError(
267
+ headers=dict(_response.headers),
268
+ body=typing.cast(
269
+ RateLimitError,
270
+ parse_obj_as(
271
+ type_=RateLimitError, # type: ignore
272
+ object_=_response.json(),
273
+ ),
274
+ ),
275
+ )
276
+ if _response.status_code == 500:
277
+ raise InternalServerError(
278
+ headers=dict(_response.headers),
279
+ body=typing.cast(
280
+ typing.Optional[typing.Any],
281
+ parse_obj_as(
282
+ type_=typing.Optional[typing.Any], # type: ignore
283
+ object_=_response.json(),
284
+ ),
285
+ ),
286
+ )
287
+ if _response.status_code == 503:
288
+ raise ServiceUnavailableError(
289
+ headers=dict(_response.headers),
290
+ body=typing.cast(
291
+ typing.Optional[typing.Any],
292
+ parse_obj_as(
293
+ type_=typing.Optional[typing.Any], # type: ignore
294
+ object_=_response.json(),
295
+ ),
296
+ ),
297
+ )
298
+ _response_json = _response.json()
299
+ except JSONDecodeError:
300
+ raise ApiError(
301
+ status_code=_response.status_code,
302
+ headers=dict(_response.headers),
303
+ body=_response.text,
304
+ )
305
+ raise ApiError(
306
+ status_code=_response.status_code,
307
+ headers=dict(_response.headers),
308
+ body=_response_json,
309
+ )
310
+
311
+ def get(
312
+ self,
313
+ organization_id: str,
314
+ invitation_id: str,
315
+ *,
316
+ request_options: typing.Optional[RequestOptions] = None,
317
+ ) -> HttpResponse[OrganizationInvitationsGetResponse]:
318
+ """
319
+ Parameters
320
+ ----------
321
+ organization_id : str
322
+
323
+ invitation_id : str
324
+
325
+ request_options : typing.Optional[RequestOptions]
326
+ Request-specific configuration.
327
+
328
+ Returns
329
+ -------
330
+ HttpResponse[OrganizationInvitationsGetResponse]
331
+ Success
332
+ """
333
+ _response = self._client_wrapper.httpx_client.request(
334
+ f"organizations/{jsonable_encoder(organization_id)}/invitations/{jsonable_encoder(invitation_id)}",
335
+ method="GET",
336
+ request_options=request_options,
337
+ )
338
+ try:
339
+ if 200 <= _response.status_code < 300:
340
+ _data = typing.cast(
341
+ OrganizationInvitationsGetResponse,
342
+ parse_obj_as(
343
+ type_=OrganizationInvitationsGetResponse, # type: ignore
344
+ object_=_response.json(),
345
+ ),
346
+ )
347
+ return HttpResponse(response=_response, data=_data)
348
+ if _response.status_code == 400:
349
+ raise BadRequestError(
350
+ headers=dict(_response.headers),
351
+ body=typing.cast(
352
+ typing.Optional[typing.Any],
353
+ parse_obj_as(
354
+ type_=typing.Optional[typing.Any], # type: ignore
355
+ object_=_response.json(),
356
+ ),
357
+ ),
358
+ )
359
+ if _response.status_code == 403:
360
+ raise ForbiddenError(
361
+ headers=dict(_response.headers),
362
+ body=typing.cast(
363
+ PermissionDeniedError,
364
+ parse_obj_as(
365
+ type_=PermissionDeniedError, # type: ignore
366
+ object_=_response.json(),
367
+ ),
368
+ ),
369
+ )
370
+ if _response.status_code == 404:
371
+ raise NotFoundError(
372
+ headers=dict(_response.headers),
373
+ body=typing.cast(
374
+ NotFoundErrorBody,
375
+ parse_obj_as(
376
+ type_=NotFoundErrorBody, # type: ignore
377
+ object_=_response.json(),
378
+ ),
379
+ ),
380
+ )
381
+ if _response.status_code == 429:
382
+ raise TooManyRequestsError(
383
+ headers=dict(_response.headers),
384
+ body=typing.cast(
385
+ RateLimitError,
386
+ parse_obj_as(
387
+ type_=RateLimitError, # type: ignore
388
+ object_=_response.json(),
389
+ ),
390
+ ),
391
+ )
392
+ if _response.status_code == 500:
393
+ raise InternalServerError(
394
+ headers=dict(_response.headers),
395
+ body=typing.cast(
396
+ typing.Optional[typing.Any],
397
+ parse_obj_as(
398
+ type_=typing.Optional[typing.Any], # type: ignore
399
+ object_=_response.json(),
400
+ ),
401
+ ),
402
+ )
403
+ if _response.status_code == 503:
404
+ raise ServiceUnavailableError(
405
+ headers=dict(_response.headers),
406
+ body=typing.cast(
407
+ typing.Optional[typing.Any],
408
+ parse_obj_as(
409
+ type_=typing.Optional[typing.Any], # type: ignore
410
+ object_=_response.json(),
411
+ ),
412
+ ),
413
+ )
414
+ _response_json = _response.json()
415
+ except JSONDecodeError:
416
+ raise ApiError(
417
+ status_code=_response.status_code,
418
+ headers=dict(_response.headers),
419
+ body=_response.text,
420
+ )
421
+ raise ApiError(
422
+ status_code=_response.status_code,
423
+ headers=dict(_response.headers),
424
+ body=_response_json,
425
+ )
426
+
427
+ def resend(
428
+ self,
429
+ organization_id: str,
430
+ invitation_id: str,
431
+ *,
432
+ request_options: typing.Optional[RequestOptions] = None,
433
+ ) -> HttpResponse[None]:
434
+ """
435
+ Parameters
436
+ ----------
437
+ organization_id : str
438
+
439
+ invitation_id : str
440
+
441
+ request_options : typing.Optional[RequestOptions]
442
+ Request-specific configuration.
443
+
444
+ Returns
445
+ -------
446
+ HttpResponse[None]
447
+ """
448
+ _response = self._client_wrapper.httpx_client.request(
449
+ f"organizations/{jsonable_encoder(organization_id)}/invitations/{jsonable_encoder(invitation_id)}/resend",
450
+ method="POST",
451
+ request_options=request_options,
452
+ )
453
+ try:
454
+ if 200 <= _response.status_code < 300:
455
+ return HttpResponse(response=_response, data=None)
456
+ if _response.status_code == 400:
457
+ raise BadRequestError(
458
+ headers=dict(_response.headers),
459
+ body=typing.cast(
460
+ typing.Optional[typing.Any],
461
+ parse_obj_as(
462
+ type_=typing.Optional[typing.Any], # type: ignore
463
+ object_=_response.json(),
464
+ ),
465
+ ),
466
+ )
467
+ if _response.status_code == 403:
468
+ raise ForbiddenError(
469
+ headers=dict(_response.headers),
470
+ body=typing.cast(
471
+ PermissionDeniedError,
472
+ parse_obj_as(
473
+ type_=PermissionDeniedError, # type: ignore
474
+ object_=_response.json(),
475
+ ),
476
+ ),
477
+ )
478
+ if _response.status_code == 404:
479
+ raise NotFoundError(
480
+ headers=dict(_response.headers),
481
+ body=typing.cast(
482
+ NotFoundErrorBody,
483
+ parse_obj_as(
484
+ type_=NotFoundErrorBody, # type: ignore
485
+ object_=_response.json(),
486
+ ),
487
+ ),
488
+ )
489
+ if _response.status_code == 429:
490
+ raise TooManyRequestsError(
491
+ headers=dict(_response.headers),
492
+ body=typing.cast(
493
+ RateLimitError,
494
+ parse_obj_as(
495
+ type_=RateLimitError, # type: ignore
496
+ object_=_response.json(),
497
+ ),
498
+ ),
499
+ )
500
+ if _response.status_code == 500:
501
+ raise InternalServerError(
502
+ headers=dict(_response.headers),
503
+ body=typing.cast(
504
+ typing.Optional[typing.Any],
505
+ parse_obj_as(
506
+ type_=typing.Optional[typing.Any], # type: ignore
507
+ object_=_response.json(),
508
+ ),
509
+ ),
510
+ )
511
+ if _response.status_code == 503:
512
+ raise ServiceUnavailableError(
513
+ headers=dict(_response.headers),
514
+ body=typing.cast(
515
+ typing.Optional[typing.Any],
516
+ parse_obj_as(
517
+ type_=typing.Optional[typing.Any], # type: ignore
518
+ object_=_response.json(),
519
+ ),
520
+ ),
521
+ )
522
+ _response_json = _response.json()
523
+ except JSONDecodeError:
524
+ raise ApiError(
525
+ status_code=_response.status_code,
526
+ headers=dict(_response.headers),
527
+ body=_response.text,
528
+ )
529
+ raise ApiError(
530
+ status_code=_response.status_code,
531
+ headers=dict(_response.headers),
532
+ body=_response_json,
533
+ )
534
+
535
+ def revoke(
536
+ self,
537
+ organization_id: str,
538
+ invitation_id: str,
539
+ *,
540
+ request_options: typing.Optional[RequestOptions] = None,
541
+ ) -> HttpResponse[None]:
542
+ """
543
+ Parameters
544
+ ----------
545
+ organization_id : str
546
+
547
+ invitation_id : str
548
+
549
+ request_options : typing.Optional[RequestOptions]
550
+ Request-specific configuration.
551
+
552
+ Returns
553
+ -------
554
+ HttpResponse[None]
555
+ """
556
+ _response = self._client_wrapper.httpx_client.request(
557
+ f"organizations/{jsonable_encoder(organization_id)}/invitations/{jsonable_encoder(invitation_id)}/revoke",
558
+ method="POST",
559
+ request_options=request_options,
560
+ )
561
+ try:
562
+ if 200 <= _response.status_code < 300:
563
+ return HttpResponse(response=_response, data=None)
564
+ if _response.status_code == 400:
565
+ raise BadRequestError(
566
+ headers=dict(_response.headers),
567
+ body=typing.cast(
568
+ typing.Optional[typing.Any],
569
+ parse_obj_as(
570
+ type_=typing.Optional[typing.Any], # type: ignore
571
+ object_=_response.json(),
572
+ ),
573
+ ),
574
+ )
575
+ if _response.status_code == 403:
576
+ raise ForbiddenError(
577
+ headers=dict(_response.headers),
578
+ body=typing.cast(
579
+ PermissionDeniedError,
580
+ parse_obj_as(
581
+ type_=PermissionDeniedError, # type: ignore
582
+ object_=_response.json(),
583
+ ),
584
+ ),
585
+ )
586
+ if _response.status_code == 404:
587
+ raise NotFoundError(
588
+ headers=dict(_response.headers),
589
+ body=typing.cast(
590
+ NotFoundErrorBody,
591
+ parse_obj_as(
592
+ type_=NotFoundErrorBody, # type: ignore
593
+ object_=_response.json(),
594
+ ),
595
+ ),
596
+ )
597
+ if _response.status_code == 429:
598
+ raise TooManyRequestsError(
599
+ headers=dict(_response.headers),
600
+ body=typing.cast(
601
+ RateLimitError,
602
+ parse_obj_as(
603
+ type_=RateLimitError, # type: ignore
604
+ object_=_response.json(),
605
+ ),
606
+ ),
607
+ )
608
+ if _response.status_code == 500:
609
+ raise InternalServerError(
610
+ headers=dict(_response.headers),
611
+ body=typing.cast(
612
+ typing.Optional[typing.Any],
613
+ parse_obj_as(
614
+ type_=typing.Optional[typing.Any], # type: ignore
615
+ object_=_response.json(),
616
+ ),
617
+ ),
618
+ )
619
+ if _response.status_code == 503:
620
+ raise ServiceUnavailableError(
621
+ headers=dict(_response.headers),
622
+ body=typing.cast(
623
+ typing.Optional[typing.Any],
624
+ parse_obj_as(
625
+ type_=typing.Optional[typing.Any], # type: ignore
626
+ object_=_response.json(),
627
+ ),
628
+ ),
629
+ )
630
+ _response_json = _response.json()
631
+ except JSONDecodeError:
632
+ raise ApiError(
633
+ status_code=_response.status_code,
634
+ headers=dict(_response.headers),
635
+ body=_response.text,
636
+ )
637
+ raise ApiError(
638
+ status_code=_response.status_code,
639
+ headers=dict(_response.headers),
640
+ body=_response_json,
641
+ )
642
+
643
+ def accept(
644
+ self, *, token: str, request_options: typing.Optional[RequestOptions] = None
645
+ ) -> HttpResponse[OrganizationInvitationsAcceptResponse]:
646
+ """
647
+ Parameters
648
+ ----------
649
+ token : str
650
+
651
+ request_options : typing.Optional[RequestOptions]
652
+ Request-specific configuration.
653
+
654
+ Returns
655
+ -------
656
+ HttpResponse[OrganizationInvitationsAcceptResponse]
657
+ Success
658
+ """
659
+ _response = self._client_wrapper.httpx_client.request(
660
+ "invitations/accept",
661
+ method="POST",
662
+ json={
663
+ "token": token,
664
+ },
665
+ headers={
666
+ "content-type": "application/json",
667
+ },
668
+ request_options=request_options,
669
+ omit=OMIT,
670
+ )
671
+ try:
672
+ if 200 <= _response.status_code < 300:
673
+ _data = typing.cast(
674
+ OrganizationInvitationsAcceptResponse,
675
+ parse_obj_as(
676
+ type_=OrganizationInvitationsAcceptResponse, # type: ignore
677
+ object_=_response.json(),
678
+ ),
679
+ )
680
+ return HttpResponse(response=_response, data=_data)
681
+ if _response.status_code == 400:
682
+ raise BadRequestError(
683
+ headers=dict(_response.headers),
684
+ body=typing.cast(
685
+ typing.Optional[typing.Any],
686
+ parse_obj_as(
687
+ type_=typing.Optional[typing.Any], # type: ignore
688
+ object_=_response.json(),
689
+ ),
690
+ ),
691
+ )
692
+ if _response.status_code == 402:
693
+ raise PaymentRequiredError(
694
+ headers=dict(_response.headers),
695
+ body=typing.cast(
696
+ PlanLimitExceededError,
697
+ parse_obj_as(
698
+ type_=PlanLimitExceededError, # type: ignore
699
+ object_=_response.json(),
700
+ ),
701
+ ),
702
+ )
703
+ if _response.status_code == 403:
704
+ raise ForbiddenError(
705
+ headers=dict(_response.headers),
706
+ body=typing.cast(
707
+ PermissionDeniedError,
708
+ parse_obj_as(
709
+ type_=PermissionDeniedError, # type: ignore
710
+ object_=_response.json(),
711
+ ),
712
+ ),
713
+ )
714
+ if _response.status_code == 404:
715
+ raise NotFoundError(
716
+ headers=dict(_response.headers),
717
+ body=typing.cast(
718
+ NotFoundErrorBody,
719
+ parse_obj_as(
720
+ type_=NotFoundErrorBody, # type: ignore
721
+ object_=_response.json(),
722
+ ),
723
+ ),
724
+ )
725
+ if _response.status_code == 409:
726
+ raise ConflictError(
727
+ headers=dict(_response.headers),
728
+ body=typing.cast(
729
+ typing.Optional[typing.Any],
730
+ parse_obj_as(
731
+ type_=typing.Optional[typing.Any], # type: ignore
732
+ object_=_response.json(),
733
+ ),
734
+ ),
735
+ )
736
+ if _response.status_code == 429:
737
+ raise TooManyRequestsError(
738
+ headers=dict(_response.headers),
739
+ body=typing.cast(
740
+ RateLimitError,
741
+ parse_obj_as(
742
+ type_=RateLimitError, # type: ignore
743
+ object_=_response.json(),
744
+ ),
745
+ ),
746
+ )
747
+ if _response.status_code == 500:
748
+ raise InternalServerError(
749
+ headers=dict(_response.headers),
750
+ body=typing.cast(
751
+ typing.Optional[typing.Any],
752
+ parse_obj_as(
753
+ type_=typing.Optional[typing.Any], # type: ignore
754
+ object_=_response.json(),
755
+ ),
756
+ ),
757
+ )
758
+ if _response.status_code == 503:
759
+ raise ServiceUnavailableError(
760
+ headers=dict(_response.headers),
761
+ body=typing.cast(
762
+ typing.Optional[typing.Any],
763
+ parse_obj_as(
764
+ type_=typing.Optional[typing.Any], # type: ignore
765
+ object_=_response.json(),
766
+ ),
767
+ ),
768
+ )
769
+ _response_json = _response.json()
770
+ except JSONDecodeError:
771
+ raise ApiError(
772
+ status_code=_response.status_code,
773
+ headers=dict(_response.headers),
774
+ body=_response.text,
775
+ )
776
+ raise ApiError(
777
+ status_code=_response.status_code,
778
+ headers=dict(_response.headers),
779
+ body=_response_json,
780
+ )
781
+
782
+
783
+ class AsyncRawOrganizationInvitationsClient:
784
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
785
+ self._client_wrapper = client_wrapper
786
+
787
+ async def list(
788
+ self,
789
+ organization_id: str,
790
+ *,
791
+ request_options: typing.Optional[RequestOptions] = None,
792
+ ) -> AsyncHttpResponse[typing.List[OrganizationInvitationsListResponseItem]]:
793
+ """
794
+ Parameters
795
+ ----------
796
+ organization_id : str
797
+
798
+ request_options : typing.Optional[RequestOptions]
799
+ Request-specific configuration.
800
+
801
+ Returns
802
+ -------
803
+ AsyncHttpResponse[typing.List[OrganizationInvitationsListResponseItem]]
804
+ Success
805
+ """
806
+ _response = await self._client_wrapper.httpx_client.request(
807
+ f"organizations/{jsonable_encoder(organization_id)}/invitations",
808
+ method="GET",
809
+ request_options=request_options,
810
+ )
811
+ try:
812
+ if 200 <= _response.status_code < 300:
813
+ _data = typing.cast(
814
+ typing.List[OrganizationInvitationsListResponseItem],
815
+ parse_obj_as(
816
+ type_=typing.List[OrganizationInvitationsListResponseItem], # type: ignore
817
+ object_=_response.json(),
818
+ ),
819
+ )
820
+ return AsyncHttpResponse(response=_response, data=_data)
821
+ if _response.status_code == 400:
822
+ raise BadRequestError(
823
+ headers=dict(_response.headers),
824
+ body=typing.cast(
825
+ typing.Optional[typing.Any],
826
+ parse_obj_as(
827
+ type_=typing.Optional[typing.Any], # type: ignore
828
+ object_=_response.json(),
829
+ ),
830
+ ),
831
+ )
832
+ if _response.status_code == 403:
833
+ raise ForbiddenError(
834
+ headers=dict(_response.headers),
835
+ body=typing.cast(
836
+ PermissionDeniedError,
837
+ parse_obj_as(
838
+ type_=PermissionDeniedError, # type: ignore
839
+ object_=_response.json(),
840
+ ),
841
+ ),
842
+ )
843
+ if _response.status_code == 404:
844
+ raise NotFoundError(
845
+ headers=dict(_response.headers),
846
+ body=typing.cast(
847
+ NotFoundErrorBody,
848
+ parse_obj_as(
849
+ type_=NotFoundErrorBody, # type: ignore
850
+ object_=_response.json(),
851
+ ),
852
+ ),
853
+ )
854
+ if _response.status_code == 429:
855
+ raise TooManyRequestsError(
856
+ headers=dict(_response.headers),
857
+ body=typing.cast(
858
+ RateLimitError,
859
+ parse_obj_as(
860
+ type_=RateLimitError, # type: ignore
861
+ object_=_response.json(),
862
+ ),
863
+ ),
864
+ )
865
+ if _response.status_code == 500:
866
+ raise InternalServerError(
867
+ headers=dict(_response.headers),
868
+ body=typing.cast(
869
+ typing.Optional[typing.Any],
870
+ parse_obj_as(
871
+ type_=typing.Optional[typing.Any], # type: ignore
872
+ object_=_response.json(),
873
+ ),
874
+ ),
875
+ )
876
+ if _response.status_code == 503:
877
+ raise ServiceUnavailableError(
878
+ headers=dict(_response.headers),
879
+ body=typing.cast(
880
+ typing.Optional[typing.Any],
881
+ parse_obj_as(
882
+ type_=typing.Optional[typing.Any], # type: ignore
883
+ object_=_response.json(),
884
+ ),
885
+ ),
886
+ )
887
+ _response_json = _response.json()
888
+ except JSONDecodeError:
889
+ raise ApiError(
890
+ status_code=_response.status_code,
891
+ headers=dict(_response.headers),
892
+ body=_response.text,
893
+ )
894
+ raise ApiError(
895
+ status_code=_response.status_code,
896
+ headers=dict(_response.headers),
897
+ body=_response_json,
898
+ )
899
+
900
+ async def create(
901
+ self,
902
+ organization_id: str,
903
+ *,
904
+ recipient_email: str,
905
+ role: OrganizationInvitationsCreateRequestRole,
906
+ request_options: typing.Optional[RequestOptions] = None,
907
+ ) -> AsyncHttpResponse[OrganizationInvitationsCreateResponse]:
908
+ """
909
+ Parameters
910
+ ----------
911
+ organization_id : str
912
+
913
+ recipient_email : str
914
+ a string matching the pattern ^[^ \t\n\r\f\v@]+@[^ \t\n\r\f\v@]+[.][^ \t\n\r\f\v@]+$
915
+
916
+ role : OrganizationInvitationsCreateRequestRole
917
+
918
+ request_options : typing.Optional[RequestOptions]
919
+ Request-specific configuration.
920
+
921
+ Returns
922
+ -------
923
+ AsyncHttpResponse[OrganizationInvitationsCreateResponse]
924
+ Success
925
+ """
926
+ _response = await self._client_wrapper.httpx_client.request(
927
+ f"organizations/{jsonable_encoder(organization_id)}/invitations",
928
+ method="POST",
929
+ json={
930
+ "recipientEmail": recipient_email,
931
+ "role": role,
932
+ },
933
+ headers={
934
+ "content-type": "application/json",
935
+ },
936
+ request_options=request_options,
937
+ omit=OMIT,
938
+ )
939
+ try:
940
+ if 200 <= _response.status_code < 300:
941
+ _data = typing.cast(
942
+ OrganizationInvitationsCreateResponse,
943
+ parse_obj_as(
944
+ type_=OrganizationInvitationsCreateResponse, # type: ignore
945
+ object_=_response.json(),
946
+ ),
947
+ )
948
+ return AsyncHttpResponse(response=_response, data=_data)
949
+ if _response.status_code == 400:
950
+ raise BadRequestError(
951
+ headers=dict(_response.headers),
952
+ body=typing.cast(
953
+ typing.Optional[typing.Any],
954
+ parse_obj_as(
955
+ type_=typing.Optional[typing.Any], # type: ignore
956
+ object_=_response.json(),
957
+ ),
958
+ ),
959
+ )
960
+ if _response.status_code == 402:
961
+ raise PaymentRequiredError(
962
+ headers=dict(_response.headers),
963
+ body=typing.cast(
964
+ PlanLimitExceededError,
965
+ parse_obj_as(
966
+ type_=PlanLimitExceededError, # type: ignore
967
+ object_=_response.json(),
968
+ ),
969
+ ),
970
+ )
971
+ if _response.status_code == 403:
972
+ raise ForbiddenError(
973
+ headers=dict(_response.headers),
974
+ body=typing.cast(
975
+ PermissionDeniedError,
976
+ parse_obj_as(
977
+ type_=PermissionDeniedError, # type: ignore
978
+ object_=_response.json(),
979
+ ),
980
+ ),
981
+ )
982
+ if _response.status_code == 404:
983
+ raise NotFoundError(
984
+ headers=dict(_response.headers),
985
+ body=typing.cast(
986
+ NotFoundErrorBody,
987
+ parse_obj_as(
988
+ type_=NotFoundErrorBody, # type: ignore
989
+ object_=_response.json(),
990
+ ),
991
+ ),
992
+ )
993
+ if _response.status_code == 409:
994
+ raise ConflictError(
995
+ headers=dict(_response.headers),
996
+ body=typing.cast(
997
+ typing.Optional[typing.Any],
998
+ parse_obj_as(
999
+ type_=typing.Optional[typing.Any], # type: ignore
1000
+ object_=_response.json(),
1001
+ ),
1002
+ ),
1003
+ )
1004
+ if _response.status_code == 429:
1005
+ raise TooManyRequestsError(
1006
+ headers=dict(_response.headers),
1007
+ body=typing.cast(
1008
+ RateLimitError,
1009
+ parse_obj_as(
1010
+ type_=RateLimitError, # type: ignore
1011
+ object_=_response.json(),
1012
+ ),
1013
+ ),
1014
+ )
1015
+ if _response.status_code == 500:
1016
+ raise InternalServerError(
1017
+ headers=dict(_response.headers),
1018
+ body=typing.cast(
1019
+ typing.Optional[typing.Any],
1020
+ parse_obj_as(
1021
+ type_=typing.Optional[typing.Any], # type: ignore
1022
+ object_=_response.json(),
1023
+ ),
1024
+ ),
1025
+ )
1026
+ if _response.status_code == 503:
1027
+ raise ServiceUnavailableError(
1028
+ headers=dict(_response.headers),
1029
+ body=typing.cast(
1030
+ typing.Optional[typing.Any],
1031
+ parse_obj_as(
1032
+ type_=typing.Optional[typing.Any], # type: ignore
1033
+ object_=_response.json(),
1034
+ ),
1035
+ ),
1036
+ )
1037
+ _response_json = _response.json()
1038
+ except JSONDecodeError:
1039
+ raise ApiError(
1040
+ status_code=_response.status_code,
1041
+ headers=dict(_response.headers),
1042
+ body=_response.text,
1043
+ )
1044
+ raise ApiError(
1045
+ status_code=_response.status_code,
1046
+ headers=dict(_response.headers),
1047
+ body=_response_json,
1048
+ )
1049
+
1050
+ async def get(
1051
+ self,
1052
+ organization_id: str,
1053
+ invitation_id: str,
1054
+ *,
1055
+ request_options: typing.Optional[RequestOptions] = None,
1056
+ ) -> AsyncHttpResponse[OrganizationInvitationsGetResponse]:
1057
+ """
1058
+ Parameters
1059
+ ----------
1060
+ organization_id : str
1061
+
1062
+ invitation_id : str
1063
+
1064
+ request_options : typing.Optional[RequestOptions]
1065
+ Request-specific configuration.
1066
+
1067
+ Returns
1068
+ -------
1069
+ AsyncHttpResponse[OrganizationInvitationsGetResponse]
1070
+ Success
1071
+ """
1072
+ _response = await self._client_wrapper.httpx_client.request(
1073
+ f"organizations/{jsonable_encoder(organization_id)}/invitations/{jsonable_encoder(invitation_id)}",
1074
+ method="GET",
1075
+ request_options=request_options,
1076
+ )
1077
+ try:
1078
+ if 200 <= _response.status_code < 300:
1079
+ _data = typing.cast(
1080
+ OrganizationInvitationsGetResponse,
1081
+ parse_obj_as(
1082
+ type_=OrganizationInvitationsGetResponse, # type: ignore
1083
+ object_=_response.json(),
1084
+ ),
1085
+ )
1086
+ return AsyncHttpResponse(response=_response, data=_data)
1087
+ if _response.status_code == 400:
1088
+ raise BadRequestError(
1089
+ headers=dict(_response.headers),
1090
+ body=typing.cast(
1091
+ typing.Optional[typing.Any],
1092
+ parse_obj_as(
1093
+ type_=typing.Optional[typing.Any], # type: ignore
1094
+ object_=_response.json(),
1095
+ ),
1096
+ ),
1097
+ )
1098
+ if _response.status_code == 403:
1099
+ raise ForbiddenError(
1100
+ headers=dict(_response.headers),
1101
+ body=typing.cast(
1102
+ PermissionDeniedError,
1103
+ parse_obj_as(
1104
+ type_=PermissionDeniedError, # type: ignore
1105
+ object_=_response.json(),
1106
+ ),
1107
+ ),
1108
+ )
1109
+ if _response.status_code == 404:
1110
+ raise NotFoundError(
1111
+ headers=dict(_response.headers),
1112
+ body=typing.cast(
1113
+ NotFoundErrorBody,
1114
+ parse_obj_as(
1115
+ type_=NotFoundErrorBody, # type: ignore
1116
+ object_=_response.json(),
1117
+ ),
1118
+ ),
1119
+ )
1120
+ if _response.status_code == 429:
1121
+ raise TooManyRequestsError(
1122
+ headers=dict(_response.headers),
1123
+ body=typing.cast(
1124
+ RateLimitError,
1125
+ parse_obj_as(
1126
+ type_=RateLimitError, # type: ignore
1127
+ object_=_response.json(),
1128
+ ),
1129
+ ),
1130
+ )
1131
+ if _response.status_code == 500:
1132
+ raise InternalServerError(
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 == 503:
1143
+ raise ServiceUnavailableError(
1144
+ headers=dict(_response.headers),
1145
+ body=typing.cast(
1146
+ typing.Optional[typing.Any],
1147
+ parse_obj_as(
1148
+ type_=typing.Optional[typing.Any], # type: ignore
1149
+ object_=_response.json(),
1150
+ ),
1151
+ ),
1152
+ )
1153
+ _response_json = _response.json()
1154
+ except JSONDecodeError:
1155
+ raise ApiError(
1156
+ status_code=_response.status_code,
1157
+ headers=dict(_response.headers),
1158
+ body=_response.text,
1159
+ )
1160
+ raise ApiError(
1161
+ status_code=_response.status_code,
1162
+ headers=dict(_response.headers),
1163
+ body=_response_json,
1164
+ )
1165
+
1166
+ async def resend(
1167
+ self,
1168
+ organization_id: str,
1169
+ invitation_id: str,
1170
+ *,
1171
+ request_options: typing.Optional[RequestOptions] = None,
1172
+ ) -> AsyncHttpResponse[None]:
1173
+ """
1174
+ Parameters
1175
+ ----------
1176
+ organization_id : str
1177
+
1178
+ invitation_id : str
1179
+
1180
+ request_options : typing.Optional[RequestOptions]
1181
+ Request-specific configuration.
1182
+
1183
+ Returns
1184
+ -------
1185
+ AsyncHttpResponse[None]
1186
+ """
1187
+ _response = await self._client_wrapper.httpx_client.request(
1188
+ f"organizations/{jsonable_encoder(organization_id)}/invitations/{jsonable_encoder(invitation_id)}/resend",
1189
+ method="POST",
1190
+ request_options=request_options,
1191
+ )
1192
+ try:
1193
+ if 200 <= _response.status_code < 300:
1194
+ return AsyncHttpResponse(response=_response, data=None)
1195
+ if _response.status_code == 400:
1196
+ raise BadRequestError(
1197
+ headers=dict(_response.headers),
1198
+ body=typing.cast(
1199
+ typing.Optional[typing.Any],
1200
+ parse_obj_as(
1201
+ type_=typing.Optional[typing.Any], # type: ignore
1202
+ object_=_response.json(),
1203
+ ),
1204
+ ),
1205
+ )
1206
+ if _response.status_code == 403:
1207
+ raise ForbiddenError(
1208
+ headers=dict(_response.headers),
1209
+ body=typing.cast(
1210
+ PermissionDeniedError,
1211
+ parse_obj_as(
1212
+ type_=PermissionDeniedError, # type: ignore
1213
+ object_=_response.json(),
1214
+ ),
1215
+ ),
1216
+ )
1217
+ if _response.status_code == 404:
1218
+ raise NotFoundError(
1219
+ headers=dict(_response.headers),
1220
+ body=typing.cast(
1221
+ NotFoundErrorBody,
1222
+ parse_obj_as(
1223
+ type_=NotFoundErrorBody, # type: ignore
1224
+ object_=_response.json(),
1225
+ ),
1226
+ ),
1227
+ )
1228
+ if _response.status_code == 429:
1229
+ raise TooManyRequestsError(
1230
+ headers=dict(_response.headers),
1231
+ body=typing.cast(
1232
+ RateLimitError,
1233
+ parse_obj_as(
1234
+ type_=RateLimitError, # type: ignore
1235
+ object_=_response.json(),
1236
+ ),
1237
+ ),
1238
+ )
1239
+ if _response.status_code == 500:
1240
+ raise InternalServerError(
1241
+ headers=dict(_response.headers),
1242
+ body=typing.cast(
1243
+ typing.Optional[typing.Any],
1244
+ parse_obj_as(
1245
+ type_=typing.Optional[typing.Any], # type: ignore
1246
+ object_=_response.json(),
1247
+ ),
1248
+ ),
1249
+ )
1250
+ if _response.status_code == 503:
1251
+ raise ServiceUnavailableError(
1252
+ headers=dict(_response.headers),
1253
+ body=typing.cast(
1254
+ typing.Optional[typing.Any],
1255
+ parse_obj_as(
1256
+ type_=typing.Optional[typing.Any], # type: ignore
1257
+ object_=_response.json(),
1258
+ ),
1259
+ ),
1260
+ )
1261
+ _response_json = _response.json()
1262
+ except JSONDecodeError:
1263
+ raise ApiError(
1264
+ status_code=_response.status_code,
1265
+ headers=dict(_response.headers),
1266
+ body=_response.text,
1267
+ )
1268
+ raise ApiError(
1269
+ status_code=_response.status_code,
1270
+ headers=dict(_response.headers),
1271
+ body=_response_json,
1272
+ )
1273
+
1274
+ async def revoke(
1275
+ self,
1276
+ organization_id: str,
1277
+ invitation_id: str,
1278
+ *,
1279
+ request_options: typing.Optional[RequestOptions] = None,
1280
+ ) -> AsyncHttpResponse[None]:
1281
+ """
1282
+ Parameters
1283
+ ----------
1284
+ organization_id : str
1285
+
1286
+ invitation_id : str
1287
+
1288
+ request_options : typing.Optional[RequestOptions]
1289
+ Request-specific configuration.
1290
+
1291
+ Returns
1292
+ -------
1293
+ AsyncHttpResponse[None]
1294
+ """
1295
+ _response = await self._client_wrapper.httpx_client.request(
1296
+ f"organizations/{jsonable_encoder(organization_id)}/invitations/{jsonable_encoder(invitation_id)}/revoke",
1297
+ method="POST",
1298
+ request_options=request_options,
1299
+ )
1300
+ try:
1301
+ if 200 <= _response.status_code < 300:
1302
+ return AsyncHttpResponse(response=_response, data=None)
1303
+ if _response.status_code == 400:
1304
+ raise BadRequestError(
1305
+ headers=dict(_response.headers),
1306
+ body=typing.cast(
1307
+ typing.Optional[typing.Any],
1308
+ parse_obj_as(
1309
+ type_=typing.Optional[typing.Any], # type: ignore
1310
+ object_=_response.json(),
1311
+ ),
1312
+ ),
1313
+ )
1314
+ if _response.status_code == 403:
1315
+ raise ForbiddenError(
1316
+ headers=dict(_response.headers),
1317
+ body=typing.cast(
1318
+ PermissionDeniedError,
1319
+ parse_obj_as(
1320
+ type_=PermissionDeniedError, # type: ignore
1321
+ object_=_response.json(),
1322
+ ),
1323
+ ),
1324
+ )
1325
+ if _response.status_code == 404:
1326
+ raise NotFoundError(
1327
+ headers=dict(_response.headers),
1328
+ body=typing.cast(
1329
+ NotFoundErrorBody,
1330
+ parse_obj_as(
1331
+ type_=NotFoundErrorBody, # type: ignore
1332
+ object_=_response.json(),
1333
+ ),
1334
+ ),
1335
+ )
1336
+ if _response.status_code == 429:
1337
+ raise TooManyRequestsError(
1338
+ headers=dict(_response.headers),
1339
+ body=typing.cast(
1340
+ RateLimitError,
1341
+ parse_obj_as(
1342
+ type_=RateLimitError, # type: ignore
1343
+ object_=_response.json(),
1344
+ ),
1345
+ ),
1346
+ )
1347
+ if _response.status_code == 500:
1348
+ raise InternalServerError(
1349
+ headers=dict(_response.headers),
1350
+ body=typing.cast(
1351
+ typing.Optional[typing.Any],
1352
+ parse_obj_as(
1353
+ type_=typing.Optional[typing.Any], # type: ignore
1354
+ object_=_response.json(),
1355
+ ),
1356
+ ),
1357
+ )
1358
+ if _response.status_code == 503:
1359
+ raise ServiceUnavailableError(
1360
+ headers=dict(_response.headers),
1361
+ body=typing.cast(
1362
+ typing.Optional[typing.Any],
1363
+ parse_obj_as(
1364
+ type_=typing.Optional[typing.Any], # type: ignore
1365
+ object_=_response.json(),
1366
+ ),
1367
+ ),
1368
+ )
1369
+ _response_json = _response.json()
1370
+ except JSONDecodeError:
1371
+ raise ApiError(
1372
+ status_code=_response.status_code,
1373
+ headers=dict(_response.headers),
1374
+ body=_response.text,
1375
+ )
1376
+ raise ApiError(
1377
+ status_code=_response.status_code,
1378
+ headers=dict(_response.headers),
1379
+ body=_response_json,
1380
+ )
1381
+
1382
+ async def accept(
1383
+ self, *, token: str, request_options: typing.Optional[RequestOptions] = None
1384
+ ) -> AsyncHttpResponse[OrganizationInvitationsAcceptResponse]:
1385
+ """
1386
+ Parameters
1387
+ ----------
1388
+ token : str
1389
+
1390
+ request_options : typing.Optional[RequestOptions]
1391
+ Request-specific configuration.
1392
+
1393
+ Returns
1394
+ -------
1395
+ AsyncHttpResponse[OrganizationInvitationsAcceptResponse]
1396
+ Success
1397
+ """
1398
+ _response = await self._client_wrapper.httpx_client.request(
1399
+ "invitations/accept",
1400
+ method="POST",
1401
+ json={
1402
+ "token": token,
1403
+ },
1404
+ headers={
1405
+ "content-type": "application/json",
1406
+ },
1407
+ request_options=request_options,
1408
+ omit=OMIT,
1409
+ )
1410
+ try:
1411
+ if 200 <= _response.status_code < 300:
1412
+ _data = typing.cast(
1413
+ OrganizationInvitationsAcceptResponse,
1414
+ parse_obj_as(
1415
+ type_=OrganizationInvitationsAcceptResponse, # type: ignore
1416
+ object_=_response.json(),
1417
+ ),
1418
+ )
1419
+ return AsyncHttpResponse(response=_response, data=_data)
1420
+ if _response.status_code == 400:
1421
+ raise BadRequestError(
1422
+ headers=dict(_response.headers),
1423
+ body=typing.cast(
1424
+ typing.Optional[typing.Any],
1425
+ parse_obj_as(
1426
+ type_=typing.Optional[typing.Any], # type: ignore
1427
+ object_=_response.json(),
1428
+ ),
1429
+ ),
1430
+ )
1431
+ if _response.status_code == 402:
1432
+ raise PaymentRequiredError(
1433
+ headers=dict(_response.headers),
1434
+ body=typing.cast(
1435
+ PlanLimitExceededError,
1436
+ parse_obj_as(
1437
+ type_=PlanLimitExceededError, # type: ignore
1438
+ object_=_response.json(),
1439
+ ),
1440
+ ),
1441
+ )
1442
+ if _response.status_code == 403:
1443
+ raise ForbiddenError(
1444
+ headers=dict(_response.headers),
1445
+ body=typing.cast(
1446
+ PermissionDeniedError,
1447
+ parse_obj_as(
1448
+ type_=PermissionDeniedError, # type: ignore
1449
+ object_=_response.json(),
1450
+ ),
1451
+ ),
1452
+ )
1453
+ if _response.status_code == 404:
1454
+ raise NotFoundError(
1455
+ headers=dict(_response.headers),
1456
+ body=typing.cast(
1457
+ NotFoundErrorBody,
1458
+ parse_obj_as(
1459
+ type_=NotFoundErrorBody, # type: ignore
1460
+ object_=_response.json(),
1461
+ ),
1462
+ ),
1463
+ )
1464
+ if _response.status_code == 409:
1465
+ raise ConflictError(
1466
+ headers=dict(_response.headers),
1467
+ body=typing.cast(
1468
+ typing.Optional[typing.Any],
1469
+ parse_obj_as(
1470
+ type_=typing.Optional[typing.Any], # type: ignore
1471
+ object_=_response.json(),
1472
+ ),
1473
+ ),
1474
+ )
1475
+ if _response.status_code == 429:
1476
+ raise TooManyRequestsError(
1477
+ headers=dict(_response.headers),
1478
+ body=typing.cast(
1479
+ RateLimitError,
1480
+ parse_obj_as(
1481
+ type_=RateLimitError, # type: ignore
1482
+ object_=_response.json(),
1483
+ ),
1484
+ ),
1485
+ )
1486
+ if _response.status_code == 500:
1487
+ raise InternalServerError(
1488
+ headers=dict(_response.headers),
1489
+ body=typing.cast(
1490
+ typing.Optional[typing.Any],
1491
+ parse_obj_as(
1492
+ type_=typing.Optional[typing.Any], # type: ignore
1493
+ object_=_response.json(),
1494
+ ),
1495
+ ),
1496
+ )
1497
+ if _response.status_code == 503:
1498
+ raise ServiceUnavailableError(
1499
+ headers=dict(_response.headers),
1500
+ body=typing.cast(
1501
+ typing.Optional[typing.Any],
1502
+ parse_obj_as(
1503
+ type_=typing.Optional[typing.Any], # type: ignore
1504
+ object_=_response.json(),
1505
+ ),
1506
+ ),
1507
+ )
1508
+ _response_json = _response.json()
1509
+ except JSONDecodeError:
1510
+ raise ApiError(
1511
+ status_code=_response.status_code,
1512
+ headers=dict(_response.headers),
1513
+ body=_response.text,
1514
+ )
1515
+ raise ApiError(
1516
+ status_code=_response.status_code,
1517
+ headers=dict(_response.headers),
1518
+ body=_response_json,
1519
+ )