# SPDX-FileCopyrightText: 2025 diffo_example contributors # # SPDX-License-Identifier: MIT defmodule DiffoExample.Nbn.Avc do @moduledoc """ Diffo - TMF Service and Resource Management with a difference Avc - Access Virtual Circuit Resource Instance An AVC is the virtual circuit dedicated to an NBN Ethernet circuit, carrying traffic between its related UNI and the CVC that aggregates it. """ alias Diffo.Provider.BaseInstance alias Diffo.Provider.Resource alias DiffoExample.Nbn use Ash.Resource, fragments: [BaseInstance, Resource], domain: Nbn, authorizers: [Ash.Policy.Authorizer] resource do description "An Ash Resource representing an Access Virtual Circuit (AVC)" plural_name :Avcs end provider do specification do id "b2c3d4e5-6f7a-4b8c-9d0e-1f2a3b4c5d6e" name "avc" type :resourceSpecification description "An AVC Resource Instance dedicated to an NBN Ethernet circuit" category "Network Resource" end characteristics do characteristic :avc, DiffoExample.Nbn.AvcCharacteristic # The CVC this AVC is assigned a cvlan from — single-hop via the AVC's # :cvc consumer-alias. Structurally one, so collapse to a single record. inherited_characteristic :cvc, collapse: :first # The NNI Group backing this AVC's CVC — two-hop: AVC's :cvc alias to # the CVC, then the CVC's :nni_group alias to its NNI Group. inherited_characteristic :nni_group, via: [:cvc, :nni_group], collapse: :first end relationships do source :all target :all end behaviour do actions do create :build end end end actions do create :build do description "creates a new AVC resource instance" accept [:id, :which] argument :relationships, {:array, :struct} argument :places, {:array, :struct} argument :parties, {:array, :struct} change set_attribute(:name, &DiffoExample.Nbn.Avc.identifier/0) change set_attribute(:type, :resource) change DiffoExample.Nbn.Changes.SetRspId change load [:href] upsert? false end update :define do description "defines the AVC" argument :characteristic_value_updates, {:array, :term} change set_attribute(:lifecycle_state, :installed) change Diffo.Provider.Changes.Define end update :relate do description "relates the AVC with other instances" argument :relationships, {:array, :struct} change Diffo.Provider.Changes.Relate 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 use DiffoExample.Nbn.RspOwnership end