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,223 @@
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.bulk_operation_accepted import BulkOperationAccepted
10
+ from ...models.bundle import Bundle
11
+ from ...models.fhir_resource import FhirResource
12
+ from ...models.operation_outcome import OperationOutcome
13
+ from ...types import Response
14
+
15
+
16
+ def _get_kwargs(
17
+ tenant_id: str,
18
+ store_id: str,
19
+ *,
20
+ body: FhirResource,
21
+ ) -> dict[str, Any]:
22
+ headers: dict[str, Any] = {}
23
+
24
+ _kwargs: dict[str, Any] = {
25
+ "method": "post",
26
+ "url": "/v1/tenants/{tenant_id}/stores/{store_id}/$bulk".format(
27
+ tenant_id=quote(str(tenant_id), safe=""),
28
+ store_id=quote(str(store_id), safe=""),
29
+ ),
30
+ }
31
+
32
+ _kwargs["json"] = body.to_dict()
33
+
34
+ headers["Content-Type"] = "application/fhir+json"
35
+
36
+ _kwargs["headers"] = headers
37
+ return _kwargs
38
+
39
+
40
+ def _parse_response(
41
+ *, client: AuthenticatedClient | Client, response: httpx.Response
42
+ ) -> BulkOperationAccepted | Bundle | OperationOutcome | None:
43
+ if response.status_code == 200:
44
+ response_200 = Bundle.from_dict(response.json())
45
+
46
+ return response_200
47
+
48
+ if response.status_code == 202:
49
+ response_202 = BulkOperationAccepted.from_dict(response.json())
50
+
51
+ return response_202
52
+
53
+ if response.status_code == 400:
54
+ response_400 = OperationOutcome.from_dict(response.json())
55
+
56
+ return response_400
57
+
58
+ if response.status_code == 403:
59
+ response_403 = OperationOutcome.from_dict(response.json())
60
+
61
+ return response_403
62
+
63
+ if client.raise_on_unexpected_status:
64
+ raise errors.UnexpectedStatus(response.status_code, response.content)
65
+ else:
66
+ return None
67
+
68
+
69
+ def _build_response(
70
+ *, client: AuthenticatedClient | Client, response: httpx.Response
71
+ ) -> Response[BulkOperationAccepted | Bundle | OperationOutcome]:
72
+ return Response(
73
+ status_code=HTTPStatus(response.status_code),
74
+ content=response.content,
75
+ headers=response.headers,
76
+ parsed=_parse_response(client=client, response=response),
77
+ )
78
+
79
+
80
+ def sync_detailed(
81
+ tenant_id: str,
82
+ store_id: str,
83
+ *,
84
+ client: AuthenticatedClient | Client,
85
+ body: FhirResource,
86
+ ) -> Response[BulkOperationAccepted | Bundle | OperationOutcome]:
87
+ """Submit a bulk operation
88
+
89
+ Submits a batch Bundle for bulk processing. Operations with ≤100 entries
90
+ are processed synchronously; larger batches are processed asynchronously
91
+ and return 202 with a Content-Location header for polling.
92
+
93
+ Args:
94
+ tenant_id (str):
95
+ store_id (str):
96
+ body (FhirResource): An arbitrary FHIR resource stored as raw JSON.
97
+
98
+ Raises:
99
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
100
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
101
+
102
+ Returns:
103
+ Response[BulkOperationAccepted | Bundle | OperationOutcome]
104
+ """
105
+
106
+ kwargs = _get_kwargs(
107
+ tenant_id=tenant_id,
108
+ store_id=store_id,
109
+ body=body,
110
+ )
111
+
112
+ response = client.get_httpx_client().request(
113
+ **kwargs,
114
+ )
115
+
116
+ return _build_response(client=client, response=response)
117
+
118
+
119
+ def sync(
120
+ tenant_id: str,
121
+ store_id: str,
122
+ *,
123
+ client: AuthenticatedClient | Client,
124
+ body: FhirResource,
125
+ ) -> BulkOperationAccepted | Bundle | OperationOutcome | None:
126
+ """Submit a bulk operation
127
+
128
+ Submits a batch Bundle for bulk processing. Operations with ≤100 entries
129
+ are processed synchronously; larger batches are processed asynchronously
130
+ and return 202 with a Content-Location header for polling.
131
+
132
+ Args:
133
+ tenant_id (str):
134
+ store_id (str):
135
+ body (FhirResource): An arbitrary FHIR resource stored as raw JSON.
136
+
137
+ Raises:
138
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
139
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
140
+
141
+ Returns:
142
+ BulkOperationAccepted | Bundle | OperationOutcome
143
+ """
144
+
145
+ return sync_detailed(
146
+ tenant_id=tenant_id,
147
+ store_id=store_id,
148
+ client=client,
149
+ body=body,
150
+ ).parsed
151
+
152
+
153
+ async def asyncio_detailed(
154
+ tenant_id: str,
155
+ store_id: str,
156
+ *,
157
+ client: AuthenticatedClient | Client,
158
+ body: FhirResource,
159
+ ) -> Response[BulkOperationAccepted | Bundle | OperationOutcome]:
160
+ """Submit a bulk operation
161
+
162
+ Submits a batch Bundle for bulk processing. Operations with ≤100 entries
163
+ are processed synchronously; larger batches are processed asynchronously
164
+ and return 202 with a Content-Location header for polling.
165
+
166
+ Args:
167
+ tenant_id (str):
168
+ store_id (str):
169
+ body (FhirResource): An arbitrary FHIR resource stored as raw JSON.
170
+
171
+ Raises:
172
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
173
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
174
+
175
+ Returns:
176
+ Response[BulkOperationAccepted | Bundle | OperationOutcome]
177
+ """
178
+
179
+ kwargs = _get_kwargs(
180
+ tenant_id=tenant_id,
181
+ store_id=store_id,
182
+ body=body,
183
+ )
184
+
185
+ response = await client.get_async_httpx_client().request(**kwargs)
186
+
187
+ return _build_response(client=client, response=response)
188
+
189
+
190
+ async def asyncio(
191
+ tenant_id: str,
192
+ store_id: str,
193
+ *,
194
+ client: AuthenticatedClient | Client,
195
+ body: FhirResource,
196
+ ) -> BulkOperationAccepted | Bundle | OperationOutcome | None:
197
+ """Submit a bulk operation
198
+
199
+ Submits a batch Bundle for bulk processing. Operations with ≤100 entries
200
+ are processed synchronously; larger batches are processed asynchronously
201
+ and return 202 with a Content-Location header for polling.
202
+
203
+ Args:
204
+ tenant_id (str):
205
+ store_id (str):
206
+ body (FhirResource): An arbitrary FHIR resource stored as raw JSON.
207
+
208
+ Raises:
209
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
210
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
211
+
212
+ Returns:
213
+ BulkOperationAccepted | Bundle | OperationOutcome
214
+ """
215
+
216
+ return (
217
+ await asyncio_detailed(
218
+ tenant_id=tenant_id,
219
+ store_id=store_id,
220
+ client=client,
221
+ body=body,
222
+ )
223
+ ).parsed
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,277 @@
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 UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ tenant_id: str,
16
+ store_id: str,
17
+ resource_type: ResourceType,
18
+ *,
19
+ field_id: str | Unset = UNSET,
20
+ field_last_updated: str | Unset = UNSET,
21
+ identifier: str | Unset = UNSET,
22
+ ) -> dict[str, Any]:
23
+
24
+ params: dict[str, Any] = {}
25
+
26
+ params["_id"] = field_id
27
+
28
+ params["_lastUpdated"] = field_last_updated
29
+
30
+ params["identifier"] = identifier
31
+
32
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
33
+
34
+ _kwargs: dict[str, Any] = {
35
+ "method": "delete",
36
+ "url": "/v1/tenants/{tenant_id}/stores/{store_id}/{resource_type}".format(
37
+ tenant_id=quote(str(tenant_id), safe=""),
38
+ store_id=quote(str(store_id), safe=""),
39
+ resource_type=quote(str(resource_type), safe=""),
40
+ ),
41
+ "params": params,
42
+ }
43
+
44
+ return _kwargs
45
+
46
+
47
+ def _parse_response(
48
+ *, client: AuthenticatedClient | Client, response: httpx.Response
49
+ ) -> Any | OperationOutcome | None:
50
+ if response.status_code == 204:
51
+ response_204 = cast(Any, None)
52
+ return response_204
53
+
54
+ if response.status_code == 400:
55
+ response_400 = OperationOutcome.from_dict(response.json())
56
+
57
+ return response_400
58
+
59
+ if response.status_code == 403:
60
+ response_403 = OperationOutcome.from_dict(response.json())
61
+
62
+ return response_403
63
+
64
+ if response.status_code == 412:
65
+ response_412 = OperationOutcome.from_dict(response.json())
66
+
67
+ return response_412
68
+
69
+ if client.raise_on_unexpected_status:
70
+ raise errors.UnexpectedStatus(response.status_code, response.content)
71
+ else:
72
+ return None
73
+
74
+
75
+ def _build_response(
76
+ *, client: AuthenticatedClient | Client, response: httpx.Response
77
+ ) -> Response[Any | OperationOutcome]:
78
+ return Response(
79
+ status_code=HTTPStatus(response.status_code),
80
+ content=response.content,
81
+ headers=response.headers,
82
+ parsed=_parse_response(client=client, response=response),
83
+ )
84
+
85
+
86
+ def sync_detailed(
87
+ tenant_id: str,
88
+ store_id: str,
89
+ resource_type: ResourceType,
90
+ *,
91
+ client: AuthenticatedClient | Client,
92
+ field_id: str | Unset = UNSET,
93
+ field_last_updated: str | Unset = UNSET,
94
+ identifier: str | Unset = UNSET,
95
+ ) -> Response[Any | OperationOutcome]:
96
+ """Conditionally delete a FHIR resource
97
+
98
+ Deletes a resource matching the given search criteria.
99
+ 0 matches → 204, 1 match → delete + 204, 2+ matches → 412.
100
+ Requires at least one search parameter. Pass FHIR search parameters
101
+ as query parameters (e.g. ?identifier=http://example.com|123).
102
+ Any resource-type-specific search parameter is accepted in addition
103
+ to the common parameters listed below.
104
+
105
+ Args:
106
+ tenant_id (str):
107
+ store_id (str):
108
+ resource_type (ResourceType): FHIR resource type
109
+ field_id (str | Unset):
110
+ field_last_updated (str | Unset):
111
+ identifier (str | Unset):
112
+
113
+ Raises:
114
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
115
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
116
+
117
+ Returns:
118
+ Response[Any | OperationOutcome]
119
+ """
120
+
121
+ kwargs = _get_kwargs(
122
+ tenant_id=tenant_id,
123
+ store_id=store_id,
124
+ resource_type=resource_type,
125
+ field_id=field_id,
126
+ field_last_updated=field_last_updated,
127
+ identifier=identifier,
128
+ )
129
+
130
+ response = client.get_httpx_client().request(
131
+ **kwargs,
132
+ )
133
+
134
+ return _build_response(client=client, response=response)
135
+
136
+
137
+ def sync(
138
+ tenant_id: str,
139
+ store_id: str,
140
+ resource_type: ResourceType,
141
+ *,
142
+ client: AuthenticatedClient | Client,
143
+ field_id: str | Unset = UNSET,
144
+ field_last_updated: str | Unset = UNSET,
145
+ identifier: str | Unset = UNSET,
146
+ ) -> Any | OperationOutcome | None:
147
+ """Conditionally delete a FHIR resource
148
+
149
+ Deletes a resource matching the given search criteria.
150
+ 0 matches → 204, 1 match → delete + 204, 2+ matches → 412.
151
+ Requires at least one search parameter. Pass FHIR search parameters
152
+ as query parameters (e.g. ?identifier=http://example.com|123).
153
+ Any resource-type-specific search parameter is accepted in addition
154
+ to the common parameters listed below.
155
+
156
+ Args:
157
+ tenant_id (str):
158
+ store_id (str):
159
+ resource_type (ResourceType): FHIR resource type
160
+ field_id (str | Unset):
161
+ field_last_updated (str | Unset):
162
+ identifier (str | Unset):
163
+
164
+ Raises:
165
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
166
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
167
+
168
+ Returns:
169
+ Any | OperationOutcome
170
+ """
171
+
172
+ return sync_detailed(
173
+ tenant_id=tenant_id,
174
+ store_id=store_id,
175
+ resource_type=resource_type,
176
+ client=client,
177
+ field_id=field_id,
178
+ field_last_updated=field_last_updated,
179
+ identifier=identifier,
180
+ ).parsed
181
+
182
+
183
+ async def asyncio_detailed(
184
+ tenant_id: str,
185
+ store_id: str,
186
+ resource_type: ResourceType,
187
+ *,
188
+ client: AuthenticatedClient | Client,
189
+ field_id: str | Unset = UNSET,
190
+ field_last_updated: str | Unset = UNSET,
191
+ identifier: str | Unset = UNSET,
192
+ ) -> Response[Any | OperationOutcome]:
193
+ """Conditionally delete a FHIR resource
194
+
195
+ Deletes a resource matching the given search criteria.
196
+ 0 matches → 204, 1 match → delete + 204, 2+ matches → 412.
197
+ Requires at least one search parameter. Pass FHIR search parameters
198
+ as query parameters (e.g. ?identifier=http://example.com|123).
199
+ Any resource-type-specific search parameter is accepted in addition
200
+ to the common parameters listed below.
201
+
202
+ Args:
203
+ tenant_id (str):
204
+ store_id (str):
205
+ resource_type (ResourceType): FHIR resource type
206
+ field_id (str | Unset):
207
+ field_last_updated (str | Unset):
208
+ identifier (str | Unset):
209
+
210
+ Raises:
211
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
212
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
213
+
214
+ Returns:
215
+ Response[Any | OperationOutcome]
216
+ """
217
+
218
+ kwargs = _get_kwargs(
219
+ tenant_id=tenant_id,
220
+ store_id=store_id,
221
+ resource_type=resource_type,
222
+ field_id=field_id,
223
+ field_last_updated=field_last_updated,
224
+ identifier=identifier,
225
+ )
226
+
227
+ response = await client.get_async_httpx_client().request(**kwargs)
228
+
229
+ return _build_response(client=client, response=response)
230
+
231
+
232
+ async def asyncio(
233
+ tenant_id: str,
234
+ store_id: str,
235
+ resource_type: ResourceType,
236
+ *,
237
+ client: AuthenticatedClient | Client,
238
+ field_id: str | Unset = UNSET,
239
+ field_last_updated: str | Unset = UNSET,
240
+ identifier: str | Unset = UNSET,
241
+ ) -> Any | OperationOutcome | None:
242
+ """Conditionally delete a FHIR resource
243
+
244
+ Deletes a resource matching the given search criteria.
245
+ 0 matches → 204, 1 match → delete + 204, 2+ matches → 412.
246
+ Requires at least one search parameter. Pass FHIR search parameters
247
+ as query parameters (e.g. ?identifier=http://example.com|123).
248
+ Any resource-type-specific search parameter is accepted in addition
249
+ to the common parameters listed below.
250
+
251
+ Args:
252
+ tenant_id (str):
253
+ store_id (str):
254
+ resource_type (ResourceType): FHIR resource type
255
+ field_id (str | Unset):
256
+ field_last_updated (str | Unset):
257
+ identifier (str | Unset):
258
+
259
+ Raises:
260
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
261
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
262
+
263
+ Returns:
264
+ Any | OperationOutcome
265
+ """
266
+
267
+ return (
268
+ await asyncio_detailed(
269
+ tenant_id=tenant_id,
270
+ store_id=store_id,
271
+ resource_type=resource_type,
272
+ client=client,
273
+ field_id=field_id,
274
+ field_last_updated=field_last_updated,
275
+ identifier=identifier,
276
+ )
277
+ ).parsed