Created: 2023-08-07 | Updated: 2024-05-17

Vertices & Edges

Table of contents

  1. Vertex
    1. Vertex without Metadata:
    2. Vertex with Metadata:
  2. Edge
    1. Edge with Label of Actions:

Vertices & Edges are core components of multicloud-diagrams framework. It supports ingestion of these elements through programming API or from YAML-based files.

Vertex

def add_vertex(self, node_id: str, node_name: str, metadata: dict = None, 
               node_type: str = '', layer_name: str = None, layer_id: str = None, 
               style: dict = None, x: int = None, y: int = None)
Mandatory 
node_idunique identifier (FQDN, URL, ARN, etc.) - unique in entire diagram
node_nameany value (FQDN, URL, alpha-numeric value, etc.)
node_typethere is a defined list of supported node_types for rendering (dynamodb, lambda_function, etc.), if node type is not supported, fallback will be used. Each node on documentation page has node_type.
Optional 
metadatakey/value pairs used to represent additional information
layer_namevertices can be added to specific layer, if not specified the default layer is used
layer_idfor programmatic access layers can be referenced also by ID
styleif specified changes default Vertex styling (color, fillColor, opacity, etc.) Check Customization section for more details.
xpositioning Vertex on palette
ypositioning Vertex on palette

Vertex without Metadata:

Code Snippet

# given
mcd = MultiCloudDiagrams()

# when
mcd.add_vertex(node_id="arn:aws:lambda:eu-west-1:123456789012:function:prod-lambda-name",
               node_name='prod-lambda-name',
               node_type='lambda_function')

Rendering:

layers

Vertex with Metadata:

Code Snippet

Metadata is represented as dictionary of key/value pairs. When rendering key is be marked with bold, each key/value pair is located on dedicated line.

# given
mcd = MultiCloudDiagrams()
metadata = {
    "CodeSize": 1234,
    "Handler": "main",
    "Layers": 0,
    "Memory": 128,
    "PackageType": "Zip",
    "Runtime": "go1.x",
    "Timeout": 30,
    "TracingConfig": "{'Mode': 'Active'}",
    "Version": "$LATEST"
}

# when
mcd.add_vertex(node_id="arn:aws:lambda:eu-west-1:123456789012:function:prod-lambda-name",
               node_name='prod-lambda-name',
               node_type='lambda_function',
               metadata=metadata)

Rendering:

layers

Edge

def add_link(self, src_node_id, dst_node_id, action=None)
Mandatory Attributes 
src_node_idRESOURCE_TYPE:ID
dst_node_idRESOURCE_TYPE:ID
Optional Attributes 
actionstring[]

Vertices are connected using Edges. Such edge is build by specifying source and target Vertex IDs. These connections, also can have a series of labels to describe the relation or actions.

node_id has the following syntax: <RESOURCE_TYPE>:<ID>. Examples:

'lambda_function:arn:aws:lambda:eu-west-1:123456789012:function:prod-lambda-name',
'dynamo:arn:aws:dynamodb:eu-west-1:123456789012:table/prod-dynamo-table',

Edge with Label of Actions:

Code Snippet

# given
mcd = MultiCloudDiagrams()
mcd.read_coords_from_file('docs/docs/core-components/output/drawio/edge.drawio')
mcd.add_vertex(node_id="arn:aws:lambda:eu-west-1:123456789012:function:prod-lambda-name",
               node_name='prod-lambda-name',
               node_type='lambda_function')
mcd.add_vertex(node_id='arn:aws:dynamodb:eu-west-1:123456789012:table/prod-dynamo-table',
               node_name='prod-dynamo-table',
               node_type='dynamo')

# when
mcd.add_link('lambda_function:arn:aws:lambda:eu-west-1:123456789012:function:prod-lambda-name',
             'dynamo:arn:aws:dynamodb:eu-west-1:123456789012:table/prod-dynamo-table',
             action=['GET permissions', 'GET userinfo'])

Rendering:

layers

The comprehensive compilation of supported Components, accompanied by their respective syntax, enriched with illustrative code snippets, rendering previews, and credible sources, can be found on appropriate section of this documentation: