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,124 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ from collections.abc import Mapping
5
+ from typing import Any, TypeVar
6
+
7
+ from attrs import define as _attrs_define
8
+ from attrs import field as _attrs_field
9
+
10
+ from ..models.search_total_mode import SearchTotalMode
11
+ from ..types import UNSET, Unset
12
+
13
+ T = TypeVar("T", bound="PostDocrefBody")
14
+
15
+
16
+ @_attrs_define
17
+ class PostDocrefBody:
18
+ """
19
+ Attributes:
20
+ patient (str): Patient reference
21
+ start (datetime.date | Unset): Period start date
22
+ end (datetime.date | Unset): Period end date
23
+ type_ (str | Unset): Document type (CodeableConcept token)
24
+ field_total (SearchTotalMode | Unset): FHIR `_total` mode controlling whether a result total is returned. These
25
+ are the three values defined by FHIR R4. `estimate` is accepted but currently behaves like `none` (no total is
26
+ emitted).
27
+ """
28
+
29
+ patient: str
30
+ start: datetime.date | Unset = UNSET
31
+ end: datetime.date | Unset = UNSET
32
+ type_: str | Unset = UNSET
33
+ field_total: SearchTotalMode | Unset = UNSET
34
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
35
+
36
+ def to_dict(self) -> dict[str, Any]:
37
+ patient = self.patient
38
+
39
+ start: str | Unset = UNSET
40
+ if not isinstance(self.start, Unset):
41
+ start = self.start.isoformat()
42
+
43
+ end: str | Unset = UNSET
44
+ if not isinstance(self.end, Unset):
45
+ end = self.end.isoformat()
46
+
47
+ type_ = self.type_
48
+
49
+ field_total: str | Unset = UNSET
50
+ if not isinstance(self.field_total, Unset):
51
+ field_total = self.field_total.value
52
+
53
+ field_dict: dict[str, Any] = {}
54
+ field_dict.update(self.additional_properties)
55
+ field_dict.update(
56
+ {
57
+ "patient": patient,
58
+ }
59
+ )
60
+ if start is not UNSET:
61
+ field_dict["start"] = start
62
+ if end is not UNSET:
63
+ field_dict["end"] = end
64
+ if type_ is not UNSET:
65
+ field_dict["type"] = type_
66
+ if field_total is not UNSET:
67
+ field_dict["_total"] = field_total
68
+
69
+ return field_dict
70
+
71
+ @classmethod
72
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
73
+ d = dict(src_dict)
74
+ patient = d.pop("patient")
75
+
76
+ _start = d.pop("start", UNSET)
77
+ start: datetime.date | Unset
78
+ if isinstance(_start, Unset):
79
+ start = UNSET
80
+ else:
81
+ start = datetime.date.fromisoformat(_start)
82
+
83
+ _end = d.pop("end", UNSET)
84
+ end: datetime.date | Unset
85
+ if isinstance(_end, Unset):
86
+ end = UNSET
87
+ else:
88
+ end = datetime.date.fromisoformat(_end)
89
+
90
+ type_ = d.pop("type", UNSET)
91
+
92
+ _field_total = d.pop("_total", UNSET)
93
+ field_total: SearchTotalMode | Unset
94
+ if isinstance(_field_total, Unset):
95
+ field_total = UNSET
96
+ else:
97
+ field_total = SearchTotalMode(_field_total)
98
+
99
+ post_docref_body = cls(
100
+ patient=patient,
101
+ start=start,
102
+ end=end,
103
+ type_=type_,
104
+ field_total=field_total,
105
+ )
106
+
107
+ post_docref_body.additional_properties = d
108
+ return post_docref_body
109
+
110
+ @property
111
+ def additional_keys(self) -> list[str]:
112
+ return list(self.additional_properties.keys())
113
+
114
+ def __getitem__(self, key: str) -> Any:
115
+ return self.additional_properties[key]
116
+
117
+ def __setitem__(self, key: str, value: Any) -> None:
118
+ self.additional_properties[key] = value
119
+
120
+ def __delitem__(self, key: str) -> None:
121
+ del self.additional_properties[key]
122
+
123
+ def __contains__(self, key: str) -> bool:
124
+ return key in self.additional_properties
@@ -0,0 +1,47 @@
1
+ from enum import StrEnum
2
+
3
+
4
+ class ResourceType(StrEnum):
5
+ ALLERGYINTOLERANCE = "AllergyIntolerance"
6
+ APPOINTMENT = "Appointment"
7
+ CAREPLAN = "CarePlan"
8
+ CARETEAM = "CareTeam"
9
+ CLAIM = "Claim"
10
+ COMMUNICATION = "Communication"
11
+ CONDITION = "Condition"
12
+ CONSENT = "Consent"
13
+ COVERAGE = "Coverage"
14
+ DEVICE = "Device"
15
+ DIAGNOSTICREPORT = "DiagnosticReport"
16
+ DOCUMENTREFERENCE = "DocumentReference"
17
+ ENCOUNTER = "Encounter"
18
+ EXPLANATIONOFBENEFIT = "ExplanationOfBenefit"
19
+ FAMILYMEMBERHISTORY = "FamilyMemberHistory"
20
+ GOAL = "Goal"
21
+ HEALTHCARESERVICE = "HealthcareService"
22
+ IMMUNIZATION = "Immunization"
23
+ LOCATION = "Location"
24
+ MEDICATION = "Medication"
25
+ MEDICATIONADMINISTRATION = "MedicationAdministration"
26
+ MEDICATIONDISPENSE = "MedicationDispense"
27
+ MEDICATIONREQUEST = "MedicationRequest"
28
+ MEDICATIONSTATEMENT = "MedicationStatement"
29
+ OBSERVATION = "Observation"
30
+ ORGANIZATION = "Organization"
31
+ PATIENT = "Patient"
32
+ PRACTITIONER = "Practitioner"
33
+ PRACTITIONERROLE = "PractitionerRole"
34
+ PROCEDURE = "Procedure"
35
+ PROVENANCE = "Provenance"
36
+ QUESTIONNAIRE = "Questionnaire"
37
+ QUESTIONNAIRERESPONSE = "QuestionnaireResponse"
38
+ RELATEDPERSON = "RelatedPerson"
39
+ SCHEDULE = "Schedule"
40
+ SERVICEREQUEST = "ServiceRequest"
41
+ SLOT = "Slot"
42
+ SPECIMEN = "Specimen"
43
+ SUBSCRIPTION = "Subscription"
44
+ TASK = "Task"
45
+
46
+ def __str__(self) -> str:
47
+ return str(self.value)
@@ -0,0 +1,155 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import Any, TypeVar, cast
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ from ..models.search_summary_mode import SearchSummaryMode
10
+ from ..models.search_total_mode import SearchTotalMode
11
+ from ..types import UNSET, Unset
12
+
13
+ T = TypeVar("T", bound="SearchResourcesPostBody")
14
+
15
+
16
+ @_attrs_define
17
+ class SearchResourcesPostBody:
18
+ """
19
+ Attributes:
20
+ field_count (int | Unset):
21
+ field_offset (int | Unset):
22
+ field_cursor (str | Unset):
23
+ field_total (SearchTotalMode | Unset): FHIR `_total` mode controlling whether a result total is returned. These
24
+ are the three values defined by FHIR R4. `estimate` is accepted but currently behaves like `none` (no total is
25
+ emitted).
26
+ field_summary (SearchSummaryMode | Unset): Search response summary mode
27
+ field_elements (str | Unset):
28
+ field_sort (str | Unset):
29
+ field_include (list[str] | Unset):
30
+ field_revinclude (list[str] | Unset):
31
+ """
32
+
33
+ field_count: int | Unset = UNSET
34
+ field_offset: int | Unset = UNSET
35
+ field_cursor: str | Unset = UNSET
36
+ field_total: SearchTotalMode | Unset = UNSET
37
+ field_summary: SearchSummaryMode | Unset = UNSET
38
+ field_elements: str | Unset = UNSET
39
+ field_sort: str | Unset = UNSET
40
+ field_include: list[str] | Unset = UNSET
41
+ field_revinclude: list[str] | Unset = UNSET
42
+ additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict)
43
+
44
+ def to_dict(self) -> dict[str, Any]:
45
+ field_count = self.field_count
46
+
47
+ field_offset = self.field_offset
48
+
49
+ field_cursor = self.field_cursor
50
+
51
+ field_total: str | Unset = UNSET
52
+ if not isinstance(self.field_total, Unset):
53
+ field_total = self.field_total.value
54
+
55
+ field_summary: str | Unset = UNSET
56
+ if not isinstance(self.field_summary, Unset):
57
+ field_summary = self.field_summary.value
58
+
59
+ field_elements = self.field_elements
60
+
61
+ field_sort = self.field_sort
62
+
63
+ field_include: list[str] | Unset = UNSET
64
+ if not isinstance(self.field_include, Unset):
65
+ field_include = self.field_include
66
+
67
+ field_revinclude: list[str] | Unset = UNSET
68
+ if not isinstance(self.field_revinclude, Unset):
69
+ field_revinclude = self.field_revinclude
70
+
71
+ field_dict: dict[str, Any] = {}
72
+ field_dict.update(self.additional_properties)
73
+ field_dict.update({})
74
+ if field_count is not UNSET:
75
+ field_dict["_count"] = field_count
76
+ if field_offset is not UNSET:
77
+ field_dict["_offset"] = field_offset
78
+ if field_cursor is not UNSET:
79
+ field_dict["_cursor"] = field_cursor
80
+ if field_total is not UNSET:
81
+ field_dict["_total"] = field_total
82
+ if field_summary is not UNSET:
83
+ field_dict["_summary"] = field_summary
84
+ if field_elements is not UNSET:
85
+ field_dict["_elements"] = field_elements
86
+ if field_sort is not UNSET:
87
+ field_dict["_sort"] = field_sort
88
+ if field_include is not UNSET:
89
+ field_dict["_include"] = field_include
90
+ if field_revinclude is not UNSET:
91
+ field_dict["_revinclude"] = field_revinclude
92
+
93
+ return field_dict
94
+
95
+ @classmethod
96
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
97
+ d = dict(src_dict)
98
+ field_count = d.pop("_count", UNSET)
99
+
100
+ field_offset = d.pop("_offset", UNSET)
101
+
102
+ field_cursor = d.pop("_cursor", UNSET)
103
+
104
+ _field_total = d.pop("_total", UNSET)
105
+ field_total: SearchTotalMode | Unset
106
+ if isinstance(_field_total, Unset):
107
+ field_total = UNSET
108
+ else:
109
+ field_total = SearchTotalMode(_field_total)
110
+
111
+ _field_summary = d.pop("_summary", UNSET)
112
+ field_summary: SearchSummaryMode | Unset
113
+ if isinstance(_field_summary, Unset):
114
+ field_summary = UNSET
115
+ else:
116
+ field_summary = SearchSummaryMode(_field_summary)
117
+
118
+ field_elements = d.pop("_elements", UNSET)
119
+
120
+ field_sort = d.pop("_sort", UNSET)
121
+
122
+ field_include = cast(list[str], d.pop("_include", UNSET))
123
+
124
+ field_revinclude = cast(list[str], d.pop("_revinclude", UNSET))
125
+
126
+ search_resources_post_body = cls(
127
+ field_count=field_count,
128
+ field_offset=field_offset,
129
+ field_cursor=field_cursor,
130
+ field_total=field_total,
131
+ field_summary=field_summary,
132
+ field_elements=field_elements,
133
+ field_sort=field_sort,
134
+ field_include=field_include,
135
+ field_revinclude=field_revinclude,
136
+ )
137
+
138
+ search_resources_post_body.additional_properties = d
139
+ return search_resources_post_body
140
+
141
+ @property
142
+ def additional_keys(self) -> list[str]:
143
+ return list(self.additional_properties.keys())
144
+
145
+ def __getitem__(self, key: str) -> str:
146
+ return self.additional_properties[key]
147
+
148
+ def __setitem__(self, key: str, value: str) -> None:
149
+ self.additional_properties[key] = value
150
+
151
+ def __delitem__(self, key: str) -> None:
152
+ del self.additional_properties[key]
153
+
154
+ def __contains__(self, key: str) -> bool:
155
+ return key in self.additional_properties
@@ -0,0 +1,12 @@
1
+ from enum import StrEnum
2
+
3
+
4
+ class SearchSummaryMode(StrEnum):
5
+ COUNT = "count"
6
+ DATA = "data"
7
+ FALSE = "false"
8
+ TEXT = "text"
9
+ TRUE = "true"
10
+
11
+ def __str__(self) -> str:
12
+ return str(self.value)
@@ -0,0 +1,10 @@
1
+ from enum import StrEnum
2
+
3
+
4
+ class SearchTotalMode(StrEnum):
5
+ ACCURATE = "accurate"
6
+ ESTIMATE = "estimate"
7
+ NONE = "none"
8
+
9
+ def __str__(self) -> str:
10
+ return str(self.value)
@@ -0,0 +1,111 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import Any, TypeVar, cast
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ from ..types import UNSET, Unset
10
+
11
+ T = TypeVar("T", bound="SmartConfiguration")
12
+
13
+
14
+ @_attrs_define
15
+ class SmartConfiguration:
16
+ """
17
+ Attributes:
18
+ token_endpoint (str | Unset):
19
+ grant_types_supported (list[str] | Unset):
20
+ token_endpoint_auth_methods_supported (list[str] | Unset):
21
+ scopes_supported (list[str] | Unset):
22
+ capabilities (list[str] | Unset):
23
+ """
24
+
25
+ token_endpoint: str | Unset = UNSET
26
+ grant_types_supported: list[str] | Unset = UNSET
27
+ token_endpoint_auth_methods_supported: list[str] | Unset = UNSET
28
+ scopes_supported: list[str] | Unset = UNSET
29
+ capabilities: list[str] | Unset = UNSET
30
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
31
+
32
+ def to_dict(self) -> dict[str, Any]:
33
+ token_endpoint = self.token_endpoint
34
+
35
+ grant_types_supported: list[str] | Unset = UNSET
36
+ if not isinstance(self.grant_types_supported, Unset):
37
+ grant_types_supported = self.grant_types_supported
38
+
39
+ token_endpoint_auth_methods_supported: list[str] | Unset = UNSET
40
+ if not isinstance(self.token_endpoint_auth_methods_supported, Unset):
41
+ token_endpoint_auth_methods_supported = (
42
+ self.token_endpoint_auth_methods_supported
43
+ )
44
+
45
+ scopes_supported: list[str] | Unset = UNSET
46
+ if not isinstance(self.scopes_supported, Unset):
47
+ scopes_supported = self.scopes_supported
48
+
49
+ capabilities: list[str] | Unset = UNSET
50
+ if not isinstance(self.capabilities, Unset):
51
+ capabilities = self.capabilities
52
+
53
+ field_dict: dict[str, Any] = {}
54
+ field_dict.update(self.additional_properties)
55
+ field_dict.update({})
56
+ if token_endpoint is not UNSET:
57
+ field_dict["token_endpoint"] = token_endpoint
58
+ if grant_types_supported is not UNSET:
59
+ field_dict["grant_types_supported"] = grant_types_supported
60
+ if token_endpoint_auth_methods_supported is not UNSET:
61
+ field_dict["token_endpoint_auth_methods_supported"] = (
62
+ token_endpoint_auth_methods_supported
63
+ )
64
+ if scopes_supported is not UNSET:
65
+ field_dict["scopes_supported"] = scopes_supported
66
+ if capabilities is not UNSET:
67
+ field_dict["capabilities"] = capabilities
68
+
69
+ return field_dict
70
+
71
+ @classmethod
72
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
73
+ d = dict(src_dict)
74
+ token_endpoint = d.pop("token_endpoint", UNSET)
75
+
76
+ grant_types_supported = cast(list[str], d.pop("grant_types_supported", UNSET))
77
+
78
+ token_endpoint_auth_methods_supported = cast(
79
+ list[str], d.pop("token_endpoint_auth_methods_supported", UNSET)
80
+ )
81
+
82
+ scopes_supported = cast(list[str], d.pop("scopes_supported", UNSET))
83
+
84
+ capabilities = cast(list[str], d.pop("capabilities", UNSET))
85
+
86
+ smart_configuration = cls(
87
+ token_endpoint=token_endpoint,
88
+ grant_types_supported=grant_types_supported,
89
+ token_endpoint_auth_methods_supported=token_endpoint_auth_methods_supported,
90
+ scopes_supported=scopes_supported,
91
+ capabilities=capabilities,
92
+ )
93
+
94
+ smart_configuration.additional_properties = d
95
+ return smart_configuration
96
+
97
+ @property
98
+ def additional_keys(self) -> list[str]:
99
+ return list(self.additional_properties.keys())
100
+
101
+ def __getitem__(self, key: str) -> Any:
102
+ return self.additional_properties[key]
103
+
104
+ def __setitem__(self, key: str, value: Any) -> None:
105
+ self.additional_properties[key] = value
106
+
107
+ def __delitem__(self, key: str) -> None:
108
+ del self.additional_properties[key]
109
+
110
+ def __contains__(self, key: str) -> bool:
111
+ return key in self.additional_properties
@@ -0,0 +1,87 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import Any, TypeVar
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ from ..models.token_response_token_type import TokenResponseTokenType
10
+
11
+ T = TypeVar("T", bound="TokenResponse")
12
+
13
+
14
+ @_attrs_define
15
+ class TokenResponse:
16
+ """
17
+ Attributes:
18
+ access_token (str):
19
+ token_type (TokenResponseTokenType):
20
+ expires_in (int): Token lifetime in seconds
21
+ scope (str): Space-delimited list of granted scopes
22
+ """
23
+
24
+ access_token: str
25
+ token_type: TokenResponseTokenType
26
+ expires_in: int
27
+ scope: str
28
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
29
+
30
+ def to_dict(self) -> dict[str, Any]:
31
+ access_token = self.access_token
32
+
33
+ token_type = self.token_type.value
34
+
35
+ expires_in = self.expires_in
36
+
37
+ scope = self.scope
38
+
39
+ field_dict: dict[str, Any] = {}
40
+ field_dict.update(self.additional_properties)
41
+ field_dict.update(
42
+ {
43
+ "access_token": access_token,
44
+ "token_type": token_type,
45
+ "expires_in": expires_in,
46
+ "scope": scope,
47
+ }
48
+ )
49
+
50
+ return field_dict
51
+
52
+ @classmethod
53
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
54
+ d = dict(src_dict)
55
+ access_token = d.pop("access_token")
56
+
57
+ token_type = TokenResponseTokenType(d.pop("token_type"))
58
+
59
+ expires_in = d.pop("expires_in")
60
+
61
+ scope = d.pop("scope")
62
+
63
+ token_response = cls(
64
+ access_token=access_token,
65
+ token_type=token_type,
66
+ expires_in=expires_in,
67
+ scope=scope,
68
+ )
69
+
70
+ token_response.additional_properties = d
71
+ return token_response
72
+
73
+ @property
74
+ def additional_keys(self) -> list[str]:
75
+ return list(self.additional_properties.keys())
76
+
77
+ def __getitem__(self, key: str) -> Any:
78
+ return self.additional_properties[key]
79
+
80
+ def __setitem__(self, key: str, value: Any) -> None:
81
+ self.additional_properties[key] = value
82
+
83
+ def __delitem__(self, key: str) -> None:
84
+ del self.additional_properties[key]
85
+
86
+ def __contains__(self, key: str) -> bool:
87
+ return key in self.additional_properties
@@ -0,0 +1,8 @@
1
+ from enum import StrEnum
2
+
3
+
4
+ class TokenResponseTokenType(StrEnum):
5
+ BEARER = "Bearer"
6
+
7
+ def __str__(self) -> str:
8
+ return str(self.value)
@@ -0,0 +1,54 @@
1
+ """Contains some shared types for properties"""
2
+
3
+ from collections.abc import Mapping, MutableMapping
4
+ from http import HTTPStatus
5
+ from typing import IO, BinaryIO, Generic, Literal, TypeVar
6
+
7
+ from attrs import define
8
+
9
+
10
+ class Unset:
11
+ def __bool__(self) -> Literal[False]:
12
+ return False
13
+
14
+
15
+ UNSET: Unset = Unset()
16
+
17
+ # The types that `httpx.Client(files=)` can accept, copied from that library.
18
+ FileContent = IO[bytes] | bytes | str
19
+ FileTypes = (
20
+ # (filename, file (or bytes), content_type)
21
+ tuple[str | None, FileContent, str | None]
22
+ # (filename, file (or bytes), content_type, headers)
23
+ | tuple[str | None, FileContent, str | None, Mapping[str, str]]
24
+ )
25
+ RequestFiles = list[tuple[str, FileTypes]]
26
+
27
+
28
+ @define
29
+ class File:
30
+ """Contains information for file uploads"""
31
+
32
+ payload: BinaryIO
33
+ file_name: str | None = None
34
+ mime_type: str | None = None
35
+
36
+ def to_tuple(self) -> FileTypes:
37
+ """Return a tuple representation that httpx will accept for multipart/form-data"""
38
+ return self.file_name, self.payload, self.mime_type
39
+
40
+
41
+ T = TypeVar("T")
42
+
43
+
44
+ @define
45
+ class Response(Generic[T]):
46
+ """A response from an endpoint"""
47
+
48
+ status_code: HTTPStatus
49
+ content: bytes
50
+ headers: MutableMapping[str, str]
51
+ parsed: T | None
52
+
53
+
54
+ __all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"]
phenostore/py.typed ADDED
File without changes