clear-skies 2.0.0__py3-none-any.whl → 2.0.2__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.0.dist-info → clear_skies-2.0.2.dist-info}/METADATA +2 -2
- {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/RECORD +78 -77
- clearskies/__init__.py +5 -8
- clearskies/authentication/authentication.py +4 -0
- clearskies/authentication/authorization.py +4 -0
- clearskies/authentication/jwks.py +8 -3
- clearskies/authentication/secret_bearer.py +3 -3
- clearskies/backends/api_backend.py +2 -2
- clearskies/backends/backend.py +13 -0
- clearskies/backends/secrets_backend.py +0 -1
- clearskies/column.py +9 -8
- clearskies/columns/audit.py +3 -2
- clearskies/columns/belongs_to_id.py +2 -2
- clearskies/columns/belongs_to_model.py +6 -2
- clearskies/columns/belongs_to_self.py +2 -2
- clearskies/columns/boolean.py +6 -2
- clearskies/columns/category_tree.py +2 -2
- clearskies/columns/category_tree_children.py +2 -2
- clearskies/columns/created.py +3 -2
- clearskies/columns/created_by_authorization_data.py +2 -2
- clearskies/columns/created_by_header.py +2 -2
- clearskies/columns/created_by_ip.py +2 -2
- clearskies/columns/created_by_routing_data.py +3 -2
- clearskies/columns/created_by_user_agent.py +2 -2
- clearskies/columns/date.py +6 -2
- clearskies/columns/datetime.py +6 -2
- clearskies/columns/float.py +6 -2
- clearskies/columns/has_many.py +2 -2
- clearskies/columns/has_many_self.py +2 -2
- clearskies/columns/integer.py +6 -2
- clearskies/columns/json.py +6 -2
- clearskies/columns/many_to_many_ids.py +6 -2
- clearskies/columns/many_to_many_ids_with_data.py +6 -2
- clearskies/columns/many_to_many_models.py +6 -2
- clearskies/columns/many_to_many_pivots.py +3 -2
- clearskies/columns/phone.py +3 -2
- clearskies/columns/select.py +3 -2
- clearskies/columns/string.py +4 -0
- clearskies/columns/timestamp.py +6 -2
- clearskies/columns/updated.py +2 -2
- clearskies/columns/uuid.py +2 -2
- clearskies/configs/__init__.py +4 -1
- clearskies/configs/config.py +4 -1
- clearskies/configs/endpoint_list.py +28 -0
- clearskies/contexts/cli.py +4 -0
- clearskies/contexts/context.py +13 -0
- clearskies/contexts/wsgi.py +4 -0
- clearskies/contexts/wsgi_ref.py +4 -0
- clearskies/{parameters_to_properties.py → decorators.py} +2 -0
- clearskies/di/di.py +2 -2
- clearskies/di/injectable_properties.py +2 -2
- clearskies/endpoint.py +7 -6
- clearskies/endpoint_group.py +14 -1
- clearskies/endpoints/callable.py +5 -4
- clearskies/endpoints/create.py +1 -1
- clearskies/endpoints/delete.py +1 -1
- clearskies/endpoints/get.py +1 -1
- clearskies/endpoints/health_check.py +1 -1
- clearskies/endpoints/list.py +1 -1
- clearskies/endpoints/restful_api.py +2 -2
- clearskies/endpoints/simple_search.py +1 -1
- clearskies/endpoints/update.py +1 -1
- clearskies/model.py +1214 -64
- clearskies/query/query.py +4 -4
- clearskies/security_header.py +7 -0
- clearskies/security_headers/cache_control.py +2 -2
- clearskies/security_headers/cors.py +2 -2
- clearskies/security_headers/csp.py +2 -2
- clearskies/security_headers/hsts.py +2 -2
- clearskies/validator.py +12 -0
- clearskies/validators/after_column.py +2 -2
- clearskies/validators/in_the_future.py +1 -1
- clearskies/validators/in_the_past.py +1 -1
- clearskies/validators/required.py +0 -1
- clearskies/validators/timedelta.py +2 -2
- clearskies/validators/unique.py +0 -1
- {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/LICENSE +0 -0
- {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/WHEEL +0 -0
clearskies/di/di.py
CHANGED
|
@@ -23,7 +23,7 @@ class Di:
|
|
|
23
23
|
Build a dependency injection object.
|
|
24
24
|
|
|
25
25
|
The dependency injection (DI) container is a key part of clearskies, so understanding how to both configure
|
|
26
|
-
them and get dependencies for your classes is important. Note however that
|
|
26
|
+
them and get dependencies for your classes is important. Note however that you don't often have
|
|
27
27
|
to interact with the dependency injection container directly. All of the configuration options for
|
|
28
28
|
the DI container are also available to all the contexts, which is typically how you will build clearskies
|
|
29
29
|
applications. So, while you can create a DI container and use it directly, typically you'll just follow
|
|
@@ -648,7 +648,7 @@ class Di:
|
|
|
648
648
|
its name and type-hint.
|
|
649
649
|
"""
|
|
650
650
|
built_value = self.build_class_from_type_hint(argument_name, type_hint, context=context, cache=True)
|
|
651
|
-
if built_value:
|
|
651
|
+
if built_value is not None:
|
|
652
652
|
return built_value
|
|
653
653
|
return self.build_from_name(argument_name, context=context, cache=True)
|
|
654
654
|
|
|
@@ -44,7 +44,7 @@ class InjectableProperties:
|
|
|
44
44
|
```python
|
|
45
45
|
import clearskies
|
|
46
46
|
import time
|
|
47
|
-
|
|
47
|
+
import clearskies.decorators
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
class MyOtherThing(clearskies.di.InjectableProperties):
|
|
@@ -56,7 +56,7 @@ class InjectableProperties:
|
|
|
56
56
|
some_number = clearskies.di.inject.ByName("some_number")
|
|
57
57
|
my_other_thing = clearskies.di.inject.ByClass(MyOtherThing)
|
|
58
58
|
|
|
59
|
-
@parameters_to_properties
|
|
59
|
+
@clearskies.decorators.parameters_to_properties
|
|
60
60
|
def __init__(self, my_int: int):
|
|
61
61
|
self.finalize_and_validate_configuration()
|
|
62
62
|
|
clearskies/endpoint.py
CHANGED
|
@@ -8,9 +8,9 @@ from typing import TYPE_CHECKING, Any, Callable
|
|
|
8
8
|
import clearskies.column
|
|
9
9
|
import clearskies.configs
|
|
10
10
|
import clearskies.configurable
|
|
11
|
+
import clearskies.decorators
|
|
11
12
|
import clearskies.di
|
|
12
13
|
import clearskies.end
|
|
13
|
-
import clearskies.parameters_to_properties
|
|
14
14
|
import clearskies.typing
|
|
15
15
|
from clearskies import autodoc, exceptions
|
|
16
16
|
from clearskies.authentication import Authentication, Authorization, Public
|
|
@@ -32,15 +32,16 @@ class Endpoint(
|
|
|
32
32
|
clearskies.di.InjectableProperties,
|
|
33
33
|
):
|
|
34
34
|
"""
|
|
35
|
-
|
|
35
|
+
Automating drudgery!
|
|
36
36
|
|
|
37
37
|
With clearskies, endpoints exist to offload some drudgery and make your life easier, but they can also
|
|
38
38
|
get out of your way when you don't need them. Think of them as pre-built endpoints that can execute
|
|
39
39
|
common functionality needed for web applications/APIs. Instead of defining a function that fetches
|
|
40
40
|
records from your backend and returns them to the end user, you can let the list endpoint do this for you
|
|
41
41
|
with a minimal amount of configuration. Instead of making an endpoint that creates records, just deploy
|
|
42
|
-
a create endpoint.
|
|
43
|
-
|
|
42
|
+
a create endpoint. While this gives clearskies some helpful capabiltiies for automation, it also has
|
|
43
|
+
the Callable endpoint which simply calls a developer-defined function, and therefore allows clearskies to
|
|
44
|
+
act like a much more typical framework.
|
|
44
45
|
"""
|
|
45
46
|
|
|
46
47
|
"""
|
|
@@ -342,7 +343,7 @@ class Endpoint(
|
|
|
342
343
|
"""
|
|
343
344
|
The model class used by this endpoint.
|
|
344
345
|
|
|
345
|
-
The
|
|
346
|
+
The endpoint will use this to fetch/save/validate incoming data as needed.
|
|
346
347
|
"""
|
|
347
348
|
model_class = clearskies.configs.ModelClass(default=None)
|
|
348
349
|
|
|
@@ -878,7 +879,7 @@ class Endpoint(
|
|
|
878
879
|
_sortable_columns: dict[str, clearskies.column.Column] = None # type: ignore
|
|
879
880
|
_as_json_map: dict[str, clearskies.column.Column] = None # type: ignore
|
|
880
881
|
|
|
881
|
-
@clearskies.
|
|
882
|
+
@clearskies.decorators.parameters_to_properties
|
|
882
883
|
def __init__(
|
|
883
884
|
self,
|
|
884
885
|
url: str = "",
|
clearskies/endpoint_group.py
CHANGED
|
@@ -217,16 +217,29 @@ class EndpointGroup(
|
|
|
217
217
|
The dependency injection container
|
|
218
218
|
"""
|
|
219
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
|
+
"""
|
|
220
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
|
+
|
|
221
233
|
response_headers = clearskies.configs.StringListOrCallable(default=[])
|
|
222
234
|
authentication = clearskies.configs.Authentication(default=Public())
|
|
223
235
|
authorization = clearskies.configs.Authorization(default=Authorization())
|
|
224
236
|
security_headers = clearskies.configs.SecurityHeaders(default=[])
|
|
237
|
+
|
|
225
238
|
cors_header: SecurityHeader = None # type: ignore
|
|
226
239
|
has_cors: bool = False
|
|
227
240
|
endpoints_initialized = False
|
|
228
241
|
|
|
229
|
-
@clearskies.
|
|
242
|
+
@clearskies.decorators.parameters_to_properties
|
|
230
243
|
def __init__(
|
|
231
244
|
self,
|
|
232
245
|
endpoints: list[Endpoint | Self],
|
clearskies/endpoints/callable.py
CHANGED
|
@@ -23,13 +23,13 @@ class Callable(Endpoint):
|
|
|
23
23
|
"""
|
|
24
24
|
An endpoint that executes a user-defined function.
|
|
25
25
|
|
|
26
|
-
The Callable endpoint does exactly that - you provide a function that will be called when the
|
|
27
|
-
all callables invoked by clearskies, you can request any defined
|
|
26
|
+
The Callable endpoint does exactly that - you provide a function that will be called when the endpoint is invoked. Like
|
|
27
|
+
all callables invoked by clearskies, you can request any defined dependency that can be provided by the clearskies
|
|
28
28
|
framework.
|
|
29
29
|
|
|
30
30
|
Whatever you return will be returned to the client. By default, the return value is sent along in the `data` parameter
|
|
31
31
|
of the standard clearskies response. To suppress this behavior, set `return_standard_response` to `False`. You can also
|
|
32
|
-
return
|
|
32
|
+
return a model instance, a model query, or a list of model instances and the callable endpoint will automatically return
|
|
33
33
|
the columns specified in `readable_column_names` to the client.
|
|
34
34
|
|
|
35
35
|
Here's a basic working example:
|
|
@@ -239,7 +239,7 @@ class Callable(Endpoint):
|
|
|
239
239
|
"""
|
|
240
240
|
return_records = clearskies.configs.Boolean(default=False)
|
|
241
241
|
|
|
242
|
-
@clearskies.
|
|
242
|
+
@clearskies.decorators.parameters_to_properties
|
|
243
243
|
def __init__(
|
|
244
244
|
self,
|
|
245
245
|
to_call: CallableType,
|
|
@@ -300,6 +300,7 @@ class Callable(Endpoint):
|
|
|
300
300
|
converted_models,
|
|
301
301
|
number_results=len(response) if response.backend.can_count else None,
|
|
302
302
|
next_page=response.next_page_data(),
|
|
303
|
+
limit=response.get_query().limit,
|
|
303
304
|
)
|
|
304
305
|
|
|
305
306
|
# or did they return a list of models?
|
clearskies/endpoints/create.py
CHANGED
|
@@ -102,7 +102,7 @@ class Create(Endpoint):
|
|
|
102
102
|
5. We provided an extra column (`not_a_column`) that wasn't in the list of allowed columns.
|
|
103
103
|
"""
|
|
104
104
|
|
|
105
|
-
@clearskies.
|
|
105
|
+
@clearskies.decorators.parameters_to_properties
|
|
106
106
|
def __init__(
|
|
107
107
|
self,
|
|
108
108
|
model_class: type[Model],
|
clearskies/endpoints/delete.py
CHANGED
clearskies/endpoints/get.py
CHANGED
|
@@ -159,7 +159,7 @@ class Get(Endpoint):
|
|
|
159
159
|
"""
|
|
160
160
|
record_lookup_column_name = clearskies.configs.ReadableModelColumn("model_class", default=None)
|
|
161
161
|
|
|
162
|
-
@clearskies.
|
|
162
|
+
@clearskies.decorators.parameters_to_properties
|
|
163
163
|
def __init__(
|
|
164
164
|
self,
|
|
165
165
|
model_class: type[Model],
|
|
@@ -130,7 +130,7 @@ class HealthCheck(Endpoint):
|
|
|
130
130
|
"""
|
|
131
131
|
callables = clearskies.configs.Any(default=[])
|
|
132
132
|
|
|
133
|
-
@clearskies.
|
|
133
|
+
@clearskies.decorators.parameters_to_properties
|
|
134
134
|
def __init__(
|
|
135
135
|
self,
|
|
136
136
|
dependency_injection_names: list[str] = [],
|
clearskies/endpoints/list.py
CHANGED
|
@@ -182,7 +182,7 @@ class List(Endpoint):
|
|
|
182
182
|
"model_class", allow_relationship_references=True
|
|
183
183
|
)
|
|
184
184
|
|
|
185
|
-
@clearskies.
|
|
185
|
+
@clearskies.decorators.parameters_to_properties
|
|
186
186
|
def __init__(
|
|
187
187
|
self,
|
|
188
188
|
model_class: type[Model],
|
|
@@ -5,8 +5,8 @@ from collections import OrderedDict
|
|
|
5
5
|
from typing import TYPE_CHECKING, Any, Callable
|
|
6
6
|
|
|
7
7
|
import clearskies.configs
|
|
8
|
+
import clearskies.decorators
|
|
8
9
|
import clearskies.exceptions
|
|
9
|
-
import clearskies.parameters_to_properties
|
|
10
10
|
from clearskies import authentication, autodoc, typing
|
|
11
11
|
from clearskies.authentication import Authentication, Authorization, Public
|
|
12
12
|
from clearskies.endpoint import Endpoint
|
|
@@ -293,7 +293,7 @@ class RestfulApi(EndpointGroup):
|
|
|
293
293
|
where = clearskies.configs.Conditions(default=[])
|
|
294
294
|
_descriptor_config_map = None
|
|
295
295
|
|
|
296
|
-
@clearskies.
|
|
296
|
+
@clearskies.decorators.parameters_to_properties
|
|
297
297
|
def __init__(
|
|
298
298
|
self,
|
|
299
299
|
model_class: type[Model],
|