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