Referencing resources

When defining relations is perspectives, resources are identified by name (except in rare cases when a resource has the id property specified). If a resource name (or id) is unique in an Ilograph diagram, then it can be referenced by name without any qualifiers. If it is not unique, then references to it will need to be qualified in terms of its ancestor resources.

Referencing a child resource

If two are more resources have the same name, they can be distinguished by specifying their parent(s) using xpath-like expressions. To demonstrate this, consider two AWS regions and their availability zones in a resource list:

resources:
...
- name: AWS
  subtitle: Cloud service provider
  children:
    ...
    - name: us-east-1
      subtitle: Region
      color: green
      children:
      - name: AZ1
        subtitle: Availability Zone
        color: darkgreen
        
      - name: AZ2
        subtitle: Availability Zone
        color: darkgreen
        
    - name: us-east-2
      subtitle: Region
      color: green
      children:
      - name: AZ1
        subtitle: Availability Zone
        color: darkgreen
        
      - name: AZ2
        subtitle: Availability Zone
        color: darkgreen
...

Notice that the AZ1 and AZ2 resources appear twice each; they are identical except for their parent resources (us-east-1 and us-east-2). We’ll create a new perspective (called Availability Zone) and reference these resources:

perspectives:
...
- name: Availability Zone
  color: green
  defaultRelationLabel: Runs in
  relations:
    - from: Alpha
      to: us-east-1/AZ1
      
    - from: Bravo
      to: us-east-1/AZ2
      
    - from: Charlie
      to: us-east-2/AZ1
      
    - from: Delta
      to: us-east-2/AZ2

We’ve distinguished the different availability zones by pre-pending the parent resource, followed by a forward slash. This can be done using as many hierarchy levels as needed. When rendered, this perspective looks like so:

Referencing a descendant resource

To reference any descendant resource of a parent resource, use two forward slashes in succession. Consider the following example:

relations:
    ...
    to: us-east-1//Load Balancer
...

In this reference will match a Load Balancer resource that is any descendant resource of a us-east-1 resource. The Load Balancer need not be a direct child of us-east-1.

Ambiguous references

Resource references that are ambiguous (that is, they refer to more than one resource of the same name or id) are allowed in IDL. Ambiguous references will resolve to one of the referenced resources. Which specific resource is resolved in these cases is not defined.

Last updated on 2 Feb 2020
Published on 2 Feb 2020