DSL Extension customising an Instance.
Provides two top-level sections:
structure
Describes the static shape of the Instance kind — what it is, what values it carries,
and what parties it relates to. All structure declarations are baked into the resource
module at compile time via persisters and are introspectable at runtime via
Diffo.Provider.Instance.Info or directly as generated functions on the resource module.
specification do— the TMF Specification (id, name, type, version, description, category). The id is a stable UUID4 that is the same across all environments for this Instance kind.characteristics do— typed value slots carried by instances of this kind, each backed by anAsh.TypedStruct.features do— optional capabilities of this kind, each with its own typed characteristic payload and an enabled/disabled default.parties do— the party roles that instances of this kind relate to, with multiplicity, reference, and calculation options.places do— the place roles that instances of this kind relate to, mirroringparties doin structure and options.
behaviour
Declares which Ash actions should be wired for instance build lifecycle management.
Currently supports create declarations; future sections will cover triggers and other
lifecycle concerns.
Declaring create :name in behaviour do actions do causes the TransformBehaviour
transformer to inject :specified_by, :features, and :characteristics arguments onto
the named Ash create action. These arguments carry the UUIDs of the TMF entities created
by build_before/1 and consumed by the Ash relationship management in the action.
See the DSL cheat sheet for the full DSL reference.
See Diffo.Provider.BaseInstance for full usage documentation including generated functions.
structure
Defines the structural shape of the Instance — its specification, characteristics, features, parties, and places
Nested DSLs
- specification
- characteristics
- characteristic
- features
- feature
- characteristic
- feature
- parties
- party
- parties
- places
- place
- places
Examples
structure do
specification do
id "da9b207a-26c3-451d-8abd-0640c6349979"
name "DSL Access Service"
type :serviceSpecification
end
characteristics do
characteristic :circuit, Diffo.Access.Circuit
end
parties do
party :provider, MyApp.Provider
end
places do
place :installation_site, MyApp.GeographicSite
end
end
structure.specification
Defines the Instance Specification
Examples
specification do
id "da9b207a-26c3-451d-8abd-0640c6349979"
name "DSL Access Service"
type :serviceSpecification
major_version 1
description "An access network service connecting a subscriber premises to an access NNI via DSL"
category "Network Service"
end
Options
| Name | Type | Default | Docs |
|---|---|---|---|
id | String.t | The id of the specification, a uuid4 the same in all environments, unique for name and major_version. | |
name | String.t | The name of the specification, unique to a service but common for all versions. | |
type | atom | :serviceSpecification | The type of the specification. |
major_version | integer | 1 | The major_version of the specification. |
minor_version | integer | The minor_version of the specification. | |
patch_version | integer | The patch_version of the specification. | |
tmf_version | integer | The TMF API version of the specification, e.g. 4. | |
description | String.t | A generic description of the specified service or resource. | |
category | String.t | The category the specified service or resource belongs to. |
structure.characteristics
List of Instance Characteristics
Nested DSLs
Examples
characteristics do
characteristic :dslam, Diffo.Access.Dslam
characteristic :aggregate_interface, Diffo.Access.AggregateInterface
characteristic :circuit, Diffo.Access.Circuit
characteristic :line, Diffo.Access.Line
end
structure.characteristics.characteristic
characteristic name, value_typeAdds a Characteristic
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | The name of the characteristic, an atom | |
value_type | any | The type of the characteristic's value. An atom module name such as an Ash.TypedStruct for a scalar value, or {:array, module} for an array of values of that type. |
structure.features
Configuration for Instance Features
Nested DSLs
- feature
- characteristic
Examples
features do
feature :dynamic_line_management do
is_enabled? true
characteristics do
characteristic :constraints, Diffo.Access.Constraints
end
end
end
structure.features.feature
feature nameAdds a Feature
Nested DSLs
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | The name of the feature, an atom |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
is_enabled? | boolean | Whether the feature is enabled by default, defaults true |
structure.features.feature.characteristic
characteristic name, value_typeAdds a Characteristic
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | The name of the characteristic, an atom | |
value_type | any | The type of the characteristic's value. An atom module name such as an Ash.TypedStruct for a scalar value, or {:array, module} for an array of values of that type. |
structure.parties
List of Instance Party roles
Nested DSLs
Examples
parties do
party :provider, MyApp.Provider, calculate: :provider_calculation
parties :technician, MyApp.Technician, constraints: [min: 1, max: 3]
party :owner, MyApp.InfrastructureCo, reference: true
end
structure.parties.party
party role, party_typeDeclares a singular party role on this Instance
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
role | atom | The role name, an atom | |
party_type | any | The module of the Party kind. An atom module name such as a BaseParty-derived resource. |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
reference | boolean | false | If true, no direct PartyRef edge is created; the party is reachable by graph traversal. |
calculate | atom | Name of an Ash calculation on this resource that produces the party at build time. |
Introspection
Target: Diffo.Provider.Instance.Extension.PartyDeclaration
structure.parties.parties
parties role, party_typeDeclares a plural party role on this Instance
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
role | atom | The role name, an atom | |
party_type | any | The module of the Party kind. An atom module name such as a BaseParty-derived resource. |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
reference | boolean | false | If true, no direct PartyRef edge is created; the party is reachable by graph traversal. |
calculate | atom | Name of an Ash calculation on this resource that produces the party at build time. | |
constraints | keyword | Multiplicity constraints on the number of parties in this role, e.g. [min: 1, max: 3] |
Introspection
Target: Diffo.Provider.Instance.Extension.PartyDeclaration
structure.places
List of Instance Place roles
Nested DSLs
Examples
places do
place :installation_site, MyApp.GeographicSite
places :coverage_areas, MyApp.GeographicLocation, constraints: [min: 1]
place :billing_address, MyApp.GeographicAddress, reference: true
end
structure.places.place
place role, place_typeDeclares a singular place role on this Instance
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
role | atom | The role name, an atom | |
place_type | any | The module of the Place kind. A BasePlace-derived resource. |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
reference | boolean | false | If true, no direct PlaceRef edge is created; the place is reachable by graph traversal. |
calculate | atom | Name of an Ash calculation on this resource that produces the place at build time. |
Introspection
Target: Diffo.Provider.Instance.Extension.PlaceDeclaration
structure.places.places
places role, place_typeDeclares a plural place role on this Instance
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
role | atom | The role name, an atom | |
place_type | any | The module of the Place kind. A BasePlace-derived resource. |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
reference | boolean | false | If true, no direct PlaceRef edge is created; the place is reachable by graph traversal. |
calculate | atom | Name of an Ash calculation on this resource that produces the place at build time. | |
constraints | keyword | Multiplicity constraints on the number of places in this role, e.g. [min: 1, max: 3] |
Introspection
Target: Diffo.Provider.Instance.Extension.PlaceDeclaration
behaviour
Defines the behavioural wiring for the Instance — actions, and in future triggers and tasks
Nested DSLs
- actions
- create
- update
Examples
behaviour do
actions do
create :build
update :define
end
end
behaviour.actions
Declares which actions to wire for instance behaviour
Nested DSLs
Examples
actions do
create :build
update :define
end
behaviour.actions.create
create nameMarks a create action for instance build wiring, injecting :specified_by, :features, and :characteristics arguments
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | The name of the create action to wire |
behaviour.actions.update
update nameMarks an update action for instance behaviour wiring
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | The name of the update action to wire |