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
File renamed without changes.
221 changes: 137 additions & 84 deletions diffo.livemd

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions lib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](Https://conventionalcommits.org) for commit guidelines.

<!-- changelog -->

## [v0.1.0](https://github.com/diffo-dev/diffo/compare/v0.1.0...v0.1.0) (2025-08-10)

### Features:
* initial version using Neo4j DataLayer

2 changes: 1 addition & 1 deletion lib/diffo/provider.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ defmodule Diffo.Provider do
define :activate_service, action: :activate
define :suspend_service, action: :suspend
define :terminate_service, action: :terminate
define :status_instance, action: :status
define :status_service, action: :status
define :specify_instance, action: :specify
define :relate_instance_features, action: :relate_features
define :unrelate_instance_features, action: :unrelate_features
Expand Down
26 changes: 13 additions & 13 deletions lib/diffo/provider/resources/instance.ex
Original file line number Diff line number Diff line change
Expand Up @@ -176,26 +176,17 @@ defmodule Diffo.Provider.Instance do

attribute :service_state, :atom do
allow_nil? false
default :initial
default Diffo.Provider.Service.default_service_state()
public? true

constraints one_of: [
:initial,
:cancelled,
:feasibilityChecked,
:reserved,
:active,
:inactive,
:suspended,
:terminated
]
constraints one_of: Diffo.Provider.Service.service_states()
end

attribute :service_operating_status, :atom do
description "the service operating status, if this instance is a service"
allow_nil? true
public? true
default Diffo.Provider.Service.default_service_operating_status()
default nil
constraints one_of: Diffo.Provider.Service.service_operating_statuses()
end

Expand Down Expand Up @@ -348,9 +339,18 @@ defmodule Diffo.Provider.Instance do
update :feasibilityCheck do
description "feasibilityChecks a service instance"
require_atomic? false
accept [:service_operating_status]
validate attribute_equals(:type, :service)
change transition_state(:feasibilityChecked)
change set_attribute(:service_operating_status, :pending)

validate argument_in(:service_operating_status, [
nil,
:initial,
:pending,
:unknown,
:feasible,
:not_feasible
])
end

update :reserve do
Expand Down
2 changes: 1 addition & 1 deletion lib/diffo/provider/resources/party_ref.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ defmodule Diffo.Provider.PartyRef do
preparations do
prepare build(
load: [:party],
sort: [role: :asc]
sort: [role: :asc, inserted_at: :desc]
)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/diffo/provider/resources/place_ref.ex
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ defmodule Diffo.Provider.PlaceRef do
preparations do
prepare build(
load: [:place],
sort: [role: :asc]
sort: [role: :asc, inserted_at: :desc]
)
end

Expand Down
2 changes: 2 additions & 0 deletions lib/diffo/provider/service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ defmodule Diffo.Provider.Service do
def service_operating_statuses() do
[
:pending,
:feasible,
:not_feasible,
:configured,
:starting,
:running,
Expand Down
6 changes: 3 additions & 3 deletions lib/diffo/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,9 @@ defmodule Diffo.Util do
## Examples
iex> duration = Duration.new!(month: 1)
iex> list = [duration: duration]
iex> result = Diffo.Util.extract_suppress(list, :duration, :month, :months)
iex> List.last(result)
{:months, 1}
iex> tl(Diffo.Util.extract_suppress(list, :duration, :month, :months))
[months: 1]

"""
def extract_suppress(list, tuple_key, map_key, new_tuple_key) when is_list(list) do
tuple_value = get(list, tuple_key)
Expand Down
52 changes: 36 additions & 16 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
defmodule Diffo.MixProject do
@moduledoc false
use Mix.Project

@version "0.1.0"
@name "Diffo"
@description "TMF Service and Resource Manager with a difference"
@github_url "https://github.com/diffo-dev/diffo"

def project do
[
app: :diffo,
version: "0.1.0",
version: @version,
name: @name,
description: @description,
elixir: "~> 1.18",
start_permanent: Mix.env() == :prod,
package: package(),
deps: deps(),
aliases: aliases(),
elixirc_paths: elixirc_paths(Mix.env()),
name: "Diffo",
source_url: "https://github.com/diffo-dev/diffo/",
homepage_url: "http://diffo.dev/diffo/",
docs: [
main: "Diffo.Provider",
before_closing_body_tag: fn
:html ->
"""
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<script>mermaid.initialize({startOnLoad: true})</script>
"""

_ ->
""
end
]
docs: docs()
]
end

Expand Down Expand Up @@ -55,10 +51,34 @@ defmodule Diffo.MixProject do
end
end

def docs do
[
homepage_url: @github_url,
source_url: @github_url,
source_ref: "v#{@version}",
main: "readme",
logo: "logos/diffo.jpg",
extras: [
"README.md": [title: "Guide"],
"LICENSE.md": [title: "License"]
]
]
end

defp package do
[
name: :diffo,
licenses: ["MIT"],
files: ~w(lib .formatter.exs mix.exs README* LICENSE* documentation),
links: %{
GitHub: @github_url
}
]
end

# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:outstanding, "~> 0.2.3"},
{:ash_outstanding, "~> 0.2.1"},
{:ash_jason, "~> 2.0"},
{:ash_state_machine, "~> 0.2.7"},
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"finch": {:hex, :finch, "0.20.0", "5330aefb6b010f424dcbbc4615d914e9e3deae40095e73ab0c1bb0968933cadf", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.6.2 or ~> 1.7", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 1.1", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2658131a74d051aabfcba936093c903b8e89da9a1b63e430bee62045fa9b2ee2"},
"glob_ex": {:hex, :glob_ex, "0.1.11", "cb50d3f1ef53f6ca04d6252c7fde09fd7a1cf63387714fe96f340a1349e62c93", [:mix], [], "hexpm", "342729363056e3145e61766b416769984c329e4378f1d558b63e341020525de4"},
"hpax": {:hex, :hpax, "1.0.3", "ed67ef51ad4df91e75cc6a1494f851850c0bd98ebc0be6e81b026e765ee535aa", [:mix], [], "hexpm", "8eab6e1cfa8d5918c2ce4ba43588e894af35dbd8e91e6e55c817bca5847df34a"},
"igniter": {:hex, :igniter, "0.6.25", "e2774a4605c2bc9fc38f689232604aea0fc925c7966ae8e928fd9ea2fa9d300c", [:mix], [{:glob_ex, "~> 0.1.7", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:owl, "~> 0.11", [hex: :owl, repo: "hexpm", optional: false]}, {:phx_new, "~> 1.7", [hex: :phx_new, repo: "hexpm", optional: true]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}, {:rewrite, ">= 1.1.1 and < 2.0.0-0", [hex: :rewrite, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.4", [hex: :sourceror, repo: "hexpm", optional: false]}, {:spitfire, ">= 0.1.3 and < 1.0.0-0", [hex: :spitfire, repo: "hexpm", optional: false]}], "hexpm", "b1916e1e45796d5c371c7671305e81277231617eb58b1c120915aba237fbce6a"},
"igniter": {:hex, :igniter, "0.6.26", "a6b4f6680a7e158bd13cd3b2be047102e42c046b3b240578d68d89d1a39a83fa", [:mix], [{:glob_ex, "~> 0.1.7", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:owl, "~> 0.11", [hex: :owl, repo: "hexpm", optional: false]}, {:phx_new, "~> 1.7", [hex: :phx_new, repo: "hexpm", optional: true]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}, {:rewrite, ">= 1.1.1 and < 2.0.0-0", [hex: :rewrite, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.4", [hex: :sourceror, repo: "hexpm", optional: false]}, {:spitfire, ">= 0.1.3 and < 1.0.0-0", [hex: :spitfire, repo: "hexpm", optional: false]}], "hexpm", "a4f8c404fc4cbc05a1b536c8125ae64909e3a02d5f972ffe6a3a2ebd75530f3c"},
"iterex": {:hex, :iterex, "0.1.2", "58f9b9b9a22a55cbfc7b5234a9c9c63eaac26d276b3db80936c0e1c60355a5a6", [:mix], [], "hexpm", "2e103b8bcc81757a9af121f6dc0df312c9a17220f302b1193ef720460d03029d"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"libgraph": {:hex, :libgraph, "0.16.0", "3936f3eca6ef826e08880230f806bfea13193e49bf153f93edcf0239d4fd1d07", [:mix], [], "hexpm", "41ca92240e8a4138c30a7e06466acc709b0cbb795c643e9e17174a178982d6bf"},
Expand Down
32 changes: 28 additions & 4 deletions test/provider/characteristic_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,37 @@ defmodule Diffo.Provider.CharacteristicTest do
@port_range %Diffo.Provider.Characteristic{name: "port", value: 1..4}

gen_nothing_outstanding_test("specific nothing outstanding", @port1, @port1)
gen_result_outstanding_test("specific name and value result", @port1, nil, Ash.Test.strip_metadata(@port1))
gen_result_outstanding_test("specific name result", @port1, @pair1, Ash.Test.strip_metadata(@name_only))
gen_result_outstanding_test("specific value result", @port1, @port3, Ash.Test.strip_metadata(@value_only))

gen_result_outstanding_test(
"specific name and value result",
@port1,
nil,
Ash.Test.strip_metadata(@port1)
)

gen_result_outstanding_test(
"specific name result",
@port1,
@pair1,
Ash.Test.strip_metadata(@name_only)
)

gen_result_outstanding_test(
"specific value result",
@port1,
@port3,
Ash.Test.strip_metadata(@value_only)
)

gen_nothing_outstanding_test("port range nothing outstanding, port1", @port_range, @port1)
gen_nothing_outstanding_test("port range nothing outstanding, port3", @port_range, @port3)
gen_result_outstanding_test("port range name result, pair1", @port_range, @pair1, Ash.Test.strip_metadata(@name_only))

gen_result_outstanding_test(
"port range name result, pair1",
@port_range,
@pair1,
Ash.Test.strip_metadata(@name_only)
)

gen_result_outstanding_test(
"port range value result, port5",
Expand Down
8 changes: 7 additions & 1 deletion test/provider/entity_ref_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,13 @@ defmodule Diffo.Provider.EntityRefTest do
}

gen_nothing_outstanding_test("specific nothing outstanding", @specific_cost, @actual_cost)
gen_result_outstanding_test("specific cost result", @specific_cost, nil, Ash.Test.strip_metadata(@specific_cost))

gen_result_outstanding_test(
"specific cost result",
@specific_cost,
nil,
Ash.Test.strip_metadata(@specific_cost)
)

gen_result_outstanding_test(
"specific role result",
Expand Down
66 changes: 51 additions & 15 deletions test/provider/feature_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -181,29 +181,65 @@ defmodule Diffo.Provider.FeatureTest do

describe "Diffo.Provider outstanding Features" do
use Outstand
@dynamicLineManagementEnabled %Diffo.Provider.Feature{name: :dynamicLineManagement, isEnabled: true}
@dynamicLineManagementDisabled %Diffo.Provider.Feature{name: :dynamicLineManagement, isEnabled: false}
@dynamicLineManagementEnabledSpeed %Diffo.Provider.Feature{name: :dynamicLineManagement, isEnabled: false, characteristics:
[

@dynamicLineManagementEnabled %Diffo.Provider.Feature{
name: :dynamicLineManagement,
isEnabled: true
}
@dynamicLineManagementDisabled %Diffo.Provider.Feature{
name: :dynamicLineManagement,
isEnabled: false
}
@dynamicLineManagementEnabledSpeed %Diffo.Provider.Feature{
name: :dynamicLineManagement,
isEnabled: false,
characteristics: [
%Diffo.Provider.Characteristic{name: :optimiseFor, value: :speed}
]}
]
}

@dynamicLineManagementEnabledStable %Diffo.Provider.Feature{name: :dynamicLineManagement, isEnabled: false, characteristics:
[
@dynamicLineManagementEnabledStable %Diffo.Provider.Feature{
name: :dynamicLineManagement,
isEnabled: false,
characteristics: [
%Diffo.Provider.Characteristic{name: :optimiseFor, value: :stable}
]}
]
}
@name_only %Diffo.Provider.Feature{name: :dynamicLineManagement}
@isEnabled_only %Diffo.Provider.Feature{isEnabled: true}
@isDisabled_only %Diffo.Provider.Feature{isEnabled: false}
@speed_only %Diffo.Provider.Feature{characteristics:
[
@speed_only %Diffo.Provider.Feature{
characteristics: [
%Diffo.Provider.Characteristic{value: :speed}
]}
]
}

gen_nothing_outstanding_test(
"specific nothing outstanding",
@dynamicLineManagementEnabled,
@dynamicLineManagementEnabled
)

gen_result_outstanding_test(
"specific name and isEnabled result",
@dynamicLineManagementEnabled,
nil,
Ash.Test.strip_metadata(@dynamicLineManagementEnabled)
)

gen_nothing_outstanding_test("specific nothing outstanding", @dynamicLineManagementEnabled, @dynamicLineManagementEnabled)
gen_result_outstanding_test("specific name and isEnabled result", @dynamicLineManagementEnabled, nil, Ash.Test.strip_metadata(@dynamicLineManagementEnabled))
gen_result_outstanding_test("specific name result", @dynamicLineManagementEnabled, @isEnabled_only, Ash.Test.strip_metadata(@name_only))
gen_result_outstanding_test("specific isEnabled result", @dynamicLineManagementDisabled, @name_only, Ash.Test.strip_metadata(@isDisabled_only))
gen_result_outstanding_test(
"specific name result",
@dynamicLineManagementEnabled,
@isEnabled_only,
Ash.Test.strip_metadata(@name_only)
)

gen_result_outstanding_test(
"specific isEnabled result",
@dynamicLineManagementDisabled,
@name_only,
Ash.Test.strip_metadata(@isDisabled_only)
)

gen_result_outstanding_test(
"feature characteristic outstanding",
Expand Down
Loading