Skip to content

Commit

Permalink
feat: finished connect_in_graph_for resources
Browse files Browse the repository at this point in the history
  • Loading branch information
1101-1 committed Jun 13, 2024
1 parent 15deee1 commit 51079ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 5 additions & 3 deletions plugins/aws/fix_plugin_aws/resource/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from fix_plugin_aws.resource.base import AwsResource, AwsApiSpec, GraphBuilder
from fix_plugin_aws.utils import TagsValue, ToDict
from fixlib.baseresources import ModelReference
from fixlib.json_bender import Bender, S, ForallBend, Bend, bend
from fixlib.json_bender import Bender, S, ForallBend, Bend
from fixlib.types import Json

log = logging.getLogger("fix.plugins.aws")
Expand Down Expand Up @@ -122,7 +122,7 @@ class AwsBackupProtectedResource(AwsResource):
)
reference_kinds: ClassVar[ModelReference] = {
"predecessors": {"default": ["aws_backup_vault", "aws_backup_recovery_point"]},
"successors": {"default": ["aws_resource"]},
"successors": {"default": ["aws_s3_bucket", "aws_ec2_instance", "aws_ec2_volume","aws_rds_cluster","aws_rds_instance","aws_dynamodb_table","aws_dynamodb_global_table","aws_efs_file_system", "aws_redshift_cluster", "aws_cloudformation_stack"]},
}
api_spec: ClassVar[AwsApiSpec] = AwsApiSpec("backup", "list-protected-resources", "Results")
mapping: ClassVar[Dict[str, Bender]] = {
Expand Down Expand Up @@ -293,7 +293,7 @@ class AwsBackupRecoveryPoint(AwsResource):
"These recovery points are crucial for restoring data during disaster recovery or operational recovery scenarios."
)
reference_kinds: ClassVar[ModelReference] = {
"predecessors": {"default": ["aws_backup_vault"]},
"predecessors": {"default": ["aws_backup_vault", "aws_backup_plan"]},
}
# Resource will be collect by AwsBackupVault
mapping: ClassVar[Dict[str, Bender]] = {
Expand Down Expand Up @@ -352,6 +352,8 @@ class AwsBackupRecoveryPoint(AwsResource):
def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
if backup_vault_name := self.backup_vault_name:
builder.add_edge(self, reverse=True, clazz=AwsBackupVault, name=backup_vault_name)
if (created_by := self.recovery_point_created_by) and (backup_plan_id := created_by.backup_plan_id):
builder.add_edge(self, reverse=True, clazz=AwsBackupPlan, id=backup_plan_id)


@define(eq=False, slots=False)
Expand Down
3 changes: 1 addition & 2 deletions plugins/aws/tools/aws_model_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ def complex_simple_shape(s: Shape) -> Optional[Tuple[str, str]]:
props = []
prefix = prefix or ""
prop_prefix = prop_prefix or ""
result = []

def process_shape_items(shape_items: List[Tuple[Any, Any]], prop_prefix: str, clazz_name: Optional[str]) -> None:
for name, prop_shape in shape_items:
Expand Down Expand Up @@ -242,7 +241,7 @@ def process_shape_items(shape_items: List[Tuple[Any, Any]], prop_prefix: str, cl
elif isinstance(shape, ListShape):
process_shape_items(shape.member.members.items(), prop_prefix, clazz_name)
else:
if (getattr(shape, "members", None) is None) or (getattr(shape, "member", None) is None):
if getattr(shape, "members", None) is None:
return []
process_shape_items(shape.members.items(), prop_prefix, clazz_name)
return result
Expand Down

0 comments on commit 51079ed

Please sign in to comment.