Convert docs to rst and set up platform section
[aai/aai-common.git] / docs / Getting Started / Edge_Rules.rst
1 .. contents::
2    :depth: 3
3 ..
4
5 Edge Rules
6 ==========
7
8 -  `Edge Rules Location <#EdgeRules-EdgeRulesLocation>`__
9
10 -  `How to Interpret an Edge
11    Rule <#EdgeRules-HowtoInterpretanEdgeRule>`__
12
13    -  `Mentally Constructing an
14       Edge <#EdgeRules-MentallyConstructinganEdge>`__
15
16       -  `Quick guide for which is your in node and which is your out
17          node <#EdgeRules-Quickguideforwhichisyourinnod>`__
18
19 -  `How to Read Multiplicity <#EdgeRules-HowtoReadMultiplicity>`__
20
21 -  `Internal Edge Properties <#EdgeRules-InternalEdgeProperties>`__
22
23    -  `Quick guide to our direction
24       syntax: <#EdgeRules-Quickguidetoourdirectionsynta>`__
25
26 Edge Rules Location
27 -------------------
28
29 The edge rules json files are located in
30 aai-common/aai-core/src/main/resources/dbedgerules.
31
32 How to Interpret an Edge Rule
33 -----------------------------
34
35 Mentally Constructing an Edge
36 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37
38 Read the from/to/direction as a recipe for how to construct the edge.
39
40 {
41
42     | "from": "tenant",
43     | "to": "vserver",
44     | "label": "owns",
45     | "direction": "OUT",
46     | "multiplicity": "One2Many",
47     | "contains-other-v": "${direction}",
48     | "delete-other-v": "NONE",
49     | "SVC-INFRA": "!${direction}",
50     | "prevent-delete": "${direction}"
51
52 }
53
54 1. Start by drawing the "from" node.
55
56 2. Draw an edge off this node in the specified. So if it's OUT, point
57    the edge out away from the from node, if it's IN, point it into the
58    node.
59
60 3. Draw the "to" node on the empty end of that edge.
61
62 Essentially, "from" and "to" do not imply direction. Think of them as
63 more like "NodeA" and "NodeB".
64
65 Quick guide for which is your in node and which is your out node
66 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
67
68 +-----------------+---------------+----------------+
69 | **direction**   | **in node**   | **out node**   |
70 +=================+===============+================+
71 | OUT             | to            | from           |
72 +-----------------+---------------+----------------+
73 | IN              | from          | to             |
74 +-----------------+---------------+----------------+
75
76 How to Read Multiplicity
77 ------------------------
78
79 Multiplicity, by itself, has nothing to do with the edge direction or
80 the from/to nodes. Think of it as a property of the edge label. It
81 defines how many IN edges of this label and how many OUT edges of this
82 label are allowed. The format we use is defined by Titan to be In2Out.
83
84 Ex: One2Many means on a node, there may be only one IN edge, and many
85 OUT edges.
86
87 The from and to node types come in on top of this at the A&AI layer.
88 A&AI's code defines which node types may have those IN and OUT edges of
89 this label.
90
91 {
92
93     | "from": "tenant",
94     | "to": "vserver",
95     | "label": "owns",
96     | "direction": "OUT",
97     | "multiplicity": "One2Many",
98     | "contains-other-v": "${direction}",
99     | "delete-other-v": "NONE",
100     | "SVC-INFRA": "!${direction}",
101     | "prevent-delete": "${direction}"
102
103 }
104
105 In this example, the vserver gets the IN edge, so it may have only one
106 edge from a tenant. The tenant gets the OUT edge, so it may get many
107 edges to vservers.
108
109 Internal Edge Properties
110 ------------------------
111
112 A&AI uses the following edge properties for internal processing.
113
114 -  contains-other-v
115
116    -  This property defines whether or not the other vertex is contained
117       within another when rendering the resources view
118
119    -  This property was previously known as isParent
120
121    -  If contains-other-v=OUT, this means that the outVertex contains
122       the inVertex
123
124    -  Or in other words, you can read contains-other-v=OUT as "I am an
125       edge, my OUT vertex contains my IN vertex"
126
127 -  delete-other-v
128
129    -  defines whether or not the other vertex is automatically included
130       in delete processing
131
132    -  this property was previously known as hasDelTarget
133
134    -  if delete-other-v=IN, this means that when deleting the inVertex
135       also delete the outVertex
136
137 -  SVC-INFRA
138
139    -  what direction should the traverser continue in when running
140       edge-tag-query
141
142    -  if SVC-INFRA=OUT, when on the outVertex traverse to the inVertex
143       and continue
144
145 -  prevent-delete
146
147    -  defines whether or not this edge can be deleted from a particular
148       direction
149
150    -  if prevent-delete=IN, prevent the deletion of the inVertex of the
151       edge, allow the outVertex to be deleted.
152
153    -  Or in other words, you can read it as "I am an edge, my IN vertex
154       cannot be deleted"
155
156 Quick guide to our direction syntax:
157 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158
159 ${direction} = same as value of "direction" property
160
161 !${direction} = opposite