Skip to content

Commit

Permalink
feat: loading mapping between vertex ID and uml actor name
Browse files Browse the repository at this point in the history
  • Loading branch information
tsypuk committed Sep 26, 2023
1 parent 8379611 commit 311e0fb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions multicloud_diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Distribution:

class MultiCloudDiagrams:
def __init__(self, debug_mode=False, shadow=True, layer_name=''):
self.actors_to_nodes = {}
self.mx_file = Et.Element('mxfile',
host="multicloud-diagrams",
agent="PIP package multicloud-diagrams. Generate resources in draw.io compatible format for Cloud infrastructure. Copyrights @ Roman Tsypuk 2023. MIT license.",
Expand Down Expand Up @@ -578,3 +579,12 @@ def extract_info(self, input_string):
return actor1, actor2, message
else:
return None

def read_uml_mappings(self, yaml_name: str):
self.actors_to_nodes = {}
with open(yaml_name, 'r') as file:
data = yaml.safe_load(file)
for vertex in data['nodes']:
node_id = vertex['node_id']
actor = vertex['actor']
self.actors_to_nodes[actor] = node_id
1 change: 1 addition & 0 deletions samples/samples/aws_mermaid_uml.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def main():
mcd.read_coords_from_file(prev_file)
prepare_end2end(mcd)

mcd.read_uml_mappings('uml_mapping.yml')
mcd.read_uml_from_file('uml.mermaid')

mcd.export_to_file(result_file)
Expand Down
13 changes: 13 additions & 0 deletions samples/samples/uml_mapping.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
nodes:
- actor: S3Bucket
node_id: arn:aws:s3:::bucket_name/key_name
- actor: LambdaFunction1
node_id: arn:aws:lambda:eu-west-1:123456789012:function:producer-lambda
- actor: LambdaFunction2
node_id: arn:aws:lambda:eu-west-1:123456789012:function:consumer-lambda
- actor: SNS
node_id: arn:aws:sns:eu-west-1:123456789012:internal.fifo
- actor: SQS
node_id: arn:aws:sqs:eu-west-1:123456789012:int-eu-live-events.fifo
- actor: Storage
node_id: arn:aws:dynamodb:eu-west-1:123456789012:table/table1

0 comments on commit 311e0fb

Please sign in to comment.