clear-skies 2.0.7__py3-none-any.whl → 2.0.9__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.
- {clear_skies-2.0.7.dist-info → clear_skies-2.0.9.dist-info}/METADATA +1 -1
- clear_skies-2.0.9.dist-info/RECORD +256 -0
- clearskies/__init__.py +2 -2
- clearskies/authentication/authentication.py +1 -3
- clearskies/authentication/authorization.py +12 -5
- clearskies/authentication/authorization_pass_through.py +5 -3
- clearskies/authentication/jwks.py +25 -23
- clearskies/authentication/secret_bearer.py +15 -17
- clearskies/autodoc/schema/schema.py +1 -1
- clearskies/backends/api_backend.py +50 -56
- clearskies/backends/backend.py +14 -14
- clearskies/backends/cursor_backend.py +17 -23
- clearskies/backends/memory_backend.py +27 -30
- clearskies/backends/secrets_backend.py +13 -18
- clearskies/column.py +44 -56
- clearskies/columns/audit.py +14 -13
- clearskies/columns/belongs_to_id.py +10 -15
- clearskies/columns/belongs_to_model.py +6 -9
- clearskies/columns/belongs_to_self.py +13 -9
- clearskies/columns/boolean.py +13 -16
- clearskies/columns/category_tree.py +9 -11
- clearskies/columns/category_tree_children.py +2 -3
- clearskies/columns/category_tree_descendants.py +1 -1
- clearskies/columns/created.py +8 -11
- clearskies/columns/created_by_authorization_data.py +7 -9
- clearskies/columns/created_by_header.py +12 -8
- clearskies/columns/created_by_ip.py +6 -8
- clearskies/columns/created_by_routing_data.py +12 -7
- clearskies/columns/created_by_user_agent.py +6 -9
- clearskies/columns/date.py +12 -14
- clearskies/columns/datetime.py +19 -17
- clearskies/columns/email.py +3 -1
- clearskies/columns/float.py +10 -14
- clearskies/columns/has_many.py +8 -10
- clearskies/columns/has_many_self.py +13 -7
- clearskies/columns/has_one.py +2 -0
- clearskies/columns/integer.py +9 -11
- clearskies/columns/json.py +10 -12
- clearskies/columns/many_to_many_ids.py +14 -16
- clearskies/columns/many_to_many_ids_with_data.py +16 -16
- clearskies/columns/many_to_many_models.py +5 -7
- clearskies/columns/many_to_many_pivots.py +3 -5
- clearskies/columns/phone.py +12 -9
- clearskies/columns/select.py +12 -9
- clearskies/columns/string.py +1 -1
- clearskies/columns/timestamp.py +15 -15
- clearskies/columns/updated.py +8 -10
- clearskies/columns/uuid.py +7 -10
- clearskies/configs/__init__.py +8 -0
- clearskies/configs/any.py +2 -0
- clearskies/configs/any_dict.py +2 -0
- clearskies/configs/any_dict_or_callable.py +2 -0
- clearskies/configs/boolean.py +2 -0
- clearskies/configs/boolean_or_callable.py +2 -0
- clearskies/configs/callable_config.py +2 -0
- clearskies/configs/config.py +2 -0
- clearskies/configs/datetime.py +2 -0
- clearskies/configs/datetime_or_callable.py +2 -0
- clearskies/configs/email.py +10 -0
- clearskies/configs/email_list.py +17 -0
- clearskies/configs/email_list_or_callable.py +19 -0
- clearskies/configs/email_or_email_list_or_callable.py +59 -0
- clearskies/configs/float.py +2 -0
- clearskies/configs/float_or_callable.py +2 -0
- clearskies/configs/integer.py +2 -0
- clearskies/configs/integer_or_callable.py +2 -0
- clearskies/configs/list_any_dict.py +2 -0
- clearskies/configs/list_any_dict_or_callable.py +2 -0
- clearskies/configs/model_column.py +2 -0
- clearskies/configs/model_columns.py +2 -0
- clearskies/configs/model_destination_name.py +2 -1
- clearskies/configs/model_to_id_column.py +2 -0
- clearskies/configs/readable_model_column.py +2 -0
- clearskies/configs/readable_model_columns.py +2 -0
- clearskies/configs/searchable_model_columns.py +2 -0
- clearskies/configs/select.py +2 -0
- clearskies/configs/select_list.py +2 -0
- clearskies/configs/string.py +4 -2
- clearskies/configs/string_dict.py +2 -0
- clearskies/configs/string_list.py +17 -2
- clearskies/configs/string_list_or_callable.py +13 -0
- clearskies/configs/timedelta.py +2 -0
- clearskies/configs/timezone.py +2 -0
- clearskies/configs/url.py +2 -0
- clearskies/configs/writeable_model_column.py +2 -0
- clearskies/configs/writeable_model_columns.py +2 -0
- clearskies/configurable.py +2 -0
- clearskies/contexts/cli.py +9 -1
- clearskies/contexts/context.py +13 -14
- clearskies/contexts/wsgi.py +12 -10
- clearskies/contexts/wsgi_ref.py +12 -6
- clearskies/decorators.py +1 -1
- clearskies/decorators.pyi +10 -0
- clearskies/di/di.py +7 -6
- clearskies/di/inject/by_class.py +2 -0
- clearskies/di/inject/by_name.py +2 -0
- clearskies/di/inject/di.py +2 -0
- clearskies/di/inject/environment.py +1 -1
- clearskies/di/inject/now.py +2 -0
- clearskies/di/inject/requests.py +2 -0
- clearskies/di/inject/secrets.py +2 -2
- clearskies/di/inject/utcnow.py +2 -0
- clearskies/di/inject/uuid.py +2 -2
- clearskies/end.py +45 -7
- clearskies/endpoint.py +43 -59
- clearskies/endpoint_group.py +15 -18
- clearskies/endpoints/advanced_search.py +19 -26
- clearskies/endpoints/callable.py +10 -16
- clearskies/endpoints/create.py +6 -10
- clearskies/endpoints/delete.py +5 -11
- clearskies/endpoints/get.py +11 -15
- clearskies/endpoints/health_check.py +9 -11
- clearskies/endpoints/list.py +29 -36
- clearskies/endpoints/restful_api.py +43 -53
- clearskies/endpoints/schema.py +14 -18
- clearskies/endpoints/simple_search.py +5 -12
- clearskies/endpoints/update.py +6 -11
- clearskies/environment.py +2 -0
- clearskies/input_outputs/cli.py +2 -0
- clearskies/input_outputs/headers.py +2 -0
- clearskies/input_outputs/input_output.py +15 -15
- clearskies/input_outputs/programmatic.py +2 -2
- clearskies/input_outputs/wsgi.py +2 -2
- clearskies/model.py +120 -25
- clearskies/query/query.py +1 -4
- clearskies/secrets/__init__.py +2 -1
- clearskies/secrets/akeyless.py +16 -11
- clearskies/secrets/secrets.py +7 -2
- clearskies/security_header.py +4 -2
- clearskies/security_headers/cache_control.py +15 -14
- clearskies/security_headers/cors.py +10 -9
- clearskies/security_headers/csp.py +25 -24
- clearskies/security_headers/hsts.py +6 -5
- clearskies/typing.py +1 -1
- clearskies/validator.py +5 -6
- clearskies/validators/after_column.py +6 -7
- clearskies/validators/before_column.py +2 -0
- clearskies/validators/in_the_future.py +5 -8
- clearskies/validators/in_the_future_at_least.py +2 -0
- clearskies/validators/in_the_future_at_most.py +2 -0
- clearskies/validators/in_the_past.py +5 -8
- clearskies/validators/in_the_past_at_least.py +2 -0
- clearskies/validators/in_the_past_at_most.py +2 -0
- clearskies/validators/maximum_length.py +4 -5
- clearskies/validators/maximum_value.py +4 -4
- clearskies/validators/minimum_length.py +4 -4
- clearskies/validators/minimum_value.py +4 -4
- clearskies/validators/required.py +2 -4
- clearskies/validators/timedelta.py +8 -9
- clearskies/validators/unique.py +2 -3
- clear_skies-2.0.7.dist-info/RECORD +0 -251
- {clear_skies-2.0.7.dist-info → clear_skies-2.0.9.dist-info}/WHEEL +0 -0
- {clear_skies-2.0.7.dist-info → clear_skies-2.0.9.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import inspect
|
|
4
|
-
from collections import OrderedDict
|
|
5
4
|
from typing import TYPE_CHECKING, Any, Callable
|
|
6
5
|
|
|
7
|
-
import
|
|
8
|
-
import clearskies.decorators
|
|
9
|
-
import clearskies.exceptions
|
|
10
|
-
from clearskies import authentication, autodoc, typing
|
|
6
|
+
from clearskies import configs, decorators
|
|
11
7
|
from clearskies.authentication import Authentication, Authorization, Public
|
|
12
|
-
from clearskies.endpoint import Endpoint
|
|
13
8
|
from clearskies.endpoint_group import EndpointGroup
|
|
14
9
|
from clearskies.endpoints.create import Create
|
|
15
10
|
from clearskies.endpoints.delete import Delete
|
|
16
11
|
from clearskies.endpoints.get import Get
|
|
17
12
|
from clearskies.endpoints.simple_search import SimpleSearch
|
|
18
13
|
from clearskies.endpoints.update import Update
|
|
19
|
-
from clearskies.functional import string
|
|
20
|
-
from clearskies.input_outputs import InputOutput
|
|
21
14
|
|
|
22
15
|
if TYPE_CHECKING:
|
|
23
|
-
from clearskies import SecurityHeader
|
|
24
|
-
from clearskies.model import Column, Model, Schema
|
|
16
|
+
from clearskies import Column, Endpoint, Model, Schema, SecurityHeader
|
|
25
17
|
|
|
26
18
|
|
|
27
19
|
class RestfulApi(EndpointGroup):
|
|
@@ -190,7 +182,7 @@ class RestfulApi(EndpointGroup):
|
|
|
190
182
|
This defaults to `clearskies.endpoints.Create`. To disable the create operation all together,
|
|
191
183
|
set this to None.
|
|
192
184
|
"""
|
|
193
|
-
create_endpoint =
|
|
185
|
+
create_endpoint = configs.Endpoint(default=Create)
|
|
194
186
|
|
|
195
187
|
"""
|
|
196
188
|
The endpoint class to use for managing the delete operation.
|
|
@@ -198,7 +190,7 @@ class RestfulApi(EndpointGroup):
|
|
|
198
190
|
This defaults to `clearskies.endpoints.Delete`. To disable the delete operation all together,
|
|
199
191
|
set this to None.
|
|
200
192
|
"""
|
|
201
|
-
delete_endpoint =
|
|
193
|
+
delete_endpoint = configs.Endpoint(default=Delete)
|
|
202
194
|
|
|
203
195
|
"""
|
|
204
196
|
The endpoint class to use for managing the update operation.
|
|
@@ -206,7 +198,7 @@ class RestfulApi(EndpointGroup):
|
|
|
206
198
|
This defaults to `clearskies.endpoints.Update`. To disable the update operation all together,
|
|
207
199
|
set this to None.
|
|
208
200
|
"""
|
|
209
|
-
update_endpoint =
|
|
201
|
+
update_endpoint = configs.Endpoint(default=Update)
|
|
210
202
|
|
|
211
203
|
"""
|
|
212
204
|
The endpoint class to use to fetch individual records.
|
|
@@ -214,7 +206,7 @@ class RestfulApi(EndpointGroup):
|
|
|
214
206
|
This defaults to `clearskies.endpoints.Get`. To disable the get operation all together,
|
|
215
207
|
set this to None.
|
|
216
208
|
"""
|
|
217
|
-
get_endpoint =
|
|
209
|
+
get_endpoint = configs.Endpoint(default=Get)
|
|
218
210
|
|
|
219
211
|
"""
|
|
220
212
|
The endpoint class to use to list records.
|
|
@@ -222,78 +214,76 @@ class RestfulApi(EndpointGroup):
|
|
|
222
214
|
This defaults to `clearskies.endpoints.SimpleSearch`. To disable the list operation all together,
|
|
223
215
|
set this to None.
|
|
224
216
|
"""
|
|
225
|
-
list_endpoint =
|
|
217
|
+
list_endpoint = configs.Endpoint(default=SimpleSearch)
|
|
226
218
|
|
|
227
219
|
"""
|
|
228
220
|
The request method(s) to use to route to the create operation. Default is ["POST"].
|
|
229
221
|
"""
|
|
230
|
-
create_request_methods =
|
|
222
|
+
create_request_methods = configs.SelectList(
|
|
231
223
|
allowed_values=["GET", "POST", "PUT", "DELETE", "PATCH"], default=["POST"]
|
|
232
224
|
)
|
|
233
225
|
|
|
234
226
|
"""
|
|
235
227
|
The request method(s) to use to route to the update operation. Default is ["PATCH"].
|
|
236
228
|
"""
|
|
237
|
-
update_request_methods =
|
|
229
|
+
update_request_methods = configs.SelectList(
|
|
238
230
|
allowed_values=["GET", "POST", "PUT", "DELETE", "PATCH"], default=["PATCH"]
|
|
239
231
|
)
|
|
240
232
|
|
|
241
233
|
"""
|
|
242
234
|
The request method(s) to use to route to the delete operation. Default is ["DELETE"].
|
|
243
235
|
"""
|
|
244
|
-
delete_request_methods =
|
|
236
|
+
delete_request_methods = configs.SelectList(
|
|
245
237
|
allowed_values=["GET", "POST", "PUT", "DELETE", "PATCH"], default=["DELETE"]
|
|
246
238
|
)
|
|
247
239
|
|
|
248
240
|
"""
|
|
249
241
|
The request method(s) to use to route to the get operation. Default is ["GET"].
|
|
250
242
|
"""
|
|
251
|
-
get_request_methods =
|
|
252
|
-
allowed_values=["GET", "POST", "PUT", "DELETE", "PATCH"], default=["GET"]
|
|
253
|
-
)
|
|
243
|
+
get_request_methods = configs.SelectList(allowed_values=["GET", "POST", "PUT", "DELETE", "PATCH"], default=["GET"])
|
|
254
244
|
|
|
255
245
|
"""
|
|
256
246
|
The request method(s) to use to route to the create operation. Default is ["GET"].
|
|
257
247
|
"""
|
|
258
|
-
list_request_methods =
|
|
248
|
+
list_request_methods = configs.SelectList(
|
|
259
249
|
allowed_values=["GET", "POST", "PUT", "DELETE", "PATCH", "QUERY"], default=["GET", "POST", "QUERY"]
|
|
260
250
|
)
|
|
261
251
|
|
|
262
252
|
"""
|
|
263
253
|
The request method(s) to use to route to the create operation. Default is ["POST"].
|
|
264
254
|
"""
|
|
265
|
-
id_column_name =
|
|
255
|
+
id_column_name = configs.ModelColumn("model_class", default=None)
|
|
266
256
|
|
|
267
257
|
"""
|
|
268
258
|
The base URL to be used for all the endpoints.
|
|
269
259
|
"""
|
|
270
|
-
url =
|
|
271
|
-
|
|
272
|
-
authentication =
|
|
273
|
-
authorization =
|
|
274
|
-
output_map =
|
|
275
|
-
output_schema =
|
|
276
|
-
model_class =
|
|
277
|
-
readable_column_names =
|
|
278
|
-
writeable_column_names =
|
|
279
|
-
searchable_column_names =
|
|
280
|
-
sortable_column_names =
|
|
281
|
-
default_sort_column_name =
|
|
282
|
-
default_sort_direction =
|
|
283
|
-
default_limit =
|
|
284
|
-
maximum_limit =
|
|
285
|
-
group_by_column_name =
|
|
286
|
-
input_validation_callable =
|
|
287
|
-
include_routing_data_in_request_data =
|
|
288
|
-
column_overrides =
|
|
289
|
-
internal_casing =
|
|
290
|
-
external_casing =
|
|
291
|
-
security_headers =
|
|
292
|
-
description =
|
|
293
|
-
where =
|
|
260
|
+
url = configs.String(default="")
|
|
261
|
+
|
|
262
|
+
authentication = configs.Authentication(default=Public())
|
|
263
|
+
authorization = configs.Authorization(default=Authorization())
|
|
264
|
+
output_map = configs.Callable(default=None)
|
|
265
|
+
output_schema = configs.Schema(default=None)
|
|
266
|
+
model_class = configs.ModelClass(default=None)
|
|
267
|
+
readable_column_names = configs.ReadableModelColumns("model_class", default=[])
|
|
268
|
+
writeable_column_names = configs.WriteableModelColumns("model_class", default=[])
|
|
269
|
+
searchable_column_names = configs.SearchableModelColumns("model_class", default=[])
|
|
270
|
+
sortable_column_names = configs.ReadableModelColumns("model_class", default=[])
|
|
271
|
+
default_sort_column_name = configs.ModelColumn("model_class", required=True)
|
|
272
|
+
default_sort_direction = configs.Select(["ASC", "DESC"], default="ASC")
|
|
273
|
+
default_limit = configs.Integer(default=50)
|
|
274
|
+
maximum_limit = configs.Integer(default=200)
|
|
275
|
+
group_by_column_name = configs.ModelColumn("model_class")
|
|
276
|
+
input_validation_callable = configs.Callable(default=None)
|
|
277
|
+
include_routing_data_in_request_data = configs.Boolean(default=False)
|
|
278
|
+
column_overrides = configs.Columns(default={})
|
|
279
|
+
internal_casing = configs.Select(["snake_case", "camelCase", "TitleCase"], default="snake_case")
|
|
280
|
+
external_casing = configs.Select(["snake_case", "camelCase", "TitleCase"], default="snake_case")
|
|
281
|
+
security_headers = configs.SecurityHeaders(default=[])
|
|
282
|
+
description = configs.String(default="")
|
|
283
|
+
where = configs.Conditions(default=[])
|
|
294
284
|
_descriptor_config_map = None
|
|
295
285
|
|
|
296
|
-
@
|
|
286
|
+
@decorators.parameters_to_properties
|
|
297
287
|
def __init__(
|
|
298
288
|
self,
|
|
299
289
|
model_class: type[Model],
|
|
@@ -303,11 +293,11 @@ class RestfulApi(EndpointGroup):
|
|
|
303
293
|
sortable_column_names: list[str],
|
|
304
294
|
default_sort_column_name: str,
|
|
305
295
|
read_only: bool = False,
|
|
306
|
-
create_endpoint: Endpoint | None = Create,
|
|
307
|
-
delete_endpoint: Endpoint | None = Delete,
|
|
308
|
-
update_endpoint: Endpoint | None = Update,
|
|
309
|
-
get_endpoint: Endpoint | None = Get,
|
|
310
|
-
list_endpoint: Endpoint | None = SimpleSearch,
|
|
296
|
+
create_endpoint: type[Endpoint] | None = Create,
|
|
297
|
+
delete_endpoint: type[Endpoint] | None = Delete,
|
|
298
|
+
update_endpoint: type[Endpoint] | None = Update,
|
|
299
|
+
get_endpoint: type[Endpoint] | None = Get,
|
|
300
|
+
list_endpoint: type[Endpoint] | None = SimpleSearch,
|
|
311
301
|
create_request_methods: list[str] = ["POST"],
|
|
312
302
|
update_request_methods: list[str] = ["PATCH"],
|
|
313
303
|
delete_request_methods: list[str] = ["DELETE"],
|
clearskies/endpoints/schema.py
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
from
|
|
6
|
-
|
|
7
|
-
import clearskies.autodoc
|
|
8
|
-
import clearskies.configs
|
|
9
|
-
import clearskies.exceptions
|
|
10
|
-
from clearskies import authentication, autodoc, typing
|
|
11
|
-
from clearskies.authentication import Authentication, Authorization
|
|
3
|
+
from typing import TYPE_CHECKING, Any, Callable
|
|
4
|
+
|
|
5
|
+
from clearskies import authentication, autodoc, configs, decorators
|
|
12
6
|
from clearskies.endpoint import Endpoint
|
|
13
|
-
from clearskies.input_outputs import InputOutput
|
|
14
7
|
|
|
15
8
|
if TYPE_CHECKING:
|
|
16
|
-
from clearskies import
|
|
17
|
-
from clearskies.
|
|
9
|
+
from clearskies import SecurityHeader
|
|
10
|
+
from clearskies.authentication import Authentication
|
|
11
|
+
from clearskies.input_outputs import InputOutput
|
|
18
12
|
|
|
19
13
|
|
|
20
14
|
class Schema(Endpoint):
|
|
21
15
|
"""
|
|
22
|
-
An endpoint that automatically creates a swagger doc for the application
|
|
16
|
+
An endpoint that automatically creates a swagger doc for the application.
|
|
23
17
|
|
|
24
18
|
The schema endpoint must always be attached to an endpoint group. It will document all endpoints
|
|
25
19
|
attached to its parent endpoint group.
|
|
@@ -74,11 +68,12 @@ class Schema(Endpoint):
|
|
|
74
68
|
sortable_column_names=readable_column_names,
|
|
75
69
|
searchable_column_names=readable_column_names,
|
|
76
70
|
default_sort_column_name="name",
|
|
77
|
-
)
|
|
71
|
+
),
|
|
78
72
|
],
|
|
79
73
|
url="/users",
|
|
80
74
|
)
|
|
81
75
|
|
|
76
|
+
|
|
82
77
|
class SomeThing(clearskies.Model):
|
|
83
78
|
id_column_name = "id"
|
|
84
79
|
backend = clearskies.backends.MemoryBackend()
|
|
@@ -87,6 +82,7 @@ class Schema(Endpoint):
|
|
|
87
82
|
thing_1 = clearskies.columns.String(validators=[Required()])
|
|
88
83
|
thing_2 = clearskies.columns.String(validators=[Unique()])
|
|
89
84
|
|
|
85
|
+
|
|
90
86
|
more_endpoints = clearskies.EndpointGroup(
|
|
91
87
|
[
|
|
92
88
|
clearskies.endpoints.HealthCheck(url="health"),
|
|
@@ -130,7 +126,7 @@ class Schema(Endpoint):
|
|
|
130
126
|
"""
|
|
131
127
|
The doc builder class/format to use
|
|
132
128
|
"""
|
|
133
|
-
schema_format =
|
|
129
|
+
schema_format = configs.Any(default=autodoc.formats.oai3_json.Oai3Json)
|
|
134
130
|
|
|
135
131
|
"""
|
|
136
132
|
Addiional data to inject into the schema doc.
|
|
@@ -138,13 +134,13 @@ class Schema(Endpoint):
|
|
|
138
134
|
This is typically used for setting info/server settings in the resultant swagger doc. Anything
|
|
139
135
|
in this dictionary is injected into the "root" of the generated documentation file.
|
|
140
136
|
"""
|
|
141
|
-
schema_configuration =
|
|
137
|
+
schema_configuration = configs.AnyDict(default={})
|
|
142
138
|
|
|
143
|
-
@
|
|
139
|
+
@decorators.parameters_to_properties
|
|
144
140
|
def __init__(
|
|
145
141
|
self,
|
|
146
142
|
url: str,
|
|
147
|
-
schema_format=
|
|
143
|
+
schema_format=autodoc.formats.oai3_json.Oai3Json,
|
|
148
144
|
request_methods: list[str] = ["GET"],
|
|
149
145
|
response_headers: list[str | Callable[..., list[str]]] = [],
|
|
150
146
|
security_headers: list[SecurityHeader] = [],
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import inspect
|
|
4
|
-
from collections import OrderedDict
|
|
5
3
|
from typing import TYPE_CHECKING, Any, Callable
|
|
6
4
|
|
|
7
|
-
import
|
|
8
|
-
import clearskies.exceptions
|
|
9
|
-
from clearskies import authentication, autodoc, typing
|
|
5
|
+
from clearskies import authentication, autodoc, decorators, exceptions
|
|
10
6
|
from clearskies.endpoints.list import List
|
|
11
|
-
from clearskies.functional import string
|
|
12
|
-
from clearskies.input_outputs import InputOutput
|
|
13
7
|
|
|
14
8
|
if TYPE_CHECKING:
|
|
15
|
-
from clearskies import Column, Schema, SecurityHeader
|
|
16
|
-
from clearskies.model import Model
|
|
9
|
+
from clearskies import Column, Model, Schema, SecurityHeader, typing
|
|
17
10
|
|
|
18
11
|
|
|
19
12
|
class SimpleSearch(List):
|
|
@@ -194,7 +187,7 @@ class SimpleSearch(List):
|
|
|
194
187
|
```
|
|
195
188
|
"""
|
|
196
189
|
|
|
197
|
-
@
|
|
190
|
+
@decorators.parameters_to_properties
|
|
198
191
|
def __init__(
|
|
199
192
|
self,
|
|
200
193
|
model_class: type[Model],
|
|
@@ -233,7 +226,7 @@ class SimpleSearch(List):
|
|
|
233
226
|
if column_name in self.allowed_request_keys and column_name not in self.searchable_column_names:
|
|
234
227
|
continue
|
|
235
228
|
if column_name not in self.searchable_column_names:
|
|
236
|
-
raise
|
|
229
|
+
raise exceptions.ClientError(
|
|
237
230
|
f"Invalid request parameter found in {input_source_label}: '{column_name}'"
|
|
238
231
|
)
|
|
239
232
|
[relationship_column_name, final_column_name] = self.unpack_column_name_with_relationship(column_name)
|
|
@@ -242,7 +235,7 @@ class SimpleSearch(List):
|
|
|
242
235
|
value, relationship_reference=final_column_name
|
|
243
236
|
)
|
|
244
237
|
if value_error:
|
|
245
|
-
raise
|
|
238
|
+
raise exceptions.InputErrors({column_name: value_error})
|
|
246
239
|
|
|
247
240
|
def configure_model_from_request_data(
|
|
248
241
|
self,
|
clearskies/endpoints/update.py
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
from collections import OrderedDict
|
|
5
|
-
from typing import TYPE_CHECKING, Any, Callable, Type
|
|
3
|
+
from typing import TYPE_CHECKING, Any, Callable
|
|
6
4
|
|
|
7
|
-
import
|
|
8
|
-
import clearskies.exceptions
|
|
9
|
-
from clearskies import authentication, autodoc, typing
|
|
5
|
+
from clearskies import authentication, autodoc, decorators, exceptions
|
|
10
6
|
from clearskies.endpoints.get import Get
|
|
11
|
-
from clearskies.functional import
|
|
7
|
+
from clearskies.functional import string
|
|
12
8
|
from clearskies.input_outputs import InputOutput
|
|
13
9
|
|
|
14
10
|
if TYPE_CHECKING:
|
|
15
|
-
from clearskies import SecurityHeader
|
|
16
|
-
from clearskies.model import Column, Model, Schema
|
|
11
|
+
from clearskies import Column, Model, Schema, SecurityHeader, typing
|
|
17
12
|
|
|
18
13
|
|
|
19
14
|
class Update(Get):
|
|
@@ -90,7 +85,7 @@ class Update(Get):
|
|
|
90
85
|
}
|
|
91
86
|
"""
|
|
92
87
|
|
|
93
|
-
@
|
|
88
|
+
@decorators.parameters_to_properties
|
|
94
89
|
def __init__(
|
|
95
90
|
self,
|
|
96
91
|
model_class: type[Model],
|
|
@@ -124,7 +119,7 @@ class Update(Get):
|
|
|
124
119
|
def handle(self, input_output: InputOutput) -> Any:
|
|
125
120
|
request_data = self.get_request_data(input_output)
|
|
126
121
|
if not request_data and input_output.has_body():
|
|
127
|
-
raise
|
|
122
|
+
raise exceptions.ClientError("Request body was not valid JSON")
|
|
128
123
|
model = self.fetch_model(input_output)
|
|
129
124
|
self.validate_input_against_schema(request_data, input_output, model)
|
|
130
125
|
model.save(request_data)
|
clearskies/environment.py
CHANGED
clearskies/input_outputs/cli.py
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import json
|
|
2
4
|
from abc import ABC, abstractmethod
|
|
3
|
-
from typing import Any
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
4
6
|
from urllib.parse import parse_qs
|
|
5
7
|
|
|
6
|
-
import
|
|
7
|
-
import clearskies.typing
|
|
8
|
-
from clearskies.configs import AnyDict, StringDict
|
|
9
|
-
from clearskies.exceptions import ClientError
|
|
8
|
+
from clearskies import configs, configurable, input_outputs
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from clearskies import typing
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
class InputOutput(ABC,
|
|
14
|
+
class InputOutput(ABC, configurable.Configurable):
|
|
15
15
|
"""Manage the request and response to the client."""
|
|
16
16
|
|
|
17
|
-
response_headers: Headers = None # type: ignore
|
|
18
|
-
request_headers: Headers = None # type: ignore
|
|
19
|
-
query_parameters =
|
|
20
|
-
routing_data =
|
|
21
|
-
authorization_data =
|
|
17
|
+
response_headers: input_outputs.Headers = None # type: ignore
|
|
18
|
+
request_headers: input_outputs.Headers = None # type: ignore
|
|
19
|
+
query_parameters = configs.AnyDict(default={})
|
|
20
|
+
routing_data = configs.StringDict(default={})
|
|
21
|
+
authorization_data = configs.AnyDict(default={})
|
|
22
22
|
|
|
23
23
|
_body_as_json: dict[str, Any] | list[Any] | None = {}
|
|
24
24
|
_body_loaded_as_json = False
|
|
25
25
|
|
|
26
26
|
def __init__(self):
|
|
27
|
-
self.response_headers = Headers()
|
|
28
|
-
self.request_headers = Headers(self.get_request_headers())
|
|
27
|
+
self.response_headers = input_outputs.Headers()
|
|
28
|
+
self.request_headers = input_outputs.Headers(self.get_request_headers())
|
|
29
29
|
self.query_parameters = {key: val[0] for (key, val) in parse_qs(self.get_query_string()).items()}
|
|
30
30
|
self.authorization_data = {}
|
|
31
31
|
self.routing_data = {}
|
|
32
32
|
self.finalize_and_validate_configuration()
|
|
33
33
|
|
|
34
34
|
@abstractmethod
|
|
35
|
-
def respond(self, body:
|
|
35
|
+
def respond(self, body: typing.response, status_code: int = 200) -> Any:
|
|
36
36
|
"""
|
|
37
37
|
Pass along a response to the client.
|
|
38
38
|
|