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,129 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ...core.request_options import RequestOptions
7
+ from .raw_client import AsyncRawAuthClient, RawAuthClient
8
+ from .types.auth_generate_token_response import AuthGenerateTokenResponse
9
+
10
+ # this is used as the default value for optional parameters
11
+ OMIT = typing.cast(typing.Any, ...)
12
+
13
+
14
+ class AuthClient:
15
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
16
+ self._raw_client = RawAuthClient(client_wrapper=client_wrapper)
17
+
18
+ @property
19
+ def with_raw_response(self) -> RawAuthClient:
20
+ """
21
+ Retrieves a raw implementation of this client that returns raw responses.
22
+
23
+ Returns
24
+ -------
25
+ RawAuthClient
26
+ """
27
+ return self._raw_client
28
+
29
+ def generate_token(
30
+ self, *, username: str, password: str, request_options: typing.Optional[RequestOptions] = None
31
+ ) -> AuthGenerateTokenResponse:
32
+ """
33
+ Obtain an access token using client credentials
34
+
35
+ Parameters
36
+ ----------
37
+ username : str
38
+ The user's username or email
39
+
40
+ password : str
41
+ The user's password
42
+
43
+ request_options : typing.Optional[RequestOptions]
44
+ Request-specific configuration.
45
+
46
+ Returns
47
+ -------
48
+ AuthGenerateTokenResponse
49
+ Successfully generated token
50
+
51
+ Examples
52
+ --------
53
+ from phenoml import phenoml
54
+
55
+ client = phenoml(
56
+ token="YOUR_TOKEN",
57
+ )
58
+ client.authtoken.auth.generate_token(
59
+ username="username",
60
+ password="password",
61
+ )
62
+ """
63
+ _response = self._raw_client.generate_token(
64
+ username=username, password=password, request_options=request_options
65
+ )
66
+ return _response.data
67
+
68
+
69
+ class AsyncAuthClient:
70
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
71
+ self._raw_client = AsyncRawAuthClient(client_wrapper=client_wrapper)
72
+
73
+ @property
74
+ def with_raw_response(self) -> AsyncRawAuthClient:
75
+ """
76
+ Retrieves a raw implementation of this client that returns raw responses.
77
+
78
+ Returns
79
+ -------
80
+ AsyncRawAuthClient
81
+ """
82
+ return self._raw_client
83
+
84
+ async def generate_token(
85
+ self, *, username: str, password: str, request_options: typing.Optional[RequestOptions] = None
86
+ ) -> AuthGenerateTokenResponse:
87
+ """
88
+ Obtain an access token using client credentials
89
+
90
+ Parameters
91
+ ----------
92
+ username : str
93
+ The user's username or email
94
+
95
+ password : str
96
+ The user's password
97
+
98
+ request_options : typing.Optional[RequestOptions]
99
+ Request-specific configuration.
100
+
101
+ Returns
102
+ -------
103
+ AuthGenerateTokenResponse
104
+ Successfully generated token
105
+
106
+ Examples
107
+ --------
108
+ import asyncio
109
+
110
+ from phenoml import Asyncphenoml
111
+
112
+ client = Asyncphenoml(
113
+ token="YOUR_TOKEN",
114
+ )
115
+
116
+
117
+ async def main() -> None:
118
+ await client.authtoken.auth.generate_token(
119
+ username="username",
120
+ password="password",
121
+ )
122
+
123
+
124
+ asyncio.run(main())
125
+ """
126
+ _response = await self._raw_client.generate_token(
127
+ username=username, password=password, request_options=request_options
128
+ )
129
+ return _response.data
@@ -0,0 +1,173 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import base64
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.pydantic_utilities import parse_obj_as
11
+ from ...core.request_options import RequestOptions
12
+ from ..errors.bad_request_error import BadRequestError
13
+ from ..errors.unauthorized_error import UnauthorizedError
14
+ from .types.auth_generate_token_response import AuthGenerateTokenResponse
15
+
16
+ # this is used as the default value for optional parameters
17
+ OMIT = typing.cast(typing.Any, ...)
18
+
19
+
20
+ class RawAuthClient:
21
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
22
+ self._client_wrapper = client_wrapper
23
+
24
+ def generate_token(
25
+ self, *, username: str, password: str, request_options: typing.Optional[RequestOptions] = None
26
+ ) -> HttpResponse[AuthGenerateTokenResponse]:
27
+ """
28
+ Obtain an access token using client credentials
29
+
30
+ Parameters
31
+ ----------
32
+ username : str
33
+ The user's username or email
34
+
35
+ password : str
36
+ The user's password
37
+
38
+ request_options : typing.Optional[RequestOptions]
39
+ Request-specific configuration.
40
+
41
+ Returns
42
+ -------
43
+ HttpResponse[AuthGenerateTokenResponse]
44
+ Successfully generated token
45
+ """
46
+ # Create basic auth header
47
+ credentials = f"{username}:{password}"
48
+ encoded_credentials = base64.b64encode(credentials.encode()).decode()
49
+
50
+ _response = self._client_wrapper.httpx_client.request(
51
+ "auth/token",
52
+ method="POST",
53
+ headers={
54
+ "Authorization": f"Basic {encoded_credentials}",
55
+ "content-type": "application/json",
56
+ },
57
+ request_options=request_options,
58
+ omit=OMIT,
59
+ )
60
+ try:
61
+ if 200 <= _response.status_code < 300:
62
+ _data = typing.cast(
63
+ AuthGenerateTokenResponse,
64
+ parse_obj_as(
65
+ type_=AuthGenerateTokenResponse, # type: ignore
66
+ object_=_response.json(),
67
+ ),
68
+ )
69
+ return HttpResponse(response=_response, data=_data)
70
+ if _response.status_code == 400:
71
+ raise BadRequestError(
72
+ headers=dict(_response.headers),
73
+ body=typing.cast(
74
+ typing.Optional[typing.Any],
75
+ parse_obj_as(
76
+ type_=typing.Optional[typing.Any], # type: ignore
77
+ object_=_response.json(),
78
+ ),
79
+ ),
80
+ )
81
+ if _response.status_code == 401:
82
+ raise UnauthorizedError(
83
+ headers=dict(_response.headers),
84
+ body=typing.cast(
85
+ typing.Optional[typing.Any],
86
+ parse_obj_as(
87
+ type_=typing.Optional[typing.Any], # type: ignore
88
+ object_=_response.json(),
89
+ ),
90
+ ),
91
+ )
92
+ _response_json = _response.json()
93
+ except JSONDecodeError:
94
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
95
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
96
+
97
+
98
+ class AsyncRawAuthClient:
99
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
100
+ self._client_wrapper = client_wrapper
101
+
102
+ async def generate_token(
103
+ self, *, username: str, password: str, request_options: typing.Optional[RequestOptions] = None
104
+ ) -> AsyncHttpResponse[AuthGenerateTokenResponse]:
105
+ """
106
+ Obtain an access token using client credentials
107
+
108
+ Parameters
109
+ ----------
110
+ username : str
111
+ The user's username or email
112
+
113
+ password : str
114
+ The user's password
115
+
116
+ request_options : typing.Optional[RequestOptions]
117
+ Request-specific configuration.
118
+
119
+ Returns
120
+ -------
121
+ AsyncHttpResponse[AuthGenerateTokenResponse]
122
+ Successfully generated token
123
+ """
124
+ # Create basic auth header
125
+ credentials = f"{username}:{password}"
126
+ encoded_credentials = base64.b64encode(credentials.encode()).decode()
127
+
128
+ _response = await self._client_wrapper.httpx_client.request(
129
+ "auth/token",
130
+ method="POST",
131
+ headers={
132
+ "Authorization": f"Basic {encoded_credentials}",
133
+ "content-type": "application/json",
134
+ },
135
+ request_options=request_options,
136
+ omit=OMIT,
137
+ )
138
+ try:
139
+ if 200 <= _response.status_code < 300:
140
+ _data = typing.cast(
141
+ AuthGenerateTokenResponse,
142
+ parse_obj_as(
143
+ type_=AuthGenerateTokenResponse, # type: ignore
144
+ object_=_response.json(),
145
+ ),
146
+ )
147
+ return AsyncHttpResponse(response=_response, data=_data)
148
+ if _response.status_code == 400:
149
+ raise BadRequestError(
150
+ headers=dict(_response.headers),
151
+ body=typing.cast(
152
+ typing.Optional[typing.Any],
153
+ parse_obj_as(
154
+ type_=typing.Optional[typing.Any], # type: ignore
155
+ object_=_response.json(),
156
+ ),
157
+ ),
158
+ )
159
+ if _response.status_code == 401:
160
+ raise UnauthorizedError(
161
+ headers=dict(_response.headers),
162
+ body=typing.cast(
163
+ typing.Optional[typing.Any],
164
+ parse_obj_as(
165
+ type_=typing.Optional[typing.Any], # type: ignore
166
+ object_=_response.json(),
167
+ ),
168
+ ),
169
+ )
170
+ _response_json = _response.json()
171
+ except JSONDecodeError:
172
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
173
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -0,0 +1,7 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .auth_generate_token_response import AuthGenerateTokenResponse
6
+
7
+ __all__ = ["AuthGenerateTokenResponse"]
@@ -0,0 +1,22 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ....core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class AuthGenerateTokenResponse(UniversalBaseModel):
10
+ token: str = pydantic.Field()
11
+ """
12
+ JWT token to be used for subsequent authenticated requests
13
+ """
14
+
15
+ if IS_PYDANTIC_V2:
16
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
17
+ else:
18
+
19
+ class Config:
20
+ frozen = True
21
+ smart_union = True
22
+ extra = pydantic.Extra.allow
@@ -0,0 +1,39 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
4
+ from .auth.client import AsyncAuthClient, AuthClient
5
+ from .raw_client import AsyncRawAuthtokenClient, RawAuthtokenClient
6
+
7
+
8
+ class AuthtokenClient:
9
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
10
+ self._raw_client = RawAuthtokenClient(client_wrapper=client_wrapper)
11
+ self.auth = AuthClient(client_wrapper=client_wrapper)
12
+
13
+ @property
14
+ def with_raw_response(self) -> RawAuthtokenClient:
15
+ """
16
+ Retrieves a raw implementation of this client that returns raw responses.
17
+
18
+ Returns
19
+ -------
20
+ RawAuthtokenClient
21
+ """
22
+ return self._raw_client
23
+
24
+
25
+ class AsyncAuthtokenClient:
26
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
27
+ self._raw_client = AsyncRawAuthtokenClient(client_wrapper=client_wrapper)
28
+ self.auth = AsyncAuthClient(client_wrapper=client_wrapper)
29
+
30
+ @property
31
+ def with_raw_response(self) -> AsyncRawAuthtokenClient:
32
+ """
33
+ Retrieves a raw implementation of this client that returns raw responses.
34
+
35
+ Returns
36
+ -------
37
+ AsyncRawAuthtokenClient
38
+ """
39
+ return self._raw_client
@@ -0,0 +1,8 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .bad_request_error import BadRequestError
6
+ from .unauthorized_error import UnauthorizedError
7
+
8
+ __all__ = ["BadRequestError", "UnauthorizedError"]
@@ -0,0 +1,10 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ...core.api_error import ApiError
6
+
7
+
8
+ class BadRequestError(ApiError):
9
+ def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
10
+ super().__init__(status_code=400, headers=headers, body=body)
@@ -0,0 +1,10 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ...core.api_error import ApiError
6
+
7
+
8
+ class UnauthorizedError(ApiError):
9
+ def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
10
+ super().__init__(status_code=401, headers=headers, body=body)
@@ -0,0 +1,13 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
4
+
5
+
6
+ class RawAuthtokenClient:
7
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
8
+ self._client_wrapper = client_wrapper
9
+
10
+
11
+ class AsyncRawAuthtokenClient:
12
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
13
+ self._client_wrapper = client_wrapper
@@ -0,0 +1,8 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .bad_request_error_body import BadRequestErrorBody
6
+ from .unauthorized_error_body import UnauthorizedErrorBody
7
+
8
+ __all__ = ["BadRequestErrorBody", "UnauthorizedErrorBody"]
@@ -0,0 +1,21 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class BadRequestErrorBody(UniversalBaseModel):
10
+ code: typing.Optional[int] = None
11
+ message: typing.Optional[str] = None
12
+ data: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
13
+
14
+ if IS_PYDANTIC_V2:
15
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
16
+ else:
17
+
18
+ class Config:
19
+ frozen = True
20
+ smart_union = True
21
+ extra = pydantic.Extra.allow
@@ -0,0 +1,21 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class UnauthorizedErrorBody(UniversalBaseModel):
10
+ code: typing.Optional[int] = None
11
+ message: typing.Optional[str] = None
12
+ data: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
13
+
14
+ if IS_PYDANTIC_V2:
15
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
16
+ else:
17
+
18
+ class Config:
19
+ frozen = True
20
+ smart_union = True
21
+ extra = pydantic.Extra.allow
phenoml/client.py ADDED
@@ -0,0 +1,177 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+ from .agent.client import AgentClient, AsyncAgentClient
7
+ from .authtoken.client import AsyncAuthtokenClient, AuthtokenClient
8
+ from .cohort.client import AsyncCohortClient, CohortClient
9
+ from .construe.client import AsyncConstrueClient, ConstrueClient
10
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
11
+ from .environment import phenomlEnvironment
12
+ from .fhir.client import AsyncFhirClient, FhirClient
13
+ from .fhir_provider.client import AsyncFhirProviderClient, FhirProviderClient
14
+ from .lang2fhir.client import AsyncLang2FhirClient, Lang2FhirClient
15
+ from .tools.client import AsyncToolsClient, ToolsClient
16
+ from .workflows.client import AsyncWorkflowsClient, WorkflowsClient
17
+
18
+
19
+ class phenoml:
20
+ """
21
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
22
+
23
+ Parameters
24
+ ----------
25
+ base_url : typing.Optional[str]
26
+ The base url to use for requests from the client.
27
+
28
+ environment : phenomlEnvironment
29
+ The environment to use for requests from the client. from .environment import phenomlEnvironment
30
+
31
+
32
+
33
+ Defaults to phenomlEnvironment.DEFAULT
34
+
35
+
36
+
37
+ token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
38
+ headers : typing.Optional[typing.Dict[str, str]]
39
+ Additional headers to send with every request.
40
+
41
+ timeout : typing.Optional[float]
42
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
43
+
44
+ follow_redirects : typing.Optional[bool]
45
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
46
+
47
+ httpx_client : typing.Optional[httpx.Client]
48
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
49
+
50
+ Examples
51
+ --------
52
+ from phenoml import phenoml
53
+
54
+ client = phenoml(
55
+ token="YOUR_TOKEN",
56
+ )
57
+ """
58
+
59
+ def __init__(
60
+ self,
61
+ *,
62
+ base_url: typing.Optional[str] = None,
63
+ environment: phenomlEnvironment = phenomlEnvironment.DEFAULT,
64
+ token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
65
+ headers: typing.Optional[typing.Dict[str, str]] = None,
66
+ timeout: typing.Optional[float] = None,
67
+ follow_redirects: typing.Optional[bool] = True,
68
+ httpx_client: typing.Optional[httpx.Client] = None,
69
+ ):
70
+ _defaulted_timeout = (
71
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
72
+ )
73
+ self._client_wrapper = SyncClientWrapper(
74
+ base_url=_get_base_url(base_url=base_url, environment=environment),
75
+ token=token,
76
+ headers=headers,
77
+ httpx_client=httpx_client
78
+ if httpx_client is not None
79
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
80
+ if follow_redirects is not None
81
+ else httpx.Client(timeout=_defaulted_timeout),
82
+ timeout=_defaulted_timeout,
83
+ )
84
+ self.agent = AgentClient(client_wrapper=self._client_wrapper)
85
+ self.authtoken = AuthtokenClient(client_wrapper=self._client_wrapper)
86
+ self.cohort = CohortClient(client_wrapper=self._client_wrapper)
87
+ self.construe = ConstrueClient(client_wrapper=self._client_wrapper)
88
+ self.fhir = FhirClient(client_wrapper=self._client_wrapper)
89
+ self.fhir_provider = FhirProviderClient(client_wrapper=self._client_wrapper)
90
+ self.lang2fhir = Lang2FhirClient(client_wrapper=self._client_wrapper)
91
+ self.tools = ToolsClient(client_wrapper=self._client_wrapper)
92
+ self.workflows = WorkflowsClient(client_wrapper=self._client_wrapper)
93
+
94
+
95
+ class Asyncphenoml:
96
+ """
97
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
98
+
99
+ Parameters
100
+ ----------
101
+ base_url : typing.Optional[str]
102
+ The base url to use for requests from the client.
103
+
104
+ environment : phenomlEnvironment
105
+ The environment to use for requests from the client. from .environment import phenomlEnvironment
106
+
107
+
108
+
109
+ Defaults to phenomlEnvironment.DEFAULT
110
+
111
+
112
+
113
+ token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
114
+ headers : typing.Optional[typing.Dict[str, str]]
115
+ Additional headers to send with every request.
116
+
117
+ timeout : typing.Optional[float]
118
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
119
+
120
+ follow_redirects : typing.Optional[bool]
121
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
122
+
123
+ httpx_client : typing.Optional[httpx.AsyncClient]
124
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
125
+
126
+ Examples
127
+ --------
128
+ from phenoml import Asyncphenoml
129
+
130
+ client = Asyncphenoml(
131
+ token="YOUR_TOKEN",
132
+ )
133
+ """
134
+
135
+ def __init__(
136
+ self,
137
+ *,
138
+ base_url: typing.Optional[str] = None,
139
+ environment: phenomlEnvironment = phenomlEnvironment.DEFAULT,
140
+ token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
141
+ headers: typing.Optional[typing.Dict[str, str]] = None,
142
+ timeout: typing.Optional[float] = None,
143
+ follow_redirects: typing.Optional[bool] = True,
144
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
145
+ ):
146
+ _defaulted_timeout = (
147
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
148
+ )
149
+ self._client_wrapper = AsyncClientWrapper(
150
+ base_url=_get_base_url(base_url=base_url, environment=environment),
151
+ token=token,
152
+ headers=headers,
153
+ httpx_client=httpx_client
154
+ if httpx_client is not None
155
+ else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
156
+ if follow_redirects is not None
157
+ else httpx.AsyncClient(timeout=_defaulted_timeout),
158
+ timeout=_defaulted_timeout,
159
+ )
160
+ self.agent = AsyncAgentClient(client_wrapper=self._client_wrapper)
161
+ self.authtoken = AsyncAuthtokenClient(client_wrapper=self._client_wrapper)
162
+ self.cohort = AsyncCohortClient(client_wrapper=self._client_wrapper)
163
+ self.construe = AsyncConstrueClient(client_wrapper=self._client_wrapper)
164
+ self.fhir = AsyncFhirClient(client_wrapper=self._client_wrapper)
165
+ self.fhir_provider = AsyncFhirProviderClient(client_wrapper=self._client_wrapper)
166
+ self.lang2fhir = AsyncLang2FhirClient(client_wrapper=self._client_wrapper)
167
+ self.tools = AsyncToolsClient(client_wrapper=self._client_wrapper)
168
+ self.workflows = AsyncWorkflowsClient(client_wrapper=self._client_wrapper)
169
+
170
+
171
+ def _get_base_url(*, base_url: typing.Optional[str] = None, environment: phenomlEnvironment) -> str:
172
+ if base_url is not None:
173
+ return base_url
174
+ elif environment is not None:
175
+ return environment.value
176
+ else:
177
+ raise Exception("Please pass in either base_url or environment to construct the client")
@@ -0,0 +1,8 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .types import CohortResponse, SearchConcept
6
+ from .errors import BadRequestError, InternalServerError, UnauthorizedError
7
+
8
+ __all__ = ["BadRequestError", "CohortResponse", "InternalServerError", "SearchConcept", "UnauthorizedError"]