phenoml 0.0.6__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 (244) hide show
  1. phenoml/__init__.py +30 -0
  2. phenoml/agent/__init__.py +56 -0
  3. phenoml/agent/client.py +939 -0
  4. phenoml/agent/errors/__init__.py +11 -0
  5. phenoml/agent/errors/bad_request_error.py +10 -0
  6. phenoml/agent/errors/forbidden_error.py +10 -0
  7. phenoml/agent/errors/internal_server_error.py +10 -0
  8. phenoml/agent/errors/not_found_error.py +10 -0
  9. phenoml/agent/errors/unauthorized_error.py +10 -0
  10. phenoml/agent/prompts/__init__.py +7 -0
  11. phenoml/agent/prompts/client.py +707 -0
  12. phenoml/agent/prompts/raw_client.py +1345 -0
  13. phenoml/agent/prompts/types/__init__.py +8 -0
  14. phenoml/agent/prompts/types/prompts_delete_response.py +20 -0
  15. phenoml/agent/prompts/types/prompts_list_response.py +22 -0
  16. phenoml/agent/raw_client.py +1668 -0
  17. phenoml/agent/types/__init__.py +43 -0
  18. phenoml/agent/types/agent_chat_response.py +33 -0
  19. phenoml/agent/types/agent_create_request.py +53 -0
  20. phenoml/agent/types/agent_create_request_provider.py +5 -0
  21. phenoml/agent/types/agent_delete_response.py +20 -0
  22. phenoml/agent/types/agent_get_chat_messages_request_order.py +5 -0
  23. phenoml/agent/types/agent_get_chat_messages_response.py +22 -0
  24. phenoml/agent/types/agent_list_response.py +22 -0
  25. phenoml/agent/types/agent_prompts_response.py +22 -0
  26. phenoml/agent/types/agent_response.py +22 -0
  27. phenoml/agent/types/agent_template.py +58 -0
  28. phenoml/agent/types/agent_template_provider.py +5 -0
  29. phenoml/agent/types/chat_message_template.py +72 -0
  30. phenoml/agent/types/chat_session_template.py +67 -0
  31. phenoml/agent/types/json_patch.py +7 -0
  32. phenoml/agent/types/json_patch_operation.py +40 -0
  33. phenoml/agent/types/json_patch_operation_op.py +5 -0
  34. phenoml/agent/types/prompt_template.py +52 -0
  35. phenoml/agent/types/success_response.py +20 -0
  36. phenoml/authtoken/__init__.py +17 -0
  37. phenoml/authtoken/auth/__init__.py +7 -0
  38. phenoml/authtoken/auth/client.py +129 -0
  39. phenoml/authtoken/auth/raw_client.py +173 -0
  40. phenoml/authtoken/auth/types/__init__.py +7 -0
  41. phenoml/authtoken/auth/types/auth_generate_token_response.py +22 -0
  42. phenoml/authtoken/client.py +39 -0
  43. phenoml/authtoken/errors/__init__.py +8 -0
  44. phenoml/authtoken/errors/bad_request_error.py +10 -0
  45. phenoml/authtoken/errors/unauthorized_error.py +10 -0
  46. phenoml/authtoken/raw_client.py +13 -0
  47. phenoml/authtoken/types/__init__.py +8 -0
  48. phenoml/authtoken/types/bad_request_error_body.py +21 -0
  49. phenoml/authtoken/types/unauthorized_error_body.py +21 -0
  50. phenoml/client.py +177 -0
  51. phenoml/cohort/__init__.py +8 -0
  52. phenoml/cohort/client.py +113 -0
  53. phenoml/cohort/errors/__init__.py +9 -0
  54. phenoml/cohort/errors/bad_request_error.py +10 -0
  55. phenoml/cohort/errors/internal_server_error.py +10 -0
  56. phenoml/cohort/errors/unauthorized_error.py +10 -0
  57. phenoml/cohort/raw_client.py +185 -0
  58. phenoml/cohort/types/__init__.py +8 -0
  59. phenoml/cohort/types/cohort_response.py +33 -0
  60. phenoml/cohort/types/search_concept.py +37 -0
  61. phenoml/construe/__init__.py +45 -0
  62. phenoml/construe/client.py +399 -0
  63. phenoml/construe/errors/__init__.py +11 -0
  64. phenoml/construe/errors/bad_request_error.py +10 -0
  65. phenoml/construe/errors/conflict_error.py +10 -0
  66. phenoml/construe/errors/failed_dependency_error.py +10 -0
  67. phenoml/construe/errors/internal_server_error.py +10 -0
  68. phenoml/construe/errors/unauthorized_error.py +10 -0
  69. phenoml/construe/raw_client.py +706 -0
  70. phenoml/construe/types/__init__.py +41 -0
  71. phenoml/construe/types/bad_request_error_body.py +27 -0
  72. phenoml/construe/types/construe_cohort_request_config.py +37 -0
  73. phenoml/construe/types/construe_cohort_response.py +33 -0
  74. phenoml/construe/types/construe_cohort_response_queries_item.py +49 -0
  75. phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item.py +31 -0
  76. phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item_codes_item.py +32 -0
  77. phenoml/construe/types/construe_upload_code_system_response.py +19 -0
  78. phenoml/construe/types/extract_codes_result.py +22 -0
  79. phenoml/construe/types/extract_request_config.py +23 -0
  80. phenoml/construe/types/extract_request_config_chunking_method.py +5 -0
  81. phenoml/construe/types/extract_request_system.py +37 -0
  82. phenoml/construe/types/extracted_code_result.py +41 -0
  83. phenoml/construe/types/internal_server_error_body.py +27 -0
  84. phenoml/construe/types/unauthorized_error_body.py +27 -0
  85. phenoml/construe/types/upload_request_format.py +5 -0
  86. phenoml/core/__init__.py +52 -0
  87. phenoml/core/api_error.py +23 -0
  88. phenoml/core/client_wrapper.py +87 -0
  89. phenoml/core/datetime_utils.py +28 -0
  90. phenoml/core/file.py +67 -0
  91. phenoml/core/force_multipart.py +16 -0
  92. phenoml/core/http_client.py +543 -0
  93. phenoml/core/http_response.py +55 -0
  94. phenoml/core/jsonable_encoder.py +100 -0
  95. phenoml/core/pydantic_utilities.py +255 -0
  96. phenoml/core/query_encoder.py +58 -0
  97. phenoml/core/remove_none_from_dict.py +11 -0
  98. phenoml/core/request_options.py +35 -0
  99. phenoml/core/serialization.py +276 -0
  100. phenoml/environment.py +7 -0
  101. phenoml/fhir/__init__.py +36 -0
  102. phenoml/fhir/client.py +970 -0
  103. phenoml/fhir/errors/__init__.py +10 -0
  104. phenoml/fhir/errors/bad_request_error.py +10 -0
  105. phenoml/fhir/errors/internal_server_error.py +10 -0
  106. phenoml/fhir/errors/not_found_error.py +10 -0
  107. phenoml/fhir/errors/unauthorized_error.py +10 -0
  108. phenoml/fhir/raw_client.py +1385 -0
  109. phenoml/fhir/types/__init__.py +29 -0
  110. phenoml/fhir/types/error_response.py +36 -0
  111. phenoml/fhir/types/fhir_bundle.py +43 -0
  112. phenoml/fhir/types/fhir_bundle_entry_item.py +34 -0
  113. phenoml/fhir/types/fhir_bundle_entry_item_request.py +25 -0
  114. phenoml/fhir/types/fhir_bundle_entry_item_request_method.py +5 -0
  115. phenoml/fhir/types/fhir_bundle_entry_item_response.py +24 -0
  116. phenoml/fhir/types/fhir_patch_request_body_item.py +40 -0
  117. phenoml/fhir/types/fhir_patch_request_body_item_op.py +7 -0
  118. phenoml/fhir/types/fhir_resource.py +40 -0
  119. phenoml/fhir/types/fhir_resource_meta.py +28 -0
  120. phenoml/fhir/types/fhir_search_response.py +8 -0
  121. phenoml/fhir_provider/__init__.py +43 -0
  122. phenoml/fhir_provider/client.py +731 -0
  123. phenoml/fhir_provider/errors/__init__.py +11 -0
  124. phenoml/fhir_provider/errors/bad_request_error.py +10 -0
  125. phenoml/fhir_provider/errors/forbidden_error.py +10 -0
  126. phenoml/fhir_provider/errors/internal_server_error.py +10 -0
  127. phenoml/fhir_provider/errors/not_found_error.py +10 -0
  128. phenoml/fhir_provider/errors/unauthorized_error.py +10 -0
  129. phenoml/fhir_provider/raw_client.py +1445 -0
  130. phenoml/fhir_provider/types/__init__.py +35 -0
  131. phenoml/fhir_provider/types/auth_method.py +7 -0
  132. phenoml/fhir_provider/types/fhir_provider_auth_config.py +53 -0
  133. phenoml/fhir_provider/types/fhir_provider_delete_response.py +20 -0
  134. phenoml/fhir_provider/types/fhir_provider_list_response.py +22 -0
  135. phenoml/fhir_provider/types/fhir_provider_remove_auth_config_response.py +22 -0
  136. phenoml/fhir_provider/types/fhir_provider_response.py +22 -0
  137. phenoml/fhir_provider/types/fhir_provider_set_active_auth_config_response.py +22 -0
  138. phenoml/fhir_provider/types/fhir_provider_template.py +66 -0
  139. phenoml/fhir_provider/types/fhir_query_response.py +27 -0
  140. phenoml/fhir_provider/types/fhir_query_response_data.py +5 -0
  141. phenoml/fhir_provider/types/json_web_key.py +51 -0
  142. phenoml/fhir_provider/types/provider.py +8 -0
  143. phenoml/fhir_provider/types/service_account_key.py +35 -0
  144. phenoml/fhir_provider/types/smart_configuration.py +46 -0
  145. phenoml/lang2fhir/__init__.py +27 -0
  146. phenoml/lang2fhir/client.py +430 -0
  147. phenoml/lang2fhir/errors/__init__.py +11 -0
  148. phenoml/lang2fhir/errors/bad_request_error.py +10 -0
  149. phenoml/lang2fhir/errors/failed_dependency_error.py +10 -0
  150. phenoml/lang2fhir/errors/forbidden_error.py +10 -0
  151. phenoml/lang2fhir/errors/internal_server_error.py +10 -0
  152. phenoml/lang2fhir/errors/unauthorized_error.py +10 -0
  153. phenoml/lang2fhir/raw_client.py +788 -0
  154. phenoml/lang2fhir/types/__init__.py +19 -0
  155. phenoml/lang2fhir/types/create_request_resource.py +25 -0
  156. phenoml/lang2fhir/types/document_request_file_type.py +7 -0
  157. phenoml/lang2fhir/types/document_request_resource.py +5 -0
  158. phenoml/lang2fhir/types/fhir_resource.py +5 -0
  159. phenoml/lang2fhir/types/lang2fhir_upload_profile_response.py +23 -0
  160. phenoml/lang2fhir/types/search_response.py +33 -0
  161. phenoml/py.typed +0 -0
  162. phenoml/tools/__init__.py +37 -0
  163. phenoml/tools/client.py +359 -0
  164. phenoml/tools/errors/__init__.py +11 -0
  165. phenoml/tools/errors/bad_request_error.py +10 -0
  166. phenoml/tools/errors/failed_dependency_error.py +10 -0
  167. phenoml/tools/errors/forbidden_error.py +10 -0
  168. phenoml/tools/errors/internal_server_error.py +10 -0
  169. phenoml/tools/errors/unauthorized_error.py +10 -0
  170. phenoml/tools/mcp_server/__init__.py +7 -0
  171. phenoml/tools/mcp_server/client.py +336 -0
  172. phenoml/tools/mcp_server/raw_client.py +641 -0
  173. phenoml/tools/mcp_server/tools/__init__.py +4 -0
  174. phenoml/tools/mcp_server/tools/client.py +358 -0
  175. phenoml/tools/mcp_server/tools/raw_client.py +656 -0
  176. phenoml/tools/raw_client.py +696 -0
  177. phenoml/tools/types/__init__.py +27 -0
  178. phenoml/tools/types/cohort_response.py +49 -0
  179. phenoml/tools/types/lang2fhir_and_create_request_resource.py +25 -0
  180. phenoml/tools/types/lang2fhir_and_create_response.py +33 -0
  181. phenoml/tools/types/lang2fhir_and_search_response.py +40 -0
  182. phenoml/tools/types/mcp_server_response.py +33 -0
  183. phenoml/tools/types/mcp_server_response_data.py +51 -0
  184. phenoml/tools/types/mcp_server_tool_call_response.py +37 -0
  185. phenoml/tools/types/mcp_server_tool_response.py +33 -0
  186. phenoml/tools/types/mcp_server_tool_response_data.py +61 -0
  187. phenoml/tools/types/search_concept.py +41 -0
  188. phenoml/types/__init__.py +21 -0
  189. phenoml/types/cohort_response.py +5 -0
  190. phenoml/types/lang2fhir_and_create_response.py +5 -0
  191. phenoml/types/lang2fhir_and_search_response.py +5 -0
  192. phenoml/types/mcp_server_response.py +5 -0
  193. phenoml/types/mcp_server_tool_call_response.py +5 -0
  194. phenoml/types/mcp_server_tool_response.py +5 -0
  195. phenoml/types/search_concept.py +5 -0
  196. phenoml/version.py +3 -0
  197. phenoml/workflows/__init__.py +66 -0
  198. phenoml/workflows/client.py +210 -0
  199. phenoml/workflows/errors/__init__.py +11 -0
  200. phenoml/workflows/errors/bad_request_error.py +10 -0
  201. phenoml/workflows/errors/forbidden_error.py +10 -0
  202. phenoml/workflows/errors/internal_server_error.py +10 -0
  203. phenoml/workflows/errors/not_found_error.py +10 -0
  204. phenoml/workflows/errors/unauthorized_error.py +10 -0
  205. phenoml/workflows/mcp_server/__init__.py +7 -0
  206. phenoml/workflows/mcp_server/client.py +274 -0
  207. phenoml/workflows/mcp_server/raw_client.py +226 -0
  208. phenoml/workflows/mcp_server/tools/__init__.py +4 -0
  209. phenoml/workflows/mcp_server/tools/client.py +287 -0
  210. phenoml/workflows/mcp_server/tools/raw_client.py +244 -0
  211. phenoml/workflows/raw_client.py +169 -0
  212. phenoml/workflows/types/__init__.py +43 -0
  213. phenoml/workflows/types/create_workflow_response.py +44 -0
  214. phenoml/workflows/types/decision_node_definition.py +32 -0
  215. phenoml/workflows/types/execute_workflow_response.py +30 -0
  216. phenoml/workflows/types/execute_workflow_response_results.py +22 -0
  217. phenoml/workflows/types/lang2fhir_create_definition.py +37 -0
  218. phenoml/workflows/types/lang2fhir_search_definition.py +42 -0
  219. phenoml/workflows/types/list_workflows_response.py +39 -0
  220. phenoml/workflows/types/step_operation.py +26 -0
  221. phenoml/workflows/types/sub_workflow_definition.py +32 -0
  222. phenoml/workflows/types/workflow_config.py +27 -0
  223. phenoml/workflows/types/workflow_definition.py +57 -0
  224. phenoml/workflows/types/workflow_graph.py +23 -0
  225. phenoml/workflows/types/workflow_response.py +61 -0
  226. phenoml/workflows/types/workflow_response_graph.py +23 -0
  227. phenoml/workflows/types/workflow_step.py +55 -0
  228. phenoml/workflows/types/workflow_step_summary.py +47 -0
  229. phenoml/workflows/types/workflow_step_summary_type.py +5 -0
  230. phenoml/workflows/types/workflow_step_type.py +5 -0
  231. phenoml/workflows/workflows/__init__.py +19 -0
  232. phenoml/workflows/workflows/client.py +694 -0
  233. phenoml/workflows/workflows/raw_client.py +1266 -0
  234. phenoml/workflows/workflows/types/__init__.py +17 -0
  235. phenoml/workflows/workflows/types/create_workflow_request_fhir_provider_id.py +5 -0
  236. phenoml/workflows/workflows/types/update_workflow_request_fhir_provider_id.py +5 -0
  237. phenoml/workflows/workflows/types/workflows_delete_response.py +20 -0
  238. phenoml/workflows/workflows/types/workflows_get_response.py +26 -0
  239. phenoml/workflows/workflows/types/workflows_update_response.py +31 -0
  240. phenoml/wrapper_client.py +123 -0
  241. phenoml-0.0.6.dist-info/LICENSE +21 -0
  242. phenoml-0.0.6.dist-info/METADATA +192 -0
  243. phenoml-0.0.6.dist-info/RECORD +244 -0
  244. phenoml-0.0.6.dist-info/WHEEL +4 -0
@@ -0,0 +1,1445 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from ..core.api_error import ApiError
8
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
10
+ from ..core.jsonable_encoder import jsonable_encoder
11
+ from ..core.pydantic_utilities import parse_obj_as
12
+ from ..core.request_options import RequestOptions
13
+ from ..core.serialization import convert_and_respect_annotation_metadata
14
+ from .errors.bad_request_error import BadRequestError
15
+ from .errors.forbidden_error import ForbiddenError
16
+ from .errors.internal_server_error import InternalServerError
17
+ from .errors.not_found_error import NotFoundError
18
+ from .errors.unauthorized_error import UnauthorizedError
19
+ from .types.auth_method import AuthMethod
20
+ from .types.fhir_provider_delete_response import FhirProviderDeleteResponse
21
+ from .types.fhir_provider_list_response import FhirProviderListResponse
22
+ from .types.fhir_provider_remove_auth_config_response import FhirProviderRemoveAuthConfigResponse
23
+ from .types.fhir_provider_response import FhirProviderResponse
24
+ from .types.fhir_provider_set_active_auth_config_response import FhirProviderSetActiveAuthConfigResponse
25
+ from .types.provider import Provider
26
+ from .types.service_account_key import ServiceAccountKey
27
+
28
+ # this is used as the default value for optional parameters
29
+ OMIT = typing.cast(typing.Any, ...)
30
+
31
+
32
+ class RawFhirProviderClient:
33
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
34
+ self._client_wrapper = client_wrapper
35
+
36
+ def create(
37
+ self,
38
+ *,
39
+ name: str,
40
+ provider: Provider,
41
+ auth_method: AuthMethod,
42
+ base_url: str,
43
+ description: typing.Optional[str] = OMIT,
44
+ client_id: typing.Optional[str] = OMIT,
45
+ client_secret: typing.Optional[str] = OMIT,
46
+ service_account_key: typing.Optional[ServiceAccountKey] = OMIT,
47
+ scopes: typing.Optional[str] = OMIT,
48
+ request_options: typing.Optional[RequestOptions] = None,
49
+ ) -> HttpResponse[FhirProviderResponse]:
50
+ """
51
+ Creates a new FHIR provider configuration with authentication credentials
52
+
53
+ Parameters
54
+ ----------
55
+ name : str
56
+ Display name for the FHIR provider
57
+
58
+ provider : Provider
59
+
60
+ auth_method : AuthMethod
61
+
62
+ base_url : str
63
+ Base URL of the FHIR server
64
+
65
+ description : typing.Optional[str]
66
+ Optional description of the FHIR provider
67
+
68
+ client_id : typing.Optional[str]
69
+ OAuth client ID (required for most auth methods)
70
+
71
+ client_secret : typing.Optional[str]
72
+ OAuth client secret (required for client_secret and on_behalf_of auth methods)
73
+
74
+ service_account_key : typing.Optional[ServiceAccountKey]
75
+
76
+ scopes : typing.Optional[str]
77
+ OAuth scopes to request
78
+
79
+ request_options : typing.Optional[RequestOptions]
80
+ Request-specific configuration.
81
+
82
+ Returns
83
+ -------
84
+ HttpResponse[FhirProviderResponse]
85
+ FHIR provider created successfully
86
+ """
87
+ _response = self._client_wrapper.httpx_client.request(
88
+ "fhir-provider/create",
89
+ method="POST",
90
+ json={
91
+ "name": name,
92
+ "description": description,
93
+ "provider": provider,
94
+ "auth_method": auth_method,
95
+ "base_url": base_url,
96
+ "client_id": client_id,
97
+ "client_secret": client_secret,
98
+ "service_account_key": convert_and_respect_annotation_metadata(
99
+ object_=service_account_key, annotation=ServiceAccountKey, direction="write"
100
+ ),
101
+ "scopes": scopes,
102
+ },
103
+ headers={
104
+ "content-type": "application/json",
105
+ },
106
+ request_options=request_options,
107
+ omit=OMIT,
108
+ )
109
+ try:
110
+ if 200 <= _response.status_code < 300:
111
+ _data = typing.cast(
112
+ FhirProviderResponse,
113
+ parse_obj_as(
114
+ type_=FhirProviderResponse, # type: ignore
115
+ object_=_response.json(),
116
+ ),
117
+ )
118
+ return HttpResponse(response=_response, data=_data)
119
+ if _response.status_code == 400:
120
+ raise BadRequestError(
121
+ headers=dict(_response.headers),
122
+ body=typing.cast(
123
+ typing.Optional[typing.Any],
124
+ parse_obj_as(
125
+ type_=typing.Optional[typing.Any], # type: ignore
126
+ object_=_response.json(),
127
+ ),
128
+ ),
129
+ )
130
+ if _response.status_code == 401:
131
+ raise UnauthorizedError(
132
+ headers=dict(_response.headers),
133
+ body=typing.cast(
134
+ typing.Optional[typing.Any],
135
+ parse_obj_as(
136
+ type_=typing.Optional[typing.Any], # type: ignore
137
+ object_=_response.json(),
138
+ ),
139
+ ),
140
+ )
141
+ if _response.status_code == 403:
142
+ raise ForbiddenError(
143
+ headers=dict(_response.headers),
144
+ body=typing.cast(
145
+ typing.Optional[typing.Any],
146
+ parse_obj_as(
147
+ type_=typing.Optional[typing.Any], # type: ignore
148
+ object_=_response.json(),
149
+ ),
150
+ ),
151
+ )
152
+ if _response.status_code == 500:
153
+ raise InternalServerError(
154
+ headers=dict(_response.headers),
155
+ body=typing.cast(
156
+ typing.Optional[typing.Any],
157
+ parse_obj_as(
158
+ type_=typing.Optional[typing.Any], # type: ignore
159
+ object_=_response.json(),
160
+ ),
161
+ ),
162
+ )
163
+ _response_json = _response.json()
164
+ except JSONDecodeError:
165
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
166
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
167
+
168
+ def list(
169
+ self, *, request_options: typing.Optional[RequestOptions] = None
170
+ ) -> HttpResponse[FhirProviderListResponse]:
171
+ """
172
+ Retrieves a list of all active FHIR providers for the authenticated user
173
+
174
+ Parameters
175
+ ----------
176
+ request_options : typing.Optional[RequestOptions]
177
+ Request-specific configuration.
178
+
179
+ Returns
180
+ -------
181
+ HttpResponse[FhirProviderListResponse]
182
+ FHIR providers retrieved successfully
183
+ """
184
+ _response = self._client_wrapper.httpx_client.request(
185
+ "fhir-provider/list",
186
+ method="GET",
187
+ request_options=request_options,
188
+ )
189
+ try:
190
+ if 200 <= _response.status_code < 300:
191
+ _data = typing.cast(
192
+ FhirProviderListResponse,
193
+ parse_obj_as(
194
+ type_=FhirProviderListResponse, # type: ignore
195
+ object_=_response.json(),
196
+ ),
197
+ )
198
+ return HttpResponse(response=_response, data=_data)
199
+ if _response.status_code == 401:
200
+ raise UnauthorizedError(
201
+ headers=dict(_response.headers),
202
+ body=typing.cast(
203
+ typing.Optional[typing.Any],
204
+ parse_obj_as(
205
+ type_=typing.Optional[typing.Any], # type: ignore
206
+ object_=_response.json(),
207
+ ),
208
+ ),
209
+ )
210
+ if _response.status_code == 403:
211
+ raise ForbiddenError(
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 == 500:
222
+ raise InternalServerError(
223
+ headers=dict(_response.headers),
224
+ body=typing.cast(
225
+ typing.Optional[typing.Any],
226
+ parse_obj_as(
227
+ type_=typing.Optional[typing.Any], # type: ignore
228
+ object_=_response.json(),
229
+ ),
230
+ ),
231
+ )
232
+ _response_json = _response.json()
233
+ except JSONDecodeError:
234
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
235
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
236
+
237
+ def get(
238
+ self, fhir_provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
239
+ ) -> HttpResponse[FhirProviderResponse]:
240
+ """
241
+ Retrieves a specific FHIR provider configuration by its ID
242
+
243
+ Parameters
244
+ ----------
245
+ fhir_provider_id : str
246
+ ID of the FHIR provider to retrieve
247
+
248
+ request_options : typing.Optional[RequestOptions]
249
+ Request-specific configuration.
250
+
251
+ Returns
252
+ -------
253
+ HttpResponse[FhirProviderResponse]
254
+ FHIR provider retrieved successfully
255
+ """
256
+ _response = self._client_wrapper.httpx_client.request(
257
+ f"fhir-provider/{jsonable_encoder(fhir_provider_id)}",
258
+ method="GET",
259
+ request_options=request_options,
260
+ )
261
+ try:
262
+ if 200 <= _response.status_code < 300:
263
+ _data = typing.cast(
264
+ FhirProviderResponse,
265
+ parse_obj_as(
266
+ type_=FhirProviderResponse, # type: ignore
267
+ object_=_response.json(),
268
+ ),
269
+ )
270
+ return HttpResponse(response=_response, data=_data)
271
+ if _response.status_code == 401:
272
+ raise UnauthorizedError(
273
+ headers=dict(_response.headers),
274
+ body=typing.cast(
275
+ typing.Optional[typing.Any],
276
+ parse_obj_as(
277
+ type_=typing.Optional[typing.Any], # type: ignore
278
+ object_=_response.json(),
279
+ ),
280
+ ),
281
+ )
282
+ if _response.status_code == 403:
283
+ raise ForbiddenError(
284
+ headers=dict(_response.headers),
285
+ body=typing.cast(
286
+ typing.Optional[typing.Any],
287
+ parse_obj_as(
288
+ type_=typing.Optional[typing.Any], # type: ignore
289
+ object_=_response.json(),
290
+ ),
291
+ ),
292
+ )
293
+ if _response.status_code == 404:
294
+ raise NotFoundError(
295
+ headers=dict(_response.headers),
296
+ body=typing.cast(
297
+ typing.Optional[typing.Any],
298
+ parse_obj_as(
299
+ type_=typing.Optional[typing.Any], # type: ignore
300
+ object_=_response.json(),
301
+ ),
302
+ ),
303
+ )
304
+ if _response.status_code == 500:
305
+ raise InternalServerError(
306
+ headers=dict(_response.headers),
307
+ body=typing.cast(
308
+ typing.Optional[typing.Any],
309
+ parse_obj_as(
310
+ type_=typing.Optional[typing.Any], # type: ignore
311
+ object_=_response.json(),
312
+ ),
313
+ ),
314
+ )
315
+ _response_json = _response.json()
316
+ except JSONDecodeError:
317
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
318
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
319
+
320
+ def delete(
321
+ self, fhir_provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
322
+ ) -> HttpResponse[FhirProviderDeleteResponse]:
323
+ """
324
+ Soft deletes a FHIR provider by setting is_active to false
325
+
326
+ Parameters
327
+ ----------
328
+ fhir_provider_id : str
329
+ ID of the FHIR provider to delete
330
+
331
+ request_options : typing.Optional[RequestOptions]
332
+ Request-specific configuration.
333
+
334
+ Returns
335
+ -------
336
+ HttpResponse[FhirProviderDeleteResponse]
337
+ FHIR provider deleted successfully
338
+ """
339
+ _response = self._client_wrapper.httpx_client.request(
340
+ f"fhir-provider/{jsonable_encoder(fhir_provider_id)}",
341
+ method="DELETE",
342
+ request_options=request_options,
343
+ )
344
+ try:
345
+ if 200 <= _response.status_code < 300:
346
+ _data = typing.cast(
347
+ FhirProviderDeleteResponse,
348
+ parse_obj_as(
349
+ type_=FhirProviderDeleteResponse, # type: ignore
350
+ object_=_response.json(),
351
+ ),
352
+ )
353
+ return HttpResponse(response=_response, data=_data)
354
+ if _response.status_code == 401:
355
+ raise UnauthorizedError(
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
+ )
365
+ if _response.status_code == 403:
366
+ raise ForbiddenError(
367
+ headers=dict(_response.headers),
368
+ body=typing.cast(
369
+ typing.Optional[typing.Any],
370
+ parse_obj_as(
371
+ type_=typing.Optional[typing.Any], # type: ignore
372
+ object_=_response.json(),
373
+ ),
374
+ ),
375
+ )
376
+ if _response.status_code == 404:
377
+ raise NotFoundError(
378
+ headers=dict(_response.headers),
379
+ body=typing.cast(
380
+ typing.Optional[typing.Any],
381
+ parse_obj_as(
382
+ type_=typing.Optional[typing.Any], # type: ignore
383
+ object_=_response.json(),
384
+ ),
385
+ ),
386
+ )
387
+ if _response.status_code == 500:
388
+ raise InternalServerError(
389
+ headers=dict(_response.headers),
390
+ body=typing.cast(
391
+ typing.Optional[typing.Any],
392
+ parse_obj_as(
393
+ type_=typing.Optional[typing.Any], # type: ignore
394
+ object_=_response.json(),
395
+ ),
396
+ ),
397
+ )
398
+ _response_json = _response.json()
399
+ except JSONDecodeError:
400
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
401
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
402
+
403
+ def add_auth_config(
404
+ self,
405
+ fhir_provider_id: str,
406
+ *,
407
+ auth_method: AuthMethod,
408
+ client_secret: typing.Optional[str] = OMIT,
409
+ service_account_key: typing.Optional[ServiceAccountKey] = OMIT,
410
+ credential_expiry: typing.Optional[dt.datetime] = OMIT,
411
+ scopes: typing.Optional[str] = OMIT,
412
+ request_options: typing.Optional[RequestOptions] = None,
413
+ ) -> HttpResponse[FhirProviderResponse]:
414
+ """
415
+ Adds a new authentication configuration to an existing FHIR provider. This enables key rotation and multiple auth configurations per provider.
416
+
417
+ Parameters
418
+ ----------
419
+ fhir_provider_id : str
420
+ ID of the FHIR provider to add auth config to
421
+
422
+ auth_method : AuthMethod
423
+
424
+ client_secret : typing.Optional[str]
425
+ OAuth client secret (required for client_secret and on_behalf_of auth methods)
426
+
427
+ service_account_key : typing.Optional[ServiceAccountKey]
428
+
429
+ credential_expiry : typing.Optional[dt.datetime]
430
+ Expiry time for JWT credentials (only applicable for JWT auth method)
431
+
432
+ scopes : typing.Optional[str]
433
+ OAuth scopes to request
434
+
435
+ request_options : typing.Optional[RequestOptions]
436
+ Request-specific configuration.
437
+
438
+ Returns
439
+ -------
440
+ HttpResponse[FhirProviderResponse]
441
+ Auth configuration added successfully
442
+ """
443
+ _response = self._client_wrapper.httpx_client.request(
444
+ f"fhir-provider/{jsonable_encoder(fhir_provider_id)}/add-auth-config",
445
+ method="PATCH",
446
+ json={
447
+ "auth_method": auth_method,
448
+ "client_secret": client_secret,
449
+ "service_account_key": convert_and_respect_annotation_metadata(
450
+ object_=service_account_key, annotation=ServiceAccountKey, direction="write"
451
+ ),
452
+ "credential_expiry": credential_expiry,
453
+ "scopes": scopes,
454
+ },
455
+ headers={
456
+ "content-type": "application/json",
457
+ },
458
+ request_options=request_options,
459
+ omit=OMIT,
460
+ )
461
+ try:
462
+ if 200 <= _response.status_code < 300:
463
+ _data = typing.cast(
464
+ FhirProviderResponse,
465
+ parse_obj_as(
466
+ type_=FhirProviderResponse, # type: ignore
467
+ object_=_response.json(),
468
+ ),
469
+ )
470
+ return HttpResponse(response=_response, data=_data)
471
+ if _response.status_code == 400:
472
+ raise BadRequestError(
473
+ headers=dict(_response.headers),
474
+ body=typing.cast(
475
+ typing.Optional[typing.Any],
476
+ parse_obj_as(
477
+ type_=typing.Optional[typing.Any], # type: ignore
478
+ object_=_response.json(),
479
+ ),
480
+ ),
481
+ )
482
+ if _response.status_code == 401:
483
+ raise UnauthorizedError(
484
+ headers=dict(_response.headers),
485
+ body=typing.cast(
486
+ typing.Optional[typing.Any],
487
+ parse_obj_as(
488
+ type_=typing.Optional[typing.Any], # type: ignore
489
+ object_=_response.json(),
490
+ ),
491
+ ),
492
+ )
493
+ if _response.status_code == 403:
494
+ raise ForbiddenError(
495
+ headers=dict(_response.headers),
496
+ body=typing.cast(
497
+ typing.Optional[typing.Any],
498
+ parse_obj_as(
499
+ type_=typing.Optional[typing.Any], # type: ignore
500
+ object_=_response.json(),
501
+ ),
502
+ ),
503
+ )
504
+ if _response.status_code == 404:
505
+ raise NotFoundError(
506
+ headers=dict(_response.headers),
507
+ body=typing.cast(
508
+ typing.Optional[typing.Any],
509
+ parse_obj_as(
510
+ type_=typing.Optional[typing.Any], # type: ignore
511
+ object_=_response.json(),
512
+ ),
513
+ ),
514
+ )
515
+ if _response.status_code == 500:
516
+ raise InternalServerError(
517
+ headers=dict(_response.headers),
518
+ body=typing.cast(
519
+ typing.Optional[typing.Any],
520
+ parse_obj_as(
521
+ type_=typing.Optional[typing.Any], # type: ignore
522
+ object_=_response.json(),
523
+ ),
524
+ ),
525
+ )
526
+ _response_json = _response.json()
527
+ except JSONDecodeError:
528
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
529
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
530
+
531
+ def set_active_auth_config(
532
+ self, fhir_provider_id: str, *, auth_config_id: str, request_options: typing.Optional[RequestOptions] = None
533
+ ) -> HttpResponse[FhirProviderSetActiveAuthConfigResponse]:
534
+ """
535
+ Sets which authentication configuration should be active for a FHIR provider. Only one auth config can be active at a time.
536
+
537
+ Parameters
538
+ ----------
539
+ fhir_provider_id : str
540
+ ID of the FHIR provider
541
+
542
+ auth_config_id : str
543
+ ID of the auth configuration to set as active
544
+
545
+ request_options : typing.Optional[RequestOptions]
546
+ Request-specific configuration.
547
+
548
+ Returns
549
+ -------
550
+ HttpResponse[FhirProviderSetActiveAuthConfigResponse]
551
+ Active auth configuration set successfully
552
+ """
553
+ _response = self._client_wrapper.httpx_client.request(
554
+ f"fhir-provider/{jsonable_encoder(fhir_provider_id)}/set-active-auth-config",
555
+ method="PATCH",
556
+ json={
557
+ "auth_config_id": auth_config_id,
558
+ },
559
+ headers={
560
+ "content-type": "application/json",
561
+ },
562
+ request_options=request_options,
563
+ omit=OMIT,
564
+ )
565
+ try:
566
+ if 200 <= _response.status_code < 300:
567
+ _data = typing.cast(
568
+ FhirProviderSetActiveAuthConfigResponse,
569
+ parse_obj_as(
570
+ type_=FhirProviderSetActiveAuthConfigResponse, # type: ignore
571
+ object_=_response.json(),
572
+ ),
573
+ )
574
+ return HttpResponse(response=_response, data=_data)
575
+ if _response.status_code == 400:
576
+ raise BadRequestError(
577
+ headers=dict(_response.headers),
578
+ body=typing.cast(
579
+ typing.Optional[typing.Any],
580
+ parse_obj_as(
581
+ type_=typing.Optional[typing.Any], # type: ignore
582
+ object_=_response.json(),
583
+ ),
584
+ ),
585
+ )
586
+ if _response.status_code == 401:
587
+ raise UnauthorizedError(
588
+ headers=dict(_response.headers),
589
+ body=typing.cast(
590
+ typing.Optional[typing.Any],
591
+ parse_obj_as(
592
+ type_=typing.Optional[typing.Any], # type: ignore
593
+ object_=_response.json(),
594
+ ),
595
+ ),
596
+ )
597
+ if _response.status_code == 403:
598
+ raise ForbiddenError(
599
+ headers=dict(_response.headers),
600
+ body=typing.cast(
601
+ typing.Optional[typing.Any],
602
+ parse_obj_as(
603
+ type_=typing.Optional[typing.Any], # type: ignore
604
+ object_=_response.json(),
605
+ ),
606
+ ),
607
+ )
608
+ if _response.status_code == 404:
609
+ raise NotFoundError(
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 == 500:
620
+ raise InternalServerError(
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(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
633
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
634
+
635
+ def remove_auth_config(
636
+ self, fhir_provider_id: str, *, auth_config_id: str, request_options: typing.Optional[RequestOptions] = None
637
+ ) -> HttpResponse[FhirProviderRemoveAuthConfigResponse]:
638
+ """
639
+ Removes an authentication configuration from a FHIR provider. Cannot remove the currently active auth configuration.
640
+
641
+ Parameters
642
+ ----------
643
+ fhir_provider_id : str
644
+ ID of the FHIR provider
645
+
646
+ auth_config_id : str
647
+ ID of the auth configuration to remove
648
+
649
+ request_options : typing.Optional[RequestOptions]
650
+ Request-specific configuration.
651
+
652
+ Returns
653
+ -------
654
+ HttpResponse[FhirProviderRemoveAuthConfigResponse]
655
+ Auth configuration removed successfully
656
+ """
657
+ _response = self._client_wrapper.httpx_client.request(
658
+ f"fhir-provider/{jsonable_encoder(fhir_provider_id)}/remove-auth-config",
659
+ method="PATCH",
660
+ json={
661
+ "auth_config_id": auth_config_id,
662
+ },
663
+ headers={
664
+ "content-type": "application/json",
665
+ },
666
+ request_options=request_options,
667
+ omit=OMIT,
668
+ )
669
+ try:
670
+ if 200 <= _response.status_code < 300:
671
+ _data = typing.cast(
672
+ FhirProviderRemoveAuthConfigResponse,
673
+ parse_obj_as(
674
+ type_=FhirProviderRemoveAuthConfigResponse, # type: ignore
675
+ object_=_response.json(),
676
+ ),
677
+ )
678
+ return HttpResponse(response=_response, data=_data)
679
+ if _response.status_code == 400:
680
+ raise BadRequestError(
681
+ headers=dict(_response.headers),
682
+ body=typing.cast(
683
+ typing.Optional[typing.Any],
684
+ parse_obj_as(
685
+ type_=typing.Optional[typing.Any], # type: ignore
686
+ object_=_response.json(),
687
+ ),
688
+ ),
689
+ )
690
+ if _response.status_code == 401:
691
+ raise UnauthorizedError(
692
+ headers=dict(_response.headers),
693
+ body=typing.cast(
694
+ typing.Optional[typing.Any],
695
+ parse_obj_as(
696
+ type_=typing.Optional[typing.Any], # type: ignore
697
+ object_=_response.json(),
698
+ ),
699
+ ),
700
+ )
701
+ if _response.status_code == 403:
702
+ raise ForbiddenError(
703
+ headers=dict(_response.headers),
704
+ body=typing.cast(
705
+ typing.Optional[typing.Any],
706
+ parse_obj_as(
707
+ type_=typing.Optional[typing.Any], # type: ignore
708
+ object_=_response.json(),
709
+ ),
710
+ ),
711
+ )
712
+ if _response.status_code == 404:
713
+ raise NotFoundError(
714
+ headers=dict(_response.headers),
715
+ body=typing.cast(
716
+ typing.Optional[typing.Any],
717
+ parse_obj_as(
718
+ type_=typing.Optional[typing.Any], # type: ignore
719
+ object_=_response.json(),
720
+ ),
721
+ ),
722
+ )
723
+ if _response.status_code == 500:
724
+ raise InternalServerError(
725
+ headers=dict(_response.headers),
726
+ body=typing.cast(
727
+ typing.Optional[typing.Any],
728
+ parse_obj_as(
729
+ type_=typing.Optional[typing.Any], # type: ignore
730
+ object_=_response.json(),
731
+ ),
732
+ ),
733
+ )
734
+ _response_json = _response.json()
735
+ except JSONDecodeError:
736
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
737
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
738
+
739
+
740
+ class AsyncRawFhirProviderClient:
741
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
742
+ self._client_wrapper = client_wrapper
743
+
744
+ async def create(
745
+ self,
746
+ *,
747
+ name: str,
748
+ provider: Provider,
749
+ auth_method: AuthMethod,
750
+ base_url: str,
751
+ description: typing.Optional[str] = OMIT,
752
+ client_id: typing.Optional[str] = OMIT,
753
+ client_secret: typing.Optional[str] = OMIT,
754
+ service_account_key: typing.Optional[ServiceAccountKey] = OMIT,
755
+ scopes: typing.Optional[str] = OMIT,
756
+ request_options: typing.Optional[RequestOptions] = None,
757
+ ) -> AsyncHttpResponse[FhirProviderResponse]:
758
+ """
759
+ Creates a new FHIR provider configuration with authentication credentials
760
+
761
+ Parameters
762
+ ----------
763
+ name : str
764
+ Display name for the FHIR provider
765
+
766
+ provider : Provider
767
+
768
+ auth_method : AuthMethod
769
+
770
+ base_url : str
771
+ Base URL of the FHIR server
772
+
773
+ description : typing.Optional[str]
774
+ Optional description of the FHIR provider
775
+
776
+ client_id : typing.Optional[str]
777
+ OAuth client ID (required for most auth methods)
778
+
779
+ client_secret : typing.Optional[str]
780
+ OAuth client secret (required for client_secret and on_behalf_of auth methods)
781
+
782
+ service_account_key : typing.Optional[ServiceAccountKey]
783
+
784
+ scopes : typing.Optional[str]
785
+ OAuth scopes to request
786
+
787
+ request_options : typing.Optional[RequestOptions]
788
+ Request-specific configuration.
789
+
790
+ Returns
791
+ -------
792
+ AsyncHttpResponse[FhirProviderResponse]
793
+ FHIR provider created successfully
794
+ """
795
+ _response = await self._client_wrapper.httpx_client.request(
796
+ "fhir-provider/create",
797
+ method="POST",
798
+ json={
799
+ "name": name,
800
+ "description": description,
801
+ "provider": provider,
802
+ "auth_method": auth_method,
803
+ "base_url": base_url,
804
+ "client_id": client_id,
805
+ "client_secret": client_secret,
806
+ "service_account_key": convert_and_respect_annotation_metadata(
807
+ object_=service_account_key, annotation=ServiceAccountKey, direction="write"
808
+ ),
809
+ "scopes": scopes,
810
+ },
811
+ headers={
812
+ "content-type": "application/json",
813
+ },
814
+ request_options=request_options,
815
+ omit=OMIT,
816
+ )
817
+ try:
818
+ if 200 <= _response.status_code < 300:
819
+ _data = typing.cast(
820
+ FhirProviderResponse,
821
+ parse_obj_as(
822
+ type_=FhirProviderResponse, # type: ignore
823
+ object_=_response.json(),
824
+ ),
825
+ )
826
+ return AsyncHttpResponse(response=_response, data=_data)
827
+ if _response.status_code == 400:
828
+ raise BadRequestError(
829
+ headers=dict(_response.headers),
830
+ body=typing.cast(
831
+ typing.Optional[typing.Any],
832
+ parse_obj_as(
833
+ type_=typing.Optional[typing.Any], # type: ignore
834
+ object_=_response.json(),
835
+ ),
836
+ ),
837
+ )
838
+ if _response.status_code == 401:
839
+ raise UnauthorizedError(
840
+ headers=dict(_response.headers),
841
+ body=typing.cast(
842
+ typing.Optional[typing.Any],
843
+ parse_obj_as(
844
+ type_=typing.Optional[typing.Any], # type: ignore
845
+ object_=_response.json(),
846
+ ),
847
+ ),
848
+ )
849
+ if _response.status_code == 403:
850
+ raise ForbiddenError(
851
+ headers=dict(_response.headers),
852
+ body=typing.cast(
853
+ typing.Optional[typing.Any],
854
+ parse_obj_as(
855
+ type_=typing.Optional[typing.Any], # type: ignore
856
+ object_=_response.json(),
857
+ ),
858
+ ),
859
+ )
860
+ if _response.status_code == 500:
861
+ raise InternalServerError(
862
+ headers=dict(_response.headers),
863
+ body=typing.cast(
864
+ typing.Optional[typing.Any],
865
+ parse_obj_as(
866
+ type_=typing.Optional[typing.Any], # type: ignore
867
+ object_=_response.json(),
868
+ ),
869
+ ),
870
+ )
871
+ _response_json = _response.json()
872
+ except JSONDecodeError:
873
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
874
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
875
+
876
+ async def list(
877
+ self, *, request_options: typing.Optional[RequestOptions] = None
878
+ ) -> AsyncHttpResponse[FhirProviderListResponse]:
879
+ """
880
+ Retrieves a list of all active FHIR providers for the authenticated user
881
+
882
+ Parameters
883
+ ----------
884
+ request_options : typing.Optional[RequestOptions]
885
+ Request-specific configuration.
886
+
887
+ Returns
888
+ -------
889
+ AsyncHttpResponse[FhirProviderListResponse]
890
+ FHIR providers retrieved successfully
891
+ """
892
+ _response = await self._client_wrapper.httpx_client.request(
893
+ "fhir-provider/list",
894
+ method="GET",
895
+ request_options=request_options,
896
+ )
897
+ try:
898
+ if 200 <= _response.status_code < 300:
899
+ _data = typing.cast(
900
+ FhirProviderListResponse,
901
+ parse_obj_as(
902
+ type_=FhirProviderListResponse, # type: ignore
903
+ object_=_response.json(),
904
+ ),
905
+ )
906
+ return AsyncHttpResponse(response=_response, data=_data)
907
+ if _response.status_code == 401:
908
+ raise UnauthorizedError(
909
+ headers=dict(_response.headers),
910
+ body=typing.cast(
911
+ typing.Optional[typing.Any],
912
+ parse_obj_as(
913
+ type_=typing.Optional[typing.Any], # type: ignore
914
+ object_=_response.json(),
915
+ ),
916
+ ),
917
+ )
918
+ if _response.status_code == 403:
919
+ raise ForbiddenError(
920
+ headers=dict(_response.headers),
921
+ body=typing.cast(
922
+ typing.Optional[typing.Any],
923
+ parse_obj_as(
924
+ type_=typing.Optional[typing.Any], # type: ignore
925
+ object_=_response.json(),
926
+ ),
927
+ ),
928
+ )
929
+ if _response.status_code == 500:
930
+ raise InternalServerError(
931
+ headers=dict(_response.headers),
932
+ body=typing.cast(
933
+ typing.Optional[typing.Any],
934
+ parse_obj_as(
935
+ type_=typing.Optional[typing.Any], # type: ignore
936
+ object_=_response.json(),
937
+ ),
938
+ ),
939
+ )
940
+ _response_json = _response.json()
941
+ except JSONDecodeError:
942
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
943
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
944
+
945
+ async def get(
946
+ self, fhir_provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
947
+ ) -> AsyncHttpResponse[FhirProviderResponse]:
948
+ """
949
+ Retrieves a specific FHIR provider configuration by its ID
950
+
951
+ Parameters
952
+ ----------
953
+ fhir_provider_id : str
954
+ ID of the FHIR provider to retrieve
955
+
956
+ request_options : typing.Optional[RequestOptions]
957
+ Request-specific configuration.
958
+
959
+ Returns
960
+ -------
961
+ AsyncHttpResponse[FhirProviderResponse]
962
+ FHIR provider retrieved successfully
963
+ """
964
+ _response = await self._client_wrapper.httpx_client.request(
965
+ f"fhir-provider/{jsonable_encoder(fhir_provider_id)}",
966
+ method="GET",
967
+ request_options=request_options,
968
+ )
969
+ try:
970
+ if 200 <= _response.status_code < 300:
971
+ _data = typing.cast(
972
+ FhirProviderResponse,
973
+ parse_obj_as(
974
+ type_=FhirProviderResponse, # type: ignore
975
+ object_=_response.json(),
976
+ ),
977
+ )
978
+ return AsyncHttpResponse(response=_response, data=_data)
979
+ if _response.status_code == 401:
980
+ raise UnauthorizedError(
981
+ headers=dict(_response.headers),
982
+ body=typing.cast(
983
+ typing.Optional[typing.Any],
984
+ parse_obj_as(
985
+ type_=typing.Optional[typing.Any], # type: ignore
986
+ object_=_response.json(),
987
+ ),
988
+ ),
989
+ )
990
+ if _response.status_code == 403:
991
+ raise ForbiddenError(
992
+ headers=dict(_response.headers),
993
+ body=typing.cast(
994
+ typing.Optional[typing.Any],
995
+ parse_obj_as(
996
+ type_=typing.Optional[typing.Any], # type: ignore
997
+ object_=_response.json(),
998
+ ),
999
+ ),
1000
+ )
1001
+ if _response.status_code == 404:
1002
+ raise NotFoundError(
1003
+ headers=dict(_response.headers),
1004
+ body=typing.cast(
1005
+ typing.Optional[typing.Any],
1006
+ parse_obj_as(
1007
+ type_=typing.Optional[typing.Any], # type: ignore
1008
+ object_=_response.json(),
1009
+ ),
1010
+ ),
1011
+ )
1012
+ if _response.status_code == 500:
1013
+ raise InternalServerError(
1014
+ headers=dict(_response.headers),
1015
+ body=typing.cast(
1016
+ typing.Optional[typing.Any],
1017
+ parse_obj_as(
1018
+ type_=typing.Optional[typing.Any], # type: ignore
1019
+ object_=_response.json(),
1020
+ ),
1021
+ ),
1022
+ )
1023
+ _response_json = _response.json()
1024
+ except JSONDecodeError:
1025
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1026
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1027
+
1028
+ async def delete(
1029
+ self, fhir_provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
1030
+ ) -> AsyncHttpResponse[FhirProviderDeleteResponse]:
1031
+ """
1032
+ Soft deletes a FHIR provider by setting is_active to false
1033
+
1034
+ Parameters
1035
+ ----------
1036
+ fhir_provider_id : str
1037
+ ID of the FHIR provider to delete
1038
+
1039
+ request_options : typing.Optional[RequestOptions]
1040
+ Request-specific configuration.
1041
+
1042
+ Returns
1043
+ -------
1044
+ AsyncHttpResponse[FhirProviderDeleteResponse]
1045
+ FHIR provider deleted successfully
1046
+ """
1047
+ _response = await self._client_wrapper.httpx_client.request(
1048
+ f"fhir-provider/{jsonable_encoder(fhir_provider_id)}",
1049
+ method="DELETE",
1050
+ request_options=request_options,
1051
+ )
1052
+ try:
1053
+ if 200 <= _response.status_code < 300:
1054
+ _data = typing.cast(
1055
+ FhirProviderDeleteResponse,
1056
+ parse_obj_as(
1057
+ type_=FhirProviderDeleteResponse, # type: ignore
1058
+ object_=_response.json(),
1059
+ ),
1060
+ )
1061
+ return AsyncHttpResponse(response=_response, data=_data)
1062
+ if _response.status_code == 401:
1063
+ raise UnauthorizedError(
1064
+ headers=dict(_response.headers),
1065
+ body=typing.cast(
1066
+ typing.Optional[typing.Any],
1067
+ parse_obj_as(
1068
+ type_=typing.Optional[typing.Any], # type: ignore
1069
+ object_=_response.json(),
1070
+ ),
1071
+ ),
1072
+ )
1073
+ if _response.status_code == 403:
1074
+ raise ForbiddenError(
1075
+ headers=dict(_response.headers),
1076
+ body=typing.cast(
1077
+ typing.Optional[typing.Any],
1078
+ parse_obj_as(
1079
+ type_=typing.Optional[typing.Any], # type: ignore
1080
+ object_=_response.json(),
1081
+ ),
1082
+ ),
1083
+ )
1084
+ if _response.status_code == 404:
1085
+ raise NotFoundError(
1086
+ headers=dict(_response.headers),
1087
+ body=typing.cast(
1088
+ typing.Optional[typing.Any],
1089
+ parse_obj_as(
1090
+ type_=typing.Optional[typing.Any], # type: ignore
1091
+ object_=_response.json(),
1092
+ ),
1093
+ ),
1094
+ )
1095
+ if _response.status_code == 500:
1096
+ raise InternalServerError(
1097
+ headers=dict(_response.headers),
1098
+ body=typing.cast(
1099
+ typing.Optional[typing.Any],
1100
+ parse_obj_as(
1101
+ type_=typing.Optional[typing.Any], # type: ignore
1102
+ object_=_response.json(),
1103
+ ),
1104
+ ),
1105
+ )
1106
+ _response_json = _response.json()
1107
+ except JSONDecodeError:
1108
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1109
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1110
+
1111
+ async def add_auth_config(
1112
+ self,
1113
+ fhir_provider_id: str,
1114
+ *,
1115
+ auth_method: AuthMethod,
1116
+ client_secret: typing.Optional[str] = OMIT,
1117
+ service_account_key: typing.Optional[ServiceAccountKey] = OMIT,
1118
+ credential_expiry: typing.Optional[dt.datetime] = OMIT,
1119
+ scopes: typing.Optional[str] = OMIT,
1120
+ request_options: typing.Optional[RequestOptions] = None,
1121
+ ) -> AsyncHttpResponse[FhirProviderResponse]:
1122
+ """
1123
+ Adds a new authentication configuration to an existing FHIR provider. This enables key rotation and multiple auth configurations per provider.
1124
+
1125
+ Parameters
1126
+ ----------
1127
+ fhir_provider_id : str
1128
+ ID of the FHIR provider to add auth config to
1129
+
1130
+ auth_method : AuthMethod
1131
+
1132
+ client_secret : typing.Optional[str]
1133
+ OAuth client secret (required for client_secret and on_behalf_of auth methods)
1134
+
1135
+ service_account_key : typing.Optional[ServiceAccountKey]
1136
+
1137
+ credential_expiry : typing.Optional[dt.datetime]
1138
+ Expiry time for JWT credentials (only applicable for JWT auth method)
1139
+
1140
+ scopes : typing.Optional[str]
1141
+ OAuth scopes to request
1142
+
1143
+ request_options : typing.Optional[RequestOptions]
1144
+ Request-specific configuration.
1145
+
1146
+ Returns
1147
+ -------
1148
+ AsyncHttpResponse[FhirProviderResponse]
1149
+ Auth configuration added successfully
1150
+ """
1151
+ _response = await self._client_wrapper.httpx_client.request(
1152
+ f"fhir-provider/{jsonable_encoder(fhir_provider_id)}/add-auth-config",
1153
+ method="PATCH",
1154
+ json={
1155
+ "auth_method": auth_method,
1156
+ "client_secret": client_secret,
1157
+ "service_account_key": convert_and_respect_annotation_metadata(
1158
+ object_=service_account_key, annotation=ServiceAccountKey, direction="write"
1159
+ ),
1160
+ "credential_expiry": credential_expiry,
1161
+ "scopes": scopes,
1162
+ },
1163
+ headers={
1164
+ "content-type": "application/json",
1165
+ },
1166
+ request_options=request_options,
1167
+ omit=OMIT,
1168
+ )
1169
+ try:
1170
+ if 200 <= _response.status_code < 300:
1171
+ _data = typing.cast(
1172
+ FhirProviderResponse,
1173
+ parse_obj_as(
1174
+ type_=FhirProviderResponse, # type: ignore
1175
+ object_=_response.json(),
1176
+ ),
1177
+ )
1178
+ return AsyncHttpResponse(response=_response, data=_data)
1179
+ if _response.status_code == 400:
1180
+ raise BadRequestError(
1181
+ headers=dict(_response.headers),
1182
+ body=typing.cast(
1183
+ typing.Optional[typing.Any],
1184
+ parse_obj_as(
1185
+ type_=typing.Optional[typing.Any], # type: ignore
1186
+ object_=_response.json(),
1187
+ ),
1188
+ ),
1189
+ )
1190
+ if _response.status_code == 401:
1191
+ raise UnauthorizedError(
1192
+ headers=dict(_response.headers),
1193
+ body=typing.cast(
1194
+ typing.Optional[typing.Any],
1195
+ parse_obj_as(
1196
+ type_=typing.Optional[typing.Any], # type: ignore
1197
+ object_=_response.json(),
1198
+ ),
1199
+ ),
1200
+ )
1201
+ if _response.status_code == 403:
1202
+ raise ForbiddenError(
1203
+ headers=dict(_response.headers),
1204
+ body=typing.cast(
1205
+ typing.Optional[typing.Any],
1206
+ parse_obj_as(
1207
+ type_=typing.Optional[typing.Any], # type: ignore
1208
+ object_=_response.json(),
1209
+ ),
1210
+ ),
1211
+ )
1212
+ if _response.status_code == 404:
1213
+ raise NotFoundError(
1214
+ headers=dict(_response.headers),
1215
+ body=typing.cast(
1216
+ typing.Optional[typing.Any],
1217
+ parse_obj_as(
1218
+ type_=typing.Optional[typing.Any], # type: ignore
1219
+ object_=_response.json(),
1220
+ ),
1221
+ ),
1222
+ )
1223
+ if _response.status_code == 500:
1224
+ raise InternalServerError(
1225
+ headers=dict(_response.headers),
1226
+ body=typing.cast(
1227
+ typing.Optional[typing.Any],
1228
+ parse_obj_as(
1229
+ type_=typing.Optional[typing.Any], # type: ignore
1230
+ object_=_response.json(),
1231
+ ),
1232
+ ),
1233
+ )
1234
+ _response_json = _response.json()
1235
+ except JSONDecodeError:
1236
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1237
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1238
+
1239
+ async def set_active_auth_config(
1240
+ self, fhir_provider_id: str, *, auth_config_id: str, request_options: typing.Optional[RequestOptions] = None
1241
+ ) -> AsyncHttpResponse[FhirProviderSetActiveAuthConfigResponse]:
1242
+ """
1243
+ Sets which authentication configuration should be active for a FHIR provider. Only one auth config can be active at a time.
1244
+
1245
+ Parameters
1246
+ ----------
1247
+ fhir_provider_id : str
1248
+ ID of the FHIR provider
1249
+
1250
+ auth_config_id : str
1251
+ ID of the auth configuration to set as active
1252
+
1253
+ request_options : typing.Optional[RequestOptions]
1254
+ Request-specific configuration.
1255
+
1256
+ Returns
1257
+ -------
1258
+ AsyncHttpResponse[FhirProviderSetActiveAuthConfigResponse]
1259
+ Active auth configuration set successfully
1260
+ """
1261
+ _response = await self._client_wrapper.httpx_client.request(
1262
+ f"fhir-provider/{jsonable_encoder(fhir_provider_id)}/set-active-auth-config",
1263
+ method="PATCH",
1264
+ json={
1265
+ "auth_config_id": auth_config_id,
1266
+ },
1267
+ headers={
1268
+ "content-type": "application/json",
1269
+ },
1270
+ request_options=request_options,
1271
+ omit=OMIT,
1272
+ )
1273
+ try:
1274
+ if 200 <= _response.status_code < 300:
1275
+ _data = typing.cast(
1276
+ FhirProviderSetActiveAuthConfigResponse,
1277
+ parse_obj_as(
1278
+ type_=FhirProviderSetActiveAuthConfigResponse, # type: ignore
1279
+ object_=_response.json(),
1280
+ ),
1281
+ )
1282
+ return AsyncHttpResponse(response=_response, data=_data)
1283
+ if _response.status_code == 400:
1284
+ raise BadRequestError(
1285
+ headers=dict(_response.headers),
1286
+ body=typing.cast(
1287
+ typing.Optional[typing.Any],
1288
+ parse_obj_as(
1289
+ type_=typing.Optional[typing.Any], # type: ignore
1290
+ object_=_response.json(),
1291
+ ),
1292
+ ),
1293
+ )
1294
+ if _response.status_code == 401:
1295
+ raise UnauthorizedError(
1296
+ headers=dict(_response.headers),
1297
+ body=typing.cast(
1298
+ typing.Optional[typing.Any],
1299
+ parse_obj_as(
1300
+ type_=typing.Optional[typing.Any], # type: ignore
1301
+ object_=_response.json(),
1302
+ ),
1303
+ ),
1304
+ )
1305
+ if _response.status_code == 403:
1306
+ raise ForbiddenError(
1307
+ headers=dict(_response.headers),
1308
+ body=typing.cast(
1309
+ typing.Optional[typing.Any],
1310
+ parse_obj_as(
1311
+ type_=typing.Optional[typing.Any], # type: ignore
1312
+ object_=_response.json(),
1313
+ ),
1314
+ ),
1315
+ )
1316
+ if _response.status_code == 404:
1317
+ raise NotFoundError(
1318
+ headers=dict(_response.headers),
1319
+ body=typing.cast(
1320
+ typing.Optional[typing.Any],
1321
+ parse_obj_as(
1322
+ type_=typing.Optional[typing.Any], # type: ignore
1323
+ object_=_response.json(),
1324
+ ),
1325
+ ),
1326
+ )
1327
+ if _response.status_code == 500:
1328
+ raise InternalServerError(
1329
+ headers=dict(_response.headers),
1330
+ body=typing.cast(
1331
+ typing.Optional[typing.Any],
1332
+ parse_obj_as(
1333
+ type_=typing.Optional[typing.Any], # type: ignore
1334
+ object_=_response.json(),
1335
+ ),
1336
+ ),
1337
+ )
1338
+ _response_json = _response.json()
1339
+ except JSONDecodeError:
1340
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1341
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1342
+
1343
+ async def remove_auth_config(
1344
+ self, fhir_provider_id: str, *, auth_config_id: str, request_options: typing.Optional[RequestOptions] = None
1345
+ ) -> AsyncHttpResponse[FhirProviderRemoveAuthConfigResponse]:
1346
+ """
1347
+ Removes an authentication configuration from a FHIR provider. Cannot remove the currently active auth configuration.
1348
+
1349
+ Parameters
1350
+ ----------
1351
+ fhir_provider_id : str
1352
+ ID of the FHIR provider
1353
+
1354
+ auth_config_id : str
1355
+ ID of the auth configuration to remove
1356
+
1357
+ request_options : typing.Optional[RequestOptions]
1358
+ Request-specific configuration.
1359
+
1360
+ Returns
1361
+ -------
1362
+ AsyncHttpResponse[FhirProviderRemoveAuthConfigResponse]
1363
+ Auth configuration removed successfully
1364
+ """
1365
+ _response = await self._client_wrapper.httpx_client.request(
1366
+ f"fhir-provider/{jsonable_encoder(fhir_provider_id)}/remove-auth-config",
1367
+ method="PATCH",
1368
+ json={
1369
+ "auth_config_id": auth_config_id,
1370
+ },
1371
+ headers={
1372
+ "content-type": "application/json",
1373
+ },
1374
+ request_options=request_options,
1375
+ omit=OMIT,
1376
+ )
1377
+ try:
1378
+ if 200 <= _response.status_code < 300:
1379
+ _data = typing.cast(
1380
+ FhirProviderRemoveAuthConfigResponse,
1381
+ parse_obj_as(
1382
+ type_=FhirProviderRemoveAuthConfigResponse, # type: ignore
1383
+ object_=_response.json(),
1384
+ ),
1385
+ )
1386
+ return AsyncHttpResponse(response=_response, data=_data)
1387
+ if _response.status_code == 400:
1388
+ raise BadRequestError(
1389
+ headers=dict(_response.headers),
1390
+ body=typing.cast(
1391
+ typing.Optional[typing.Any],
1392
+ parse_obj_as(
1393
+ type_=typing.Optional[typing.Any], # type: ignore
1394
+ object_=_response.json(),
1395
+ ),
1396
+ ),
1397
+ )
1398
+ if _response.status_code == 401:
1399
+ raise UnauthorizedError(
1400
+ headers=dict(_response.headers),
1401
+ body=typing.cast(
1402
+ typing.Optional[typing.Any],
1403
+ parse_obj_as(
1404
+ type_=typing.Optional[typing.Any], # type: ignore
1405
+ object_=_response.json(),
1406
+ ),
1407
+ ),
1408
+ )
1409
+ if _response.status_code == 403:
1410
+ raise ForbiddenError(
1411
+ headers=dict(_response.headers),
1412
+ body=typing.cast(
1413
+ typing.Optional[typing.Any],
1414
+ parse_obj_as(
1415
+ type_=typing.Optional[typing.Any], # type: ignore
1416
+ object_=_response.json(),
1417
+ ),
1418
+ ),
1419
+ )
1420
+ if _response.status_code == 404:
1421
+ raise NotFoundError(
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 == 500:
1432
+ raise InternalServerError(
1433
+ headers=dict(_response.headers),
1434
+ body=typing.cast(
1435
+ typing.Optional[typing.Any],
1436
+ parse_obj_as(
1437
+ type_=typing.Optional[typing.Any], # type: ignore
1438
+ object_=_response.json(),
1439
+ ),
1440
+ ),
1441
+ )
1442
+ _response_json = _response.json()
1443
+ except JSONDecodeError:
1444
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1445
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)