api-foundry 0.1.16__tar.gz → 0.1.20__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.
Files changed (44) hide show
  1. {api_foundry-0.1.16 → api_foundry-0.1.20}/.gitignore +3 -1
  2. {api_foundry-0.1.16 → api_foundry-0.1.20}/PKG-INFO +10 -2
  3. api_foundry-0.1.20/api_foundry/__init__.py +6 -0
  4. api_foundry-0.1.20/api_foundry/iac/gateway_spec.py +584 -0
  5. api_foundry-0.1.20/api_foundry/iac/pulumi/api_foundry.py +207 -0
  6. api_foundry-0.1.20/api_foundry/utils/model_factory.py +565 -0
  7. api_foundry-0.1.20/api_foundry/utils/schema_validator.py +197 -0
  8. {api_foundry-0.1.16 → api_foundry-0.1.20}/pyproject.toml +16 -1
  9. api_foundry-0.1.16/api_foundry/__init__.py +0 -0
  10. api_foundry-0.1.16/api_foundry/adapters/adapter.py +0 -67
  11. api_foundry-0.1.16/api_foundry/adapters/case_change_adapter.py +0 -79
  12. api_foundry-0.1.16/api_foundry/adapters/gateway_adapter.py +0 -112
  13. api_foundry-0.1.16/api_foundry/cloudprints/archive_builder.py +0 -6
  14. api_foundry-0.1.16/api_foundry/cloudprints/hash_comparator.py +0 -90
  15. api_foundry-0.1.16/api_foundry/cloudprints/pulumi/lambda_.py +0 -106
  16. api_foundry-0.1.16/api_foundry/cloudprints/pulumi/log_group.pv +0 -18
  17. api_foundry-0.1.16/api_foundry/cloudprints/pulumi/rest_api.py +0 -16
  18. api_foundry-0.1.16/api_foundry/cloudprints/python_archive_builder.py +0 -207
  19. api_foundry-0.1.16/api_foundry/connectors/connection.py +0 -32
  20. api_foundry-0.1.16/api_foundry/connectors/connection_factory.py +0 -110
  21. api_foundry-0.1.16/api_foundry/connectors/oracle_connector.py +0 -29
  22. api_foundry-0.1.16/api_foundry/connectors/postgres_connection.py +0 -105
  23. api_foundry-0.1.16/api_foundry/dao/dao.py +0 -23
  24. api_foundry-0.1.16/api_foundry/dao/operation_dao.py +0 -141
  25. api_foundry-0.1.16/api_foundry/dao/sql_custom_query_handler.py +0 -66
  26. api_foundry-0.1.16/api_foundry/dao/sql_delete_query_handler.py +0 -36
  27. api_foundry-0.1.16/api_foundry/dao/sql_insert_query_handler.py +0 -102
  28. api_foundry-0.1.16/api_foundry/dao/sql_query_handler.py +0 -378
  29. api_foundry-0.1.16/api_foundry/dao/sql_select_query_handler.py +0 -303
  30. api_foundry-0.1.16/api_foundry/dao/sql_subselect_query_handler.py +0 -63
  31. api_foundry-0.1.16/api_foundry/dao/sql_update_query_handler.py +0 -59
  32. api_foundry-0.1.16/api_foundry/iac/gateway_spec.py +0 -632
  33. api_foundry-0.1.16/api_foundry/iac/handler.py +0 -42
  34. api_foundry-0.1.16/api_foundry/iac/pulumi/api_foundry.py +0 -127
  35. api_foundry-0.1.16/api_foundry/operation.py +0 -15
  36. api_foundry-0.1.16/api_foundry/services/service.py +0 -60
  37. api_foundry-0.1.16/api_foundry/services/transactional_service.py +0 -35
  38. api_foundry-0.1.16/api_foundry/utils/model_factory.py +0 -482
  39. api_foundry-0.1.16/api_foundry/utils/spec_handler.py +0 -74
  40. {api_foundry-0.1.16 → api_foundry-0.1.20}/LICENSE +0 -0
  41. {api_foundry-0.1.16 → api_foundry-0.1.20}/api_foundry/scripts/install_secret.py +0 -0
  42. {api_foundry-0.1.16 → api_foundry-0.1.20}/api_foundry/scripts/postgres_to_openapi.py +0 -0
  43. {api_foundry-0.1.16 → api_foundry-0.1.20}/api_foundry/utils/app_exception.py +0 -0
  44. {api_foundry-0.1.16 → api_foundry-0.1.20}/api_foundry/utils/logger.py +0 -0
@@ -2,8 +2,10 @@
2
2
  *.pyc
3
3
  dist/
4
4
  __pycache__/
5
- venv
5
+ venv/
6
+ temp/
6
7
  build/
8
+ volume/
7
9
  coverage.xml
8
10
  htmlcov/
9
11
  .coverage.*
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: api-foundry
3
- Version: 0.1.16
3
+ Version: 0.1.20
4
4
  Summary: The `api_foundry` project is a powerful tool designed to automate the deployment of REST APIs on AWS using Lambda services to access and interact with relational databases (RDBMS). This project leverages the OpenAPI specification to define and manage the APIs
5
5
  Project-URL: Documentation, https://github.com/DanRepik/api-foundry
6
6
  Project-URL: Source, https://github.com/DanRepik/api-foundry
@@ -10,10 +10,18 @@ Classifier: Operating System :: OS Independent
10
10
  Classifier: Programming Language :: Python :: 3.9
11
11
  Requires-Python: >=3.9
12
12
  Requires-Dist: boto3
13
+ Requires-Dist: cloud-foundry
13
14
  Requires-Dist: cryptography
15
+ Requires-Dist: fixture-foundry
14
16
  Requires-Dist: pulumi
15
17
  Requires-Dist: pulumi-aws
16
18
  Requires-Dist: pyhumps
17
19
  Requires-Dist: pyyaml
18
20
  Requires-Dist: requests
19
21
  Requires-Dist: simplejson
22
+ Provides-Extra: dev
23
+ Requires-Dist: api-foundry-query-engine; extra == 'dev'
24
+ Requires-Dist: docker; extra == 'dev'
25
+ Requires-Dist: psycopg2-binary; extra == 'dev'
26
+ Requires-Dist: pulumi-automation; extra == 'dev'
27
+ Requires-Dist: pytest>=7.0; extra == 'dev'
@@ -0,0 +1,6 @@
1
+ # __init__.py
2
+
3
+ from api_foundry.iac.pulumi.api_foundry import APIFoundry
4
+ from cloud_foundry import logger
5
+
6
+ __all__ = ["APIFoundry", "logger"]
@@ -0,0 +1,584 @@
1
+ # gatway_spec.py
2
+
3
+ import copy
4
+ from typing import Any, Optional
5
+
6
+ from cloud_foundry import Function
7
+ from cloud_foundry.utils.aws_openapi_editor import AWSOpenAPISpecEditor
8
+
9
+ from cloud_foundry import logger
10
+
11
+
12
+ log = logger(__name__)
13
+
14
+
15
+ class APISpecEditor:
16
+ api_spec: dict
17
+ function: Optional[Function]
18
+ integrations: list[dict]
19
+
20
+ def __init__(self, *, open_api_spec: Optional[dict], function: Optional[Function]):
21
+ self.function = function
22
+ self.integrations = []
23
+ self.editor = AWSOpenAPISpecEditor(
24
+ copy.deepcopy(open_api_spec) if open_api_spec else None
25
+ )
26
+
27
+ def rest_api_spec(self) -> str:
28
+ schemas = self.editor.get_spec_part(["components", "schemas"], create=False)
29
+ if schemas:
30
+ if isinstance(schemas, dict):
31
+ for schema_name, schema_object in schemas.items():
32
+ self.generate_crud_operations(schema_name, schema_object)
33
+ elif isinstance(schemas, list):
34
+ for schema_object in schemas:
35
+ schema_name = schema_object.get("name", None)
36
+ if schema_name:
37
+ self.generate_crud_operations(schema_name, schema_object)
38
+
39
+ # self.editor.remove_attributes_with_pattern("^x-af-.*$")
40
+
41
+ self.editor.correct_schema_names()
42
+ return self.editor.yaml
43
+
44
+ def add_operation(
45
+ self,
46
+ path: str,
47
+ method: str,
48
+ operation: dict,
49
+ schema_name: str,
50
+ schema_object: dict,
51
+ function: Optional[Function] = None,
52
+ ):
53
+ # Ensure any schema-level permissions are carried onto the operation if not set.
54
+ if "x-af-permissions" not in operation and isinstance(schema_object, dict):
55
+ permissions = schema_object.get("x-af-permissions")
56
+ if permissions:
57
+ operation["x-af-permissions"] = permissions
58
+ self.integrations.append(
59
+ {"path": path, "method": method, "function": function or self.function}
60
+ )
61
+ self.editor.add_operation(
62
+ path=path,
63
+ method=method,
64
+ operation=operation,
65
+ schema_name=schema_name,
66
+ schema_object=schema_object,
67
+ )
68
+
69
+ def generate_regex(self, property: dict[str, Any]) -> str:
70
+ regex_pattern = ""
71
+
72
+ # UUID (either explicit type 'uuid' or string with format 'uuid')
73
+ if property.get("type") == "uuid" or (
74
+ property.get("type") == "string" and property.get("format", None) == "uuid"
75
+ ):
76
+ hex_pat = r"[0-9a-fA-F]"
77
+ regex_pattern = (
78
+ rf"{hex_pat}{{8}}-"
79
+ rf"{hex_pat}{{4}}-"
80
+ rf"[1-5]{hex_pat}{{3}}-"
81
+ rf"[89abAB]{hex_pat}{{3}}-"
82
+ rf"{hex_pat}{{12}}"
83
+ )
84
+
85
+ elif property["type"] == "string" and property.get("format", None) == "date":
86
+ # Assuming ISO 8601 date format (YYYY-MM-DD)
87
+ regex_pattern = r"\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])" # Date part: YYYY-MM-DD
88
+
89
+ elif (
90
+ property["type"] == "string" and property.get("format", None) == "date-time"
91
+ ):
92
+ regex_pattern = (
93
+ r"\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])" # Date part: YYYY-MM-DD
94
+ r"T" # Separator: T
95
+ r"([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])" # Time part: HH:MM:SS
96
+ r"(?:\.\d+)?(?:Z|[+-](?:0[0-9]|1[0-4]):[0-5][0-9])?" # Optional: fractional seconds and timezone
97
+ )
98
+
99
+ elif property["type"] == "string":
100
+ if "pattern" in property:
101
+ regex_pattern = f"{property.get('pattern')}" + regex_pattern
102
+ else:
103
+ max_length = property.get("max_length", 200)
104
+ min_length = property.get("min_length", 0)
105
+ regex_pattern = rf"[\w\s]{min_length},{max_length}" # Allows letters, numbers, and underscores
106
+
107
+ elif property["type"] == "integer":
108
+ signed = property.get("signed", True)
109
+ regex_pattern = r"[\-\+]?\d+" if signed else r"\d+"
110
+
111
+ elif property["type"] == "number":
112
+ regex_pattern = r"[+-]?\d+(\.\d+)?"
113
+
114
+ if len(regex_pattern) == 0:
115
+ regex_pattern = ".*"
116
+
117
+ return (
118
+ rf"^{regex_pattern}$"
119
+ + rf"|^(?:lt::|le::|eq::|ne::|ge::|gt::)?{regex_pattern}$"
120
+ + rf"|^between::{regex_pattern},{regex_pattern}$"
121
+ + rf"|^not-between::{regex_pattern},{regex_pattern},"
122
+ + rf"|^in::{regex_pattern}(,{regex_pattern})*$"
123
+ + rf"|^not-in::{regex_pattern}(,{regex_pattern})*$"
124
+ )
125
+
126
+ def generate_query_parameters(self, schema_object: dict[str, Any]):
127
+ parameters = []
128
+ for (
129
+ property_name,
130
+ property_details,
131
+ ) in self.get_input_properties(schema_object, include_primary_key=True).items():
132
+ parameter = {
133
+ "in": "query",
134
+ "name": property_name,
135
+ "required": False,
136
+ "schema": {
137
+ "type": property_details["type"],
138
+ "pattern": self.generate_regex(property_details),
139
+ }, # Assuming default type is string
140
+ "description": f"Filter by {property_name}",
141
+ }
142
+ parameters.append(parameter)
143
+ return parameters
144
+
145
+ def __list_of_schema(self, schema_name: str):
146
+ return {
147
+ "application/json": {
148
+ "schema": {
149
+ "type": "array",
150
+ "items": {"$ref": f"#/components/schemas/{schema_name}"},
151
+ }
152
+ }
153
+ }
154
+
155
+ def get_primary_key(
156
+ self, schema_object: dict[str, Any]
157
+ ) -> Optional[tuple[str, dict[str, Any]]]:
158
+ for name, property in schema_object["properties"].items():
159
+ if "x-af-primary-key" in property:
160
+ return (name, property)
161
+ return None
162
+
163
+ def get_concurrency_property(
164
+ self, schema_object: dict[str, Any]
165
+ ) -> Optional[tuple[str, dict[str, Any]]]:
166
+ concurrency_property = schema_object.get("x-af-concurrency-control", None)
167
+ if concurrency_property:
168
+ return (
169
+ concurrency_property,
170
+ schema_object["properties"][concurrency_property],
171
+ )
172
+ return None
173
+
174
+ def get_input_properties(
175
+ self, schema_object: dict[str, Any], include_primary_key: bool = False
176
+ ) -> dict[str, Any]:
177
+ # Retrieve primary key and concurrency property if they exist
178
+ primary_key = (
179
+ self.get_primary_key(schema_object) if not include_primary_key else None
180
+ )
181
+ concurrency_property = self.get_concurrency_property(schema_object)
182
+
183
+ result = dict()
184
+ for name, prop in schema_object["properties"].items():
185
+ if "$ref" in prop:
186
+ ref_parts = prop["$ref"].lstrip("#/").split("/")
187
+ referenced_schema = self.editor.get_spec_part(ref_parts)
188
+ if isinstance(referenced_schema, dict):
189
+ prop = {**prop, **referenced_schema}
190
+ prop.pop("$ref")
191
+
192
+ if (
193
+ "x-af-parent-property" not in prop
194
+ and "x-af-child-property" not in prop
195
+ and (
196
+ include_primary_key
197
+ or name != (primary_key[0] if primary_key else None)
198
+ )
199
+ and name != (concurrency_property[0] if concurrency_property else None)
200
+ ):
201
+ result[name] = prop
202
+ return result
203
+
204
+ def get_required_input_properties(
205
+ self,
206
+ schema_object: dict[str, Any],
207
+ input_properties: dict[str, Any],
208
+ ) -> list[str]:
209
+ # Filter the required properties from input properties
210
+ required_properties = schema_object.get("required", [])
211
+ return [name for name in input_properties if name in required_properties]
212
+
213
+ def generate_crud_operations(self, schema_name: str, schema_object: dict):
214
+ path = f"/{schema_name.lower()}"
215
+ self.generate_create_operation(path, schema_name, schema_object)
216
+ self.generate_get_by_id_operation(path, schema_name, schema_object)
217
+ self.generate_get_many_operation(path, schema_name, schema_object)
218
+ self.generate_update_by_id_operation(path, schema_name, schema_object)
219
+ self.generate_update_with_cc_operation(path, schema_name, schema_object)
220
+ self.generate_update_many_operation(path, schema_name, schema_object)
221
+ self.generate_delete_by_id_operation(path, schema_name, schema_object)
222
+ self.generate_delete_with_cc_operation(path, schema_name, schema_object)
223
+ self.generate_delete_many_operation(path, schema_name, schema_object)
224
+
225
+ def generate_create_operation(
226
+ self, path: str, schema_name: str, schema_object: dict[str, Any]
227
+ ):
228
+ primary_key = self.get_primary_key(schema_object)
229
+ include_primary_key = primary_key and primary_key[1].get("key_type") == "manual"
230
+ input_properties = self.get_input_properties(
231
+ schema_object, include_primary_key=include_primary_key or False
232
+ )
233
+ self.add_operation(
234
+ path=path,
235
+ method="post",
236
+ operation={
237
+ "summary": f"Create a new {schema_name}",
238
+ "requestBody": {
239
+ "required": True,
240
+ "content": {
241
+ "application/json": {
242
+ "schema": {
243
+ "type": "object",
244
+ "properties": input_properties,
245
+ "required": self.get_required_input_properties(
246
+ schema_object, input_properties
247
+ ),
248
+ }
249
+ }
250
+ },
251
+ },
252
+ "responses": {
253
+ "201": {
254
+ "description": f"{schema_name} created successfully",
255
+ "content": self.__list_of_schema(schema_name),
256
+ }
257
+ },
258
+ },
259
+ schema_name=schema_name,
260
+ schema_object=schema_object,
261
+ )
262
+
263
+ def generate_get_many_operation(
264
+ self, path: str, schema_name: str, schema_object: dict[str, Any]
265
+ ):
266
+ self.add_operation(
267
+ path=path,
268
+ method="get",
269
+ operation={
270
+ "summary": f"Retrieve all {schema_name}",
271
+ "parameters": self.generate_query_parameters(schema_object),
272
+ "responses": {
273
+ "200": {
274
+ "description": f"A list of {schema_name}.",
275
+ "content": self.__list_of_schema(schema_name),
276
+ }
277
+ },
278
+ },
279
+ schema_name=schema_name,
280
+ schema_object=schema_object,
281
+ )
282
+
283
+ def generate_get_by_id_operation(
284
+ self, path: str, schema_name: str, schema_object: dict[str, Any]
285
+ ):
286
+ key = self.get_primary_key(schema_object)
287
+ if not key:
288
+ return
289
+
290
+ key_name = key[0]
291
+ self.add_operation(
292
+ path=f"{path}/{{{key_name}}}",
293
+ method="get",
294
+ operation={
295
+ "summary": f"Retrieve {schema_name} by {key_name}",
296
+ "parameters": [
297
+ {
298
+ "name": key_name,
299
+ "in": "path",
300
+ "description": f"ID of the {schema_name} to get",
301
+ "required": True,
302
+ "schema": {"type": "string"},
303
+ }
304
+ ],
305
+ "responses": {
306
+ "200": {
307
+ "description": f"A list of {schema_name}.",
308
+ "content": self.__list_of_schema(schema_name),
309
+ }
310
+ },
311
+ },
312
+ schema_name=schema_name,
313
+ schema_object=schema_object,
314
+ )
315
+
316
+ def generate_update_by_id_operation(
317
+ self, path: str, schema_name: str, schema_object: dict[str, Any]
318
+ ):
319
+ concurrency = self.get_concurrency_property(schema_object)
320
+ if concurrency:
321
+ return
322
+
323
+ key = self.get_primary_key(schema_object)
324
+ if not key:
325
+ return
326
+
327
+ key_name = key[0]
328
+ self.add_operation(
329
+ path=f"{path}/{{{key_name}}}",
330
+ method="put",
331
+ operation={
332
+ "summary": f"Update an existing {schema_name} by {key_name}",
333
+ "parameters": [
334
+ {
335
+ "name": key_name,
336
+ "in": "path",
337
+ "description": f"ID of the {schema_name} to update",
338
+ "required": True,
339
+ "schema": {"type": "string"},
340
+ }
341
+ ],
342
+ "requestBody": {
343
+ "required": True,
344
+ "content": {
345
+ "application/json": {
346
+ "schema": {
347
+ "type": "object",
348
+ "properties": self.get_input_properties(schema_object),
349
+ "required": [], # No properties are marked as required
350
+ }
351
+ }
352
+ },
353
+ },
354
+ "responses": {
355
+ "200": {
356
+ "description": f"{schema_name} updated successfully",
357
+ "content": self.__list_of_schema(schema_name),
358
+ }
359
+ },
360
+ },
361
+ schema_name=schema_name,
362
+ schema_object=schema_object,
363
+ )
364
+
365
+ def generate_update_with_cc_operation(
366
+ self, path: str, schema_name: str, schema_object: dict[str, Any]
367
+ ):
368
+ # Update operation
369
+ key = self.get_primary_key(schema_object)
370
+ if not key:
371
+ return
372
+
373
+ key_name = key[0]
374
+ cc_tuple = self.get_concurrency_property(schema_object)
375
+ if not cc_tuple:
376
+ return
377
+
378
+ cc_property_name = cc_tuple[0]
379
+ self.add_operation(
380
+ path=f"{path}/{{{key_name}}}/{cc_property_name}/{{{cc_property_name}}}",
381
+ method="put",
382
+ operation={
383
+ "summary": f"Update an existing {schema_name} by ID",
384
+ "parameters": [
385
+ {
386
+ "name": key_name,
387
+ "in": "path",
388
+ "description": f"ID of the {schema_name} to update",
389
+ "required": True,
390
+ "schema": {"type": "string"},
391
+ },
392
+ {
393
+ "name": cc_property_name,
394
+ "in": "path",
395
+ "description": (
396
+ cc_property_name + " of the " + schema_name + " to update"
397
+ ),
398
+ "required": True,
399
+ "schema": {"type": "string"},
400
+ },
401
+ ],
402
+ "requestBody": {
403
+ "required": False,
404
+ "content": {
405
+ "application/json": {
406
+ "schema": {
407
+ "type": "object",
408
+ "properties": self.get_input_properties(schema_object),
409
+ "required": [],
410
+ }
411
+ }
412
+ },
413
+ },
414
+ "responses": {
415
+ "200": {
416
+ "description": f"{schema_name} updated successfully",
417
+ "content": self.__list_of_schema(schema_name),
418
+ }
419
+ },
420
+ },
421
+ schema_name=schema_name,
422
+ schema_object=schema_object,
423
+ )
424
+
425
+ def generate_update_many_operation(
426
+ self, path: str, schema_name: str, schema_object: dict[str, Any]
427
+ ):
428
+ cc_tuple = self.get_concurrency_property(schema_object)
429
+ if cc_tuple:
430
+ return
431
+
432
+ # Update operation
433
+ self.add_operation(
434
+ path=path,
435
+ method="put",
436
+ operation={
437
+ "summary": f"Update an existing {schema_name} by ID",
438
+ "parameters": self.generate_query_parameters(schema_object),
439
+ "requestBody": {
440
+ "required": False,
441
+ "content": {
442
+ "application/json": {
443
+ "schema": {
444
+ "type": "object",
445
+ "properties": schema_object["properties"],
446
+ "required": [],
447
+ }
448
+ }
449
+ },
450
+ },
451
+ "responses": {
452
+ "200": {
453
+ "description": f"{schema_name} updated successfully",
454
+ "content": self.__list_of_schema(schema_name),
455
+ }
456
+ },
457
+ },
458
+ schema_name=schema_name,
459
+ schema_object=schema_object,
460
+ )
461
+
462
+ # Delete operation
463
+
464
+ def generate_delete_with_cc_operation(
465
+ self, path: str, schema_name: str, schema_object: dict[str, Any]
466
+ ):
467
+ cc_tuple = self.get_concurrency_property(schema_object)
468
+ if not cc_tuple:
469
+ return
470
+
471
+ cc_property_name = cc_tuple[0]
472
+
473
+ key = self.get_primary_key(schema_object)
474
+ if not key:
475
+ return
476
+
477
+ key_name = key[0]
478
+
479
+ self.add_operation(
480
+ path=f"{path}/{{{key_name}}}/{cc_property_name}/{{{cc_property_name}}}",
481
+ method="delete",
482
+ operation={
483
+ "summary": f"Delete an existing {schema_name} by ID",
484
+ "parameters": [
485
+ {
486
+ "name": key_name,
487
+ "in": "path",
488
+ "description": f"ID of the {schema_name} to update",
489
+ "required": True,
490
+ "schema": {"type": "string"},
491
+ },
492
+ {
493
+ "name": cc_property_name,
494
+ "in": "path",
495
+ "description": (
496
+ f"{cc_property_name} of the {schema_name} to update"
497
+ ),
498
+ "required": True,
499
+ "schema": {"type": "string"},
500
+ },
501
+ ],
502
+ "responses": {
503
+ "204": {
504
+ "description": f"{schema_name} deleted successfully",
505
+ "content": self.__list_of_schema(schema_name),
506
+ }
507
+ },
508
+ },
509
+ schema_name=schema_name,
510
+ schema_object=schema_object,
511
+ )
512
+
513
+ def generate_delete_by_id_operation(
514
+ self, path: str, schema_name: str, schema_object: dict[str, Any]
515
+ ):
516
+ if self.get_concurrency_property(schema_object):
517
+ return
518
+
519
+ key = self.get_primary_key(schema_object)
520
+ if not key:
521
+ return
522
+
523
+ key_name = key[0]
524
+
525
+ self.add_operation(
526
+ path=f"{path}/{{{key_name}}}",
527
+ method="delete",
528
+ operation={
529
+ "summary": f"Delete an existing {schema_name} by {key_name}",
530
+ "parameters": [
531
+ {
532
+ "name": key_name,
533
+ "in": "path",
534
+ "description": f"ID of the {schema_name} to update",
535
+ "required": True,
536
+ "schema": {"type": "string"},
537
+ }
538
+ ],
539
+ "responses": {
540
+ "204": {
541
+ "description": f"{schema_name} deleted successfully",
542
+ "content": self.__list_of_schema(schema_name),
543
+ }
544
+ },
545
+ },
546
+ schema_name=schema_name,
547
+ schema_object=schema_object,
548
+ )
549
+
550
+ def generate_delete_many_operation(
551
+ self, path: str, schema_name: str, schema_object: dict[str, Any]
552
+ ):
553
+ if self.get_concurrency_property(schema_object):
554
+ return
555
+
556
+ self.add_operation(
557
+ path=path,
558
+ method="delete",
559
+ operation={
560
+ "summary": f"Delete many existing {schema_name} using query",
561
+ "parameters": self.generate_query_parameters(schema_object),
562
+ "responses": {
563
+ "204": {
564
+ "description": f"{schema_name} deleted successfully",
565
+ "content": self.__list_of_schema(schema_name),
566
+ }
567
+ },
568
+ },
569
+ schema_name=schema_name,
570
+ schema_object=schema_object,
571
+ )
572
+
573
+ def transform_schemas(self, spec_dict):
574
+ for component_name, component_data in (
575
+ spec_dict.get("components", {}).get("schemas", {}).items()
576
+ ):
577
+ # Remove attributes that start with 'x-af'
578
+ attributes_to_remove = [
579
+ key for key in component_data if key.startswith("x-af")
580
+ ]
581
+ for attribute in attributes_to_remove:
582
+ component_data.pop(attribute)
583
+
584
+ return spec_dict