phenostore-sdk-python 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. phenostore/__init__.py +26 -0
  2. phenostore/_auth.py +94 -0
  3. phenostore/client.py +276 -0
  4. phenostore/errors.py +93 -0
  5. phenostore/gen/__init__.py +8 -0
  6. phenostore/gen/api/__init__.py +1 -0
  7. phenostore/gen/api/bulk/__init__.py +1 -0
  8. phenostore/gen/api/bulk/get_bulk_status.py +194 -0
  9. phenostore/gen/api/bulk/submit_bulk.py +223 -0
  10. phenostore/gen/api/fhir/__init__.py +1 -0
  11. phenostore/gen/api/fhir/conditional_delete_resource.py +277 -0
  12. phenostore/gen/api/fhir/create_resource.py +257 -0
  13. phenostore/gen/api/fhir/delete_resource.py +212 -0
  14. phenostore/gen/api/fhir/get_docref.py +281 -0
  15. phenostore/gen/api/fhir/get_metadata.py +185 -0
  16. phenostore/gen/api/fhir/get_resource_history.py +240 -0
  17. phenostore/gen/api/fhir/get_smart_configuration.py +169 -0
  18. phenostore/gen/api/fhir/patch_resource.py +282 -0
  19. phenostore/gen/api/fhir/post_docref.py +200 -0
  20. phenostore/gen/api/fhir/process_bundle.py +201 -0
  21. phenostore/gen/api/fhir/read_resource.py +214 -0
  22. phenostore/gen/api/fhir/read_resource_version.py +228 -0
  23. phenostore/gen/api/fhir/search_resources.py +390 -0
  24. phenostore/gen/api/fhir/search_resources_post.py +228 -0
  25. phenostore/gen/api/fhir/update_resource.py +281 -0
  26. phenostore/gen/api/fhir/validate_resource.py +217 -0
  27. phenostore/gen/api/o_auth/__init__.py +1 -0
  28. phenostore/gen/api/o_auth/issue_token.py +186 -0
  29. phenostore/gen/api/system/__init__.py +1 -0
  30. phenostore/gen/api/system/get_health.py +128 -0
  31. phenostore/gen/client.py +280 -0
  32. phenostore/gen/errors.py +16 -0
  33. phenostore/gen/models/__init__.py +71 -0
  34. phenostore/gen/models/bulk_operation_accepted.py +79 -0
  35. phenostore/gen/models/bulk_operation_accepted_status.py +8 -0
  36. phenostore/gen/models/bulk_operation_status.py +122 -0
  37. phenostore/gen/models/bulk_operation_status_code.py +11 -0
  38. phenostore/gen/models/bundle.py +132 -0
  39. phenostore/gen/models/bundle_entry.py +128 -0
  40. phenostore/gen/models/bundle_entry_request.py +70 -0
  41. phenostore/gen/models/bundle_entry_response.py +97 -0
  42. phenostore/gen/models/bundle_entry_search.py +69 -0
  43. phenostore/gen/models/bundle_entry_search_mode.py +9 -0
  44. phenostore/gen/models/bundle_link.py +69 -0
  45. phenostore/gen/models/bundle_resource_type.py +8 -0
  46. phenostore/gen/models/bundle_type.py +11 -0
  47. phenostore/gen/models/fhir_resource.py +47 -0
  48. phenostore/gen/models/health_response.py +63 -0
  49. phenostore/gen/models/health_response_status.py +8 -0
  50. phenostore/gen/models/issue_severity.py +11 -0
  51. phenostore/gen/models/issue_token_body.py +91 -0
  52. phenostore/gen/models/issue_token_body_grant_type.py +8 -0
  53. phenostore/gen/models/json_patch_item.py +90 -0
  54. phenostore/gen/models/json_patch_op.py +13 -0
  55. phenostore/gen/models/o_auth_error.py +69 -0
  56. phenostore/gen/models/operation_outcome.py +85 -0
  57. phenostore/gen/models/operation_outcome_issue.py +92 -0
  58. phenostore/gen/models/operation_outcome_resource_type.py +8 -0
  59. phenostore/gen/models/post_docref_body.py +124 -0
  60. phenostore/gen/models/resource_type.py +47 -0
  61. phenostore/gen/models/search_resources_post_body.py +155 -0
  62. phenostore/gen/models/search_summary_mode.py +12 -0
  63. phenostore/gen/models/search_total_mode.py +10 -0
  64. phenostore/gen/models/smart_configuration.py +111 -0
  65. phenostore/gen/models/token_response.py +87 -0
  66. phenostore/gen/models/token_response_token_type.py +8 -0
  67. phenostore/gen/types.py +54 -0
  68. phenostore/py.typed +0 -0
  69. phenostore_sdk_python-0.1.1.dist-info/METADATA +196 -0
  70. phenostore_sdk_python-0.1.1.dist-info/RECORD +72 -0
  71. phenostore_sdk_python-0.1.1.dist-info/WHEEL +4 -0
  72. phenostore_sdk_python-0.1.1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,257 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.fhir_resource import FhirResource
10
+ from ...models.operation_outcome import OperationOutcome
11
+ from ...models.resource_type import ResourceType
12
+ from ...types import UNSET, Response, Unset
13
+
14
+
15
+ def _get_kwargs(
16
+ tenant_id: str,
17
+ store_id: str,
18
+ resource_type: ResourceType,
19
+ *,
20
+ body: FhirResource,
21
+ if_none_exist: str | Unset = UNSET,
22
+ ) -> dict[str, Any]:
23
+ headers: dict[str, Any] = {}
24
+ if not isinstance(if_none_exist, Unset):
25
+ headers["If-None-Exist"] = if_none_exist
26
+
27
+ _kwargs: dict[str, Any] = {
28
+ "method": "post",
29
+ "url": "/v1/tenants/{tenant_id}/stores/{store_id}/{resource_type}".format(
30
+ tenant_id=quote(str(tenant_id), safe=""),
31
+ store_id=quote(str(store_id), safe=""),
32
+ resource_type=quote(str(resource_type), safe=""),
33
+ ),
34
+ }
35
+
36
+ _kwargs["json"] = body.to_dict()
37
+
38
+ headers["Content-Type"] = "application/fhir+json"
39
+
40
+ _kwargs["headers"] = headers
41
+ return _kwargs
42
+
43
+
44
+ def _parse_response(
45
+ *, client: AuthenticatedClient | Client, response: httpx.Response
46
+ ) -> FhirResource | OperationOutcome | None:
47
+ if response.status_code == 200:
48
+ response_200 = FhirResource.from_dict(response.json())
49
+
50
+ return response_200
51
+
52
+ if response.status_code == 201:
53
+ response_201 = FhirResource.from_dict(response.json())
54
+
55
+ return response_201
56
+
57
+ if response.status_code == 400:
58
+ response_400 = OperationOutcome.from_dict(response.json())
59
+
60
+ return response_400
61
+
62
+ if response.status_code == 403:
63
+ response_403 = OperationOutcome.from_dict(response.json())
64
+
65
+ return response_403
66
+
67
+ if response.status_code == 412:
68
+ response_412 = OperationOutcome.from_dict(response.json())
69
+
70
+ return response_412
71
+
72
+ if response.status_code == 422:
73
+ response_422 = OperationOutcome.from_dict(response.json())
74
+
75
+ return response_422
76
+
77
+ if client.raise_on_unexpected_status:
78
+ raise errors.UnexpectedStatus(response.status_code, response.content)
79
+ else:
80
+ return None
81
+
82
+
83
+ def _build_response(
84
+ *, client: AuthenticatedClient | Client, response: httpx.Response
85
+ ) -> Response[FhirResource | OperationOutcome]:
86
+ return Response(
87
+ status_code=HTTPStatus(response.status_code),
88
+ content=response.content,
89
+ headers=response.headers,
90
+ parsed=_parse_response(client=client, response=response),
91
+ )
92
+
93
+
94
+ def sync_detailed(
95
+ tenant_id: str,
96
+ store_id: str,
97
+ resource_type: ResourceType,
98
+ *,
99
+ client: AuthenticatedClient | Client,
100
+ body: FhirResource,
101
+ if_none_exist: str | Unset = UNSET,
102
+ ) -> Response[FhirResource | OperationOutcome]:
103
+ """Create a FHIR resource
104
+
105
+ Creates a new resource with a server-assigned ID. Supports conditional
106
+ create via the If-None-Exist header.
107
+
108
+ Args:
109
+ tenant_id (str):
110
+ store_id (str):
111
+ resource_type (ResourceType): FHIR resource type
112
+ if_none_exist (str | Unset):
113
+ body (FhirResource): An arbitrary FHIR resource stored as raw JSON.
114
+
115
+ Raises:
116
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
117
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
118
+
119
+ Returns:
120
+ Response[FhirResource | OperationOutcome]
121
+ """
122
+
123
+ kwargs = _get_kwargs(
124
+ tenant_id=tenant_id,
125
+ store_id=store_id,
126
+ resource_type=resource_type,
127
+ body=body,
128
+ if_none_exist=if_none_exist,
129
+ )
130
+
131
+ response = client.get_httpx_client().request(
132
+ **kwargs,
133
+ )
134
+
135
+ return _build_response(client=client, response=response)
136
+
137
+
138
+ def sync(
139
+ tenant_id: str,
140
+ store_id: str,
141
+ resource_type: ResourceType,
142
+ *,
143
+ client: AuthenticatedClient | Client,
144
+ body: FhirResource,
145
+ if_none_exist: str | Unset = UNSET,
146
+ ) -> FhirResource | OperationOutcome | None:
147
+ """Create a FHIR resource
148
+
149
+ Creates a new resource with a server-assigned ID. Supports conditional
150
+ create via the If-None-Exist header.
151
+
152
+ Args:
153
+ tenant_id (str):
154
+ store_id (str):
155
+ resource_type (ResourceType): FHIR resource type
156
+ if_none_exist (str | Unset):
157
+ body (FhirResource): An arbitrary FHIR resource stored as raw JSON.
158
+
159
+ Raises:
160
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
161
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
162
+
163
+ Returns:
164
+ FhirResource | OperationOutcome
165
+ """
166
+
167
+ return sync_detailed(
168
+ tenant_id=tenant_id,
169
+ store_id=store_id,
170
+ resource_type=resource_type,
171
+ client=client,
172
+ body=body,
173
+ if_none_exist=if_none_exist,
174
+ ).parsed
175
+
176
+
177
+ async def asyncio_detailed(
178
+ tenant_id: str,
179
+ store_id: str,
180
+ resource_type: ResourceType,
181
+ *,
182
+ client: AuthenticatedClient | Client,
183
+ body: FhirResource,
184
+ if_none_exist: str | Unset = UNSET,
185
+ ) -> Response[FhirResource | OperationOutcome]:
186
+ """Create a FHIR resource
187
+
188
+ Creates a new resource with a server-assigned ID. Supports conditional
189
+ create via the If-None-Exist header.
190
+
191
+ Args:
192
+ tenant_id (str):
193
+ store_id (str):
194
+ resource_type (ResourceType): FHIR resource type
195
+ if_none_exist (str | Unset):
196
+ body (FhirResource): An arbitrary FHIR resource stored as raw JSON.
197
+
198
+ Raises:
199
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
200
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
201
+
202
+ Returns:
203
+ Response[FhirResource | OperationOutcome]
204
+ """
205
+
206
+ kwargs = _get_kwargs(
207
+ tenant_id=tenant_id,
208
+ store_id=store_id,
209
+ resource_type=resource_type,
210
+ body=body,
211
+ if_none_exist=if_none_exist,
212
+ )
213
+
214
+ response = await client.get_async_httpx_client().request(**kwargs)
215
+
216
+ return _build_response(client=client, response=response)
217
+
218
+
219
+ async def asyncio(
220
+ tenant_id: str,
221
+ store_id: str,
222
+ resource_type: ResourceType,
223
+ *,
224
+ client: AuthenticatedClient | Client,
225
+ body: FhirResource,
226
+ if_none_exist: str | Unset = UNSET,
227
+ ) -> FhirResource | OperationOutcome | None:
228
+ """Create a FHIR resource
229
+
230
+ Creates a new resource with a server-assigned ID. Supports conditional
231
+ create via the If-None-Exist header.
232
+
233
+ Args:
234
+ tenant_id (str):
235
+ store_id (str):
236
+ resource_type (ResourceType): FHIR resource type
237
+ if_none_exist (str | Unset):
238
+ body (FhirResource): An arbitrary FHIR resource stored as raw JSON.
239
+
240
+ Raises:
241
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
242
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
243
+
244
+ Returns:
245
+ FhirResource | OperationOutcome
246
+ """
247
+
248
+ return (
249
+ await asyncio_detailed(
250
+ tenant_id=tenant_id,
251
+ store_id=store_id,
252
+ resource_type=resource_type,
253
+ client=client,
254
+ body=body,
255
+ if_none_exist=if_none_exist,
256
+ )
257
+ ).parsed
@@ -0,0 +1,212 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, cast
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.operation_outcome import OperationOutcome
10
+ from ...models.resource_type import ResourceType
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ tenant_id: str,
16
+ store_id: str,
17
+ resource_type: ResourceType,
18
+ id: str,
19
+ ) -> dict[str, Any]:
20
+
21
+ _kwargs: dict[str, Any] = {
22
+ "method": "delete",
23
+ "url": "/v1/tenants/{tenant_id}/stores/{store_id}/{resource_type}/{id}".format(
24
+ tenant_id=quote(str(tenant_id), safe=""),
25
+ store_id=quote(str(store_id), safe=""),
26
+ resource_type=quote(str(resource_type), safe=""),
27
+ id=quote(str(id), safe=""),
28
+ ),
29
+ }
30
+
31
+ return _kwargs
32
+
33
+
34
+ def _parse_response(
35
+ *, client: AuthenticatedClient | Client, response: httpx.Response
36
+ ) -> Any | OperationOutcome | None:
37
+ if response.status_code == 204:
38
+ response_204 = cast(Any, None)
39
+ return response_204
40
+
41
+ if response.status_code == 403:
42
+ response_403 = OperationOutcome.from_dict(response.json())
43
+
44
+ return response_403
45
+
46
+ if response.status_code == 404:
47
+ response_404 = OperationOutcome.from_dict(response.json())
48
+
49
+ return response_404
50
+
51
+ if response.status_code == 410:
52
+ response_410 = OperationOutcome.from_dict(response.json())
53
+
54
+ return response_410
55
+
56
+ if client.raise_on_unexpected_status:
57
+ raise errors.UnexpectedStatus(response.status_code, response.content)
58
+ else:
59
+ return None
60
+
61
+
62
+ def _build_response(
63
+ *, client: AuthenticatedClient | Client, response: httpx.Response
64
+ ) -> Response[Any | OperationOutcome]:
65
+ return Response(
66
+ status_code=HTTPStatus(response.status_code),
67
+ content=response.content,
68
+ headers=response.headers,
69
+ parsed=_parse_response(client=client, response=response),
70
+ )
71
+
72
+
73
+ def sync_detailed(
74
+ tenant_id: str,
75
+ store_id: str,
76
+ resource_type: ResourceType,
77
+ id: str,
78
+ *,
79
+ client: AuthenticatedClient | Client,
80
+ ) -> Response[Any | OperationOutcome]:
81
+ """Delete a FHIR resource
82
+
83
+ Args:
84
+ tenant_id (str):
85
+ store_id (str):
86
+ resource_type (ResourceType): FHIR resource type
87
+ id (str):
88
+
89
+ Raises:
90
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
91
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
92
+
93
+ Returns:
94
+ Response[Any | OperationOutcome]
95
+ """
96
+
97
+ kwargs = _get_kwargs(
98
+ tenant_id=tenant_id,
99
+ store_id=store_id,
100
+ resource_type=resource_type,
101
+ id=id,
102
+ )
103
+
104
+ response = client.get_httpx_client().request(
105
+ **kwargs,
106
+ )
107
+
108
+ return _build_response(client=client, response=response)
109
+
110
+
111
+ def sync(
112
+ tenant_id: str,
113
+ store_id: str,
114
+ resource_type: ResourceType,
115
+ id: str,
116
+ *,
117
+ client: AuthenticatedClient | Client,
118
+ ) -> Any | OperationOutcome | None:
119
+ """Delete a FHIR resource
120
+
121
+ Args:
122
+ tenant_id (str):
123
+ store_id (str):
124
+ resource_type (ResourceType): FHIR resource type
125
+ id (str):
126
+
127
+ Raises:
128
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
129
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
130
+
131
+ Returns:
132
+ Any | OperationOutcome
133
+ """
134
+
135
+ return sync_detailed(
136
+ tenant_id=tenant_id,
137
+ store_id=store_id,
138
+ resource_type=resource_type,
139
+ id=id,
140
+ client=client,
141
+ ).parsed
142
+
143
+
144
+ async def asyncio_detailed(
145
+ tenant_id: str,
146
+ store_id: str,
147
+ resource_type: ResourceType,
148
+ id: str,
149
+ *,
150
+ client: AuthenticatedClient | Client,
151
+ ) -> Response[Any | OperationOutcome]:
152
+ """Delete a FHIR resource
153
+
154
+ Args:
155
+ tenant_id (str):
156
+ store_id (str):
157
+ resource_type (ResourceType): FHIR resource type
158
+ id (str):
159
+
160
+ Raises:
161
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
162
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
163
+
164
+ Returns:
165
+ Response[Any | OperationOutcome]
166
+ """
167
+
168
+ kwargs = _get_kwargs(
169
+ tenant_id=tenant_id,
170
+ store_id=store_id,
171
+ resource_type=resource_type,
172
+ id=id,
173
+ )
174
+
175
+ response = await client.get_async_httpx_client().request(**kwargs)
176
+
177
+ return _build_response(client=client, response=response)
178
+
179
+
180
+ async def asyncio(
181
+ tenant_id: str,
182
+ store_id: str,
183
+ resource_type: ResourceType,
184
+ id: str,
185
+ *,
186
+ client: AuthenticatedClient | Client,
187
+ ) -> Any | OperationOutcome | None:
188
+ """Delete a FHIR resource
189
+
190
+ Args:
191
+ tenant_id (str):
192
+ store_id (str):
193
+ resource_type (ResourceType): FHIR resource type
194
+ id (str):
195
+
196
+ Raises:
197
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
198
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
199
+
200
+ Returns:
201
+ Any | OperationOutcome
202
+ """
203
+
204
+ return (
205
+ await asyncio_detailed(
206
+ tenant_id=tenant_id,
207
+ store_id=store_id,
208
+ resource_type=resource_type,
209
+ id=id,
210
+ client=client,
211
+ )
212
+ ).parsed