rn-forge-web 0.3.2__tar.gz → 0.3.3__tar.gz
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.
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/PKG-INFO +2 -2
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/pyproject.toml +8 -8
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/pyproject.toml.orig +8 -8
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/conformance/_platform.py +5 -6
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/conformance/_transfer.py +23 -18
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/transfer.py +36 -28
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/LICENSE +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/README.md +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/__init__.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/asgi.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/auth.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/concurrency.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/conformance/__init__.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/conformance/_pagination.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/conformance/_problem.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/conformance/_shared.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/conformance/_writes.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/conformance/cases.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/conformance/types.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/deprecation.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/exceptions.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/health.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/idempotency.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/merge_patch.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/models.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/openapi.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/operations.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/pagination.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/problem.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/py.typed +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/read_mask.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/security.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/soft_delete.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.3.3}/src/rn_forge/web/tracing.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rn-forge-web
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Framework-agnostic HTTP/API primitives built on rn-forge-commons
|
|
5
5
|
Author: Rohit Narayanan
|
|
6
6
|
Author-email: Rohit Narayanan <rohit.nn@gmail.com>
|
|
@@ -16,7 +16,7 @@ Classifier: Typing :: Typed
|
|
|
16
16
|
Requires-Dist: rn-forge-commons[pydantic]>=0.8.0,<0.11
|
|
17
17
|
Requires-Dist: opentelemetry-api>=1.44
|
|
18
18
|
Requires-Dist: secure>=2.0.1 ; extra == 'security'
|
|
19
|
-
Requires-Dist: assertpy>=2.
|
|
19
|
+
Requires-Dist: assertpy>=2.36.0 ; extra == 'testing'
|
|
20
20
|
Requires-Dist: pytest>=9.1.1 ; extra == 'testing'
|
|
21
21
|
Requires-Python: >=3.14
|
|
22
22
|
Project-URL: Documentation, https://rn-forge.github.io/pykit/packages/rn-forge-web/latest/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "rn-forge-web"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.3"
|
|
4
4
|
description = "Framework-agnostic HTTP/API primitives built on rn-forge-commons"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -26,7 +26,7 @@ email = "rohit.nn@gmail.com"
|
|
|
26
26
|
|
|
27
27
|
[project.optional-dependencies]
|
|
28
28
|
testing = [
|
|
29
|
-
"assertpy>=2.
|
|
29
|
+
"assertpy>=2.36.0",
|
|
30
30
|
"pytest>=9.1.1",
|
|
31
31
|
]
|
|
32
32
|
security = ["secure>=2.0.1"]
|
|
@@ -68,22 +68,22 @@ markers = ["unit: fast isolated tests"]
|
|
|
68
68
|
|
|
69
69
|
[dependency-groups]
|
|
70
70
|
dev = [
|
|
71
|
-
"assertpy>=2.
|
|
71
|
+
"assertpy>=2.36.0",
|
|
72
72
|
"opentelemetry-instrumentation-asgi>=0.65b0",
|
|
73
73
|
"opentelemetry-sdk>=1.44",
|
|
74
74
|
"pyright>=1.1.411",
|
|
75
|
-
"pytest>=9.
|
|
76
|
-
"pytest-asyncio>=1.
|
|
75
|
+
"pytest>=9.2.0",
|
|
76
|
+
"pytest-asyncio>=1.4.1.post1",
|
|
77
77
|
"pytest-cov>=7.1.0",
|
|
78
78
|
"pytest-randomly>=4.1.0",
|
|
79
79
|
"rn-forge-auth>=0.1.0,<0.3",
|
|
80
80
|
"rn-forge-web[security]",
|
|
81
|
-
"ruff>=0.
|
|
81
|
+
"ruff>=0.17.4",
|
|
82
82
|
]
|
|
83
83
|
docs = [
|
|
84
84
|
"mkdocs>=1.6.1",
|
|
85
|
-
"mkdocs-material>=9.
|
|
86
|
-
"mkdocstrings[python]>=1.0.
|
|
85
|
+
"mkdocs-material>=9.8.1",
|
|
86
|
+
"mkdocstrings[python]>=1.0.8",
|
|
87
87
|
"opentelemetry-instrumentation-asgi>=0.65b0",
|
|
88
88
|
"rn-forge-auth>=0.1.0,<0.3",
|
|
89
89
|
"rn-forge-web[security]",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "rn-forge-web"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.3"
|
|
4
4
|
description = "Framework-agnostic HTTP/API primitives built on rn-forge-commons"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "Rohit Narayanan", email = "rohit.nn@gmail.com" }]
|
|
@@ -27,7 +27,7 @@ dependencies = [
|
|
|
27
27
|
]
|
|
28
28
|
|
|
29
29
|
[project.optional-dependencies]
|
|
30
|
-
testing = ["assertpy>=2.
|
|
30
|
+
testing = ["assertpy>=2.36.0", "pytest>=9.1.1"]
|
|
31
31
|
# `rn_forge.web.security` only. `secure` is framework-agnostic (no dependencies
|
|
32
32
|
# of its own) and emits the OWASP header preset directly, so it is wrapped
|
|
33
33
|
# rather than hand-rolled.
|
|
@@ -66,23 +66,23 @@ markers = ["unit: fast isolated tests"]
|
|
|
66
66
|
|
|
67
67
|
[dependency-groups]
|
|
68
68
|
dev = [
|
|
69
|
-
"assertpy>=2.
|
|
69
|
+
"assertpy>=2.36.0",
|
|
70
70
|
"opentelemetry-instrumentation-asgi>=0.65b0",
|
|
71
71
|
"opentelemetry-sdk>=1.44",
|
|
72
72
|
"pyright>=1.1.411",
|
|
73
|
-
"pytest>=9.
|
|
74
|
-
"pytest-asyncio>=1.
|
|
73
|
+
"pytest>=9.2.0",
|
|
74
|
+
"pytest-asyncio>=1.4.1.post1",
|
|
75
75
|
"pytest-cov>=7.1.0",
|
|
76
76
|
"pytest-randomly>=4.1.0",
|
|
77
77
|
# The guide examples, which the tests run, import rn-forge-auth.
|
|
78
78
|
"rn-forge-auth>=0.1.0,<0.3",
|
|
79
79
|
"rn-forge-web[security]",
|
|
80
|
-
"ruff>=0.
|
|
80
|
+
"ruff>=0.17.4",
|
|
81
81
|
]
|
|
82
82
|
docs = [
|
|
83
83
|
"mkdocs>=1.6.1",
|
|
84
|
-
"mkdocs-material>=9.
|
|
85
|
-
"mkdocstrings[python]>=1.0.
|
|
84
|
+
"mkdocs-material>=9.8.1",
|
|
85
|
+
"mkdocstrings[python]>=1.0.8",
|
|
86
86
|
"opentelemetry-instrumentation-asgi>=0.65b0",
|
|
87
87
|
"rn-forge-auth>=0.1.0,<0.3",
|
|
88
88
|
"rn-forge-web[security]",
|
|
@@ -28,6 +28,7 @@ _TRACEPARENT: Final = "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"
|
|
|
28
28
|
_READYZ_PATH: Final = "/conformance/readyz"
|
|
29
29
|
|
|
30
30
|
_ECHO_PATH: Final = "/conformance/echo"
|
|
31
|
+
_ORIGIN: Final = "https://example.com"
|
|
31
32
|
|
|
32
33
|
PLATFORM_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
33
34
|
ConformanceCase(
|
|
@@ -263,13 +264,11 @@ PLATFORM_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
263
264
|
"configured order. traceresponse is exposed by the OpenTelemetry "
|
|
264
265
|
"response propagator itself, not by this list."
|
|
265
266
|
),
|
|
266
|
-
request=RequestSpec(
|
|
267
|
-
"GET", _ECHO_PATH, headers={"Origin": "https://example.com"}
|
|
268
|
-
),
|
|
267
|
+
request=RequestSpec("GET", _ECHO_PATH, headers={"Origin": _ORIGIN}),
|
|
269
268
|
expect_status=200,
|
|
270
269
|
expect_headers={
|
|
271
270
|
**_JSON,
|
|
272
|
-
"Access-Control-Allow-Origin":
|
|
271
|
+
"Access-Control-Allow-Origin": _ORIGIN,
|
|
273
272
|
"Access-Control-Expose-Headers": ", ".join(
|
|
274
273
|
(*EXPOSED_HEADERS, "traceresponse")
|
|
275
274
|
),
|
|
@@ -286,10 +285,10 @@ PLATFORM_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
286
285
|
request=RequestSpec(
|
|
287
286
|
"GET",
|
|
288
287
|
"/conformance/orders",
|
|
289
|
-
headers={"Accept": _CSV_TYPE, "Origin":
|
|
288
|
+
headers={"Accept": _CSV_TYPE, "Origin": _ORIGIN},
|
|
290
289
|
),
|
|
291
290
|
expect_status=200,
|
|
292
|
-
expect_headers={"Access-Control-Allow-Origin":
|
|
291
|
+
expect_headers={"Access-Control-Allow-Origin": _ORIGIN},
|
|
293
292
|
expect_header_patterns={
|
|
294
293
|
"Content-Type": _CSV_TYPE_PATTERN,
|
|
295
294
|
"Access-Control-Expose-Headers": r"(.+, )?Content-Disposition(, .+)?",
|
|
@@ -27,6 +27,11 @@ from rn_forge.web.problem import (
|
|
|
27
27
|
__all__ = ["TRANSFER_CASES"]
|
|
28
28
|
|
|
29
29
|
_BOOKS_UPDATE: Final = "/conformance/books:batchUpdate"
|
|
30
|
+
_ORDERS_IMPORT: Final = "/conformance/orders:import"
|
|
31
|
+
_MULTIPART: Final = "multipart/form-data"
|
|
32
|
+
_ROWS_INVALID: Final = "One or more rows are invalid."
|
|
33
|
+
_ORDERS_BATCH_CREATE: Final = "/conformance/orders:batchCreate"
|
|
34
|
+
_VALIDATION_ERROR: Final = "Validation Error"
|
|
30
35
|
|
|
31
36
|
_STALE_BOOK: Final = "Precondition failed: expected version 1, got 9"
|
|
32
37
|
|
|
@@ -107,8 +112,8 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
107
112
|
),
|
|
108
113
|
request=RequestSpec(
|
|
109
114
|
"POST",
|
|
110
|
-
|
|
111
|
-
headers={"Content-Type":
|
|
115
|
+
_ORDERS_IMPORT,
|
|
116
|
+
headers={"Content-Type": _MULTIPART},
|
|
112
117
|
query={"validateOnly": "true"},
|
|
113
118
|
body={"file": "id,name,Quantity\n2,gadget,3\n"},
|
|
114
119
|
),
|
|
@@ -125,15 +130,15 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
125
130
|
),
|
|
126
131
|
request=RequestSpec(
|
|
127
132
|
"POST",
|
|
128
|
-
|
|
129
|
-
headers={"Content-Type":
|
|
133
|
+
_ORDERS_IMPORT,
|
|
134
|
+
headers={"Content-Type": _MULTIPART},
|
|
130
135
|
body={"file": "id,name,Quantity\n2,gadget,three\n"},
|
|
131
136
|
),
|
|
132
137
|
expect_status=422,
|
|
133
138
|
expect_headers=_PROBLEM,
|
|
134
139
|
expect_body=_problem_body(
|
|
135
140
|
VALIDATION_ERROR,
|
|
136
|
-
|
|
141
|
+
_ROWS_INVALID,
|
|
137
142
|
errors=[{"pointer": "/rows/0/Quantity", "detail": "Enter a whole number."}],
|
|
138
143
|
),
|
|
139
144
|
),
|
|
@@ -146,7 +151,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
146
151
|
),
|
|
147
152
|
request=RequestSpec(
|
|
148
153
|
"POST",
|
|
149
|
-
|
|
154
|
+
_ORDERS_BATCH_CREATE,
|
|
150
155
|
headers=_JSON,
|
|
151
156
|
body={"requests": [{"name": "ok"}, {}]},
|
|
152
157
|
),
|
|
@@ -154,7 +159,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
154
159
|
expect_headers=_PROBLEM,
|
|
155
160
|
expect_body=_problem_body(
|
|
156
161
|
VALIDATION_ERROR,
|
|
157
|
-
|
|
162
|
+
_ROWS_INVALID,
|
|
158
163
|
errors=[
|
|
159
164
|
{"pointer": "/requests/1/name", "detail": "This field is required."}
|
|
160
165
|
],
|
|
@@ -176,7 +181,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
176
181
|
description="AIP-233: a successful batch is 200 with the created resources under the plural name.",
|
|
177
182
|
request=RequestSpec(
|
|
178
183
|
"POST",
|
|
179
|
-
|
|
184
|
+
_ORDERS_BATCH_CREATE,
|
|
180
185
|
headers=_JSON,
|
|
181
186
|
body={"requests": [{"name": "gadget"}]},
|
|
182
187
|
),
|
|
@@ -261,15 +266,15 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
261
266
|
description="A multipart import with no file part is a 422 naming /file.",
|
|
262
267
|
request=RequestSpec(
|
|
263
268
|
"POST",
|
|
264
|
-
|
|
265
|
-
headers={"Content-Type":
|
|
269
|
+
_ORDERS_IMPORT,
|
|
270
|
+
headers={"Content-Type": _MULTIPART},
|
|
266
271
|
body={},
|
|
267
272
|
),
|
|
268
273
|
expect_status=422,
|
|
269
274
|
expect_headers=_PROBLEM,
|
|
270
275
|
expect_body=_problem_body(
|
|
271
276
|
VALIDATION_ERROR,
|
|
272
|
-
|
|
277
|
+
_VALIDATION_ERROR,
|
|
273
278
|
errors=[{"pointer": "/file", "detail": "This field is required."}],
|
|
274
279
|
),
|
|
275
280
|
),
|
|
@@ -280,7 +285,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
280
285
|
request=RequestSpec(
|
|
281
286
|
"POST",
|
|
282
287
|
"/conformance/capped:import",
|
|
283
|
-
headers={"Content-Type":
|
|
288
|
+
headers={"Content-Type": _MULTIPART},
|
|
284
289
|
body={"file": "id,name,Quantity\n2,a,3\n3,b,4\n"},
|
|
285
290
|
),
|
|
286
291
|
expect_status=422,
|
|
@@ -295,7 +300,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
295
300
|
description="AIP-233: an empty requests list is a 422 naming /requests.",
|
|
296
301
|
request=RequestSpec(
|
|
297
302
|
"POST",
|
|
298
|
-
|
|
303
|
+
_ORDERS_BATCH_CREATE,
|
|
299
304
|
headers=_JSON,
|
|
300
305
|
body={"requests": []},
|
|
301
306
|
),
|
|
@@ -303,7 +308,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
303
308
|
expect_headers=_PROBLEM,
|
|
304
309
|
expect_body=_problem_body(
|
|
305
310
|
VALIDATION_ERROR,
|
|
306
|
-
|
|
311
|
+
_VALIDATION_ERROR,
|
|
307
312
|
errors=[
|
|
308
313
|
{"pointer": "/requests", "detail": "A non-empty list is required."}
|
|
309
314
|
],
|
|
@@ -334,7 +339,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
334
339
|
),
|
|
335
340
|
request=RequestSpec(
|
|
336
341
|
"POST",
|
|
337
|
-
|
|
342
|
+
_ORDERS_BATCH_CREATE,
|
|
338
343
|
headers=_JSON,
|
|
339
344
|
body={"requests": [{"name": "ok"}, {"name": "forbidden"}]},
|
|
340
345
|
),
|
|
@@ -469,7 +474,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
469
474
|
expect_headers=_PROBLEM,
|
|
470
475
|
expect_body=_problem_body(
|
|
471
476
|
VALIDATION_ERROR,
|
|
472
|
-
|
|
477
|
+
_ROWS_INVALID,
|
|
473
478
|
errors=[{"pointer": "/requests/0/patch/name", "detail": NULL_FIELD_DETAIL}],
|
|
474
479
|
),
|
|
475
480
|
),
|
|
@@ -501,7 +506,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
501
506
|
expect_headers=_PROBLEM,
|
|
502
507
|
expect_body=_problem_body(
|
|
503
508
|
VALIDATION_ERROR,
|
|
504
|
-
|
|
509
|
+
_ROWS_INVALID,
|
|
505
510
|
errors=[{"pointer": "/requests/1/id", "detail": "Duplicate id in batch."}],
|
|
506
511
|
),
|
|
507
512
|
),
|
|
@@ -516,7 +521,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
516
521
|
expect_headers=_PROBLEM,
|
|
517
522
|
expect_body=_problem_body(
|
|
518
523
|
VALIDATION_ERROR,
|
|
519
|
-
|
|
524
|
+
_VALIDATION_ERROR,
|
|
520
525
|
errors=[
|
|
521
526
|
{"pointer": "/requests", "detail": "A non-empty list is required."}
|
|
522
527
|
],
|
|
@@ -51,6 +51,7 @@ DUPLICATE_ID_DETAIL: Final = "Duplicate id in batch."
|
|
|
51
51
|
"""The detail for a repeated id in a ``:batchUpdate`` request."""
|
|
52
52
|
|
|
53
53
|
_PATCH_DETAIL: Final = "A merge patch must be a JSON object."
|
|
54
|
+
_VALIDATION_ERROR: Final = "Validation Error"
|
|
54
55
|
_IF_MATCH_DETAIL: Final = "Not a valid string."
|
|
55
56
|
|
|
56
57
|
|
|
@@ -207,7 +208,7 @@ def row_errors_problem(
|
|
|
207
208
|
]
|
|
208
209
|
return render_problem(
|
|
209
210
|
registry or default_registry(),
|
|
210
|
-
ValueError(
|
|
211
|
+
ValueError(_VALIDATION_ERROR),
|
|
211
212
|
instance=instance,
|
|
212
213
|
problem=VALIDATION_ERROR,
|
|
213
214
|
detail="One or more rows are invalid.",
|
|
@@ -221,7 +222,7 @@ def export_cap_problem(
|
|
|
221
222
|
"""Render "the export exceeds *cap* rows" as a 422 problem naming the cap."""
|
|
222
223
|
return render_problem(
|
|
223
224
|
registry or default_registry(),
|
|
224
|
-
ValueError(
|
|
225
|
+
ValueError(_VALIDATION_ERROR),
|
|
225
226
|
instance=instance,
|
|
226
227
|
problem=VALIDATION_ERROR,
|
|
227
228
|
detail=f"The export exceeds the limit of {cap} rows; narrow the filter.",
|
|
@@ -245,7 +246,7 @@ def row_cap_problem(
|
|
|
245
246
|
"""
|
|
246
247
|
return render_problem(
|
|
247
248
|
registry or default_registry(),
|
|
248
|
-
ValueError(
|
|
249
|
+
ValueError(_VALIDATION_ERROR),
|
|
249
250
|
instance=instance,
|
|
250
251
|
problem=VALIDATION_ERROR,
|
|
251
252
|
detail=_cap_detail(kind, cap),
|
|
@@ -291,6 +292,33 @@ class BatchUpdateItem:
|
|
|
291
292
|
if_match: str | None
|
|
292
293
|
|
|
293
294
|
|
|
295
|
+
def _parse_batch_item(
|
|
296
|
+
index: int, entry: object, errors: list[RowError]
|
|
297
|
+
) -> BatchUpdateItem | None:
|
|
298
|
+
fields = cast("dict[str, object]", entry) if isinstance(entry, dict) else {}
|
|
299
|
+
item_id = fields.get("id")
|
|
300
|
+
patch = fields.get("patch")
|
|
301
|
+
if_match = fields.get("ifMatch")
|
|
302
|
+
failed = False
|
|
303
|
+
if isinstance(item_id, bool) or not isinstance(item_id, (str, int)):
|
|
304
|
+
errors.append(RowError(index, "id", REQUIRED_FIELD_DETAIL))
|
|
305
|
+
failed = True
|
|
306
|
+
if not isinstance(patch, dict):
|
|
307
|
+
errors.append(RowError(index, "patch", _PATCH_DETAIL))
|
|
308
|
+
failed = True
|
|
309
|
+
if if_match is not None and not isinstance(if_match, str):
|
|
310
|
+
errors.append(RowError(index, "ifMatch", _IF_MATCH_DETAIL))
|
|
311
|
+
failed = True
|
|
312
|
+
if failed:
|
|
313
|
+
return None
|
|
314
|
+
return BatchUpdateItem(
|
|
315
|
+
index,
|
|
316
|
+
str(item_id),
|
|
317
|
+
cast("dict[str, JsonValue]", patch),
|
|
318
|
+
cast("str | None", if_match),
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
|
|
294
322
|
def parse_batch_update(
|
|
295
323
|
body: object,
|
|
296
324
|
*,
|
|
@@ -325,10 +353,10 @@ def parse_batch_update(
|
|
|
325
353
|
)
|
|
326
354
|
return render_problem(
|
|
327
355
|
registry or default_registry(),
|
|
328
|
-
ValueError(
|
|
356
|
+
ValueError(_VALIDATION_ERROR),
|
|
329
357
|
instance=instance,
|
|
330
358
|
problem=VALIDATION_ERROR,
|
|
331
|
-
detail=
|
|
359
|
+
detail=_VALIDATION_ERROR,
|
|
332
360
|
extensions={"errors": [field_error(("requests",), detail)]},
|
|
333
361
|
)
|
|
334
362
|
entries = cast("list[object]", raw)
|
|
@@ -338,29 +366,9 @@ def parse_batch_update(
|
|
|
338
366
|
items: list[BatchUpdateItem] = []
|
|
339
367
|
errors: list[RowError] = []
|
|
340
368
|
for index, entry in enumerate(entries):
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
if_match = fields.get("ifMatch")
|
|
345
|
-
failed = False
|
|
346
|
-
if isinstance(item_id, bool) or not isinstance(item_id, (str, int)):
|
|
347
|
-
errors.append(RowError(index, "id", REQUIRED_FIELD_DETAIL))
|
|
348
|
-
failed = True
|
|
349
|
-
if not isinstance(patch, dict):
|
|
350
|
-
errors.append(RowError(index, "patch", _PATCH_DETAIL))
|
|
351
|
-
failed = True
|
|
352
|
-
if if_match is not None and not isinstance(if_match, str):
|
|
353
|
-
errors.append(RowError(index, "ifMatch", _IF_MATCH_DETAIL))
|
|
354
|
-
failed = True
|
|
355
|
-
if not failed:
|
|
356
|
-
items.append(
|
|
357
|
-
BatchUpdateItem(
|
|
358
|
-
index,
|
|
359
|
-
str(item_id),
|
|
360
|
-
cast("dict[str, JsonValue]", patch),
|
|
361
|
-
cast("str | None", if_match),
|
|
362
|
-
)
|
|
363
|
-
)
|
|
369
|
+
item = _parse_batch_item(index, entry, errors)
|
|
370
|
+
if item is not None:
|
|
371
|
+
items.append(item)
|
|
364
372
|
if errors:
|
|
365
373
|
raise RowsInvalid(errors, root="requests")
|
|
366
374
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|