api-foundry 0.8.8__tar.gz → 0.8.10__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: api-foundry
3
- Version: 0.8.8
3
+ Version: 0.8.10
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
@@ -1,5 +1,5 @@
1
1
  # __init__.py
2
- __version__ = "0.8.8"
2
+ __version__ = "0.8.10"
3
3
 
4
4
  from api_foundry.iac.pulumi.api_foundry import APIFoundry
5
5
  from cloud_foundry import logger
@@ -214,7 +214,7 @@ class APISpecEditor:
214
214
  else:
215
215
  max_length = property.get("max_length", 200)
216
216
  min_length = property.get("min_length", 0)
217
- regex_pattern = rf"[\w\s]{min_length},{max_length}"
217
+ regex_pattern = rf"[\w\s]{{{min_length},{max_length}}}"
218
218
  # Allows letters, numbers, and underscores
219
219
 
220
220
  elif property["type"] == "integer":
@@ -234,6 +234,8 @@ class APISpecEditor:
234
234
  + rf"|^not-between::{regex_pattern},{regex_pattern},"
235
235
  + rf"|^in::{regex_pattern}(,{regex_pattern})*$"
236
236
  + rf"|^not-in::{regex_pattern}(,{regex_pattern})*$"
237
+ + r"|^like::.+$"
238
+ + r"|^not-like::.+$"
237
239
  )
238
240
 
239
241
  def generate_query_parameters(self, schema_object: dict[str, Any]):
@@ -234,6 +234,7 @@ class APIFoundry(ComponentResource):
234
234
  batch_path=batch_path,
235
235
  token_validators=token_validators,
236
236
  )
237
+ self.api_spec_editor = gateway_spec
237
238
 
238
239
  # Merge gateway_spec.integrations with user-provided integrations
239
240
  specification = gateway_spec.rest_api_spec()
@@ -1,15 +1,16 @@
1
1
  import argparse
2
+ import os
2
3
  import boto3
3
4
  import json
4
5
 
5
6
  from botocore.exceptions import ClientError
6
7
 
7
8
 
8
- def create_secret_if_not_exists(secret_name, secret_value):
9
- # Create a Secrets Manager client
10
- client = boto3.client(
11
- "secretsmanager", endpoint_url="http://localhost.localstack.cloud:4566"
12
- )
9
+ def create_secret_if_not_exists(secret_name, secret_value, endpoint_url=None):
10
+ # Create a Secrets Manager client. endpoint_url is None (real AWS
11
+ # Secrets Manager) unless explicitly overridden, e.g. for testing
12
+ # against LocalStack.
13
+ client = boto3.client("secretsmanager", endpoint_url=endpoint_url)
13
14
 
14
15
  try:
15
16
  # Check if the secret already exists
@@ -55,6 +56,15 @@ def main():
55
56
  parser.add_argument(
56
57
  "--schema", default="public", help="The database schema (default: public)"
57
58
  )
59
+ parser.add_argument(
60
+ "--endpoint-url",
61
+ default=os.environ.get("AWS_ENDPOINT_URL"),
62
+ help=(
63
+ "Optional AWS endpoint URL override, e.g. for testing against "
64
+ "LocalStack. Defaults to the AWS_ENDPOINT_URL environment "
65
+ "variable, or real AWS Secrets Manager if unset."
66
+ ),
67
+ )
58
68
 
59
69
  args = parser.parse_args()
60
70
 
@@ -70,7 +80,7 @@ def main():
70
80
  }
71
81
  )
72
82
 
73
- create_secret_if_not_exists(args.secret_name, secret_value)
83
+ create_secret_if_not_exists(args.secret_name, secret_value, args.endpoint_url)
74
84
 
75
85
 
76
86
  if __name__ == "__main__":
@@ -263,38 +263,24 @@ class SchemaObjectProperty(OpenAPIElement):
263
263
 
264
264
  return soft_delete_config
265
265
 
266
-
267
- class SchemaObjectKey(SchemaObjectProperty):
268
- """Represents a primary key in a schema object."""
269
-
270
- def __init__(self, schema_name: str, name: str, properties: Dict[str, Any]):
271
- super().__init__(schema_name, name, properties)
272
- self.key_type = properties.get("x-af-primary-key", "auto")
273
-
274
- if self.key_type not in ["manual", "uuid", "auto", "sequence"]:
275
- raise ApplicationException(
276
- 500,
277
- (
278
- f"Invalid primary key type '{self.key_type}' "
279
- + f"in schema object '{schema_name}', "
280
- + f"property '{self.api_name}'"
281
- ),
282
- )
283
-
284
- self.sequence_name = (
285
- properties.get("x-af-sequence-name")
286
- if self.key_type == "sequence"
287
- else None
288
- )
289
- if self.key_type == "sequence" and not self.sequence_name:
290
- raise ApplicationException(
291
- 500,
292
- (
293
- "Sequence-based primary keys must have a sequence name in "
294
- + f"schema object '{schema_name}', "
295
- + f"property '{self.api_name}'"
296
- ),
297
- )
266
+ def to_dict(self) -> Dict[str, Any]:
267
+ """
268
+ Convert to a dictionary, recursively converting sub_properties and
269
+ items_sub_properties (dicts of SchemaObjectProperty for embedded
270
+ objects and arrays of embedded objects), which the base
271
+ OpenAPIElement.to_dict() does not recurse into since they are
272
+ plain dicts rather than OpenAPIElement instances themselves.
273
+ """
274
+ data = super().to_dict()
275
+ if self.sub_properties is not None:
276
+ data["sub_properties"] = {
277
+ k: v.to_dict() for k, v in self.sub_properties.items()
278
+ }
279
+ if self.items_sub_properties is not None:
280
+ data["items_sub_properties"] = {
281
+ k: v.to_dict() for k, v in self.items_sub_properties.items()
282
+ }
283
+ return data
298
284
 
299
285
 
300
286
  class SchemaObjectAssociation(OpenAPIElement):
File without changes
File without changes
File without changes