Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions .formatter.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,21 @@
# SPDX-License-Identifier: MIT

# Used by "mix format"
locals_without_parens = [
id: 1,
category: 1,
is_enabled?: 1,
characteristic: 2,
pick: 1,
rename: 1,
field: 3,
expect: 1,
relate: 1,
translate: 1,
guard: 1,
customize: 1,
order: 1,
initial_states: 1,
default_initial_state: 1,
state_attribute: 1,
transition: 1
]
locals_without_parens = []

[
plugins: [Spark.Formatter],
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
import_deps: [:ash],
import_deps: [
:diffo,
:ash,
:ash_state_machine,
:ash_neo4j,
:ash_jason,
:ash_outstanding,
:ash_json_api,
:plug
],
locals_without_parens: locals_without_parens,
export: [
locals_without_parens: locals_without_parens
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ diffo-*.tar
.DS_Store

# Agent related
.claude/*
.claude/*
CLAUDE*
14 changes: 14 additions & 0 deletions .igniter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: 2025 diffo_example contributors <https://github.com/diffo-dev/diffo_example/graphs.contributors>
#
# SPDX-License-Identifier: MIT

# This is a configuration file for igniter.
# For option documentation, see https://hexdocs.pm/igniter/Igniter.Project.IgniterConfig.html
# To keep it up to date, use `mix igniter.setup`
[
module_location: :outside_matching_folder,
extensions: [],
deps_location: :last_list_literal,
source_folders: ["lib", "test/support"],
dont_move_files: [~r"lib/mix"]
]
6 changes: 6 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

import Config

config :bolty, Bolt,
uri: "bolt://localhost:7687",
auth: [username: "neo4j", password: "password"],
pool_size: 10,
name: Bolt

if config_env() == :prod do
database_url =
System.get_env("DATABASE_URL") ||
Expand Down
2 changes: 1 addition & 1 deletion lib/access/resources/characteristic_values/cable_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Access.CableValue do

jason do
pick [:name, :pairs, :length, :loss, :technology]
compact(true)
compact true
end

outstanding do
Expand Down
2 changes: 1 addition & 1 deletion lib/access/resources/characteristic_values/card_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Access.CardValue do

jason do
pick [:name, :family, :model, :technology]
compact(true)
compact true
end

outstanding do
Expand Down
2 changes: 1 addition & 1 deletion lib/access/resources/characteristic_values/float_unit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Access.FloatUnit do

jason do
pick [:amount, :unit]
compact(true)
compact true
end

outstanding do
Expand Down
2 changes: 1 addition & 1 deletion lib/access/resources/characteristic_values/integer_unit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Access.IntegerUnit do

jason do
pick [:amount, :unit]
compact(true)
compact true
end

outstanding do
Expand Down
2 changes: 1 addition & 1 deletion lib/access/resources/characteristic_values/path_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Access.PathValue do

jason do
pick [:name, :sections, :length, :loss, :technology]
compact(true)
compact true
end

outstanding do
Expand Down
2 changes: 1 addition & 1 deletion lib/access/resources/characteristic_values/shelf_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Access.ShelfValue do

jason do
pick [:name, :family, :model, :technology]
compact(true)
compact true
end

outstanding do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Access.AggregateInterface do

jason do
pick [:name, :physical_interface, :physical_layer, :link_layer, :svlan_id, :vpi]
compact(true)
compact true

rename physical_interface: "physicalInterface",
physical_layer: "physicalLayer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Access.BandwidthProfile do

jason do
pick [:downstream, :upstream, :units]
compact(true)
compact true
end

outstanding do
Expand Down
2 changes: 1 addition & 1 deletion lib/access/services/characteristic_values/circuit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule DiffoExample.Access.Circuit do

jason do
pick [:circuit_id, :cvlan_id, :vci, :encapsulation, :bandwidth_profile]
compact(true)
compact true
rename circuit_id: "circuitId", vci: "VCI", bandwidth_profile: "bandwidthProfile"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/access/services/characteristic_values/constraints.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Access.Constraints do

jason do
pick [:max_latency, :min_profile]
compact(true)
compact true
rename max_latency: "maxLatency", min_profile: "minProfile"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/access/services/characteristic_values/dslam.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Access.Dslam do

jason do
pick [:name, :family, :model, :technology]
compact(true)
compact true
end

outstanding do
Expand Down
2 changes: 1 addition & 1 deletion lib/access/services/characteristic_values/line.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Access.Line do

jason do
pick [:port, :slot, :standard, :profile]
compact(true)
compact true
end

outstanding do
Expand Down
16 changes: 9 additions & 7 deletions lib/nbn/initializer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ defmodule DiffoExample.Nbn.Initializer do

@rsps [
%{name: "Wedge-tail Telecom", short_name: :wedgetail, id: "0001"},
%{name: "Quokka Connect", short_name: :quokka, id: "0002"},
%{name: "Ibis Telecom", short_name: :ibis, id: "0003"},
%{name: "Taipan Group", short_name: :taipan, id: "0004"},
%{name: "Echidna Networks", short_name: :echidna, id: "0005"},
%{name: "Dugong Digital", short_name: :dugong, id: "0006"},
#%{name: "Lyrebird", short_name: :lyrebird, id: "0007"}
%{name: "Quokka Connect", short_name: :quokka, id: "0002"},
%{name: "Ibis Telecom", short_name: :ibis, id: "0003"},
%{name: "Taipan Group", short_name: :taipan, id: "0004"},
%{name: "Echidna Networks", short_name: :echidna, id: "0005"},
%{name: "Dugong Digital", short_name: :dugong, id: "0006"}
# %{name: "Lyrebird", short_name: :lyrebird, id: "0007"}
]

def init do
Expand All @@ -35,7 +35,9 @@ defmodule DiffoExample.Nbn.Initializer do
{:error, _} -> seed_rsp(attrs)
end
rescue
e -> require Logger; Logger.error("Exception seeding RSP #{attrs.id}: #{inspect(e)}")
e ->
require Logger
Logger.error("Exception seeding RSP #{attrs.id}: #{inspect(e)}")
end
end)
end
Expand Down
2 changes: 0 additions & 2 deletions lib/nbn/nbn.ex
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ defmodule DiffoExample.Nbn do
base_route "/rsp", Rsp do
get :read
end

end
end

Expand Down Expand Up @@ -171,6 +170,5 @@ defmodule DiffoExample.Nbn do
define :suspend_rsp, action: :suspend
define :deactivate_rsp, action: :deactivate
end

end
end
26 changes: 13 additions & 13 deletions lib/nbn/resources/avc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ defmodule DiffoExample.Nbn.Avc do
extensions: [AshJsonApi.Resource],
authorizers: [Ash.Policy.Authorizer]

json_api do
type "avc"
end

resource do
description "An Ash Resource representing an Access Virtual Circuit (AVC)"
plural_name :Avcs
end

json_api do
type "avc"
end

structure do
specification do
id "b2c3d4e5-6f7a-4b8c-9d0e-1f2a3b4c5d6e"
Expand All @@ -54,14 +54,6 @@ defmodule DiffoExample.Nbn.Avc do
end
end

attributes do
attribute :rsp_id, :string do
description "the owning RSP's id — nil for Perentie-managed infrastructure"
allow_nil? true
public? true
end
end

actions do
create :build do
description "creates a new AVC resource instance"
Expand Down Expand Up @@ -115,13 +107,21 @@ defmodule DiffoExample.Nbn.Avc do
end
end

attributes do
attribute :rsp_id, :string do
description "the owning RSP's id — nil for Perentie-managed infrastructure"
allow_nil? true
public? true
end
end

def identifier() do
DiffoExample.Nbn.Util.identifier("AVC")
end

# mines related resource to characteristics
def mine_related(changeset, _context) when is_struct(changeset, Ash.Changeset) do
avc = Ash.load!(changeset.data, [reverse_relationships: [:characteristics]])
avc = Ash.load!(changeset.data, reverse_relationships: [:characteristics])

cvlan = {:cvlan, Diffo.Unwrap.unwrap(hd(hd(avc.reverse_relationships).characteristics).value)}

Expand Down
2 changes: 1 addition & 1 deletion lib/nbn/resources/characteristic_values/avc_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule DiffoExample.Nbn.AvcValue do

jason do
pick [:cvlan, :bandwidth_profile]
compact(true)
compact true
end

outstanding do
Expand Down
2 changes: 1 addition & 1 deletion lib/nbn/resources/characteristic_values/cvc_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Nbn.CvcValue do

jason do
pick [:svlan, :bandwidth]
compact(true)
compact true
end

outstanding do
Expand Down
2 changes: 1 addition & 1 deletion lib/nbn/resources/characteristic_values/nni_group_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Nbn.NniGroupValue do

jason do
pick [:name, :location]
compact(true)
compact true
end

outstanding do
Expand Down
2 changes: 1 addition & 1 deletion lib/nbn/resources/characteristic_values/nni_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule DiffoExample.Nbn.NniValue do

jason do
pick [:port_id, :capacity, :technology]
compact(true)
compact true
rename port_id: "portId"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nbn/resources/characteristic_values/ntd_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule DiffoExample.Nbn.NtdValue do

jason do
pick [:model, :serial_number, :technology]
compact(true)
compact true
end

outstanding do
Expand Down
2 changes: 1 addition & 1 deletion lib/nbn/resources/characteristic_values/pri_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule DiffoExample.Nbn.PriValue do

jason do
pick [:avcid, :uniid, :technology, :bandwidth_profile, :speeds]
compact(true)
compact true
rename avcid: "AVCID", uniid: "UNIID", bandwidth_profile: "bandwidthProfile"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nbn/resources/characteristic_values/uni_value.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule DiffoExample.Nbn.UniValue do

jason do
pick [:port, :encapsulation, :technology]
compact(true)
compact true
end

outstanding do
Expand Down
Loading
Loading