@@ -9,7 +9,21 @@ SPDX-License-Identifier: MIT
99``` elixir
1010Mix .install (
1111 [
12- {:diffo_example , " ~> 0.2.0" }
12+ {:diffo_example , " ~> 0.2.0" },
13+ {:req , " ~> 0.5" }
14+ ],
15+ config: [
16+ bolty: [{Bolt , [
17+ uri: " bolt://localhost:7687" ,
18+ auth: [username: " neo4j" , password: " password" ],
19+ user_agent: " diffoExampleLivebook/1" ,
20+ pool_size: 15 ,
21+ max_overflow: 3 ,
22+ prefix: :default ,
23+ name: Bolt ,
24+ log: false ,
25+ log_hex: false
26+ ]}]
1327 ],
1428 consolidate_protocols: false
1529)
@@ -37,25 +51,9 @@ The NBN domain models a fictional NBN Ethernet access circuit and its constituen
3751
3852## Installing Neo4j and Configuring Bolty
3953
40- Update the configuration below to match your Neo4j installation and evaluate .
54+ Bolty is configured in the ` Mix.install ` block above — update the Neo4j credentials there if needed before evaluating .
4155
42- ``` elixir
43- config = [
44- uri: " bolt://localhost:7687" ,
45- auth: [username: " neo4j" , password: " password" ],
46- user_agent: " diffoExampleLivebook/1" ,
47- pool_size: 15 ,
48- max_overflow: 3 ,
49- prefix: :default ,
50- name: Bolt ,
51- log: false ,
52- log_hex: false
53- ]
54- ```
55-
56- ``` elixir
57- AshNeo4j .BoltyHelper .start (config)
58- ```
56+ You need [ Neo4j] ( https://neo4j.com/deployment-center/ ) installed and running. Verify the connection:
5957
6058``` elixir
6159AshNeo4j .BoltyHelper .is_connected ()
@@ -148,11 +146,11 @@ nni_group |> Jason.encode!(pretty: true) |> IO.puts
148146Define the NNI Group with an SVLAN assignment and relate the NNI:
149147
150148``` elixir
151- nni_group = Nbn .define_nni_group! (%{
149+ nni_group = Nbn .define_nni_group! (nni_group, %{
152150 characteristic_value_updates: [nni_group: [svlan: 100 ]]
153151})
154152nni_group = Nbn .relate_nni_group! (nni_group, %{
155- relationships: [%{ alias: : nni, target_id: nni.id , type: :isAssigned }]
153+ relationships: [%Diffo . Provider . Instance . Relationship { id: nni.id, alias: : nni , type: :isAssigned }]
156154})
157155nni_group |> Jason .encode! (pretty: true ) |> IO .puts
158156```
@@ -162,7 +160,7 @@ Build a CVC — the aggregation virtual circuit that terminates at the NNI Group
162160``` elixir
163161cvc = Nbn .build_cvc! (%{})
164162cvc = Nbn .relate_cvc! (cvc, %{
165- relationships: [%{ alias: : nni_group, target_id: nni_group.id , type: :isAssigned }]
163+ relationships: [%Diffo . Provider . Instance . Relationship { id: nni_group.id, alias: : nni_group , type: :isAssigned }]
166164})
167165cvc |> Jason .encode! (pretty: true ) |> IO .puts
168166```
@@ -187,7 +185,7 @@ Build a UNI — the interface at the customer premises — and assign a port fro
187185uni = Nbn .build_uni! (%{})
188186alias Diffo .Provider .Assignment
189187ntd = Nbn .assign_port! (ntd, %{
190- assignment: %Assignment {assignee_id: uni.id, value: 1 }
188+ assignment: %Assignment {assignee_id: uni.id, operation: :auto_assign }
191189})
192190ntd |> Jason .encode! (pretty: true ) |> IO .puts
193191```
@@ -196,7 +194,7 @@ Relate the UNI back to the NTD so it can mine technology and port from it:
196194
197195``` elixir
198196uni = Nbn .relate_uni! (uni, %{
199- relationships: [%{ alias: : ntd, target_id: ntd.id , type: :isAssigned }]
197+ relationships: [%Diffo . Provider . Instance . Relationship { id: ntd.id, alias: : ntd , type: :isAssigned }]
200198})
201199uni = Nbn .mine_uni! (uni, %{})
202200uni |> Jason .encode! (pretty: true ) |> IO .puts
@@ -210,7 +208,7 @@ avc = Nbn.define_avc!(avc, %{
210208 characteristic_value_updates: [avc: [bandwidth_profile: :home_ultrafast ]]
211209})
212210cvc = Nbn .assign_cvlan! (cvc, %{
213- assignment: %Assignment {assignee_id: avc.id, value: 200 }
211+ assignment: %Assignment {assignee_id: avc.id, operation: :auto_assign }
214212})
215213avc = Nbn .mine_avc! (avc, %{})
216214avc |> Jason .encode! (pretty: true ) |> IO .puts
@@ -222,8 +220,8 @@ Now build the top-level NBN Ethernet access and relate it to both the UNI and AV
222220pri = Nbn .build_nbn_ethernet! (%{})
223221pri = Nbn .relate_nbn_ethernet! (pri, %{
224222 relationships: [
225- %{ alias: : uni, target_id: uni.id , type: :isAssigned },
226- %{ alias: : avc, target_id: avc.id , type: :isAssigned }
223+ %Diffo . Provider . Instance . Relationship { id: uni.id, alias: : uni , type: :isAssigned },
224+ %Diffo . Provider . Instance . Relationship { id: avc.id, alias: : avc , type: :isAssigned }
227225 ]
228226})
229227pri = Nbn .mine_nbn_ethernet! (pri, %{})
@@ -246,6 +244,28 @@ Or from Elixir:
246244AshNeo4j .Cypher .run (" MATCH (n1)-[r]->(n2) RETURN r, n1, n2 LIMIT 50" )
247245```
248246
247+ ## JSON API
248+
249+ The NBN domain exposes a JSON API via ` Plug.Cowboy ` on port 4000. Start the server in your application before evaluating these cells.
250+
251+ First check the catalog — all NBN specifications are initialised on startup:
252+
253+ ``` elixir
254+ Req .get! (" http://localhost:4000/catalog" ).body |> Jason .encode! (pretty: true ) |> IO .puts ()
255+ ```
256+
257+ Now retrieve all NBN Ethernet instances:
258+
259+ ``` elixir
260+ Req .get! (" http://localhost:4000/nbnEthernet" ).body |> Jason .encode! (pretty: true ) |> IO .puts ()
261+ ```
262+
263+ Or fetch the one we provisioned above by id:
264+
265+ ``` elixir
266+ Req .get! (" http://localhost:4000/nbnEthernet/#{ pri.id } " ).body |> Jason .encode! (pretty: true ) |> IO .puts ()
267+ ```
268+
249269## What Next?
250270
251271You've provisioned a complete NBN Ethernet access — NTD, UNI, AVC, CVC, NNI Group, and NNI — and seen how the ` mine ` actions propagate technology, speeds, CVLAN and port assignments up the resource hierarchy automatically.
0 commit comments