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.
- clear_skies-2.0.5.dist-info/METADATA +74 -0
- clear_skies-2.0.5.dist-info/RECORD +4 -0
- {clear_skies-2.0.3.dist-info → clear_skies-2.0.5.dist-info}/WHEEL +1 -1
- clear_skies-2.0.3.dist-info/METADATA +0 -46
- clear_skies-2.0.3.dist-info/RECORD +0 -249
- clearskies/__init__.py +0 -59
- clearskies/action.py +0 -7
- clearskies/authentication/__init__.py +0 -15
- clearskies/authentication/authentication.py +0 -46
- clearskies/authentication/authorization.py +0 -16
- clearskies/authentication/authorization_pass_through.py +0 -20
- clearskies/authentication/jwks.py +0 -163
- clearskies/authentication/public.py +0 -5
- clearskies/authentication/secret_bearer.py +0 -553
- clearskies/autodoc/__init__.py +0 -8
- clearskies/autodoc/formats/__init__.py +0 -5
- clearskies/autodoc/formats/oai3_json/__init__.py +0 -7
- clearskies/autodoc/formats/oai3_json/oai3_json.py +0 -87
- clearskies/autodoc/formats/oai3_json/oai3_schema_resolver.py +0 -15
- clearskies/autodoc/formats/oai3_json/parameter.py +0 -35
- clearskies/autodoc/formats/oai3_json/request.py +0 -68
- clearskies/autodoc/formats/oai3_json/response.py +0 -28
- clearskies/autodoc/formats/oai3_json/schema/__init__.py +0 -11
- clearskies/autodoc/formats/oai3_json/schema/array.py +0 -9
- clearskies/autodoc/formats/oai3_json/schema/default.py +0 -13
- clearskies/autodoc/formats/oai3_json/schema/enum.py +0 -7
- clearskies/autodoc/formats/oai3_json/schema/object.py +0 -29
- clearskies/autodoc/formats/oai3_json/test.json +0 -1985
- clearskies/autodoc/py.typed +0 -0
- clearskies/autodoc/request/__init__.py +0 -15
- clearskies/autodoc/request/header.py +0 -6
- clearskies/autodoc/request/json_body.py +0 -6
- clearskies/autodoc/request/parameter.py +0 -8
- clearskies/autodoc/request/request.py +0 -38
- clearskies/autodoc/request/url_parameter.py +0 -6
- clearskies/autodoc/request/url_path.py +0 -6
- clearskies/autodoc/response/__init__.py +0 -5
- clearskies/autodoc/response/response.py +0 -9
- clearskies/autodoc/schema/__init__.py +0 -31
- clearskies/autodoc/schema/array.py +0 -10
- clearskies/autodoc/schema/base64.py +0 -8
- clearskies/autodoc/schema/boolean.py +0 -5
- clearskies/autodoc/schema/date.py +0 -5
- clearskies/autodoc/schema/datetime.py +0 -5
- clearskies/autodoc/schema/double.py +0 -5
- clearskies/autodoc/schema/enum.py +0 -17
- clearskies/autodoc/schema/integer.py +0 -6
- clearskies/autodoc/schema/long.py +0 -5
- clearskies/autodoc/schema/number.py +0 -6
- clearskies/autodoc/schema/object.py +0 -13
- clearskies/autodoc/schema/password.py +0 -5
- clearskies/autodoc/schema/schema.py +0 -11
- clearskies/autodoc/schema/string.py +0 -5
- clearskies/backends/__init__.py +0 -65
- clearskies/backends/api_backend.py +0 -1178
- clearskies/backends/backend.py +0 -136
- clearskies/backends/cursor_backend.py +0 -335
- clearskies/backends/memory_backend.py +0 -797
- clearskies/backends/secrets_backend.py +0 -106
- clearskies/column.py +0 -1233
- clearskies/columns/__init__.py +0 -71
- clearskies/columns/audit.py +0 -206
- clearskies/columns/belongs_to_id.py +0 -483
- clearskies/columns/belongs_to_model.py +0 -132
- clearskies/columns/belongs_to_self.py +0 -105
- clearskies/columns/boolean.py +0 -113
- clearskies/columns/category_tree.py +0 -275
- clearskies/columns/category_tree_ancestors.py +0 -51
- clearskies/columns/category_tree_children.py +0 -127
- clearskies/columns/category_tree_descendants.py +0 -48
- clearskies/columns/created.py +0 -95
- clearskies/columns/created_by_authorization_data.py +0 -116
- clearskies/columns/created_by_header.py +0 -99
- clearskies/columns/created_by_ip.py +0 -92
- clearskies/columns/created_by_routing_data.py +0 -97
- clearskies/columns/created_by_user_agent.py +0 -92
- clearskies/columns/date.py +0 -234
- clearskies/columns/datetime.py +0 -282
- clearskies/columns/email.py +0 -76
- clearskies/columns/float.py +0 -153
- clearskies/columns/has_many.py +0 -505
- clearskies/columns/has_many_self.py +0 -56
- clearskies/columns/has_one.py +0 -14
- clearskies/columns/integer.py +0 -160
- clearskies/columns/json.py +0 -126
- clearskies/columns/many_to_many_ids.py +0 -337
- clearskies/columns/many_to_many_ids_with_data.py +0 -274
- clearskies/columns/many_to_many_models.py +0 -158
- clearskies/columns/many_to_many_pivots.py +0 -134
- clearskies/columns/phone.py +0 -159
- clearskies/columns/select.py +0 -92
- clearskies/columns/string.py +0 -102
- clearskies/columns/timestamp.py +0 -164
- clearskies/columns/updated.py +0 -110
- clearskies/columns/uuid.py +0 -86
- clearskies/configs/README.md +0 -105
- clearskies/configs/__init__.py +0 -162
- clearskies/configs/actions.py +0 -43
- clearskies/configs/any.py +0 -13
- clearskies/configs/any_dict.py +0 -22
- clearskies/configs/any_dict_or_callable.py +0 -23
- clearskies/configs/authentication.py +0 -23
- clearskies/configs/authorization.py +0 -23
- clearskies/configs/boolean.py +0 -16
- clearskies/configs/boolean_or_callable.py +0 -18
- clearskies/configs/callable_config.py +0 -18
- clearskies/configs/columns.py +0 -34
- clearskies/configs/conditions.py +0 -30
- clearskies/configs/config.py +0 -24
- clearskies/configs/datetime.py +0 -18
- clearskies/configs/datetime_or_callable.py +0 -19
- clearskies/configs/endpoint.py +0 -23
- clearskies/configs/endpoint_list.py +0 -28
- clearskies/configs/float.py +0 -16
- clearskies/configs/float_or_callable.py +0 -18
- clearskies/configs/integer.py +0 -16
- clearskies/configs/integer_or_callable.py +0 -18
- clearskies/configs/joins.py +0 -30
- clearskies/configs/list_any_dict.py +0 -30
- clearskies/configs/list_any_dict_or_callable.py +0 -31
- clearskies/configs/model_class.py +0 -35
- clearskies/configs/model_column.py +0 -65
- clearskies/configs/model_columns.py +0 -56
- clearskies/configs/model_destination_name.py +0 -25
- clearskies/configs/model_to_id_column.py +0 -43
- clearskies/configs/readable_model_column.py +0 -9
- clearskies/configs/readable_model_columns.py +0 -9
- clearskies/configs/schema.py +0 -23
- clearskies/configs/searchable_model_columns.py +0 -9
- clearskies/configs/security_headers.py +0 -39
- clearskies/configs/select.py +0 -26
- clearskies/configs/select_list.py +0 -47
- clearskies/configs/string.py +0 -29
- clearskies/configs/string_dict.py +0 -32
- clearskies/configs/string_list.py +0 -32
- clearskies/configs/string_list_or_callable.py +0 -35
- clearskies/configs/string_or_callable.py +0 -18
- clearskies/configs/timedelta.py +0 -18
- clearskies/configs/timezone.py +0 -18
- clearskies/configs/url.py +0 -23
- clearskies/configs/validators.py +0 -45
- clearskies/configs/writeable_model_column.py +0 -9
- clearskies/configs/writeable_model_columns.py +0 -9
- clearskies/configurable.py +0 -76
- clearskies/contexts/__init__.py +0 -11
- clearskies/contexts/cli.py +0 -117
- clearskies/contexts/context.py +0 -98
- clearskies/contexts/wsgi.py +0 -76
- clearskies/contexts/wsgi_ref.py +0 -82
- clearskies/decorators.py +0 -33
- clearskies/di/__init__.py +0 -14
- clearskies/di/additional_config.py +0 -130
- clearskies/di/additional_config_auto_import.py +0 -17
- clearskies/di/di.py +0 -968
- clearskies/di/inject/__init__.py +0 -23
- clearskies/di/inject/by_class.py +0 -21
- clearskies/di/inject/by_name.py +0 -18
- clearskies/di/inject/di.py +0 -13
- clearskies/di/inject/environment.py +0 -14
- clearskies/di/inject/input_output.py +0 -20
- clearskies/di/inject/now.py +0 -13
- clearskies/di/inject/requests.py +0 -13
- clearskies/di/inject/secrets.py +0 -14
- clearskies/di/inject/utcnow.py +0 -13
- clearskies/di/inject/uuid.py +0 -15
- clearskies/di/injectable.py +0 -29
- clearskies/di/injectable_properties.py +0 -131
- clearskies/di/test_module/__init__.py +0 -6
- clearskies/di/test_module/another_module/__init__.py +0 -2
- clearskies/di/test_module/module_class.py +0 -5
- clearskies/end.py +0 -183
- clearskies/endpoint.py +0 -1310
- clearskies/endpoint_group.py +0 -310
- clearskies/endpoints/__init__.py +0 -23
- clearskies/endpoints/advanced_search.py +0 -526
- clearskies/endpoints/callable.py +0 -388
- clearskies/endpoints/create.py +0 -202
- clearskies/endpoints/delete.py +0 -139
- clearskies/endpoints/get.py +0 -275
- clearskies/endpoints/health_check.py +0 -181
- clearskies/endpoints/list.py +0 -573
- clearskies/endpoints/restful_api.py +0 -427
- clearskies/endpoints/simple_search.py +0 -286
- clearskies/endpoints/update.py +0 -190
- clearskies/environment.py +0 -104
- clearskies/exceptions/__init__.py +0 -17
- clearskies/exceptions/authentication.py +0 -2
- clearskies/exceptions/authorization.py +0 -2
- clearskies/exceptions/client_error.py +0 -2
- clearskies/exceptions/input_errors.py +0 -4
- clearskies/exceptions/moved_permanently.py +0 -3
- clearskies/exceptions/moved_temporarily.py +0 -3
- clearskies/exceptions/not_found.py +0 -2
- clearskies/functional/__init__.py +0 -7
- clearskies/functional/routing.py +0 -92
- clearskies/functional/string.py +0 -112
- clearskies/functional/validations.py +0 -76
- clearskies/input_outputs/__init__.py +0 -13
- clearskies/input_outputs/cli.py +0 -171
- clearskies/input_outputs/exceptions/__init__.py +0 -2
- clearskies/input_outputs/exceptions/cli_input_error.py +0 -2
- clearskies/input_outputs/exceptions/cli_not_found.py +0 -2
- clearskies/input_outputs/headers.py +0 -45
- clearskies/input_outputs/input_output.py +0 -138
- clearskies/input_outputs/programmatic.py +0 -69
- clearskies/input_outputs/py.typed +0 -0
- clearskies/input_outputs/wsgi.py +0 -77
- clearskies/model.py +0 -1922
- clearskies/py.typed +0 -0
- clearskies/query/__init__.py +0 -12
- clearskies/query/condition.py +0 -223
- clearskies/query/join.py +0 -136
- clearskies/query/query.py +0 -196
- clearskies/query/sort.py +0 -27
- clearskies/schema.py +0 -82
- clearskies/secrets/__init__.py +0 -6
- clearskies/secrets/additional_configs/__init__.py +0 -32
- clearskies/secrets/additional_configs/mysql_connection_dynamic_producer.py +0 -61
- clearskies/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssh_cert_bastion.py +0 -160
- clearskies/secrets/akeyless.py +0 -182
- clearskies/secrets/exceptions/__init__.py +0 -1
- clearskies/secrets/exceptions/not_found.py +0 -2
- clearskies/secrets/secrets.py +0 -38
- clearskies/security_header.py +0 -15
- clearskies/security_headers/__init__.py +0 -11
- clearskies/security_headers/cache_control.py +0 -67
- clearskies/security_headers/cors.py +0 -50
- clearskies/security_headers/csp.py +0 -94
- clearskies/security_headers/hsts.py +0 -22
- clearskies/security_headers/x_content_type_options.py +0 -0
- clearskies/security_headers/x_frame_options.py +0 -0
- clearskies/test_base.py +0 -8
- clearskies/typing.py +0 -11
- clearskies/validator.py +0 -37
- clearskies/validators/__init__.py +0 -33
- clearskies/validators/after_column.py +0 -62
- clearskies/validators/before_column.py +0 -13
- clearskies/validators/in_the_future.py +0 -32
- clearskies/validators/in_the_future_at_least.py +0 -11
- clearskies/validators/in_the_future_at_most.py +0 -10
- clearskies/validators/in_the_past.py +0 -32
- clearskies/validators/in_the_past_at_least.py +0 -10
- clearskies/validators/in_the_past_at_most.py +0 -10
- clearskies/validators/maximum_length.py +0 -26
- clearskies/validators/maximum_value.py +0 -29
- clearskies/validators/minimum_length.py +0 -26
- clearskies/validators/minimum_value.py +0 -29
- clearskies/validators/required.py +0 -34
- clearskies/validators/timedelta.py +0 -59
- clearskies/validators/unique.py +0 -30
- {clear_skies-2.0.3.dist-info → clear_skies-2.0.5.dist-info/licenses}/LICENSE +0 -0
|
@@ -1,427 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import inspect
|
|
4
|
-
from collections import OrderedDict
|
|
5
|
-
from typing import TYPE_CHECKING, Any, Callable
|
|
6
|
-
|
|
7
|
-
import clearskies.configs
|
|
8
|
-
import clearskies.decorators
|
|
9
|
-
import clearskies.exceptions
|
|
10
|
-
from clearskies import authentication, autodoc, typing
|
|
11
|
-
from clearskies.authentication import Authentication, Authorization, Public
|
|
12
|
-
from clearskies.endpoint import Endpoint
|
|
13
|
-
from clearskies.endpoint_group import EndpointGroup
|
|
14
|
-
from clearskies.endpoints.create import Create
|
|
15
|
-
from clearskies.endpoints.delete import Delete
|
|
16
|
-
from clearskies.endpoints.get import Get
|
|
17
|
-
from clearskies.endpoints.simple_search import SimpleSearch
|
|
18
|
-
from clearskies.endpoints.update import Update
|
|
19
|
-
from clearskies.functional import string
|
|
20
|
-
from clearskies.input_outputs import InputOutput
|
|
21
|
-
|
|
22
|
-
if TYPE_CHECKING:
|
|
23
|
-
from clearskies import SecurityHeader
|
|
24
|
-
from clearskies.model import Column, Model, Schema
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class RestfulApi(EndpointGroup):
|
|
28
|
-
"""
|
|
29
|
-
Full CRUD operations for a model.
|
|
30
|
-
|
|
31
|
-
This endpoint group sets up all five standard endpoints to manage a model:
|
|
32
|
-
|
|
33
|
-
1. Create
|
|
34
|
-
2. Update
|
|
35
|
-
3. Delete
|
|
36
|
-
4. Get
|
|
37
|
-
5. List
|
|
38
|
-
|
|
39
|
-
As such, you can set any option for all of the above endpoints. All five endpoints are enabled by default
|
|
40
|
-
but can be turned off individually. It's important to understand that the actual API behavior is controlled
|
|
41
|
-
by other endoints. This endpoint group creates them and routes requests to them. So, to fully understand
|
|
42
|
-
the behavior of the subsequent Restful API, you have to consult the documentation for the endpoints themselves.
|
|
43
|
-
|
|
44
|
-
For routing purposes, the create and list endpoints are reachable via the URL specified for this endpoint group
|
|
45
|
-
and are separated by request method (POST for create by default, GET for list). The update, delete, and get
|
|
46
|
-
endoints all expect the id to be appended to the base URL, and then are separated by request method
|
|
47
|
-
(PATCH for update, DELETE for delete, and GET for get). See the example app and calls below:
|
|
48
|
-
|
|
49
|
-
```python
|
|
50
|
-
import clearskies
|
|
51
|
-
from clearskies.validators import Required, Unique
|
|
52
|
-
from clearskies import columns
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
class User(clearskies.Model):
|
|
56
|
-
id_column_name = "id"
|
|
57
|
-
backend = clearskies.backends.MemoryBackend()
|
|
58
|
-
|
|
59
|
-
id = columns.Uuid()
|
|
60
|
-
name = columns.String(validators=[Required()])
|
|
61
|
-
username = columns.String(
|
|
62
|
-
validators=[
|
|
63
|
-
Required(),
|
|
64
|
-
Unique(),
|
|
65
|
-
]
|
|
66
|
-
)
|
|
67
|
-
age = columns.Integer(validators=[Required()])
|
|
68
|
-
created_at = columns.Created()
|
|
69
|
-
updated_at = columns.Updated()
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
wsgi = clearskies.contexts.WsgiRef(
|
|
73
|
-
clearskies.endpoints.RestfulApi(
|
|
74
|
-
url="users",
|
|
75
|
-
model_class=User,
|
|
76
|
-
readable_column_names=["id", "name", "username", "age", "created_at", "updated_at"],
|
|
77
|
-
writeable_column_names=["name", "username", "age"],
|
|
78
|
-
sortable_column_names=["id", "name", "username", "age", "created_at", "updated_at"],
|
|
79
|
-
searchable_column_names=["id", "name", "username", "age", "created_at", "updated_at"],
|
|
80
|
-
default_sort_column_name="name",
|
|
81
|
-
)
|
|
82
|
-
)
|
|
83
|
-
wsgi()
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Which spins up a fully functional API. In the below usage examples we create two users, fetch
|
|
87
|
-
one of them, update a user, delete the other, and then list all users.
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
$ curl 'http://localhost:8080/users' -d '{"name":"Bob", "username": "bob", "age": 25}' | jq
|
|
91
|
-
{
|
|
92
|
-
"status": "success",
|
|
93
|
-
"error": "",
|
|
94
|
-
"data": {
|
|
95
|
-
"id": "8bd9c03f-bb0c-41bd-afbc-f9526ded88f4",
|
|
96
|
-
"name": "Bob",
|
|
97
|
-
"username": "bob",
|
|
98
|
-
"age": 25,
|
|
99
|
-
"created_at": "2025-06-10T12:39:35+00:00",
|
|
100
|
-
"updated_at": "2025-06-10T12:39:35+00:00"
|
|
101
|
-
},
|
|
102
|
-
"pagination": {},
|
|
103
|
-
"input_errors": {}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
$ curl 'http://localhost:8080/users' -d '{"name":"Alice", "username": "alice", "age": 22}' | jq
|
|
107
|
-
{
|
|
108
|
-
"status": "success",
|
|
109
|
-
"error": "",
|
|
110
|
-
"data": {
|
|
111
|
-
"id": "16d483c6-0eb1-4104-b07b-32f3d736223f",
|
|
112
|
-
"name": "Alice",
|
|
113
|
-
"username": "alice",
|
|
114
|
-
"age": 22,
|
|
115
|
-
"created_at": "2025-06-10T12:42:59+00:00",
|
|
116
|
-
"updated_at": "2025-06-10T12:42:59+00:00"
|
|
117
|
-
},
|
|
118
|
-
"pagination": {},
|
|
119
|
-
"input_errors": {}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
$ curl 'http://localhost:8080/users/8bd9c03f-bb0c-41bd-afbc-f9526ded88f4' | jq
|
|
123
|
-
{
|
|
124
|
-
"status": "success",
|
|
125
|
-
"error": "",
|
|
126
|
-
"data": {
|
|
127
|
-
"id": "8bd9c03f-bb0c-41bd-afbc-f9526ded88f4",
|
|
128
|
-
"name": "Bob",
|
|
129
|
-
"username": "bob",
|
|
130
|
-
"age": 25,
|
|
131
|
-
"created_at": "2025-06-10T12:39:35+00:00",
|
|
132
|
-
"updated_at": "2025-06-10T12:39:35+00:00"
|
|
133
|
-
},
|
|
134
|
-
"pagination": {},
|
|
135
|
-
"input_errors": {}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
$ curl 'http://localhost:8080/users/16d483c6-0eb1-4104-b07b-32f3d736223f' -d '{"name":"Alice Smith", "age": 23}' -X PATCH | jq
|
|
139
|
-
{
|
|
140
|
-
"status": "success",
|
|
141
|
-
"error": "",
|
|
142
|
-
"data": {
|
|
143
|
-
"id": "16d483c6-0eb1-4104-b07b-32f3d736223f",
|
|
144
|
-
"name": "Alice Smith",
|
|
145
|
-
"username": "alice",
|
|
146
|
-
"age": 23,
|
|
147
|
-
"created_at": "2025-06-10T12:42:59+00:00",
|
|
148
|
-
"updated_at": "2025-06-10T12:45:01+00:00"
|
|
149
|
-
},
|
|
150
|
-
"pagination": {},
|
|
151
|
-
"input_errors": {}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
$ curl 'http://localhost:8080/users/8bd9c03f-bb0c-41bd-afbc-f9526ded88f4' -X DELETE | jq
|
|
155
|
-
{
|
|
156
|
-
"status": "success",
|
|
157
|
-
"error": "",
|
|
158
|
-
"data": {},
|
|
159
|
-
"pagination": {},
|
|
160
|
-
"input_errors": {}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
$ curl 'http://localhost:8080/users/' | jq
|
|
164
|
-
{
|
|
165
|
-
"status": "success",
|
|
166
|
-
"error": "",
|
|
167
|
-
"data": [
|
|
168
|
-
{
|
|
169
|
-
"id": "16d483c6-0eb1-4104-b07b-32f3d736223f",
|
|
170
|
-
"name": "Alice Smith",
|
|
171
|
-
"username": "alice",
|
|
172
|
-
"age": 23,
|
|
173
|
-
"created_at": "2025-06-10T12:42:59+00:00",
|
|
174
|
-
"updated_at": "2025-06-10T12:45:01+00:00"
|
|
175
|
-
}
|
|
176
|
-
],
|
|
177
|
-
"pagination": {
|
|
178
|
-
"number_results": 1,
|
|
179
|
-
"limit": 50,
|
|
180
|
-
"next_page": {}
|
|
181
|
-
},
|
|
182
|
-
"input_errors": {}
|
|
183
|
-
}
|
|
184
|
-
```
|
|
185
|
-
"""
|
|
186
|
-
|
|
187
|
-
"""
|
|
188
|
-
The endpoint class to use for managing the create operation.
|
|
189
|
-
|
|
190
|
-
This defaults to `clearskies.endpoints.Create`. To disable the create operation all together,
|
|
191
|
-
set this to None.
|
|
192
|
-
"""
|
|
193
|
-
create_endpoint = clearskies.configs.Endpoint(default=Create)
|
|
194
|
-
|
|
195
|
-
"""
|
|
196
|
-
The endpoint class to use for managing the delete operation.
|
|
197
|
-
|
|
198
|
-
This defaults to `clearskies.endpoints.Delete`. To disable the delete operation all together,
|
|
199
|
-
set this to None.
|
|
200
|
-
"""
|
|
201
|
-
delete_endpoint = clearskies.configs.Endpoint(default=Delete)
|
|
202
|
-
|
|
203
|
-
"""
|
|
204
|
-
The endpoint class to use for managing the update operation.
|
|
205
|
-
|
|
206
|
-
This defaults to `clearskies.endpoints.Update`. To disable the update operation all together,
|
|
207
|
-
set this to None.
|
|
208
|
-
"""
|
|
209
|
-
update_endpoint = clearskies.configs.Endpoint(default=Update)
|
|
210
|
-
|
|
211
|
-
"""
|
|
212
|
-
The endpoint class to use to fetch individual records.
|
|
213
|
-
|
|
214
|
-
This defaults to `clearskies.endpoints.Get`. To disable the get operation all together,
|
|
215
|
-
set this to None.
|
|
216
|
-
"""
|
|
217
|
-
get_endpoint = clearskies.configs.Endpoint(default=Get)
|
|
218
|
-
|
|
219
|
-
"""
|
|
220
|
-
The endpoint class to use to list records.
|
|
221
|
-
|
|
222
|
-
This defaults to `clearskies.endpoints.SimpleSearch`. To disable the list operation all together,
|
|
223
|
-
set this to None.
|
|
224
|
-
"""
|
|
225
|
-
list_endpoint = clearskies.configs.Endpoint(default=SimpleSearch)
|
|
226
|
-
|
|
227
|
-
"""
|
|
228
|
-
The request method(s) to use to route to the create operation. Default is ["POST"].
|
|
229
|
-
"""
|
|
230
|
-
create_request_methods = clearskies.configs.SelectList(
|
|
231
|
-
allowed_values=["GET", "POST", "PUT", "DELETE", "PATCH"], default=["POST"]
|
|
232
|
-
)
|
|
233
|
-
|
|
234
|
-
"""
|
|
235
|
-
The request method(s) to use to route to the update operation. Default is ["PATCH"].
|
|
236
|
-
"""
|
|
237
|
-
update_request_methods = clearskies.configs.SelectList(
|
|
238
|
-
allowed_values=["GET", "POST", "PUT", "DELETE", "PATCH"], default=["PATCH"]
|
|
239
|
-
)
|
|
240
|
-
|
|
241
|
-
"""
|
|
242
|
-
The request method(s) to use to route to the delete operation. Default is ["DELETE"].
|
|
243
|
-
"""
|
|
244
|
-
delete_request_methods = clearskies.configs.SelectList(
|
|
245
|
-
allowed_values=["GET", "POST", "PUT", "DELETE", "PATCH"], default=["DELETE"]
|
|
246
|
-
)
|
|
247
|
-
|
|
248
|
-
"""
|
|
249
|
-
The request method(s) to use to route to the get operation. Default is ["GET"].
|
|
250
|
-
"""
|
|
251
|
-
get_request_methods = clearskies.configs.SelectList(
|
|
252
|
-
allowed_values=["GET", "POST", "PUT", "DELETE", "PATCH"], default=["GET"]
|
|
253
|
-
)
|
|
254
|
-
|
|
255
|
-
"""
|
|
256
|
-
The request method(s) to use to route to the create operation. Default is ["GET"].
|
|
257
|
-
"""
|
|
258
|
-
list_request_methods = clearskies.configs.SelectList(
|
|
259
|
-
allowed_values=["GET", "POST", "PUT", "DELETE", "PATCH", "QUERY"], default=["GET", "POST", "QUERY"]
|
|
260
|
-
)
|
|
261
|
-
|
|
262
|
-
"""
|
|
263
|
-
The request method(s) to use to route to the create operation. Default is ["POST"].
|
|
264
|
-
"""
|
|
265
|
-
id_column_name = clearskies.configs.ModelColumn("model_class", default=None)
|
|
266
|
-
|
|
267
|
-
"""
|
|
268
|
-
The base URL to be used for all the endpoints.
|
|
269
|
-
"""
|
|
270
|
-
url = clearskies.configs.String(default="")
|
|
271
|
-
|
|
272
|
-
authentication = clearskies.configs.Authentication(default=Public())
|
|
273
|
-
authorization = clearskies.configs.Authorization(default=Authorization())
|
|
274
|
-
output_map = clearskies.configs.Callable(default=None)
|
|
275
|
-
output_schema = clearskies.configs.Schema(default=None)
|
|
276
|
-
model_class = clearskies.configs.ModelClass(default=None)
|
|
277
|
-
readable_column_names = clearskies.configs.ReadableModelColumns("model_class", default=[])
|
|
278
|
-
writeable_column_names = clearskies.configs.WriteableModelColumns("model_class", default=[])
|
|
279
|
-
searchable_column_names = clearskies.configs.SearchableModelColumns("model_class", default=[])
|
|
280
|
-
sortable_column_names = clearskies.configs.ReadableModelColumns("model_class", default=[])
|
|
281
|
-
default_sort_column_name = clearskies.configs.ModelColumn("model_class", required=True)
|
|
282
|
-
default_sort_direction = clearskies.configs.Select(["ASC", "DESC"], default="ASC")
|
|
283
|
-
default_limit = clearskies.configs.Integer(default=50)
|
|
284
|
-
maximum_limit = clearskies.configs.Integer(default=200)
|
|
285
|
-
group_by_column_name = clearskies.configs.ModelColumn("model_class")
|
|
286
|
-
input_validation_callable = clearskies.configs.Callable(default=None)
|
|
287
|
-
include_routing_data_in_request_data = clearskies.configs.Boolean(default=False)
|
|
288
|
-
column_overrides = clearskies.configs.Columns(default={})
|
|
289
|
-
internal_casing = clearskies.configs.Select(["snake_case", "camelCase", "TitleCase"], default="snake_case")
|
|
290
|
-
external_casing = clearskies.configs.Select(["snake_case", "camelCase", "TitleCase"], default="snake_case")
|
|
291
|
-
security_headers = clearskies.configs.SecurityHeaders(default=[])
|
|
292
|
-
description = clearskies.configs.String(default="")
|
|
293
|
-
where = clearskies.configs.Conditions(default=[])
|
|
294
|
-
_descriptor_config_map = None
|
|
295
|
-
|
|
296
|
-
@clearskies.decorators.parameters_to_properties
|
|
297
|
-
def __init__(
|
|
298
|
-
self,
|
|
299
|
-
model_class: type[Model],
|
|
300
|
-
writeable_column_names: list[str],
|
|
301
|
-
readable_column_names: list[str],
|
|
302
|
-
searchable_column_names: list[str],
|
|
303
|
-
sortable_column_names: list[str],
|
|
304
|
-
default_sort_column_name: str,
|
|
305
|
-
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,
|
|
311
|
-
create_request_methods: list[str] = ["POST"],
|
|
312
|
-
update_request_methods: list[str] = ["PATCH"],
|
|
313
|
-
delete_request_methods: list[str] = ["DELETE"],
|
|
314
|
-
get_request_methods: list[str] = ["GET"],
|
|
315
|
-
list_request_methods: list[str] = ["GET"],
|
|
316
|
-
id_column_name: str = "",
|
|
317
|
-
group_by_column_name: str = "",
|
|
318
|
-
input_validation_callable: Callable | None = None,
|
|
319
|
-
include_routing_data_in_request_data: bool = False,
|
|
320
|
-
url: str = "",
|
|
321
|
-
default_sort_direction: str = "ASC",
|
|
322
|
-
default_limit: int = 50,
|
|
323
|
-
maximum_limit: int = 200,
|
|
324
|
-
request_methods: list[str] = ["POST"],
|
|
325
|
-
response_headers: list[str | Callable[..., list[str]]] = [],
|
|
326
|
-
output_map: Callable[..., dict[str, Any]] | None = None,
|
|
327
|
-
output_schema: Schema | None = None,
|
|
328
|
-
column_overrides: dict[str, Column] = {},
|
|
329
|
-
internal_casing: str = "snake_case",
|
|
330
|
-
external_casing: str = "snake_case",
|
|
331
|
-
security_headers: list[SecurityHeader] = [],
|
|
332
|
-
description: str = "",
|
|
333
|
-
authentication: Authentication = Public(),
|
|
334
|
-
authorization: Authorization = Authorization(),
|
|
335
|
-
):
|
|
336
|
-
self.finalize_and_validate_configuration()
|
|
337
|
-
|
|
338
|
-
id_column_name = id_column_name if id_column_name else model_class.id_column_name
|
|
339
|
-
|
|
340
|
-
# figure out which endpoints we actually need
|
|
341
|
-
endpoints_to_build = []
|
|
342
|
-
if not read_only:
|
|
343
|
-
if create_endpoint:
|
|
344
|
-
endpoints_to_build.append(
|
|
345
|
-
{
|
|
346
|
-
"class": create_endpoint,
|
|
347
|
-
"request_methods": create_request_methods,
|
|
348
|
-
}
|
|
349
|
-
)
|
|
350
|
-
if delete_endpoint:
|
|
351
|
-
endpoints_to_build.append(
|
|
352
|
-
{
|
|
353
|
-
"class": delete_endpoint,
|
|
354
|
-
"request_methods": delete_request_methods,
|
|
355
|
-
"url_suffix": f"/:{id_column_name}",
|
|
356
|
-
}
|
|
357
|
-
)
|
|
358
|
-
if update_endpoint:
|
|
359
|
-
endpoints_to_build.append(
|
|
360
|
-
{
|
|
361
|
-
"class": update_endpoint,
|
|
362
|
-
"request_methods": update_request_methods,
|
|
363
|
-
"url_suffix": f"/:{id_column_name}",
|
|
364
|
-
}
|
|
365
|
-
)
|
|
366
|
-
if get_endpoint:
|
|
367
|
-
endpoints_to_build.append(
|
|
368
|
-
{
|
|
369
|
-
"class": get_endpoint,
|
|
370
|
-
"request_methods": get_request_methods,
|
|
371
|
-
"url_suffix": f"/:{id_column_name}",
|
|
372
|
-
}
|
|
373
|
-
)
|
|
374
|
-
if list_endpoint:
|
|
375
|
-
endpoints_to_build.append(
|
|
376
|
-
{
|
|
377
|
-
"class": list_endpoint,
|
|
378
|
-
"request_methods": list_request_methods,
|
|
379
|
-
}
|
|
380
|
-
)
|
|
381
|
-
|
|
382
|
-
# and now build them! Pass along our own kwargs to the endoints when we build them. Now, technically, I
|
|
383
|
-
# know what the kwargs are for each endpoint. However, it would be a lot of duplication to manually
|
|
384
|
-
# instantiate each endpoint and pass along all the kwargs. So, fetch the list of kwargs from our own
|
|
385
|
-
# __init__ and then compare that with the kwargs of the __init__ for each endpoint and map everything
|
|
386
|
-
# automatically like that. Then add in the individual config from above.
|
|
387
|
-
|
|
388
|
-
# these lines take all of the arguments we were initialized with and dumps it into a dict. It's the
|
|
389
|
-
# equivalent of combining both *args and **kwargs without using either
|
|
390
|
-
my_args = inspect.getfullargspec(self.__class__)
|
|
391
|
-
local_variables = inspect.currentframe().f_locals # type: ignore
|
|
392
|
-
available_args = {arg: local_variables[arg] for arg in my_args.args[1:]}
|
|
393
|
-
|
|
394
|
-
# we handle this one manually
|
|
395
|
-
del available_args["url"]
|
|
396
|
-
|
|
397
|
-
# now loop through the list of endpoints
|
|
398
|
-
endpoints = []
|
|
399
|
-
for endpoint_to_build in endpoints_to_build:
|
|
400
|
-
# grab our class and any pre-defined configs
|
|
401
|
-
endpoint_class = endpoint_to_build["class"]
|
|
402
|
-
url_suffix = endpoint_to_build.get("url_suffix")
|
|
403
|
-
|
|
404
|
-
# now get the allowed args out of the init and fill them out with our own.
|
|
405
|
-
endpoint_args = inspect.getfullargspec(endpoint_class)
|
|
406
|
-
nendpoint_args = len(endpoint_args.args)
|
|
407
|
-
nendpoint_kwargs = len(endpoint_args.defaults) if endpoint_args.defaults else 0
|
|
408
|
-
final_args: list[str] = []
|
|
409
|
-
final_kwargs: dict[str, Any] = {}
|
|
410
|
-
for arg in endpoint_args.args[1:]:
|
|
411
|
-
if not available_args.get(arg):
|
|
412
|
-
continue
|
|
413
|
-
final_kwargs[arg] = available_args[arg]
|
|
414
|
-
|
|
415
|
-
if url_suffix:
|
|
416
|
-
final_kwargs["url"] = url_suffix
|
|
417
|
-
final_kwargs["request_methods"] = endpoint_to_build["request_methods"]
|
|
418
|
-
endpoints.append(endpoint_class(*final_args, **final_kwargs)) # type: ignore
|
|
419
|
-
|
|
420
|
-
super().__init__(
|
|
421
|
-
endpoints,
|
|
422
|
-
url=url,
|
|
423
|
-
response_headers=response_headers,
|
|
424
|
-
security_headers=security_headers,
|
|
425
|
-
authentication=authentication,
|
|
426
|
-
authorization=authorization,
|
|
427
|
-
)
|