clear-skies 2.0.3__py3-none-any.whl → 2.0.5__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.

Potentially problematic release.


This version of clear-skies might be problematic. Click here for more details.

Files changed (251) hide show
  1. clear_skies-2.0.5.dist-info/METADATA +74 -0
  2. clear_skies-2.0.5.dist-info/RECORD +4 -0
  3. {clear_skies-2.0.3.dist-info → clear_skies-2.0.5.dist-info}/WHEEL +1 -1
  4. clear_skies-2.0.3.dist-info/METADATA +0 -46
  5. clear_skies-2.0.3.dist-info/RECORD +0 -249
  6. clearskies/__init__.py +0 -59
  7. clearskies/action.py +0 -7
  8. clearskies/authentication/__init__.py +0 -15
  9. clearskies/authentication/authentication.py +0 -46
  10. clearskies/authentication/authorization.py +0 -16
  11. clearskies/authentication/authorization_pass_through.py +0 -20
  12. clearskies/authentication/jwks.py +0 -163
  13. clearskies/authentication/public.py +0 -5
  14. clearskies/authentication/secret_bearer.py +0 -553
  15. clearskies/autodoc/__init__.py +0 -8
  16. clearskies/autodoc/formats/__init__.py +0 -5
  17. clearskies/autodoc/formats/oai3_json/__init__.py +0 -7
  18. clearskies/autodoc/formats/oai3_json/oai3_json.py +0 -87
  19. clearskies/autodoc/formats/oai3_json/oai3_schema_resolver.py +0 -15
  20. clearskies/autodoc/formats/oai3_json/parameter.py +0 -35
  21. clearskies/autodoc/formats/oai3_json/request.py +0 -68
  22. clearskies/autodoc/formats/oai3_json/response.py +0 -28
  23. clearskies/autodoc/formats/oai3_json/schema/__init__.py +0 -11
  24. clearskies/autodoc/formats/oai3_json/schema/array.py +0 -9
  25. clearskies/autodoc/formats/oai3_json/schema/default.py +0 -13
  26. clearskies/autodoc/formats/oai3_json/schema/enum.py +0 -7
  27. clearskies/autodoc/formats/oai3_json/schema/object.py +0 -29
  28. clearskies/autodoc/formats/oai3_json/test.json +0 -1985
  29. clearskies/autodoc/py.typed +0 -0
  30. clearskies/autodoc/request/__init__.py +0 -15
  31. clearskies/autodoc/request/header.py +0 -6
  32. clearskies/autodoc/request/json_body.py +0 -6
  33. clearskies/autodoc/request/parameter.py +0 -8
  34. clearskies/autodoc/request/request.py +0 -38
  35. clearskies/autodoc/request/url_parameter.py +0 -6
  36. clearskies/autodoc/request/url_path.py +0 -6
  37. clearskies/autodoc/response/__init__.py +0 -5
  38. clearskies/autodoc/response/response.py +0 -9
  39. clearskies/autodoc/schema/__init__.py +0 -31
  40. clearskies/autodoc/schema/array.py +0 -10
  41. clearskies/autodoc/schema/base64.py +0 -8
  42. clearskies/autodoc/schema/boolean.py +0 -5
  43. clearskies/autodoc/schema/date.py +0 -5
  44. clearskies/autodoc/schema/datetime.py +0 -5
  45. clearskies/autodoc/schema/double.py +0 -5
  46. clearskies/autodoc/schema/enum.py +0 -17
  47. clearskies/autodoc/schema/integer.py +0 -6
  48. clearskies/autodoc/schema/long.py +0 -5
  49. clearskies/autodoc/schema/number.py +0 -6
  50. clearskies/autodoc/schema/object.py +0 -13
  51. clearskies/autodoc/schema/password.py +0 -5
  52. clearskies/autodoc/schema/schema.py +0 -11
  53. clearskies/autodoc/schema/string.py +0 -5
  54. clearskies/backends/__init__.py +0 -65
  55. clearskies/backends/api_backend.py +0 -1178
  56. clearskies/backends/backend.py +0 -136
  57. clearskies/backends/cursor_backend.py +0 -335
  58. clearskies/backends/memory_backend.py +0 -797
  59. clearskies/backends/secrets_backend.py +0 -106
  60. clearskies/column.py +0 -1233
  61. clearskies/columns/__init__.py +0 -71
  62. clearskies/columns/audit.py +0 -206
  63. clearskies/columns/belongs_to_id.py +0 -483
  64. clearskies/columns/belongs_to_model.py +0 -132
  65. clearskies/columns/belongs_to_self.py +0 -105
  66. clearskies/columns/boolean.py +0 -113
  67. clearskies/columns/category_tree.py +0 -275
  68. clearskies/columns/category_tree_ancestors.py +0 -51
  69. clearskies/columns/category_tree_children.py +0 -127
  70. clearskies/columns/category_tree_descendants.py +0 -48
  71. clearskies/columns/created.py +0 -95
  72. clearskies/columns/created_by_authorization_data.py +0 -116
  73. clearskies/columns/created_by_header.py +0 -99
  74. clearskies/columns/created_by_ip.py +0 -92
  75. clearskies/columns/created_by_routing_data.py +0 -97
  76. clearskies/columns/created_by_user_agent.py +0 -92
  77. clearskies/columns/date.py +0 -234
  78. clearskies/columns/datetime.py +0 -282
  79. clearskies/columns/email.py +0 -76
  80. clearskies/columns/float.py +0 -153
  81. clearskies/columns/has_many.py +0 -505
  82. clearskies/columns/has_many_self.py +0 -56
  83. clearskies/columns/has_one.py +0 -14
  84. clearskies/columns/integer.py +0 -160
  85. clearskies/columns/json.py +0 -126
  86. clearskies/columns/many_to_many_ids.py +0 -337
  87. clearskies/columns/many_to_many_ids_with_data.py +0 -274
  88. clearskies/columns/many_to_many_models.py +0 -158
  89. clearskies/columns/many_to_many_pivots.py +0 -134
  90. clearskies/columns/phone.py +0 -159
  91. clearskies/columns/select.py +0 -92
  92. clearskies/columns/string.py +0 -102
  93. clearskies/columns/timestamp.py +0 -164
  94. clearskies/columns/updated.py +0 -110
  95. clearskies/columns/uuid.py +0 -86
  96. clearskies/configs/README.md +0 -105
  97. clearskies/configs/__init__.py +0 -162
  98. clearskies/configs/actions.py +0 -43
  99. clearskies/configs/any.py +0 -13
  100. clearskies/configs/any_dict.py +0 -22
  101. clearskies/configs/any_dict_or_callable.py +0 -23
  102. clearskies/configs/authentication.py +0 -23
  103. clearskies/configs/authorization.py +0 -23
  104. clearskies/configs/boolean.py +0 -16
  105. clearskies/configs/boolean_or_callable.py +0 -18
  106. clearskies/configs/callable_config.py +0 -18
  107. clearskies/configs/columns.py +0 -34
  108. clearskies/configs/conditions.py +0 -30
  109. clearskies/configs/config.py +0 -24
  110. clearskies/configs/datetime.py +0 -18
  111. clearskies/configs/datetime_or_callable.py +0 -19
  112. clearskies/configs/endpoint.py +0 -23
  113. clearskies/configs/endpoint_list.py +0 -28
  114. clearskies/configs/float.py +0 -16
  115. clearskies/configs/float_or_callable.py +0 -18
  116. clearskies/configs/integer.py +0 -16
  117. clearskies/configs/integer_or_callable.py +0 -18
  118. clearskies/configs/joins.py +0 -30
  119. clearskies/configs/list_any_dict.py +0 -30
  120. clearskies/configs/list_any_dict_or_callable.py +0 -31
  121. clearskies/configs/model_class.py +0 -35
  122. clearskies/configs/model_column.py +0 -65
  123. clearskies/configs/model_columns.py +0 -56
  124. clearskies/configs/model_destination_name.py +0 -25
  125. clearskies/configs/model_to_id_column.py +0 -43
  126. clearskies/configs/readable_model_column.py +0 -9
  127. clearskies/configs/readable_model_columns.py +0 -9
  128. clearskies/configs/schema.py +0 -23
  129. clearskies/configs/searchable_model_columns.py +0 -9
  130. clearskies/configs/security_headers.py +0 -39
  131. clearskies/configs/select.py +0 -26
  132. clearskies/configs/select_list.py +0 -47
  133. clearskies/configs/string.py +0 -29
  134. clearskies/configs/string_dict.py +0 -32
  135. clearskies/configs/string_list.py +0 -32
  136. clearskies/configs/string_list_or_callable.py +0 -35
  137. clearskies/configs/string_or_callable.py +0 -18
  138. clearskies/configs/timedelta.py +0 -18
  139. clearskies/configs/timezone.py +0 -18
  140. clearskies/configs/url.py +0 -23
  141. clearskies/configs/validators.py +0 -45
  142. clearskies/configs/writeable_model_column.py +0 -9
  143. clearskies/configs/writeable_model_columns.py +0 -9
  144. clearskies/configurable.py +0 -76
  145. clearskies/contexts/__init__.py +0 -11
  146. clearskies/contexts/cli.py +0 -117
  147. clearskies/contexts/context.py +0 -98
  148. clearskies/contexts/wsgi.py +0 -76
  149. clearskies/contexts/wsgi_ref.py +0 -82
  150. clearskies/decorators.py +0 -33
  151. clearskies/di/__init__.py +0 -14
  152. clearskies/di/additional_config.py +0 -130
  153. clearskies/di/additional_config_auto_import.py +0 -17
  154. clearskies/di/di.py +0 -968
  155. clearskies/di/inject/__init__.py +0 -23
  156. clearskies/di/inject/by_class.py +0 -21
  157. clearskies/di/inject/by_name.py +0 -18
  158. clearskies/di/inject/di.py +0 -13
  159. clearskies/di/inject/environment.py +0 -14
  160. clearskies/di/inject/input_output.py +0 -20
  161. clearskies/di/inject/now.py +0 -13
  162. clearskies/di/inject/requests.py +0 -13
  163. clearskies/di/inject/secrets.py +0 -14
  164. clearskies/di/inject/utcnow.py +0 -13
  165. clearskies/di/inject/uuid.py +0 -15
  166. clearskies/di/injectable.py +0 -29
  167. clearskies/di/injectable_properties.py +0 -131
  168. clearskies/di/test_module/__init__.py +0 -6
  169. clearskies/di/test_module/another_module/__init__.py +0 -2
  170. clearskies/di/test_module/module_class.py +0 -5
  171. clearskies/end.py +0 -183
  172. clearskies/endpoint.py +0 -1310
  173. clearskies/endpoint_group.py +0 -310
  174. clearskies/endpoints/__init__.py +0 -23
  175. clearskies/endpoints/advanced_search.py +0 -526
  176. clearskies/endpoints/callable.py +0 -388
  177. clearskies/endpoints/create.py +0 -202
  178. clearskies/endpoints/delete.py +0 -139
  179. clearskies/endpoints/get.py +0 -275
  180. clearskies/endpoints/health_check.py +0 -181
  181. clearskies/endpoints/list.py +0 -573
  182. clearskies/endpoints/restful_api.py +0 -427
  183. clearskies/endpoints/simple_search.py +0 -286
  184. clearskies/endpoints/update.py +0 -190
  185. clearskies/environment.py +0 -104
  186. clearskies/exceptions/__init__.py +0 -17
  187. clearskies/exceptions/authentication.py +0 -2
  188. clearskies/exceptions/authorization.py +0 -2
  189. clearskies/exceptions/client_error.py +0 -2
  190. clearskies/exceptions/input_errors.py +0 -4
  191. clearskies/exceptions/moved_permanently.py +0 -3
  192. clearskies/exceptions/moved_temporarily.py +0 -3
  193. clearskies/exceptions/not_found.py +0 -2
  194. clearskies/functional/__init__.py +0 -7
  195. clearskies/functional/routing.py +0 -92
  196. clearskies/functional/string.py +0 -112
  197. clearskies/functional/validations.py +0 -76
  198. clearskies/input_outputs/__init__.py +0 -13
  199. clearskies/input_outputs/cli.py +0 -171
  200. clearskies/input_outputs/exceptions/__init__.py +0 -2
  201. clearskies/input_outputs/exceptions/cli_input_error.py +0 -2
  202. clearskies/input_outputs/exceptions/cli_not_found.py +0 -2
  203. clearskies/input_outputs/headers.py +0 -45
  204. clearskies/input_outputs/input_output.py +0 -138
  205. clearskies/input_outputs/programmatic.py +0 -69
  206. clearskies/input_outputs/py.typed +0 -0
  207. clearskies/input_outputs/wsgi.py +0 -77
  208. clearskies/model.py +0 -1922
  209. clearskies/py.typed +0 -0
  210. clearskies/query/__init__.py +0 -12
  211. clearskies/query/condition.py +0 -223
  212. clearskies/query/join.py +0 -136
  213. clearskies/query/query.py +0 -196
  214. clearskies/query/sort.py +0 -27
  215. clearskies/schema.py +0 -82
  216. clearskies/secrets/__init__.py +0 -6
  217. clearskies/secrets/additional_configs/__init__.py +0 -32
  218. clearskies/secrets/additional_configs/mysql_connection_dynamic_producer.py +0 -61
  219. clearskies/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssh_cert_bastion.py +0 -160
  220. clearskies/secrets/akeyless.py +0 -182
  221. clearskies/secrets/exceptions/__init__.py +0 -1
  222. clearskies/secrets/exceptions/not_found.py +0 -2
  223. clearskies/secrets/secrets.py +0 -38
  224. clearskies/security_header.py +0 -15
  225. clearskies/security_headers/__init__.py +0 -11
  226. clearskies/security_headers/cache_control.py +0 -67
  227. clearskies/security_headers/cors.py +0 -50
  228. clearskies/security_headers/csp.py +0 -94
  229. clearskies/security_headers/hsts.py +0 -22
  230. clearskies/security_headers/x_content_type_options.py +0 -0
  231. clearskies/security_headers/x_frame_options.py +0 -0
  232. clearskies/test_base.py +0 -8
  233. clearskies/typing.py +0 -11
  234. clearskies/validator.py +0 -37
  235. clearskies/validators/__init__.py +0 -33
  236. clearskies/validators/after_column.py +0 -62
  237. clearskies/validators/before_column.py +0 -13
  238. clearskies/validators/in_the_future.py +0 -32
  239. clearskies/validators/in_the_future_at_least.py +0 -11
  240. clearskies/validators/in_the_future_at_most.py +0 -10
  241. clearskies/validators/in_the_past.py +0 -32
  242. clearskies/validators/in_the_past_at_least.py +0 -10
  243. clearskies/validators/in_the_past_at_most.py +0 -10
  244. clearskies/validators/maximum_length.py +0 -26
  245. clearskies/validators/maximum_value.py +0 -29
  246. clearskies/validators/minimum_length.py +0 -26
  247. clearskies/validators/minimum_value.py +0 -29
  248. clearskies/validators/required.py +0 -34
  249. clearskies/validators/timedelta.py +0 -59
  250. clearskies/validators/unique.py +0 -30
  251. {clear_skies-2.0.3.dist-info → clear_skies-2.0.5.dist-info/licenses}/LICENSE +0 -0
@@ -1,310 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import TYPE_CHECKING, Any, Callable, Self
4
-
5
- import clearskies.configurable
6
- import clearskies.di
7
- import clearskies.end
8
- from clearskies import exceptions
9
- from clearskies.authentication import Authentication, Authorization, Public
10
- from clearskies.endpoint import Endpoint
11
- from clearskies.functional import routing
12
- from clearskies.input_outputs import InputOutput
13
-
14
- if TYPE_CHECKING:
15
- from clearskies import SecurityHeader
16
-
17
-
18
- class EndpointGroup(
19
- clearskies.end.End, # type: ignore
20
- clearskies.configurable.Configurable,
21
- clearskies.di.InjectableProperties,
22
- ):
23
- """
24
- An endpoint group brings endpoints together: it basically handles routing.
25
-
26
- The endpoint group accepts a list of endpoints/endpoint groups and routes requests to them. You can set a URL for
27
- the endpoint group, and this becomes a URL prefix for all of the endpoints under it. Note that all routing is
28
- greedy, which means you want to put endpoints with more specific URLs first. Here's an example of how
29
- you can use them to build a fully functional API that manages both users and companies. Each individual
30
- endpoint is defined for the purpose of the example, but note that in practice you could accomplish this same
31
- thing with much less code by using the RestfulApi endpoint:
32
-
33
- ```python
34
- import clearskies
35
- from clearskies.validators import Required, Unique
36
- from clearskies import columns
37
-
38
-
39
- class Company(clearskies.Model):
40
- id_column_name = "id"
41
- backend = clearskies.backends.MemoryBackend()
42
-
43
- id = columns.Uuid()
44
- name = columns.String(
45
- validators=[
46
- Required(),
47
- Unique(),
48
- ]
49
- )
50
-
51
-
52
- class User(clearskies.Model):
53
- id_column_name = "id"
54
- backend = clearskies.backends.MemoryBackend()
55
-
56
- id = columns.Uuid()
57
- name = columns.String(validators=[Required()])
58
- username = columns.String(
59
- validators=[
60
- Required(),
61
- Unique(),
62
- ]
63
- )
64
- age = columns.Integer(validators=[Required()])
65
- created_at = columns.Created()
66
- updated_at = columns.Updated()
67
- company_id = columns.BelongsToId(
68
- Company,
69
- readable_parent_columns=["id", "name"],
70
- validators=[Required()],
71
- )
72
- company = columns.BelongsToModel("company_id")
73
-
74
-
75
- readable_user_column_names = [
76
- "id",
77
- "name",
78
- "username",
79
- "age",
80
- "created_at",
81
- "updated_at",
82
- "company",
83
- ]
84
- writeable_user_column_names = ["name", "username", "age", "company_id"]
85
- users_api = clearskies.EndpointGroup(
86
- [
87
- clearskies.endpoints.Update(
88
- model_class=User,
89
- url="/:id",
90
- readable_column_names=readable_user_column_names,
91
- writeable_column_names=writeable_user_column_names,
92
- ),
93
- clearskies.endpoints.Delete(
94
- model_class=User,
95
- url="/:id",
96
- ),
97
- clearskies.endpoints.Get(
98
- model_class=User,
99
- url="/:id",
100
- readable_column_names=readable_user_column_names,
101
- ),
102
- clearskies.endpoints.Create(
103
- model_class=User,
104
- readable_column_names=readable_user_column_names,
105
- writeable_column_names=writeable_user_column_names,
106
- ),
107
- clearskies.endpoints.SimpleSearch(
108
- model_class=User,
109
- readable_column_names=readable_user_column_names,
110
- sortable_column_names=readable_user_column_names,
111
- searchable_column_names=readable_user_column_names,
112
- default_sort_column_name="name",
113
- ),
114
- ],
115
- url="users",
116
- )
117
-
118
- readable_company_column_names = ["id", "name"]
119
- writeable_company_column_names = ["name"]
120
- companies_api = clearskies.EndpointGroup(
121
- [
122
- clearskies.endpoints.Update(
123
- model_class=Company,
124
- url="/:id",
125
- readable_column_names=readable_company_column_names,
126
- writeable_column_names=writeable_company_column_names,
127
- ),
128
- clearskies.endpoints.Delete(
129
- model_class=Company,
130
- url="/:id",
131
- ),
132
- clearskies.endpoints.Get(
133
- model_class=Company,
134
- url="/:id",
135
- readable_column_names=readable_company_column_names,
136
- ),
137
- clearskies.endpoints.Create(
138
- model_class=Company,
139
- readable_column_names=readable_company_column_names,
140
- writeable_column_names=writeable_company_column_names,
141
- ),
142
- clearskies.endpoints.SimpleSearch(
143
- model_class=Company,
144
- readable_column_names=readable_company_column_names,
145
- sortable_column_names=readable_company_column_names,
146
- searchable_column_names=readable_company_column_names,
147
- default_sort_column_name="name",
148
- ),
149
- ],
150
- url="companies",
151
- )
152
-
153
- wsgi = clearskies.contexts.WsgiRef(clearskies.EndpointGroup([users_api, companies_api]))
154
- wsgi()
155
- ```
156
-
157
- Usage then works exactly as expected:
158
-
159
- ```bash
160
- $ curl 'http://localhost:8080/companies' -d '{"name": "Box Store"}' | jq
161
- {
162
- "status": "success",
163
- "error": "",
164
- "data": {
165
- "id": "f073ee4d-318d-4e0b-a796-f450c40aa771",
166
- "name": "Box Store"
167
- },
168
- "pagination": {},
169
- "input_errors": {}
170
- }
171
-
172
- curl 'http://localhost:8080/users' -d '{"name": "Bob Brown", "username": "bobbrown", "age": 25, "company_id": "f073ee4d-318d-4e0b-a796-f450c40aa771"}'
173
- curl 'http://localhost:8080/users' -d '{"name": "Jane Doe", "username": "janedoe", "age": 32, "company_id": "f073ee4d-318d-4e0b-a796-f450c40aa771"}'
174
-
175
- $ curl 'http://localhost:8080/users' | jq
176
- {
177
- "status": "success",
178
- "error": "",
179
- "data": [
180
- {
181
- "id": "68cbb9e9-689a-4ae0-af77-d60e4cb344f1",
182
- "name": "Bob Brown",
183
- "username": "bobbrown",
184
- "age": 25,
185
- "created_at": "2025-06-08T10:40:37+00:00",
186
- "updated_at": "2025-06-08T10:40:37+00:00",
187
- "company": {
188
- "id": "f073ee4d-318d-4e0b-a796-f450c40aa771",
189
- "name": "Box Store"
190
- }
191
- },
192
- {
193
- "id": "e69c4ebf-38b1-40d2-b523-5d58f5befc7b",
194
- "name": "Jane Doe",
195
- "username": "janedoe",
196
- "age": 32,
197
- "created_at": "2025-06-08T10:41:04+00:00",
198
- "updated_at": "2025-06-08T10:41:04+00:00",
199
- "company": {
200
- "id": "f073ee4d-318d-4e0b-a796-f450c40aa771",
201
- "name": "Box Store"
202
- }
203
- }
204
- ],
205
- "pagination": {
206
- "number_results": 2,
207
- "limit": 50,
208
- "next_page": {}
209
- },
210
- "input_errors": {}
211
- }
212
-
213
- ```
214
- """
215
-
216
- """
217
- The dependency injection container
218
- """
219
- di = clearskies.di.inject.Di()
220
-
221
- """
222
- The base URL for the endpoint group.
223
-
224
- This URL is added as a prefix to all endpoints attached to the group. This includes any named URL parameters:
225
- """
226
- url = clearskies.configs.String(default="")
227
-
228
- """
229
- The list of endpoints connected to this endpoint group
230
- """
231
- endpoints = clearskies.configs.EndpointList()
232
-
233
- response_headers = clearskies.configs.StringListOrCallable(default=[])
234
- authentication = clearskies.configs.Authentication(default=Public())
235
- authorization = clearskies.configs.Authorization(default=Authorization())
236
- security_headers = clearskies.configs.SecurityHeaders(default=[])
237
-
238
- cors_header: SecurityHeader = None # type: ignore
239
- has_cors: bool = False
240
- endpoints_initialized = False
241
-
242
- @clearskies.decorators.parameters_to_properties
243
- def __init__(
244
- self,
245
- endpoints: list[Endpoint | Self],
246
- url: str = "",
247
- response_headers: list[str | Callable[..., list[str]]] = [],
248
- security_headers: list[SecurityHeader] = [],
249
- authentication: Authentication = Public(),
250
- authorization: Authorization = Authorization(),
251
- ):
252
- self.finalize_and_validate_configuration()
253
- for security_header in self.security_headers:
254
- if not security_header.is_cors:
255
- continue
256
- self.cors_header = security_header
257
- self.has_cors = True
258
- break
259
-
260
- if not endpoints:
261
- raise ValueError(
262
- "An endpoint group must receive a list of endpoints/endpoint groups, but my list of endpoints is empty."
263
- )
264
- if not isinstance(endpoints, list):
265
- raise ValueError(
266
- f"An endpoint group must receive a list of endpoints/endpoint groups, but instead of a list I found an object of type '{endpoints.__class__.__name__}'"
267
- )
268
- for index, endpoint in enumerate(endpoints):
269
- if not isinstance(endpoint, Endpoint) and not isinstance(endpoint, self.__class__):
270
- raise ValueError(
271
- f"An endpoint group must receive a list of endpoints/endpoint groups, but item #{index + 1} was neither an endpoint nor an endpoint group, but an object of type '{endpoints.__class__.__name__}'"
272
- )
273
- if self.url.strip("/"):
274
- endpoint.add_url_prefix(self.url)
275
-
276
- def matches_request(self, input_output: InputOutput, allow_partial=True) -> bool:
277
- """Whether or not we can handle an incoming request based on URL and request method."""
278
- expected_url = self.url.strip("/")
279
- incoming_url = input_output.get_full_path().strip("/")
280
- if not expected_url and not incoming_url:
281
- return True
282
- (matches, routing_data) = routing.match_route(expected_url, incoming_url, allow_partial=allow_partial)
283
- return matches
284
-
285
- def populate_routing_data(self, input_output: InputOutput) -> Any:
286
- # only endpoints (not the endpoint group) can handle this because the endpoint group doesn't have the full url
287
- return None
288
-
289
- def handle(self, input_output):
290
- if not self.endpoints_initialized:
291
- self.endpoints_initialized = True
292
- for endpoint in self.endpoints:
293
- endpoint.injectable_properties(self.di)
294
-
295
- has_match = False
296
- for endpoint in self.endpoints:
297
- if not endpoint.matches_request(input_output):
298
- continue
299
- has_match = True
300
- break
301
-
302
- if not has_match:
303
- return self.error(input_output, "Not Found", 404)
304
-
305
- self.add_response_headers(input_output)
306
- return endpoint(input_output)
307
-
308
- def error(self, input_output: InputOutput, message: str, status_code: int) -> Any:
309
- """Return a client-side error (e.g. 400)."""
310
- return self.respond_json(input_output, {"status": "client_error", "error": message}, status_code)
@@ -1,23 +0,0 @@
1
- from clearskies.endpoints.advanced_search import AdvancedSearch
2
- from clearskies.endpoints.callable import Callable
3
- from clearskies.endpoints.create import Create
4
- from clearskies.endpoints.delete import Delete
5
- from clearskies.endpoints.get import Get
6
- from clearskies.endpoints.health_check import HealthCheck
7
- from clearskies.endpoints.list import List
8
- from clearskies.endpoints.restful_api import RestfulApi
9
- from clearskies.endpoints.simple_search import SimpleSearch
10
- from clearskies.endpoints.update import Update
11
-
12
- __all__ = [
13
- "AdvancedSearch",
14
- "Callable",
15
- "Create",
16
- "Delete",
17
- "Get",
18
- "HealthCheck",
19
- "List",
20
- "RestfulApi",
21
- "SimpleSearch",
22
- "Update",
23
- ]